Diffuse normalization factor

Sep 17, 2011 at 12:46 PM
Edited Sep 17, 2011 at 12:46 PM

In some samples shaders like "FinalPassLP.hlsl" and "Lights.hlsl" a Diffuse and also a specular normalization factor are used.

What is the theory behind those factors? I didn't found any reference to those factors in the book but I would like to how what are they for?

Developer
Sep 17, 2011 at 7:55 PM
Edited Sep 17, 2011 at 7:55 PM

Hi Tiago,

The idea behind the normalization factors is that you want to be conserve energy with your lighting. Basically, the amount of light being reflected by a surface should never be more than the amount of incoming light (and by the same token if the albedo is 1, it should be the same as the amount of incoming light). To do this you need the normalization factors, which you can get working out the integral of your BRDF over the hemisphere and solving for 1. This blog here goes through the math and has some pictures to illustrate the difference: http://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/. You can also check out "Crafting Physically Motivated Shading Models for Game Development" from SIGGRAPH 2010 for more in-depth information. I believe the 3rd edition of Real-Time Rendering also has similar information.

One thing that's probably not obvious from my code is that even with the normalization factors, when you combine phong + specular you need to balance them so that together they are energy-conserving. You can do this easily by having a [0,1] balance factor that lerps between full diffuse, or full specular. I think in the Hieroglyph samples I just implicitly built that into the diffuse and specular albedos, I'll have to check on that and maybe explicitly point that out in the shader code.

-Matt

Sep 17, 2011 at 9:57 PM

Thanks for the explanation. Specular highlights look a lot better with normalization, definitely worth implementing (at least in some materials).