
Classnotes for CMSC740 taught by Matthias Zwicker (Spring 2020).
This first portion of the class focuses on ray tracing (specifically, path tracing) and is based on the PBRT book
The second portion of the class introduces deep learning approaches to computer graphics.

Acceleration

How to speed up intersection calculations during ray tracing.

Object Subdivision

Bounding volume hierarchy

• Create a tree where objects are placed together.
• Each node corresponds to a region covering all the objects it has
• You want to insert in some greedy way:
• Minimize the size of each region
• Subtrees may overlap and are unorder

Octtree, kd tree

Geometrical Optics

• Light are rays which reflect, refract, and scatter

Solid Angle

• Solid angle = area / radius^2 on a sphere

• Spectral radiance is energy per time per wavelength per solid angle per area
• $$\displaystyle L(t, \lambda, \omega, \mathbf{x})=\frac{d^4 Q(t, \lambda, \omega, \mathbf{x})}{dt d\lambda d\omega dA^\perp}$$
where energy is $$\displaystyle Q(t, \lambda, \omega, \mathbf{x})$$

• power per solid angle per area
• $$\displaystyle L(\omega, \mathbf{x}) = \frac{d^2 \Phi(\omega, \mathbf{x})}{d\omega dA^\perp}$$

Monte Carlo Integration

Suppose we want to estimate $$\displaystyle I_1 = \int_{a}^{b}f(x)dx$$.
Then we can use $$\displaystyle \hat{I_1} = \frac{b-a}{N}\sum f(X_i)$$ where $$\displaystyle X_1,...,X_n \sim Uniform(a,b)$$.
This is because $$\displaystyle E\left[\frac{b-a}{N}\sum f(X_i)\right] = \frac{b-a}{N}\sum E[f(X_i)] = \frac{1}{N}\sum \int_{a}^{b}(b-a)f(x)(1/(b-a))dx = \int_{a}^{b}f(x)dx$$
Note that in general, if we can sample from some distribution with pdf $$\displaystyle p(x)$$ then we use the estimator:

• $$\displaystyle \hat{I} = \frac{1}{N} \sum \frac{f(X_i)}{p(X_i)}$$

Importance Sampling

Suppose we can only sample from pdf $$\displaystyle g(x)$$ but we want to sample from pdf $$\displaystyle p(x)$$ to yield a more reliable (less variance) estimate.
Then we can sample from $$\displaystyle p(x)$$ using $$\displaystyle Y = F_{p}^{-1}(F_{g}(X))$$.
Then apply the above equation.

Integration

• Hemisphere: $$\displaystyle d\omega = \sin \theta d\theta d\phi$$ where $$\displaystyle \theta \in [0, \pi/2)$$ and $$\displaystyle \phi \in [0, 2\pi)$$

Path Tracing

PDF for sampling light sources

$$\displaystyle p_{\omega}(x) = \frac{1}{\# lights} * \frac{1}{area of light} * conversion$$

Refractive objects

For mirrors

In practice, refractive objects are handled as a distinct case.
You do not need to sample a direction.

For glass
• Randomly sample either reflected or refracted ray with given probability.
• Typically produces a lot of noice

Emitting surfaces

• If a ray accidentally hits emitting surface, don't add emission
• Exception: If eye ray hits emitting surface
• Exception: If ray is generated from a refractive surface

Multiple Importance Sampling

Weighted sampling between $$\displaystyle F_a$$ $$\displaystyle F_d$$

• Take $$\displaystyle N$$ samples from each technique (j=1,...,N)
• $$\displaystyle F=\frac{1}{N} \sum_{j=1}^{N} \sum_{i=1}^{n} w_i(X_{i,j}) \frac{f(X_{i,j})}{p_i(X_{i,j})}$$
• Make sure $$\displaystyle \sum_{i=1}^{n}w_i(x) = 1$$
• Weights for provable variance reduction
• Balance heuristics: $$\displaystyle w_i(x)=\frac{p_i(x)}{\sum_{k=1}^{n}p_k(x)}$$
• Power heuristics: $$\displaystyle w_i(x)=\frac{p_i^2(x)}{\sum_{k=1}^{n}p_k^2(x)}$$

Stratified Sampling

• Intuition: clumping of samples is bad
• Instead of canonic uniform random variables, generate variables in strata
• Also known as "Jittered sampling"

Other stratified sampling patterns

• N-rooks (Latin hypercube)
• Quasi Monte Carlo

Bidirectional Path Tracing

Trace path from eye and light
Example:

• from eye we get path $$\displaystyle z_0, z_1, z_2$$
• from light we get $$\displaystyle y_0, y_1$$
• Then make shadow rays from every pair of z, y

Path of length k with k+1 vertices

• s vertices from light, t from eye
• Path denoted $$\displaystyle \bar{X}^{s,t}$$ (e.g. $$\displaystyle \bar{X}^{2,3}$$)
• We also get probability density for this path $$\displaystyle p_{s,t}$$

Participating Media

Transmittance

• Multiplicative property
• $$\displaystyle T(s)=T(s_0) * T(s_1)$$
• Beer's law $$\displaystyle T(s)=e^{-sigma_t s}$$
• For homogenous media where $$\displaystyle \sigma(x) = \sigma$$ is constant

Phase Functions

Henyey-Greenstein phase function

• $$\displaystyle p(\cos \theta) = \frac{1-g^2}{4\pi(1+g^2-2g\cos \theta)^{1.5}}$$

Properties

• Unitless
• Reciprocity
• $$\displaystyle p(\omega' \rightarrow \omega) = p(\omega \rightarrow \omega')$$
• Energy conservation
• Integrates to 1
• Average phase angle determined by g

Volume Rendering Equation

Integro-integral form

• $$\displaystyle L(\mathbf{x}, \omega) = \int_{0}^{\infty}\exp(-\int_{0}^{s'}\sigma_t(\mathbf{x}-s''\omega)ds'')S(\mathbf{x}-s'\omega, \omega)ds$$
• $$\displaystyle \exp(-\int_{0}^{s'}\sigma_t(\mathbf{x}-s''\omega)ds'')$$ is Transmittance $$\displaystyle T(s')$$ due to extinction
• $$\displaystyle S(\mathbf{x}-s'\omega, \omega)$$ is source (emission, in-scattering)

Subsurface Scattering

BSSRDF

bidirectional surface scattering reflectance distribution function

• $$\displaystyle S(\mathbf{x}_i, \omega_i, \mathbf{x}_o, \omega_o)$$