siware.dev

The Rendering Equation

This is one of the most important equation for rendering:

Lo(p,ωo)=Le(p,ωo)+S2f(p,ωo,ωi)  Li(p,ωi)  (nωi)  dωi\displaystyle \quad L_o(p, \omega_o) = L_e(p,\omega_o) + \int_{S^2} f(p,\omega_o,\omega_i) \; L_i(p,\omega_i) \; (n \cdot \omega_i) \; d\omega_i

The equation above requires integration of incoming radiance over all possible directions in the hemisphere. Note that this formulation is more suited for distant lighting which is why it’s weighted by the solid angle dωid\omega_i.

Spherical Coordinates Formulation

When trying to come up with analytical solution to the rendering equation, we often do this in spherical coordinates. We need to take into account the change of domain of integration [wiki]:

dω=sinθ  dθdϕ\quad d\omega = sin\theta \; d\theta d\phi

Which yields:

Lo(p,ωo)=Le(p,ωo)+02π0πf(p,ωo,θ,ϕ)  Li(p,θ,ϕ)  cosθ  sinθ  dθ  dϕ\displaystyle \quad L_o(p, \omega_o) = L_e(p, \omega_o) + \int_{0}^{2\pi}\int_{0}^{\pi} f(p,\omega_o,\theta,\phi) \; L_i(p,\theta,\phi) \; |cos\theta| \; sin\theta \; d\theta \; d\phi

Surface Formulation

In the context of patch tracing, it’s more common to formulate the rendering equation based on patches that we hit. This is done by considering all the visible hit points from rays shot from upper hemisphere of pp.

Consider starting at point p=xp = x and casting a ray in the direction of ωi\omega_i. Let y=ray(x,ωi)y = ray(x, \omega_i) be the hit-point for the raycast. Assuming there’s no participating media, radiance is constant along rays through the scene and therefore L(y,ωi)=L(p,ωi)L(y, -\omega_i) = L(p, \omega_i) (we can drop the suffix from LiL_i and LoL_o for simplicity). If we just want to consider all points above the hemisphere of xx, we will need to introduce visibility function V(x,y)V(x, y) between the two points xx and yy. Finally, we will need to account for the change of domain of integration from differential solid angle dωid\omega_i to differential area dAydA_y:

dωi=cosθyrxy2  dAy\displaystyle \quad d\omega_i = \frac{|cos\theta_y|}{{r_{xy}}^2} \; dA_y

To simplify notation, we will introduce geometric term G(x,y)G(x, y):

G(x,y)=cosθx  cosθyrxy2\displaystyle \quad G(x, y) = \frac{|cos \theta_x| \; |cos\theta_y|}{{r_{xy}}^2}

Note:

Which yields the following equation for surfaces:

L(x,ω0)=Le(x,ω0)+Mf(x,ωo,ωi)  L(y,ωi)  V(x,y)  G(x,y)  dAy\displaystyle \quad L(x, \omega_0) = L_e(x,\omega_0) + \int_{M} f(x,\omega_o,\omega_i) \; L(y, -\omega_i) \; V(x, y) \; G(x, y) \; dA_y

Table of Contents

Radiometry

In order to understand the rendering equation, it’s important to get familiar with basic radiometric quantities oftenly used in rendering: flux, irradiance, radiant exitance, intensity and radiance. They are basically different ways of measuring photons. A photon at wavelength λ\lambda carries energy Q=hcλQ = \frac{h c}{\lambda} where h is Planck’s constant and c is the speed of light. The four basic quantities can be derived from energy (J) by taking limits over time, area and directions.

Quantity Formula Unit Definition
(Radiant) Flux Φ=dQdt\displaystyle \Phi = \frac{dQ}{dt} WW Total amount of energy passing through surface per unit time (J/s). Also known as power.
Irradiance E=dΦdA\displaystyle E = \frac{d\Phi}{dA} W/m2W/m^2 Area density of arriving at a surface.
Radiant exitance M=dΦdA\displaystyle M = \frac{d\Phi}{dA} W/m2W/m^2 Area density of flux leaving a surface.
(Radiant) Intensity I=dΦdω\displaystyle I = \frac{d\Phi}{d\omega} W/srW/sr Angular density of emitted power. Intensity describes directional distribution of light but only meaningful for point light sources.
Radiance L=dΦdω  dA  cosθ\displaystyle L = \frac{d\Phi}{d\omega \; dA \; cos\theta} W/(m2sr)W/(m^2 sr) Flux density per unit area, per unit solid angle.

Irradiance

Irradiance is an average density of power over a finite area E=ΦA\displaystyle E = \frac{\Phi}{A}. We can compute irradiance at point E(p)E(p) by taking the limA0ΔΦ(p)ΔA=dΦdA\displaystyle \lim_{A \to 0} \frac{\Delta \Phi(p)}{\Delta A} = \frac{d\Phi}{dA}.

Irradiance can also be computed by taking integral of radiance:

E(p,n)=S2Li(p,ω)  cosθ  dω\quad E(p,n) = \displaystyle \int_{S^2} L_i(p, \omega) \; |cos \theta| \; d\omega

Irradiance via Monte Carlo

We can compute irradiance vis Monte Carlo estimator E^=1Ni=0N1f(Xi)pdf(Xi)\hat{E} = \frac{1}{N} \sum_{i=0}^{N-1} \frac{f(X_i)}{pdf(X_i)}.

For uniform hemisphere sampling, pdf is just a constant 12π\frac{1}{2 \pi}, which makes the estimator to be:

E^=2πNi=0N1Li  cosθ\quad \hat{E} = \displaystyle \frac{2 \pi}{N} \sum_{i=0}^{N-1} L_i \; cos \theta

For cosine hemisphere sampling, pdf becomes cosθπ\frac{cos \theta}{\pi}, which makes the estimator to be:

E^=πNi=0N1Li\quad \hat{E} = \displaystyle \frac{\pi}{N} \sum_{i=0}^{N-1} L_i

Solid Angle

Solid angle Ω\Omega is defined as:

Ω=Ar2\displaystyle \quad \Omega = \frac{A}{r^2}

where AA is the spherical surface area and rr is the radius of a sphere.

Differential Solid Angle

Given a unit sphere parameterized by (ϕ,θ)(\phi, \theta)

x=sinθ  cosϕy=sinθ  sinϕz=cosθ\quad x = sin\theta \; cos\phi \\ \quad y = sin\theta \; sin\phi \\ \quad z = cos\theta

the differential solid angle is

dΩ=sin(θ)dθdϕ\quad d\Omega = sin(\theta) d\theta d\phi

Spherical Cap

The projection of a sphere onto a surface of another sphere is spherical cap. Solid angle of spherical cap with apex angle 2θ2\theta is given by:

Ω=2π(1cosθ)\quad \Omega = 2 \pi (1 - cos\theta)

We can use this to approximate sphere radius RR at distance dd given solid angle Ω\Omega (only valid when d>=Rd >= R):

sinθ=Rd\quad sin\theta = \frac{R}{d}

R2=d2  (1(1Ω2π)2)=d2  Ω2π(2Ω2π)\quad R^2 = d^2 \; (1 - (1 - \frac{\Omega}{2\pi})^2) = d^2 \; \frac{\Omega}{2\pi} (2 - \frac{\Omega}{2\pi})

Notation

Linear Operators

Sometimes the rendering equation is written in operator equations which tend to be more concise than the integral equation.

References

  1. The Light Transport Equation: http://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/The_Light_Transport_Equation.html
  2. Radiometry: https://pbr-book.org/3ed-2018/Color_and_Radiometry/Radiometry
  3. A Framework for the Analysis of error in Global Illumination Algorithms: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.114.5283&rep=rep1&type=pdf