# Lambert and the division by PI

This topic is 2414 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I define my diffuse lighting term as the following:

float4 Diffuse = Ka + (Kd / PI) * Ei;

Ei being the color of the light combined with the materials diffuse color multiplied by N dot L.
Ka = Ambient constant
Kd = Diffuse constant

So do I understand that right when I say my outgoing energy is < incoming energy ?
Because doing so what I get as a result is a darker color than when I don't divide by PI.

e.g.
Ei = float4(1.0f, 1.0f, 1.0f, 1.0f);
would give me a complete white surface on a plane with a directional light shining directly onto it, while doing the division by PI the result looks more like something around
~ RGBA(0.7, 0.7, 0.7, 1.0f).

Now if what I said before was true would it even be possible to get a perfect white as a result if the output is always going to be darker than that? Edited by lipsryme

##### Share on other sites
You divide by pi because a BRDF works on infinitesimally small solid angles (it is a derivative), the total radiance contribution is summed up over the whole diffuse hemisphere which cancels out the 1/pi term to ensure energy conservation (note that you've already failed in that respect by using an ambient term, but anyway). And Ei can (and usually is) more intense than just (1, 1, 1).

This thread might make things clearer (pretty much the same question).

##### Share on other sites
The energy conservation thing is a little tricky to understand at first. This is because when you render you usually only deal with the amount of reflected energy that goes towards the viewer, but energy conservation is concerned with the amount of energy reflected in all directions. Formally you definite it as exitant irradiance <= incident irradiance, or

[attachment=9314:CodeCogsEqn.gif]

where Eo is defined like this:

[attachment=9312:CodeCogsEqn(1).gif]

where f is our BRDF. Conceptually you can imagine this as moving the camera everywhere around the hemisphere surrounding the normal, applying the BRDF, and summing up the amount that's reflected toward the camera. This is very different from saying "the amount of energy reflected in the view direction should be less than or equal to the incident lighting", which isn't required to be true for energy conservation. In fact with a physically-based specular term the specular reflection can be many times greater than the incident irradiance.

If we use Lambertian diffuse as our BRDF, we can derive the 1/pi factor required for energy conservation. For Lambertian our BRDF = DiffuseAlbedo, so if we assume albedo = 1 then our BRDF drops out completely. If we then assume that our only incident irradiance comes from a directional light with intensity = 1.0 that's exactly perpendicular to the surface, then Ei = 1.0 and that also drops. Which leaves us with this, once we convert from hemispherical integral to spherical double integral form:

[attachment=9313:CodeCogsEqn(2).gif]

If we solve that integral we get a result of pi, which means that if we multiply our diffuse by 1/pi then we'll satisfy the energy conservation inequality.

##### Share on other sites
Thanks a lot both of you.
I'm starting to understand

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634058
• Total Posts
3015289
×