Download presentation
Presentation is loading. Please wait.
1
Monte Carlo Integration COS 323 Acknowledgment: Tom Funkhouser
2
Integration in 1D x=1 f(x) Slide courtesy of Peter Shirley
3
We can approximate x=1 f(x) g(x) Slide courtesy of Peter Shirley
4
Or we can average x=1 f(x) E(f(x)) E(f(x)) Slide courtesy of Peter Shirley
5
Estimating the average x1x1x1x1 f(x) xNxNxNxN E(f(x)) E(f(x)) Slide courtesy of Peter Shirley
6
Other Domains x=b f(x) ab ab x=a Slide courtesy of Peter Shirley
7
Benefits of Monte Carlo No “exponential explosion” in required number of samples with increase in dimensionNo “exponential explosion” in required number of samples with increase in dimension Resistance to badly-behaved functionsResistance to badly-behaved functions
8
Variance x1x1x1x1 xNxNxNxN E(f(x)) E(f(x))
9
Variance x1x1x1x1 xNxNxNxN Variance decreases as 1/N Error decreases as 1/sqrt(N)
10
Variance Problem: variance decreases with 1/NProblem: variance decreases with 1/N – Increasing # samples removes noise slowly x1x1x1x1 xNxNxNxN E(f(x)) E(f(x))
11
Variance Reduction Techniques Problem: variance decreases with 1/NProblem: variance decreases with 1/N – Increasing # samples removes noise slowly Variance reduction:Variance reduction: – Stratified sampling – Importance sampling
12
Stratified Sampling Estimate subdomains separatelyEstimate subdomains separately x1x1x1x1 xNxNxNxN E k (f(x)) E k (f(x)) Arvo
13
Stratified Sampling This is still unbiasedThis is still unbiased x1x1x1x1 xNxNxNxN E k (f(x)) E k (f(x))
14
Stratified Sampling Less overall variance if less variance in subdomainsLess overall variance if less variance in subdomains x1x1x1x1 xNxNxNxN E k (f(x)) E k (f(x))
15
Importance Sampling Put more samples where f(x) is biggerPut more samples where f(x) is bigger x1x1x1x1 xNxNxNxN E(f(x)) E(f(x))
16
Importance Sampling This is still unbiasedThis is still unbiased x1x1x1x1 xNxNxNxN E(f(x)) E(f(x)) for all N
17
Importance Sampling Zero variance if p(x) ~ f(x)Zero variance if p(x) ~ f(x) x1x1 xNxN E(f(x)) Less variance with better importance sampling
18
Generating Random Points Uniform distribution:Uniform distribution: – Use pseudorandom number generator Probability 0 1
19
Pseudorandom Numbers Deterministic, but have statistical properties resembling true random numbersDeterministic, but have statistical properties resembling true random numbers Common approach: each successive pseudorandom number is function of previousCommon approach: each successive pseudorandom number is function of previous Linear congruential method:Linear congruential method: – Choose constants carefully, e.g. a = 1664525 b = 1013904223 c = 2 32 – 1
20
Pseudorandom Numbers To get floating-point numbers in [0..1), divide integer numbers by c + 1To get floating-point numbers in [0..1), divide integer numbers by c + 1 To get integers in range [u..v], divide by (c+1)/(v–u+1), truncate, and add uTo get integers in range [u..v], divide by (c+1)/(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
21
Generating Random Points Uniform distribution:Uniform distribution: – Use pseudorandom number generator Probability 0 1
22
Importance Sampling Specific probability distribution:Specific probability distribution: – Function inversion – Rejection
23
Importance Sampling “Inversion method”“Inversion method” – Integrate f ( x ): Cumulative Distribution Function 11
24
Importance Sampling “Inversion method”“Inversion method” – Integrate f ( x ): Cumulative Distribution Function – Invert CDF, apply to uniform random variable 11
25
Importance Sampling Specific probability distribution:Specific probability distribution: – Function inversion – Rejection
26
Generating Random Points “Rejection method”“Rejection method” – Generate random (x,y) pairs, y between 0 and max(f ( x ) )
27
Generating Random Points “Rejection method”“Rejection method” – Generate random (x,y) pairs, y between 0 and max(f ( x ) ) – Keep only samples where y < f(x)
28
Monte Carlo in Computer Graphics
29
or, Solving Integral Equations for Fun and Profit
30
or, Ugly Equations, Pretty Pictures
31
AnimationAnimation Computer Graphics Pipeline RenderingRendering LightingandReflectanceLightingandReflectance ModelingModeling
32
Rendering Equation Surface Light [Kajiya 1986] Viewer
33
Rendering Equation This is an integral equationThis is an integral equation Hard to solve!Hard to solve! – Can’t solve this in closed form – Simulate complex phenomena Jensen
34
Rendering Equation This is an integral equationThis is an integral equation Hard to solve!Hard to solve! – Can’t solve this in closed form – Simulate complex phenomena Heinrich
35
Rendering Equation This is an integral equationThis is an integral equation Hard to solve!Hard to solve! – Can’t solve this in closed form – Simulate complex phenomena Jensen
36
Monte Carlo Integration f(x) Shirley
37
Monte Carlo Path Tracing Estimate integral for each pixel by random sampling
38
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics
39
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics SurfaceEyePixel x x
40
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Surface Eye Light x x’
41
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Herf
42
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Surface Eye Light x Surface ’’’’
43
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Debevec
44
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Diffuse Surface Eye Light x Specular Surface ’’’’
45
Monte Carlo Global Illumination Rendering = integrationRendering = integration – Antialiasing – Soft shadows – Indirect illumination – Caustics Jensen
46
Challenge Rendering integrals are difficult to evaluateRendering integrals are difficult to evaluate – Multiple dimensions – Discontinuities Partial occludersPartial occluders HighlightsHighlights CausticsCaustics Drettakis
47
Challenge Rendering integrals are difficult to evaluateRendering integrals are difficult to evaluate – Multiple dimensions – Discontinuities Partial occludersPartial occluders HighlightsHighlights CausticsCaustics Jensen
48
Monte Carlo Path Tracing Big diffuse light source, 20 minutes Jensen
49
Monte Carlo Path Tracing 1000 paths/pixel Jensen
50
Monte Carlo Path Tracing Drawback: can be noisy unless lots of paths simulatedDrawback: can be noisy unless lots of paths simulated 40 paths per pixel:40 paths per pixel: Lawrence
51
Monte Carlo Path Tracing Drawback: can be noisy unless lots of paths simulatedDrawback: can be noisy unless lots of paths simulated 1200 paths per pixel:1200 paths per pixel: Lawrence
52
Reducing Variance Observation: some paths more important (carry more energy) than othersObservation: 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 biggerIdea: put more samples where f(x) is bigger
53
Importance Sampling Idea: put more samples where f(x) is biggerIdea: put more samples where f(x) is bigger
54
Effect of Importance Sampling Less noise at a given number of samplesLess noise at a given number of samples Equivalently, need to simulate fewer paths for some desired limit of noiseEquivalently, need to simulate fewer paths for some desired limit of noise Uniform random sampling Importance sampling
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.