I’m not sure if this is the right category, please let me know if it was. Other than that, let’s get started;
- What does the code do and what are you not satisfied with?
My code takes 3 numbers (coordinates in this case), and returns a material enum and a value (occupancy) to place in the terrain instance, I’m not satisfied with the basic noise method I wrote here, I would like some proper cliffs, and overhangs, I know this is possible with 3D noise, but that doesn’t satisfy me enough.
- What potential improvements have you considered?
I’ve considered making the procedural terrain generator more realistic, with cliffs, overhangs, and caves.
- How (specifically) do you want to improve the code?
This is not really anything about code improvement, this is just about improving the looks of the terrain using code. I would want to improve the code, as mentioned above:
I’ve considered making the procedural terrain generator more realistic, with cliffs, overhangs, and caves
Reference code:
-- This is just a reference code, I did something a little better in the main code.
-- I'm still not satisfied with the main code either.
local function basic(pos) -- Assume this is the function I currently have.
local mat, occ = Enum.Material.Air, 0
-- The material, and occupancy values to be set in terrain
local noise = math.noise(pos.x * 0.1, pos.y * 0.1, pos.z * 0.1)
local ny = (noise * 16) - pos.y
local diff = math.clamp(ny, 0, 1) -- Using diff to clamp the value for the occupancy value
if diff > 0 then -- If there is any value to occupy, then set the material to grass.
mat, occ = Enum.Material.Grass, diff
end
return mat, occ
end
-- After that, just iterate in all directions (x, y, z) in for loops
-- and assign the values to the terrain using WriteVoxels.
-- Note: The function above can generate in negative coordinates,
-- due to non-normalized noise
It would be fun to have a community invent many kinds of procedural terrain methods.