---
breaks: False
---
# The Rendering Equation
Key nodes:
- Kajiya's "the rendering equation" which introduces the integral equation for radiance, suggests MCMC solution, introduces importance sampling.
- Tzu Mao's `diffrt.pdf` and PhD thesis. Shows that under mild assumptions the integral operator introduced by Kajiya has piecewise differentiable kernel with discontinuities at edges. Consequence: differentiability in the weak sense, edges contribute as delta-functions, triangles are modeled as products of three Heaviside functions, Tzu Mao suggests combining usual samples of triangles' interior with sampling edge points. Only silhouette edges are sampled, as far as I understand.
- Some basics on the pipeline and how shaders work: see "Intro to DXR" in the links.
- ...
# Kajiya'86
- $L(x,y)$ -- radiance passed from $y$ to $x$.
- $g(x,y)$ -- geometry term, depends on distance, visibility, and, apparently, the media; $g(x,y)=0$ unless $x$ is visible from $y$.
- $\epsilon(x,y)$ -- emmitance term; light emmited (by a light source) from $y$ to $x$.
- $\rho(x,y,z)$ -- scattering term; density of distribution of light scattered from $z$ to $x$ through $y$; usually realized by some **B**idirectional **R**eflectance **D**istribution **F**unction (BRDF) that depends on the vector $\omega_{\text{LS}} \propto z-y$ pointing towards lightsource and vector $\omega_{\text{V}} \propto x-y$ towards viewer: $\rho(x,y,z) = f(\omega_{\text{LS}}, \omega_{\text{V}}).$
- $\rho(x,y,z)L(y,z)$ -- radiance scattered from $z$ to $x$ through $y$.
- Far as I understand, equations should be refined to account for wavelengths, which are ignored in the paper; in equation on the wiki, $L$ depends on wavelength $\lambda$.
$$L(x,y) = g(x,y)\left[
\epsilon(x,y) +
\int_S \rho(x,y,z) L(y, z) \mathrm{d}z\right],$$
Operator form:
$$L = g\epsilon + gML,$$
$$M: L\mapsto (x,y) \mapsto \int_S \rho(x, y, \cdot) L(y,\cdot).$$
Can be rewritten as:
$$(1 - gM)L = g\epsilon.$$
If $\operatorname{spr}(gM) < 1$, the inverse operator
is given by (converging) Neumann series:
$$(1 - gM)^{-1} = \sum_{k\geq 0} g^kM^k,$$
and the solution:
$$\begin{split}L
&= (\sum_{k\geq 0} g^kM^k)g\epsilon
= g\epsilon + \sum_{k\geq 1} g^kM^kg\epsilon\\
&= g\epsilon + gMg\epsilon + gMgMg\epsilon + \cdots
\end{split}$$
Note that in this series expansion:
- $g\epsilon$ term stands for the direct light,
- $gMg\epsilon$ is the once-scattered light,
- $(gM)^k g\epsilon$ is the $k$-times scattered light.
Kajiya claims that in cases of interest the $\operatorname{spr}(gM)$ is indeed $<1$ and series is convergent.
# Materials and approximations
- Lambertian/ideal diffuse
Light is scattered uniformly in all directions and intensity depends only on the cosangle betwen **light direction** and **surface normal** -- not on direction of scattered ray.
This is $\rho(x,y,z)=\cos(z-y,n(y))$ in Kajiya's model,
with $n(y)$ the surface normal at $y$.
- Whitted
$M$ is the sum of two "delta functions" (deltas not in $\mathbb{R}^3$ but in angles, AFAIU) -- one for reflection, one for refraction -- and the diffuse term $\int_S \cos(\cdot-y, n) L(y, \cdot).$
- [Phong](@newkozlukov/rJR8GHeEH)
- [Torrance&Sparrow](/eHJK60yMSuyfyH1mmIndNg)
- [Blinn-Phong](/N2NFMir6SvuF3rgeYBfdfA)
- [Dichromatic Reflection Model (Shafer)](/prmEE7wXScWGwDurE-CxrQ)
- Also see the [rest of the collection](/@newkozlukov/SkjMyrlEr/)
## Links
**Seminal works**
- Whitted'80: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.107.3997&rep=rep1&type=pdf
- Cook'84: https://artis.inrialpes.fr/Enseignement/TRSA/CookDistributed84.pdf
- Kajiya'86: http://www.cse.chalmers.se/edu/year/2011/course/TDA361/2007/rend_eq.pdf
**Shaders, raytracing**
- [Siggraph 2018 course on DirectX Raytracing](http://intro-to-dxr.cwyman.org/)
- [TU Wien Rendering/Ray Tracing Course on Youtube](https://www.youtube.com/playlist?list=PLujxSBD-JXgnGmsn7gEyN28P1DnRZG7qi)
- https://users.cg.tuwien.ac.at/zsolnai/gfx/rendering-course/
- https://rgl.epfl.ch/publications/Dupuy2018Adaptive
**Gravity-based ray (beam) tracing, AKA Interstellar's Gargantua blackhole**
Kip Thorne and Double Negative team implemented a custom renderer that traces *beams of rays (paths and shapes) back in time, along geodesics of general-relativistic spacetime*. The beam is initiated as shooting from the eye into a pixel-sized disc on the screen. That's some cool twist between VFX and differential geometry.
- https://www.dneg.com/black-holes/
- https://www.dneg.com/show/interstellar/
- Gravitational renderer (1-page report): https://authors.library.caltech.edu/71785/1/a21-james.pdf
- Gravitational lensing by spinning blackholes: https://arxiv.org/abs/1502.03808
- DNEG youtube channel: https://www.youtube.com/channel/UCdVCZDUJkSsWDfQkS4dHvYA/
- Corridor and Blender Guru's breakdown of interstellar: https://youtu.be/D7Cv7x6jjYQ?t=749
**Interstellar's wormhole**
- https://www.dneg.com/interstellar-wormhole/
- https://aapt.scitation.org/doi/pdf/10.1119/1.4916949?class=pdf
- Kip Thorne's '87 paper on wormholes for teaching general relativity: http://www.cmp.caltech.edu/refael/league/thorne-morris.pdf
- SE on accretion disk in interstellar: https://physics.stackexchange.com/questions/151301/shape-of-accretion-disk-surrounding-the-black-hole-in-interstellar-film
**Real-time raytracing**
- unity/realtime raytracing https://youtu.be/Gz9weuemhDA?list=PLUPhVMQuDB_aTQ8Ir8tfL1tLr_TVOnvL5&t=5562