Rendering Equation Revisited

Recall the Rendering Equation originally presented in Eq (3):

\[L_o(\vec{x},\omega_o,\lambda) = L_e(\vec{x},\omega_o,\lambda) + \int_{\Omega} f_r(\vec{x},\omega_i,\omega_o,\lambda)L_i(\vec{x},\omega_o,\lambda)(\omega_i\cdot \hat{n}) \ d\omega_i\]

Integrating Lambertian BRDF

Lets consider a simple scene with no emittance, and so the rendering equation is simply:

\[L_o(x, \omega_o) = \int_{\Omega} f(x,\omega_o,\omega_i)L_i(x,\omega_i) \left(\omega_i \cdot \hat{n}\right) \ d\omega_i\]

Now, consider a surface with a Lambertian BRDF (see: Bidirectional Reflectance Distribution Function (BRDF))

\[f_r = \frac{\rho}{\pi}\]

where \(\rho\) is the surface’s albedo. With this constant BRDF, the integral simply becomes:

\[L_r = \frac{\rho}{\pi}\int_{\Omega}L_i(\vec{x},\omega_i) \left(\omega_i \cdot \hat{n}\right) \ d\omega_i\]

We’ll also have an isotropic spherical light source (see Lights), with a radius \(R\) and a radiant power of \(\Phi\), that is \(d\) away from point \(x\) directly along the surface normal vector \(\hat{n}\). Because the light source emits light in all directions, \(L_i\) has no dependence on the direction \(\omega_i\), and so it can be pulled out from the integral as well:

\[L_r = \frac{\rho}{\pi} L_i \int_{\Omega} \left(\omega_i \cdot \hat{n}\right) \ d\omega_i\]

Given that the light is located directly above the point, along \(\hat{n}\), then all of the light incident on \(\vec{x}\) is within \(\delta\) of \(\hat{n}\), where \(\delta\) is the half the angular diameter of the light. The angular diameter is defined as:

\[\delta = \sin^{-1}\left(\frac{R}{d}\right)\]

Therefore, our integral can be rewritten as:

\[\begin{split}\begin{align} L_r &= \frac{\rho}{\pi} L_i \int_0^{2\pi} \int_0^{\delta} \cos{\theta_i}\sin{\theta_i} \ d\theta d\phi\\ &= \frac{\rho}{\pi} L_i \int_0^{2\pi} \left[\frac{-\cos^2{\theta}}{2}\right]_0^\delta \ d\phi\\ &= \frac{\rho}{\pi} L_i \left(\pi \sin^2\left(\sin^{-1}\frac{R}{d}\right)\right)\\ &= \rho L_i \frac{R^2}{d^2} \end{align}\end{split}\]

Now lets say I want to setup a monte carlo estimator, which for this setup should take the following form:

\[L_r \approx \frac{\rho}{\pi} \frac{1}{N} \sum_{i=1}^N \frac{L_i(\omega_i)\cos{\theta_i}}{p(\omega_i)}\]

If we were to uniformly sample \(\omega_i\) from the entire hemisphere, then \(p(\omega_i) = \frac{1}{2\pi}\) and so the estimator simplifies to:

\[L_r \approx 2\rho \frac{1}{N} \sum_{i=1}^N L_i(\omega_i)\cos{\theta_i}\]

If instead, we were to use importance sampling and directly sample the light, then \(p(\omega_i) = \frac{1}{\Omega}\) where \(\Omega\) can be calculated using:

\[\Omega = 2\pi\left(1 - \frac{\sqrt{d^2 - R^2}}{d}\right)\]

and so the estimator becomes:

\[L_r \approx \frac{\rho}{\pi} \frac{\Omega_{light}}{2\pi} \frac{1}{N} \sum_{i=1}^N L_i(\omega_i)\cos{\theta_i}\]

If we assume \(\Phi = 100W\), \(d = 100m\), \(R = 10m\), and \(\rho = 0.4\), our analytical solution yields:

\[L = 1.0132\times10^{-4} \frac{W}{sr\cdot m^2}\]

If we use the uniformly sampled monte carlo method with a million samples, we get:

\[L_{uniform} = 1.0141\times10^{-4} \frac{W}{sr\cdot m^2}\]

And if I use the importance sampled version with 10 samples, we get:

\[L_{importance} = 1.0131\times10^{-4} \frac{W}{sr\cdot m^2}\]

Hopefully it is clear how valuable importance sampling is for quickly and accurately evaluating the rendering equation. The goal of this document wasn’t to necessarily make you an expert in the topic, but to give you decent insight into the motivation of how rendering has been implemented in Vira.