# Help with Perlin Noise generation

Hello!

I am trying to generate a normal perlin noise texture
Example:

When I try to do it, I am continuously getting this:

I am so lost, because it either looks like what was described as “wood” by one resource I read, or it just looks like random noise:

I have determined that firstly, I cannot just use integers in `math.noise`, so I must divide all of the coordinates going into the function by at least 10 so that they become decimals of some sort. I have also determined that the larger the number I divide by, the more it “zooms in”. I want it to zoom in a lot, but I don’t want me resulting texture to look like wood, I want it to look like the nice blurry noise from the first picture.

I am really struggling to understand why this is happening, as terrain generators use `math.noise` and have no problems. Part of my research was trying to find a roblox-provided terrain generator script, because I remember one existing on the old developer hub, but it seems they deleted a lot of the tutorials since the switch, so I was unable to find that.

Help would be greatly appreciated. For context, here is my code:

My perlin noise “generator” function:

``````local function getPerlinValue(x: number, y: number?, z: number?)
y = y or 0
z = z or 0

return math.noise(x/10, y/10, PERLIN_SEED)
end
``````

My “image” generator function:

``````local function generateImage()
clearPartFolder()
for x = -500, 500, 5 do
local f = Instance.new("Folder")
f.Name = x
for y = -500, 500, 5 do
createPart(Vector3.new(x, 50, y), Vector3.new(5, 5, 5), getPerlinValue(x, y), f)
end
f.Parent = partFolder
end
end
``````

And for reference, my part creator function:

``````local function createPart(Position: Vector3, Size: Vector3, Color: number, parent)
local p = Instance.new("Part")
p.Anchored = true
p.Position = Position
p.Size = Size
p.Material = Enum.Material.SmoothPlastic
p.Color = Color3.fromHSV(0, 0, Color* 100)
p.Parent = parent
end
``````

2 Likes

Your colors are looping around because the range is too big. Noise has a range of +/- 1 which fromRGB and fromHSV all have components that must be between 0 and 1

1 Like

Even if I correct for that I still get the same thing.
Corrected line:

``````return (math.clamp(math.noise(x/300, y/300, PERLIN_SEED), -1, 1) + 1) / 2
``````

Result:

1 Like

Okay, I figured it out. It was a dumb goof.

In this line I was treating HSV like it went from 0 to 100:

``````p.Color = Color3.fromHSV(0, 0, Color* 100)
``````

Even though HSV only goes from 0 to 1

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.