computer graphics iii
play

Computer Graphics III Monte Carlo integration Direct illumination - PowerPoint PPT Presentation

Computer Graphics III Monte Carlo integration Direct illumination Jaroslav Kivnek, MFF UK Jaroslav.Krivanek@mff.cuni.cz Entire the lecture in 5 slides Reflection equation = L ( ) L


  1. Computer Graphics III – Monte Carlo integration Direct illumination Jaroslav Křivánek, MFF UK Jaroslav.Krivanek@mff.cuni.cz

  2. Entire the lecture in 5 slides

  3. Reflection equation   =    →     L ( ) L ( ) f ( ) cos d r o i i r i o i i H ( x ) upper hemisphere over x n L i (  i ) L o (  o ) d  i  i  o L r (  o ) CG III (NPGR010) - J. Křivánek 2015

  4. Rendering = Integration of functions   =   →    L ( ) L ( ) f ( ) cos d r o i i r i o i i H ( x ) ◼ Problems ❑ Discontinuous integrand (visibility) ❑ Arbitrarily large integrand values (e.g. light distribution in caustics, BRDFs of glossy surfaces) Incoming radiance ❑ Complex geometry L i ( x ,  i ) for a point on the floor. Images: Greg Ward CG III (NPGR010) - J. Křivánek 2015 4

  5. Monte Carlo integration ◼ General tool for estimating definite integrals Integral:  f ( x ) = I f ( x d ) x Monte Carlo estimate I :  N 1 f ( )  =   i I ; p ( x ) p ( x )  i N p ( ) = i 1 i Works “on average” :  5  3  1  4  2  6 0 1 = E [ I ] I CG III (NPGR010) - J. Křivánek 2015 5

  6. Application of MC to reflection eq: Estimator of reflected radiance ◼ Integral to be estimated:    →    L ( ) f ( ) cos d i i r i o i i integrand(  i ) H ( x ) ◼ PDF for cosine-proportional sampling:  cos  = i p ( )  i ◼ MC estimator (formula to use in the renderer): ( )  N integrand 1  = i ,k F ( )  N N pdf = k 1 i ,k  N  =   →  L ( ) f ( ) i i ,k r i ,k o N = k 1 CG III (NPGR010) - J. Křivánek 2015 6

  7. Variance => image noise CG III (NPGR010) - J. Křivánek 2015 7

  8. … and now the slow way

  9. Digression: Numerical quadrature

  10. Quadrature formulas for numerical integration ◼ General formula in 1D: n  ˆ = I w f ( x ) i i = i 1 f integrand (i.e. the integrated function) n quadrature order (i.e. number of integrand samples) x i node points (i.e. positions of the samples) f (x i ) integrand values at node points w i quadrature weights CG III (NPGR010) - J. Křivánek 2015 10

  11. Quadrature formulas for numerical integration ◼ Quadrature rules differ by the choice of node point positions x i and the weights w i E.g. rectangle rule, trapezoidal rule, Simpson’s method, ❑ Gauss quadrature , … ◼ The samples (i.e. the node points) are placed deterministically CG III (NPGR010) - J. Křivánek 2015 11

  12. Quadrature formulas in multiple dimensions ◼ General formula for quadrature of a function of multiple variables: n n n   ˆ = I ... w w ... w f ( x , x ,..., x ) i i i i i i 1 2 s 1 2 s = = = i 1 i 1 i 1 1 2 s ◼ Convergence speed of approximation error E for an s - dimensional integral is E = O( N -1/s ) ❑ E.g. in order to cut the error in half for a 3-dimensional integral, we need 2 3 = 8 – times more samples ◼ Unusable in higher dimensions ❑ Dimensional explosion CG III (NPGR010) - J. Křivánek 2015 12

  13. Quadrature formulas in multiple dimensions ◼ Deterministic quadrature vs. Monte Carlo ❑ In 1D deterministic better than Monte Carlo ❑ In 2D roughly equivalent ❑ From 3D, MC will always perform better ◼ Remember, quadrature rules are NOT the Monte Carlo method CG III (NPGR010) - J. Křivánek 2015 13

  14. Monte Carlo

  15. History of the Monte Carlo method ◼ Atomic bomb development, Los Alamos 1940 John von Neumann, Stanislav Ulam, Nicholas Metropolis ◼ Further development and practical applications from the early 50’s CG III (NPGR010) - J. Křivánek 2015 15

  16. Monte Carlo method ◼ We simulate many random occurrences of the same type of events, e.g.: ❑ Neutrons – emission, absorption, collisions with hydrogen nuclei ❑ Behavior of computer networks, traffic simulation. ❑ Sociological and economical models – demography, inflation, insurance, etc. CG III (NPGR010) - J. Křivánek 2015 16

  17. Monte Carlo – applications ◼ Financial market simulations ◼ Traffic flow simulations ◼ Environmental sciences ◼ Particle physics ◼ Quantum field theory ◼ Astrophysics ◼ Molecular modeling ◼ Semiconductor devices ◼ Optimization problems ◼ Light transport calculations ◼ ... CG III (NPGR010) - J. Křivánek 2015 17

  18. Slide credit: Iwan Kawrakov CG III (NPGR010) - J. Křivánek 2015 18

  19. Slide credit: Iwan Kawrakov CG III (NPGR010) - J. Křivánek 2015 19

  20. Variance => image noise CG III (NPGR010) - J. Křivánek 2015 20

  21. Monte Carlo integration Samples are placed randomly (or pseudo-randomly) ◼ Convergence of standard error: std. dev. = O( N -1/2 ) ◼ Convergence speed independent of dimension ❑ Faster than classic quadrature rules for 3 and more ❑ dimensions Special methods for placing samples exist ◼ Quasi-Monte Carlo ❑ Faster asymptotic convergence than MC for “smooth” ❑ functions CG III (NPGR010) - J. Křivánek 2015 21

  22. Monte Carlo integration ◼ Pros ❑ Simple implementation ❑ Robust solution for complex integrands and integration domains ❑ Effective for high-dimensional integrals ◼ Cons ❑ Relatively slow convergence – halving the standard error requires four times as many samples ❑ In rendering: images contain noise that disappears slowly CG III (NPGR010) - J. Křivánek 2015 22

  23. Review – Random variables

  24. Random variable ◼ X … random variable ◼ X assumes different values with different probability ❑ Given by the probability distribution D ❑ X  D CG III (NPGR010) - J. Křivánek 2015 24

  25. Discrete random variable Probability mass function ◼ Finite set of values of x i ◼ Each assumed with prob. p i p n  i =  =  p 1 p Pr( X x ) 0 x i i i i = i 1 Cumulative distribution func. ◼ Cumulative distribution 1 function P i )  i (   = = P Pr X x p P 1 i i j n = j 1 x i CG III (NPGR010) - J. Křivánek 2015 25

  26. Continuous random variable ◼ Probability density function, pdf, p ( x ) ( )   = Pr X D p ( x ) d x D ◼ In 1D: )  ( b   = Pr a X b p ( t ) d t a CG III (NPGR010) - J. Křivánek 2015 26

  27. Continuous random variable ◼ Cumulative distribution function, cdf, P ( x ) V 1D: )   ( x   = P ( x ) Pr X x p ( t ) d t − ( )  a = = = Pr X a p ( t ) d t 0 ! a CG III (NPGR010) - J. Křivánek 2015 27

  28. Continuous random variable Example: Uniform distribution Probability density function (pdf) Cumulative distribution function (cdf) CG III (NPGR010) - J. Křivánek 2015 28

  29. Continuous random variable Gaussian (normal) distribution Probability density function (pdf) Image: wikipedia Cumulative distribution function (cdf) CG III (NPGR010) - J. Křivánek 2015 29

  30. Expected value and variance ◼ Expected value    = E X x p ( x ) d x D ◼ Variance ❑ Properties of variance (if X i are independent) CG III (NPGR010) - J. Křivánek 2015 30

  31. Transformation of a random variable 𝑍 = 𝑕(𝑌) ◼ Y is a random variable ◼ Expected value of Y 𝐹[𝑍] = න 𝑕 𝐲 𝑞 𝐲 𝑒𝐲 𝐸 CG III (NPGR010) - J. Křivánek 2015 31

  32. Monte Carlo integration

  33. Monte Carlo integration ◼ General tool for estimating definite integrals Integral:  f ( x ) = I f ( x d ) x Monte Carlo estimate I :  N 1 f ( )  =   i I ; p ( x ) p ( x )  i N p ( ) = i 1 i Works “on average” :  5  3  1  4  2  6 0 1 = E [ I ] I CG III (NPGR010) - J. Křivánek 2015 33

  34. Primary estimator of an integral ( )  = Integral to be estimated: I f x d x  Let X be a random variable from the distribution with the pdf p ( x ), then the random variable F prim given by the transformation f ( X )/ p ( X ) is called the primary estimator of the above integral. f ( X ) = F prim p ( X ) CG III (NPGR010) - J. Křivánek 2015 34

  35. Primary estimator of an integral f ( X ) f ( x ) X 0 1 CG III (NPGR010) - J. Křivánek 2015 35

  36. Estimator vs. estimate ◼ Estimator is a random variable ❑ It is defined though a transformation of another random variable ◼ Estimate is a concrete realization (outcome) of the estimator ◼ No need to worry: the above distinction is important for proving theorems but less important in practice CG III (NPGR010) - J. Křivánek 2015 36

  37. Unbiased estimator ◼ A general statistical estimator is called unbiased if – “on average” – it yields the correct value of an estimated quantity Q (without systematic error). ◼ More precisely:   = E F Q Estimator of the quantity Q Estimated quantity (random variable) (In our case, it is an integral, but in general it could be anything. It is a number, not a random variable.) CG III (NPGR010) - J. Křivánek 2015 37

  38. Unbiased estimator The primary estimator F prim is an unbiased estimator of the integral I. Proof: ( ) ( )   =  f x E F p x d x prim p ( x )  = I CG III (NPGR010) - J. Křivánek 2015 38

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend