---
id: "marching-tetrahedra"
title: "Marching Tetrahedra"
domain: "geometry"
stage: "geometry"
realtime: "interactive"
platforms: [cpu, webgl2, webgpu, desktop-gpu, cuda]
year_introduced: 1988
inputs: [voxels, sdf]
outputs: [mesh]
style: "both"
dynamic: "both"
cost: "medium"
authority: "Bloomenthal, 1988"
url: "https://texelatlas.vercel.app/t/marching-tetrahedra/"
sources_verified_at: "2026-11-29"
---
# Marching Tetrahedra (Bloomenthal, 1988)

> Splits each grid cube into tetrahedra and triangulates the iso-surface inside each one using just three cases. It removes the ambiguity of marching cubes and works on arbitrary tetrahedral meshes.

## Reach for it when

- marching cubes gives ambiguous holes or cracks
- iso-surface needed from a tetrahedral mesh
- extract surface from fem simulation output
- need topology-consistent surface extraction without a big table

## How it works

Each cube is divided into five or six tetrahedra sharing a diagonal (or the grid is a body-centred / Freudenthal tetrahedralization). In a tetrahedron the four vertex signs give at most 16 combinations that collapse to three non-trivial cases: one vertex apart (one triangle), two against two (a quad, i.e. two triangles) and the empty cases. Because a tetrahedron is a simplex, the surface inside it is unambiguous and the resulting mesh is guaranteed watertight and crack-free across neighbours as long as the split directions agree on shared faces. Crossing points are interpolated linearly along edges exactly as in marching cubes. Because it operates on simplices, the same code runs on simulation tetrahedral meshes and adaptive grids.

## When to use it

Choose it when the field lives on an unstructured tet mesh (FEM output, adaptive grids) or when you want guaranteed topology consistency without a 256-entry table. Prefer [Marching Cubes](https://texelatlas.vercel.app/t/marching-cubes.md) when you want fewer triangles from a regular grid (tets produce roughly twice as many), and [Dual Contouring](https://texelatlas.vercel.app/t/dual-contouring.md) when sharp features matter.

## Cost

medium — Linear in cell count with a constant factor several times that of marching cubes because each cube becomes five or six tets.
Measured GPU Weight: 44.13× baseline (heavy) — 1.3681 ms median / 1.4355 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 34.98× baseline (heavy) — 0.5562 ms median (2.46× faster on L4).
Ampere A100 scaling: 29.76× baseline (heavy) — 0.8571 ms median (1.6× faster on A100).

## Failure modes

- Noticeably more and thinner triangles than marching cubes
- Visible diagonal bias: the tetrahedral split direction leaves a faint directional pattern on flat regions
- Same corner-rounding as marching cubes; sharp features are lost
- Linear interpolation across a coarse grid gives a faceted look unless normals come from the field

## Dataflow

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

## Presets

### Marching Tetrahedra — 6-tet Kuhn voxel decomposition (left) vs watertight extracted isosurface (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_CELL_RES": 7,
  "P_ISO_LEVEL": 0,
  "P_WIRE_GAIN": 0.9,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_CELL_RES = 7.0; // P Voxel Grid Res [4.0, 14.0, 1.0]
const float P_ISO_LEVEL = 0.0; // P Isovalue Shift [-0.15, 0.15, 0.01]
const float P_WIRE_GAIN = 0.90; // P Tet Wireframe [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Tet Facets / Smooth [0.0, 1.0, 0.02]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

float smin(float a, float b, float k) {
  float h = clamp(0.5 + 0.5 * (b - a) / max(k, 1e-4), 0.0, 1.0);
  return mix(b, a, h) - k * h * (1.0 - h);
}

// Smooth organic metaball scalar field f(p) (classic ambiguous saddle for Marching Cubes, clean in Marching Tetrahedra!)
float scalarField(vec3 q, float t, float iso) {
  vec3 c1 = vec3(0.38 * sin(t * 0.9), 0.24 * cos(t * 0.7), 0.18 * sin(t * 0.5));
  vec3 c2 = vec3(-0.38 * cos(t * 0.8), -0.22 * sin(t * 0.9), -0.15 * cos(t * 0.6));
  vec3 c3 = vec3(0.0, 0.34 * sin(t * 1.1), 0.30 * cos(t * 0.85));
  float d1 = length(q - c1) - 0.38;
  float d2 = length(q - c2) - 0.36;
  float d3 = length(q - c3) - 0.32;
  return smin(smin(d1, d2, 0.28), d3, 0.28) - iso;
}

// Identify which of the 6 Kuhn tetrahedra inside the unit cube [0,1]^3 contains f:
// Ordering of (f.x, f.y, f.z) defines the 6 canonical tetrahedra sharing main diagonal (0,0,0)-(1,1,1)!
int kuhnTetId(vec3 f) {
  if (f.x >= f.y && f.y >= f.z) return 0;
  if (f.x >= f.z && f.z >= f.y) return 1;
  if (f.z >= f.x && f.x >= f.y) return 2;
  if (f.z >= f.y && f.y >= f.x) return 3;
  if (f.y >= f.z && f.z >= f.x) return 4;
  return 5;
}

// Piecewise-linear tetrahedral interpolation of the scalar field inside the Kuhn simplex!
float evalTetLinear(vec3 q, float res, float t, float iso) {
  vec3 g = q * res;
  vec3 cell = floor(g);
  vec3 f = fract(g);
  float invR = 1.0 / res;

  // Sort f.x, f.y, f.z to locate the 4 vertices of the enclosing Kuhn tetrahedron
  vec3 v0 = cell;
  vec3 v3 = cell + vec3(1.0);
  vec3 v1, v2;
  float w0, w1, w2, w3;

  if (f.x >= f.y && f.y >= f.z) {
    v1 = cell + vec3(1.0, 0.0, 0.0); v2 = cell + vec3(1.0, 1.0, 0.0);
    w0 = 1.0 - f.x; w1 = f.x - f.y; w2 = f.y - f.z; w3 = f.z;
  } else if (f.x >= f.z && f.z >= f.y) {
    v1 = cell + vec3(1.0, 0.0, 0.0); v2 = cell + vec3(1.0, 0.0, 1.0);
    w0 = 1.0 - f.x; w1 = f.x - f.z; w2 = f.z - f.y; w3 = f.y;
  } else if (f.z >= f.x && f.x >= f.y) {
    v1 = cell + vec3(0.0, 0.0, 1.0); v2 = cell + vec3(1.0, 0.0, 1.0);
    w0 = 1.0 - f.z; w1 = f.z - f.x; w2 = f.x - f.y; w3 = f.y;
  } else if (f.z >= f.y && f.y >= f.x) {
    v1 = cell + vec3(0.0, 0.0, 1.0); v2 = cell + vec3(0.0, 1.0, 1.0);
    w0 = 1.0 - f.z; w1 = f.z - f.y; w2 = f.y - f.x; w3 = f.x;
  } else if (f.y >= f.z && f.z >= f.x) {
    v1 = cell + vec3(0.0, 1.0, 0.0); v2 = cell + vec3(0.0, 1.0, 1.0);
    w0 = 1.0 - f.y; w1 = f.y - f.z; w2 = f.z - f.x; w3 = f.x;
  } else {
    v1 = cell + vec3(0.0, 1.0, 0.0); v2 = cell + vec3(1.0, 1.0, 0.0);
    w0 = 1.0 - f.y; w1 = f.y - f.x; w2 = f.x - f.z; w3 = f.z;
  }

  return w0 * scalarField(v0 * invR, t, iso)
       + w1 * scalarField(v1 * invR, t, iso)
       + w2 * scalarField(v2 * invR, t, iso)
       + w3 * scalarField(v3 * invR, t, iso);
}

float mapWorld(vec3 p, bool faceted, float res, float t, float iso) {
  vec3 q = p;
  q.xz = rot2(t * 0.35) * q.xz;
  return faceted ? evalTetLinear(q, res, t, iso) : scalarField(q, t, iso);
}

vec3 calcNormal(vec3 p, bool faceted, float res, float t, float iso) {
  vec2 e = vec2(faceted ? 0.003 : 0.002, 0.0);
  return normalize(vec3(
    mapWorld(p + e.xyy, faceted, res, t, iso) - mapWorld(p - e.xyy, faceted, res, t, iso),
    mapWorld(p + e.yxy, faceted, res, t, iso) - mapWorld(p - e.yxy, faceted, res, t, iso),
    mapWorld(p + e.yyx, faceted, res, t, iso) - mapWorld(p - e.yyx, faceted, res, t, iso)
  ));
}

vec3 tetColor(int id) {
  if (id == 0) return vec3(0.95, 0.42, 0.24);
  if (id == 1) return vec3(0.96, 0.74, 0.22);
  if (id == 2) return vec3(0.22, 0.84, 0.56);
  if (id == 3) return vec3(0.18, 0.72, 0.94);
  if (id == 4) return vec3(0.58, 0.46, 0.96);
  return vec3(0.92, 0.38, 0.72);
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool isSmooth = screenX >= split;
  float res = clamp(floor(P_CELL_RES + 0.5), 4.0, 14.0);
  float iso = clamp(P_ISO_LEVEL, -0.18, 0.18);
  float wireGain = clamp(P_WIRE_GAIN, 0.0, 1.5);
  float t = iTime;

  vec3 ro = vec3(0.0, 0.06, 2.38);
  vec3 rd = normalize(vec3(uv, -1.55));

  vec3 col = mix(vec3(0.025, 0.036, 0.058), vec3(0.072, 0.092, 0.142), smoothstep(-0.55, 0.55, uv.y));

  float tHit = 0.0;
  bool hit = false;
  for (int i = 0; i < 72; i++) {
    float d = mapWorld(ro + rd * tHit, !isSmooth, res, t, iso);
    if (d < 0.002) { hit = true; break; }
    tHit += d * 0.72;
    if (tHit > 7.5) break;
  }

  if (hit) {
    vec3 p = ro + rd * tHit;
    vec3 n = calcNormal(p, !isSmooth, res, t, iso);

    vec3 objP = p;
    objP.xz = rot2(t * 0.35) * objP.xz;
    vec3 f = fract(objP * res);
    int tid = kuhnTetId(f);

    // Distance to any of the 6 Kuhn tetrahedron faces (cube boundaries + diagonal planes x=y, y=z, z=x)
    float dCube = min(min(min(f.x, 1.0 - f.x), min(f.y, 1.0 - f.y)), min(f.z, 1.0 - f.z));
    float dDiag = min(min(abs(f.x - f.y), abs(f.y - f.z)), abs(f.z - f.x)) * 0.7071;
    float tetWire = smoothstep(0.055, 0.012, min(dCube, dDiag));

    vec3 l1 = normalize(vec3(0.58, 0.84, 0.52));
    vec3 l2 = normalize(vec3(-0.68, -0.22, 0.54));
    float diff = max(dot(n, l1), 0.0) * 0.85 + max(dot(n, l2), 0.0) * 0.25;
    float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 46.0);

    if (!isSmooth) {
      // Left: Exact piecewise-linear Marching Tetrahedra facets colored by the 6 Kuhn tetrahedron IDs
      vec3 tCol = tetColor(tid);
      col = tCol * (0.28 + 0.82 * diff) + vec3(0.95) * spec * 0.35;
      col = mix(col, vec3(0.04, 0.06, 0.10), tetWire * 0.72 * min(wireGain, 1.2));
    } else {
      // Right: Watertight smooth isosurface with subtle tetrahedral edge lattice
      vec3 alb = vec3(0.20, 0.76, 0.78);
      col = alb * (0.26 + 0.84 * diff) + vec3(0.98) * spec * 0.62;
      col = mix(col, vec3(0.06, 0.14, 0.20), tetWire * 0.24 * min(wireGain, 1.0));
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Combines with

- [Marching Cubes](https://texelatlas.vercel.app/t/marching-cubes.md): Same field input; tets trade triangle count for topological certainty.

## Combination ideas

- [Crack-free latent morphing via DeepSDF and Marching Tetrahedra](https://texelatlas.vercel.app/ideas/deepsdf-isosurface-marching-tetrahedra/)

## Sources

1. [primary] Jules Bloomenthal (1988) Polygonization of implicit surfaces. Computer Aided Geometric Design. https://doi.org/10.1016/0167-8396(88)90013-1 (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)

## Cite this entry

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