I’m not the best at using perlin noise, mathematically wise. However, how would you make caves off a basic perlin-noise terrain?
Here’s a “test-code”, that I’ll make it better in the future, and turn it into a triangle map.
local p = workspace:WaitForChild('Part');
p.Anchored = true;
local folder = Instance.new'Folder';
folder.Parent = workspace;
folder.Name = 'Parts';
local f = 67
local coeff = 450;
function calc(x,z,o)
local height = 0;
local r = math.random(8,8*2);
for i = 1, r do
height = height + math.noise(x/(coeff/i)+o,z/(coeff/i)+o);
end
height = height/r;
return height;
end
for i = 1, 450 do
for j = 1, 450 do
local new = p:Clone();
new.Parent = folder;
new.Position = Vector3.new(i*new.Size.x, 0+coeff*calc(i,j,f), j*new.Size.z);
end
end
game.Debris:AddItem(p,0);
I don’t know the specifics for part/heightmap terrain (probably a fair bit harder to do) but I do know the specifics for voxel terrain, e.g. smooth terrain.
Personally I use perlin worms. They make for really convincing cave systems!
Here’s an example from a decidedly more blocky voxel engine:
The idea is to create a point in space which randomly moves around, destroying everything in a radius around it. You can vary the radius as well to get a more convincing effect. To do the randomisation, you can use perlin noise to create smoothly changing random values.
Hopefully this at least partially helps you find a solution for your heightmapped terrain generator
yeah, when I first saw it I was pretty impressed too. If you want to see what it might look like in a Roblox implementation, I actually used this technique to generate caves in Project Vox.