Marching Cubes
Marching Cubes is an algorithm that converts a volumetric representation to a dense mesh.
- Divide the Space into Voxels: Split the 3D space into a grid of voxels (cubic cells). The size of each voxel determines the mesh resolution.
- Sample the Eight Vertex Positions: For each voxel, sample the density at the eight vertices (corners). Determine if each vertex is inside or outside the surface based on its density.
- Determine the Triangle Configuration: Each voxel has eight vertices, each with two possible states (inside or outside), yielding 256 possible configurations. Each configuration corresponds to a specific triangulation pattern.
Let’s walk through these steps in more detail.
1. Divide the Space into Voxels
The first step is to divide the 3D space into a grid of voxels. The size of each voxel will determine the resolution of the mesh.
2. Sample the Eight Vertex Positions
For each voxel, the algorithm samples the density at the eight vertices. Depending on the density, each vertex is classified as either inside
or outside
the surface.
3. Determine the Triangle Configuration
Each voxel’s eight vertices can be in two possible states, resulting in $2^8 = 256$ possible configurations. Each configuration corresponds to a specific triangulation pattern.
4. Generate the Mesh
To generate the final mesh, the algorithm “marches” through each voxel and applies the corresponding triangle configuration, hence the name “Marching Cubes”.
This process produces a dense, rough mesh that approximates the surface of the volume.
Limitations
While useful for visualization, Marching Cubes meshes are mostly unsuitable for productions like games due to several limiting factors:
- Polygon Count: High polygon meshes require more computation for rendering, which can significantly impact performance in real-time applications.
- Edge Flow: Poor edge flow affects how the mesh deforms when animated, resulting in undesirable artifacts like creasing and pinching.
- Texturing: The dense and irregular topology complicates UV mapping and texturing, resulting in texture artifacts.
Improvements
Techniques like FlexiCubes address some limitations by allowing the mesh vertices to move, creating smoother surfaces. This approach is used by InstantMesh, the current leading open-source 3D pipeline. However, the resulting meshes remain overly dense and impractical for production.
In Practice
Cleaning up the topology of Marching Cubes output often requires more time and effort than creating a mesh from scratch. This creates a major bottleneck for ML for 3D applications. Gaussian Splatting, as discussed earlier, offers a potential solution to this bottleneck.
However, recent work has emerged that directly addresses this bottleneck, using differentiable techniques to produce low-poly meshes with higher-quality topology. This will be covered in the next section.
< > Update on GitHub