# Physically Based Blinn Phong questions

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

## Recommended Posts

According to RTR3 and this article (n+8)/8Pi is the energy conservation term for Blinn-Phong.

So if we integrate it in

ignoring both the visibility and the fresnel terms we should use ?

Far Cry 3 seems to be using (n+2)/2Pi (slide 43) which is incorrect? And the same goes for this topic.

Or am I missing something? Edited by TiagoCosta

##### Share on other sites

You have to distiguish between normalizing a BRDF and normalizing a microfacet distribution. (And between Phong and Blinn-Phong). This is a relatively nice online resource on the topic:
http://www.thetenthplanet.de/archives/255

(n+2)/(2*pi) is for the modified Phong BRDF (i.e. the BRDF without the cosine in the denominator).
It is also correct for the Blinn-Phong MF-distribution.

(n+8)/(8*pi) is an approximation commonly used for the modified Blinn-Phong BRDF. As far as I remember, it is slightly too large, but in most cases where this BRDF is used it doesn't really matter.

##### Share on other sites

Related questions:
Should I remove the Pi in every light source? Or just in point lights?
And the Lambert normalization factor is cdiff/Pi, should the Pi also be removed? Edited by TiagoCosta

##### Share on other sites

Related questions:
Should I remove the Pi in every light source? Or just in point lights?
And the Lambert normalization factor is cdiff/Pi, should the Pi also be removed?

The factor of 1/pi is independent of the light source. If you integrate the Lambertian cosine term over the hemisphere of incoming directions, you get:

[eqn]\displaystyle \int_\Omega | \omega \cdot \mathbf{n} | ~ \text{d} \omega = \int_0^{2 \pi} \int_0^{\frac{\pi}{2}} \sin{\theta} \cos{\theta} ~ \text{d} \theta ~ \text{d} \phi = \pi[/eqn]

So to make sure your BRDF is normalized, you need to divide by pi. In realtime rendering this division is often precomputed into the light intensity values themselves, as you achieve essentially the same result by doing that (it should be clear by looking at the rendering equation).

Edited by Bacterius

##### Share on other sites
The RDFs and NDFs nec­es­sar­ily con­tain , as the result of an inte­gra­tion over parts of a sphere. In the shader code how­ever, does usu­ally not appear, because it can­cels out when mul­ti­ply­ing with irra­di­ance, which is itself an inte­gra­tion over parts of a sphere.
Con­sider a point light source mod­eled as a small and very far away sphere, at dis­tance . Let this sphere have radius and a homo­ge­neous emis­sive sur­face of radi­ance . From the point of view of the receiv­ing sur­face, the solid angle sub­tended by this sphere is a spher­i­cal cap, and so the irra­di­ance inte­grates to . So there you have in the for­mula for the irra­di­ance of a point light, neatly can­cel­ing with the from the RDF/?NDF.
So Pi or no Pi? Edited by TiagoCosta

##### Share on other sites
The way I see it, the derivation in the link is a special case for a small circular area light. Small means small enough (as seen from the surface) that you can assume the fr*cos term is constant over the projected area and take it out of the integral. For this case it's correct, but I'm pretty sure you cannot generalize this to arbitrary lights.

But, as Bacterius said, for _direct_ illumination from delta lights, you can always pull the pi into the light's intensity. Example:

Consider a point light 1 unit above a surface normal to the light. Let's say the light causes an irradiance of E=1 at the surface point closest to the light. For a diffuse BRDF we get for every direction
L_o(wo) = fr*E.

Case 1: With fr = 1 we get L_o = 1 for every direction. The radiant exitance (Lo*cos integrated over hemisphere) is M = pi. So we have M>E which means we reflect more than came in.

Case 2: With fr = 1/pi we get exactly M=E, which is correct.

Of course, in case 1 you can always say "My light source was really causing E=1*pi and my BRDF was really 1/pi". You'll get the exact same image (if only direct illumination from this point light is considered), but you safe a division by pi.

Bottom line:
In my opinion, the pi should always be there. But if you're only doing direct illumination from delta lights and every multiplication counts, you can pull the pi into the light sources. But that's only my personal opinion, so you should take it with a pinch of salt.

EDIT: Of course, if you decide to "pull pi into the light source", you have to multiply _every_ BRDF by pi. (And every BRDF component, e.g. if you only remove pi in the diffuse term, you'll obviously shift the balance between diffuse and glossy.) Edited by macnihilist

##### Share on other sites

For diffuse alone the pi factor isn't really that important. Like others have mentioned you can consider it to be "baked" into the light intensity and so the difference is mostly arbitrary. What's it's actually important for is balancing your diffuse with your specular, which is what machnilist mentioned above. If you don't properly account for the 1/pi you can easily end up with diffuse that's too bright, and your materials won't look right.

##### Share on other sites

Thanks for all answers! So the most important thing is consistency, either both diffuse and specular BRDF have the pi factor or neither.

I did a little more research, and found the calculations that eliminate the Pi factor and an explanation in SIGGRAPH 2012 PBR Course notes (page 21).

##### Share on other sites

Especially if you're doing tone-mapping, a constant intensity difference everywhere will probably make little to no difference to the final render.

##### Share on other sites
Of course, in case 1 you can always say "My light source was really causing E=1*pi and my BRDF was really 1/pi". You'll get the exact same image (if only direct illumination from this point light is considered), but you safe a division by pi.

I haven't understood which part should be divided by pi if the light is not implicitly causing pi*1 light.

Should it be:

((diffuse / pi) + (f_microfacet)) * light_energy

or

(diffuse + f_microfacet) * (light_energy / pi)

##### Share on other sites
I haven't understood which part should be divided by pi if the light is not implicitly causing pi*1 light.

When normalized both lambert diffuse and blinn-phong NDF terms have Pi in the denominator so:

##### Share on other sites
Ok, in that case I see how it makes sense to "pretend" that a light really emits pi times as much energy.
But then I don't understand MJP's comment, that the pi is important for balancing diffuse and specular. How so if they both are affected equally? Edited by B_old

##### Share on other sites
But that I don't understand MJP's comment, that the pi is important for balancing diffuse and specular. How so if they both are affected equally?

He's saying that if you remove the pi from the diffuse and leave it in the specular the lighting wont be balanced because the diffuse will too bright, and the same will happen the other way around, if you remove the pi from the specular and leave it in the diffuse the specular will be too bright.