Lecture 8: Cook-Torrance GGX
Power exponent
In traditional Blinn-Phong we had a simple power parameter (usually called shininess
) that we used to control the size and intensity of the specular highlight.
In Cook-Torrance we want to have a more general parameter that can be used in multiple places.
Cook-Torrance defines a constant α that indicates the roughness of the material, with 0
indicating ideal smooth surfaces and 1
indicating maximum roughness.
In practice you never want to use absolute 0
or 1
since these edge cases tend to produce divide-by-zero and other issues.
We can then relate our new α parameter to our old power
variable as such:
roughness
is one of the material properties defined by our .pov
files.
We’ll use UE4’s convention for determining α from roughness:
Note that for traditional Blinn-Phong (specifically, not just Dblinn but if we aren’t doing Cook-Torrance at all), you should still use the above power equation for shininess
,
but you don’t need to square the roughness constant:
This is an arbitrary convention but I have found it works reasonably well!
GGX Equations
Normal Distribution Function
χ+ is the positive characteristic function:
χ+(a)={1if a>00if a≤0Geometric Shadowing Function
θx is the angle between ˆx and ˆn.
tan2(θ)=sec2(θ)−1 =1cos2(θ)−1 =1−cos2(θ)cos2(θ)
tan2(θx)=1−(→x⋅→n)2(→x⋅→n)2Implementation Details
Every dot product in these equations should be “saturated”, i.e. clamped between 0 and 1.