# Monte Carlo Integration II

## Full text

(1)

### Monte Carlo Integration II

Digital Image Synthesisg g y Yung-Yu Chuang

with slides by Pat Hanrahan and Torsten Moller

(2)

### variance = noise in the image

without variance reduction with variance reductionwith variance reduction

Same amount of computation for rendering this scene with glossy reflection

(3)

### Variance reduction

• Efficiency measure for an estimator

###  

• Although we call them variance reduction techniques, they are actually techniques to q , y y q increase efficiency

– Stratified samplingp g – Importance sampling

(4)

### Russian roulette

• Assume that we want to estimate the following direct lighting integral

direct lighting integral

i i

i d

i o r

o

o p f p L p d

L ( ,)

### 

( ,,) ( ,) | cos|

• The Monte Carlo estimator is

### 

N f ( p, , i )Ld ( p, i ) | cos i |

1    

Si t i th h d i tl if

### 

i i

i i

d i

o r

p

p L

p f

N 1 ( )

| cos

| ) ,

( )

, ,

( 1

• Since tracing the shadow ray is very costly, if we somewhat know that the contribution is

ll ld lik t ki t i small anyway, we would like to skip tracing.

• For example, we could skip tracing rays if | cosi | or is small enough.fr ( p,o,i )

(5)

### Russian roulette

• However, we can’t just ignore them since the estimate will be consistently under-estimated estimate will be consistently under-estimated otherwise.

• Russian roulette makes it possible to skip tracing

• Russian roulette makes it possible to skip tracing rays when the integrand’s value is low while still computing the correct value on average

computing the correct value on average.

(6)

### Russian roulette

• Select some termination probability q,



 

otherwise

' 1

c F q q

qc

F

### 

c otherwise

] ] [

) [ 1

( ]

'

[ E F qc qc E F

q F

E   

 

R i l tt ill t ll i i b t

] 1 [

) 1

( ]

[ qc E F

q q F

E   

 

 

• Russian roulette will actually increase variance, but improve efficiency if q is chosen so that samples that are likely to make a small contribution are skipped (if are likely to make a small contribution are skipped. (if same number of samples are taken, RR could be worse.

However, since RR could be faster, we could increase number of samples)

(7)

### Careful sample placement

• Carefully place samples to less likely to miss important features of the integrand

important features of the integrand

• Stratified sampling: the domain [0,1]s is split i t t t S S hi h di j i t d into strata S1..Sk which are disjoint and

completely cover the domain.

k

j i

S

Si j

k i s

i

S [0,1]

1

i

i v

S |

|

### 

vi 1



 

 0 otherwise ) if

( 1v i

i

S x x

p i

0 otherwise

(8)

k i i

s v

I N

V 1 2

ˆ ]

[

i

i i

s] N 1

[

k v

k v I

I

V 1 2 ( )2

ˆ ]

[

###  

i

i i i

i i

ns v v I

I N V

1 1

) (

]

[

Thus, the variance can only be reduced by using stratified sampling.

(9)

### Stratified sampling

without stratified sampling with stratified sampling

(10)

### Bias

• Another approach to reduce variance is to introduce bias into the computation

introduce bias into the computation.

E[F] f (x)dx

### 

• Example: estimate the mean of a set of random numbers Xi over [0..1].

unbiased estimator variance (N1

### 

N X -1) unbiased estimator variance (N )

bi d ti t i (N 2)

### 

i

Xi

N 1

biased estimator variance (N1 max( , ,..., ) -2)

2 1

2

1 X X N

X

(11)

### 

w x f x dx I ( ) ( )

### 

N

• Biased estimator

(but less variance)

###  

N

i N

i i i

b w X

X f

X I 1w

) (

) (

) ˆ (

(but less variance)

i1w(Xi )

N w X f X

### 

( ) ( )

• Unbiased estimator

h i h if PDF f h i

c

i i i

u Np

X f

X

Iˆ

### 

1w( ) ( )

where pc is the uniform PDF of choosing Xi X

f X w E I

E N

i i i

u] 1

[ ( ) ( )]

[ ˆ

1

dx x f x w dx

p x f x w Np f

N

i i i

c u

### 

1 ( ) ( ) ( ) ( )

)]

( ) (

[ ]

[ 1

dx x f x w dx

p x f x

Npc

i w c

( ) ( ) ( ) ( )

1

(12)

### Importance sampling

• The Monte Carlo estimator

N f (X )

1

### 

N

i i

i

N p X

X f

F N

1 ( )

) (

1

converges more quickly if the distribution p(x) is similar to f(x). The basic idea is to concentrate f( ) on where the integrand value is high to

compute an accurate estimate more efficiently.p y

• So long as the random variables are sampled from a distribution that is similar in shape to from a distribution that is similar in shape to the integrand, variance is reduced.

(13)

### Informal argument

• Since we can choose p(x) arbitrarily, let’s

choose it so that p(x) f(x) That is p(x)=cf(x) To choose it so that p(x)f(x). That is, p(x)=cf(x). To make p(x) a pdf, we have to choose c so that

1

### 

dx x

c f

) (

1

• Thus, for each sample Xi, we have

### 

f x dx X

f i

) 1 (

) (

Since c is a constant, the variance is zero!

### 

f x dx c

X

p i ( )

) (

• This is an ideal case. If we can evaluate c, we won’t use Monte Carlo. However, if we know p(x), p( ) has a similar shape to f(x), variance decreases.

(14)

### Importance sampling

• Bad distribution could hurt variance.

4

### 

0

8 xdx

I

method Sampling function

variance Samples needed for standard error of 0.008

importance (6-x)/16 56.8/N 887,500

importance 1/4 21.3/N 332,812

importance (x+2)/16 6 4/N 98 432

importance (x+2)/16 6.4/N 98,432

importance x/8 0 1

stratified 1/4 21.3/N3 70

(15)

### Importance sampling

• Fortunately, it is not too hard to find good

sampling distributions for importance sampling sampling distributions for importance sampling for many integration problems in graphics.

F l i th i t d i

• For example, in many cases, the integrand is the product of more than one function. It is

ft diffi lt t t df i il t th often difficult construct a pdf similar to the

product, but sampling along one multiplicand is ft h l f l

s2

o

i

i

i

i

i

(16)

i i

i d

i o r

o

o p f p L p d

L ( ,)

### 

( ,,) ( ,) | cos|

• If we sample based on either L or f, it often performs poorly.

performs poorly.

• Consider a near-mirror BRDF illuminated by an area light where L’s distribution is used to draw area light where L s distribution is used to draw samples. (It is better to sample by f.)

Consider a diffuse BRDF and a small light source

• Consider a diffuse BRDF and a small light source.

If we sample according to f, it will lead to a larger variance than sampling by L

larger variance than sampling by L.

• It does not work by averaging two together dd

(17)

### Multiple importance sampling

• To estimate , MIS draws nf samples according to p and n samples to p The Monte

### 

f (x)g(x)dx

according to pf and ng samples to pg, The Monte Carlo estimator given by MIS is

### 

g

f n

j g j

i g j j

g n

i f i

i f

i i

f p Y

Y w Y g Y f n

X p

X w

X g X f

n 1 1 ( )

) ( )

( ) 1 (

) (

) ( )

( ) 1 (

• Balance heuristic v.s. power heuristic

s

s p x

x n

w ( )

)

(

ns ps x

x w

)

) (

(

i i i

s s

s x n p x

w ( ) ( )

i

i i

s x n p x

w

) ) (

(

(18)

### Multiple importance sampling

• Assume a sample X is drawn from pf where pf(X) is small thus f(X) is small if p matches f If

is small, thus f(X) is small if pf matches f. If, unfortunately, g(X) is large, then standard

importance sampling gives a large value f (X )g(X ) importance sampling gives a large value

• However, with the balance heuristic, the t ib ti f X ill b

) (

) ( ) (

X p

g f

f

contribution of X will be

) ) (

( ) ) (

( )

( )

(X g X w X f X g X n p X

f f f f

)

( ) (

) ( )

( )

( )

(

n X g X f

X p

n X

p n X

p X

p

f

g g f

f f

f

) ( )

(

) ( ) (

X p

n X

p n

g f

g g f

f

f

(19)

(20)

(21)

o

o

e

o

o

i

i

i

i

i

### 

• Importance sampling: sample ωi according to BxDF f and L (especially for light sources)

• If don’t know anything about f and L, then use cosine-weighted sampling of hemisphere to find g p g p a sampled ωi

(22)

### Sampling reflection functions

Spectrum BxDF::Sample_f(const Vector &wo,

Vector *wi, float u1, float u2, float *pdf){

Vector wi, float u1, float u2, float pdf){

*wi = CosineSampleHemisphere(u1, u2);

if (wo.z < 0.) wi->z *= -1.f;( ) ;

*pdf = Pdf(wo, *wi);

return f(wo, *wi);

}

For those who modified Sample_f, Pdf must be changed di l

accordingly

float BxDF::Pdf(Vector &wo, Vector &wi) {

t S H i h ( i) ?

return SameHemisphere(wo, wi) ?

fabsf(wi.z) * INV_PI : 0.f;

} Pdf() i f l f lti l i t li g } Pdf() is useful for multiple importance sampling.

(23)

### Sampling microfacet model

geometric attenuation G

microfacet distribution D Fresnel reflection F

Too complicated to sample according to f, sample D instead. It is often effective since D accounts for most variation for f.

(24)

### Sampling microfacet model

Spectrum Microfacet::Sample_f(const Vector &wo, Vector *wi, float u1, float u2, float *pdf) { distribution->Sample_f(wo, wi, u1, u2, pdf);

if (!SameHemisphere(wo, *wi)) return Spectrum(0 f);

return Spectrum(0.f);

return f(wo, *wi);

}

float Microfacet::Pdf(const Vector &wo, const Vector &wi) const {

if (!SameHemisphere(wo, wi)) return 0.f;

if (!SameHemisphere(wo, wi)) return 0.f;

return distribution->Pdf(wo, wi);

}

(25)

### Sampling Blinn microfacet model

• Blinn distribution: e

h h

### (cos    

• Generate ωh according to the above function

1 1

h

e

ωh

C t t

2

h

### 

ωo ωh ω

i

• Convert ωh to ωi

h h

o o

i

i

o

o

h

h

(26)

### Sampling Blinn microfacet model

• Convert half-angle PDF to incoming-angle PDF, that is change from a density in term of ω to that is, change from a density in term of ωh to one in terms of ωi

transformation ) ( )

(

1

x d p

y dy

py x

method

y dx

(27)

### Sampling anisotropic microfacet model

• Anisotropic model (after Ashikhmin and Shirley) for the first quadrant of the unit hemisphere

for the first quadrant of the unit hemisphere

cos2 sin2

h

h

ex ey

h

x

y

h

(28)

### 

r o i i i

o

hd f d

( ) ( , ) | cos |

Spectrum BxDF::rho(const Vector &w, int nSamples, const float *samples) const {

Spectrum r = 0.;

### 

N

i i

i i

o r

p f

N 1 ( )

| cos

| ) ,

( 1

for (int i = 0; i < nSamples; ++i) { Vector wi;

float pdf = 0 f;

i

float pdf = 0.f;

Spectrum f = Sample_f(w, &wi, samples[2*i], samples[2*i+1], &pdf);

if (pdf > 0 ) r += f * AbsCosTheta(wi) / pdf;

if (pdf > 0.) r += f * AbsCosTheta(wi) / pdf;

}

return r / float(nSamples);

} }

(29)

### Estimate reflectance

Spectrum BxDF::rho(int nSamples, float *samples1, float *samples2) const

{

Spectrum r = 0.;

 

### 

r o i i o i o

hh f d d

1 ( , ) | cos cos |

for (int i = 0; i < nSamples; ++i) { Vector wo, wi;

wo = UniformSampleHemisphere(samples1[2*i], p p ( p [ ], samples1[2*i+1]);

float pdf_o = INV_TWOPI, pdf_i = 0.f;

Spectrum f = Sample f(wo &wi samples2[2*i]

Spectrum f = Sample_f(wo, &wi, samples2[2 i], samples2[2*i+1], &pdf_i);

if (pdf_i > 0.)

r += f * AbsCosTheta(wi) * AbsCosTheta(wo) r += f * AbsCosTheta(wi) * AbsCosTheta(wo)

/ (pdf_o * pdf_i);

}

/( * S l ) 1 1

### 

N fr(i',i'') | cosi' cosi'' |

return r/(M_PI*nSamples);

}

i i i

i i

i i r

p p

f

N 1 ( ') ( '')

|

| ) ,

(

(30)

### Sampling BSDF (mixture of BxDFs)

• We would like to sample from the density that is the sum of individual densities

is the sum of individual densities

• Difficult. Instead, uniformly sample one , y p

component and use it for importance sampling.

However, f and Pdf returns the sum.,

• Three uniform random numbers are used, the first one determines which BxDF to be sampled first one determines which BxDF to be sampled (uniformly sampled) and then sample that BxDF using the other two random numbers

using the other two random numbers

(31)

### Sampling light sources

• Direct illumination from light sources makes an

important contribution, so it is crucial to be able to important contribution, so it is crucial to be able to generates

– Sp: samples directions from a point p to the lightSp: samples directions from a point p to the light – Sr: random rays from the light source (for

bidirectional light transport algorithms such as g p g bidirectional path tracing and photon mapping)

small sphere light diff BRDF

small sphere light diffuse BRDF

(32)

### Interface

Spectrum Sample_L(Point &p, float pEpsilon, LightSample &ls float time Vector *wi LightSample &ls, float time, Vector *wi, float *pdf, VisibilityTester *vis) = 0;

float Pdf(const Point &p, const Vector &wi) const = 0;

const = 0;

float uPos[2], uComponent;

Spectrum Sample L(Scene *scene LightSample Spectrum Sample_L(Scene *scene, LightSample

&ls, float u1, float u2, float time, Ray *ray, Normal *Ns, float *pdf) = 0;

Ray ray, Normal Ns, float pdf) 0;

(33)

### Point lights

• Sp: delta distribution, treat similar to specular BxDF

BxDF

• Sr: sampling of a uniform sphere

(34)

### Point lights

Spectrum Sample_L(const Point &p, float u1, float u2, Vector *wi, float *pdf, VisibilityTester *vis)

{

*pdf = 1.f;

return Sample_L(p, wi, visibility);

delta function }

float Pdf(Point &, Vector &) { return 0.; }

for almost any direction, pdf is 0

{ ; }

Spectrum Sample_L(Scene *scene, LightSample &ls, float u1, float u2, float time, Ray *ray,

Normal *Ns float *pdf) const { Normal Ns, float pdf) const {

*ray = Ray(lightPos,

UniformSampleSphere(ls.uPos[0], ls.uPos[1]), 0 f INFINITY time);

0.f, INFINITY, time);

*Ns = (Normal)ray->d;

*pdf = UniformSpherePdf();

i

return Intensity;

}

(35)

### Spotlights

• Sp: the same as a point light

S li f (i h f ll ff)

• Sr: sampling of a cone (ignore the falloff)

cone over

)

( c

p() p(,)  csin over[0,θ ][0,2]

p p(,) csin over [0,θmax] [0,2]

###  

2 ' sin 2 (1 cosmax)

1 c d d c 2 (1 cos )

) sin ,

(

p

0 0 2(1cosmax)

2

1

sin )

1 ( 2 ) sin

(

### 

d

p

0 2(1 cosmax) 1 cosmax

' sin 1 cos '

)

(

### 

d

P 1 cos (1 ) cos

01 cos max 1 cos max

)

(

d P

| ) ( , ) 1

( p

p P( |')

' 1 d '

max 1

1) cos

1 (

cos 2

| ) ( ) 2

(

p p

0

2 2

) 2

|' (

d

P 22

(36)

### Spotlights

Spectrum Sample_L(Scene *scene, LightSample &ls, float u1, float u2, float time, Ray *ray,

Normal *Ns, float *pdf) const {

Vector v = UniformSampleCone(ls.uPos[0], ls.uPos[1], cosTotalWidth);

*ray = Ray(lightPos, LightToWorld(v), 0.f, INFINITY, time);, );

*Ns = (Normal)ray->d;

*pdf = UniformConePdf(cosTotalWidth);

return Intensity * Falloff(ray->d);

return Intensity Falloff(ray >d);

}

(37)

Projection lights and goniophotometric lights

• Ignore spatial variance; sampling routines are essentially the same as spot lights and point essentially the same as spot lights and point lights

(38)

### Directional lights

• Sp: no need to sample

S i l di k f h di

• Sr: create a virtual disk of the same radius as scene’s bounding sphere and then sample the di k if l

disk uniformly.

(39)

### Directional lights

Spectrum Sample_L(Scene *scene, LightSample &ls, float u1, float u2, float time, Ray *ray,

Normal *Ns, float *pdf) const { Point worldCenter;

scene->WorldBound().BoundingSphere(&worldCenter,

Vector v1, v2;, ;

CoordinateSystem(lightDir, &v1, &v2);

float d1, d2;

ConcentricSampleDisk(ls uPos[0] ls uPos[1] &d1 &d2);

ConcentricSampleDisk(ls.uPos[0],ls.uPos[1],&d1,&d2);

Point Pdisk = worldCenter + worldRadius

* (d1 * v1 + d2 * v2);

*ray = Ray(Pdisk + worldRadius * lightDir

*ray = Ray(Pdisk + worldRadius * lightDir, -lightDir, 0.f, INFINITY, time);

*Ns = (Normal)ray->d;

* df 1 f / ( * ld di * ld di )

return L;

}

(40)

### Area lights

• Defined by shapes

Add h li f ti f h

• Add shape sampling functions for Shape

• Sp: uses a density with respect to solid angle from the point p

Point Shape::Sample(Point &P, float u1, float u2, Normal *Ns)

• Sr: generates points on the shape according to a density with respect to surface area

Point Shape::Sample(float u1, float u2, Normal *Ns)

• virtual float Shape::Pdf(Point &Pshape) { return 1.f / Area(); }

(41)

### Area light sampling method

• Most of work is done by Shape.

Spectrum DiffuseAreaLight::Sample L(Point &p float Spectrum DiffuseAreaLight::Sample_L(Point &p, float

pEpsilon, LightSample &ls, float time, Vector *wi, float *pdf, VisibilityTester *visibility) const {p , y y) { Normal ns;

Point ps = shapeSet->Sample(p, ls, &ns);

*wi = Normalize(ps - p);

*pdf = shapeSet->Pdf(p, *wi);

visibility >SetSegment(p pEpsilon ps 1e 3f time);

visibility->SetSegment(p,pEpsilon,ps,1e-3f,time);

Spectrum Ls = L(ps, ns, -*wi);

return Ls;

}

float DiffuseAreaLight:: Pdf(Point &p, Vector &wi) { return shapeSet->Pdf(p, wi);

}

(42)

### Area light sampling method

Spectrum DiffuseAreaLight::Sample_L(Scene *scene, LightSample &ls, float u1, float u2, float time,g p , , , , Ray *ray, Normal *Ns, float *pdf) const

{

Point org = shapeSet->Sample(ls, Ns);

Vector dir = UniformSampleSphere(u1, u2);

if (Dot(dir *Ns) < 0 ) dir *= 1 f;

if (Dot(dir, *Ns) < 0.) dir *= -1.f;

*ray = Ray(org, dir, 1e-3f, INFINITY, time);

*pdf = shapeSet->Pdf(org) * INV TWOPI;p p ( g) _ Spectrum Ls = L(org, *Ns, dir);

return Ls;

}

(43)

### Sampling spheres

• Only consider full spheres

Point Sphere::Sample(float u1, float u2,

N l * ) t

Normal *ns) const {

(0 0 0)

Point p = Point(0,0,0) + radius

* UniformSampleSphere(u1, u2);

*ns = Normalize(

(*ObjectToWorld)(Normal(p.x, p.y, p.z)));

if (ReverseOrientation) *ns *= -1.f;

return (*ObjectToWorld)(p);

}

(44)

r c

r

θ 2

 r

θ cos 1

p c

r

p

(45)

### Sampling spheres

Point Sphere::Sample(Point &p, float u1, float u2, Normal *ns) const

{

Point Pcenter

= (*ObjectToWorld)(Point(0 0 0));

= (*ObjectToWorld)(Point(0,0,0));

Vector wc = Normalize(Pcenter - p);

Vector wcX, wcY;

CoordinateSystem(wc, &wcX, &wcY);

if (DistanceSquared(p, Pcenter) if (DistanceSquared(p, Pcenter)

(46)

### Sampling spheres

/ DistanceSquared(p, Pcenter);

float cosThetaMax = sqrtf(

max(0.f, 1.f - sinThetaMax2));

DifferentialGeometry dgSphere;

DifferentialGeometry dgSphere;

float thit, rayEpsilon;

Point ps;

Ray r(p, UniformSampleCone(u1, u2,

cosThetaMax, wcX, wcY, wc), 1e-3f);

if (!Intersect(r &thit &rayEpsilon &dgSphere)) if (!Intersect(r,&thit,&rayEpsilon,&dgSphere))

thit = Dot(Pcenter - p, Normalize(r.d));

ps = r(thit); It’s unexpected.

*ns = Normal(Normalize(ps - Pcenter));

if (ReverseOrientation) *ns *= -1.f;

return ps;

return ps;

}

(47)

### Infinite area lights

uniform sampling 4 image samples 4 image samples X 8 light sample

importance sampling 4 image samples

4 image samples X 8 light sample

(48)

### Infinite area lights

Spectrum Sample_L(Point &p, float pEpsilon, LightSample &ls, float time, Vector *wi, g p , , , float *pdf, VisibilityTester *visibility)

{ use importance sampling to find (u, v)

float uv[2], mapPdf;

distribution->SampleContinuous(ls.uPos[0], ls uPos[1] uv &mapPdf);

precomputed

ls.uPos[1], uv, &mapPdf);

if (mapPdf == 0.f) return 0.f;distribution2D

convert (u v) to direction float theta=uv[1]*M_PI, phi=uv[0]*2.f* M_PI;

float costheta = cosf(theta),

convert (u,v) to direction

sintheta = sinf(theta);

float sinphi = sinf(phi), cosphi = cosf(phi);

cosphi = cosf(phi);

(49)

### Infinite area lights

*wi = LightToWorld(Vector(sintheta * cosphi,

sintheta * sinphi, costheta));

sintheta sinphi, costheta));

*pdf = mapPdf / (2.f * M_PI * M_PI * sintheta);

if (sintheta == 0.f) *pdf = 0.f;

i ibilit >S tR ( E il * i ti ) visibility->SetRay(p, pEpsilon, *wi, time);

Spectrum Ls = Spectrum(radianceMap->Lookup(uv[0], uv[1]), SPECTRUM ILLUMINANT);[ ]), _ );

return Ls;

} gg((uu,vv))  ((

vv,22

uu)) J  2

2

) , ) (

(

p u v

p  (

) p(

,

) p(u,v)

p  

2

gJ

2 2

) ,

(

p

sin 2

) sin

( 2

p  

(50)

### Infinite area lights

Float Pdf(const Point &, const Vector &w) {

{

Vector wi = WorldToLight(w);

float theta = SphericalTheta(wi), phi = SphericalPhi(wi);

float sintheta = sinf(theta);

if (sintheta == 0 f) return 0 f;

if (sintheta == 0.f) return 0.f;

float p =

distribution->Pdf(phi*INV TWOPI, theta*INV PI) (p _ , _ ) / (2.f * M_PI * M_PI * sintheta);

return p;

}

(51)

### Infinite area lights

Spectrum Sample_L(Scene *scene, LightSample &ls, float u1, float u2, float time, Ray *ray, , , , y y,

Normal *Ns, float *pdf) const

{ sample a direction first

float uv[2], mapPdf;

distribution->SampleContinuous(ls.uPos[0], ls uPos[1] uv &mapPdf);

ls.uPos[1], uv, &mapPdf);

if (mapPdf == 0.f) return Spectrum(0.f);

float theta = uv[1]*M_PI, phi = uv[0]*2.f*M_PI;

float costheta = cosf(theta), sintheta = sinf(theta);

float sinphi = sinf(phi), cosphi = cosf(phi);

cosphi = cosf(phi);

(52)

### Infinite area lights

Vector d = -LightToWorld(Vector(sintheta * cosphi, sintheta * sinphi, costheta));p , ));

*Ns = (Normal)d;

For the origin, do the similar as distant lights Point worldCenter; float worldRadius;

scene->WorldBound().BoundingSphere(&worldCenter,

Vector v1, v2;

CoordinateSystem(-d, &v1, &v2);y ( , , ) float d1, d2;

ConcentricSampleDisk(u1, u2, &d1, &d2);

Point Pdisk = worldCenter + worldRadius *

(d1 * v1 + d2 * v2);

*ray = Ray(Pdisk+worldRadius * -d d 0 );

*ray = Ray(Pdisk+worldRadius * -d, d, 0., …);

(53)

### Infinite area lights

float directionPdf = mapPdf

/ (2.f * M PI * M PI * sintheta);

/ ( _ _ );

float areaPdf = 1.f

*pdf = directionPdf * areaPdf;

if (sintheta == 0.f) *pdf = 0.f;

SPECTRUM_ILLUMINANT);

return Ls;

}

(54)

### Sampling lights

• Structured Importance Sampling of Environment Maps SIGGRAPH 2003

Maps, SIGGRAPH 2003

Infinite area light; easy to evaluate

(55)

### Importance metric

illumination of a region

b

a

###  ( , )

• Illumination-based importance sampling (a=1

solid angle of a region

• Illumination based importance sampling (a 1, b=0)

• Area based stratified sampling (a=0 b=1)

• Area-based stratified sampling (a=0, b=1)

(56)

### Variance in visibility

• After testing over 10 visibility maps, they found that variance in visibility is proportional to the that variance in visibility is proportional to the square root of solid angle (if it is small)

2

### V ,    3 

parameter typically

• Thus they empirically define the importance as

### 3 T

visibility map parameter typically between 0.02 and 0.6

• Thus, they empirically define the importance as

14

0

4

###  LL

set as 0.01 set as 0.01

(57)

i

### 

standard deviation of d=6

the illumination mapp

)

(

L

4 / 1 0 0

4  ( ,

)  

L L

i

t t

) ,

(

j iC i iC i

j

j L

j

td td1

Nd

1

Nd4

 j

j N

N

(58)

(59)

(60)

### Sampling BRDF

http://www.cs.virginia.edu/~jdl/papers/brdfsamp/lawrence_sig04.ppt

(61)

### Sampling product

• Wavelet Importance Sampling: Efficiently Evaluating Products of Complex Functions Evaluating Products of Complex Functions, SIGGRAPH 2005.

(62)

(63)

(64)

(65)

Updating...

## References

Related subjects :