I have a terrain generator that uses 3D Perlin noise to generate terrain, the terrain generator generates terrain around the player instead of a fixed area. However, there is an issue where when the terrain gets really low, there becomes these holes in the ground:
Is there anything I can do to stop these massive holes?
Since I don’t want to show the code that I use to do all the terrain generation, I’m only going to show the code that generates the terrain:
local seed = math.random(-1000000000, 1000000000)
local amp = 200
local fre = 1
local scale = 400
local maxDensity = 0
local size = 256
local frequencyDetail = .3
local scaleDetail = 250
local detailOffset = 1
for x = -size/2, size/2 do
game:GetService("RunService").Stepped:Wait()
for y = -128/2, 128/2 do
for z = -size/2, size/2 do
local aNoise = math.noise(fre * (x / scale), fre * (y / scale), seed) * amp * (math.noise((frequencyDetail) * (x / scaleDetail), (frequencyDetail) * (y / scaleDetail), seed) + detailOffset)
local bNoise = math.noise(fre * (z / scale), fre * (x / scale), seed) * amp * (math.noise((frequencyDetail) * (z / scaleDetail), (frequencyDetail) * (x / scaleDetail), seed) + detailOffset)
local cNoise = math.noise(fre * (y / scale), fre * (z / scale), seed) * amp * (math.noise((frequencyDetail) * (y / scaleDetail), (frequencyDetail) * (z / scaleDetail), seed) + detailOffset)
local density = aNoise + bNoise + cNoise + y
if density < maxDensity then
workspace.Terrain:FillBlock(CFrame.new(x, y, z), Vector3.new(4, 4, 4), Enum.Material.Grass)
end
end
end
end
So can someone please help me stop these holes in the terrain?