Processing math: 100%

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:

power=(2α22)

roughness is one of the material properties defined by our .pov files. We’ll use UE4’s convention for determining α from roughness:

α=roughness2

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:

power=(2roughness22)

This is an arbitrary convention but I have found it works reasonably well!

GGX Equations

Normal Distribution Function

Cook_Torrance_D_GGX

DGGX=χ+(nh)α2π((nh)2(α21)+1)2

χ+ is the positive characteristic function:

χ+(a)={1if a>00if a0

Geometric Shadowing Function

Cook_Torrance_G_GGX

GGGX=G1(v)G1(l) G1(x)=χ+(xhxn)21+1+α2tan2(θx))

θx is the angle between ˆx and ˆn.

tan2(θ)=sec2(θ)1 =1cos2(θ)1 =1cos2(θ)cos2(θ)

tan2(θx)=1(xn)2(xn)2

Implementation Details

Every dot product in these equations should be “saturated”, i.e. clamped between 0 and 1.