Marching cubes converts an implicit shape into a triangle mesh by sampling a signed distance function (SDF) on a grid. Instead of seeking an exact smooth surface, it chooses a cell size as an acceptable error scale and approximates the surface locally with triangles. section 11.3.1
Each grid cell is classified from the signs at its corners: negative means inside, positive means outside. A configuration of inside and outside corners selects a small surface pattern; symmetric cases reduce the original set to 15 configurations. The 2D counterpart is marching squares, which produces contour segments rather than triangles. section 11.3.1 section 11.7
A practical contouring workflow is:
- Choose a grid resolution that balances tolerable geometric error against mesh size. section 11.3.1 section 11.3
- Sample the SDF at grid corners and identify where neighboring samples change sign. section 11.3.1
- Place the selected segments or triangles in each cell; linear interpolation can improve their positions along grid edges. section 11.3.1
- Use the resulting mesh when SDF-based Boolean operations, offsets, repair, or interpolation must return to a triangulated representation. section 11.3
From a circle to a contour
A circle sampled on a 2D grid becomes line segments that separate positive SDF values from negative ones. A coarse grid can satisfy a numerical error bound yet still look unlike a circle; finer sampling and interpolated edge positions make the contour more convincing. The same cell-by-cell idea extends from squares to 3D cubes and triangles. section 11.3.1
Marching cubes generally suits smooth surfaces. For sharp features, dual contouring is often preferable, though implementations can add sharp-feature restoration or optimize either family for different surface types. Resolution remains the central trade-off: increasing accuracy can sharply increase computation; a stated rule of thumb is that doubling accuracy makes the algorithm four times slower. section 11.3.4
Figure 11.11 Original configurations of triangles substituting the implicit surface in cells. Note that the symmetrical configurations are omitted; otherwise, there would have been 28 = 256 combinations (Jmtrivial, GPL, via Wikimedia Commons).
Inspect the cube surface patterns to see how corner sign combinations become local triangle arrangements. section 11.3.1
