I created a module that can easily create caves in seconds. At the moment its basically just a tech demo that I may or may not improve on or add to at a later date.
It samples points in 3d space and each point is given a unique perlin noise value. Then it marches over the points uses the noise values to create a cave like stucture.
How to use it
local MarchingCubesService = require(game:GetService("ReplicatedStorage").MarchingCubesService)
local marching = MarchingCubesService.new{
LocalPosition=Vector2.new(0,0), -- the x and z coords of where the caves will be created
LocalSize=Vector3.new(60,60,60), -- the size of the caves
Gap=6 -- the distance in studs between the sample points, this also affects the scale
}
marching:marchAll()
Interesting idea. I hadn’t thought of using MeshParts(?) for generating custom geometry programmatically on Roblox, but based on the videos the result is surprisingly good. How’s the performance considering marching cubes is typically done using a compute shader in game engines that support them?
theres not much you can do to eliminate the triangle effects since the system is created from triangles. If you lower the Gap number then the triangles become smaller and therefore less noticeable.
mm, what about making the triangle also thicker? I am wondering about player bleed through if your head is close the to top of the terrain, like ur camera pans through it
the first link you mentioned is a demo game that uses the same marching cube alogorithm impemented in 2D. The second link you mentioned is the installation for the MarchingCubesService Module.
added more arguements for the MarchingCubesService.new function:
Material (the material of the caves)
Color (the color of the caves)
Smooth (disables interpolation resulting in the caves being less smooth)
NoiseFunc (the function used for calculating the noise of a given point. Must accept "x,y,z" as arguements.)
Here is an updated example of how to use the new arguements.
local MarchingCubesService = require(game:GetService("ReplicatedStorage").MarchingCubesService)
local function noise(x,y,z)
return math.noise(x/40,y/40,z/40)
end
local marching = MarchingCubesService.new{
LocalPosition=Vector2.new(0,0), -- the x and z coords of where the caves will be created
LocalSize=Vector3.new(30,30,30), -- the size of the caves
Gap=10, -- the distance in studs between the sample points, this also affects the scale
Material=Enum.Material.Grass, -- the material of the caves
Color=Color3.fromRGB(111, 126, 62), -- the color of the caves
Smooth=true, -- disables interpolation resulting in the caves being less smooth
NoiseFunc=noise -- the function used for calculating the noise of a given point. Must accept "x,y,z" as arguements.
}
marching:marchAll()