How glTF Topological Deduplication Works
Topological deduplication is an optimization technique that detects and merges geometrically identical meshes within a glTF asset regardless of their position, orientation, or scale in the scene. By analyzing the connectivity, vertex relationships, and surface structure of 3D objects rather than their world-space coordinates, the algorithm identifies matching components and collapses redundant data into shared references. This process drastically reduces file sizes, minimizes memory usage, and improves runtime rendering performance by enabling hardware instancing.
Extracting Local Topology
In a standard glTF file, repeated objects—such as screws, wheels, or foliage—are frequently exported as separate meshes, each containing distinct vertex, normal, UV, and index buffers. Topological deduplication begins by decoupling each mesh from its scene-graph transform.
The algorithm examines the intrinsic connectivity of the mesh data, evaluating topological invariants that do not change under rotation or translation:
- Graph Adjacency: The arrangement of vertices, edges, and faces forming the mesh manifold.
- Vertex Degree: The number of edges connected to each vertex.
- Loop and Boundary Counts: The number of closed edge loops, holes, or open boundaries within the surface.
Because spatial location and rotation do not alter these connectivity relationships, meshes placed throughout a 3D scene can be compared in a neutral, local coordinate space.
Canonical Normalization and Hashing
Comparing every mesh to every other mesh sequentially is computationally expensive. To accelerate identification, the algorithm normalizes each candidate mesh into a canonical frame of reference:
- Centering and Scale Normalization: The geometry is translated so its center of mass sits at the origin \((0,0,0)\), and its bounding dimensions are scaled to unit size if scale-invariant matching is enabled.
- Principal Axis Alignment: The algorithm calculates the eigenvectors of the mesh's inertia tensor (Principal Component Analysis) to align the primary geometric axes along the standard X, Y, and Z coordinate axes.
- Canonical Sorting: Vertices and faces are reordered based on a deterministic rule (e.g., sorting by coordinates along the aligned axes and traversing connected edges).
- Signature Hashing: A cryptographic or geometric hash is generated from the sorted topology, relative vertex positions, and attribute buffers (normals, UV coordinates, vertex colors). Meshes with differing hashes are immediately discarded as non-matching.
Isomorphism Verification with Tolerances
When two meshes produce identical or near-identical topological hashes, a geometric verification step confirms that the components are truly identical within an acceptable floating-point tolerance.
This step tests for graph isomorphism, ensuring that face indices point to equivalent vertex locations across both surfaces. It also checks that auxiliary data—such as texture coordinates (UVs), vertex normals, and skinning weights—match. Using spatial tolerances ensures that minor precision discrepancies introduced during export or floating-point rounding do not prevent valid duplicates from being recognized.
Calculating Relative Transforms
Once a match between a target mesh and a reference mesh is confirmed, the deduplication engine computes the affine transformation matrix required to map the canonical reference mesh to the duplicate's original orientation, scale, and position in the scene:
\[\mathbf{M}_{\text{node}} = \mathbf{M}_{\text{original}} \times \mathbf{M}_{\text{alignment}}^{-1}\]
This matrix preserves the exact world-space appearance of the duplicate while allowing the underlying geometry data to be discarded.
Collapsing the glTF Structure
The final phase restructures the glTF JSON hierarchy and binary
buffer (.bin):
- Buffer Pruning: The redundant accessors and bufferViews belonging to duplicate meshes are removed from the glTF payload.
- Mesh Pointer Redirection: The
meshproperty of each duplicate node in the glTFnodesarray is updated to point to the single, retained referencemeshindex. - Transform Assignment: The calculated transformation
matrices are applied to the relevant
nodedefinitions via thematrixproperty or decomposed intotranslation,rotation, andscale(TRS) vectors. - GPU Instancing (Optional): If the glTF asset
targets modern runtimes, identical nodes sharing a parent can be grouped
using the
EXT_mesh_gpu_instancingextension, collapsing multiple nodes into a single draw call with per-instance transform attributes.