ΘρϵηΠατπ

Path Tracing

Path tracing is a Monte Carlo method for estimating camera-ray radiance by sampling light transport paths through a rendering scene. This page builds on the radiometric quantities and surface-scattering definitions from radiometry.

Rendering Scene
A rendering scene is the collection of surfaces, light sources, and material scattering functions used to determine the radiance reaching a camera.

Path Notation

Directed Point Pair
If p,q3 and pq, then pq denotes the direction from p toward q. As a unit vector, this direction is ωpq=qpqp.

The notation pq is not a new kind of point. It is shorthand for asking about light traveling from the location p toward the location q.

Radiance Along a Directed Point Pair
If p,q3 and pq, then radiance(pq) means the radiance at p in the direction from p toward q: radiance(pq)=radiance(p,ωpq). When p lies on a surface and the light is leaving p toward q, this is an exitant radiance value.
Camera Ray Radiance Estimate
Suppose a camera ray starts at p0 and first intersects the scene at p1. The quantity radiance(p1p0) is the radiance leaving the first intersection point p1 back toward the camera point p0. Path tracing estimates this value by summing contributions from valid light transport paths that begin at p0 and then visit p1.
Pixel Sample
A pixel sample is one sampled point within a pixel's image-plane region. A renderer usually estimates a pixel value by tracing one camera ray for each pixel sample and averaging the returned radiance estimates.
Camera Ray
A camera ray is a ray that starts at the camera and travels through a point on the image plane or pixel sample. A path tracer estimates the incident radiance carried back along this ray.
Ray-Scene Intersection
A ray-scene intersection is the first point where a ray meets a surface in a rendering scene. If no such point exists, the ray escapes the scene.
Visibility Between Points
Two points in or around a rendering scene are visible to each other if the open line segment between them does not intersect any blocking surface in the scene. The visibility factor V(p,q) is 1 when p and q are visible to each other and 0 otherwise.
Light Sample
A light sample at a surface point p is a randomly chosen point or direction on a light source, together with the sampled incident radiance and the density used to choose that sample.
Direct Lighting Estimator
A direct lighting estimator estimates the one-bounce light arriving at a surface point by sampling a light source. For a light sample from direction ωi with density pl(ωi), one sample contributes bsdf(p,ωi,ωo)radiance_in(p,ωi)|nωi|Vpl(ωi), where bsdf is the BSDF, radiance_in is incident radiance, n is the surface normal, and V is the visibility factor.
BSDF Sample
A BSDF sample at a surface point chooses a new direction ωi according to a density pdir on the unit sphere 𝕊2, measured with respect to solid angle. Thus pdir(ωi) is the density assigned to sampling the particular direction ωi. The sample also returns bsdf(p,ωi,ωo), the value of the BSDF for the sampled incoming direction and the outgoing direction. This is an importance sampling step for the BSDF scattering equation.

Choosing a direction according to pdir means that the renderer uses random numbers to produce a direction-valued random variable whose density is pdir. In one dimension, a standard way to do this is the inversion method: start with a uniform random number and transform it so the output has the desired distribution. Direction sampling uses the same idea, but the output is a point ω on 𝕊2 instead of a real number. By the definition of density, having density pdir means that for any set of directions A𝕊2, the probability that the sampled direction lands in A is Apdir(ω)dω.

Operationally, a renderer implements this with a sampling procedure: a function that takes one or more uniform random numbers and returns a direction. The function is designed so that the preimage of a direction patch A occupies exactly Apdir(ω)dω worth of area in the uniform random-number domain. Larger-density direction patches are assigned larger regions of the input random-number square, so they occur more often. The path tracer later divides by pdir(ωi), so sampling some directions more frequently changes how noisy the estimate is, not which radiance integral is being estimated.

Path Throughput
The path throughput is the accumulated multiplicative estimator weight of a sampled light path. If a path has already scattered through directions ω1,,ωk, then its throughput has the form β=j=1kbsdf(pj,ωj,ωj1)|njωj|pdir(ωj), where each denominator is the density used when sampling the corresponding direction. The throughput is the reason a later light contribution is multiplied by all earlier scattering weights.
Path Throughput from Importance Sampling
The path throughput factor comes from applying the Monte Carlo estimator to the BSDF scattering equation. At a surface point p, with outgoing direction ωo, surface normal n, and sampled incoming direction ωi drawn from density pdir, the one-sample estimator for the scattered incident radiance term is bsdf(p,ωi,ωo)radiance_in(p,ωi)|nωi|pdir(ωi). Therefore the estimate of whatever radiance is found by continuing the path in direction ωi must be multiplied by bsdf(p,ωi,ωo)|nωi|pdir(ωi). Repeating this at each bounce multiplies these factors together, which gives the path throughput β.
In the BSDF scattering equation, the scattered part of radiance_out(p,ωo) is an integral over incoming directions: 𝕊2bsdf(p,ωi,ωo)radiance_in(p,ωi)|nωi|dωi. If the renderer samples ωi from density pdir, the Monte Carlo estimator replaces the integrand by the sampled integrand divided by the sampling density: bsdf(p,ωi,ωo)radiance_in(p,ωi)|nωi|pdir(ωi). The remaining term radiance_in(p,ωi) is the radiance arriving from the next ray direction, so a recursive path tracer estimates it by continuing the path. Thus the continuation estimate is multiplied by the non-radiance_in part of the sampled term. After k sampled scattering events, these multiplicative factors form the product in the definition of path throughput.
Light Transport Path
Let S be a rendering scene, and let p03 be an initial point. The set of valid light transport paths from p0 through S is denoted LTP(p0,S). An element of LTP(p0,S) is a tuple (p1,,pk) such that each pi lies on a surface in S, and each adjacent pair pi, pi+1 is visible in S, where the index i ranges from 0 to k1. Thus the open line segment from pi to pi+1 hits no other surface in the scene before reaching pi+1. The initial point p0 is not part of the tuple; it is supplied as an argument of LTP(p0,S).
Fixed-Length Light Transport Paths
Let S be a rendering scene, let p03, and let k1. The set LTPk(p0,S) is the subset of valid light transport paths from p0 through S whose elements are k-tuples: LTPk(p0,S)={(p1,,pk)LTP(p0,S)}. Thus LTP1(p0,S) contains one-vertex paths, LTP2(p0,S) contains two-vertex paths, and so on.
Path Radiance Contribution
Let S be a rendering scene, and let (p1,,pk)LTP(p0,S). The notation path_rad(p0;p1,,pk) denotes the radiance contribution assigned to that path. The exact formula depends on the path's emitted radiance, BSDF factors, geometric factors, and visibility. The sampling density appears later when a Monte Carlo estimator chooses which paths to sample. At this stage, path_rad(p0;p1,,pk) should be read as one path's contribution to the camera-ray radiance value.
Path Tracing Overview Equation
Let S be a rendering scene. If a camera ray starts at p0 and first hits the scene at p1, then the path tracing goal can be written schematically as radiance(p1p0)=k=1(p1,,pk)LTPk(p0,S)path_rad(p0;p1,,pk). The left side is the radiance leaving the first intersection point back toward the camera. The right side says that this radiance is assembled from path radiance contributions of valid light transport paths. This equation is schematic: later, sums over continuously many surface points must be interpreted as integrals.
Recursive Path Depth
The recursive path depth of a sampled path is the number of surface scattering events that have already been used to extend the path away from the camera.
Maximum Path Depth
The maximum path depth is the largest recursive path depth that a path tracer allows before it stops extending the current light transport path.
Simple Path Tracer
A simple path tracer is a Monte Carlo estimator for camera-ray radiance. It repeatedly intersects a ray with the scene, adds emitted and directly sampled light scaled by the current path throughput, samples a new direction using bsdf from the surface BSDF, updates the throughput, and continues until the path ends or reaches its maximum path depth.
Simple Path Tracing Loop
Given a camera ray for one pixel sample, initialize accumulated radiance L=0, path throughput β=1, and recursive path depth d=0. The current ray always points away from the previous path vertex. At each intersection point p, let n be the surface normal at p, and let ωo𝕊2 point from p back along the current ray toward the previous path vertex. Then repeat:
  1. Find the next ray-scene intersection. If the ray escapes, add any visible environment emitted radiance scaled by β, and stop.
  2. If the intersected surface emits light, add βemitted_radiance(p,ωo) to L, where emitted_radiance(p,ωo) is the emitted radiance at the intersection point p in the outgoing direction ωo back toward the previous path vertex.
  3. If direct light sampling is enabled, take a light sample and add its direct lighting estimator contribution scaled by β to L.
  4. If d has reached the maximum path depth, stop.
  5. Take a BSDF sample to choose the next direction ωi.
  6. Update ββbsdf(p,ωi,ωo)|nωi|pdir(ωi).
  7. Spawn the next ray in direction ωi, set dd+1, and continue. At the next intersection, the new ωo is the direction back toward the current point p.