---
id: "qem-mesh-simplification"
title: "Quadric Error Metric Simplification"
aliases: [QEM, quadric simplification, Mesh Simplification, Mesh Decimation, Polygon Reduction]
domain: "geometry"
stage: "geometry"
realtime: "interactive"
platforms: [cpu, webgl2, webgpu, desktop-gpu, blender, unity, unreal]
year_introduced: 1997
inputs: [mesh]
outputs: [mesh]
style: "both"
dynamic: "static"
cost: "offline"
authority: "Garland & Heckbert, 1997"
url: "https://texelatlas.vercel.app/t/qem-mesh-simplification/"
sources_verified_at: "2026-11-29"
---
# Quadric Error Metric Simplification (Garland & Heckbert, 1997)

> Collapses mesh edges greedily, always choosing the cheapest collapse measured by a sum of squared distances to the planes of the original surrounding faces. A fast, general-purpose way to cut triangle counts while keeping shape.

## Reach for it when

- mesh has too many polygons for realtime
- decimate model while keeping its shape
- generate lod chain from a high poly asset
- reduce triangles but preserve silhouette and features

## How it works

Attach to each vertex a 4x4 symmetric quadric: the sum of outer products of the plane equations of the faces around it. The error of placing a vertex at v is vᵀQv. For each candidate edge, merge the two quadrics, solve for the optimal position (or fall back to an endpoint or midpoint if the system is singular), and push the edge into a priority queue by cost. Repeatedly pop the cheapest edge, collapse it, update neighbouring costs and continue until the target triangle count is reached. Practical versions add rules to avoid triangle flips, preserve boundaries via extra penalty planes, weight by area and carry UVs or attributes in extended quadrics.

## When to use it

Choose it for automatic LODs, cleaning dense scans or marching-cubes output and shrinking assets for the web. Prefer [Isotropic Remeshing](https://texelatlas.vercel.app/t/isotropic-remeshing.md) when you need uniform triangle sizes rather than minimal count, [Instant Field-Aligned Meshes](https://texelatlas.vercel.app/t/instant-meshes.md) or [QuadriFlow](https://texelatlas.vercel.app/t/quadriflow.md) for clean quad topology, and hand-authored LODs where silhouettes or animation deformation must be controlled.

## Cost

offline — Near O(n log n) with a priority queue; millions of triangles take seconds on CPU. Not a per-frame operation.
Measured GPU Weight: 25.84× baseline (heavy) — 0.8113 ms median / 0.8766 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 21.07× baseline (heavy) — 0.3329 ms median (2.44× faster on L4).
Ampere A100 scaling: 15.44× baseline (moderate) — 0.4447 ms median (1.82× faster on A100).

## Failure modes

- UV seams, skin weights and normals tear or distort unless attributes are included in the metric
- Flipped or overlapping triangles when a collapse moves a vertex across its ring
- Boundary and thin-shell collapse: open edges shrink or holes grow
- Topology can change unexpectedly (non-manifold results) without explicit checks
- Uneven triangle shapes: it optimises error, not triangle quality

## Engine support

- babylonjs: builtin — `mesh.simplify([{distance, quality}]) (QuadraticErrorSimplification)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Meshes/meshSimplification.ts, checked 2026-12-01)
- blender: builtin — `Add Modifier > Generate > Decimate > Collapse` (evidence: https://docs.blender.org/manual/en/5.2/modeling/modifiers/generate/decimate.html, checked 2026-12-01) — Collapse mode; the manual does not name quadric error metrics.
- godot: builtin — `ImporterMesh.generate_lods(); scene import option Meshes > Generate LODs` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/ImporterMesh.xml, checked 2026-12-01) — Simplification via bundled meshoptimizer.
- unity: plugin — `openupm add com.whinarn.unitymeshsimplifier` (evidence: https://github.com/Whinarn/UnityMeshSimplifier, checked 2026-12-01) — UnityMeshSimplifier (Fast Quadric Mesh Simplification in C#).
- unreal: builtin — `Static Mesh Editor > LOD Settings > Reduction Settings (and GeometryScript_MeshSimplification)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/creating-and-using-lods-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: mesh
- Outputs: mesh
- Platforms: cpu, webgl2, webgpu, desktop-gpu, blender, unity, unreal

## Presets

### Quadric Error Metric Simplification — smooth high-poly reference (left) vs QEF edge-collapsed facets & error map (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_DECIMATION": 0.62,
  "P_ERROR_HEAT": 0.55,
  "P_WIRE_ALPHA": 0.85,
  "P_SPLIT": 0.44
}
```

```glsl
const float P_DECIMATION = 0.62; // P Decimation Ratio [0.1, 1.0, 0.02]
const float P_ERROR_HEAT = 0.55; // P Quadric Error Map [0.0, 1.0, 0.02]
const float P_WIRE_ALPHA = 0.85; // P Mesh Wireframe [0.0, 1.5, 0.05]
const float P_SPLIT = 0.44; // P Hi-Poly / QEM Split [0.0, 1.0, 0.02]

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

// Sculpted multi-lobed organic polyhedron with both smooth basins and sharp ridges (ideal QEM test!)
float mapSculpt(vec3 p, float spin) {
  vec3 q = p;
  q.xz = rot2(spin * 0.35) * q.xz;
  q.yz = rot2(0.28) * q.yz;
  float r = length(q);
  vec3 d = q / max(r, 1e-4);
  float lobes = 0.14 * sin(d.x * 5.0) * cos(d.y * 5.0) + 0.09 * cos(d.z * 6.0 + d.x * 3.0);
  float ridge = 0.045 * abs(sin(atan(d.z, d.x) * 4.0));
  return (r - (0.78 + lobes + ridge)) * 0.78;
}

vec3 calcNormal(vec3 p, float spin) {
  vec2 e = vec2(0.0025, 0.0);
  return normalize(vec3(
    mapSculpt(p + e.xyy, spin) - mapSculpt(p - e.xyy, spin),
    mapSculpt(p + e.yxy, spin) - mapSculpt(p - e.yxy, spin),
    mapSculpt(p + e.yyx, spin) - mapSculpt(p - e.yyx, spin)
  ));
}

// Compute triangle-grid facet center, flat quantized normal, edge distance, and local quadric error
void evalQemFacet(vec3 objP, vec3 smoothN, float freq, out vec3 flatN, out float edgeDist, out float qemErr) {
  // Spherical octahedral-like parameterization to form uniform triangle facets on the 3D surface
  vec3 d = normalize(objP + vec3(1e-5));
  vec2 sp = vec2(atan(d.z, d.x) / 3.14159265, asin(clamp(d.y, -0.999, 0.999)) / 1.5707963);
  vec2 g = sp * vec2(freq * 1.8, freq);
  vec2 cell = floor(g);
  vec2 f = fract(g);
  float upper = step(f.x, f.y);
  vec3 bary = (upper > 0.5) ? vec3(1.0 - f.y, f.x, f.y - f.x) : vec3(1.0 - f.x, f.y, f.x - f.y);
  edgeDist = min(bary.x, min(bary.y, bary.z));

  // Centroid of the collapsed QEM triangle on the unit sphere
  vec2 cUV = (cell + ((upper > 0.5) ? vec2(0.33, 0.67) : vec2(0.67, 0.33))) / vec2(freq * 1.8, freq);
  float lon = cUV.x * 3.14159265;
  float lat = clamp(cUV.y * 1.5707963, -1.55, 1.55);
  vec3 cDir = vec3(cos(lat) * cos(lon), sin(lat), cos(lat) * sin(lon));

  // Approximate face normal & quadric error v^T Q v = (n_smooth . (v - v_plane))^2
  flatN = normalize(mix(cDir, smoothN, 0.25));
  qemErr = clamp((1.0 - dot(smoothN, flatN)) * 12.0, 0.0, 1.0);
}

vec3 errPalette(float x) {
  x = clamp(x, 0.0, 1.0);
  vec3 c0 = vec3(0.10, 0.32, 0.64);
  vec3 c1 = vec3(0.16, 0.84, 0.66);
  vec3 c2 = vec3(0.98, 0.72, 0.18);
  vec3 c3 = vec3(0.98, 0.22, 0.34);
  if (x < 0.35) return mix(c0, c1, x / 0.35);
  if (x < 0.72) return mix(c1, c2, (x - 0.35) / 0.37);
  return mix(c2, c3, (x - 0.72) / 0.28);
}

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);
  float decim = clamp(P_DECIMATION, 0.05, 1.0);
  float heatMix = clamp(P_ERROR_HEAT, 0.0, 1.0);
  float wireVis = clamp(P_WIRE_ALPHA, 0.0, 1.5);
  float spin = iTime;

  vec3 ro = vec3(0.0, 0.06, 2.45);
  vec3 rd = normalize(vec3(uv, -1.52));

  vec3 col = mix(vec3(0.032, 0.042, 0.068), vec3(0.092, 0.116, 0.168), smoothstep(-0.55, 0.55, uv.y));
  vec2 bgG = abs(fract(uv * 10.0 - 0.5) - 0.5);
  col += vec3(0.018, 0.028, 0.045) * smoothstep(0.03, 0.0, min(bgG.x, bgG.y));

  float t = 0.0;
  bool hit = false;
  for (int i = 0; i < 64; i++) {
    float d = mapSculpt(ro + rd * t, spin);
    if (d < 0.002) { hit = true; break; }
    t += d;
    if (t > 9.0) break;
  }

  if (hit) {
    vec3 p = ro + rd * t;
    vec3 nSmooth = calcNormal(p, spin);

    vec3 objP = p;
    objP.xz = rot2(spin * 0.35) * objP.xz;
    objP.yz = rot2(0.28) * objP.yz;
    vec3 objN = nSmooth;
    objN.xz = rot2(spin * 0.35) * objN.xz;
    objN.yz = rot2(0.28) * objN.yz;

    // Left: dense reference mesh (freq = 18); Right: QEM simplified mesh (freq drops with P_DECIMATION)
    bool isQem = screenX >= split;
    float triFreq = isQem ? mix(13.0, 3.8, decim) : 18.0;

    vec3 flatObjN;
    float edgeD;
    float qemErr;
    evalQemFacet(objP, objN, triFreq, flatObjN, edgeD, qemErr);

    // Transform faceted normal back to world space for authentic flat-shaded decimated lighting
    vec3 nFlat = flatObjN;
    nFlat.yz = rot2(-0.28) * nFlat.yz;
    nFlat.xz = rot2(-spin * 0.35) * nFlat.xz;
    vec3 nShade = isQem ? normalize(mix(nSmooth, nFlat, 0.82)) : nSmooth;

    vec3 l1 = normalize(vec3(0.62, 0.85, 0.55));
    vec3 l2 = normalize(vec3(-0.72, -0.20, 0.52));
    float diff1 = max(dot(nShade, l1), 0.0);
    float diff2 = max(dot(nShade, l2), 0.0);
    vec3 hVec = normalize(l1 - rd);
    float spec = pow(max(dot(nShade, hVec), 0.0), 36.0) * 0.45;
    float rim = pow(1.0 - max(dot(nSmooth, -rd), 0.0), 3.0) * 0.28;

    vec3 clayAlb = vec3(0.76, 0.74, 0.72);
    vec3 qemAlb = mix(vec3(0.72, 0.75, 0.80), errPalette(qemErr * 1.45), heatMix);
    vec3 alb = isQem ? qemAlb : clayAlb;

    col = alb * (0.26 + 0.84 * diff1 + 0.24 * diff2) + vec3(spec) + vec3(0.45, 0.72, 1.0) * rim;
    float wire = smoothstep(0.065, 0.012, edgeD);
    vec3 wireCol = isQem ? vec3(0.06, 0.08, 0.12) : vec3(0.22, 0.30, 0.42);
    col = mix(col, wireCol, wire * (isQem ? 0.72 : 0.28) * min(wireVis, 1.2));
  }

  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: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).

## Combines with

- [Marching Cubes](https://texelatlas.vercel.app/t/marching-cubes.md): Collapse the dense uniform mesh into an adaptive one.
- [Geometry Images](https://texelatlas.vercel.app/t/geometry-images.md): Remesh/simplify before parametrization to keep atlas sizes sane.

## Sources

1. [primary] Michael Garland, Paul S. Heckbert (1997) Surface simplification using quadric error metrics. Proceedings of the 24th annual conference on Computer graphics and interactive techniques  - SIGGRAPH '97. https://doi.org/10.1145/258734.258849 (verified via crossref on 2026-11-29)
2. [implementation] zeux (2016) zeux/meshoptimizer. https://github.com/zeux/meshoptimizer License: MIT. (verified via github on 2026-11-29)
3. [implementation] sp4cerat (2015) sp4cerat/Fast-Quadric-Mesh-Simplification. https://github.com/sp4cerat/Fast-Quadric-Mesh-Simplification License: MIT. (verified via github on 2026-11-29)
4. [tutorial] Michael Garland QSlim. cs.cmu.edu. https://www.cs.cmu.edu/~garland/quadrics/qslim.html (verified via http on 2026-11-29)

## Cite this entry

Texel. "Quadric Error Metric Simplification." https://texelatlas.vercel.app/t/qem-mesh-simplification/ (accessed 2026-12-01).
