Beer's Law in Transmissive glTF Materials

This article provides an overview of how the Beer-Lambert Law governs light attenuation within transmissive glTF 2.0 materials. It explains the physical principles of exponential light absorption through a medium, details the implementation through the KHR_materials_volume and KHR_materials_transmission extensions, and breaks down the core parameters required to achieve realistic, physically accurate colored glass, liquids, and plastics in real-time 3D rendering.

The Physics of Beer's Law

The Beer-Lambert Law (commonly referred to as Beer's Law) states that the intensity of light decreases exponentially as it travels through an absorbing medium. Mathematically, it is expressed as:

\[I = I_0 e^{-\sigma_a d}\]

In this equation, \(I\) represents the transmitted light intensity, \(I_0\) is the initial light intensity entering the medium, \(\sigma_a\) is the absorption coefficient (which varies across different wavelengths to produce color), and \(d\) is the path length the light travels through the volume.

In real-world materials like colored glass or murky water, light passing through a thin edge barely loses intensity and retains its original color, while light traveling through a thick section is heavily absorbed, appearing darker and more saturated.

glTF Extensions and Volumetric Transmission

Standard glTF 2.0 metallic-roughness materials are modeled as infinitely thin surfaces. To simulate realistic interior light attenuation via Beer’s Law, glTF relies on two combined extensions:

  1. KHR_materials_transmission: Defines the fraction of specular light that passes through the surface rather than being reflected, transforming the mesh into a transmissive boundary.
  2. KHR_materials_volume: Treats the enclosed mesh as a solid volume rather than a hollow shell, providing the necessary thickness and absorption properties for Beer's Law calculations.

Key Parameters in glTF

Rather than exposing raw, non-intuitive absorption coefficients (\(\sigma_a\)), the KHR_materials_volume extension maps Beer’s Law using visually artist-friendly parameters:

  • thicknessFactor: The base thickness of the object along the surface normal. It can be modified per-texel using a thicknessTexture to account for varying internal geometry in real-time approximations.
  • attenuationDistance: The average distance light travels through the medium before its intensity diminishes to the specified attenuationColor. If set to infinity, the material exhibits zero absorption regardless of thickness.
  • attenuationColor: The linear RGB color that transmitted white light attains after traveling the exact length of the attenuationDistance.

Mathematical Application in Renderers

Real-time and ray-traced glTF engines use attenuationColor (\(C\)) and attenuationDistance (\(d_{\text{ref}}\)) to derive the wavelength-dependent absorption coefficient vector (\(\sigma_a\)):

\[\sigma_a = -\frac{\ln(C)}{d_{\text{ref}}}\]

When a light ray enters the transmissive object and travels a distance \(d\), the renderer computes the transmitted transmittance factor (\(T\)) using Beer's Law:

\[T = e^{-\sigma_a d} = C^{\frac{d}{d_{\text{ref}}}}\]

This resulting factor \(T\) modulates the transmitted light. If the ray's travel distance \(d\) matches attenuationDistance, the transmitted light color precisely equals attenuationColor. If the path is short (\(d \ll d_{\text{ref}}\)), \(T\) approaches white (no absorption). If the path is long (\(d \gg d_{\text{ref}}\)), light is heavily absorbed, shifting deeply into the attenuation color before decaying toward complete blackness.

Practical Impact on Rendering

By integrating Beer’s Law via the volume extension, glTF models naturally convey depth and thickness. Thin rims of glassware remain bright and clear, while thick stems, heavy bases, and curved edges exhibit deep, physically accurate color saturation and falloff without requiring manual texture baking.