Computer Graphics III – Monte Carlo integration Direct illumination
Jaroslav Křivánek, MFF UK Jaroslav.Krivanek@mff.cuni.cz
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
Jaroslav Křivánek, MFF UK Jaroslav.Krivanek@mff.cuni.cz
) ( i i
i i
x H r
CG III (NPGR010) - J. Křivánek 2015
◼ Problems
❑ Discontinuous integrand
❑ Arbitrarily large integrand
❑ Complex geometry
CG III (NPGR010) - J. Křivánek 2015 4
) ( i i
i i
x H r
Incoming radiance Li(x,i) for a point
Images: Greg Ward
◼ General tool for estimating definite integrals
1
i N i i i
=
CG III (NPGR010) - J. Křivánek 2015 5
◼ Integral to be estimated: ◼ PDF for cosine-proportional sampling: ◼ MC estimator (formula to use in the renderer):
CG III (NPGR010) - J. Křivánek 2015 6
= =
N k ,k r ,k N k ,k ,k N
1
i i 1 i i
i i
) ( i i
i i
x H r
integrand(i)
CG III (NPGR010) - J. Křivánek 2015 7
◼ General formula in 1D:
=
n i i i
1
CG III (NPGR010) - J. Křivánek 2015 10
◼ Quadrature rules differ by the choice of node point
❑
◼ The samples (i.e. the node points) are placed
CG III (NPGR010) - J. Křivánek 2015 11
◼ General formula for quadrature of a function of multiple
◼ Convergence speed of approximation error E for an s-
❑ E.g. in order to cut the error in half for a 3-dimensional
◼ Unusable in higher dimensions
❑ Dimensional explosion
= = =
n i n i n i i i i i i i
s s s
1 1 1
1 2 2 1 2 1
CG III (NPGR010) - J. Křivánek 2015 12
◼ 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
CG III (NPGR010) - J. Křivánek 2015 13
◼ Atomic bomb development, Los Alamos 1940
◼ Further development and practical applications from the
CG III (NPGR010) - J. Křivánek 2015 15
◼ We simulate many random occurrences of the same type
❑ Neutrons – emission, absorption, collisions with hydrogen
❑ Behavior of computer networks, traffic simulation. ❑ Sociological and economical models – demography,
CG III (NPGR010) - J. Křivánek 2015 16
◼ 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
CG III (NPGR010) - J. Křivánek 2015
Slide credit: Iwan Kawrakov
18
CG III (NPGR010) - J. Křivánek 2015
Slide credit: Iwan Kawrakov
19
CG III (NPGR010) - J. Křivánek 2015 20
◼
◼
❑
❑
◼
❑
❑
CG III (NPGR010) - J. Křivánek 2015 21
◼ Pros
❑ Simple implementation ❑ Robust solution for complex integrands and integration
❑ Effective for high-dimensional integrals
◼ Cons
❑ Relatively slow convergence – halving the standard error
❑ In rendering: images contain noise that disappears slowly
CG III (NPGR010) - J. Křivánek 2015 22
◼ 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
◼ Finite set of values of xi ◼ Each assumed with prob. pi ◼ Cumulative distribution
CG III (NPGR010) - J. Křivánek 2015 25
i i
=
n i i
1
i
i
Probability mass function
=
i j j i i
1
n
i
i
Cumulative distribution func.
◼ Probability density function, pdf, p(x) ◼ In 1D:
CG III (NPGR010) - J. Křivánek 2015 26
D
b a
◼ Cumulative distribution function, cdf, P(x)
CG III (NPGR010) - J. Křivánek 2015 27
−
x
a a
CG III (NPGR010) - J. Křivánek 2015 28
CG III (NPGR010) - J. Křivánek 2015 29
Image: wikipedia
◼ Expected value ◼ Variance
❑ Properties of variance
D
(if Xi are independent)
CG III (NPGR010) - J. Křivánek 2015 30
◼ Y is a random variable ◼ Expected value of Y
CG III (NPGR010) - J. Křivánek 2015 31
𝐸
◼ General tool for estimating definite integrals
1
i N i i i
=
CG III (NPGR010) - J. Křivánek 2015 33
prim
CG III (NPGR010) - J. Křivánek 2015 34
CG III (NPGR010) - J. Křivánek 2015 35
◼ Estimator is a random variable
❑ It is defined though a transformation of another random
◼ Estimate is a concrete realization (outcome) of the
◼ No need to worry: the above distinction is important for
CG III (NPGR010) - J. Křivánek 2015 36
◼ A general statistical estimator is called unbiased if –
◼ More precisely:
CG III (NPGR010) - J. Křivánek 2015 37
Estimated quantity (In our case, it is an integral, but in general it could be
random variable.) Estimator of the quantity Q (random variable)
CG III (NPGR010) - J. Křivánek 2015 38
prim
2 2 2 prim 2 prim 2 prim prim
(for an unbiased estimator)
CG III (NPGR010) - J. Křivánek 2015 39
◼ Consider N independent random variables Xi ◼ The estimator FN given be the formula below is called the
◼ The secondary estimator is unbiased.
CG III (NPGR010) - J. Křivánek 2015 40
=
N i i i N
1
prim 2 1 i
i i N i i N
=
CG III (NPGR010) - J. Křivánek 2015 41
◼ A general statistical estimator is called unbiased if –
◼ More precisely:
CG III (NPGR010) - J. Křivánek 2015 43
Estimated quantity (In our case, it is an integral, but in general it could be
random variable.) Estimator of the quantity Q (random variable)
◼ If
◼ Bias is the systematic error of he estimator:
CG III (NPGR010) - J. Křivánek 2015 44
◼ Consider a secondary estimator with N samples: ◼ Estimator FN is consistent if
CG III (NPGR010) - J. Křivánek 2015 45
2 1 N N N
◼ Sufficient condition for consistency of an estimator: ◼ Unbiasedness is not sufficient for consistency by itself (if
◼ But if the variance of a primary estimator finite, then the
CG III (NPGR010) - J. Křivánek 2015 46
◼ Unbiased
❑ Path tracing ❑ Bidirectional path tracing ❑ Metropolis light transport
◼ Biased & Consistent
❑ Progressive photon mapping
◼ Biased & not consistent
❑ Photon mapping ❑ Irradiance / radiance caching
CG III (NPGR010) - J. Křivánek 2015 47
◼ Definition ◼ Proposition
❑ Proof
CG III (NPGR010) - J. Křivánek 2015 48
2
2
◼ If the estimator F is unbiased, then
◼ Unbiased estimator of variance
CG III (NPGR010) - J. Křivánek 2015 49
CG III (NPGR010) - J. Křivánek 2015 50
◼ Efficiency of an unbiased estimator is given by:
CG III (NPGR010) - J. Křivánek 2015 51
◼ PDF for uniform sampling: ◼ Estimator:
CG III (NPGR010) - J. Křivánek 2015 53
) ( i i i i
x
H
= =
N k ,k k N k k k N
1 i i, i 1 i, i,
◼ Integral to be estimated:
CG III (NPGR010) - J. Křivánek 2015 54
= =
N k ,k N k ,k ,k N
1 i i 1 i i
◼ PDF for cosine-
◼ Estimator ◼ Integral to be estimated:
) ( i i i i
x
H
CG III (NPGR010) - J. Křivánek 2015 55
◼ Reformulate the reflection integral (change of variables) ◼ PDF for uniform sampling of the surface area: ◼ Estimator
CG III (NPGR010) - J. Křivánek 2015 56
A H
2 e ) ( i i i i
x y x
=
N k k k k N
1 e
CG III (NPGR010) - J. Křivánek 2015 57
Light source area sampling Cosine-proportional sampling Images: Pat Hanrahan
CG III (NPGR010) - J. Křivánek 2015 58
CG III (NPGR010) - J. Křivánek 2015 59
1 sample per pixel 9 samples per pixel 36 samples per pixel
CG III (NPGR010) - J. Křivánek 2015 60
◼ Integral to be estimated ◼ Estimator based on uniform light source sampling
CG III (NPGR010) - J. Křivánek 2015 61
A r
=
N k k k k r k N
1