glTF Clearcoat Specular Reflection Equation

In glTF 2.0, the KHR_materials_clearcoat extension simulates a transparent, thin layer over a base material using physically based rendering principles. Specular reflection off this outer boundary is computed using a microfacet specular Bidirectional Reflectance Distribution Function (BRDF). This article breaks down the mathematical equations governing glTF clearcoat specular reflection, detailing the Cook-Torrance model and its constituent Fresnel, normal distribution, and geometric visibility terms.

The Specular Reflection Model

The specular reflection off the clearcoat layer is defined by the standard Cook-Torrance microfacet specular BRDF, scaled by the clearcoat strength factor (\(F_c\)):

\[f_{\text{clearcoat}}(\mathbf{l}, \mathbf{v}) = c \cdot \frac{D(\mathbf{h}) \cdot F(\mathbf{v}, \mathbf{h}) \cdot G(\mathbf{l}, \mathbf{v}, \mathbf{h})}{4 (\mathbf{n}_c \cdot \mathbf{l}) (\mathbf{n}_c \cdot \mathbf{v})}\]

Where:

  • \(c\) is the clearcoat factor (clearcoatFactor), modulated by an optional clearcoat texture.
  • \(\mathbf{l}\) is the unit vector pointing toward the light source.
  • \(\mathbf{v}\) is the unit vector pointing toward the viewer.
  • \(\mathbf{n}_c\) is the surface normal of the clearcoat layer (incorporating clearcoat normal maps if present).
  • \(\mathbf{h}\) is the half-vector between \(\mathbf{l}\) and \(\mathbf{v}\), calculated as \(\mathbf{h} = \frac{\mathbf{l} + \mathbf{v}}{\|\mathbf{l} + \mathbf{v}\|}\).

1. Normal Distribution Function (\(D\))

glTF uses the Trowbridge-Reitz (GGX) distribution function to model the alignment of microfacets on the clearcoat boundary:

\[D(\mathbf{h}) = \frac{\alpha_c^2}{\pi \left( (\mathbf{n}_c \cdot \mathbf{h})^2 (\alpha_c^2 - 1) + 1 \right)^2}\]

In this term, \(\alpha_c\) is the roughness parameter mapped from the artist-provided clearcoat roughness (\(r_c\)):

\[\alpha_c = r_c^2\]

2. Fresnel Reflectance (\(F\))

The clearcoat boundary represents an interface between air and a dielectric medium. glTF employs Schlick’s approximation to determine the fraction of light reflected at the interface:

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

Unless altered by the KHR_materials_ior extension, the index of refraction (\(\text{IOR}\)) of the clearcoat is fixed at \(1.5\), yielding a standard dielectric reflectance at normal incidence (\(F_0\)):

\[F_0 = \left( \frac{\text{IOR} - 1}{\text{IOR} + 1} \right)^2 = \left( \frac{1.5 - 1}{1.5 + 1} \right)^2 = 0.04\]

3. Visibility and Masking Term (\(V\) or \(G\))

The geometric attenuation accounts for microfacets shadowing and masking each other. Implementations typically combine the geometric term \(G\) with the denominator \(4(\mathbf{n}_c \cdot \mathbf{l})(\mathbf{n}_c \cdot \mathbf{v})\) into a single visibility function \(V(\mathbf{l}, \mathbf{v})\).

glTF recommends the correlated Smith visibility function for GGX:

\[V(\mathbf{l}, \mathbf{v}) = \frac{G(\mathbf{l}, \mathbf{v}, \mathbf{h})}{4 (\mathbf{n}_c \cdot \mathbf{l}) (\mathbf{n}_c \cdot \mathbf{v})} = \frac{1}{\Lambda(\mathbf{l}) + \Lambda(\mathbf{v})}\]

Expressed explicitly:

\[V(\mathbf{l}, \mathbf{v}) = \frac{0.5}{(\mathbf{n}_c \cdot \mathbf{l}) \sqrt{(\mathbf{n}_c \cdot \mathbf{v})^2 (1 - \alpha_c^2) + \alpha_c^2} + (\mathbf{n}_c \cdot \mathbf{v}) \sqrt{(\mathbf{n}_c \cdot \mathbf{l})^2 (1 - \alpha_c^2) + \alpha_c^2}}\]

Layer Energy Conservation

Light reflected by the clearcoat boundary does not penetrate to the base material. The transmitted energy reaching the underlying substrate is reduced according to the clearcoat Fresnel term:

\[\text{Energy}_{\text{base}} = 1 - c \cdot F(\mathbf{v}, \mathbf{h})\]

All specular and diffuse contributions from the underlying base layer are multiplied by this attenuation factor to maintain overall energy conservation.