Marching Cubes & smooth terrain problems

Hello,

I’m working on a marching cubes based terrain engine in my spare time. The issue i have currently is the step like nature of the terrain. In some instances slopes will be smooth but only on particular angles. There is a clue here but i have not managed to figure out what’s happening as of yet. Any suggestions appreciated.



Well. Most likely you messed up the implementation of the algorithm.

Marching cubes are supposed to sample distance from the iso-surface at it s corners, using “inside surface/outside of surface” lookup triangulation, AND points used during triangulation are calculated using interpolation of edges… or in other words, the points where iso surface intersects cube edges. Meaning… if you forget about “interpolate values” or “use point where edge intersects the surface” and use cube corner coordinates, you’ll get the steps.

It’ll also help you if you visualize the grid using DrawGizmo renderer. Something like this, for example:

2 Likes

Yeah, I was on a huge marching cube kick for a long, long time and best I can tell is exactly what @neginfinity said.

This is a common problem if you’re using a binary data set.

Marching Cubes generates an approximate “isosurface” - a theoretical shape in a field of samples which has the same value over its entire surface. If you’re using binary data (Empty vs Full) to store your voxels, the surface will always cut through the center of each voxel in your sample grid, since the value between empty and full will always be “half empty”.

Instead, try representing your voxels using something like a floating-point density function. Higher values are more dense, and values with a density of 0 are open air. This will create the smoother mesh you’re looking for.

1 Like