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 do NOT have to update yours if you already had it compiled CS295, Spring 2017 Shuang Zhao 2
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
Today’s Lecture • Monte Carlo Path Tracing II • BRDF sampling • Multiple importance sampling CS295, Spring 2017 Shuang Zhao 4
Recap: Rendering Equation = + = + CS295, Spring 2017 Shuang Zhao 5
Recap: Rendering Equation (Invariant of radiance along lines) CS295, Spring 2017 Shuang Zhao 6
Recap: Path Tracing (Version 1.0) reflectedRadiance ( x , ω , depth): [ y 1 , pdf] = luminaireSample() Direct ω 1 = normalize( y 1 - x ) illumination r 2 = dot( y 1 - x , y 1 - x ) reflRad = emittedRadiance( y 1 , - ω 1 ) * brdf( x , ω 1 , ω ) * visibility( x , y 1 ) * dot( n x , ω 1 ) * dot( n y , - ω 1 ) / (r 2 * pdf) if depth <= rrDepth: Indirect p = 1.0 illumination else: p = survivalProbability if rand() < p : ω 2 = uniformRandomPSA( n x ) y 2 = RayTrace( x , ω 2 ) reflRad += π * reflectedRadiance( y 2 , - ω 2 , depth + 1) * brdf( x , ω 2 , ω ) / p return reflRad CS295, Spring 2017 Shuang Zhao 7
Path Tracing (Version 1.0) reflectedRadiance ( x , ω , depth): flexible [ y 1 , pdf] = luminaireSample() Direct ω 1 = normalize( y 1 - x ) illumination r 2 = dot( y 1 - x , y 1 - x ) reflRad = emittedRadiance( y 1 , - ω 1 ) * brdf( x , ω 1 , ω ) * visibility( x , y 1 ) * dot( n x , ω 1 ) * dot( n y , - ω 1 ) / (r 2 * pdf) if depth <= rrDepth: Indirect p = 1.0 illumination else: p = survivalProbability if rand() < p : ω 2 = uniformRandomPSA( n x ) inflexible y 2 = RayTrace( x , ω 2 ) reflRad += π * reflectedRadiance( y 2 , - ω 2 , depth + 1) * brdf( x , ω 2 , ω ) / p return reflRad CS295, Spring 2017 Shuang Zhao 8
Fixed Sampling of Incident Direction [Lawrence et al. 2004] Uniform sampling Better sampling CS295, Spring 2017 Shuang Zhao 9
BRDF Sampling Monte Carlo Path Tracing II CS295, Spring 2017 Shuang Zhao 10
Estimating Indirect Illumination MC Integration • Path tracing version 1.1! CS295, Spring 2017 Shuang Zhao 11
Path Tracing (Version 1.1) reflectedRadiance ( x , ω , depth): [ y 1 , pdf] = luminaireSample() Direct ω 1 = normalize( y 1 - x ) illumination r 2 = dot( y 1 - x , y 1 - x ) reflRad = emittedRadiance( y 1 , - ω 1 ) * brdf( x , ω 1 , ω ) * visibility( x , y 1 ) * dot( n x , ω 1 ) * dot( n y , - ω 1 ) / (r 2 * pdf) if depth <= rrDepth: Indirect p = 1.0 illumination else: p = survivalProbability if rand() < p : [ ω 2 , pdf 2 ] = brdfSample( x ) y 2 = RayTrace( x , ω 2 ) reflRad += reflectedRadiance( y 2 , - ω 2 , depth + 1) * brdf( x , ω 2 , ω ) * dot( n x , ω 2 ) / (pdf 2 * p ) return reflRad CS114, Spring 2017 Shuang Zhao 12
Estimating Indirect Illumination MC Integration • 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
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
Sampling Ideal Specular BRDF where • 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
Sampling the Phong BRDF • It is hard to sample according to • Instead, sample according to over the hemi- sphere around : CS295, Spring 2017 Shuang Zhao 16
Sampling the Phong BRDF • Obtaining c (the normalization factor) : • To sample θ 1 (inversion method): CS295, Spring 2017 Shuang Zhao 17
Sampling the Phong BRDF • Lastly, where CS295, Spring 2017 Shuang Zhao 18
BRDF Sampling • Also applies to the estimation of the direct illumination: or the full radiance: where CS295, Spring 2017 Shuang Zhao 19
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
Multiple Importance Sampling Monte Carlo Path Tracing II CS295, Spring 2017 Shuang Zhao 21
Sampling Light Source vs. BRDF • Sampling y on the light source: where and A e 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
Sampling Light Source vs. BRDF • It depends! CS295, Spring 2017 Shuang Zhao 23
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
What is Going On? • Assuming we have and • Then, we should pick p = p 1 if f ( x ) has higher variance and p = p 2 if otherwise (since we want to have low variance) • Can we combine multiple sampling strategies? CS295, Spring 2017 Shuang Zhao 25
Multiple Importance Sampling • To estimate • Assume there are n probability densities p 1 , p 2 , …, p n to sample x . Then, is an unbiased estimator of as long as: • for all x with • whenever CS295, Spring 2017 Shuang Zhao 26
Multiple Importance Sampling • Proof: CS295, Spring 2017 Shuang Zhao 27
Weighting Functions • How to choose the weighting functions w i ( x )? • Method 1: constant • Let for all x • Unfortunately, since if one f ( x i )/ p i ( x i ) has high variance, so will • This is undesirable! CS295, Spring 2017 Shuang Zhao 28
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” will also be “good” estimator for , CS295, Spring 2017 Shuang Zhao 29
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
Example: MIS denotes the indicator function • 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
Example: MIS • σ = 1; a = 1.9, b = 2.0 CS295, Spring 2017 Shuang Zhao 32
Example: MIS • σ = 0.05; a = -3.0, b = 3.0 CS295, Spring 2017 Shuang Zhao 33
Next Lecture • Monte Carlo Path Tracing III • Multiple importance sampling ( con’t ) • Operator formulation of light transport CS295, Spring 2017 Shuang Zhao 34
Recommend
More recommend