glTF PBR BRDF Mathematical Foundation Explained

The glTF 2.0 specification relies on a physically based rendering (PBR) metallic-roughness model to achieve consistent, realistic surface appearance across diverse rendering engines. At its core, the standard glTF lighting model employs a microfacet Bidirectional Reflectance Distribution Function (BRDF) that separates surface reflectance into a Lambertian diffuse term and a Cook-Torrance specular term. This article breaks down the mathematical equations that define standard glTF PBR lighting, including the GGX normal distribution, the Schlick Fresnel approximation, and the height-correlated Smith visibility function.

The Combined Surface BRDF

In glTF PBR, the total reflected radiance at a surface point is governed by the sum of diffuse reflection and specular microfacet reflection:

\[f(\mathbf{l}, \mathbf{v}) = (1 - F) f_{\text{diffuse}} + f_{\text{specular}}\]

Here, \(\mathbf{l}\) is the unit light vector, \(\mathbf{v}\) is the unit view vector, and \(F\) is the Fresnel factor determining the fraction of light reflected specularly versus refracted diffusely.

Diffuse Term: Lambertian Model

glTF uses standard Lambertian diffuse reflectance for energy-conserving diffuse scattering:

\[f_{\text{diffuse}} = \frac{c_{\text{diff}}}{\pi}\]

Where \(c_{\text{diff}}\) is the diffuse albedo color, calculated by interpolating between the base color and pure black based on the material's metallic value:

\[c_{\text{diff}} = \text{baseColor} \cdot (1 - \text{metallic})\]

Pure metals absorb all refracted light, reducing diffuse reflection to zero.

Specular Term: Cook-Torrance Microfacet BRDF

The specular component models reflection from microscopic surface facets oriented according to normal distributions:

\[f_{\text{specular}} = \frac{D \cdot F \cdot G}{4 (\mathbf{n} \cdot \mathbf{l}) (\mathbf{n} \cdot \mathbf{v})}\]

To optimize evaluation, rendering engines combine the geometric shadowing factor \(G\) with the denominator into a single visibility function, \(V\):

\[V = \frac{G}{4 (\mathbf{n} \cdot \mathbf{l}) (\mathbf{n} \cdot \mathbf{v})}\]

This simplifies the specular equation to:

\[f_{\text{specular}} = D \cdot F \cdot V\]

The three core functions are evaluated as follows:

1. Normal Distribution Function (\(D\)): Trowbridge-Reitz (GGX)

The distribution function models the statistical distribution of microfacet normal orientations relative to the half-vector \(\mathbf{h} = \frac{\mathbf{l} + \mathbf{v}}{\|\mathbf{l} + \mathbf{v}\|}\). glTF mandates the Trowbridge-Reitz / GGX distribution:

\[D_{\text{GGX}}(\mathbf{n}, \mathbf{h}, \alpha) = \frac{\alpha^2}{\pi \left( (\mathbf{n} \cdot \mathbf{h})^2 (\alpha^2 - 1) + 1 \right)^2}\]

In this formula, \(\mathbf{n}\) represents the macroscopic surface normal, and \(\alpha\) is the perceptual roughness squared (\(\alpha = \text{roughness}^2\)), which yields a perceptually linear roughness adjustment.

2. Fresnel Function (\(F\)): Schlick's Approximation

The Fresnel term computes the ratio of light reflected at varying incident angles. glTF implements the standard Schlick approximation:

\[F_{\text{Schlick}}(\mathbf{v}, \mathbf{h}, F_0) = F_0 + (1 - F_0)(1 - (\mathbf{v} \cdot \mathbf{h}))^5\]

\(F_0\) represents the specular reflectance at normal incidence (\(0^\circ\)). In glTF, \(F_0\) is derived by linearly interpolating between a fixed dielectric reflectance (0.04 for standard dielectrics) and the base color for conductors:

\[F_0 = \text{mix}(0.04, \text{baseColor}, \text{metallic})\]

3. Visibility and Shadowing Function (\(V\)): Height-Correlated Smith GGX

Microfacets can occlude each other both from the incoming light direction and the outgoing viewing direction. glTF specifies the height-correlated form of the Smith masking-shadowing function, which accounts for the correlation between microfacet heights:

\[V_{\text{SmithGGX}}(\mathbf{n}, \mathbf{v}, \mathbf{l}, \alpha) = \frac{0.5}{(\mathbf{n} \cdot \mathbf{l}) \sqrt{(\mathbf{n} \cdot \mathbf{v})^2 (1 - \alpha^2) + \alpha^2} + (\mathbf{n} \cdot \mathbf{v}) \sqrt{(\mathbf{n} \cdot \mathbf{l})^2 (1 - \alpha^2) + \alpha^2}}\]

This formulation avoids division by zero at grazing angles and ensures energy conservation across all viewing and illumination vectors. Together, these closed-form equations define the baseline mathematical standard required for real-time glTF rendering pipelines.