Another “educational” post:
In computer graphics kindergarten, we were all taught that diffuse is:
Where is a constant that determines how bright the diffuse response is.
In computer graphics grade-school, we then learn about the rendering equation, and we’re given:
Where is the BRDF (bidirectional reflectance distribution function). For the diffuse case, the BRDF is :
where r is albedo
This is the source of much confusion. The albedo is, by definition, the fraction of incident light that gets reflected from the surface. So how come the BRDF isn’t just r?
In this post, I’m going to attempt to give an intuitive answer to this question. The target audience is anybody who’s been puzzled by this question for as long as I was. I’ll be using diffuse here for simplicity, but pretty much every BRDF you see in the literature has got a factor of in it’s normalization term someplace, for the same reasons.
The short answer is this: Integrating intensity over cosine-weighted solid angle gives an answer which is off by a factor of . For the long version, I need to pretend I understand calculus. If you are a CS freshman: pay attention in math class. You’d be surprised how relevant that stuff becomes later in your career.
Lets imagine we have a greyscale image. If we want to compute its average value, we know how do do that, just sum over pixels and divide:
I find that a good, intuitive mental model for an integral is an average in the limit. If we could somehow average over all infinity points on the continuous domain, the integral is the answer that we would get. If we happen to have a closed-form expression for the function, we can often derive the integral analytically, but in graphics, we never do. Luckily, we get can arbitrarily close to the right answer just by taking a crapload of samples and averaging them appropriately. Another important aspect of an integral is that it is measuring a density. In our example above, if our image represented some commodity like light or happiness, then the integral over the domain is the amount of white stuff per unit area.
If we liked, we could average over scan-lines. We take the average in each line, and then average the averages, like this:
It’s easy to see that we’ll get exactly the same answer. This is what a multi-dimensional integral is (kinda,sorta)
The Rendering Equation is Not What You Think It Is
Here’s that rendering equation again:
Since we’re limiting ourselves to the diffuse case, the BRDF is a constant, so we can yank it out:
One important fact which graphics literature rarely mentions is that the integration over solid angle can and should be expressed as a multi-dimensional integral in spherical coordinates:
You may not have seen this term before, but its the source of all the trouble.
The rendering equation is trying to average something over solid angle, which the same as averaging over the surface area on a unit sphere above our shading point. It turns out that the spherical coodinate system is skewed. If you hold fixed, and sweep the angle around the pole, you sweep out a great circle, as shown below.
The circumference of the circle increases with . These little circles are analogous to the scanlines in our earlier example. If we imagine cutting up the sphere into circles and assigning the same number of ‘pixels’ to each, we end up with sample points that are closer together at the top of the sphere than at the bottom. In order to compute the correct density, we now need to do a weighted average, so that each sample’s contribution is proportional to the amount of surface area it covers. This is what the term is doing.
Now we have everything we need to explain that away.
Finding the PI
Let’s make things simple and build a test case that we can actually solve in closed form. We’ll assume that the incoming light intensity is constant over the entire hemisphere of directions. Now we have:
Time for some mathematical slight-of-hand. Had I paid more attention in calculus class, this part would have been much easier to write. Observe that:
We need the antiderivative of which we can get by abusing the product rule, which states:
Let . Now:
Now we just plug that in the outer integral and we have:
So, in this scenario, we put in radiant intensity from all directions and get out. Did we conserve energy? Probably not, but let’s prove it.
Energy conservation means that the flux leaving the surface must not exceed the flux arriving at the surface. We’ll write this as:
Once again, we construct an imaginary test case that makes the math easier. If we have radiant intensity over the entire hemisphere, and intensity is flux per steradian (unit hemisphere area), then the incoming flux is given by:
If you’re not sure what flux and intensity are, you may find my earlier post helpful.
Now lets calculate how much flux is leaving. We’ve just calculated , the flux per unit hemisphere area in any particular direction, so we can just integrate that over the outgoing hemisphere.
Now, let , meaning that we want , and plug back in:
Ooops, we’ve got times as much flux as we started with, and that won’t do. In order to fix it, we need to divide out the extra in our BRDF. And that, dear friends, is where that mysterious comes from.
It’s There By Definition
You can also derive this directly from the conventional definition of the BRDF. The BRDF is the ratio:
Where is the reflected intensity through solid angle and is the irradiance due to light entering from solid angle .
Again, assuming uniform incoming intensity and an ideal diffuse reflector with albedo , we have:
There are ‘s in a hemisphere, and input and output are both constant over the hemisphere, meaning:
And we’ve already derived irradiance earlier: