Ambient Occlusion in glTF Specular Highlights
This article provides an overview of how ambient occlusion (AO) maps interact with specular reflections in the glTF 2.0 Physically Based Rendering (PBR) pipeline. While the glTF specification primarily defines ambient occlusion as an attenuation factor for indirect diffuse light, production renderers and runtime engines must balance physical accuracy with visual fidelity. The following sections explain the distinction between direct specular highlights and indirect specular reflections, how ambient occlusion is mathematically factored into specular lighting, and how engines avoid specular leaking in occluded crevices.
The glTF 2.0 Specification Baseline
According to the official glTF 2.0 specification, the
occlusionTexture represents ambient occlusion that scales
the indirect ambient light received by a material. In a strictly
physical context, ambient occlusion represents large-scale shadowing of
ambient, non-directional light.
Direct lighting from punctual sources—such as directional lights, point lights, and spotlights—is fundamentally separate from ambient lighting. As a result, standard glTF PBR implementations do not apply ambient occlusion to direct specular highlights. Direct specular visibility is instead governed strictly by shadow mapping or geometric occlusion techniques. Multiplying direct specular highlights by an AO map would violate physical principles by causing highlights from bright, direct sources to artificially disappear in open crevices.
Indirect Specular Reflections vs. Direct Highlights
While direct specular highlights remain unaffected by AO, indirect specular reflections—typically derived from Image-Based Lighting (IBL) environment maps—require special consideration.
If ambient occlusion is applied exclusively to indirect diffuse irradiance, materials with high reflectivity or low roughness in deeply occluded areas (such as concave folds, gaps, or internal corners) will reflect the bright environment map. This discrepancy leads to an artifact known as "specular leaking," where dark cracks display unrealistic, glowing reflections.
To solve this, modern glTF runtime viewers (such as Three.js, Babylon.js, and Google Filament) derive a specular ambient occlusion factor (\(SO\)) from the material’s scalar ambient occlusion value (\(AO\)), material roughness (\(\alpha\)), and viewing angle (\(N \cdot V\)).
Computing Specular Ambient Occlusion
Engines implement specular occlusion through empirical models that blend the AO factor into the indirect specular calculation. A widely adopted standard in real-time PBR is the approximation formulated by Sébastien Lagarde:
\[SO = \text{clamp}\left( (N \cdot V + AO)^{\left(1.0 - \text{roughness}\right)} - 1.0 + AO, 0.0, 1.0 \right)\]
This formula models two distinct physical behaviors:
- Rough Surfaces: Rougher surfaces disperse light over a broader solid angle, behaving similarly to diffuse surfaces. Consequently, rough specular reflections receive heavy occlusion nearly identical to the diffuse ambient occlusion value.
- Smooth Surfaces: Mirror-like surfaces reflect light along narrow, specific paths. The occlusion of these reflections depends heavily on the viewing angle relative to the surface normal (\(N \cdot V\)), meaning specular reflections survive better at grazing angles than at direct incidence.
Practical Implementation in glTF Engines
When a glTF asset is rendered:
- Direct Specular: Calculated using the Cook-Torrance microfacet specular BRDF and attenuated solely by the light's attenuation curve and active shadow maps. Ambient occlusion is not included.
- Indirect Diffuse: Scaled directly by the sampled
occlusionTexturevalue, adjusted by the material'socclusionTexture.strengthfactor: \[\text{Diffuse}_{\text{indirect}} = \text{IBL}_{\text{diffuse}} \times \left(1.0 + \text{strength} \times (AO - 1.0)\right)\] - Indirect Specular: The environment reflection is multiplied by the calculated specular occlusion term (\(SO\)), preventing visual artifacts while preserving specular energy on visible planar surfaces.