Marching Cubes Linear Interpolation


Marching Cubes Linear Interpolation

In this image I’m playing around with marching cubes. Marching cubes works by treating the world as a large 3D array. Each element of this array can be zero or one. Zero is empty and one is solid. In order to generate triangles from this array you look at a small cube (2x2x2) of data for each array element and then lookup which triangles you should create from a precomputed table. This is what you see on the right side of this image.

On the left I’m using a version of marching cubes that linearly interpolates it’s results based on the input. Instead of using zero or one, each value in the 3D array is between 0 and 7. Zero being empty and seven being solid. By adding just these two extra bits per element, I get the smooth contour on the left.

If you zoom closer into the model you can still see the steps on the left side however they are gradual enough to allow the lighting to look smooth. Both versions of this algorithm produce almost exactly the same number of triangles.