Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path tracing: why is there no cosine term when calculating perfect mirror reflection?

I've been looking at Kevin Beason's path tracer "smallpt" (http://www.kevinbeason.com/smallpt/) and have a question regarding the mirror reflection calculation (line 62).

My understanding of the rendering equation (http://en.wikipedia.org/wiki/Rendering_equation) is that to calculate the outgoing radiance for a differential area, you integrate the incoming radiance over each differential solid angle in a hemisphere above the differential area, weighted by the BRDF and a cosine factor, with the purpose of the cosine factor being to reduce the contribution to the differential irradiance landing on the area for incoming light at more grazing angles (as light at these angles will be spread across a larger area, meaning that the differential area in question will receive less of this light).

But in the smallpt code this cosine factor is not part of the calculation for mirror reflection on line 62. (It is also omitted from the diffuse calculation, but I believe that to be because the diffuse ray is chosen with cosine-weighted importance sampling, meaning that an explicit multiplication by the cosine factor is not needed).

My question is why doesn't the mirror reflection calculation require the cosine factor? If the incoming radiance is the same, but the angle of incidence becomes more grazing, then won't the irradiance landing on the differential area be decreased, regardless of whether diffuse or mirror reflection is being considered?

like image 345
Nick Kovac Avatar asked Mar 16 '14 01:03

Nick Kovac


3 Answers

This is a question that I have raised recently: Why the BRDF of specular reflection is infinite in the reflection direction?

For perfect specular reflection, BRDF is infinite in the reflection direction. So we can't integrate for rendering equation.

But we can make reflected radiance equal the incident according to energy conservation.

like image 74
chaosink Avatar answered Nov 15 '22 11:11

chaosink


The diffuse light paths are, as you suspect, chosen such that the cosine term is balanced out by picking rays proportionally more often in the direction where the cosine would have been higher (i.e. closer to the direction of the surface normal) a good explanation can be found here. This makes the simple division by the number of samples enough to accurately model diffuse reflection.

In the rendering equation, which is the basis for path tracing, there is a term for the reflected light:

Here represents the BRDF of the material. For a perfect reflector this BRDF would be zero in every direction except for in the reflecting direction. It then makes little sense to sample any other direction than the reflected ray path. Even so, the dot product at the end would not be omitted.

But in the smallpt code this cosine factor is not part of the calculation for mirror reflection on line 62.

By the definitions stated above, my conclusion is that it should be part of it, since this would make it needless to specify special cases for one material or another.

like image 22
dcanelhas Avatar answered Nov 15 '22 09:11

dcanelhas


That's a very good question. I don't understand it fully, but let me attempt to give an answer.

In the diffuse calculation, the cosine factor is included via the sampling. Out of the possible halfsphere of incidence rays, it is more likely a priori that one came directly from above than directly from the horizon.

In the mirror calculation, the cosine factor is included via the sampling. Out of the possible single direction that an incidence ray could have come from, it is more likely a priori - you see where I'm going.

If you sampled coarse reflection via a cone of incoming rays (as for a matte surface) you would again need to account for cosine weighting. However, for the trivial case of a single possible incidence direction, sampling reduces to if true.

like image 28
FeepingCreature Avatar answered Nov 15 '22 10:11

FeepingCreature