Lecture notes
Download
Report
Transcript Lecture notes
Last Time
• Raytracing and PBRT Structure
• Radiometric quantities
01/24/05
© 2005 University of Wisconsin
Today
• Radiometric Integrals
• Monte Carlo integration
• Section 5.3 and Chapter 14 of PBR
01/24/05
© 2005 University of Wisconsin
Irradiance from Radiance (PBR Sect. 5.3)
• Integrate radiance over directions in the upper hemisphere:
E p
L p, cos d
i
H 2 (n )
– cos term deals with projected solid angle. is angle between and
n (the normal)
• We are converting “per unit solid angle per unit projected
area” into “per unit solid angle per unit area” and then
integrating over solid angle to get “per unit area”
• Today: solving integrals like this
01/24/05
© 2005 University of Wisconsin
Integration Methods
• Analytic: not tractable for most functions you want to
integrate
• (Numerical) Quadrature:
– Break the domain of integration into pieces, evaluate the function
once in each piece, and sum up value for all pieces, weighted by the
“size” of each little area
– A very poor strategy for high-dimensional integrals – we will have
lots of these, even infinite dimensional
• Monte Carlo integration:
– Evaluate the function at random points in the domain, and sum up
the answers
– Error independent of dimensionality of problem
01/24/05
© 2005 University of Wisconsin
Probability Theory Overview
• The aim is to give you enough to survive, for more see a
probability (not statistics) textbook
• A random variable X is a value chosen by some random
process
– Rolling dice, nuclear decay, pseudo random number generator, …
• We are interested in the properties of random variables
01/24/05
© 2005 University of Wisconsin
Discrete Random Variables
•
•
•
•
Consider rolling a die
Possible values for random variable are Xi={1,2,3,4,5,6}
Probability of seeing some value is pi=1/6
Sampling x according to pi means choosing a value for x
such that the probability that x=Xi is pi
• In rendering, the most common discrete case is choosing a
light, Li{L1,…,Ln}, according to the power output:
i
pi
j j
01/24/05
© 2005 University of Wisconsin
Discrete Sampling (1)
• Always assume we can sample a canonical uniform random
variable [0,1)
– In PBRT, function: genrand_real1()
– Always get same sequence, which can be annoying
• We want to use this to choose a light according to pi
i 1
• Choose light Li if
p
j 1
01/24/05
i
j
pj
j 1
© 2005 University of Wisconsin
Discrete Sampling (2)
• Define Pi
i
p
j 1
j
– The cumulative distribution function, the probability that a variable
chosen according to the distribution pi will be less than Li
• To sample according to pi, sample then choose Li such that
Pi 1 Pi
– Build an array of Pi values (sorted), and then search it to find the index
such that above equation is true (binary search for large arrays)
01/24/05
© 2005 University of Wisconsin
Continuous Random Variables
• A random variable, X
– Takes values from some domain,
• Has an associated probability density function (pdf), p(x)
P( x ) p( y)dy
A
• Methods for sampling continuous random variables according
to various distributions on various domains are discussed in
PBR Sect 14.3-14.5
– Again, useful to know what is available and how to use it, but not
strictly necessary to understand how they work
01/24/05
© 2005 University of Wisconsin
Expected Value
• The expected value of a random variable, x, is defined as:
E[ x ] xp( x )dx
• The expected value of a function, f(x), is defined as:
E[ f ( x )] f ( x ) p( x )dx
• The sample mean, for samples xi is defined as:
01/24/05
© 2005 University of Wisconsin
1 n
x i 1 xi
n
1 n
g x i 1 g xi
n
Variance and Standard Deviation
• The variance of a random variable is defined as:
V [ x] E[( x E[ x]) 2 ]
V [ x] E[ x 2 ] E[ x]2
• The standard deviation of a random variable is defined as
the square root of its variance:
[ x] v[ x]
• The sample variance is:
1 n
i 1 xi x 2
n
01/24/05
© 2005 University of Wisconsin
Sampling
• A process samples according to the distribution p(x) if it randomly
chooses a value for x such that:
A, the probabilit y that x p( y)dy
A
• Weak Law of Large Numbers: If xi are independent samples from p(x),
then in the limit of infinite samples, the sample mean is equal to the
expected value:
1 n
Pr E[ x] lim i 1 xi 1
n n
1 n
Pr xp( x)dx lim i 1 xi 1
n n
x
01/24/05
© 2005 University of Wisconsin
Monte Carlo Integration
f ( y ) dy
• Say we wish to integrate
y
• Choose some pdf, p(x)
• If we sample xi, i{1,…,N}, according to p(x), then:
1 N f ( xi )
E
y f ( y)dy
N i 1 p( xi )
01/24/05
© 2005 University of Wisconsin
Simple Example
5
2
• Compute
x dx
1
• Sample xi uniform on interval [1,5), so p(x)=1/4
– Sample canonical i then xi=4i + 1
• Monte Carlo Estimate is
1 N xi2
4
N i 1 1 4 N
01/24/05
N
2
x
i
i 1
© 2005 University of Wisconsin
Output
Estimate
01/24/05
© 2005 University of Wisconsin
10
00
90
0
80
0
70
0
60
0
50
0
40
0
30
0
20
0
10
0
43
42
41
40
39
38
37
36
Standard Deviation of the Estimate
• Expected error in the estimate after N samples is measured by the
standard deviation of the estimate:
1 N f ( xi )
1 f
N p
N i 1 p( xi )
• Note that error goes down with 1 N
• Often, p(x) is the uniform distribution over the domain
• If p(x) is something else, the technique is called importance sampling
and p(x) is the importance function
• p must be >0 whenever f>0, and should be as close as possible to f
• Same principle for high dimensional integrals
01/24/05
© 2005 University of Wisconsin
Radiometric Integrals (PBR 5.3)
• Physically-Based rendering is all about solving integral
equations involving radiometric terms
• The domains of integration are areas, or regions of solid
angle, or even more abstract spaces
– Choosing the right domain is one consideration
• The challenge is finding a way to reduce variance, which
manifests itself as noise in images
– More on this later, after we have some more background
01/24/05
© 2005 University of Wisconsin
Computing Irradiance
E p
L p, cos d
i
H 2 (n )
• This integral is expressed in terms of solid angle within the
upper hemisphere
• To solve it, we need to sample directions
• We can’t represent with just one number
– It’s a multi-dimensional integral
• How do we parameterize directions?
01/24/05
© 2005 University of Wisconsin
In Spherical Coordinates
• Note that =0 is normal vector
direction
• We need a basis to define
– The tangent vectors
• How do we convert an angle
expressed in terms of solid
angle, to one in terms of
spherical coordinates?
– Convert domain to range of ,
– Convert d to dd
01/24/05
© 2005 University of Wisconsin
Solid angle to Spherical
• d is projected area
– Recall the definition of solid
angle
• What area goes with dd?
01/24/05
© 2005 University of Wisconsin
Irradiance Integral in Spherical Coords
E p
2 / 2
L p, , cos sin dd
i
0 0
• In general, the incoming radiance varies over the scene
– It depends on what is “seen” in each direction
• If incoming radiance is constant, then Ep Li
• Conversion functions for unit vectors =(x,y,z) to spherical
coordinates are available in PBRT
01/24/05
© 2005 University of Wisconsin
Solid Angle to Area
• Solid angle is defined in
terms of area projected
onto the unit sphere
dA cos
d
r2
01/24/05
© 2005 University of Wisconsin
Irradiance Arriving From Surface
• We want to integrate the
irradiance due to an area
light source
• Note there are two now
cos i cos o
E p Ls, t
dA
2
r
A
• Convert integral over area
into integral over (s,t)
(parameters for surface)
01/24/05
© 2005 University of Wisconsin
Next Time
• Cameras and Film Plane Sampling
01/24/05
© 2005 University of Wisconsin