Chapter 68: Cook-Torrance
In 1982, Robert Cook and Kenneth Torrance published a reflectance model that more accurately represented the physical reality of light reflectance than the Phong and Blinn-Phong models we discussed in Lecture 6.
The proposed method is general purpose - it has three “pluggable” components that can be replaced with equations of your choice. It is also effective at representing a variety of materials, whereas a BRDF like Blinn-Phong is really only good at representing plastics and some metals (though that point is debatable). As such, it is still in common usage today. Though that is perhaps a moot point, since the Phong reflection model is a weak approximation from 1975 that is still in common usage. Regardless…
With previous shading models, we had something of the form
To compute total reflectance with the Blinn-Phong model. Here we have defined for the diffuse reflectance and for the specular reflectance. Note the “power” term of the specular highlight is now to avoid confusion with forcoming equations.
This is the same equation we have been using and have already implemented.
Cook and Torrance propose a variation of this equation:
This equation introduces two concepts:
- The diffuse and specular reflectance components are now scaled by some variables and .
- We pull the and dot product out of the diffuse reflectance and make it a part of the sum. This makes our a constant, though we can modify this definition later if we choose to. This also implies that our specular reflectance is also multiplied by the same dot product (unlike before in Blinn-Phong).
As we will soon learn, however, now includes a divisor, which will simply cancel out with the in the numerator. This convention is adopted for two reasons:
- It comes from the derivation of the forthcoming equation (specifically, since it is a microfacet model).
- To be confusing.
Those I suspect that the second reason is only from my perspective.
Nevertheless, note that many texts and explanations adopt this convention.
What about and ?
and are a constant ratio that balances out the diffuse and specular contributions to our reflectance.
Sometimes we ignore the altogether and simply write:
This ratio is based on the observation that (except for emissive materials), conservation of energy implies that a material can only reflect as much energy (light) as it takes in.
Therefore if a material reflects a lot of light specularly, then it must reflect less light diffusely.
What about ?
I’m getting there.
Note the n-dot-l divisor that I warned would be there!
Note also that in the literature and other places you will sometimes find instead of in the denominator. This is an error that was made in the original Cook-Torrance paper and has thus been repeated in many places. The correct derivation of this equation has the . It’s a pretty small difference in a constant factor, though, so it’s not incredibly important to get it right.
What about ?
, , and are the three “pluggable” functions that make up the Cook-Torrance specular reflectance. You can choose from a wide variety of options for these equations. To talk about what they mean, however, we need to discuss the core theory behind the Cook-Torrance model.
Cook-Torrance is a microfacet model, which means that it approximates surfaces as a collection of small individual faces called microfacets. You can think of these microfacets as being polygonal approximations of the surface at a sub-pixel level.
The important concept here is that the normal of the surface and the normals of each microfacet may not be the same. For exceptionally smooth surfaces, like a perfect mirror, all the microfacets face the same direction which is , the normal of the surface. However, for matte or rough surfaces, such as matte paint or stone, the microfacets face random directions.
On rough surfaces, these microfacets can occlude other facets, cast shadows on facets, and be pointing away from the normal.
The Cook-Torrance model attempts to account for these three phenomena.
So… what about ?
is the Normal Distribution Function, which accounts for the fraction of facets which reflect light at the viewer.
is the Geometric Attenuation Function, which accounts for the shadowing and masking of facets by one another.
is the Fresnel Function, which accounts for the Fresnel Effect, which causes rays with high angle of incidence to reflect with more specularity.
and have a less significant contribution to the final shaded result than , so we will cover first.
is the part of the Cook-Torrance model which defines the shape of the specular highlight. It describes the concentration of facets oriented to reflect specularily, e.g. facets for which There are a lot of choices here. It may not be surprising that one of the choices is Blinn-Phong, that is, we can choose to use the same specular highlight shape as we previously used in the Blinn-Phong reflectance model.
Now this looks sort of familiar! Except, we are dividing by something now… and our clean “power” exponent has been replaced by something more nasty.
Let’s explain these two changes - starting with the divisor.
Our functions for Cook-Torrance need to be normalized such that:
The result of this normalization in our Blinn-Phong case (and indeed, for many different cases) is a factor of
But what is ?
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
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
Note that for traditional Blinn-Phong (specifically, not just but if we aren’t doing Cook-Torrance at all), you should still use the above power equation for
but you don’t need to square the roughness constant:
This is an arbitrary convention but I have found it works reasonably well!
As I have mentioned, there are other choices for Normal Distribution function. Instead of Blinn-Phong, the original authors Cook and Torrance recommend the Beckmann distribution. Modern authors usually recommend the more recent GGX distribution.
However, these is enough to process without adding these equations in as well. For now we’ll just stick with the Blinn-Phong distribution function, as it is good enough. Indeed, the Blinn-Phong and Beckmann functions are quite similar for many values of .
For additional function choices for , as well as choices for and , can be found in the reference.
Now we will cover and .
is the part of the Cook-Torrance model which accounts for attenuation caused by neighboring microfacets. It describes the fraction of microfacets which are neither occluded or shadowed. Microfacets can block the light from reaching other microfacets, and they can also obscure the microfacets from the viewer’s perspective. This effect is more prominent on rougher materials.
is therefore a number from 0 to 1 which indicates the proportion of light that is not blocked by either of these effects. As such it is defined as the minimum of two different factors which calculate either type of attenuation.
is the part of the Cook-Torrance model which accounts for the fresnel effect.
In computer graphics the most commonly used approximation for the fresnel effect is Schlick’s Approximation:
Where is the reflectance at normal incidence, given by:
Where is the material’s index of refraction.
And if you’re wondering, yes! Opaque materials can and do still have indices of refraction. See here.
Coding Labs Covers Cook-Torrance with diagrams, in the context of PBR renderer using Monte-Carlo IBL
RenderMan Pixar’s explanation of Cook-Torrance in the context of RenderMan, their offline rendering system and associated shader language. Not completely useful to us since it skips some aspects that are important to us (and either implicit or ignored in their case).
Walter et. al. Microfacet Models for Refraction through Rough Surfaces. Introduces the GGX functions.
Graphic Rants Very informative blog post from a UE4 dev describing different function choices for D, F, G.
SIGGRAPH 2012 Several presentations including general PBR exploration.
SIGGRAPH 2015 More recent slides from the previous lesson.
SIGGRAPH 2010 Some generally useful coursenotes about correct lighting.
ruh.li Pretty straight-forward explanation of Cook-Torrance with sample code.
Correct Specular Term? StackExchange question about variations in the Cook-Torrance equation.
Importance Sampling? StackExchange question about importance sampling, with some useful explanation of Cook-Torrance components.
Shininess to roughness? StackExchange question about how to convert from Blinn-Phong shininess to Cook-Torrance roughness.
Frostbite Paper on how Frostbite converted their engine to PBR (Cook-Torrance).
Disney BRDF Disney paper with lots of BRDF discussion.