Monte Carlo Integration COS 323

Similar documents
Monte Carlo Integration COS 323

Motivation. Advanced Computer Graphics (Fall 2009) CS 283, Lecture 11: Monte Carlo Integration Ravi Ramamoorthi

Monte-Carlo Ray Tracing. Antialiasing & integration. Global illumination. Why integration? Domains of integration. What else can we integrate?

Raytracing & Epsilon. Today. Last Time? Forward Ray Tracing. Does Ray Tracing Simulate Physics? Local Illumination

Monte Carlo Integration

Motivation: Monte Carlo Rendering. Sampling and Reconstruction of Visual Appearance. Caustics. Illumination Models. Overview of lecture.

Motivation. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

Schedule. MIT Monte-Carlo Ray Tracing. Radiosity. Review of last week? Limitations of radiosity. Radiosity

Motivation: Monte Carlo Path Tracing. Sampling and Reconstruction of Visual Appearance. Monte Carlo Path Tracing. Monte Carlo Path Tracing

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

To Do. Real-Time High Quality Rendering. Motivation for Lecture. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Monte Carlo Integration

Numerical Integration

Computational Methods. Randomness and Monte Carlo Methods

The Rendering Equation and Path Tracing

Monte Carlo Integration and Random Numbers

Lecture 7: Monte Carlo Rendering. MC Advantages

GAMES Webinar: Rendering Tutorial 2. Monte Carlo Methods. Shuang Zhao

Biased Monte Carlo Ray Tracing:

Monte Carlo Integration of The Rendering Equation. Computer Graphics CMU /15-662, Spring 2017

Scientific Computing: An Introductory Survey

Monte Carlo Ray Tracing. Computer Graphics CMU /15-662

Global Illumination and Monte Carlo

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

Biased Monte Carlo Ray Tracing

2/1/10. Outline. The Radiance Equation. Light: Flux Equilibrium. Light: Radiant Power. Light: Equation. Radiance. Jan Kautz

You ve already read basics of simulation now I will be taking up method of simulation, that is Random Number Generation

Path Tracing part 2. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Discussion. Smoothness of Indirect Lighting. History and Outline. Irradiance Calculation. Irradiance Caching. Advanced Computer Graphics (Spring 2013)

Physically Realistic Ray Tracing

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Advanced Graphics. Path Tracing and Photon Mapping Part 2. Path Tracing and Photon Mapping

Global Illumination The Game of Light Transport. Jian Huang

CS 563 Advanced Topics in Computer Graphics Monte Carlo Integration: Basic Concepts. by Emmanuel Agu

What We ll Do... Random

Korrigeringar: An introduction to Global Illumination. Global Illumination. Examples of light transport notation light

Photon Maps. The photon map stores the lighting information on points or photons in 3D space ( on /near 2D surfaces)

Lecture 7 - Path Tracing

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

Anti-aliasing and Monte Carlo Path Tracing

Distribution Ray Tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Illumination Algorithms

13 Distribution Ray Tracing

Reading. 8. Distribution Ray Tracing. Required: Watt, sections 10.6,14.8. Further reading:

Stochastic Path Tracing and Image-based lighting

Realistic Image Synthesis

Progressive photon mapping can be interpreted as an estimator that constructs the full paths from camera to light by constantly connecting two fresh

A Brief Overview of. Global Illumination. Thomas Larsson, Afshin Ameri Mälardalen University

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 457 Autumn 2017

Importance Sampling of Area Lights in Participating Media

Random Number Generators

Choosing the Right Algorithm & Guiding

Towards Interactive Global Illumination Effects via Sequential Monte Carlo Adaptation. Carson Brownlee Peter S. Shirley Steven G.

Distributed Ray Tracing

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Metropolis Light Transport

Random Number Generation and Monte Carlo Methods

Volumetric Path Tracing

To Do. Advanced Computer Graphics. Course Outline. Course Outline. Illumination Models. Diffuse Interreflection

The Rendering Equation & Monte Carlo Ray Tracing

Low Memory Spectral Photon Mapping

CS130 : Computer Graphics Lecture 8: Lighting and Shading. Tamar Shinar Computer Science & Engineering UC Riverside

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

Reading. Distribution Ray Tracing. BRDF, revisited. Pixel anti-aliasing. ω in. Required: Shirley, section Further reading:

Probability Models.S4 Simulating Random Variables

Final Project: Real-Time Global Illumination with Radiance Regression Functions

Philipp Slusallek Karol Myszkowski. Realistic Image Synthesis SS18 Instant Global Illumination

Virtual Spherical Lights for Many-Light Rendering of Glossy Scenes

SOME THEORY BEHIND REAL-TIME RENDERING

EECS 487: Interactive Computer Graphics

Global Illumination. COMP 575/770 Spring 2013

Path Tracing. Mikael Persson mpersson December 3, 2001

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

An introduction to Global Illumination. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Scalable many-light methods

COMP371 COMPUTER GRAPHICS

An Effective Stratified Sampling Scheme for Environment Maps with Median Cut Method

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Implementation of Bidirectional Ray Tracing Algorithm

Global Illumination CS334. Daniel G. Aliaga Department of Computer Science Purdue University

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Physics 736. Experimental Methods in Nuclear-, Particle-, and Astrophysics. - Statistical Methods -

Chapter 1. Introduction

Sampling and Monte-Carlo Integration

Spherical Harmonic Lighting: The Gritty Details Robin Green

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Assignment 2 Ray Tracing

Interactive Methods in Scientific Visualization

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Computer Graphics (CS 4731) Lecture 16: Lighting, Shading and Materials (Part 1)

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

Chapter 7 - Light, Materials, Appearance

MITOCW MIT6_172_F10_lec18_300k-mp4

Reproducibility in Stochastic Simulation

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

lecture 19: monte carlo methods

CS635 Spring Department of Computer Science Purdue University

Transcription:

Monte Carlo Integration COS 323

Integration in d Dimensions? One option: nested 1-D integration f(x,y) g(y) y f ( x, y) dx dy ( ) = g y dy x Evaluate the latter numerically, but each sample of g(y) is itself a 1-D integral, done numerically

Integration in d Dimensions? Midpoint rule in d dimensions? In 1D: (b-a)/h points In 2D: (b-a)/h 2 points In general: O(1/h d ) points Required # of points grows exponentially with dimension, for a fixed order of method Curse of dimensionality Other problems, e.g. non-rectangular domains

Rethinking Integration in 1D 1 f ( x) dx =? 0 f(x) x=1 Slide courtesy of Peter Shirley

We Can Approximate 1 1 = 0 f ( x) dx g( x) dx 0 f(x) g(x) x=1 Slide courtesy of Peter Shirley

Or We Can Average 1 f ( x) dx = E( f ( x)) 0 f(x) E(f(x)) x=1 Slide courtesy of Peter Shirley

Estimating the Average 1 0 f (x)dx 1 N N i=1 f (x i ) f(x) E(f(x)) Slide courtesy of Peter Shirley

Other Domains b a f (x)dx b a N N i=1 f (x i ) f(x) < f > ab x=a x=b Slide courtesy of Peter Shirley

Monte Carlo Integration No exponential explosion in required number of samples with increase in dimension (Some) resistance to badly-behaved functions Le Grand Casino de Monte-Carlo

Variance b a Var N b a N i= 1 f ( x) dx f ( x i ) = = b a N N ( b a) N i= 1 2 b a N 2 f ( x N i= 1 i ) Var[ Var[ f ( x f ( x i )] * 1 i )] N with a correction of N- (consult a statistician for details) Variance decreases as 1/N Error of E decreases as 1/sqrt(N)

Variance Problem: variance decreases with 1/N Increasing # samples removes noise slowly E(f(x))

Variance Reduction Techniques Problem: variance decreases with 1/N Increasing # samples removes noise slowly Variance reduction: Stratified sampling Importance sampling

Stratified Sampling Estimate subdomains separately E k (f(x)) M 1 M k Can do this recursively!

Stratified Sampling This is still unbiased E k (f(x)) E = k vol(m ) j f (x ) jn j =1 N j N j n =1 M 1 M k

Stratified Sampling Less overall variance if less variance in subdomains Var[ E] = k j =1 vol(m j ) 2 N j Var[ f (x)] M j E k (f(x)) M 1 M k Total variance minimized when number of points in each subvolume M j proportional to error in M j.

Importance Sampling Put more samples where f(x) is bigger E(f(x)) f (x)dx = 1 N Y i Ω N i=1 where Y i = f (x i ) p(x i ) and x i drawn from P(x)

Importance Sampling This is still unbiased E(f(x)) [ Y ] E i = = Ω Ω Y ( x) p( x) dx f ( x) p( x) dx p( x) = f ( x) dx Ω for all N

Importance Sampling Variance depends on choice of p(x): E(f(x)) Var(E) = 1 N N n =1 f (x n ) p(x n ) 2 E 2

Importance Sampling Zero variance if p(x) ~ f(x) E(f(x)) p( x) = cf ( x) Y i = f ( x p( x Var( Y ) i i = ) 1 = ) c 0 Less variance with better importance sampling

Random number generation

True random numbers http://www.random.org/ 10101111 00101011 10111000 11110110 10101010 00110001 01100011 00010001 00000011 00000010 00111111 00010011 00000101 01001100 10000110 11100010 10010100 10000101 10000011 00000100 00111011 10111000 00110000 11001010 11011101 11101111 00100010 10101011 00100110 10101111 00001011 10110100 00011100 00001111 11001001 11001100 01111101 10000100 10111000 01101011 01101011 01111101 11001010 11101110 11101110 00100010 10110100 01001000 11010111 11011011 11100100 01010010 10111101 01011010 01001110 01110000 00100010 11000111 01010000 10110011 01001011 00110001 01011100 10001111 11111000 10101011 01011011 01010000 01101111 00011001 00000011 00110000 10000001 00000110 11010011 00011110 11101101 00000011 00100110 01010011 11010111 10010001 10000111 01010010 01101010 00100101 10011111 01000111 10101001 01100001 01010011 01001000 11010110 01111110 11010011 01110110 00000001 01001110 00011001 00111001

Generating Random Points Uniform distribution: Use pseudorandom number generator 1 Probability 0 Ω

Pseudorandom Numbers Deterministic, but have statistical properties resembling true random numbers Common approach: each successive pseudorandom number is function of previous

Desirable properties Random pattern: Passes statistical tests (e.g., can use chi-squared) Long period: As long as possible without repeating Efficiency Repeatability: Produce same sequence if started with same initial conditions (for debugging!) Portability

Linear Congruential Methods x n+ Choose constants carefully, e.g. a = 1664525 b = 1013904223 c = 2 32 Results in integer in [0, c) ( ax b) mod c = + 1 n Simple, efficient, but often unsuitable for MC: e.g. exhibit serial correlations

Problem with LCGs

Lagged Fibonacci Generators Takes form x n = (x n-j «x n-k ) mod m, where operation «is addition, subtraction, or XOR Standard choices of (j, k): e.g., (7, 10), (5,17), (6,31), (24,55), (31, 63) with m = 2 32 Proper initialization is important and hard Built-in correlation! Not totally understood in theory (need statistical tests to evaluate)

Seeds Why? Approaches: Ask the user (for debugging) Time of day True random noise: from radio turned to static, or thermal noise in a resistor, or

Seeds Lava lamps! http://www.google.com/patents/about/5732138_method_for_seeding_a_pseud o_rand.html?id=ou0gaaaaebaj

Pseudorandom Numbers Most methods provide integers in range [0..c) To get floating-point numbers in [0..1), divide integer numbers by c To get integers in range [u..v], divide by c/(v u+1), truncate, and add u Better statistics than using modulo (v u+1) Only works if u and v small compared to c

Generating Random Points Uniform distribution: Use pseudorandom number generator 1 Probability 0 Ω

Sampling from a non-uniform distribution Specific probability distribution: Function inversion Rejection f (x)

Sampling from a non-uniform distribution Inversion method Integrate f(x): Cumulative Distribution Function f (x) 1 f ( x) dx

Sampling from a non-uniform distribution Inversion method Integrate f(x): Cumulative Distribution Function Invert CDF, apply to uniform random variable f (x) 1 f ( x) dx

Sampling from a non-uniform distribution Specific probability distribution: Function inversion Rejection f (x)

Sampling from a non-uniform distribution Rejection method Generate random (x,y) pairs, y between 0 and max(f(x))

Sampling from a non-uniform distribution Rejection method Generate random (x,y) pairs, y between 0 and max(f(x)) Keep only samples where y < f(x) Doesn t require cdf: Can use directly for importance sampling.

Example: Computing pi

With Stratified Sampling

Monte Carlo in Computer Graphics

or, Solving Integral Equations for Fun and Profit

or, Ugly Equations, Pretty Pictures

Computer Graphics Pipeline Modeling Animation Rendering Lighting and Reflectance

Rendering Equation L o Light ( x, ω') = L ( x, ω') + L ( x, ω) f ( x, ω, ω')( ω n) dω e dω ω Ω i Surface n x r ω ' Viewer Ω [Kajiya 1986]

Rendering Equation L o ( x, ω') = L ( x, ω') + L ( x, ω) f ( x, ω, ω')( ω n) dω e Ω i r This is an integral equation Hard to solve! Can t solve this in closed form Simulate complex phenomena Heinrich

Rendering Equation L o ( x, ω') = L ( x, ω') + L ( x, ω) f ( x, ω, ω')( ω n) dω e Ω i r This is an integral equation Hard to solve! Can t solve this in closed form Simulate complex phenomena Jensen

Monte Carlo Integration f(x) 1 N 1 f ( x) dx N 0 i= 1 f ( x i ) Shirley

Estimate integral for each pixel by random sampling Monte Carlo Path Tracing

Global Illumination From Grzegorz Tanski, Wikipedia

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Eye Pixel Caustics x Surface LP = L(x S e)da

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics Eye Light x x Surface L(x,w) = L e(x,x e) + S f r ( x, x x, x e) L(x x)v ( x, x ) G( x, x ) da

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics Herf L(x,w) = L e(x,x e) + S f r ( x, x x, x e) L(x x)v ( x, x ) G( x, x ) da

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics Eye ω Surface ω Light L (x,w) o = L e(x,w) + Ω f r ( x, w, w) L (x,w )( w n) dw i x Surface

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics L (x,w) o = L e(x,w) + Ω f r ( x, w, w) L (x,w )( w n) dw i Debevec

Monte Carlo Global Illumination Rendering = integration Antialiasing Specular Surface Light Soft shadows Indirect illumination Caustics Eye ω ω L (x,w) o = L e(x,w) + Ω f r ( x, w, w) L (x,w )( w n) dw i x Diffuse Surface

Monte Carlo Global Illumination Rendering = integration Antialiasing Soft shadows Indirect illumination Caustics L (x,w) o = L e(x,w) + Ω f r ( x, w, w) L (x,w )( w n) dw i Jensen

Challenge Rendering integrals are difficult to evaluate Multiple dimensions Discontinuities Partial occluders Highlights Caustics L(x,w) = L e(x,x e) + S f r ( x, x x, x e) L(x Drettakis x)v ( x, x ) G( x, x ) da

Challenge Rendering integrals are difficult to evaluate Multiple dimensions Discontinuities Partial occluders Highlights Caustics L(x,w) = L e(x,x e) + S f r ( x, x x, x e) L(x Jensen x)v ( x, x ) G( x, x ) da

Monte Carlo Path Tracing Big diffuse light source, 20 minutes Jensen

Monte Carlo Path Tracing 1000 paths/pixel Jensen

Monte Carlo Path Tracing Drawback: can be noisy unless lots of paths simulated 40 paths per pixel: Lawrence

Monte Carlo Path Tracing Drawback: can be noisy unless lots of paths simulated 1200 paths per pixel: Lawrence

Reducing Variance Observation: some paths more important (carry more energy) than others For example, shiny surfaces reflect more light in the ideal mirror direction Idea: put more samples where f(x) is bigger

Importance Sampling Idea: put more samples where f(x) is bigger 1 f ( x) dx 0 i= 1 Y i = f ( x p( x i i N 1 = Y N ) ) i

Effect of Importance Sampling Less noise at a given number of samples Uniform random sampling Importance sampling Equivalently, need to simulate fewer paths for some desired limit of noise