Marching Cubes Algorithm

I’ve been trying to generate a cave system for my game for quite a while now, I wanted to use a voxel grid so players can edit and modify terrain to their liking, but I have not found any usable implementations of the Marching Cubes algorithm online and can’t seem to understand how it works. Im looking for a thing that I can give a list of Vector3fs, a corresponding list of Floats (positions and values) and a threashold (any value that excedes this will be included), then spits out a Mesh. I can also look into alternatives if anyone knows of any

It’s older but my open source IsoSurface library uses marching cubes:

…it’s based on the article in GPU Gems.

Demo here:

One of the very early videos here:

but there are others on my channel as well if you search for “IsoSurface”

Someone else took this code and made a modifiable terrain with caves and stuff. I don’t know if anyone forked that before that dev disappeared with all of their stuff.

6 Likes

I think you might be referring to this repo: GitHub - jMonkeyEngine-archive/iso-terrain-jayfella-github: Mirror of jayfella/iso-terrain from github

4 Likes

Note that the GPU gems article is also online:

It’s easy enough to port the idea to Java code. I may be biased because I’d already implemented marching cubes a few times in both C and Java over the years. (Though my implementations back then were much worse than the current version based on that chapter.)

2 Likes