Back to Digital Arts

Mesh decimation

Reducing triangle counts with quadric error edge collapse.

optimisation.js reduces a mesh's triangle count using the method from Garland and Heckbert.

My earlier version used edge length as the cost, and it could not distinguish a short edge on a flat face from a short edge on a sharp corner.

Each vertex now stores a quadric that measures its distance from the planes of its surrounding faces. A quadric is the symmetric 4x4 matrix p * p^T for a plane p, stored as its 10 unique values.

The algorithm always collapses the edge with the lowest error next, and places the merged vertex at the position that minimises the error. Flat areas lose triangles first, and corners retain their shape.

The function returns new geometry, and printing the vertex and face counts before and after confirms the result without rendering it.