Introduction & Recap of Last Note

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.

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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e3d57cef-694d-4474-bee4-7e7f1de5c347/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/51948740-6064-499d-b0b0-8a8a9f8fff5f/Untitled.png

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.

How to Draw Samples from a Desired Probability Distribution?

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:

  1. Construct a cumulative PDF (note: have $0 ≤ P_i ≤ 1$ and $P_n = 1$): $P_j = \sum_{i=1}^{j}p_i$
  2. Given a uniform random variable $\xi \in [0,1)$, choose $X = x_i$ such that $P_{i-1}<\xi≤P_i$. In the discrete case, we can perform a binary search to find the bin that we land on.

A visual representation of the PDF.

A visual representation of the PDF.

A visual representation of the CDF.

A visual representation of the CDF.

The Inversion Method: Continuous Random Variable