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 in out Reflection equation Total reflected radiance: integrate


  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. 𝑀 in 𝑀 out Reflection equation ◼ Total reflected radiance: integrate contributions of incident radiance, weighted by the BRDF, over the hemisphere 𝑀 out (𝜕 out ) = න 𝑀 in (𝜕 in ) ⋅ 𝑔 𝑠 (𝜕 in → 𝜕 out ) ⋅ cos 𝜄 in d𝜕 in 𝐼(𝐲) upper hemisphere over x = න CG III (NPGR010) - J. Křivánek 2015

  4. Rendering = Integration of functions 𝑀 out (𝜕 out ) = න 𝑀 in (𝜕 in ) ⋅ 𝑔 𝑠 (𝜕 in → 𝜕 out ) ⋅ cos 𝜄 in d𝜕 in 𝐼(𝐲) ◼ Problems ❑ Discontinuous integrand (visibility) ❑ Arbitrarily large integrand values (e.g. light distribution in caustics, BRDFs of glossy Incoming radiance surfaces) L in ( x , w in ) for a point ❑ Complex geometry on the ceiling. Images: Greg Ward CG III (NPGR010) - J. Křivánek 2015 4

  5. Monte Carlo integration ◼ General tool for estimating definite integrals Integral: g ( x ) 𝐽 = න𝑕(𝐲)d𝐲 Monte Carlo estimate I : 𝑂 𝑕(𝜊 𝑙 ) 𝐽 = 1 𝑂 ෍ 𝑞(𝜊 𝑙 ) ; 𝜊 𝑙 ∝ 𝑞(𝐲) p ( x ) 𝑙=1 Works “on average” :  5  3  1  4  2  6 0 1 𝐹[ 𝐽 ] = 𝐽 CG III (NPGR010) - J. Křivánek 2015 5

  6. Application of MC to reflection eq: Estimator of reflected radiance ◼ Integral to be estimated: න 𝑀 in (𝜕 in ) 𝑔 𝑠 (𝜕 in → 𝜕 out ) cos 𝜄 in d𝜕 in 𝐼(𝐲) integrand( w in ) ◼ pdf for cosine-proportional sampling: 𝑞(𝜕 in ) = cos 𝜄 in 𝜌 ◼ MC estimator (formula to use in the renderer): 𝑂 integrand 𝜕 in,𝑙 1 ෠ 𝑀 out = 𝑂 ෍ pdf 𝜕 in,𝑙 𝑙=1 𝑂 𝜌 = 𝑂 ෍ 𝑀 in 𝜕 in,𝑙 𝑔 𝑠 (𝜕 in,𝑙 → 𝜕 out ) 𝑙=1 CG III (NPGR010) - J. Křivánek 2015 6

  7. Estimator of reflected radiance: Implementation // input variables x...shaded point on a surface normal...surface normal at x omegaOut...viewing (camera) direction estimatedRadianceOut := Rgb(0,0,0); for k = 1... N [omegaInK, pdf] := generateRndDirection (); // evaluate integrand radianceInEst := getRadianceIn (x, omegaInK); brdf := evalBrdf (x, omegaInK, omegaOut); cosThetaIn := dot (normal, omegaInK); integrand := radianceInEst * brdf * cosThetaIn; // evaluate contribution to the outgoing radiance estimatedRadianceOut += integrand / pdf; end for estimatedRadianceOut /= N; CG III (NPGR010) - J. Křivánek 2015 7

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

  9. … and now the slow way

  10. Digression: Numerical quadrature

  11. Quadrature formulas for numerical integration ◼ General formula in 1D: 𝑂 መ 𝐽 = ෍ 𝑥 𝑙 𝑕(𝑦 𝑙 ) 𝑙=1 g integrand (i.e. the integrated function) N quadrature order (i.e. number of integrand samples) x k node points (i.e. positions of the samples) g (x k ) integrand values at node points w k quadrature weights CG III (NPGR010) - J. Křivánek 2015 11

  12. Quadrature formulas for numerical integration ◼ Quadrature rules differ by the choice of node point positions x k and the weights w k 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 12

  13. Quadrature formulas in multiple dimensions ◼ General formula for quadrature of a function of multiple variables: 𝑂 𝑂 𝑂 መ 𝐽 = ෍ ෍ . . . ෍ 𝑥 𝑙 1 𝑥 𝑙 2 . . . 𝑥 𝑙 𝑡 𝑔(𝑦 𝑙 1 , 𝑦 𝑙 2 , . . . , 𝑦 𝑙 𝑒 ) 𝑙 1 =1 𝑙 2 =1 𝑙 𝑒 =1 ◼ Convergence speed of approximation error E for a d - dimensional integral is E = O( N -1/ d ) ❑ 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 13

  14. 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 14

  15. Monte Carlo

  16. 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 16

  17. 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 17

  18. 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 18

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

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

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

  22. 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 22

  23. 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 23

  24. Review – Random variables

  25. 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 25

  26. 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 26

  27. 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 27

  28. 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 28

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

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

  31. 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 31

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

  33. Monte Carlo integration

  34. Monte Carlo integration ◼ General tool for estimating definite integrals Integral: g ( x ) 𝐽 = න𝑕(𝐲)d𝐲 Monte Carlo estimate I : 𝑂 𝑕(𝜊 𝑙 ) 𝐽 = 1 p ( x ) 𝑂 ෍ 𝑞(𝜊 𝑙 ) ; 𝜊 𝑙 ∝ 𝑞(𝐲) 𝑙=1 Works “on average” :  5  3  1  4  2  6 0 1 𝐹[ 𝐽 ] = 𝐽 CG III (NPGR010) - J. Křivánek 2015 34

  35. 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 35

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

  37. 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 37

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