Monte Carlo Path Tracing II CS295, Spring 2017 Shuang Zhao - - PowerPoint PPT Presentation

monte carlo path tracing ii
SMART_READER_LITE
LIVE PREVIEW

Monte Carlo Path Tracing II CS295, Spring 2017 Shuang Zhao - - PowerPoint PPT Presentation

Monte Carlo Path Tracing II CS295, Spring 2017 Shuang Zhao Computer Science Department University of California, Irvine CS295, Spring 2017 Shuang Zhao 1 Announcements PA1 base code updated to fix compilation issues under Mac OS You


slide-1
SLIDE 1

Monte Carlo Path Tracing II

CS295, Spring 2017 Shuang Zhao

Computer Science Department University of California, Irvine

CS295, Spring 2017 Shuang Zhao 1

slide-2
SLIDE 2

Announcements

  • PA1 base code updated to fix compilation

issues under Mac OS

  • You do NOT have to update yours if you already

had it compiled

CS295, Spring 2017 Shuang Zhao 2

slide-3
SLIDE 3

Last Lecture

  • Rendering equation
  • Describe the distribution of light at equilibrium
  • Monte Carlo Path Tracing I
  • An unbiased numerical solution to the rendering

equation

CS295, Spring 2017 Shuang Zhao 3

slide-4
SLIDE 4

Today’s Lecture

  • Monte Carlo Path Tracing II
  • BRDF sampling
  • Multiple importance sampling

CS295, Spring 2017 Shuang Zhao 4

slide-5
SLIDE 5

Recap: Rendering Equation

CS295, Spring 2017 Shuang Zhao 5

= +

= +

slide-6
SLIDE 6

Recap: Rendering Equation

CS295, Spring 2017 Shuang Zhao 6

(Invariant of radiance along lines)

slide-7
SLIDE 7

Recap: Path Tracing (Version 1.0)

reflectedRadiance(x, ω, depth): [y1, pdf] = luminaireSample() ω1 = normalize(y1 - x) r2 = dot(y1 - x, y1 - x) reflRad = emittedRadiance(y1, -ω1) * brdf(x, ω1, ω) * visibility(x, y1) * dot(nx, ω1) * dot(ny, -ω1) / (r2 * pdf) if depth <= rrDepth: p = 1.0 else: p = survivalProbability if rand() < p: ω2 = uniformRandomPSA(nx) y2 = RayTrace(x, ω2) reflRad += π * reflectedRadiance(y2, -ω2, depth + 1) * brdf(x, ω2, ω) / p return reflRad

CS295, Spring 2017 Shuang Zhao 7

Direct illumination Indirect illumination

slide-8
SLIDE 8

Path Tracing (Version 1.0)

reflectedRadiance(x, ω, depth): [y1, pdf] = luminaireSample() ω1 = normalize(y1 - x) r2 = dot(y1 - x, y1 - x) reflRad = emittedRadiance(y1, -ω1) * brdf(x, ω1, ω) * visibility(x, y1) * dot(nx, ω1) * dot(ny, -ω1) / (r2 * pdf) if depth <= rrDepth: p = 1.0 else: p = survivalProbability if rand() < p: ω2 = uniformRandomPSA(nx) y2 = RayTrace(x, ω2) reflRad += π * reflectedRadiance(y2, -ω2, depth + 1) * brdf(x, ω2, ω) / p return reflRad

CS295, Spring 2017 Shuang Zhao 8

inflexible Direct illumination Indirect illumination flexible

slide-9
SLIDE 9

Fixed Sampling of Incident Direction

CS295, Spring 2017 Shuang Zhao 9

Uniform sampling Better sampling

[Lawrence et al. 2004]

slide-10
SLIDE 10

BRDF Sampling

Monte Carlo Path Tracing II

CS295, Spring 2017 Shuang Zhao 10

slide-11
SLIDE 11

Estimating Indirect Illumination

  • Path tracing version 1.1!

CS295, Spring 2017 Shuang Zhao 11

MC Integration

slide-12
SLIDE 12

Path Tracing (Version 1.1)

reflectedRadiance(x, ω, depth): [y1, pdf] = luminaireSample() ω1 = normalize(y1 - x) r2 = dot(y1 - x, y1 - x) reflRad = emittedRadiance(y1, -ω1) * brdf(x, ω1, ω) * visibility(x, y1) * dot(nx, ω1) * dot(ny, -ω1) / (r2 * pdf) if depth <= rrDepth: p = 1.0 else: p = survivalProbability if rand() < p: [ω2, pdf2] = brdfSample(x) y2 = RayTrace(x, ω2) reflRad += reflectedRadiance(y2, -ω2, depth + 1) * brdf(x, ω2, ω) * dot(nx, ω2) / (pdf2 * p) return reflRad

CS114, Spring 2017 Shuang Zhao 12

Direct illumination Indirect illumination

slide-13
SLIDE 13

Estimating Indirect Illumination

  • Ideally, we want
  • c is the normalization factor
  • Then,
  • Note: this is possible only for some BRDFs

(e.g., ideal diffuse, ideal specular)

CS295, Spring 2017 Shuang Zhao 13

MC Integration

slide-14
SLIDE 14

Sampling Ideal Diffuse BRDF

  • In this case, ωi is drawn using cosine-weighted

sampling (i.e., uniform sampling of projected solid angle)

  • uniformRandomPSA() from the last lecture!

CS295, Spring 2017 Shuang Zhao 14

slide-15
SLIDE 15

Sampling Ideal Specular BRDF

  • In this case, the sampling of ωi is deterministic:

ωi is always set to ωmirrored, and the estimator becomes

CS295, Spring 2017 Shuang Zhao 15

where

slide-16
SLIDE 16

Sampling the Phong BRDF

  • It is hard to sample according

to

  • Instead, sample according to
  • ver the hemi-

sphere around :

CS295, Spring 2017 Shuang Zhao 16

slide-17
SLIDE 17

Sampling the Phong BRDF

  • Obtaining c (the normalization factor):
  • To sample θ1 (inversion method):

CS295, Spring 2017 Shuang Zhao 17

slide-18
SLIDE 18

Sampling the Phong BRDF

  • Lastly,

where

CS295, Spring 2017 Shuang Zhao 18

slide-19
SLIDE 19

BRDF Sampling

  • Also applies to the estimation of the direct

illumination:

  • r the full radiance:

where

CS295, Spring 2017 Shuang Zhao 19

slide-20
SLIDE 20

BRDF Sampling

  • An active research area
  • Methods specialized to individual models
  • Ward BRDF [Walter 2005]
  • Micro-facet models [Walter et al. 2007]
  • General frameworks
  • Factorization-based sampling [Lawrence et al. 2004]

CS295, Spring 2017 Shuang Zhao 20

slide-21
SLIDE 21

Multiple Importance Sampling

Monte Carlo Path Tracing II

CS295, Spring 2017 Shuang Zhao 21

slide-22
SLIDE 22

Sampling Light Source vs. BRDF

  • Sampling y on the light source:

where and Ae is the surface area of all lights

  • Sampling ωi based on the BRDF at x:

where

  • Which one is better?

CS295, Spring 2017 Shuang Zhao 22

slide-23
SLIDE 23

Sampling Light Source vs. BRDF

  • It depends!

CS295, Spring 2017 Shuang Zhao 23

slide-24
SLIDE 24

What is Going On?

  • Consider the problem of estimating:
  • By randomly sampling x from PDF p, we have
  • Ideally, we would like

, but this can be difficult in practice

CS295, Spring 2017 Shuang Zhao 24

slide-25
SLIDE 25

What is Going On?

  • Assuming we have

and

  • Then, we should pick p = p1 if f(x) has higher

variance and p = p2 if otherwise (since we want to have low variance)

  • Can we combine multiple sampling strategies?

CS295, Spring 2017 Shuang Zhao 25

slide-26
SLIDE 26

Multiple Importance Sampling

  • To estimate
  • Assume there are n probability densities p1, p2,

…, pn to sample x. Then, is an unbiased estimator of as long as:

  • for all x with
  • whenever

CS295, Spring 2017 Shuang Zhao 26

slide-27
SLIDE 27

Multiple Importance Sampling

  • Proof:

CS295, Spring 2017 Shuang Zhao 27

slide-28
SLIDE 28

Weighting Functions

  • How to choose the weighting functions wi(x)?
  • Method 1: constant
  • Let

for all x

  • Unfortunately, since

if one f(xi)/pi(xi) has high variance, so will

  • This is undesirable!

CS295, Spring 2017 Shuang Zhao 28

slide-29
SLIDE 29

The Balance Heuristic

  • Method 2:
  • Then,
  • It holds that

for any unbiased estimator

(with the n densities)

  • In other words, as long as there exists a “good”

estimator for , will also be “good”

CS295, Spring 2017 Shuang Zhao 29

slide-30
SLIDE 30

The Power Heuristic

  • Method 3:
  • Then,
  • It holds that

for any unbiased estimator

(with the n densities)

  • Sometimes works better than balance heuristic in

rendering!

CS295, Spring 2017 Shuang Zhao 30

slide-31
SLIDE 31

Example: MIS

  • Consider the problem of evaluating:

with two probability densities

  • f: normal distribution with mean 0 and variance σ2
  • g: uniform distribution between a and b

CS295, Spring 2017 Shuang Zhao 31

denotes the indicator function

slide-32
SLIDE 32

Example: MIS

  • σ = 1; a = 1.9, b = 2.0

CS295, Spring 2017 Shuang Zhao 32

slide-33
SLIDE 33

Example: MIS

  • σ = 0.05; a = -3.0, b = 3.0

CS295, Spring 2017 Shuang Zhao 33

slide-34
SLIDE 34

Next Lecture

  • Monte Carlo Path Tracing III
  • Multiple importance sampling (con’t)
  • Operator formulation of light transport

CS295, Spring 2017 Shuang Zhao 34