Skip to content
CoreConcept & Pseudocode EntryAI Reviewed (ai-reviewed)

Marching Cubes (Lorensen-Cline, 256-case table)

Extracts a triangle mesh approximating an isosurface of a 3D scalar grid by classifying each voxel cube's 8 corners against the isovalue and looking up the triangles for that 8-bit corner pattern in a 256-case table (Lorensen and Cline 1987).

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Advanced
Family
Surface Extraction
Tier
Core
Status
Reviewed
Review
AI Reviewed
Sources
3
Formulas
2
Relationships
4
Code example
Not ready
Visualization
Ready
Aliases
Marching Cubes, Lorensen-Cline Marching Cubes

Overview

Classic Marching Cubes visits each grid cube, forms an 8-bit index from which corners lie inside the isosurface, and emits the triangles that the 256-entry case table lists for that index, with vertices interpolated along the crossed cube edges.

Core Concepts

scalar field samplingisovalue thresholding8-bit corner case index256-case triangle tableambiguous face casesedge interpolation

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(N_x N_y N_z)

Average

O(N_x N_y N_z)

Worst

O(N_x N_y N_z)

Space

O(V_mesh + T_mesh)

Interactive Runtime & Memory Budget Calculator

Estimate wall-clock latency, operation count, and working memory for Marching Cubes (Lorensen-Cline, 256-case table) across input scales.

Input Scale N:
JIT-compiled JS/TS (~350M primitive ops/sec)
Est. Average TimeO(N_x N_y N_z)

428.6 µs

60 FPS Frame-Safe (<16ms)~150.0k ops
Est. Worst-Case TimeO(N_x N_y N_z)

428.6 µs

60 FPS Frame-Safe (<16ms)~150.0k ops
Est. Working MemoryO(V_mesh + T_mesh)

1.53 MB

Standard Heap FitN=100,000

When to Use

  • Use it for fast, table-driven isosurface extraction from regular voxel grids when an approximate visual mesh is enough.
  • Use a disambiguated variant (asymptotic decider, Marching Cubes 33) or the tetrahedral variant when crack-free, topologically consistent output is required.

When Not to Use

  • Do not rely on the original 15-case table for meshes that must be watertight or manifold (finite-element meshing, 3D printing): ambiguous faces can produce holes.
  • Avoid it for sharp CAD features: linear edge interpolation rounds corners; Dual Contouring with Hermite normals keeps them.

What It Does

  • Builds an 8-bit case index from the cube's corner signs
  • Looks up the triangles for that case in a 256-entry table and interpolates their vertices on the crossed edges

Use Cases

  • Reconstructing bone and organ surfaces from CT and MRI volumes for visualization
  • Turning signed distance fields and metaballs into renderable triangle meshes
  • Extracting isosurfaces from simulation and scientific volume data

Inputs

  • field: scalar voxel values
  • nx, ny, nz: grid dimensions
  • isoLevel: threshold value

Outputs

  • list of 3D triangles approximating the isoLevel surface

Key Formulas (2)

Edge interpolation

p = p1 + ((iso − v1) / (v2 − v1)) · (p2 − p1)
p = p1 + ((iso - v1) / (v2 - v1)) * (p2 - p1)

Finds the approximate crossing point between two scalar samples.

Case index

index = sum_{i=0}^{7} [vi < iso] · 2i
index = sum_{i=0}^{7} [v_i < iso] * 2^i

Selects one of the 256 table entries from the corner signs.

Pseudocode

  1. 1.Input: scalar grid field[x, y, z] of size nx x ny x nz, isovalue iso
  2. 2.EDGE_TABLE[256]: bit mask of the 12 cube edges crossed in each corner case; TRI_TABLE[256]: up to 5 triangles per case as edge triples
  3. 3.for each cube (x, y, z) with 0 <= x < nx-1, 0 <= y < ny-1, 0 <= z < nz-1:
  4. 4. read the 8 corner values v[0..7]
  5. 5. index = sum over corners i of (v[i] < iso) << i // one of 256 cases
  6. 6. if EDGE_TABLE[index] == 0: continue // cube entirely inside or outside
  7. 7. for each edge e set in EDGE_TABLE[index]: vertex[e] = p_i + ((iso - v_i) / (v_j - v_i)) * (p_j - p_i) on edge (i, j)
  8. 8. for each edge triple (e1, e2, e3) in TRI_TABLE[index]: emit triangle (vertex[e1], vertex[e2], vertex[e3])
  9. 9.return the triangle list

Algorithmic Specification & Pseudocode

Concept & Pseudocode Entry

This entry is part of the 1,000-algorithm concept catalog and provides high-level pseudocode, complexity bounds, and relationship links rather than a standalone in-browser benchmark engine.

⚡ Explore 63 Live Benchmarked Implementations →

Structured Execution Steps

  1. Input: scalar grid field[x, y, z] of size nx x ny x nz, isovalue iso
  2. EDGE_TABLE[256]: bit mask of the 12 cube edges crossed in each corner case; TRI_TABLE[256]: up to 5 triangles per case as edge triples
  3. for each cube (x, y, z) with 0 <= x < nx-1, 0 <= y < ny-1, 0 <= z < nz-1:
  4. read the 8 corner values v[0..7]
  5. index = sum over corners i of (v[i] < iso) << i // one of 256 cases
  6. if EDGE_TABLE[index] == 0: continue // cube entirely inside or outside
  7. for each edge e set in EDGE_TABLE[index]: vertex[e] = p_i + ((iso - v_i) / (v_j - v_i)) * (p_j - p_i) on edge (i, j)
  8. for each edge triple (e1, e2, e3) in TRI_TABLE[index]: emit triangle (vertex[e1], vertex[e2], vertex[e3])
  9. return the triangle list

Canonical Example

Input
16 x 16 x 16 grid sampling f(p) = |p - c| - 5.12 with c = (7.5, 7.5, 7.5); iso = 0
Output
a triangle mesh approximating the sphere of radius 5.12
Explanation
Each cube straddling the sphere gets a case index from its corner signs, and the table supplies one to five triangles for it.

Implementation Notes

  • Store EDGE_TABLE and TRI_TABLE as constant arrays indexed by the 8-bit case number.
  • Cache edge vertices by global edge id so neighbouring cubes share them.
  • Resolve ambiguous faces with the asymptotic decider (Nielson and Hamann 1991) or use the Marching Cubes 33 case set (Chernyaev 1995; Lewiner et al. 2003) when topology matters.

Common Pitfalls

  • Using the original complementary-case symmetry produces inconsistent choices on shared ambiguous faces and hence holes (Durst 1988).
  • Interpolating an edge vertex separately in each neighbouring cube instead of caching it per edge gives duplicated, unwelded vertices.
  • Values exactly equal to the isovalue need a consistent inside/outside convention or degenerate triangles appear.

Interactive Mechanism Walkthrough & State Debugger

Spatial Primitive & Sweep-Line Canvas

Show a grid cube, its 8 corner signs, the case index, and the triangles the table emits.

Marching Cubes (Lorensen-Cline, 256-case table) mechanism walkthrough step 1 of 9
sweep-line Xx = 60px
active hull vertices2
orientation testccw(p, q, r) > 0
invariantUpper/Lower Envelope
Step 1 of 9: Input: scalar grid field[x, y, z] of size nx x ny x nz, isovalue iso
voxel-surface

Notes

Classic Marching Cubes runs in O(N_x N_y N_z) time over the voxel grid and O(V_mesh + T_mesh) output space. The 256 corner-sign cases reduce to 15 by rotation and complement symmetry. Some of those cases are ambiguous on a cube face, so the original table can leave holes between neighbouring cubes and makes no manifold or topological-correctness guarantee. Key governing relation: p = p1 + ((iso - v1) / (v2 - v1)) * (p2 - p1).

Sources (3)

What each reference supports for this entry.

Lorensen and Cline 1987

Paper

Original Marching Cubes paper: corner-sign case index, 15 symmetry classes of the 256 cases, edge interpolation.

Open source

Nielson and Hamann 1991

Paper

The asymptotic decider: resolves the ambiguous face cases of Marching Cubes that can otherwise leave holes.

Open source

Lewiner, Lopes, Vieira and Tavares 2003

Paper

Efficient implementation of Marching Cubes' cases with topological guarantees (Marching Cubes 33, after Chernyaev 1995), including the ambiguous face and interior cases.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Marching Tetrahedra splits each cube into 6 tetrahedra instead of using the 256-case cube table, which removes the ambiguous face cases.

Conceptual neighborMarching Squares

Marching Squares is the 2D analogue of Marching Cubes.

Tags

GraphicsSurface ExtractionGeometry