**Introduction**

In recent years, there are more and more papers talking about applying physically based BRDF in games. So I decided to spend some time to investigate it. For a BRDF to be physically plausible, it should satisfy 2 conditions:

- Reciprocity: The incident light direction(
*l)*and reflected light direction(*r*) for a BRDF(*f*) is the same after the incident and reflected direction is swapped. i.e.*f*(*l*,*r*)=*f*(*r*,*l*) - Energy Conservation: The total energy of reflected light is less than or equal to the energy of the incident light. i.e.

A physically based specular BRDF is based on micro-facet theory, which describe a surface is composed of many micro-facets and each micro-facet will only reflect light in a single direction according to their normal(*m*):

So, in the above diagram, for light coming from direction *l* to be reflected to viewing direction *v*, the micro-facet normal *m* must be equals to the half vector between *l* and *v*.

A micro-facet BRDF has the following form:

which consists of 3 terms: Fresnel term(*F*), Distribution term(*D*) and Geometry term(*G*). Their meaning can be found in the background talk presented by Naty Hoffman in siggraph 2010. And these 3 terms can be chosen independently as stated in the talk Physically-based lighting in Call of Duty:Black Ops (although “Microfacet Models for Refraction through Rough Surfaces“ states that some *G* depends on *D* to maintain energy conservation, but some *G* are extended to handle arbitrary distribution, so in this blog post, I assume that the G function is independent of *D*). So I decided to find some distribution functions *D* and geometry functions *G *and play with different combinations to see how it affects the rendering result. You can also play around with different combinations using the WebGL demo(need a webGL enabled browser such as Chrome) here (at the last section).

**Fresnel Term**

In this test, I use the common Schlick approximation to the Fresnel equation:

and *f0 *is found by using the following equation:

where the refractive index *n* can be tuned in the demo.

**Distribution Term**

Distribution term is used to describe how the microfacet normal distributed around a given direction. In the demo, I used two distribution function: Blinn-Phong and Beckmann distribution function.

For Blinn-Phong distribution, we can derive the distribution function by satisfying the equation:

which means that the projected microfacet area is equal to macro surface area for any projected direction *v*. So we choose *v*=*n* which simplify the equation:

To derive the Blinn Phong distribution function from original Blinn Phong specular term, we just need to multiply a constant *K* to satisfy the equation:

While the Beckmann distribution has the following form:

To convert between the roughness *m* in Beckmann distribution and shininess *α* in Blinn-Phong distribution, the following formula is used:

which gives a very similar result when both refractive index *n* and roughness *m* are small. When *n*>10 and *m*>0.5 the 2 distribution start to show difference and the difference will get larger when both *m* and *n* are getter larger.

**Geometry Term**

Geometry term is used for describing how much the microfacet is blocked by other microfacet. In the demo, 4 geometry terms have been tested: implicit, Cook-Torrance, Schlick approximation to Smith’s shadowing function and Walter approximation to Smith’s shadowing function.

The first one is implicit geometry function which has the form:

It is called implicit because when it is used, the microfacet BRDF will only depends on Fresnel equation and distribution function.

The second one used for testing is Cook-Torrance geometry function:

And the other 2 geometry functions used are both trying to approximate the Smith’s shadowing function which decompose the geometry function into another 2 geometry function as below:

With Schlick’s approximation, the following G1 is used:

While Walter’s approximate G1 as:

Among 4 geometry terms, the implicit one always show a darker specular color. While the other 3 geometry functions have similar appearance when the roughness *m* is small. When *m* is getter larger, the Schlick function will slightly darker than the Cook-Torrance and Walter geometry function. Both Cook-Torrance and Walter function gives a very similar results:

**Energy Conservation between Diffuse and Specular BRDF**

Energy conservation is important for a physically based BRDF, but most paper only talks about the conservation within the specular BRDF. How about the energy conservation between the diffuse term and specular term? I can only find 2 ways to do this from the paper provided by Tri-Ace. They multiply the diffuse reflection term with a diffuse Fresnel term:

And they later discovered that this term can be approximated with (1- *f*0), which will show very similar results. However, using this term will violate the reciprocity of the BRDF. If diffuse energy conservation is enabled, when the refractive index change, the ratio between the diffuse and specular reflection also change accordingly.

**WebGL Demo**

I provide a webGL program so that you can play around with the settings I described above. The model is illuminated by a single white directional light and the red color is the diffuse color. The diffuse BRDF is just a lambert surface which can be turned off in the demo. Dragging inside the viewport can rotate the camera. The source code can be downloaded from here.

Screen shot of the demo |

**Conclusion**

Physically plausible BRDF can give a different material appearance for a surface compare to traditional lighting model. However, in this post, I only use 1 microfacet BRDF for all 3 RGB channels, using different BRDF settings for difference channels is also possible as some material like copper and gold have different *f*0 term in RGB channels. Also only direct lighting is investigated where secondary lighting BRDF will be left for future blog post.

**Reference**

[1] Background: Physically-Based Shading (Naty Hoffman): http://renderwonk.com/publications/s2010-shading-course/hoffman/s2010_physically_based_shading_hoffman_a_notes.pdf

[2] Practical Implementation of Physically-Based Shading Models at tri-Ace (Yoshiharu Gotanda): http://renderwonk.com/publications/s2010-shading-course/gotanda/course_note_practical_implementation_at_triace.pdf

[3] Crafting Physically Motivated Shading Models for Game Development (Naty Hoffman): http://renderwonk.com/publications/s2010-shading-course/hoffman/s2010_physically_based_shading_hoffman_b_notes.pdf

[4] Physically-based lighting in Call of Duty: Black Ops: http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pptx

[5] Microfacet Models for Refraction through Rough Surfaces:http://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf

[6] http://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/