Today, we're going to wrap up our discussion of Monte Carlo (e.g. randomized) integration and move onto path tracing and global illumination, the algorithm that we're going to study at in order to create photorealistic images.
Last class, we looked at how we can change basis when we're doing Monte Carlo integration to make it easier to do things like importance sampling, where we draw random samples of the function that we're trying to integrate in the areas where we think that function will be large.=
On the left, our image is pretty noisy, since our random rays can be anywhere across the hemisphere. On the right, we ensure that our random rays go through the light source, and test whether they're blocked by the blocker, and we get a much better image.
In math form, here's what this change of basis looks like.
Here, we'd like to calculate the irradiance, $E$, at the point $p$ on the ground plane - and we can do that by taking the integral of the radiance, $L$, arriving at a point $p$ from direction $w$ integrated over all directions $dw$ (across the hemisphere). We can draw a random set of positions $w$ on the hemisphere in order to perform a Monte Carlo estimation of this integral.
To do importance sampling, however, we may want to just draw samples over the surfaces of the light sources - in this example, for some generalized-area light source, $A'$, we can sample over this by attempting to draw random positions over that surface from which we can calculate a direction $w$ from the perspective of some point $p$ on the surface. Now, we're attempting to integrate over the surface area of that light source.
The Main Takeaway: We can change from integration over $dw$ (all directions) to integration over the surface area of the light sources. Once we do this change of basis, we can then integrate by drawing samples over the area of the light sources, which is a much more efficient way to estimate the irradiance. Finally, we can apply Monte Carlo integration directly to the integrand of the function in the new basis.
The Algorithm: we draw $N$ random samples on the surface of the light source. For each of the random samples, we perform the integration to calculate $Y_i$. We then average all of those $Y_i$ and multiply by the surface area of the light source.
At a high level, here, we'll look at one approach (the inversion method) - but in general, drawing random samples from a particular probability density function is very application specific!
The Inversion Method: Discrete Random Variable
Task: given a PDF for a discrete random variable, with probability $p_i$ for each value $x_i$, draw a random value $X$ from this PDF.
Approach:
A visual representation of the PDF.
A visual representation of the CDF.
The Inversion Method: Continuous Random Variable