loading...
Cover image for Marching Cubes - 3D Animated Process

Marching Cubes - 3D Animated Process

sketchpunk profile image SketchPunk ・2 min read

So marching cubes is the same thing as marching squares but in the third dimension. So the process is still the same, you have a grid of points which you can define as True/False or On/Off. Then you process the 3d grid 8 points at a time that defines a cube or a voxel. The points are still defined with bit wise values, but now there is 8 of them instead of 4.

8 Bits gives you a total of 256 combinations that can be generated. But worry not, there around 20 possible ways to draw triangles in the voxel, the rest are just copies in various rotations. Luckily for us, its fairly easy to find all the combinations online that we can just copy and use in our projects. For my example, I used the data from boristhebrave.com.

So in this demo, i defined a 3D grid of points. Then process through all points using 3D perlin noise to set the point as ON or Off. Then loops through one voxel at a time and it draw one or a few triangles in that area based on which of the 8 points are set to on. As a result you get an idea of what Perlin Noise Looks like in a three dimensional way.

Hopefully this sample would help people learn the algorithm since its a big part of procedural generation. Oskar if you know him, uses this a lot in building his games and demos.

[ DEMO ]
https://sketchpunk.bitbucket.io/src/fungi_v5/002_marching_cube_anim.html

[ SOURCE CODE ]
https://bitbucket.org/sketchpunk/sketchpunk.bitbucket.io/src/master/src/fungi_v5/002_marching_cube_anim.html

[ RELATED LINKS ]
https://www.boristhebrave.com/2018/04/15/marching-cubes-3d-tutorial/

Posted on by:

sketchpunk profile

SketchPunk

@sketchpunk

10% luck, 20% skill, 15% concentrated power of will. 5% pleasure, 50% pain, And a 100% reason to remember the name.

Discussion

markdown guide
 

It's awesome to see a 3D application of this. Thanks for sharing!

 

np. it was fun to make.