Motivation. Advanced Computer Graphics (Fall 2009) CS 283, Lecture 11: Monte Carlo Integration Ravi Ramamoorthi

Similar documents
Motivation. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Motivation: Monte Carlo Path Tracing. Sampling and Reconstruction of Visual Appearance. Monte Carlo Path Tracing. Monte Carlo Path Tracing

To Do. Real-Time High Quality Rendering. Motivation for Lecture. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Motivation: Monte Carlo Rendering. Sampling and Reconstruction of Visual Appearance. Caustics. Illumination Models. Overview of lecture.

Monte Carlo Ray Tracing. Computer Graphics CMU /15-662

Monte-Carlo Ray Tracing. Antialiasing & integration. Global illumination. Why integration? Domains of integration. What else can we integrate?

MIT Monte-Carlo Ray Tracing. MIT EECS 6.837, Cutler and Durand 1

Raytracing & Epsilon. Today. Last Time? Forward Ray Tracing. Does Ray Tracing Simulate Physics? Local Illumination

Monte Carlo Integration COS 323

Schedule. MIT Monte-Carlo Ray Tracing. Radiosity. Review of last week? Limitations of radiosity. Radiosity

Monte Carlo Path Tracing. The Rendering Equation

Advanced Graphics. Path Tracing and Photon Mapping Part 2. Path Tracing and Photon Mapping

Choosing the Right Algorithm & Guiding

Biased Monte Carlo Ray Tracing

Recent Advances in Monte Carlo Offline Rendering

Path Tracing part 2. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Global Illumination The Game of Light Transport. Jian Huang

Monte Carlo Integration COS 323

Monte Carlo Integration

2/1/10. Outline. The Radiance Equation. Light: Flux Equilibrium. Light: Radiant Power. Light: Equation. Radiance. Jan Kautz

Discussion. Smoothness of Indirect Lighting. History and Outline. Irradiance Calculation. Irradiance Caching. Advanced Computer Graphics (Spring 2013)

Korrigeringar: An introduction to Global Illumination. Global Illumination. Examples of light transport notation light

Global Illumination and Monte Carlo

The Rendering Equation and Path Tracing

Lecture 7 - Path Tracing

Numerical Integration

Monte Carlo Integration

Monte Carlo Path Tracing

GAMES Webinar: Rendering Tutorial 2. Monte Carlo Methods. Shuang Zhao

Realistic Image Synthesis

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

A Brief Overview of. Global Illumination. Thomas Larsson, Afshin Ameri Mälardalen University

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

Virtual Spherical Lights for Many-Light Rendering of Glossy Scenes

The Rendering Equation. Computer Graphics CMU /15-662, Fall 2016

Biased Monte Carlo Ray Tracing:

Lecture 7: Monte Carlo Rendering. MC Advantages

13 Distribution Ray Tracing

Paths, diffuse interreflections, caching and radiometry. D.A. Forsyth

Overview. Radiometry and Photometry. Foundations of Computer Graphics (Spring 2012)

Assignment 3: Path tracing

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Shading Models. Welcome!

Lecture 12: Photon Mapping. Biased Methods

Part I The Basic Algorithm. Principles of Photon Mapping. A two-pass global illumination method Pass I Computing the photon map

Final Project: Real-Time Global Illumination with Radiance Regression Functions

Illumination Algorithms

To Do. Advanced Computer Graphics. Course Outline. Course Outline. Illumination Models. Diffuse Interreflection

Stochastic Path Tracing and Image-based lighting

Global Illumination. Why Global Illumination. Pros/Cons and Applications. What s Global Illumination

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

11/2/2010. In the last lecture. Monte-Carlo Ray Tracing : Path Tracing. Today. Shadow ray towards the light at each vertex. Path Tracing : algorithm

Rendering: Reality. Eye acts as pinhole camera. Photons from light hit objects

Realistic Image Synthesis

Lighting and Shading

Photon Mapping. Michael Doggett Department of Computer Science Lund university

INFOGR Computer Graphics. J. Bikker - April-July Lecture 10: Ground Truth. Welcome!

Photon Mapping. Due: 3/24/05, 11:59 PM

rendering equation computer graphics rendering equation 2009 fabio pellacini 1

COMPUTER GRAPHICS COURSE. LuxRender. Light Transport Foundations

CS 563 Advanced Topics in Computer Graphics Monte Carlo Integration: Basic Concepts. by Emmanuel Agu

The Rendering Equation & Monte Carlo Ray Tracing

Monte Carlo Integration of The Rendering Equation. Computer Graphics CMU /15-662, Spring 2017

The Rendering Equation. Computer Graphics CMU /15-662

rendering equation camera all

CS 563 Advanced Topics in Computer Graphics Irradiance Caching and Particle Tracing. by Stephen Kazmierczak

TDA361/DIT220 Computer Graphics, January 15 th 2016

Rendering Equation & Monte Carlo Path Tracing I

Global Illumination. CSCI 420 Computer Graphics Lecture 18. BRDFs Raytracing and Radiosity Subsurface Scattering Photon Mapping [Ch

Radiance. Radiance properties. Radiance properties. Computer Graphics (Fall 2008)

The Rendering Equation Philip Dutré. Course 4. State of the Art in Monte Carlo Global Illumination Sunday, Full Day, 8:30 am - 5:30 pm

Global Illumination. COMP 575/770 Spring 2013

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Photon Maps. The photon map stores the lighting information on points or photons in 3D space ( on /near 2D surfaces)

Anti-aliasing and Monte Carlo Path Tracing. Brian Curless CSE 557 Autumn 2017

In the real world, light sources emit light particles, which travel in space, reflect at objects or scatter in volumetric media (potentially multiple

Global Illumination CS334. Daniel G. Aliaga Department of Computer Science Purdue University

Anti-aliasing and Monte Carlo Path Tracing

An introduction to Global Illumination. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Global Illumination and the Rendering Equation

MONTE-CARLO PATH TRACING

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Global Illumination. Global Illumination. Direct Illumination vs. Global Illumination. Indirect Illumination. Soft Shadows.

Physically Realistic Ray Tracing

Distribution Ray Tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

Rendering Algorithms: Real-time indirect illumination. Spring 2010 Matthias Zwicker

Variance Reduction. Computer Graphics CMU /15-662, Fall 2016

Distributed Ray Tracing

Spherical Harmonic Lighting: The Gritty Details Robin Green

Local vs. Global Illumination & Radiosity

Announcement. Lighting and Photometric Stereo. Computer Vision I. Surface Reflectance Models. Lambertian (Diffuse) Surface.

SOME THEORY BEHIND REAL-TIME RENDERING

Lecture 10: Ray tracing

6. Illumination, Lighting

CS5620 Intro to Computer Graphics

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Reading. 8. Distribution Ray Tracing. Required: Watt, sections 10.6,14.8. Further reading:

Philipp Slusallek Karol Myszkowski. Realistic Image Synthesis SS18 Instant Global Illumination

Transcription:

Advanced Computer Graphics (Fall 2009) CS 283, Lecture 11: Monte Carlo Integration Ravi Ramamoorthi http://inst.eecs.berkeley.edu/~cs283 Acknowledgements and many slides courtesy: Thomas Funkhouser, Szymon Rusinkiewicz and Pat Hanrahan Motivation Rendering = integration Reflectance equation: Integrate over incident illumination Rendering equation: Integral equation Many sophisticated shading effects involve integrals Antialiasing Soft shadows Indirect illumination Caustics

Example: Soft Shadows Monte Carlo Algorithms based on statistical sampling and random numbers Coined in the beginning of 1940s. Originally used for neutron transport, nuclear simulations Von Neumann, Ulam, Metropolis, Canonical example: 1D integral done numerically Choose a set of random points to evaluate function, and then average (expectation or statistical average)

Monte Carlo Algorithms Advantages Robust for complex integrals in computer graphics (irregular domains, shadow discontinuities and so on) Efficient for high dimensional integrals (common in graphics: time, light source directions, and so on) Quite simple to implement Work for general scenes, surfaces Easy to reason about (but care taken re statistical bias) Disadvantages Noisy Slow (many samples needed for convergence) Not used if alternative analytic approaches exist (but those are rare) Outline Motivation Overview, 1D integration Basic probability and sampling Monte Carlo estimation of integrals

Integration in 1D f(x) x=1 Slide courtesy of Peter Shirley We can approximate f(x) g(x) Standard integration methods like trapezoidal rule and Simpsons rule Advantages: Converges fast for smooth integrands Deterministic x=1 Disadvantages: Exponential complexity in many dimensions Not rapid convergence for discontinuities Slide courtesy of Peter Shirley

Or we can average f(x) E(f(x)) x=1 Slide courtesy of Peter Shirley Estimating the average f(x) x 1 x N E(f(x)) Monte Carlo methods (random choose samples) Advantages: Robust for discontinuities Converges reasonably for large dimensions Can handle complex geometry, integrals Relatively simple to implement, reason about Slide courtesy of Peter Shirley

Other Domains f(x) < f > ab x=a x=b Slide courtesy of Peter Shirley Multidimensional Domains Same ideas apply for integration over Pixel areas Surfaces Projected areas Directions Eye Camera apertures Time Paths Pixel x Surface

Outline Motivation Overview, 1D integration Basic probability and sampling Monte Carlo estimation of integrals Random Variables Describes possible outcomes of an experiment In discrete case, e.g. value of a dice roll [x = 1-6] Probability p associated with each x (1/6 for dice) Continuous case is obvious extension

Expected Value Expectation For Dice example:

Sampling Techniques Problem: how do we generate random points/ directions during path tracing? Non-rectilinear domains Importance (BRDF) Stratified Eye x Surface Generating Random Points Uniform distribution: Use random number generator 1 Probability 0 Ω

Generating Random Points Specific probability distribution: Function inversion Rejection Metropolis 1 Probability 0 Ω Common Operations Want to sample probability distributions Draw samples distributed according to probability Useful for integration, picking important regions, etc. Common distributions Disk or circle Uniform Upper hemisphere for visibility Area luminaire Complex lighting like an environment map Complex reflectance like a BRDF

Generating Random Points 1 Cumulative Probability 0 Ω

Unit radius circle

Rejection Sampling 1 x x x x Probability x x x x x x 0 Ω

Outline Motivation Overview, 1D integration Basic probability and sampling Monte Carlo estimation of integrals Monte Carlo Path Tracing Big diffuse light source, 20 minutes Motivation for rendering in graphics: Covered in detail in next lecture Jensen

Monte Carlo Path Tracing 1000 paths/pixel Jensen Estimating the average f(x) x 1 x N E(f(x)) Monte Carlo methods (random choose samples) Advantages: Robust for discontinuities Converges reasonably for large dimensions Can handle complex geometry, integrals Relatively simple to implement, reason about Slide courtesy of Peter Shirley

Other Domains f(x) < f > ab x=a x=b Slide courtesy of Peter Shirley More formally

Variance E(f(x)) x 1 x N

Variance for Dice Example? Work out on board (variance for single dice roll) Exercise for students at home.

Variance E(f(x)) Variance decreases as 1/N Error decreases as 1/sqrt(N) x 1 x N Variance Problem: variance decreases with 1/N Increasing # samples removes noise slowly E(f(x)) x 1 x N

Variance Reduction Techniques Importance sampling Stratified sampling

Importance Sampling Put more samples where f(x) is bigger E(f(x)) x 1 x N Importance Sampling This is still unbiased E(f(x)) x 1 x N for all N

Stratified Sampling Estimate subdomains separately Arvo E k (f(x)) x 1 x N This is still unbiased Stratified Sampling E k (f(x)) x 1 x N

Stratified Sampling Less overall variance if less variance in subdomains E k (f(x)) x 1 x N More Information Veach PhD thesis chapter (linked to from website) Course Notes (links from website) Mathematical Models for Computer Graphics, Stanford, Fall 1997 State of the Art in Monte Carlo Methods for Realistic Image Synthesis, Course 29, SIGGRAPH 2001

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 Eye Specular Surface Light Pixel x Diffuse Surface 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 Eye x Surface 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 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: Weight = 1/probability Remember: unbiased requires having f(x) / p(x) 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: Path terminated when generate ray in random direction d Emission evaluated return 2 * f r (d d ) * (n d ) * TracePath(p, d )

Arnold Renderer (M. Fajardo) Works well diffuse surfaces, hemispherical light From CS 283(294) last year Daniel Ritchie and Lita Cho

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 E(f(x)) x 1 x N

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 Can never be 1 unless Reflectance is 0 return (1/(1- p emit )) * f r (d d ) * (n d ) * TracePath(p, d ) 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 One Variation for Reflected Ray 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

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 Fixed Adaptive 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