Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of...
-
Upload
elizabeth-fisher -
Category
Documents
-
view
213 -
download
0
Transcript of Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of...
![Page 1: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/1.jpg)
Monte Carlo I
Previous lecture Analytical illumination formula
This lecture Numerical evaluation of illumination Review random variables and probability Monte Carlo integration Sampling from distributions Sampling from shapes Variance and efficiency
![Page 2: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/2.jpg)
Lighting and Soft Shadows
Challenges
Visibility and blockers
Varying light distribution
Complex source geometry
2
( ) ( , )cosi
H
E x L x dω θ ω=∫
Source: Agrawala. Ramamoorthi, Heirich, Moll, 2000
![Page 3: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/3.jpg)
Penumbras and Umbras
![Page 4: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/4.jpg)
Monte Carlo Lighting
1 eye ray per pixel1 shadow ray per eye
ray
Fixed Random
![Page 5: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/5.jpg)
Monte Carlo Algorithms
Advantages Easy to implement Easy to think about (but be careful of statistical bias) Robust when used with complex integrands and
domains (shapes, lights, …) Efficient for high dimensional integrals Efficient solution method for a few selected points
Disadvantages Noisy Slow (many samples needed for convergence)
![Page 6: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/6.jpg)
Random Variables
is chosen by some random process
probability distribution (density) function
X
~ ( )X p x
![Page 7: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/7.jpg)
Discrete Probability Distributions
Discrete events Xi with probability pi
Cumulative PDF (distribution)
Construction of samples
To randomly select an event,
Select Xi if
0ip ≥1
1n
ii
p=
=∑
1i iP U P− < ≤
ip
1
j
j ii
P p=
=∑
Uniform random variable
U
1
0
3X
iP
![Page 8: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/8.jpg)
Continuous Probability Distributions
PDF (density)
CDF (distribution)1
0
( ) Pr( )P x X x= <
Pr( ) ( )
( ) ( )
X p x dx
P P
β
α
α β
β α
≤ ≤ =
= −
∫
( )p x
10Uniform
( ) 0p x ≥
0
( ) ( )x
P x p x dx=∫(1) 1P =
( )P x
![Page 9: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/9.jpg)
Sampling Continuous Distributions
Cumulative probability distribution function
Construction of samplesSolve for X=P-1(U)
Must know:1. The integral of p(x)2. The inverse function P-1(x)
U
X
1
0
( ) Pr( )P x X x= <
![Page 10: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/10.jpg)
Example: Power Function
Assume( ) ( 1) np x n x= +
11 1
0 0
1
1 1
nn x
x dxn n
+
= =+ +∫
1( ) nP x x +=
1 1~ ( ) ( ) nX p x X P U U− +⇒ = =
1 2 1max( , , , , )n nY U U U U += L1
1
1
Pr( ) Pr( )n
n
i
Y x U x x+
+
=
< = < =∏
Trick
![Page 11: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/11.jpg)
Sampling a Circle12 1 1 2 2
2
00 0 0 0 0
2
rA r dr d r dr d
π ππθ θ θ π
⎛ ⎞= = = =⎜ ⎟
⎝ ⎠∫∫ ∫ ∫
( , ) ( ) ( )p r p r pθ θ=
2
( ) 2
( )
p r r
P r r
=
=
12 Uθ π=
rdθ
dr
1( )
21
( )2
p
P
θπ
θ θπ
=
=
1( , ) ( , )
rp r dr d r dr d p rθ θ θ θ
π π= ⇒ =
2r U=
![Page 12: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/12.jpg)
Sampling a Circle
1
2
2 U
r U
θ π=
=1
2
2 U
r U
θ π=
=
RIGHT Equi-ArealWRONG Equi-Areal
![Page 13: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/13.jpg)
Rejection Methods
Algorithm
Pick U1 and U2
Accept U1 if U2 < f(U1)
Wasteful?
1
0
( )
( )
y f x
I f x dx
dx dy<
=
=
∫
∫∫ ( )y f x=
Efficiency = Area / Area of rectangle
![Page 14: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/14.jpg)
Sampling a Circle: Rejection
May be used to pick random 2D directions
Circle techniques may also be applied to the sphere
do {
X=1-2*U1
Y=1-2*U2
}
while(X2 + Y2 > 1)
![Page 15: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/15.jpg)
Monte Carlo Integration
Definite integral
Expectation of f
Random variables
Estimator
1
0
( ) ( )I f f x dx≡∫1
0
[ ] ( ) ( )E f f x p x dx≡∫~ ( )iX p x ( )i iY f X=
1
1 N
N ii
F YN =
= ∑
![Page 16: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/16.jpg)
Unbiased Estimator
1
1 1
1
1 0
1
1 0
1
0
1[ ] [ ]
1 1[ ] [ ( )]
1( ) ( )
1( )
( )
N
N ii
N N
i ii i
N
i
N
i
E F E YN
E Y E f XN N
f x p x dxN
f x dxN
f x dx
=
= =
=
=
=
= =
=
=
=
∑
∑ ∑
∑∫
∑∫
∫
[ ] ( )NE F I f=
Assume uniform probability distribution for now
[ ] [ ]i ii i
E Y E Y=∑ ∑[ ] [ ]E aY aE Y=
Properties
![Page 17: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/17.jpg)
Over Arbitrary Domains
∫=b
a
dxxfI )( abxp U
b
a −==
1)(
11
)()( =−
==∫b
a
b
a abxpxP∫−=
b
a
dxxpxfabI )()()(
)()( fEabI −=
fabI )( −≈
)(1
)(1
i
N
i
XfN
abI ∑=
−≈ a b
ab −1
![Page 18: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/18.jpg)
Non-Uniform Distributions
∫=b
a
dxxfI )(
∫=b
a
dxxpxp
xfI )(
)(
)(
)(
)()(
xp
xfxg =
∫=b
a
dxxpxgI )()(
)(gEI =
∑=
≈N
i
iXgN
I1
)(1
![Page 19: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/19.jpg)
Direct Lighting – Directional Sampling
2
( ) ( , ) cosH
E x L x dω θ ω=∫
*( ( , ), ) cos 2i i i iY L x x ω ω θ π= −
*( , )x x ωRay intersectionA′
ω
*x
x
θ Sample uniformly byΩω
![Page 20: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/20.jpg)
Direct Lighting – Area Sampling
22
cos cos( ) ( , ) cos ( , ) ( , )o
AH
E x L x d L x V x x dAx x
θ θω θ ω ω′
′′ ′ ′ ′= =
′−∫ ∫
2
cos cos( , ) ( , ) i i
i o i i i
i
Y L x V x x Ax x
θ θω′
′ ′ ′=′−x
x xω′ ′= −Ray direction
Sample uniformly byA′x′
0( , )
1
visibleV x x
visible
¬⎧′ =⎨⎩
A′
ω′
x′
θθ′
![Page 21: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/21.jpg)
Examples
4 eye rays per pixel1 shadow ray per eye ray
Fixed Random
![Page 22: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/22.jpg)
Examples
4 eye rays per pixel16 shadow rays per eye ray
Uniform grid Stratified random
![Page 23: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/23.jpg)
Examples
4 eye rays per pixel64 shadow rays per eye ray
Uniform grid Stratified random
![Page 24: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/24.jpg)
Examples
4 eye rays per pixel100 shadow rays per eye ray
Uniform grid Stratified random
![Page 25: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/25.jpg)
Examples
4 eye rays per pixel16 shadow rays per eye ray
64 eye rays per pixel1 shadow ray per eye ray
![Page 26: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/26.jpg)
Variance
Definition
Properties
Variance decreases with sample size
2
2 2
2 2
[ ] [( [ ]) ]
[ 2 [ ] [ ] ]
[ ] [ ]
V Y E Y E Y
E Y YE Y E Y
E Y E Y
≡ −
= − +
= −
[ ] [ ]i ii i
V Y V Y=∑ ∑2[ ] [ ]V aY a V Y=
21 1
1 1 1[ ] [ ] [ ]
N N
i ii i
V Y V Y V YN N N= =
= =∑ ∑
![Page 27: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/27.jpg)
Direct Lighting – Directional Sampling
2
( ) ( , ) cosH
E x L x dω θ ω=∫
*( ( , ), ) cos 2i i i iY L x x ω ω θ π= −
*( ( , ), )i i iY L x x ω ω π= −
*( , )x x ωRay intersection
A′
ω
*x
x
θSample uniformly byΩω
Sample uniformly byΩ%ω
![Page 28: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/28.jpg)
Sampling Projected Solid Angle
Generate cosine weighted distribution
![Page 29: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/29.jpg)
Examples
Projected solid angle
4 eye rays per pixel100 shadow rays
Area
4 eye rays per pixel100 shadow rays
![Page 30: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/30.jpg)
Variance Reduction
Efficiency measure
Techniques Importance sampling Sampling patterns: stratified, …
1Efficiency
Variance Cost∝
•
![Page 31: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/31.jpg)
Sampling a Triangle
121 1 1
0 0 00
(1 ) 1(1 )
2 2
u uA dv du u du
− −= = − =− =∫∫ ∫
( , ) 2p u v =
0
0
1
u
v
u v
≥≥+ ≤
u
v
1u v+ =
( ,1 )u u−
![Page 32: Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.](https://reader035.fdocuments.in/reader035/viewer/2022070410/56649eb45503460f94bbb891/html5/thumbnails/32.jpg)
)(
),()|(
vp
vupvup ≡
Sampling a Triangle
Here u and v are not independent!
Conditional probability
( , ) 2p u v =
00 0 00 0
0 0
1( | ) ( | )
(1 ) (1 )o ov v v
P v u p v u dv dvu u
= = =− −∫ ∫
1( | )
(1 )p v u
u=
−
0 20 00
( ) 2(1 ) (1 )u
P u u du u= − = −∫
1
0
( ) 2 2(1 )u
p u dv u−
= = −∫0 11u U= −
0 1 2v U U=
∫≡ dvvupup ),()(