Fixing Floating-Point Precision Loss in Large-Scale Web CAD Viewers
Overcome 32-bit single-precision float limitations in WebGL shaders when rendering massive GIS coordinates or millimeter-precise CAD assemblies.
When rendering high-precision CAD objects positioned far from the coordinate origin, GPUs experience single-precision floating-point degradation, resulting in visual mesh flickering and vertex jittering.
1. The 32-Bit Float Constraint in Shader Pipelines
Standard GPUs process 32-bit floats (highp float). At world coordinates exceeding millions of units, precision degrades to several centimeters, breaking sub-millimeter CAD snapping operations.
2. Relative to Center (RTC) Rendering Strategy
The RTC method subtracts a local camera origin offset on the CPU before passing double-precision coordinates down to vertex shaders, ensuring geometry is evaluated relative to the current camera position.
3. Emulating 64-Bit Precision in WebGL/WebGPU
Splitting 64-bit coordinates into two 32-bit floats (high and low components) inside WGSL or GLSL shaders restores millimeter accuracy across continental GIS coordinates without performance degradation.