Download presentation
Presentation is loading. Please wait.
Published byJean Lang Modified over 6 years ago
1
Path Tracing (some material from University of Wisconsin)
CS 655 – Computer Graphics Path Tracing (some material from University of Wisconsin)
2
Path Tracing An extension to ray tracing Simulates global illumination
Can handle all possible light bounces L(S|D)*E (this is a reg exp, not a product) Introduced by Kajiya as a solution to the rendering equation Stochastically samples all light paths Handles area light sources, diffuse reflections Approximates the integral of illumination
3
Path Tracing Algorithms
Determine the intensity of each pixel by tracing light transport paths Paths that start at light sources and carry energy A path of length k is a sequence of vertices <x0, … , xk-1> where every xi and xi+1 is mutually visible and x0 is on a light
4
“Important” Paths We are most interested in the “important” paths
Paths that go from a light source to the eye Paths that carry the most energy The rendering equation can be written as a sum of integrals, each one integrating over a different path length
5
The Rendering Equation - reordered
Light to x directly from x’ Light from light source to x’, then to x Light to x via x’ scattered twice Light to x via x’ scattered three times etc.
6
Sampling Important Paths
We want to evaluate the integral using importance sampling i.e., attempt to sample the most important paths How do we find those paths? Several approaches have been tried
7
Naïve Path Tracing (version 1)
Start at a light Build a path by randomly choosing a direction at each bounce, send the ray in that direction, and add the point hit to the path vertex list Join the last point to the eye Problems? What path is achieved by this approach?
8
Naïve Path Tracing (version 2)
Start at eye Build a path by randomly choosing a direction at each bounce, follow the path in that direction, add the point hit to the path vertex list Optionally join the last point to a light Problems? What paths are generated?
9
Path Tracing (Kajiya) Start at eye
At each bounce, send a ray out in the direction determined according to some distribution At each point on the path, cast a shadow ray and add direct lighting contribution at that point Send multiple paths per pixel, average the contributions to get the final intensity
10
Path Tracing (Kajiya) – Sampling Strategies
The way in which the direction of each bounce is determined makes a big difference in image quality. Stratified Sampling Break the possible directions into sub-regions and cast one sample per sub-region. Importance Sampling Sample according to the BRDF
12
Importance sampling
13
Path Tracing (Kajiya) - Summary
Pros: Focuses on objects that are visible – doesn’t waste time on objects that can’t be seen Spends equal time on all path lengths ray tracing spends more time on longer paths Cons: Little information gain for each ray cast Not easy to get good (important) samples Spends equal time on slow-varying diffuse components and fast varying specular components
14
Path Tracing Algorithm
Send a ray through a pixel Trace the ray to its first intersected object From the intersected object, send out One ray to each light source One additional ray a diffusely reflected ray, a specularly reflected ray, or a transmissive ray Trace the ray and recursively follow it, as above Produces a ray “path” – not a ray tree
15
Light ray Light Eye Image plane
16
Illuminance ray Light Diffuse? Specular? Transmission? Eye Image plane
17
Path Tracing This provides a Monte Carlo approach to global illumination Stochastic samples are taken that should represent the actual surface properties The lighting distribution is sampled by tracing rays stochastically along all possible light paths Averaging a large number of sample rays gives an estimate of the integral of all light paths through the pixel
18
Selecting the ray to trace
How do we select which ray to trace? Each material has a kd, ks, and kt Let ktot = kd+ ks + kt Select a random number R in the range (0, ktot ) if (R < kd) then send diffuse ray else if (R < kd + ks) then send specular ray else send transmission ray
19
Tracing a Diffuse Reflection
Ideal diffuse reflection: Light is scattered equally in all directions
20
Tracing a Diffuse Reflection
Tracing a ray from the eye, the light I see could have come from any direction (direct from the light, or indirect from another object) Randomly pick a direction and trace it
21
Computing the Diffuse reflection
We can compute a random direction as follows: Given two random numbers x1in [0,1] and x2 in [0,1], the randomly reflected direction wd is given by wd = (q, f) = (cos-1(sqrt(x1)), 2px2 )
22
Tracing a Specular Reflection
Ideal specular reflection: Light is scattered according to the reflection direction
23
Tracing a Specular Reflection
As with diffuse lighting, tracing a ray from the eye, the light I see could have come from any direction (direct from the light, or indirect from another object) Light is scattered according to the reflection direction
24
Problems Need to trace a lot of rays to get an accurate image
Typically trace 100 – 1000 rays per pixel
25
Problems Need to trace a lot of rays to get an accurate image
Typically trace 100 – 1000 rays per pixel
26
10,000 rays per pixel (Henrik Wann Jensen)
28
Bi-directional Path Tracing
What if we were to combine rays from both directions? Send a ray from the eye and trace it into the scene Send a ray from the light and trace it into the scene Combine them by sending a ray from the end of one path to the end of the other path
29
Bi-directional Path Tracing
Pros: Each ray cast contributes to many paths Building from both ends can catch difficult cases All specular paths Caustics The idea extends to participating media Cons: Still spends a lot of time in slow varying diffuse areas May not sample some of the more difficult paths
30
Example: Mirror Eye ray tracing: ES*DL Light ray tracing: LS*DE
Problematic: ES*DS*L Even Worse: LS*DS*DS*E
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.