MIT6 837F12 Lec18
MIT6 837F12 Lec18
MIT6 837F12 Lec18
4
Direct Illumination
7
Reflectance Equation, Visually
Lin
Lin Lin Sum (integrate)
over every
v
direction on the
hemisphere,
Lin
modulate incident
illumination by
BRDF
8
The Reflectance Equation
x
9
The Reflectance Equation
x
10
The Rendering Equation
13
Questions?
14
How To Render Global
Illumination?
16
Ray Tracing
• Cast a ray from the eye through each pixel
• Trace secondary rays (shadow, reflection, refraction)
17
“Monte-Carlo Ray Tracing”
• Cast a ray from the eye through each pixel
• Cast random rays from the hit point to evaluate
hemispherical integral using random sampling
18
“Monte-Carlo Ray Tracing”
• Cast a ray from the eye through each pixel
• Cast random rays from the visible point
• Recurse
19
“Monte-Carlo Ray Tracing”
• Cast a ray from the eye through each pixel
• Cast random rays from the visible point
• Recurse
20
“Monte-Carlo Ray Tracing”
• Systematically sample light sources at each hit
– Don’t just wait the rays will hit it by chance
21
Results
Henrik Wann Jensen
22
Monte Carlo Path Tracing
• Trace only one secondary ray per recursion
– Otherwise number of rays explodes!
• But send many primary rays per pixel (antialiasing)
23
Monte Carlo Path Tracing
• Trace only one secondary ray per recursion
– Otherwise number of rays explodes!
• But send many primary rays per pixel (antialiasing)
Again, trace
shadow rays
from each
intersection
24
Monte Carlo Path Tracing
• We shoot one path from the eye at a time
– Connect every surface point on the way to the light by a
shadow ray
– We are randomly sampling the space of all possible light
paths between the source and the camera
25
Path Tracing Results
• 10 paths/pixel
Henrik Wann Jensen
1 path
per pixel
4 paths
per pixel
✔
29
Why Use Random Numbers?
• Fixed random sequence
• We see the structure in the error
Henrik Wann Jensen
Image removed due to copyright restrictions. Please see the above link for further details.
31
For more demo/experimentation
• http://www.mitsuba-renderer.org/
• http://www.pbrt.org/
• http://www.luxrender.net/en_GB/index
32
Questions?
• Vintage path tracing by Kajiya
© Jim Kajiya. All rights reserved. This content is excluded from our Creative Commons
license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
33
Path Tracing is costly
• Needs tons of rays per pixel!
34
Global Illumination (with Indirect)
37
Irradiance Caching
• Indirect illumination is smooth
38
Irradiance Caching
• Indirect illumination is smooth
==> Sample sparsely, interpolate nearby values
39
Irradiance Caching
• Store the indirect illumination
• Interpolate existing cached values
• But do full calculation for direct lighting
40
Irradiance Caching
• Yellow dots:
indirect diffuse sample points
Image removed due to copyright restrictions. Please see above link for further details.
42
Questions?
Image of Y chair designed by H.J. Wegner has been removed due to copyright restrictions.
Please see http://tora_2097.cgsociety.org/portfolio/project-detail/786738/ for further details.
Image: Pure
43
Photon Mapping
• Preprocess: cast rays from light sources, let them
bounce around randomly in the scene
• Store “photons”
44
Photon Mapping
• Preprocess: cast rays from light sources
• Store photons (position + light power + incoming direction)
45
The Photon Map
• Efficiently store photons for fast access
• Use hierarchical spatial structure (kd-tree)
46
Photon Mapping - Rendering
• Cast primary rays
• For secondary rays
– reconstruct irradiance using adjacent stored photon
– Take the k closest photons
• Combine with irradiance caching and a number of other techniques
47
Photon Map Results
48
More Global Illumination Coolness
• Many materials exhibit subsurface scattering
– Light doesn’t just reflect off the surface
– Light enters, scatters around, and exits at another point
– Examples: Skin, marble, milk
Images: Jensen et al.
Photograph Rendering
© ACM. All rights reserved. This content is excluded from our Creative Commons
license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
50
That Was Just the Beginning
• Tons and tons of other Monte Carlo techniques
– Bidirectional Path Tracing
• Shoot random paths not just from camera but also light, connect
the path vertices by shadow rays
– Metropolis Light Transport
• And Finite Element Methods
– Use basis functions instead of random sampling
– Radiosity (with hierarchies & wavelets)
– Precomputed Radiance Transfer
© ACM. All rights reserved. This content is © source unknown. All rights reserved.
© source unknown. All rights reserved. This content is excluded from our Creative Commons This content is excluded from our Creative
excluded from our Creative Commons license. For more license. For more information, see Commons license. For more information,
information, see http://ocw.mit.edu/help/faq-fair-use/. http://ocw.mit.edu/help/faq-fair-use/. see http://ocw.mit.edu/help/faq-fair-use/. 52
Domains of Integration
• Pixel, lens (Euclidean 2D domain)
– Antialiasing filters, depth of field
• Time (1D) Famous motion blur image
from Cook et al. 1984
– Motion blur
• Hemisphere
– Indirect lighting
• Light source
– Soft shadows
© ACM. All rights reserved. This content is excluded from our Creative Commons
license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
53
Motivational Eye Candy
• Rendering glossy reflections
• Random reflection rays around mirror direction
– 1 sample per pixel
© source unknown. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
54
Motivational Eye Candy
• Rendering glossy reflections
• Random reflection rays around mirror direction
– 256 samples per pixel
© source unknown. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.
55
Error/noise Results in Variance
• We use random rays
– Run the algorithm again get different image
• What is the noise/variance/standard deviation?
– And what’s really going on anyway?
© source unknown. All rights reserved. This content is excluded from our Creative
Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/. 56
Integration
• Compute integral of arbitrary function
– e.g. integral over area light source, over hemisphere, etc.
• Continuous problem we need to discretize
– Analytic integration never works because of visibility and other
nasty details
57
Integration
• You know trapezoid, Simpson’s rule, etc.
58
Monte Carlo Integration
• Monte Carlo integration: use random samples and
compute average
– We don’t keep track of spacing between samples
– But we kind of hope it will be 1/N on average
59
Monte Carlo Integration
60
Monte Carlo Integration
62
Monte Carlo Computation of
• The probability is /4
• Count the inside ratio n = # inside / total # trials
• n*4
• The error depends on the number or trials
Demo
def piMC(n):
success = 0
for i in range(n): x=random.random()
y=random.random()
if x*x+y*y<1: success = success+1 return
4.0*float(success)/float(n)
63
Why Not Use Simpson Integration?
• You’re right, Monte Carlo is not very efficient for
computing
• When is it useful?
– High dimensions: Convergence is independent of
dimension!
– For d dimensions, Simpson requires Nd domains (!!!)
– Similar explosion for other quadratures (Gaussian, etc.)
64
Advantages of MC Integration
• Few restrictions on the integrand
– Doesn’t need to be continuous, smooth, ...
– Only need to be able to evaluate at a point
• Extends to high-dimensional problems
– Same convergence
• Conceptually straightforward
• Efficient for solving at just a few points
65
Disadvantages of MC
• Noisy
• Slow convergence
• Good implementation is hard
– Debugging code
– Debugging math
– Choosing appropriate techniques
66
Questions?
• Images by Veach and Guibas, SIGGRAPH 95
68
Smarter Sampling
Sample a non-uniform probability
Called “importance sampling”
Intuitive justification: Sample more in places where there are
likely to be larger contributions to the integral
69
Example: Glossy Reflection
Slide courtesy of Jason Lawrence
• Integral over hemisphere
• BRDF times cosine times incoming light
Image removed due to copyright restrictions – please see Jason Lawrence’s slide 9-12 in the talk slides on “Efficient BRDF
Importance Sampling Using a Factored Representation,” available at http://www.cs.virginia.edu/~jdl/.
70
Sampling a BRDF Slide courtesy of Jason Lawrence
Image removed due to copyright restrictions – please see Jason Lawrence’s slide 9-12 in the talk slides on “Efficient BRDF
Importance Sampling Using a Factored Representation,” available at http://www.cs.virginia.edu/~jdl/.
71
Sampling a BRDF Slide courtesy of Jason Lawrence
Image removed due to copyright restrictions – please see Jason Lawrence’s slide 9-12 in the talk slides on “Efficient BRDF
Importance Sampling Using a Factored Representation,” available at http://www.cs.virginia.edu/~jdl/.
72
Sampling a BRDF Slide courtesy of Jason Lawrence
Image removed due to copyright restrictions – please see Jason Lawrence’s slide 9-12 in the talk slides on “Efficient BRDF
Importance Sampling Using a Factored Representation,” available at http://www.cs.virginia.edu/~jdl/.
73
Importance Sampling Math
• Like before, but now {xi} are not uniform but drawn
according to a probability distribution p
– Uniform case reduces to this with p(x) = const.
• The problem is designing ps that are easy to sample
from and mimic the behavior of f
74
Monte Carlo Path Tracing
Video removed due to copyright restrictions – please see the link below for further details.
http://www.youtube.com/watch?v=mYMkAnm-PWw 75
Questions?
1200 Samples/Pixel
77
Stratified Sampling Example
• When supersampling, instead of taking KxK regular
sub-pixel samples, do random jittering within each
KxK sub-pixel
78
Stratified Sampling Analysis
• Cheap and effective
• But mostly for low-dimensional domains
– Again, subdivision of N-D needs Nd domains like
trapezoid, Simpson’s, etc.!
79
Questions?
• Image from the ARNOLD Renderer by Marcos Fajardo
80
For Further Information...
• 6.839!
• Eric Veach’s PhD dissertation
http://graphics.stanford.edu/papers/veach_thesis/
81
References
Images of the following book covers have been removed due to copyright restrictions:
-Advanced Global Illumination by Philip Dutre, Philippe Bekaert, and Kavita Bala
-Realistic Ray Tracing by Peter Shirley and R. K. Morley
-Realistic Image Synthesis Using Photon Mapping by Henrik Wann Jensen
Please check the books for further details.
82
That’s All for today
Image removed due to copyright restrictions -- please Fig. 13 in Fournier A. and W.T. Reeves. "A Simple Model of Ocean Waves."
SIGGRAPH '86 Proceedings of the 13th Annual Conference on Computer Graphics and Interactive Techniques; Pages 75-84.
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.