24
01/24/05 © 2005 University of Wisc onsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

Embed Size (px)

Citation preview

Page 1: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Last Time

• Raytracing and PBRT Structure

• Radiometric quantities

Page 2: 01/24/05© 2005 University of Wisconsin 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

Page 3: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Irradiance from Radiance (PBR Sect. 5.3)

• Integrate radiance over directions in the upper hemisphere:

– 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

)(

i2

cos,n

ppH

dLE

Page 4: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

Page 5: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

Page 6: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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:

j j

iip

Page 7: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

• Choose light Li if

i

jj

i

jj pp

1

1

1

Page 8: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Discrete Sampling (2)

• Define

– 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

– 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)

i

jji pP

1

ii PP 1

Page 9: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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)

• 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

A

dyypxP )()(

Page 10: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Expected Value

• The expected value of a random variable, x, is defined as:

• The expected value of a function, f(x), is defined as:

• The sample mean, for samples xi is defined as:

dxxxpxE )(][

dxxpxfxfE )()()]([

n

i i

n

i i

xgn

xg

xn

x

1

1

1

1

Page 11: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Variance and Standard Deviation

• The variance of a random variable is defined as:

• The standard deviation of a random variable is defined as the square root of its variance:

• The sample variance is:

22

2

][][][

]])[[(][

xExExV

xExExV

][][ xvx

n

i i xxn 1

21

Page 12: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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:

• 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:

A

dyypx )(y that probabilit the,A

11

lim)(Pr

11

lim][Pr

1

1

n

i inx

n

i in

xn

dxxxp

xn

xE

Page 13: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Monte Carlo Integration

• Say we wish to integrate

• Choose some pdf, p(x)

• If we sample xi, i{1,…,N}, according to p(x), then:

ydyyf )(

y

N

i i

i dyyfxp

xf

NE )(

)(

)(1

1

Page 14: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Simple Example

• Compute

• Sample xi uniform on interval [1,5), so p(x)=1/4

– Sample canonical i then xi=4i + 1

• Monte Carlo Estimate is

5

1

2dxx

N

ii

N

i

i xN

x

N 1

2

1

2 4

41

1

Page 15: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Output

Estimate

36

37

38

39

40

41

42

43

Page 16: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Standard Deviation of the Estimate

• Expected error in the estimate after N samples is measured by the standard deviation of the estimate:

• Note that error goes down with

• 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

p

f

Nxp

xf

N

N

i i

i 1

)(

)(1

1

N1

Page 17: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

Page 18: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Computing Irradiance

• 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?

)(

i2

cos,n

ppH

dLE

Page 19: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

Page 20: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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?

Page 21: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Irradiance Integral in Spherical Coords

• In general, the incoming radiance varies over the scene– It depends on what is “seen” in each direction

• If incoming radiance is constant, then

• Conversion functions for unit vectors =(x,y,z) to spherical coordinates are available in PBRT

2

0

2/

0

i sincos,, ddLE pp

iLE p

Page 22: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Solid Angle to Area

• Solid angle is defined in terms of area projected onto the unit sphere

2

cos

r

dAd

Page 23: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

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

• Convert integral over area into integral over (s,t) (parameters for surface)

A

oi dAr

tsLE2

coscos,

p

Page 24: 01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities

01/24/05 © 2005 University of Wisconsin

Next Time

• Cameras and Film Plane Sampling