Jump to content

  • Log In with Google      Sign In   
  • Create Account

Physically Based Blinn Phong questions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 11 January 2013 - 09:46 AM

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

So if we integrate it in microBRDF.png

ignoring both the visibility and the fresnel terms we should use Code_Cogs_Eqn.gif ?

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, 11 January 2013 - 09:50 AM.


Sponsor:

#2 macnihilist   Members   -  Reputation: 368

Like
2Likes
Like

Posted 11 January 2013 - 11:07 AM

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.
 



#3 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 11 January 2013 - 04:18 PM

Thanks! That link explained it.

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, 11 January 2013 - 04:18 PM.


#4 Bacterius   Crossbones+   -  Reputation: 9281

Like
0Likes
Like

Posted 11 January 2013 - 05:05 PM

Thanks! That link explained it.

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:

 

 

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, 11 January 2013 - 05:07 PM.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#5 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 11 January 2013 - 05:40 PM

From macnihilist link:
The RDFs and NDFs nec­es­sar­ily con­tain quicklatex.com-8a8665f7cf659993bfd05b5dd, as the result of an inte­gra­tion over parts of a sphere. In the shader code how­ever, quicklatex.com-8a8665f7cf659993bfd05b5dd 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 quicklatex.com-2650c16c3c9e38aa51f9867a2. Let this sphere have radius quicklatex.com-41b55da56ff026ecf99579290 and a homo­ge­neous emis­sive sur­face of radi­ance quicklatex.com-6f95e74d0f47b89836795acc8. 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 quicklatex.com-1a5fd135a91ccf6615e08f641. So there you have quicklatex.com-8a8665f7cf659993bfd05b5dd in the for­mula for the irra­di­ance of a point light, neatly can­cel­ing with the quicklatex.com-8a8665f7cf659993bfd05b5dd from the RDF/​NDF.
So Pi or no Pi?

Edited by TiagoCosta, 11 January 2013 - 05:41 PM.


#6 macnihilist   Members   -  Reputation: 368

Like
1Likes
Like

Posted 12 January 2013 - 04:04 AM

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, 12 January 2013 - 04:20 AM.


#7 MJP   Moderators   -  Reputation: 11761

Like
1Likes
Like

Posted 12 January 2013 - 04:51 AM

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.



#8 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 13 January 2013 - 03:52 PM

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).



#9 Bacterius   Crossbones+   -  Reputation: 9281

Like
0Likes
Like

Posted 14 January 2013 - 04:13 AM

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


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#10 B_old   Members   -  Reputation: 668

Like
0Likes
Like

Posted 14 January 2013 - 08:16 AM

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)


#11 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 14 January 2013 - 08:47 AM

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:

 

24y7i1j.jpg 25jgh3p.jpg



#12 B_old   Members   -  Reputation: 668

Like
0Likes
Like

Posted 14 January 2013 - 09:24 AM

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, 14 January 2013 - 12:21 PM.


#13 TiagoCosta   Crossbones+   -  Reputation: 2455

Like
0Likes
Like

Posted 14 January 2013 - 10:32 AM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS