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

Similar documents
Numerical Integration

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

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

Monte Carlo Integration

Monte Carlo Integration

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

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

The Rendering Equation. Computer Graphics CMU /15-662

Lecture 7: Monte Carlo Rendering. MC Advantages

Lecture 7 - Path Tracing

Assignment 3: Path tracing

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

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

Global Illumination The Game of Light Transport. Jian Huang

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

Rendering Equation & Monte Carlo Path Tracing I

Monte Carlo Path Tracing. The Rendering Equation

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

The Rendering Equation and Path Tracing

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

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

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

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Choosing the Right Algorithm & Guiding

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

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

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

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

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

Ambien Occlusion. Lighting: Ambient Light Sources. Lighting: Ambient Light Sources. Summary

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

13 Distribution Ray Tracing

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

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

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

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

MULTI-DIMENSIONAL MONTE CARLO INTEGRATION

Anti-aliasing and Monte Carlo Path Tracing

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

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

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

Shadows. COMP 575/770 Spring 2013

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

Biased Monte Carlo Ray Tracing

Global Illumination and the Rendering Equation

782 Schedule & Notes

Monte Carlo Ray-tracing and Rendering

Realistic Image Synthesis

Stochastic Path Tracing and Image-based lighting

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

Understanding Variability

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

Lecture 12: Photon Mapping. Biased Methods

Capturing light. Source: A. Efros

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

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

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

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

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

The Rendering Equation & Monte Carlo Ray Tracing

INTERACTIVE GLOBAL ILLUMINATION WITH VIRTUAL LIGHT SOURCES

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Realistic Camera Model

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

MONTE-CARLO PATH TRACING

Global Illumination and Monte Carlo

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

Measuring Light: Radiometry and Cameras

Rendering. Mike Bailey. Rendering.pptx. The Rendering Equation

Practical Product Importance Sampling for Direct Illumination

Photometric Stereo.

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

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Radiometry and reflectance

COMP371 COMPUTER GRAPHICS

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

Dynamic Ambient Occlusion and Indirect Lighting. Michael Bunnell NVIDIA Corporation

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

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

Recent Advances in Monte Carlo Offline Rendering

Computer graphics III Path tracing. Jaroslav Křivánek, MFF UK

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

Ray-Tracing. Misha Kazhdan

Shading, lighting, & BRDF Theory. Cliff Lindsay, PHD

Lecture 10: Ray tracing

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

Radiometry & BRDFs CS295, Spring 2017 Shuang Zhao

The Traditional Graphics Pipeline

COMPUTER GRAPHICS COURSE. LuxRender. Light Transport Foundations

Interactive Light Mapping with PowerVR Ray Tracing

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

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

Photorealism vs. Non-Photorealism in Computer Graphics

Lecture 22: Basic Image Formation CAP 5415

Illumination & Shading: Part 1

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

Sung-Eui Yoon ( 윤성의 )

COMP 558 lecture 16 Nov. 8, 2010

The Traditional Graphics Pipeline

Transcription:

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

TODAY: Monte Carlo Ray Tracing How do we render a photorealistic image? Put together many of the ideas we ve studied: - color - materials - radiometry - numerical integration - geometric queries - spatial data structures - rendering equation Combine into final Monte Carlo ray tracing algorithm Alternative to rasterization, lets us generate much more realistic images (usually at much greater cost )

Photorealistic Ray Tracing Basic Goal What are the INPUTS and OUTPUTS? camera geometry materials lights ( scene ) Ray Tracer image

Ray Tracing vs. Rasterization Order Both rasterization & ray tracing will generate an image What s the difference? One basic difference: order in which we process samples RASTERIZATION RAY TRACING for each primitive: for each sample: determine coverage evaluate color for each sample: for each primitive: determine coverage evaluate color (Use Z-buffer to determine which primitive is visible) (Use spatial data structure like BVH to determine which primitive is visible)

Ray Tracing vs. Rasterization Illumination More major difference: sophistication of illumination model - [LOCAL] rasterizer processes one primitive at a time; hard* to determine things like A is in the shadow of B - [GLOBAL] ray tracer processes on ray at a time; ray knows about everything it intersects, easy to talk about shadows & other global illumination effects RASTERIZATION RAY TRACING Q: What illumination effects are missing from the image on the left? *But not impossible to do some things with rasterization (e.g., shadow maps) just takes much more work

Monte Carlo Ray Tracing To develop a full-blown photorealistic ray tracer, will need to apply Monte Carlo integration to the rendering equation To determine color of each pixel, integrate incoming light What function are we integrating? - illumination along different paths of light What does a sample mean in this context? - each path we trace is a sample

Monte Carlo Integration Started looking at Monte Carlo integration in our lecture on numerical integration Basic idea: take average of random samples Will need to flesh this idea out with some key concepts: - EXPECTED VALUE what value do we get on average? - VARIANCE what s the expected deviation from the average? - IMPORTANCE SAMPLING how do we (correctly) take more samples in more important regions?

Expected Value Intuition: what value does a random variable take, on average? E.g., consider a fair coin where heads = 1, tails = 0 Equal probability of heads & is tails (1/2 for both) Expected value is then (1/2) 1 + (1/2) 0 = 1/2 expected value of random variable Y number of possible outcomes E Properties of expectation: " X Y i # E[Y i ] i = X i probability of ith outcome value of ith outcome E[aY ]=ae[y ] (Can you show these are true?)

Variance Intuition: how far are our samples from the average, on average? Definition Q: Which of these has higher variance? Properties of variance: p(x i ) p(x i ) " N X NX V Y i # = V [Y i ] i=1 i=1 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 1 x 2 x 3 x 4 x 5 x 6 x 7 V [ay ]=a 2 V [Y ] (Can you show these are true?)

Law of Large Numbers Important fact: for any random variable, the average value of N trials approaches the expected variable as we increase N Decrease in variance is always linear in N: V " 1 N NX i=1 Y i # = 1 N 2 NX i=1 V [Y i ]= 1 N 2 NV[Y ]= 1 N V [Y ] Remember the coconuts

Q: Why is the law of large numbers important for Monte Carlo ray tracing? A: No matter how hard the integrals are (crazy lighting, geometry, materials, etc.), can always* get the right image by taking more samples. *As long as we make sure to sample all possible kinds of light paths

Biasing So far, we ve picked samples uniformly from the domain (every point is equally likely) Suppose we pick samples from some other distribution (more samples in one place than another) (uniform) Q: Can we still use samples f(xi) to get a (correct) estimate of our integral? 1 A: Sure! Just weight contribution of each sample by how likely we were to pick it Q: Are we correct to divide by p? Or should we multiply instead? A: Think about a simple example where we sample RED region 8x as often as BLUE region average color over square should be purple if we multiply, average will be TOO RED if we divide, average will be JUST RIGHT

Importance sampling Q: Ok, so then WHERE is the best place to take samples? Think: What is the behavior of f(x)/p 1 (x)? f(x)/p 2 (x)? How does this impact the variance of the estimator? f(x) p 1 (x) p 2 (x) Idea: put more where integrand is large ( most useful samples ). E.g.: (BRDF) (image-based lighting) θ φ

Example: Direct Lighting p Light source Occluder (blocks light) p Visibility function: How bright is each point on the ground?

Direct lighting uniform sampling Uniformly-sample hemisphere of directions with respect to solid angle Z p(!) = 1 E(p) = L(p,!) cos d! 2 Z L(p,!) d! Z Estimator: X i p(!) Y i = f(x i ) Y i = L(p,! i )cos i da F N = 2 N NX i=1 Y i

Aside: Picking points on unit hemisphere How do we uniformly sample directions from the hemisphere? One way: use rejection sampling. (How?) Another way: warp two values in [0,1] via the inversion method: q q ( 1, 2 )=( 1 2 1 cos(2 2), 1 2 1 sin(2 2), 1 ) 1.0 0.8 0.6 0.4 0.2 0.2 0.4 0.6 0.8 1.0 Exercise: derive from the inversion method

Direct lighting uniform sampling (algorithm) Uniformly-sample hemisphere of directions with respect to solid angle p(!) = 1 2 E(p) = Z L(p,!) cos d! Z Given surface point p A ray tracer evaluates radiance along a ray (see Raytracer::trace_ray() in raytracer.cpp) Z For each of N samples: Generate random direction:! i! i Compute incoming radiance arriving L i at p from direction: Compute incident irradiance due to ray: de i = L i cos i Accumulate 2 N de i into estimator

Hemispherical solid angle Light source sampling, 100 sample rays (random directions drawn uniformly from hemisphere) Occluder (blocks light)

Why is the image in the previous slide noisy?

Incident lighting estimator uses different random directions in each pixel. Some of those directions point towards the light, others do not. (Estimator is a random variable)

How can we reduce noise?

One idea: just take more samples! Another idea: Don t need to integrate over entire hemisphere of directions (incoming radiance is 0 from most directions). Just integrate over the area of the light (directions where incoming radiance is non-zero)and weight appropriately

Direct lighting: area integral Z E(p) = L(p,!) cos d! Z Previously: just integrate over all directions E(p) = ZA0 L o (p 0,! 0 ) V (p, p 0 ) Z cos cos 0 p p 0 2 da0 Change of variables to integrate over area of light * A 0 p 0 dw = da p 0 p 2 = da0 cos p 0 p 2 0! 0 =p p 0 Binary visibility function: 1 if p is visible from p, 0 otherwise (accounts for light occlusion)! =p 0 p Outgoing radiance from light point p, in direction w towards p p

0! 0 =p p 0 Direct lighting: area integral ZA0 L o (p 0,! 0 ) V (p, p 0 ) E(p) = cos cos 0 p p 0 2 da0 Sample shape uniformly by area A Z A 0 p 0 A 0 p(p 0 )da 0 =1 p(p 0 )= 1 A 0! =p 0 p p

0! 0 =p p 0 Direct lighting: area integral ZA0 L o (p 0,! 0 ) V (p, p 0 ) E(p) = cos cos 0 p p 0 2 da0 Probability: p(p 0 )= 1 A 0 A 0 p 0 Estimator Y i = L o (p 0 i,! i) 0 V (p, p 0 i) cos i cos i 0 p p 0 i 2 0! =p 0 p F N = A0 N NX i=1 Y i 0 X p

Light source area sampling, 100 sample rays If no occlusion is present, all directions chosen in computing estimate hit the light source. (Choice of direction only matters if portion of light is occluded from surface point p.)

1 area light sample (high variance in irradiance estimate)

16 area light samples (lower variance in irradiance estimate)

Comparing different techniques Variance in an estimator manifests as noise in rendered images Estimator efficiency measure: E ciency / 1 Variance Cost If one integration technique has twice the variance of another, then it takes twice as many samples to achieve the same variance If one technique has twice the cost of another technique with the same variance, then it takes twice as much time to achieve the same variance

Example Cosine-Weighted Sampling Consider uniform hemisphere sampling in irradiance estimate: f(!) =L i (!) cos p(!) = 1 2 q q ( 1, 2 )=( 1 2 1 cos(2 2), 1 2 1 sin(2 2), 1 ) Z NX NX NX f(!)d! 1 N i f(!) p(!) = 1 N i L i (!) cos 1/2 = 2 N i L i (!) cos

Example Cosine-Weighted Sampling Cosine-weighted hemisphere sampling in irradiance estimate: f(!) =L i (!) cos p(!) = cos Z NX NX NX f(!) L i (!) cos = N L i (!) f(!)d! 1 N i p(!) = 1 N i cos / i Idea: bias samples toward directions where cos is large (if L is constant, then these are the directions that contribute most)

So far we ve considered light coming directly from light sources, scattered once. How do we use Monte Carlo integration to get the final color values for each pixel?

Monte Carlo + Rendering Equation y! i L o (p,! o )! o p Pinhole x Z L o (p,! o )=L e (p,! o )+ H 2 f r (p,! i!! o ) L i (p,! i ) cos i d! i Need to know incident radiance. So far, have only computed incoming radiance from scene light sources.

Accounting for indirect illumination y! i L o (p,! o )! o p Pinhole x Z L o (p,! o )=L e (p,! o )+ H 2 f r (p,! i!! o ) L i (p,! i ) cos i d! i Incoming light energy from direction! i may be due to light reflected off another surface in the scene (not an emitter)

Path tracing: indirect illumination Z H 2 f r (! i!! o ) L o,i (tr(p,! i ),! i ) cos i d! i Sample incoming direction from some distribution (e.g. proportional to BRDF):! i p(!) Recursively call path tracing function to compute incident indirect radiance

p Direct illumination

p One-bounce global illumination

p Two-bounce global illumination

p Four-bounce global illumination

p Eight-bounce global illumination

p Sixteen-bounce global illumination

Wait a minute When do we stop?!

Russian roulette Idea: want to avoid spending time evaluating function for samples that make a small contribution to the final result Consider a low-contribution sample of the form: L = f r(! i!! o ) L i (! i ) V (p, p 0 ) cos i p(! i ) V (p, p 0 )

Russian roulette L = f r(! i!! o ) L i (! i ) V (p, p 0 ) cos i p(! i ) apple fr (! i!! o ) L i (! i ) cos i L = p(! i ) V (p, p 0 ) If tentative contribution (in brackets) is small, total contribution to the image will be small regardless of V (p, p 0 ) Ignoring low-contribution samples introduces systematic error - No longer converges to correct value! Instead, randomly discard low-contribution samples in a way that leaves estimator unbiased

Russian roulette New estimator: evaluate original estimator with probability p rr, reweight. Otherwise ignore. Same expected value as original estimator: p rr E apple X p rr + E[(1 p rr )0] = E[X]

No Russian roulette: 6.4 seconds

Russian roulette: terminate 50% of all contributions with luminance less than 0.25: 5.1 seconds

Russian roulette: terminate 50% of all contributions with luminance less than 0.5: 4.9 seconds

Russian roulette: terminate 90% of all contributions with luminance less than 0.125: 4.8 seconds

Russian roulette: terminate 90% of all contributions with luminance less than 1: 3.6 seconds

Monte Carlo Ray Tracing Summary Light hitting a point (e.g., pixel) described by rendering equation - Expressed as recursive integral - Can use Monte Carlo to estimate this integral - Need to be intelligent about how to sample!

Next time: Variance reduction how do we get the most out of our samples?