# Worley noise fail, still looks pretty cool

I tried making a worley noise algorithm in roblox lua but failed and got something that looks like perlin noise. I still think it’s pretty cool how I intended to make something and then ended up with something else totally different. I had to mess around with tons of values to get something similar to what I wanted and figured I should just settle on this.

`5% chance of point spawn, #3 iteration rate on a 20/20/20 grid`

`5% chance of point spawn, #2 iteration rate on a 20/20/20 grid`

``````local pts = workspace.pts -- folder
local x = 20
local y = 20
local z = 20

local iteration_rate = 2 -- changes size and the third argument in the for loop

-- create points
for _x = -x,x,iteration_rate do
for _y = -y,y,iteration_rate do
for _z = -z,y,iteration_rate do
local chance = math.random(0,100)
if chance >= 95 then -- 5% chance of a point spawning
local p = Instance.new("Part", pts)
p.Anchored = true
p.Size = Vector3.new(iteration_rate,iteration_rate,iteration_rate)
p.Transparency = .9
p.CanCollide = false
p.BrickColor = BrickColor.new('Really red')
p.Position = Vector3.new(_x,_y,_z)

end
end
end
wait()
end

-- create cloudz
for _x = -x,x,iteration_rate do
for _y = -y,y,iteration_rate do
for _z = -z,y,iteration_rate do
local current = Instance.new("Part", workspace)
current.Size = Vector3.new(iteration_rate,iteration_rate,iteration_rate)
current.Position = Vector3.new(_x,_y,_z)
current.Anchored = true
-- find closest point
local scalar = nil
local last = 9999999999999
for iteration,point in pairs(pts:GetChildren()) do
if not scalar or (scalar.Position-point.Position).Magnitude < last then
scalar = point
end
end

local m = ((current.Position-scalar.Position).Magnitude)*5
print(m)
if m > 999 then
current.Color = Color3.fromHSV(0,0,100)
else
current.Color = Color3.fromHSV(0,0,m/10)
end
current.Transparency = m/1000 -- lower than 1, more than 0
end
wait()
end
end

for i,v in pairs(pts:GetChildren()) do
v:Destroy()
end
``````

Any feedback on where I went wrong would be very nice lol

3 Likes

i know absolutely nothing about calculating noise… But Roblox really should add more types of noise,
A math.worleynoise function would be very fun…

Also the noise you created kind of looks like the inside of a tree… its very cool.