02/11/05© 2005 university of wisconsin last time direct lighting light transport equation (lte)...
TRANSCRIPT
02/11/05 © 2005 University of Wisconsin
Last Time
• Direct Lighting
• Light Transport Equation (LTE) Intro
02/11/05 © 2005 University of Wisconsin
Today
• Path Tracing
02/11/05 © 2005 University of Wisconsin
Light Transport Equation (Sect 16.2)
• Power leaving is power emitted plus incoming power that is scattered
• The trace operation, t(p,) traces a ray and finds the first surface seen
• There are many variants on this equation– Mostly related to changing domain of integration
2
2
cos,,),,(,
cos),(),,(,),(
S iiiiiosoe
S iiiiosoeo
dtLfL
dLfLL
xxx
xxxx
02/11/05 © 2005 University of Wisconsin
Interior of a Sphere
• All points emit a constant amount, and also have diffuse reflectance
• Symmetric, so all radiance leaving surface pts is the same
n
xx2
cos,,),(H iiii
hdeo dtLLL
hd
e
ohde
H iiohd
eo
LL
LL
dLLL
1
,
cos,),(2
x
xxn
02/11/05 © 2005 University of Wisconsin
Another view …
• Repeatedly substitute LHS into RHS:
ehdehdehde
ohdehdehde
ohdehde
ohdeo
LLLL
LLLL
LLL
LLL
32
,
,
,),(
x
x
xx
• There is a physical interpretation to this:– Le: no bounces, paths of length 1
hdLe: 1 bounce, paths of length 2
– …
02/11/05 © 2005 University of Wisconsin
Sampling the LTE over Directions
• The integral is over directions (solid angle measure)
• To sample this, we would start at the eye and choose directions based on the BSDF– See what we hit with the trace operator
– Probabilities would be based on solid angle measure
• Some algorithms use this formulation
• Others use the surface area form …
2
cos,,),,(,),(S iiiiiosoeo dtLfLL xxxx
02/11/05 © 2005 University of Wisconsin
Point-to-Point Definitions
• Switch definitions to point-to-point form:
io
o
ff
LL
,,
,
pppp
ppp
’
02/11/05 © 2005 University of Wisconsin
LTE Over Area
• We can switch domains to be over surface area– Need another cos/r2 term to switch measure
– Need a visibility term to make sure we only include points that can see each other V=1 iff the points can see each other, otherwise 0
A se dAVLfLL ppp
ppppppppppp 2
coscos
• To solve this, we sample points on surfaces– Express probabilities in terms of area measures
02/11/05 © 2005 University of Wisconsin
The Geometry Term
• Simplifies the equations significantly, but don’t forget it’s where much of the complexity lies
• Note this term is defined for any two points in the scene, but for most pairs in most scenes it will be 0 due to the visibility term
2
coscos
pppppp
VG
A se dAGLfLL pppppppppppp
02/11/05 © 2005 University of Wisconsin
Expanding the LTE
• We can substitute the LHS into the integral to expand this equation– Mathematically, it’s a Neumann expansion of a linear operator
• One step:
A se dAGLfLL pppppppppppp
32120122312323
21201212
01
212012120101
pppppppppppppp
pppppppp
pp
pppppppppppp
dAdAGfGfL
dAGfL
L
dAGfLLL
A sA s
A se
e
A se
02/11/05 © 2005 University of Wisconsin
Contributions of Paths to Length 3
p0 p1
p0 p2
Le(p1p0)
Le(p2p1)p1
G(p2p1)f(p2p1 p0)
p0 p3Le(p3p2)
p1G(p2p1)f(p2p1 p0)
p2G(p3p2)f(p3p2 p1)
• Every extra bounce adds another reflectance/geometry term
• Total radiance to p0 is the sum over all paths of all lengths
02/11/05 © 2005 University of Wisconsin
Infinite Expansion
• Define to be the path from a light to p0 with i+1 vertices
101
121
1
1111
ii
A iA iA iiiei
i
jjjjjjsi
PL
dAdAdATLP
GfT
ppp
ppppppp
pppppp
ip
p0 p3Le(p3p2)
p1G(p2p1)f(p2p1 p0)
p2G(p3p2)f(p3p2 p1)
3pT
02/11/05 © 2005 University of Wisconsin
Computing Images
• We need one more equation – to convert the radiance into a pixel value, or any other measurement
• Consider a pixel j, for which we want the value, Ij
• We is the measurement function, which computes the ray’s contribution to pixel j– It includes the pixel filter and something to confirm that the ray
actually makes it to the pixel
01010110 pppppppp dAdAGLWIfilmA A ej
100010 , pppppp cameraje tfW
02/11/05 © 2005 University of Wisconsin
Measurement Functions
• We can define different measurement functions for different situations– For instance, with depth of field, the measurement function would
take into account the aperture and lens system
– Or, for precomputing illumination for later real-time rendering, the measurement function would integrate light arriving at a triangle in the scene
– The latter is a real application – building light maps for games
• For the case of rays to the eye, We is the visual importance of the path
02/11/05 © 2005 University of Wisconsin
Monte Carlo Integration
• We want to evaluate the integral
01010110
101
121
1
1111
pppppppp
ppp
ppppppp
pppppp
dAdAGLWI
PL
dAdAdATLP
GfT
filmA A ej
ii
A iA iA iiiei
i
jjjjjjsi
How?
02/11/05 © 2005 University of Wisconsin
Conceptually
• We sample paths, somehow– Each path has a value according to the integrand
– Each path has some probability associated with it
– We evaluate the Monte Carlo estimator• Some trickiness with sum of integrals, but falls out nicely
• The problem is, how do we sample paths?– There is an infinite sum – do we need to compute infinite length
paths?
– How do we make sure that the paths we sample are important?• Have high probability of choosing paths with high contributions
02/11/05 © 2005 University of Wisconsin
Path Tracing (PBR 16.3)
1. Start with a ray sample through a pixel2. If you hit a light, stop and return the radiance
a) This is a sample of a length 2 path
3. If not a specular surfacea) Do a direct lighting computation (sample 1 light) – this is a length
3 pathb) Add it’s contribution to the image
4. Sampling an outgoing direction according to the BSDF, cast a ray
5. Go to step 2, but now the path length is one longer6. Keep going, creating longer and longer paths…
02/11/05 © 2005 University of Wisconsin
Infinite paths?
• We can’t go on forever, path throughput gets smaller and smaller
• Russian Roulette:– At each step, before casting the next ray, make a random choice to
stop: stop with probability qi
– If you decide not to stop, weight new ray’s contribution by 1/(1- qi)
– Eventually, one of the random choices will say stop, particularly if you base the choice on the throughput to this point
• This is an essential technique in any algorithm that traces paths and aims to be unbiased
02/11/05 © 2005 University of Wisconsin
Stratification?
• It is good to stratify the sampling of the BRDF and the lights
• But the benefits of this go down with increasing path length
• The PBRT implementation stratifies the first three bounces, but not the rest
02/11/05 © 2005 University of Wisconsin
Path Tracing Results
1024 samples per pixel
02/11/05 © 2005 University of Wisconsin
Noisy with Low Sampling
8 samples per pixel
02/11/05 © 2005 University of Wisconsin
Path Tracing Analysis
• Arbitrary geometry and BSDFs– No need for surface parameterizations
• Doesn’t waste time on things that aren’t visible
• Unlike ray tracing, spends equal time on all path lengths (ray tracing spends more time on longer paths)
• Downsides:– All the decisions are local – based on BSDF at hit point
– What information is missing?
– Does not share information from different ray-trees to build better paths
02/11/05 © 2005 University of Wisconsin
Failure Mode
02/11/05 © 2005 University of Wisconsin
Bi-Directional Path Tracing• Veach 94; Lafortune and Willems 94• Build a path by working from the eye and the light and join in the
middle• Don’t just look at overall path, also weigh contributions from all sub-
paths:
p1
p2
p3
p4 Light
02/11/05 © 2005 University of Wisconsin
Bi-Directional Optimizations
• After constructing paths, throw away last link to the light– Then use direct lighting integrator to compute incoming radiance at
path endpoints
• Use multiple importance sampling (last lecture) to weight each path’s contribution
• We would really appreciate it if someone implemented this for their project
02/11/05 © 2005 University of Wisconsin
Bi-Directional Analysis
• Advantages:– Each ray cast contributes to many paths
– Building from both ends can catch difficult cases• All specular paths
• Caustics
– Extends to participating media (anisotropic, heterogeneous)
• Disadvantages:– Still using lots of effort to catch slow varying diffuse components
– May not sample difficult to find paths
02/11/05 © 2005 University of Wisconsin
Metropolis Light Transport
• Other algorithms generate independent samples– Easy to control bias
• Metropolis algorithms generate a sequence of paths where each path can depend on the previous one
• For each sample:– Propose a new candidate depending on the previous sample
– Choose to accept or reject according to a computed probability (if reject, re-use the old sample)
• Can prove the estimates for pixel intensities are correct
02/11/05 © 2005 University of Wisconsin
Metropolis Proposal Strategies
• Task: Given the previous sample, generate a new one– Should be very different, but should also be good
• Methods:– Randomly chop out some part of the path and replace it with a new
piece
– Randomly perturb a vertex on the path
– Less randomly change the pixel that is affected
– Other choices possible
02/11/05 © 2005 University of Wisconsin
Light Through Ripples
http://graphics.stanford.edu/papers/metro/
02/11/05 © 2005 University of Wisconsin
Light Through Ripples (Path tracing)
http://graphics.stanford.edu/papers/metro/
02/11/05 © 2005 University of Wisconsin
Metropolis: Analysis
• Can give unbiased estimates of difficult scenarios:– Light through a crack, almost impossible any other way
– Caustics from light reflecting off the bottom of a wavy pool
• Hard to implement – but we have an implementation for PBRT– The details of computing probabilities are difficult
– Several optimizations are required for good results
• Easy to coarsely parallelize
• But, still computes diffuse illumination on a per point basis
02/11/05 © 2005 University of Wisconsin
One more scene
• Metropolis still has trouble in one situation– Spot the error in these images
02/11/05 © 2005 University of Wisconsin
Next Time
• Irradiance Caching
• Photon Mapping