---
id: "marching-cubes"
title: "Marching Cubes"
aliases: [MC]
domain: "geometry"
stage: "geometry"
realtime: "interactive"
platforms: [cpu, webgl2, webgpu, desktop-gpu, cuda, blender, unity]
year_introduced: 1987
inputs: [voxels, sdf]
outputs: [mesh, normals]
style: "both"
dynamic: "both"
cost: "medium"
authority: "Lorensen & Cline, 1987"
url: "https://texelatlas.vercel.app/t/marching-cubes/"
sources_verified_at: "2026-11-29"
---
# Marching Cubes (Lorensen & Cline, 1987)

> Walks every cell of a scalar grid and, from the signs at its eight corners, picks a precomputed triangle pattern that cuts the cell where the field crosses the iso-value. The classic way to turn volumes or SDFs into triangle meshes.

## Reach for it when

- convert voxel or density field to a mesh
- extract surface from scalar volume or metaballs
- make terrain with caves and overhangs
- visualize medical scan volume as a surface

## How it works

Sample the field at grid corners. For each cell, build an 8-bit index from which corners are inside (below the iso-value). That index selects one of 256 cases (15 up to symmetry) from a lookup table listing which cell edges the surface crosses and how to connect those crossings into triangles. Each crossing vertex is placed by linear interpolation of the two corner values along the edge. Vertices on shared edges are identical, so welding them gives an indexed mesh. Normals come from the field gradient (central differences) rather than from the faces, which gives smooth shading. The whole loop is embarrassingly parallel: GPU versions classify cells, stream-compact the active ones with a prefix sum, then emit triangles.

## When to use it

Choose it when you need a quick, robust mesh from a density grid or SDF and sharp features do not matter (medical volumes, metaballs, voxel terrain, sculpt previews). Prefer [Dual Contouring](https://texelatlas.vercel.app/t/dual-contouring.md) or [Manifold Dual Contouring](https://texelatlas.vercel.app/t/manifold-dual-contouring.md) when corners and creases must survive, [Surface Nets](https://texelatlas.vercel.app/t/surface-nets.md) when you want fewer, better-shaped triangles with the same simplicity, and [Marching Tetrahedra](https://texelatlas.vercel.app/t/marching-tetrahedra.md) when you want to avoid the ambiguous cube cases.

## Cost

medium — Linear in the number of cells; trivially parallel. Cost is dominated by field sampling and by triangle count, which grows with the square of grid resolution.
Measured GPU Weight: 3.74× baseline (light) — 0.123 ms median / 0.1269 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 3.32× baseline (light) — 0.0528 ms median (2.33× faster on L4).
Ampere A100 scaling: 2.33× baseline (light) — 0.067 ms median (1.84× faster on A100).

## Failure modes

- Sharp edges and corners are rounded off because only edge crossings, never normals, are used
- Ambiguous face cases in the original 15-case table can produce holes or cracks unless the extended table is used
- Sliver triangles and uneven triangle sizes where the surface grazes a cell corner
- Stair-stepping or banding when the field is a binary mask instead of a smooth distance
- Cracks between chunks of different resolution unless a transition scheme is used

## Engine support

- blender: builtin — `Geometry Nodes > Volume > Grid to Mesh (or Volume to Mesh)` (evidence: https://docs.blender.org/manual/en/5.2/modeling/geometry_nodes/volume/operations/grid_to_mesh.html, checked 2026-12-01) — Isosurface extraction; the manual calls it similar to Marching Cubes.
- threejs: official — `import { MarchingCubes } from 'three/addons/objects/MarchingCubes.js'` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/objects/MarchingCubes.js, checked 2026-12-01)
- unreal: builtin — `Modeling Mode > Voxel tools (VoxelMerge / VoxelBlend / Solidify) and Geometry Script Solidify (GeometryScriptSolidifyOptions)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/GeometryScriptSolidifyOptions, checked 2026-12-01)

## Dataflow

- Inputs: voxels, sdf
- Outputs: mesh, normals
- Platforms: cpu, webgl2, webgpu, desktop-gpu, cuda, blender, unity

## Presets

### Toy 2D marching squares: corner signs, cases and interpolated crossings (glsl-fragment; rendered 2026-11-29)

```json
{
  "CELLS": 10
}
```

```glsl
// Toy 2D analogue (marching squares): corner signs pick a case per cell, edge crossings are linearly interpolated.
const float CELLS = 10.0;
float field(vec2 p) {
    vec2 a = vec2(0.36 + 0.06 * sin(iTime), 0.5), b = vec2(0.64, 0.5 + 0.1 * cos(iTime));
    return 0.018 / dot(p - a, p - a) + 0.014 / dot(p - b, p - b) - 1.0;
}
float segd(vec2 p, vec2 a, vec2 b) {
    vec2 pa = p - a, ba = b - a;
    return length(pa - ba * clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6), 0.0, 1.0));
}
vec2 xing(vec2 p0, vec2 p1, float f0, float f1) { return mix(p0, p1, f0 / (f0 - f1)); }
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = fragCoord / iResolution.xy;
    float cs = 1.0 / CELLS;
    vec2 c0 = floor(uv / cs) * cs;
    vec2 P[4]; float F[4];
    P[0] = c0; P[1] = c0 + vec2(cs, 0); P[2] = c0 + cs; P[3] = c0 + vec2(0, cs);
    for (int i = 0; i < 4; i++) F[i] = field(P[i]);
    float d = 1e9;
    vec2 pts[4]; int n = 0;
    for (int i = 0; i < 4; i++) {
        int j = (i + 1) % 4;
        if ((F[i] > 0.0) != (F[j] > 0.0)) { pts[n] = xing(P[i], P[j], F[i], F[j]); n++; }
    }
    if (n == 2) d = segd(uv, pts[0], pts[1]);
    if (n == 4) d = min(segd(uv, pts[0], pts[1]), segd(uv, pts[2], pts[3]));
    vec3 col = vec3(0.07, 0.08, 0.11);
    float f = field(uv);
    col += vec3(0.05, 0.08, 0.12) * (f > 0.0 ? 1.0 : 0.0);
    vec2 g = abs(fract(uv / cs) - 0.5);
    col = mix(col, vec3(0.2, 0.22, 0.3), smoothstep(0.015, 0.0, 0.5 - max(g.x, g.y)));
    col = mix(col, vec3(1.0, 0.75, 0.25), smoothstep(0.004, 0.002, d));
    for (int i = 0; i < 4; i++) {
        float r = length(uv - P[i]);
        col = mix(col, F[i] > 0.0 ? vec3(0.3, 0.9, 0.5) : vec3(0.4, 0.45, 0.55), smoothstep(0.011, 0.008, r));
    }
    // true contour for reference
    col = mix(col, vec3(1.0, 0.3, 0.3), smoothstep(0.012, 0.0, abs(f)) * 0.0);
    fragColor = vec4(pow(col, vec3(0.8)), 1.0);
}

```

Attribution: written for this index

## Combines with

- [SDF Modeling: CSG and Smooth Minimum](https://texelatlas.vercel.app/t/sdf-csg-smooth-min.md): The smooth-min SDF supplies the scalar field; marching cubes meshes it.
- [Taubin Smoothing](https://texelatlas.vercel.app/t/taubin-smoothing.md): Taubin smoothing relaxes the stair-stepped output without shrinking it.
- [Quadric Error Metric Simplification](https://texelatlas.vercel.app/t/qem-mesh-simplification.md): Simplify the dense triangle soup the grid produces.

## Sources

1. [primary] William E. Lorensen, Harvey E. Cline (1987) Marching cubes: A high resolution 3D surface construction algorithm. ACM SIGGRAPH Computer Graphics. https://doi.org/10.1145/37402.37422 (verified via crossref on 2026-11-29)
2. [implementation] mikolalysenko (2013) mikolalysenko/isosurface. https://github.com/mikolalysenko/isosurface License: MIT. (verified via github on 2026-11-29)
3. [implementation] mrdoob (2010) mrdoob/three.js. https://github.com/mrdoob/three.js License: MIT. (verified via github on 2026-11-29)
4. [tutorial] Paul Bourke Polygonising a scalar field. paulbourke.net. https://paulbourke.net/geometry/polygonise (verified via http on 2026-11-29)

## Cite this entry

Texel. "Marching Cubes." https://texelatlas.vercel.app/t/marching-cubes/ (accessed 2026-12-01).
