I made a 3D Perlin noise terrain generator a while back, and I decided to add ‘Octaves’ to it. Which didn’t do what I thought it would do.
Here is a picture of the terrain without the octaves:
But then this happens when I add 20 octaves:
Is this intended behavior? Or am I not doing some math equation / algorithm correctly?
Here is the code:
local ChunkSize = 64
--math.randomseed(tick())
local Seed = math.random(-1000000000, 1000000000) % math.random(-1000000000, 1000000000)
math.randomseed(Seed)
local Seed = -406931380
local NoiseScale = 34
local Amp = 20
local BlockSize = 4
local MinDensity = -20
local Octaves = 20
print(Seed.."/"..NoiseScale.."/"..Amp)
--357444159/34/40
-- -969535336 Is a cool seed.
spawn(function()
for x = 0, ChunkSize do
for z = 0, ChunkSize do
for y = 0, ChunkSize do
local Xnoise = 0
local Ynoise = 0
local Znoise = 0
Ynoise = math.noise(x / NoiseScale, z / NoiseScale, Seed) * Amp
for i = 0, Octaves do
Xnoise = Xnoise + math.noise(y / NoiseScale, z / NoiseScale, Seed) * Amp
Znoise = Znoise + math.noise(x / NoiseScale, y / NoiseScale, Seed) * Amp
end
local Density = Xnoise + Ynoise + Znoise - y
if Density > MinDensity then
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Anchored = true
Part.Size = Vector3.new(BlockSize, BlockSize, BlockSize)
Part.CFrame = CFrame.new((x - ChunkSize / 2)*BlockSize, y*BlockSize, (z - ChunkSize / 2)*BlockSize)
--workspace.Terrain:FillBlock(Part.CFrame, Vector3.new(BlockSize, BlockSize, BlockSize), Enum.Material.Grass)
--Part:Destroy()
end
end
end
wait()
end
end)
Ignore the vague title for this topic.