monte carlo techniques for rendering -...

42
Monte Carlo Techniques for Rendering CS 517 Fall 2002 Computer Science Cornell University © Kavita Bala, Computer Science, Cornell University Announcements No Lecture on Thursday Instead, attend Steven Gortler, Harvard Upson Hall B17, 4:15-5:15 (refreshments earlier) Geometry Images, reconstruction of 3D Geometry Interesting talk by Jim Gray 2:30-3:30, Wednesday, 255 Olin Hall Can Databases Help Science? Therefore, Office hours this week by appointment

Upload: vuongthu

Post on 10-Mar-2018

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

1

Monte Carlo Techniques for Rendering

CS 517 Fall 2002Computer ScienceCornell University

© Kavita Bala, Computer Science, Cornell University

Announcements• No Lecture on Thursday• Instead, attend Steven Gortler, Harvard

– Upson Hall B17, 4:15-5:15 (refreshments earlier)– Geometry Images, reconstruction of 3D Geometry

• Interesting talk by Jim Gray– 2:30-3:30, Wednesday, 255 Olin Hall– Can Databases Help Science?

• Therefore, Office hours this week– by appointment

Page 2: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

2

© Kavita Bala, Computer Science, Cornell University

MC Advantages• Convergence rate of O( )

• Simple– Sampling– Point evaluation– Can use black boxes

• General– Works for high dimensions– Deals with discontinuities, crazy functions,…

N1

© Kavita Bala, Computer Science, Cornell University

Octree Properties• Front to back traversal• Problem: Same object in multiple cells

– Could repeatedly intersectUse mailboxes

Page 3: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

3

© Kavita Bala, Computer Science, Cornell University

Intersection Acceleration• Intersect ray with root: p = root.intersect(ray)

– If no intersection, done• Find p in tree (node j = root.find(p))• Test ray against elements in node j

– If intersection found, done– Else find exit point (q) from node j, p = q, goto 2

© Kavita Bala, Computer Science, Cornell University

Rendering Equation

∫Ω

Ψ⋅Ψ⋅Ψ←⋅Θ↔Ψ+Θ→=Θ→x

dnxLfxLxL xre ω),cos()()()()(

∫Ω

⋅⋅+=x

re fL cos

function to integrate over allincoming directions over thehemisphere around x

Value we want

Page 4: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

4

© Kavita Bala, Computer Science, Cornell University

How to compute?

L(x→Θ) = ?

Check for Le(x→Θ)

Now add Lr(x→Θ) = L=?

∫Ω

Ψ⋅Ψ⋅Ψ←⋅Θ↔Ψx

dnxLf xr ω),cos()()(

© Kavita Bala, Computer Science, Cornell University

How to compute?• Monte Carlo!

• Generate random directions on hemisphere Ωx, using pdf p(Ψ)

∫Ω

Ψ⋅Ψ⋅Ψ←⋅Θ↔Ψ=Θ→x

dnxLfxL xr ω),cos()()()(

∑= Ψ

Ψ⋅Ψ←⋅Θ↔Ψ=Θ→

N

i i

xiiir

pnxLf

NxL

1 )(),cos()()(1)(

Page 5: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

5

© Kavita Bala, Computer Science, Cornell University

How to compute?

• evaluate L(x←Ψi)?

• Radiance is invariant along straight paths

• vp(x, Ψi) = first visible point

• L(x←Ψi) = L(vp(x, Ψi) → Ψi)

© Kavita Bala, Computer Science, Cornell University

PPyf )/(

Russian Roulette

Integral

Estimator

Variance

0 1

)(xf

P

∫∫∫ ===P

dyPPyfPdx

PxfdxxfI

0

1

0

1

0

)/()()(

>

≤=.0

,)(

Px

PxPxf

Ii

ii

roulette if

if

σσ >roulette

Page 6: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

6

© Kavita Bala, Computer Science, Cornell University

Russian Roulette

• Pick some ‘absorption probability’ α– probability 1-α that ray will bounce– estimated radiance becomes L/ (1-α)

• E.g. α = 0.9– only 1 chance in 10 that ray is reflected– estimated radiance of that ray is multiplied by 10– instead of shooting 10 rays, we shoot only 1, but

count the contribution of this one 10 times

© Kavita Bala, Computer Science, Cornell University

Stochastic Ray Tracing

• Parameters?– # starting rays per pixel– # random rays for each surface point

(branching factor)

• Branching factor = 1: path tracing

Page 7: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

7

© Kavita Bala, Computer Science, Cornell University

Algorithm so far ...• Shoot # viewing rays through each pixel

• Shoot # indirect rays, sampled over hemisphere

• Terminate recursion using Russian Roulette

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=L ?=L

Page 8: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

8

© Kavita Bala, Computer Science, Cornell University

Algorithm

?0

==

r

e

LL

?0

==

r

e

LL

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=inL ?=inL

Page 9: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

9

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=inL ?=inL

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=L ?=L

Page 10: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

10

© Kavita Bala, Computer Science, Cornell University

Algorithm

?0

==

r

e

LL

?0

==

r

e

LL

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=inL ?=inL

Page 11: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

11

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=L ?=L

© Kavita Bala, Computer Science, Cornell University

Algorithm

?234.1

==

r

e

LL

?234.1

==

r

e

LL

Page 12: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

12

© Kavita Bala, Computer Science, Cornell University

Algorithm

© Kavita Bala, Computer Science, Cornell University

Path Tracing

Page 13: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

13

© Kavita Bala, Computer Science, Cornell University

Performance/Error

• Want better quality with smaller number of samples – Fewer samples/better performance

• Well-distributed samples– Stratified sampling

• Faster convergence– Importance sampling: next-event estimation

© Kavita Bala, Computer Science, Cornell University

0 1

)(xf

Stratified Sampling

• Samples could be arbitrarily close

• Split Integral in subparts

• Estimator

• Variance:

∑=

=N

i i

istrat xp

xfN

I1 )(

)(1

secσσ ≤strat

∫∫ ++=NXX

dxxfdxxfI )()(1

K

Page 14: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

14

© Kavita Bala, Computer Science, Cornell University

Numerical example

© Kavita Bala, Computer Science, Cornell University

Stratified Sampling

9 shadow raysnot stratified

9 shadow raysstratified

Page 15: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

15

© Kavita Bala, Computer Science, Cornell University

Stratified Sampling

36 shadow raysnot stratified

36 shadow raysstratified

© Kavita Bala, Computer Science, Cornell University

Stratified Sampling

100 shadow raysnot stratified

100 shadow raysstratified

Page 16: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

16

© Kavita Bala, Computer Science, Cornell University

•• • •

• • ••

• • • •

• • • •

→ N2 samples

2 Dimensions

• Problem for higher dimensions

• Sample points can still be arbitrarily close to each other

© Kavita Bala, Computer Science, Cornell University

Higher Dimensions• Stratified grid sampling:

→ Nd samples

• N-rooks sampling:

→ N samples

•• • •

• • ••

• • • •

• • • •

••

Page 17: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

17

© Kavita Bala, Computer Science, Cornell University

N-Rooks Sampling - 9 rays

notstratified

stratified N-Rooks

© Kavita Bala, Computer Science, Cornell University

N-Rooks Sampling - 36 rays

notstratified

stratified N-Rooks

Page 18: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

18

© Kavita Bala, Computer Science, Cornell University

• How does it relate to Regular Sampling

• Typically importance sample then stratify

Other types of Sampling

Random sampling Regular sampling

© Kavita Bala, Computer Science, Cornell University

Quasi Monte Carlo

Use of low discrepancy sequences(these are not random numbers)

Page 19: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

19

© Kavita Bala, Computer Science, Cornell University

Quasi Monte Carlo

© Kavita Bala, Computer Science, Cornell University

Quasi Monte Carlo

• Converges as fast as stratified sampling– Does not require knowledge about how many

samples will be used

• Using QMC directions evenly spaced no matter how many samples are used

• Samples properly stratified-> better than pure MC

Page 20: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

20

© Kavita Bala, Computer Science, Cornell University

Performance/Error

• Want better quality with smaller number of samples – Fewer samples/better performance

• Well-distributed samples– Stratified sampling

• Faster convergence– Importance sampling: next-event estimation

© Kavita Bala, Computer Science, Cornell University

Path Tracing

1 sample/pixel 16 samples/pixel 256 samples/pixel

Sample hemisphere

• Importance Sampling: compute direct illumination separately!

Page 21: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

21

© Kavita Bala, Computer Science, Cornell University

Direct Illumination• Paths of length 1 only, between receiver

and light source

© Kavita Bala, Computer Science, Cornell University

Direct Lighting Global Illumination

Page 22: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

22

© Kavita Bala, Computer Science, Cornell University

Next Event Estimation

Radiance from light sources + radiance from other surfaces

∫Ω

Ψ⋅Ψ⋅Ψ←⋅Θ↔Ψ+Θ→=Θ→x

dnxLfxLxL xre ω),cos()()()()(

∫Ω

⋅⋅+=x

re fL cos

© Kavita Bala, Computer Science, Cornell University

Next Event Estimation

indirectdirecte LLLxL ++=Θ→ )(

∫∫ΩΩ

⋅⋅+⋅⋅+=xx

rre ffL coscos

• So … sample direct and indirect with separate MC integration

Page 23: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

23

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=L ?=L

© Kavita Bala, Computer Science, Cornell University

Algorithm

?0

==

r

e

LL

?0

==

r

e

LL

Page 24: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

24

© Kavita Bala, Computer Science, Cornell University

Algorithm

??0

===

i

d

e

LLL

??0

===

i

d

e

LLL

© Kavita Bala, Computer Science, Cornell University

Algorithm

?=L ?=L

?345.2

0

=≈=

i

d

e

LLL

?345.2

0

=≈=

i

d

e

LLL

Page 25: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

25

© Kavita Bala, Computer Science, Cornell University

Algorithm

© Kavita Bala, Computer Science, Cornell University

Algorithm

→ a variant of path tracing

Page 26: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

26

© Kavita Bala, Computer Science, Cornell University

Comparison

Without N.E.E. With N.E.E.

16 samples/pixel

© Kavita Bala, Computer Science, Cornell University

Rays per pixel

1 sample/pixel

4 samples/pixel

16 samples/pixel

256 samples/pixel

Page 27: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

27

© Kavita Bala, Computer Science, Cornell University

Direct Illumination

∫ ⋅⋅Ψ→⋅Θ↔Ψ−=Θ→sourceA

yr dAyxGyLxfxL ),()(),()(

x

y

rxy

Vis(x,y)=?

Ψ

Θ

nx

ny

2

),(),cos(),cos(),(

xy

yx

ryxVisnn

yxGΨΘ

=

nxΨ

hemisphere integration area integration

−Ψ

© Kavita Bala, Computer Science, Cornell University

∫Ω

Ψ⋅⋅Ψ←⋅Θ↔Ψ=Θ→x

dxLfxL xrdirect ωθcos)()()(

Rendering Equation

dAy

Ψωd

Ψ

x

2

cos

xy

yy

rdA

ω =Ψ

),( Ψ= xvpy

)),(()( Ψ−→Ψ=Ψ← xvpLxL

Page 28: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

28

© Kavita Bala, Computer Science, Cornell University

Rendering Equation: visible surfaces

∫Ω

Ψ⋅⋅Ψ←⋅Θ↔Ψ=Θ→x

dxLfxL xrdirect ωθcos)()()(

=Θ→ )(xLdirect

),( Ψ= xvpy

Integration domain = surface points y on lights

Coordinate transform

∫lights all on y

)( Ψ−→⋅ yL)( Θ↔Ψrf yxy

yx dA

ryxV ⋅⋅ 2

coscos),(

θθ

© Kavita Bala, Computer Science, Cornell University

Generating direct paths– Pick surface points yi on light source– Evaluate direct illumination integral

x

∑=

=Θ→N

i i

ir

ypyxGLf

NxL

1 )(),((...)(...)1)(

Θ

y

rxy

θx

θy

Vis(x,y)=?

Page 29: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

29

© Kavita Bala, Computer Science, Cornell University

),(coscos

)( 2 yxVisr

LAreaxEyx

yxsourcesource

θθ=

Applied to direct illumination

sourceAreayp 1)( =

© Kavita Bala, Computer Science, Cornell University

∑=

=N

ii

yx

yxsourcesource yxVisrN

LAreaxEi

i

12 ),(coscos

)(θθ

More points ...

1 shadow ray 9 shadow rays

Page 30: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

30

© Kavita Bala, Computer Science, Cornell University

∑=

=N

ii

yx

yxsourcesource yxVisrN

LAreaxEi

i

12 ),(coscos

)(θθ

Even more points ...

36 shadow rays 100 shadow rays

© Kavita Bala, Computer Science, Cornell University

Parameters• How many paths (“shadow-rays”)?

– Total?– Per light source? (~intensity, importance, …)

• How to distribute paths within light source?– Distance from point x– Uniform

Page 31: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

31

© Kavita Bala, Computer Science, Cornell University

Direct paths• Different path generators produce different

estimators and different error characteristics• Direct illumination general algorithm:

compute_radiance (point, direction)est_rad = 0;for (i=0; i<n; i++)

p = generate_path;est_rad += energy_transfer(p) / probability(p);

est_rad = est_rad / n;return(est_rad);

© Kavita Bala, Computer Science, Cornell University

Direct Paths: Using Area Form

1 path / source 9 paths / source 36 paths / source

Page 32: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

32

© Kavita Bala, Computer Science, Cornell University

Alternative direct paths• Shoot paths at random over hemisphere;

check if they hit light source

– paths not used efficiently– noise in image

– might work if light source occupies large portion on hemisphere

© Kavita Bala, Computer Science, Cornell University

Alternative direct paths

1 paths / point 16 paths / point 256 paths / point

Page 33: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

33

© Kavita Bala, Computer Science, Cornell University

Alternative direct paths• Pick random point on random surface;

check if on light source and visible to target point

– paths not used efficiently– noise in image

– might work for large surface light sources

© Kavita Bala, Computer Science, Cornell University

Direct path generators

Hemisphere sampling

- Le can be 0- no visibility in

estimator

Surface sampling

- Le can be 0- 1 visibility term in

estimator

Light source sampling

- Le non-zero- 1 visibility term in

estimator

Page 34: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

34

© Kavita Bala, Computer Science, Cornell University

Stochastic Ray Tracing• Sample area of light source for direct term

• Sample hemisphere with random rays for indirect term

• Optimizations:– Stratified sampling– Importance sampling– Combine multiple probability density functions

into a single PDF

© Kavita Bala, Computer Science, Cornell University

Hemisphere integration

nxΨ

∑=

=Θ→N

i i

ir

ypyxGLf

NxL

1 )(),((...)(...)1)(

Page 35: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

35

© Kavita Bala, Computer Science, Cornell University

• Uniform sampling over the hemisphere

)2/(1)( π=Θp

Sampling strategies

∫Ω

Ψ⋅Ψ⋅Θ↔Ψ⋅Ψ←=Θ→

x

dnfxLxL xr ω),cos()()()(

© Kavita Bala, Computer Science, Cornell University

• Sampling according to the cosine factor

πθ /cos)( =Θp

Sampling strategies

∫Ω

Ψ⋅Ψ⋅Θ↔Ψ⋅Ψ←=Θ→

x

dnfxLxL xr ω),cos()()()(

Page 36: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

36

© Kavita Bala, Computer Science, Cornell University

• Sampling according to the BRDF

)(~)( Ψ↔ΘΘ rfp

Sampling strategies

∫Ω

Ψ⋅Ψ⋅Θ↔Ψ⋅Ψ←=Θ→

x

dnfxLxL xr ω),cos()()()(

© Kavita Bala, Computer Science, Cornell University

• Sampling according to the BRDF times the cosine

θcos)(~)( Ψ↔ΘΘ rfp

Sampling strategies

∫Ω

Ψ⋅Ψ⋅Θ↔Ψ⋅Ψ←=Θ→

x

dnfxLxL xr ω),cos()()()(

Page 37: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

37

© Kavita Bala, Computer Science, Cornell University

Multi-Importance-Sampling

∫Ω

Ψ⋅Ψ⋅Ψ←⋅Θ↔Ψ=Θ→

x

dnxLfxL xr ω),cos()()()(

BRDF IrradianceRadiance

© Kavita Bala, Computer Science, Cornell University

Comparison

With importance sampling(brdf on sphere)

Without importance sampling(brdf on sphere)

Page 38: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

38

© Kavita Bala, Computer Science, Cornell University

Stochastic Ray Tracing• Sample area of light source for direct term

• Sample hemisphere with random rays for indirect term

• Optimizations:– Stratified sampling– Importance sampling– Combine multiple probability density functions

into a single PDF

© Kavita Bala, Computer Science, Cornell University

Indirect Illumination• Paths of length > 1

• Many different path generators possible

• Efficiency dependent on:– BRDFs along the path– Visibility function– ...

Page 39: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

39

© Kavita Bala, Computer Science, Cornell University

Indirect paths - surface sampling• Simple generator (path length = 2):

– select point on light source– select random point on surfaces

– per path:2 visibility checks

© Kavita Bala, Computer Science, Cornell University

Indirect paths - surface sampling• Indirect illumination (path length 2):

• 2 visibility values (which might be 0) cause noise

yzrA A

r dAdAxyGzfyzGzfyLxLsource

),(),(),(),()()( 2211 Θ↔Ψ−Ψ↔Ψ−Ψ→=Θ→ ∫ ∫

∑=

Θ↔Ψ−Ψ↔Ψ−Ψ→=Θ→

N

i iziy

iiiriiiiirii

zpypxyGzfyzGzfyL

NxL

1

2211

)()(),(),(),(),()(1)(

Page 40: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

40

© Kavita Bala, Computer Science, Cornell University

Indirect paths - source shooting• Shoot ray from light source, find hit location• Connect hit point to receiver

– per path:1 ray intersection1 visibility check

© Kavita Bala, Computer Science, Cornell University

Indirect paths - receiver gathering• Shoot ray from receiver point, find hit location• Connect hit point to random point on light source

– per path:1 ray intersection 1 visibility check

Page 41: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

41

© Kavita Bala, Computer Science, Cornell University

Indirect paths

Source shooting

- 1 visibility term- 1 ray intersection

Receiver gathering

- 1 visibility term- 1 ray intersection

Surface sampling

- 2 visibility terms;can be 0

© Kavita Bala, Computer Science, Cornell University

More variants ...• Shoot ray from receiver point, find hit

location• Shoot ray from hit point, check if on light

source– per path:

2 ray intersectionsLe might be zero

Page 42: Monte Carlo Techniques for Rendering - univ-reims.frmathinfo.univ-reims.fr/IMG/pdf/lec10_montecarlo.pdf · Monte Carlo Techniques for Rendering ... • Problem for higher dimensions

42

© Kavita Bala, Computer Science, Cornell University

Indirect paths• Same principles apply to paths of length > 2

– generate multiple surface points– generate multiple bounces from light sources

and connect to receiver– generate multiple bounces from receiver and

connect to light sources– …

• Estimator and noise characteristics change with path generator

© Kavita Bala, Computer Science, Cornell University

Indirect paths– General algorithm:

compute_radiance (point, direction)est_rad = 0;for (i=0; i<n; i++)

p = generate_indirect_path;est_rad += energy_transfer(p) / probability(p);

est_rad = est_rad / n;return(est_rad);