2.4 Global Illumination algorithms
2.4.1 Path tracing
Path tracing algorithms establish light transport paths between lights sources and those points in the scene where we wish to compute the incident radiance. Often, these points are directly on the image plane, corresponding to the pixels of the rendered image. This approach yields the pixel-driven rendering algorithm presented in Algorithm 2.1. The path tracing methods differ in their implementation of compute exitant radiance(x, ~ωo)
and any preprocessing that may be required before image generation begins.
2.4.1.1 Whitted-style ray tracing
Perhaps the best known path tracing algorithm is ray tracing, introduced to computer graphics by Whitted (Whitted, 1980). Requiring no pre-processing and being fully de- terministic, the method is simple to implement (Algorithm 2.2). The desired exitant radiance is computed as the sum of three terms: the locally emitted light, the reflected light due to direct illumination from the scene-defined light sources, and the light reflected along the angle of perfect reflection or refraction. The integral in the rendering equation is replaced with one recursive evaluation of compute exitant radiance computing indirect illumination.
The algorithm is therefore only correct for perfectly specular surfaces, such as chrome spheres. More general materials, including those with a diffuse and glossy BRDF, are not handled correctly and the image generated will be biased. The recursion must some- how be terminated for an image to eventually be generated. Simple heuristic criteria for limiting the depth of recursion, such as running out of storage or a reaching hard-coded maximum depth, lead to biased results and a large number of shadow rays which con- tribute little to the final image (Shirley, 2000). These two issues lead to the development of a more sophisticated scheme, stochastic ray tracing.
Pre-condition: x is the location under consideration Pre-condition: ~ωo is the direction towards the viewer
// Compute the locally emitted radiance in direction~ωo
result←emitted illumination(x, ~ωo)
// Compute the direct illumination due to the pre-defined light sources result←result + direct illumination(x, ~ωo)
// Compute the indirect illumination due to specular reflection if recursion termination criterion not yet reachedthen
~
ωi ←compute reflected angle(~n, ~ωo)
y←intersect with scene(x, ~ωi)
result←result +fr(x, ~ωi, ~ωo)×compute exitant radiance(y,−~ωi)
end if
Post-condition: result = the total reflected radiance from xtowards ~ωo
Algorithm 2.2: Whitted-style ray tracing. Various heuristics can be used to terminate recursion. This simple implementation of compute exitant radiance(x, ~ωo) is valid only
for perfectly specular surfaces, such as chrome balls. Nonetheless, it provides impressive results in suitable scenes.
2.4.1.2 Stochastic ray tracing
Cook introduced distributed ray tracing as a comprehensive framework for extending Whitted-style ray tracing using stochastic techniques, based on Monte-Carlo integra- tion (Cook et al., 1984). It handles arbitrary material BRDFs, as well as motion blur, depth of field, and other realistic effects. In a straightforward implementation, arbitrary BRDFs are supported by replacing the single reflection sample, along the angle of specu- lar reflection, with N randomly chosen samples using Equation 2.5 to compute the total reflected radiance. These random samples can be chosen uniformly, proportionally to the BRDF, or according to the quasi-Monte-Carlo technique (Shirley, 2000). Even an implementation of this basic technique that allowed only 4 levels of recursion, generating seriously biased images, would require N4 evaluations of compute exitant radiance. As
N is in the range of hundreds to thousands, this implementation of distributed ray trac- ing is highly inefficient, but can be easily adapted to preserve its strengths while reducing the number of computations that contribute little to the final image.
Pre-condition: x is the location under consideration Pre-condition: ~ωo is the direction towards the viewer
// Compute the locally emitted radiance in direction~ωo
result←emitted illumination(x, ~ωo)
// Compute the direct illumination due to the pre-defined light sources result←result + direct illumination(x, ~ωo)
// Determine if recursion should continue
ρ←probability of absorption if ρ > random unit number then
// Compute the indirect illumination due to specular reflection
~
ωi ←sample visable hemisphere(~n, ~ωo)
y←intersect with scene(x, ~ωi)
result←result +fr(x, ~ωi, ~ωo)×compute exitant radiance(y,−~ωi)/(1−ρ)
end if
Post-condition: result = the total reflected radiance from xtowards ~ωo
Algorithm 2.3: Stochastic ray tracing. Using Monte Carlo integration to support ar- bitrary BRDFs and Russian roulette to terminate the recursion, stochastic ray tracing is a simple but robust global illumination algorithm. Because only a single sample is generated and evaluated, many samples per pixel must be generated from the image plane.
equation is to use Russian roulette. Instead of generatingN secondary rays at each point, a single ray is created and recursively evaluated. However, this ray is chosen randomly from the hemisphere, not the angle of specular reflection as in Whitted-style ray tracing. At each intersection the ray is probabilistically terminated, depending on how reflective the material BRDF is. To avoid biasing the result, the intermediate reflected radiance must be scaled by the probability of absorption. In exchange for reducing the branching factor of recursion, this method requires hundreds to thousands of samples from each pixel. This implementation of distributed ray tracing focuses its efforts near the top of the recursion tree and is far more efficient. A full range of improvements and optimizations to stochastic ray tracing can be found in (Shirley, 2000).
2.4.1.3 Additional path tracing algorithms
Although more expressive than Whitted-style ray tracing, stochastic ray tracing has the problem that many of directions sampled will contribute little towards the final image unless they are directed to those portions of the scene that either contain light sources or strong reflectors of light sources. This results in a noisy image, especially if any caustics are present. Two alternative path tracing techniques increase efficiency by utilizing the knowledge of the specified light sources.
Bi-directional path tracing, like stochastic ray tracing using Russian roulette, traces multiple rays from the eye deep into the scene, recording all the intersection points (Lafor- tune and Willems, 1993; Veach and Guibas, 1994). Rather than using shadow rays to compute direct illumination and propagating backwards through the ray, a second ray is traced from a light source, recording all its intersections. Using the visibility function, as determined by ray tracing, and a series of weights, derived from the rendering equation, the light power is transfered from the light ray to eye ray and accumulated at the pixel. Although each eye ray is significantly more expensive to process, in certain scenes it can take far fewer samples per pixel to reduce noise to an acceptable level.
Bi-directional path tracing can be enhanced by improving the generation of sample directions as more information is known. A sophisticated technique that uses this ap- proach is Metropolis light transport (Veach, 1997). Starting with standard bi-directional path tracing, those paths that lead to a strong contribution to the image are used as guides indicating which portions of the scene are brightly illuminated. Care is taken to avoid bias while expending as few paths as possible on those portions of the scene not expected to contribute. An example where Metropolis light transport works well is two rooms separated by a keyhole, ordinarily a difficult scene to render without a lot of noise. Once even one path finds the keyhole, it is mutated, generating other paths that also get through the keyhole.