Quadric Error Metric Simplification
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.
Also known as QEM, quadric simplification, Mesh Simplification, Mesh Decimation, Polygon Reduction
In the family Geometry, meshing & signed distance fields, mesh simplification
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | Built in | mesh.simplify([{distance, quality}]) (QuadraticErrorSimplification) docs |
| Godot 4.7 | Built in | ImporterMesh.generate_lods(); scene import option Meshes > Generate LODs docs Simplification via bundled meshoptimizer. |
| Unity | Plugin | openupm add com.whinarn.unitymeshsimplifier docs UnityMeshSimplifier (Fast Quadric Mesh Simplification in C#). |
| Unreal 5.7 | Built in | Static Mesh Editor > LOD Settings > Reduction Settings (and GeometryScript_MeshSimplification) docs |
| Blender 5.2 | Built in | Add Modifier > Generate > Decimate > Collapse docs Collapse mode; the manual does not name quadric error metrics. |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
Choose it for automatic LODs, cleaning dense scans or marching-cubes output and shrinking assets for the web. Prefer Isotropic Remeshing when you need uniform triangle sizes rather than minimal count, Instant Field-Aligned Meshes or QuadriFlow for clean quad topology, and hand-authored LODs where silhouettes or animation deformation must be controlled.
Field marks
- 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
Presets
Quadric Error Metric Simplification — smooth high-poly reference (left) vs QEF edge-collapsed facets & error map (right)
{
"P_DECIMATION": 0.62,
"P_ERROR_HEAT": 0.55,
"P_WIRE_ALPHA": 0.85,
"P_SPLIT": 0.44
}Show GLSL (141 lines)
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).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| qem-mesh-simplification-live | Tesla T4 1920x1080 | 25.8× baseline (heavy) · 0.811 ms / 0.877 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| qem-mesh-simplification-live | NVIDIA L4 1920x1080 | 21.1× baseline (heavy) · 0.333 ms / 0.349 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| qem-mesh-simplification-live | NVIDIA A100-SXM4-40GB 1920x1080 | 15.4× baseline (moderate) · 0.445 ms / 0.473 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Hunyuan3D 2.0, Hunyuan3D-Paint, Manifold Dual Contouring, MeshFlow, MeshGPT, Conway Polyhedra & Spanning-Tree Hinge Net Unfolding.
Crosses
- Marching Cubes: Collapse the dense uniform mesh into an adaptive one.
- Geometry Images: Remesh/simplify before parametrization to keep atlas sizes sane.
Sources
- primaryMichael 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.Verified via crossref · 2026-11-29doi:10.1145/258734.258849
- implementationzeux (2016). zeux/meshoptimizer. Mesh optimization library that makes meshes smaller and faster to renderGitHub API · license MIT · 2026-11-29
- implementationsp4cerat (2015). sp4cerat/Fast-Quadric-Mesh-Simplification. Mesh triangle reduction using quadricsGitHub API · license MIT · 2026-11-29