1/40
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Cook-Torrance reflectance equation
r = ka + sum over lights of [ lc * (n.l) * (drd + srs) ], where the diffuse and specular terms are scaled by energy-conserving weights d and s (s + d = 1)
Cook-Torrance specular term rs
rs = (D * G * F) / (4 * (n.l) * (n.v)) -- the three pluggable microfacet functions divided by a normalization denominator
Why divide by 4, not pi, in rs
The original 1982 Cook-Torrance paper had a typo using pi in the denominator; the correct derivation of the microfacet specular term uses 4(n.l)(n.v)
D term (Normal Distribution Function)
Describes the fraction of microfacets whose normal aligns with the half-vector h, i.e. the facets oriented to reflect light straight at the viewer. Defines the shape/size of the specular highlight
G term (Geometric Attenuation Function)
Accounts for microfacets shadowing or masking each other; returns the fraction of facets that are neither occluded from the light nor from the viewer
F term (Fresnel Function)
Accounts for the Fresnel effect: reflectance increases at grazing (high) angles of incidence
Microfacet model
Treats a surface as a huge collection of tiny, randomly oriented mirror-like facets rather than one smooth surface; roughness controls how scattered the facet normals are
Roughness parameter alpha
Cook-Torrance's roughness control, 0 = perfectly smooth, 1 = maximally rough; conventionally alpha = roughness^2
Why square roughness into alpha
Perceptually linear roughness values map more naturally to visual results when squared before being fed into the D and G functions (artist-friendly remap)
GGX / Trowbridge-Reitz distribution
D(h) = alpha^2 / (pi * ((n.h)^2 * (alpha^2 - 1) + 1)^2) -- an alternative NDF to Blinn-Phong/Beckmann with longer, softer highlight tails
How GGX differs visually from Blinn-Phong
GGX has a narrower highlight peak but much longer falloff tails, producing a tight bright core with a soft glow around it, closer to measured real-world materials
Blinn-Phong NDF (Cook-Torrance form)
Dblinn = 1/(pi*alpha^2) * (n.h)^(2/alpha^2 - 2) -- the classic Blinn-Phong exponent rewritten in terms of alpha and normalized for energy conservation
NDF normalization condition
Integral over the hemisphere of D(h)*(h.n) dwi must equal 1, ensuring the distribution doesn't add or remove energy
Cook-Torrance's original G formula
G = min(1, 2(h.n)(n.v)/(v.h), 2(h.n)(n.l)/(v.h)) -- takes the minimum of the view-masking and light-shadowing terms
Smith geometry function
G(n,v,l) = G1(n.v) * G1(n.l), splitting occlusion into a separate view term and light term multiplied together; the standard pairing for GGX
Schlick-GGX approximation
G1(x,k) = x / (x*(1-k) + k), a fast single-term approximation used inside the Smith geometry function
Karis' k remap for direct lighting
k = (roughness + 1)^2 / 8 -- the roughness-to-k mapping recommended for analytic (non-IBL) light sources in Smith-Schlick-GGX
Schlick's Fresnel approximation
F = F0 + (1 - F0) * (1 - (v.h))^5 -- a fast polynomial approximation to the full Fresnel equations
F0 (reflectance at normal incidence)
The fraction of light reflected when viewed straight-on (0 degree incidence); low (~0.02-0.05) for dielectrics, high and colored for metals
F0 from index of refraction
F0 = ((n - 1) / (n + 1))^2, where n is the material's index of refraction; used for dielectrics
Metallic workflow F0 formula
F0 = mix(vec3(0.04), albedo, metallic) -- dielectrics get a flat ~4% reflectance, metals reflect (and tint) their own albedo color
Why metals have no diffuse term
In a metal, light that enters the surface is absorbed or re-emitted as reflection rather than scattering back out diffusely, so metals only exhibit specular (tinted) reflection
Energy-conserving diffuse weight kd
kd = (1 - F) * (1 - metallic) -- diffuse light is whatever fraction wasn't reflected specularly (1-F), and metals get none of it
Normalized Lambertian diffuse term
diffuse = kd * albedo / pi -- Cook-Torrance divides diffuse by pi (unlike un-normalized Blinn-Phong) to keep the BRDF physically energy-balanced
Half vector h
h = normalize(l + v) -- the vector halfway between the light direction and the view direction; microfacets aligned with h are the ones that reflect light toward the viewer
Denominator epsilon guard
A tiny constant (e.g. 1e-4) added to 4NdotVNdotL in the specular denominator to prevent divide-by-zero at grazing angles
Roughness clamping
Roughness is clamped to a small minimum (e.g. 0.045) instead of allowing exactly 0, since alpha=0 collapses the GGX denominator and causes divide-by-zero/NaN highlights
glTF metallic-roughness workflow
The standard PBR material convention: an albedo (base color) map, a combined or separate metallic value, a roughness value, plus normal, ambient occlusion, and emissive maps
albedoMap / albedoTint
Base color texture and tint multiplier; replaces the old diffuseMap in a PBR material, feeding both the diffuse term and (via metallic) the specular F0
metallicMap / metallicFactor
Texture and scalar controlling how conductor-like a surface is (0 = dielectric, 1 = metal); the factor scales the texture or acts as the value directly if no map is bound
roughnessMap / roughnessFactor
Texture and scalar controlling microfacet roughness fed into both the D and G functions; same texture/scale-or-standalone pattern as metallic
aoMap (ambient occlusion map)
Texture storing how exposed each point is to ambient/indirect light; multiplies the ambient term so crevices and contact points appear darker
emissiveMap / emissiveTint
Texture and tint for self-illumination that is added to the final lit color independent of any light source, unaffected by the BRDF
normalMap usage (unchanged by PBR conversion)
Sampled and remapped from [0,1] to [-1,1] to perturb the surface normal; behaves identically whether the shading model is Blinn-Phong or Cook-Torrance
Ambient term as an IBL placeholder
ambient = ambientLight * albedo * ao -- a flat constant standing in for real image-based lighting; gives the AO map something to modulate until proper IBL (irradiance + prefiltered specular + BRDF LUT) is added
Point light attenuation (from the shader)
attenuation = clamp(1 - distance^2/radius^2, 0, 1)^2 -- a smooth, physically-inspired falloff bounded by a light radius, independent of the BRDF used
Spot light cone falloff
fallout = clamp((theta - outerCutOff) / (innerCutOff - outerCutOff), 0, 1), where theta is the cosine angle between the light-to-fragment direction and the spot's forward direction
Directional light characteristics
Uses a constant direction (no position) and no distance attenuation, representing an infinitely distant light source like the sun
NdotL guard in the light loop
Specular and diffuse contributions are only computed when n.l > 0, since a surface facing away from the light receives no illumination and the BRDF math is undefined/wasted otherwise
Why old Blinn-Phong wasn't physically based
It uses an arbitrary fixed exponent tuned by eye, no energy conservation between diffuse and specular, and no real microfacet or Fresnel behavior -- effective for plastics but not general materials
Rendering equation role of DGF/4NdotVNdotL
This whole fraction is the specular BRDF term inside the reflectance sum; it replaces the single pow(NdotH, shininess) term from Blinn-Phong