Optimizing glTF Memory for Massive CAD Assemblies
Rendering massive Computer-Aided Design (CAD) assemblies in real-time WebGL and WebGPU engines requires aggressive memory management to avoid browser crashes and performance bottlenecks. This guide outlines the essential technical strategies for reducing the memory footprint of CAD data exported to glTF, focusing on hardware instancing, geometry compression, data quantization, draw call reduction, and hierarchical visibility.
1.
Leverage Hardware Instancing (EXT_mesh_gpu_instancing)
Industrial CAD assemblies contain thousands of repetitive components such as bolts, nuts, washers, and modular brackets. Exporting each component as an individual mesh leads to severe CPU and GPU memory exhaustion.
By applying the EXT_mesh_gpu_instancing extension, the
glTF file stores the base geometry of a repeated component only once.
The engine then supplies an array of 4x4 transform matrices to the GPU.
This eliminates redundant vertex buffers, reducing both VRAM allocation
and CPU-to-GPU bandwidth.
2. Apply Vertex Quantization and Mesh Compression
Raw CAD tessellations often output 32-bit floating-point numbers for vertex positions, normals, and texture coordinates. This level of precision is rarely necessary for real-time visualization and consumes significant memory.
- Quantization: Use
KHR_mesh_quantizationto downsample 32-bit floats to 16-bit or 8-bit normalized integers. This halves the memory footprint of vertex attribute buffers without noticeable visual degradation. - Buffer Compression: Implement
KHR_meshopt_compression. While formats like Google Draco achieve high network compression, they require substantial CPU memory and decoding overhead on the client side. Meshopt provides fast, streamable decompression that translates directly into GPU-friendly buffers with minimal CPU memory overhead during extraction.
3. Strip Unused Vertex Attributes and CAD Metadata
Native CAD formats carry extensive metadata, such as boundary representations (B-rep), edge loops, and manufacturing notes. When converting to glTF:
- Remove unnecessary vertex attributes. Keep only
POSITIONand compact oct-encodedNORMALvectors if lighting requires it. - Omit secondary UV sets, vertex colors, and tangents unless explicitly needed by target shaders. Tangents can often be derived procedurally in the pixel shader to save buffer space.
- Eliminate CAD-specific topological curves and hidden auxiliary geometry.
4. Implement Hierarchical Level of Detail (HLOD) and Chunking
Massive assemblies cannot reside in active GPU memory all at once. Structuring the glTF asset as a hierarchy of spatial chunks enables aggressive memory offloading:
- Interior Culling: CAD assemblies often feature dense internal mechanisms enclosed within outer casings. Use offline ray-tracing or voxelization tools to discard completely occluded geometry before export.
- HLOD Meshes: Group complex sub-assemblies into single, decimated proxy meshes at greater distances.
- Dynamic Streaming: Split the assembly into multiple glTF files or combine them using modern open standards like 3D Tiles, loading and unloading detail nodes dynamically based on camera proximity and the current frustum.
5. Consolidate Draw Calls and Merge Geometries
CAD software treats every individual nut, plate, and washer as an independent solid body. In glTF, this frequently translates to thousands of separate nodes and primitives, each generating an independent draw call and state-change overhead in memory.
For static, non-instanced elements:
- Merge adjacent small geometries that share the same material into a single unified mesh primitive.
- Combine distinct component materials using unified texture atlases or shared PBR (Physically Based Rendering) property sheets, significantly lowering runtime graphics state memory.