Hello I’m a new developer currently exploring procedural terrain generation. I have already implemented a 3d Perlin noise generator and made it generate a 3d map tho it look like this: (looks very swiss cheesy)
I have found this video at timestamp 27:58 he explains “squashing” however Idk how to properly implement it . (btw shout out to Henrik he’s a great resource for procedural generation)
Here’s a snippet of the code:
--SERVICES
local WS = game:GetService("Workspace")
--OBJECTS
local Chunks_Folder = WS:WaitForChild("Chunks")
--VARIABLES
local chunkName = "Chunk_%d X_%d Y_%d Z"
--SETTINGS
local CHUNK_SIZE = 32
local SEED = 0
local RESOLUTION = 10
local AMPLITUDE = 10
local MIN_DENSENESS = 1
local SQUASHING = 1
--FUNCTIONS
local function generateChunk(x: number, y: number, z: number)
--Model container
local chunk = Instance.new("Model")
chunk.Name = string.format(chunkName, x, y, z)
--Generating the blocks
for x = x, x + CHUNK_SIZE - 1 do
for y = y, y + CHUNK_SIZE - 1 do
for z = z, z + CHUNK_SIZE - 1 do
local X = math.noise(y / RESOLUTION, z / RESOLUTION, SEED) * AMPLITUDE
local Y = math.noise(x / RESOLUTION, z / RESOLUTION, SEED) * AMPLITUDE
local Z = math.noise(x / RESOLUTION, y / RESOLUTION, SEED) * AMPLITUDE
local density = X + Y + Z
if density >= MIN_DENSENESS then
local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(1, 1, 1)
part.Position = Vector3.new(x, y, z)
part.Parent = chunk
end
end
end
end
chunk.Parent = WS
end
--RUN CODE
generateChunk(0, -CHUNK_SIZE, 0)
generateChunk(CHUNK_SIZE, -CHUNK_SIZE, 0)
generateChunk(0, -CHUNK_SIZE, CHUNK_SIZE)
generateChunk(CHUNK_SIZE, -CHUNK_SIZE, CHUNK_SIZE)