monte carlo ray tracing v metropolis algorithm and photon...
TRANSCRIPT
![Page 1: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/1.jpg)
CS6620 Spring 05
Monte Carlo Ray Tracing VMetropolis Algorithm and
Photon Mapping
April 8, 2005
![Page 2: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/2.jpg)
CS6620 Spring 05
• Program 10 (monte carlo) questions?• Internship opportunity
![Page 3: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/3.jpg)
CS6620 Spring 05
Path tracing wrapup• Path tracing can handle arbitrary
L(D|S)*E light paths• But, it is SLOW• Thousands of samples are required to
eliminate noise
![Page 4: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/4.jpg)
CS6620 Spring 05
Importance SamplingClarification
• Importance sampling is a change of variablesin the integration
• Consider the one dimensional integral:
• Monte Carlo techniques can be used tocompute this integral as:
I = f x( )a
b
! dx
I !1
N
1
b ! a( )f "i( )#
"i : uniformly distributed random variable in range [a,b]
![Page 5: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/5.jpg)
CS6620 Spring 05
Importance SamplingClarification
• We can rewrite the integral as:
• And then perform a change of variables:
I =f x( )
g x( )a
b
! g x( )dx
Let dy = g x( )dx
I =f x y( )( )g x y( )( )A
B
! dy
![Page 6: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/6.jpg)
CS6620 Spring 05
Importance SamplingClarification
For a uniformly sampled distribution:
I !1
N
1
b ! a( )f "i( )#
"i : uniformly distributed random variable in range [a,b]
More generally:
I !1
N
1
b ! a( )
f "i( )p "i( )
#
"i : random variable in range [a,b]
p "i( ): probability that distribution will produce value "i
![Page 7: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/7.jpg)
CS6620 Spring 05
Importance SamplingClarification
Note that this:
I !1
N
1
b ! a( )
f "i( )p "i( )
#
looks a whole lot like this:
I =f x y( )( )g x y( )( )A
B
$ dy
if g(x) = p(x)
%Use a random variable with a probability density
that approximates f(x) to minimize variance
![Page 8: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/8.jpg)
CS6620 Spring 05
Importance Sampling Intuition• Monte Carlo techniques work very well at
integrating straight lines (the average of aconstant is always a constant)
• Choose f(x)/p(x) that approximates a straightline
• If could do that exactly we wouldn’t need tointegrate!
• But the closer we can make it, the better
![Page 9: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/9.jpg)
CS6620 Spring 05
Importance SamplingExample
Suppose f x( ) = h x( )cos x
We believe that f x( ) ! cos x
g x( ) = cos x
Integrate f x( )
g x( )= h x( )
with probability distribution cos x
![Page 10: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/10.jpg)
CS6620 Spring 05
Importance samplingpros/cons
• Importance sampling works byreducing the variance of the sample set
• However, it only works if f(x) ≈ g(x)• It CAN make it worse if g(x) is a poor
estimate!
* =
Estimate g(x) Estimate g(x)
![Page 11: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/11.jpg)
CS6620 Spring 05
Metropolis algorithm
![Page 12: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/12.jpg)
CS6620 Spring 05
Metropolis algorithm• Pure path tracing has a hard time “finding” all
of the S* paths• Small samples may contain a lot of energy
(caustics, strong indirect lights)• Solution:
– Use a path tracer to find a path to a light source– Mutate that path to find other nearby paths– Plenty of math to avoid biasing result
![Page 13: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/13.jpg)
CS6620 Spring 05
Metropolis algorithm• Math: Rosenbluth/Rosenbluth/Teller (1953)• Graphics: Veach 1997http://graphics.stanford.edu/papers/veach_thesis/
![Page 14: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/14.jpg)
CS6620 Spring 05
Math• Consider a one-dimensional integral• Evaluate at a random point• Propose a nearby point for inclusion
– Common: use a gaussian distribution– Several other more complex models– Evaluate f(x)
• Accept or reject the new point based onanother random variable:– If new value is large: more likely to accept it– If old value was large: less likely to accept new
one
![Page 15: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/15.jpg)
CS6620 Spring 05
Equations and demo
http://www.lbreyer.com/classic.html
Xi : current point
Y : proposed new point
probability of accepting:
! Xi ,Y( ) = min 1,f Y( )
f Xi( )
"
#$%
&'
(a tiny bit more complicated for complex walking criteria)
if ( < ! Xi ,Y( )
keep sample Xi+1 = Y
else
try again
![Page 16: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/16.jpg)
CS6620 Spring 05
Metropolis summary• Focus samples on important paths• Not all work contributes to final image (throw
away about half of the candidate samples)• Called Markov Chain or Random Walk
algorithm• Details for graphics are quite complex, must
obey properties:– Ergodic: Must be able to reach all states via some
mutation of the original path– Detailed balance: accept/reject ratio leads to
correct integral
![Page 17: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/17.jpg)
CS6620 Spring 05
Photon mapping• Monte Carlo spends a lot of time
computing similar results• Indirect illumination smooth (except
caustics)• Ward algorithm (Radiance): Cache
irradiance values on surfaces• Photon mapping: Reverse ray tracing
to deposit photons on surfaces
![Page 18: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/18.jpg)
CS6620 Spring 05
Pass 1: Emission• Send out photons from the light sources• Deposit energy onto surfaces as they bounce
around• Store photons in a kd-tree
– Store position, color, incoming direction
• Enhancements:– Store “shadow photons” to accelerate shadow
queries– Two separate maps: one for caustics (high
sample densities needed), one for indirectillumination
![Page 19: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/19.jpg)
CS6620 Spring 05
Pass 2: Reconstruction• Trace rays from the eye• Compute direct light the
usual way• Compute indirect light by
interpolating nearestsamples from the photonmap
Diagram from John Hart
![Page 20: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/20.jpg)
CS6620 Spring 05
Photon map
Final image
http://www.seanet.com/~myandper/gallery.htm
![Page 21: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/21.jpg)
CS6620 Spring 05http://graphics.ucsd.edu/~henrik/papers/ewr7/
![Page 22: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/22.jpg)
CS6620 Spring 05
http://www.cs.kuleuven.ac.be/cwis/research/graphics/RENDERPARK/
![Page 23: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/23.jpg)
CS6620 Spring 05
![Page 24: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/24.jpg)
CS6620 Spring 05
![Page 25: Monte Carlo Ray Tracing V Metropolis Algorithm and Photon ...web.cse.ohio-state.edu/~parent.1/classes/782/Papers/MCalgorithms.pdfMetropolis algorithm •Pure path tracing has a hard](https://reader034.vdocuments.us/reader034/viewer/2022050313/5f7597e4f12ca06daa6e9acf/html5/thumbnails/25.jpg)
CS6620 Spring 05
Upcoming lectures• 8 class periods left:
– Visualization symposium (Monday)– Performance programming/tuning– Manta architecture– Color theory– Advanced intersections (CSG, extrusions,
etc.)– Contest/wrapup– Other topics