If you have ever dealt with a global illumination algorithm based on path integral formulation, such as path tracing(PT), bidirectional path tracing(BDPT), or metropolis light transport(MLT) before, I am sure you are familiar with the notion of the probability of a light path. On the whole, the definition of probability density function(PDF) of a path seems quite direct. It is just the joint PDF in terms of surface area of all the vertices consist of the path, which can be computed by the directional probability of sampling the BRDF from the prevsious vertex times the geometry term, except for the first vertex in the camera path, where no previous BRDF directional PDF is available.

As shown in the figure above, the PDF of vertex is simply the directional PDF from v2 converted to area PDF by multiplying the geometry term between X1 and X2. The geometry term, which converts measure of projected solid angle to area, is defined as below. (The V term in the firgure is visibility test)

As mentioned before, we need a different way to calculate the directional PDF for the 1st camera vertex since the PDF for incoming direction for that vertex is our directional PDF for our primary ray. And it is essential to calculate this correctly, because the PDF of any camera path depends on the PDF of our first camera vertex. However, nobody seems to care enough to explain how to calculate this nuiance. Maybe it is simply too easy to be worth mentioning, but it did take me a long while to figure this out. And it indeed turned out to be quite simple.

Assuming we place our image plane to an appropriate distance from the camera so that the area of a single pixel is 1, the PDF w.r.t. area of sampling a point on the raster would be simply 1. Once we know the PDF w.r.t are, we can likewise convert it to PDF w.r.t. projected solid angle by multiplying with the conversion term (eq1).

Assuming we place our image plane to an appropriate distance from the camera so that the area of a single pixel is 1, the PDF w.r.t. area of sampling a point on the raster would be simply 1. Once we know the PDF w.r.t are, we can likewise convert it to PDF w.r.t. projected solid angle by multiplying with the conversion term (eq1).

Therefore, we need to first know the distance from our pixel to camera r, and the cosine of the angle between our primary ray and forward direction of camera. The latter is trivial to calculate. The distance is a little trickier.

To calculate r, we first need to know the distance between camera and the image plane. Since we know that the width and height of a pixel is 1, so given a FOV angle, we can calculate d by

The following figure explains why.

Now we have all we need to compute r, the distance between the current pixel and the camera.

Now we know the conversion between area to projected solid angle at the pixel, and since the pixel area is 1, the directional probability of the primary ray is simply eq1.

That's it, we are done! Then we can plug this PDF w.r.t. proj. solid angle to compute the PDF of the first camera vertex w.r.t. area.

I hope you find this helpful if you're implementing BDPT or MLT and puzzled by the PDF of primary ray, like I once was :)

That's it, we are done! Then we can plug this PDF w.r.t. proj. solid angle to compute the PDF of the first camera vertex w.r.t. area.

I hope you find this helpful if you're implementing BDPT or MLT and puzzled by the PDF of primary ray, like I once was :)