glTF Refraction Depth for Overlapping Objects

Evaluating refraction depth across overlapping transmissive models in glTF requires understanding how the core format, its official extensions, and modern real-time or offline renderers process light transmission. The glTF 2.0 specification manages refraction and light absorption through the KHR_materials_transmission and KHR_materials_volume extensions. While offline path tracers can accurately simulate complex multi-boundary refractive ray paths, standard real-time glTF rasterization engines rely on screen-space approximations and local thickness models that simplify how overlapping refractive depths are calculated.

glTF Transmission and Volume Extensions

Standard glTF materials treat surfaces as infinitely thin. To introduce refraction and physical depth, two extensions are required:

  • KHR_materials_transmission: Enables light to pass through the mesh surface, simulating clear or rough glass based on the material's roughness and index of refraction (defined via KHR_materials_ior).
  • KHR_materials_volume: Defines the interior space of the object, introducing absorption via attenuationColor and attenuationDistance, as well as a physical depth dimension defined by thicknessFactor and an optional thicknessTexture.

Within the glTF specification, thickness is inherently defined as a local attribute of an individual mesh rather than a global volumetric distance. The depth traversed by light through a single object is evaluated using the surface normal, the view or refraction ray direction, and the defined thickness values.

Real-Time Rasterization and Screen-Space Limitations

In real-time implementations (such as WebGL or WebGPU renderers like Three.js and Babylon.js), transparent and transmissive objects are rendered after all opaque objects have been drawn to the frame buffer. The pipeline generally captures this completed opaque rendering into a background color texture (often called a transmission or refraction texture).

When multiple transmissive objects overlap in screen space:

  1. Single Background Capture: Standard rasterizers capture the opaque pass once. The nearest transmissive object refracts the pixels behind it, but it samples only the original opaque scene texture. It typically cannot sample another transmissive object located behind it unless the engine implements multi-pass depth peeling or iterative texture captures.
  2. Lack of Dielectric Priority: glTF does not define a native dielectric priority system or nested volume tracking. In a standard rasterizer, the renderer cannot dynamically compute the shared intersection volume of two overlapping objects.
  3. Local Depth Independent Evaluation: When two transmissive meshes overlap, each mesh evaluates its thickness and attenuation independently according to its own local thickness properties and render sort order (usually back-to-front). The depth of the front object does not subtract from or compound with the depth of the rear object in an optically physical manner. Instead, the final pixel color is a standard alpha-blend or screen-space texture sample applied sequentially.

Offline and Path-Tracing Evaluation

When a glTF scene containing overlapping transmissive objects is rendered using a path tracer, the depth evaluation changes from local approximations to explicit ray-geometry intersections:

  1. Ray-Mesh Intersections: The renderer calculates the exact distance between the entry ray hit point and the exit ray hit point along the refracted trajectory.
  2. Overlapping Boundaries: If two separate closed meshes physically interpenetrate, a standard path tracer will register the entry into Object A, followed by the entry into Object B before exiting Object A. Because the glTF specification treats meshes as distinct closed manifolds, path tracers calculate absorption for each volume segment along the ray path based on which manifold boundary is currently enclosing the ray.
  3. Index of Refraction Transitions: glTF does not define boundary interfaces between two adjacent transmission media (such as glass against water). When overlapping volumes occur, path tracers typically assume each volume interfaces with a vacuum or air boundary (IOR = 1.0) unless the engine features custom heuristic volume-stack tracking to transition directly from one IOR to another.