7. Sampling and Observers

7.1. Observer Equation

The total intensity measured by an observing pixel is given be the integral of the incident emission over the collecting solid angle \(\Omega\) and surface area \(A\).

\[I = \int_{A} \int_{\Omega} L_{i}(p, \omega_i) \times \cos (\theta_i) d\omega_i dA\]

Here, \(L_{i}(p, \omega_i)\) is the incident emission at a given point \(p\) and incident angle \(\omega_i\) on the observing surface. \(\cos (\theta_i)\) is a geometry factor describing the increase in effective observing area as the incident rays become increasingly parallel to the surface.


Caption: Example sampling geometry for a pixel in a camera. (Image credit: Carr, M., Meakins, A., et. al. (2017))

7.2. Monte-Carlo Integration

The integral in the observer equation is exact but difficult to evaluate analytically for most physically relevant scenes. Monte-Carlo integration is a technique for approximating the value of an integral by simulating a random process with random numbers.

The simplest form of Monte-Carlo integration is the average value method, which starts by considering the integral

\[I = \int_{a}^{b} f(x) dx\]

The average value of the function \(f(x)\) over the domain can be expressed in terms of the integral over the same domain.

\[<f> = \frac{1}{b-a} \int_{a}^{b} f(x) dx = \frac{I}{b-a}\]

Therefore, through manipulation we can express our integral in terms of the average of \(f(x)\). We can measure \(<f(x)>\) by sampling \(f(x)\) at \(N\) points \(x_1\), \(x_2\), ..., \(x_N\) chosen randomly between \(a\) and \(b\).

\[I \approx \frac{b-a}{N} \sum_{i=1}^{N} f(x_i) = \frac{1}{N} \sum_{i=1}^{N} \frac{f(x_i)}{p(x_i)}\]

\(p(x_i) = 1/(a-b)\) is the uniform distribution we are sampling from. For a rectangular pixel in a camera the sampling distributions would be uniformly distributed 2D points in the square area \(A\) and 3D vectors in the hemisphere \(\Omega\).

In general, the standard error on the approximation scales as \(1/\sqrt{N}\) with \(N\) samples.

7.3. Importance Sampling

The average value formula works well for smoothly varying functions but becomes inefficient when the integral contains steep gradients or a divergence, for example, a bright point light source. The standard error on the integral estimator can become large in such circumstances.

We can get around these problems by drawing the sample points \(x_i\) from a non-uniform probability density function (i.e. higher density for regions with stronger emission). \(p(x_i)\) now becomes

\[p(x_i) = \frac{w(x_i)}{\int_{a}^{b} w(x) dx}\]

where \(w(x)\) is the weight function and has been normalised so that its integral is 1. The estimator for the integral is now

\[I \approx \frac{1}{N} \sum_{i=1}^{N} \frac{f(x_i)}{w(x_i)} \int_{a}^{b} w(x) dx\]

This is the fundamental formula of importance sampling and a generalisation of the average value method (try \(w(x) = 1\)). It allows estimation of the integral \(I\) by performing a weighted sum, which can be weighted to have higher density in regions of interest. The price we pay is that the random samples are being drawn from a more complicated distribution.

Importance sampling exploits the fact that the Monte-Carlo estimator converges fastest when samples are taken from a distribution p(x) that is similar to the function f(x) in the integrand (i.e. concentrate the calculations where the integrand is high).

7.3.1. Cosine distribution

7.3.2. Sampling the lights

7.3.3. Sampling the BRDF

7.4. Multiple Importance Sampling