skip to content

What are the terms of the Cook-Torrance microfacet specular BRDF, and what physical effect does each one model?

level: middleimportance: must knowfreq 60%

answer

  1. a surface of tiny mirrors
  2. only facets along the half vector
  3. distribution, Fresnel, geometry
  4. four times two cosines below

basics

~20 s

Cook-Torrance specular is D·F·G / (4·dot(n,l)·dot(n,v)): D is the density of microfacets facing the half vector, F how much each reflects at that angle, G the share neither shadowed nor masked, and the denominator maps facet terms back to the macro surface.

solid answer

~40 s

Microfacet theory models a rough surface as many tiny perfect mirrors. Only facets whose normal equals the half vector `h = normalize(l + v)` reflect light from `l` toward `v`, so the BRDF is `f = D(h) * F(v,h) * G(l,v,h) / (4 * dot(n,l) * dot(n,v))`. `D`, the normal distribution function, is the density of facets oriented along `h`; GGX (Trowbridge-Reitz) is the usual choice, normalised and with a long tail. `F` is the Fresnel reflectance of those facets, usually Schlick's approximation evaluated with `dot(v,h)`. `G`, Smith's masking-shadowing term, removes facets hidden from the light or the viewer, which matters most at grazing angles and high roughness. The denominator comes from changing variables from facet normals to light directions and from projecting facet area onto the macro surface.

code

pseudocode · 17 lines
pseudocode
function specular_ggx(n, v, l, F0, roughness):
    NdotL = dot(n, l)
    if NdotL <= 0:
        return 0
    NdotV = max(dot(n, v), 0.0001)
    h     = normalize(v + l)
    NdotH = max(dot(n, h), 0)
    VdotH = max(dot(v, h), 0)
    a  = roughness * roughness
    a2 = a * a
    k  = NdotH * NdotH * (a2 - 1) + 1
    D  = a2 / (PI * k * k)
    F  = F0 + (1 - F0) * pow(1 - VdotH, 5)
    G1v = 2 * NdotV / (NdotV + sqrt(a2 + (1 - a2) * NdotV * NdotV))
    G1l = 2 * NdotL / (NdotL + sqrt(a2 + (1 - a2) * NdotL * NdotL))
    G  = G1v * G1l
    return D * F * G / (4 * NdotL * NdotV)

go deeper

for a junior

Recall that the specular term multiplies a distribution, a Fresnel and a geometry term over four times two cosines, and that the half vector picks which facets reflect.

for a middle

Explain each term physically, write the GGX distribution and Schlick's Fresnel, say which angle each uses, and show why a normalised D makes smooth highlights brighter rather than adding energy.

for a senior

Discuss separable versus height-correlated Smith, how the denominator stays finite at grazing angles, and what the single-scattering model cannot represent: inter-reflection, anisotropy and layers.

for a principal

Judge which approximations a renderer can afford per light versus per environment sample, and when extra lobes such as clear coat or anisotropy justify their cost across a game's materials.

## Microfacet theory A surface that looks smooth is, far below the size of a pixel, a landscape of tiny facets tilted in many directions. **Microfacet theory** treats each facet as a perfect mirror. A facet reflects light from direction `l` into direction `v` only if its own normal equals the **half vector** `h = normalize(l + v)`, the direction halfway between them. The surface's appearance then depends on three questions: how many facets point along `h`, how much light each of them reflects, and how many of them can see both the light and the viewer. ## The Cook-Torrance specular BRDF The modern form of the Cook-Torrance BRDF answers the three questions with three terms: `f_spec(l, v) = D(h) * F(v, h) * G(l, v, h) / (4 * dot(n, l) * dot(n, v))` | Term | Name | Models | Common choice | |---|---|---|---| | `D` | normal distribution function | density of facets oriented along `h` | GGX (Trowbridge-Reitz) | | `F` | Fresnel term | fraction each facet reflects at its angle | Schlick's approximation | | `G` | masking-shadowing term | facets hidden from the light or the viewer | Smith, GGX form | | `4 * dot(n,l) * dot(n,v)` | correction factor | change of variables and projected area | fixed by the derivation | A light's contribution is `f_spec * radiance * dot(n, l)`, plus a diffuse term for non-metals. ## D: the normal distribution function `D(h)` is a density: microfacet area per unit of macro surface area whose normal points along `h`. For GGX, with `alpha` the squared perceptual roughness: `D(h) = alpha^2 / (pi * (dot(n,h)^2 * (alpha^2 - 1) + 1)^2)` - It is **normalised**: the integral of `D(h) * dot(n, h)` over the hemisphere is 1, because the facets' projected area must equal the macro surface's area. Lowering roughness therefore raises the peak, `1 / (pi * alpha^2)` at `h = n`, as the lobe narrows; it redistributes energy rather than adding it. - It has a **long tail**: its density falls off polynomially away from the peak, while Beckmann's falls off exponentially. Highlights get a bright core with a soft halo, which matches many measured materials better. ## F: Fresnel `F` is the fraction of light a facet reflects rather than refracts. The facet's normal is `h`, so the angle that matters lies between `v` and `h`. Schlick's approximation is the usual choice: `F = F0 + (1 - F0) * (1 - dot(v, h))^5`, rising from `F0` head-on to 1 at grazing incidence. ## G: Smith masking and shadowing Facets can hide behind their neighbours from the viewer (**masking**) or from the light (**shadowing**). The Smith model derives `G` from the same distribution as `D`, so both terms agree about the surface's shape. Two forms are common: - **Separable**: `G = G1(l) * G1(v)`, treating masking and shadowing as independent. For GGX, `G1(x) = 2 * dot(n,x) / (dot(n,x) + sqrt(alpha^2 + (1 - alpha^2) * dot(n,x)^2))`, which is 1 head-on and, for any nonzero roughness, falls to 0 at grazing. - **Height-correlated**: accounts for a facet high on the surface being likely visible to both the light and the viewer. It darkens less, is more accurate at grazing angles and costs about the same. `G` matters most at grazing angles and high roughness, where many facets hide one another. ## The denominator The factor `4 * dot(n, l) * dot(n, v)` is not a tuning constant. The `4` and one `dot(v, h)` come from changing variables from a density over facet normals to a density over light directions. The remaining factors convert facet area seen from `l` and `v` into macro-surface area, and the `dot(v, h)` factors cancel because a mirror reflection makes `dot(l, h)` equal `dot(v, h)`. Multiplying by the lighting equation's `dot(n, l)` cancels that cosine, and `G1(v)` falls roughly in proportion to `dot(n, v)` near grazing, so the product stays finite; a shader still clamps `dot(n, v)` to a small positive value so it never divides by zero. ## Evaluating it per light 1. Compute `h` and the cosines `dot(n,l)`, `dot(n,v)`, `dot(n,h)`, `dot(v,h)`. 2. Return zero when `dot(n, l) <= 0`; clamp `dot(n, v)` away from zero. 3. Evaluate `D`, `F` and `G` with the same `alpha`. 4. Combine them, multiply by the light's radiance and `dot(n, l)`, and add the diffuse term, which many shaders weight by roughly `(1 - F)` and by `(1 - metallic)`. ## What the model leaves out - Light that bounces between facets more than once: the single-scattering model loses energy at high roughness. - Anisotropy: one `alpha` cannot describe brushed grooves; an anisotropic distribution needs two. - Layered materials such as a clear coat over paint, which need a second lobe. - Subsurface transport, which the separate diffuse term approximates.

  • What does GGX's long tail change visually compared with a Beckmann distribution?
    For the same roughness, GGX keeps more facet density far from the peak, so a highlight has a bright core surrounded by a soft glow that fades slowly, and rough reflections bleed further. Beckmann's exponential falloff gives a tighter, more Gaussian-looking spot. Many measured materials show the GGX-like halo, which is one reason it became the common default.
  • Why is the height-correlated Smith term preferred over the separable one?
    The separable form multiplies the masking and shadowing probabilities as if they were independent. A facet standing high on the surface is likely visible to both the light and the viewer, so the events are correlated and the product over-darkens, most visibly at grazing angles on rough surfaces. The height-correlated form models that correlation at similar cost.
  • Why does roughness appear in G as well as in D?
    Smith's G is derived from the same distribution of facet slopes as D. Rougher surfaces have steeper facets that block one another more often, so the share hidden from the light or the viewer grows with alpha. Using the same alpha in both terms keeps the masking consistent with the facet orientations D describes.

  • D is the probability that a ray hits the surface at all.
  • G adds back light that bounces between microfacets.
  • Inside the microfacet specular term, Fresnel uses dot(n, v) rather than dot(v, h).
  • The 4·dot(n,l)·dot(n,v) denominator is an arbitrary normalisation constant.
  • Roughness changes only D; the geometry term does not depend on it.