# Marching Cube Caverns (Triangulating a noise grid)

Hey everyone, I hope you’re all doing well! I thought it would be cool to try and implement the marching cubes algorithm on Roblox in Lua, and I’m here to share the results! Feel free to take this and learn from it, or use it in a future game idea you may have cooking up!

You can try it out online here: Marching Cubes - Roblox
Or you can download the place file here (38.5 KB)
Or you can clone the git repository here: https://github.com/Imaginaerume/MarchingCubeCaves

# Marching cube caves

A Roblox Lua implementation of the Marching Cubes algorithm, in this case used to generate cool triangular caves and ore veins with Perlin Noise.

## Controls

E: Throw light
Q: Throw sticky light
G: Connect grapple to point
Hold right click: reel in grapple
Spacebar: Stop grappling

## Learning sources

Sebastian Lague

Paul Bourke

48 Likes

Thank you so so much for releasing this! There is a ton of super useful code in the place file and all of it is very well organized. I can’t wait to mess with all this cool stuff.

5 Likes

@Elttob let’s see if the Prodigy of Perlin approves

I haven’t had time to look at the code yet, but I’ve seen Sebastian Lague’s video. What alternative did you use to generating meshes?

In Sebastian’s video, he mentions a triangulation table that contains the vertices for each of the triangles required for a given configuration. Using this table, and a triangulation function, I connect these vertices using two WedgeParts per triangle!

1 Like

This looks fantastic and thanks for sharing. As a roblox coding noob ( I do Unity mainly ) seeing how to dynamically make a mesh is going to be very enlightening for me!

1 Like

Deep rock galactic, am I right?

2 Likes

This is awesome.

The theory behind marching cubes is simple, but unfortunantlly its pretty hard in practice,
roblox terrain has no customizability, only a selection of material, thats why i got intressed in it,

What i love about these modules is the fact that it has everything you need to also make it interactive, thanks to the update function and “explosion” function

There are really few resources like these, i guess most people just use terrain,

Thanks a lot.

2 Likes

This is so cool I was just thinking about it and guess what after watching one of Sebastian’s videos c: . I read the code from the git hub it should have taken lots of time especially figuring out the marching code. I congratulate you.