Advanced Computer Graphics (Fall 2009) CS 294, Rendering Lecture 5: Monte Carlo Path Tracing Ravi Ramamoorthi

Slides:



Advertisements
Similar presentations
Insu Yu (Research Fellow) James Tompkin (Research Engineer & T.A.) ( me with questions)
Advertisements

Advanced Computer Graphics
Photorealistic Rendering. Ray tracing v. photorealistic rendering What illumination effects are not captured by ray tracing? What illumination effects.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 21: Radiometry Many slides courtesy Pat Hanrahan.
Advanced Computer Graphics (Spring 2013) CS 283, Lecture 8: Illumination and Reflection Many slides courtesy.
University of Texas at Austin CS395T - Advanced Image Synthesis Spring 2006 Don Fussell Previous lecture Reflectance I BRDF, BTDF, BSDF Ideal specular.
Monte Carlo Integration Robert Lin April 20, 2004.
Advanced Computer Graphics (Spring 2005) COMS 4162, Lectures 18, 19: Monte Carlo Integration Ravi Ramamoorthi Acknowledgements.
CSCE 641: Photon Mapping Jinxiang Chai. Outline Rendering equation Photon mapping.
Photon Tracing with Arbitrary Materials Patrick Yau.
Appearance Models for Graphics COMS , Lecture 2 BRDFs and Radiometry Many slides courtesy Pat Hanrahan:
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 10: Global Illumination Ravi Ramamoorthi Some images courtesy.
Computer Graphics (Fall 2008) COMS 4160, Lecture 19: Illumination and Shading 2
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Monte Carlo Integration COS 323 Acknowledgment: Tom Funkhouser.
Advanced Computer Graphics (Spring 2006) COMS 4162, Lecture 20: Monte Carlo Path Tracing Ravi Ramamoorthi Acknowledgements.
Computer Graphics (Fall 2004) COMS 4160, Lecture 16: Illumination and Shading 2 Lecture includes number of slides from.
Global Illumination Jian Huang, CS 594, Fall 2002 This set of slides reference text book and the course note of Dutre et. al on SIGGRAPH 2001.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
Global Illumination. Direct Illumination vs. Global Illumination reflected, scattered and focused light (not discreet). physical-based light transport.
COMP 175: Computer Graphics March 24, 2015
02/11/05© 2005 University of Wisconsin Last Time Direct Lighting Light Transport Equation (LTE) Intro.
01/24/05© 2005 University of Wisconsin Last Time Raytracing and PBRT Structure Radiometric quantities.
Selected Topics in Global Illumination Computation Jaroslav Křivánek Charles University, Prague
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
02/25/05© 2005 University of Wisconsin Last Time Meshing Volume Scattering Radiometry (Adsorption and Emission)
-Global Illumination Techniques
Monte Carlo I Previous lecture Analytical illumination formula This lecture Numerical evaluation of illumination Review random variables and probability.
02/10/03© 2003 University of Wisconsin Last Time Participating Media Assignment 2 –A solution program now exists, so you can preview what your solution.
Computer graphics & visualization Photon Mapping.
Computer Graphics Global Illumination: Photon Mapping, Participating Media Lecture 12 Taku Komura.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Hybrid Algorithms K. H. Ko School of Mechatronics Gwangju Institute.
111/17/ :21 Graphics II Global Rendering and Radiosity Session 9.
Announcements Office hours today 2:30-3:30 Graded midterms will be returned at the end of the class.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Real-Time High Quality Rendering
On robust Monte Carlo algorithms for multi-pass global illumination Frank Suykens – De Laet 17 September 2002.
Monte-Carlo Ray Tracing and
Pure Path Tracing: the Good and the Bad Path tracing concentrates on important paths only –Those that hit the eye –Those from bright emitters/reflectors.
02/12/03© 2003 University of Wisconsin Last Time Intro to Monte-Carlo methods Probability.
Computer Graphics III – Monte Carlo integration Direct illumination
In the name of God Computer Graphics. Last Time Some techniques for modeling Today Global illumination and raytracing.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
Slide 1Lastra, 2/14/2016 Monte-Carlo Methods. Slide 2Lastra, 2/14/2016 Topics Kajiya’s paper –Showed that existing rendering methods are approximations.
Monte Carlo Path Tracing
University of Texas at Austin CS395T - Advanced Image Synthesis Spring 2007 Don Fussell Photon Mapping and Irradiance Caching.
Global Illumination (3) Photon Mapping (1). Overview Light Transport Notation Path Tracing Photon Mapping –Photon Tracing –The Photon Map.
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
02/9/05© 2005 University of Wisconsin Last Time Lights Next assignment – Implement Kubelka-Munk as a BSDF.
Distributed Ray Tracing. Can you get this with ray tracing?
Distributed Ray Tracing. Can you get this with ray tracing?
CS552: Computer Graphics Lecture 33: Illumination and Shading.
Computer graphics III – Multiple Importance Sampling Jaroslav Křivánek, MFF UK
Computer graphics III – Rendering equation and its solution
Computer graphics III – Path tracing Jaroslav Křivánek, MFF UK
Advanced Computer Graphics
Advanced Computer Graphics
Shading Revisited Some applications are intended to produce pictures that look photorealistic, or close to it The image should look like a photograph A.
Sampling and Reconstruction of Visual Appearance
Sampling and Reconstruction of Visual Appearance
Previous lecture Reflectance I BRDF, BTDF, BSDF Ideal specular model
© 2005 University of Wisconsin
Path Tracing (some material from University of Wisconsin)
Monte Carlo I Previous lecture Analytical illumination formula
Monte Carlo Path Tracing
Monte Carlo Rendering Central theme is sampling:
CS5500 Computer Graphics May 29, 2006
Computer Graphics (Fall 2003)
Monte Carlo Integration
Photon Density Estimation using Multiple Importance Sampling
Presentation transcript:

Advanced Computer Graphics (Fall 2009) CS 294, Rendering Lecture 5: Monte Carlo Path Tracing Ravi Ramamoorthi Acknowledgements and some slides: Szymon Rusinkiewicz and Pat Hanrahan

To Do  Start working on assignment  Find partners for this purpose

Motivation  General solution to rendering and global illumination  Suitable for a variety of general scenes  Based on Monte Carlo methods  Enumerate all paths of light transport

Monte Carlo Path Tracing Big diffuse light source, 20 minutes Jensen

Monte Carlo Path Tracing 1000 paths/pixel Jensen

Monte Carlo Path Tracing Advantages  Any type of geometry (procedural, curved,...)  Any type of BRDF (specular, glossy, diffuse,...)  Samples all types of paths (L(SD)*E)  Accuracy controlled at pixel level  Low memory consumption  Unbiased - error appears as noise in final image Disadvantages (standard Monte Carlo problems)  Slow convergence (square root of number of samples)  Noise in final image

Monte Carlo Path Tracing Integrate radiance for each pixel by sampling paths randomly Diffuse Surface Eye Light x Specular Surface Pixel

Simple Monte Carlo Path Tracer  Step 1: Choose a ray (u,v, ,   ) [per pixel]; assign weight = 1  Step 2: Trace ray to find intersection with nearest surface  Step 3: Randomly choose between emitted and reflected light  Step 3a: If emitted, return weight’ * Le  Step 3b: If reflected, weight’’ *= reflectance Generate ray in random direction Go to step 2

Sampling Techniques Problem: how do we generate random points/directions during path tracing and reduce variance?  Importance sampling (e.g. by BRDF)  Stratified sampling Surface Eye x

Outline  Motivation and Basic Idea  Implementation of simple path tracer  Variance Reduction: Importance sampling  Other variance reduction methods  Specific 2D sampling techniques

Simplest Monte Carlo Path Tracer For each pixel, cast n samples and average  Choose a ray with p=camera, d=( ,   ) within pixel  Pixel color += (1/n) * TracePath(p, d) TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  Select with probability (say) 50%:  Emitted: return 2 * (Le red, Le green, Le blue ) // 2 = 1/(50%)  Reflected: generate ray in random direction d’ return 2 * f r (d  d’) * (n  d’) * TracePath(p’, d’)

Simplest Monte Carlo Path Tracer For each pixel, cast n samples and average over paths  Choose a ray with p=camera, d=( ,   ) within pixel  Pixel color += (1/n) * TracePath(p, d) TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  Select with probability (say) 50%:  Emitted: return 2 * (Le red, Le green, Le blue ) // 2 = 1/(50%)  Reflected: generate ray in random direction d’ return 2 * f r (d  d’) * (n  d’) * TracePath(p’, d’)

Simplest Monte Carlo Path Tracer For each pixel, cast n samples and average  Choose a ray with p=camera, d=( ,   ) within pixel  Pixel color += (1/n) * TracePath(p, d) TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  Select with probability (say) 50%:  Emitted: return 2 * (Le red, Le green, Le blue ) // 2 = 1/(50%)  Reflected: generate ray in random direction d’ return 2 * f r (d  d’) * (n  d’) * TracePath(p’, d’) Weight = 1/probability Remember: unbiased requires having f(x) / p(x)

Simplest Monte Carlo Path Tracer For each pixel, cast n samples and average  Choose a ray with p=camera, d=( ,   ) within pixel  Pixel color += (1/n) * TracePath(p, d) TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  Select with probability (say) 50%:  Emitted: return 2 * (Le red, Le green, Le blue ) // 2 = 1/(50%)  Reflected: generate ray in random direction d’ return 2 * f r (d  d’) * (n  d’) * TracePath(p’, d’) Path terminated when Emission evaluated

Arnold Renderer (M. Fajardo)  Works well diffuse surfaces, hemispherical light

Advantages and Drawbacks  Advantage: general scenes, reflectance, so on  By contrast, standard recursive ray tracing only mirrors  This algorithm is unbiased, but horribly inefficient  Sample “emitted” 50% of the time, even if emitted=0  Reflect rays in random directions, even if mirror  If light source is small, rarely hit it  Goal: improve efficiency without introducing bias  Variance reduction using many of the methods discussed for Monte Carlo integration last week  Subject of much interest in graphics in 90s till today

Outline  Motivation and Basic Idea  Implementation of simple path tracer  Variance Reduction: Importance sampling  Other variance reduction methods  Specific 2D sampling techniques

Importance Sampling  Pick paths based on energy or expected contribution  More samples for high-energy paths  Don’t pick low-energy paths  At “macro” level, use to select between reflected vs emitted, or in casting more rays toward light sources  At “micro” level, importance sample the BRDF to pick ray directions  Tons of papers in 90s on tricks to reduce variance in Monte Carlo rendering

Importance Sampling Can pick paths however we want, but contribution weighted by 1/probability  Already seen this division of 1/prob in weights to emission, reflectance x1x1x1x1 xNxNxNxN E(f(x)) E(f(x))

Simplest Monte Carlo Path Tracer For each pixel, cast n samples and average  Choose a ray with p=camera, d=( ,   ) within pixel  Pixel color += (1/n) * TracePath(p, d) TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  Select with probability (say) 50%:  Emitted: return 2 * (Le red, Le green, Le blue ) // 2 = 1/(50%)  Reflected: generate ray in random direction d’ return 2 * f r (d  d’) * (n  d’) * TracePath(p’, d’)

Importance sample Emit vs Reflect TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  If Le = (0,0,0) then p emit = 0 else p emit = 0.9 (say)  If random() < p emit then:  Emitted: return (1/ p emit ) * (Le red, Le green, Le blue )  Else Reflected: generate ray in random direction d’ return (1/(1- p emit )) * f r (d  d’) * (n  d’) * TracePath(p’, d’)

Importance sample Emit vs Reflect TracePath(p, d) returns (r,g,b) [and calls itself recursively]:  Trace ray (p, d) to find nearest intersection p’  If Le = (0,0,0) then p emit = 0 else p emit = 0.9 (say)  If random() < p emit then:  Emitted: return (1/ p emit ) * (Le red, Le green, Le blue )  Else Reflected: generate ray in random direction d’ return (1/(1- p emit )) * f r (d  d’) * (n  d’) * TracePath(p’, d’) Can never be 1 unless Reflectance is 0

Outline  Motivation and Basic Idea  Implementation of simple path tracer  Variance Reduction: Importance sampling  Other variance reduction methods  Specific 2D sampling techniques

More variance reduction  Discussed “macro” importance sampling  Emitted vs reflected  How about “micro” importance sampling  Shoot rays towards light sources in scene  Distribute rays according to BRDF

 Pick a light source  Trace a ray towards that light  Trace a ray anywhere except for that light  Rejection sampling  Divide by probabilities  1/(solid angle of light) for ray to light source  (1 – the above) for non-light ray  Extra factor of 2 because shooting 2 rays One Variation for Reflected Ray

Russian Roulette  Maintain current weight along path (need another parameter to TracePath)  Terminate ray iff |weight| < const.  Be sure to weight by 1/probability

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching RenderPark

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching Heinrich

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching Unfiltered Filtered Jensen

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching Adaptive Fixed Ohbuchi

Monte Carlo Extensions Unbiased  Bidirectional path tracing  Metropolis light transport Biased, but consistent  Noise filtering  Adaptive sampling  Irradiance caching Jensen

Monte Carlo Path Tracing Image 2000 samples per pixel, 30 computers, 30 hours Jensen

Outline  Motivation and Basic Idea  Implementation of simple path tracer  Variance Reduction: Importance sampling  Other variance reduction methods  Specific 2D sampling techniques

2D Sampling: Motivation  Final step in sending reflected ray: sample 2D domain  According to projected solid angle  Or BRDF  Or area on light source  Or sampling of a triangle on geometry  Etc.

Sampling Upper Hemisphere  Uniform directional sampling: how to generate random ray on a hemisphere?  Option #1: rejection sampling  Generate random numbers (x,y,z), with x,y,z in –1..1  If x 2 +y 2 +z 2 > 1, reject  Normalize (x,y,z)  If pointing into surface (ray dot n < 0), flip

Sampling Upper Hemisphere  Option #2: inversion method  In polar coords, density must be proportional to sin  (remember d(solid angle) = sin  d  d  )  Integrate, invert  cos -1  So, recipe is  Generate  in 0..2   Generate z in 0..1  Let  = cos -1 z  (x,y,z) = (sin  cos , sin  sin , cos  )

BRDF Importance Sampling  Better than uniform sampling: importance sampling  Because you divide by probability, ideally probability  f r * cos  i

BRDF Importance Sampling  For cosine-weighted Lambertian:  Density = cos  sin   Integrate, invert  cos -1 (sqrt)  So, recipe is:  Generate  in 0..2   Generate z in 0..1  Let  = cos -1 (sqrt(z))

BRDF Importance Sampling  Phong BRDF: f r  cos n  where  is angle between outgoing ray and ideal mirror direction  Constant scale = k s (n+2)/(2  )  Can’t sample this times cos  i  Can only sample BRDF itself, then multiply by cos  i  That’s OK – still better than random sampling

BRDF Importance Sampling  Recipe for sampling specular term:  Generate z in 0..1  Let  = cos -1 (z 1/(n+1) )  Generate   in 0..2   This gives direction w.r.t. ideal mirror direction  Convert to (x,y,z), then rotate such that z points along mirror dir.

Summary  Monte Carlo methods robust and simple (at least until nitty gritty details) for global illumination  Must handle many variance reduction methods in practice  Importance sampling, Bidirectional path tracing, Russian roulette etc.  Rich field with many papers, systems researched over last 10 years