Lecture 7 - Path Tracing

Similar documents
INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

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

The Rendering Equation and Path Tracing

Global Illumination The Game of Light Transport. Jian Huang

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

The Rendering Equation. Computer Graphics CMU /15-662

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

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

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

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

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

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

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

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

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

Capturing light. Source: A. Efros

CS-184: Computer Graphics. Today. Lecture 22: Radiometry! James O Brien University of California, Berkeley! V2014-S

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

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

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

Radiometry & BRDFs CS295, Spring 2017 Shuang Zhao

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

Lecture 22: Basic Image Formation CAP 5415

Lecture 10: Ray tracing

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

Radiometry and reflectance

The Rendering Equation & Monte Carlo Ray Tracing

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

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

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

Announcements. Radiometry and Sources, Shadows, and Shading

Motivation. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing. Monte Carlo Path Tracing

Choosing the Right Algorithm & Guiding

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

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

Lighting affects appearance

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

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

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

The Light Field. Last lecture: Radiometry and photometry

13 Distribution Ray Tracing

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

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

Lecture 18: Primer on Ray Tracing Techniques

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

Reflection models and radiometry Advanced Graphics

Assignment 3: Path tracing

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

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

Local vs. Global Illumination & Radiosity

CMSC427 Shading Intro. Credit: slides from Dr. Zwicker

COMPUTER GRAPHICS COURSE. LuxRender. Light Transport Foundations

Measuring Light: Radiometry and Cameras

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

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

Global Illumination. COMP 575/770 Spring 2013

Illumination Algorithms

Lecture 12: Photon Mapping. Biased Methods

Radiometry. Radiometry. Measuring Angle. Solid Angle. Radiance

COMP371 COMPUTER GRAPHICS

SOME THEORY BEHIND REAL-TIME RENDERING

INFOGR Computer Graphics. Jacco Bikker - April-July Lecture 14: Grand Recap. Welcome!

Image Formation: Light and Shading. Introduction to Computer Vision CSE 152 Lecture 3

And if that 120MP Camera was cool

Recent Advances in Monte Carlo Offline Rendering

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

Reflectance & Lighting

Announcements. Image Formation: Light and Shading. Photometric image formation. Geometric image formation

Implementation of Dispersion Rendering Capabilities in the Advanced Rendering Toolkit

Lighting - the Radiance Equation

Stochastic Path Tracing and Image-based lighting

Lighting and Shading

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

Glossy Reflection. Objectives Modeling

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

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

Lecture 7: Monte Carlo Rendering. MC Advantages

INFOGR Computer Graphics

Global Illumination and the Rendering Equation

CSE 681 Illumination and Phong Shading

Biased Monte Carlo Ray Tracing

Lights, Surfaces, and Cameras. Light sources emit photons Surfaces reflect & absorb photons Cameras measure photons

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Monte Carlo Integration

Specular reflection. Lighting II. Snell s Law. Refraction at boundary of media

rendering equation computer graphics rendering equation 2009 fabio pellacini 1

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

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

THE goal of rendering algorithms is to synthesize images of virtual scenes. Global illumination

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

MITOCW MIT6_172_F10_lec18_300k-mp4

Biased Monte Carlo Ray Tracing:

Radiometry. Reflectance & Lighting. Solid Angle. Radiance. Radiance Power is energy per unit time

Photometric Stereo. Lighting and Photometric Stereo. Computer Vision I. Last lecture in a nutshell BRDF. CSE252A Lecture 7

EECS 487: Interactive Computer Graphics

Raytracing. COSC 4328/5327 Scott A. King

CS6670: Computer Vision

Interactive Methods in Scientific Visualization

Illumination and Shading - II

Rendering Equation & Monte Carlo Path Tracing I

Transcription:

INFOMAGR Advanced Graphics Jacco Bikker - November 2016 - February 2017 Lecture 7 - I x, x = g(x, x ) ε x, x + S ρ x, x, x I x, x dx Welcome!

Today s Agenda: Introduction

Advanced Graphics 3 Introduction Previously in Advanced Graphics The Rendering Equation: L o x, ω o = L E x, ω o + Ω f r x, ω o, ω i L i x, ω i cos θ i dω i which models light transport as it happens in the real world, by summing: Direct illumination: L E (x, ω o ) Indirect illumination, or reflected light: Ω f r x, ω o, ω i L i x, ω i cos θ i dω i We used quantities flux Φ (joules per second), radiance L (flux per m 2 per sr) and irradiance E (joules per second per m 2 ).

Advanced Graphics 4 Introduction Previously in Advanced Graphics Particle transport: As an alternative to discrete flux / radiance / irradiance, we can reason about light transport in terms of particle transport. Flux then becomes the number of emitted photons; Radiance the number of photons travelling through a unit area in a unit direction; Irradiance the number of photons arriving on a unit area. A BRDF tells us how many particles are absorbed, and how outgoing particles are distributed. The distribution depends on the incident and exitant direction.

Advanced Graphics 5 Introduction Previously in Advanced Graphics Probabilities: We can also reason about the behavior of a single photon. In that case, the BRDF tells us the probability of a photon being absorbed, or leaving in a certain direction.

Advanced Graphics 6 Introduction Previously in Advanced Graphics BRDFs: The BRDF describes how incoming light is absorbed or scattered. More accurately: for an incoming direction ω i and an outgoing direction ω o, it defines the relation between received irradiance and reflected radiance. A physically based BRDF has some important properties: f r ω o, ω i 0 f r ω o, ω i = f r ω i, ω o Ω f r ω o, ω i cos θ o dω o 1 n ω i Example: diffuse BRDF, f r ω o, ω i = albedo. π Note that the diffuse BRDF is view independent; ω o is irrelevant. It does however take into account ω i : this affects how radiance is converted to irradiance.

Advanced Graphics 7 Introduction Previously in Advanced Graphics Monte Carlo integration: Complex integrals can be approximated by replacing them by the expected value of a stochastic experiment. Soft shadows: randomly sample the area of a light source; Glossy reflections: randomly sample the directions in a cone; Depth of field: randomly sample the aperture; Motion blur: randomly sample frame time. In the case of the rendering equation, we are dealing with a recursive integral. Path tracing: evaluating this integral using a random walk.

Today s Agenda: Introduction

Advanced Graphics 9 Solving the Rendering Equation Let s start with direct illumination: For a screen pixel, diffuse surface point p with normal n is directly visible. What is the radiance travelling via p towards the eye? Answer: L o p, ω o = Ω f r p, ω o, ω i L d p, ω i cos θ i dω i ω o n ω i p

Advanced Graphics 10 Direct Illumination We can solve this integral using Monte-Carlo integration: Chose N random directions over the hemisphere for p Find the first surface in each direction by tracing a ray Sum the luminance of the encountered surfaces Divide the sum by N and multiply by 2π N L o p, ω o 2π N i=1 f r p, ω o, ω i L d p, ω i cos θ i ω o n ω i p

Advanced Graphics 11 Direct Illumination N L o p, ω o 2π f N r p, ω o, ω i L d p, ω i cos θ i=1 Questions: We integrate over the hemisphere, which has an area of 2π. Do not confuse this with the 1/ π factor in the BRDF, which doesn t compensate for the surface of the hemisphere, but the integral of cos θ over the hemisphere (π). Why do we multiply by 2π? What is the radiance L d (p, ω i ) towards p for e.g. a 100W light? What is the irradiance E arriving at p from this light? L is per sr; L d (p, ω i ) is proportional to the solid angle of the light as seen from p, so (cos θ o A Ld )/r 2. Note that the 100W flux is spread out over the area; irradiance is defined per m 2. ω o n p ω i

Advanced Graphics 12 Direct Illumination L o p, ω o = Ω f r p, ω o, ω i L d p, ω i cos θ i dω i In many directions, we will not find light sources. We can improve our estimate by sampling the lights separately. L o p, ω i = lights j=1 Ω f r p, ω o, ω i L d j p, ωi cos θ i dω i Obviously, sampling the entire hemisphere for each light is not necessary; we can sample the area of the light instead: L o p, ω i = lights j=1 A f r p, ω o, ω i L d j p, ωi C cos θ i dω i Here, C compensates for the fact that we now sample the area of the light source, instead of the hemisphere. The probability of stumbling onto an unoccluded light used to be proportional to solid angle; now it is always 1. C is therefore ~(cos θ o A Ld )/r 2.

Advanced Graphics 13 Direct Illumination lights L o p, ω i = j=1 A f r p, ω o, ω i L d j p, ωi C cos θ i dω i Using Monte-Carlo: N L o p, ω i lights 1 f N r p, ω o, p j L d p, p V p i=1 p A Ld j cos θ i cos θ o p p 2 where L d j is the direct light to p from random point p on random light j A Ld j is the area of this light source V p p is the mutual visibility between p and p.

Advanced Graphics 14 Direct Illumination We now have two methods to estimate direct illumination using Monte Carlo integration: 1. By random sampling the hemisphere: N L o p, ω o 2π f N r p, ω o, ω i L d p, ω i cos θ i i=1 2. By sampling the lights directly: L o p, ω i N lights 1 f N r p, ω o, p j L d p, p V p i=1 p A Ld j cos θ i cos θ o p p 2 For N =, these yield the same result.

Advanced Graphics 15 Direct Illumination We now have two methods to estimate direct illumination using Monte Carlo integration: 1. By random sampling the hemisphere: N L o p, ω o 2π f N r p, ω o, ω i L d p, ω i cos θ i i=1 2. By sampling the lights directly (three point notation): L o s p N lights 1 N i=1 f r s p q L d j p q V p q A Ld j cos θ i cos θ o p q 2 For N =, these yield the same result.

Advanced Graphics 16 N Verification L o p, ω o 2π N i=1 f r p, ω o, ω i L d p, ω i cos θ i Method 1 in a small C# ray tracing framework: In: Ray ray, with members O, D, N, t. Already calculated: intersection point I = O + t * D. Vector3 R = RTTools.DiffuseReflection( ray.n ); Ray raytohemisphere = new Ray( I + R * EPSILON, R, 1e34f ); Scene.Intersect( raytohemisphere ); if (raytohemisphere.objidx == LIGHT) { Vector3 BRDF = material.diffuse * INVPI; float cos_i = Vector3.Dot( R, ray.n ); return 2.0f * PI * BRDF * Scene.lightColor * cos_i; }

Advanced Graphics 17 Verification L o p, ω i lights 1 N i=1 Method 2 in a small C# ray tracing framework: // construct vector to random point on light Vector3 L = Scene.RandomPointOnLight() - I; float dist = L.Length(); L /= dist; float cos_o = Vector3.Dot( -L, lightnormal ); float cos_i = Vector3.Dot( L, ray.n ); if ((cos_o <= 0) (cos_i <= 0)) return BLACK; // light is not behind surface point, trace shadow ray Ray r = new Ray( I + EPSILON * L, L, dist - 2 * EPSILON ); Scene.Intersect( r ); if (r.objidx!= -1) return Vector3.Zero; // light is visible (V(p,p )=1); calculate transport Vector3 BRDF = material.diffuse * INVPI; float solidangle = (cos_o * Scene.LIGHTAREA) / (dist * dist); return BRDF * lightcount * Scene.lightColor * solidangle * cos_i; N f r p, ω o, p j L d p, p V p p A Ld j cos θ i cos θ o p p 2

Advanced Graphics 18 0.1s

Advanced Graphics 19 0.5s

Advanced Graphics 20 2.0s

Advanced Graphics 21 30.0s

Advanced Graphics 22 Rendering using Monte Carlo Integration In the demonstration, we sampled each light using only 1 sample. The (very noisy) result is directly visualized. To get a better estimate, we average the result of several frames (and thus: several samples). Observations: 1. The light sampling estimator is much better than the hemisphere estimator; 2. Relatively few samples are sufficient for a recognizable image; 3. Noise reduces over time, but we quickly get diminishing returns.

Advanced Graphics 23 Indirect Light Returning to the full rendering equation: We know how to evaluate direct lighting: What remains is indirect light. This is the light that is not emitted by the surface in direction ω i, but reflected.

Advanced Graphics 24 y Indirect Light x y Let s expand / reorganize this: z L o x, ω o x = L E x, ω o x + Ω L E y, ω o y fr x, ω o x, ω i x cos θ i x dω i x direct light + Ω Ω L E z, ω o z f r y, ω o y, ωi y cos θi y fr x, ω o x, ω i x cos θ i x dω i x dω i y 1 st bounce + Ω Ω Ω 2 nd bounce

Advanced Graphics 25 y Indirect Light x One particle finding the light via a surface: I, N = Trace( ray ); R = DiffuseReflection( N ); lightcolor = Trace( new Ray( I, R ) ); return dot( R, N ) * albedo * lightcolor * 2π; π One particle finding the light via two surfaces: I1, N1 = Trace( ray ); R1 = DiffuseReflection( N1 ); I2, N2 = Trace( new Ray( I1, R1 ) ); R2 = DiffuseReflection( N2 ); lightcolor = Trace( new Ray( I2, R2 ) ); return dot( R1, N1 ) * albedo π * 2π * dot( R2, N2 ) * albedo π y * 2π * lightcolor; z

Advanced Graphics 26 y Algorithm x Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.nohit) return BLACK; // terminate if we hit a light source if (material.islight) return material.emittance; // continue in random direction R = DiffuseReflection( N ); Ray newray( I, R ); // update throughput BRDF = material.albedo / PI; Ei = Sample( newray ) * dot( N, R ); // irradiance return PI * 2.0f * BRDF * Ei; } y z

Advanced Graphics 27

Advanced Graphics 28

Advanced Graphics 29

Advanced Graphics 30

Advanced Graphics 31 Particle Transport The random walk is analogous to particle transport: a particle leaves the camera at each surface, energy is absorbed proportional to 1-albedo ( surface color ) at each surface, the particle picks a new direction at a light, the path transfers energy to the camera. In the simulation, particles seem to travel backwards. This is valid because of the Helmholtz reciprocity. Notice that longer paths tend to return less energy. Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.nohit) return BLACK; // terminate if we hit a light source if (material.islight) return emittance; // continue in random direction R = DiffuseReflection( N ); Ray r( I, R ); // update throughput BRDF = material.albedo / PI; Ei = Sample( r ) * (N R); return PI * 2.0f * BRDF * Ei; }

Advanced Graphics 32 Particle Transport - Mirrors Handling a pure specular surface: A particle that encounters a mirror continues in a deterministic way. Question: What happens at a red mirror? What happens if a material is only half reflective? Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.nohit) return BLACK; // terminate if we hit a light source if (material.islight) return emittance; // surface interaction if (material.ismirror) { // continue in fixed direction Ray r( I, Reflect( N ) ); return material.albedo * Sample( r ); } // continue in random direction R = DiffuseReflection( N ); BRDF = material.albedo / PI; Ray r( I, R ); // update throughput Ei = Sample( r ) * (N R); return PI * 2.0f * BRDF * Ei; }

Advanced Graphics 33 Particle Transport - Glass Handling dielectrics: Dielectrics reflect and transmit light. In the ray tracer, we handled this using two rays. A particle must chose. The probability of each choice is calculated using the Fresnel equations. Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.nohit) return BLACK; // terminate if we hit a light source if (material.islight) return emittance; // surface interaction if (material.ismirror) { // continue in fixed direction Ray r( I, Reflect( N ) ); return material.albedo * Sample( r ); } // continue in random direction R = DiffuseReflection( N ); BRDF = material.albedo / PI; Ray r( I, R ); // update throughput Ei = Sample( r ) * (N R); return PI * 2.0f * BRDF * Ei; }

Advanced Graphics 34

Advanced Graphics 35

Today s Agenda: Introduction

INFOMAGR Advanced Graphics Jacco Bikker - November 2016 - February 2017 END of next lecture: Variance Reduction

Advanced Graphics 38 Solid Angle A few words on solid angle: As mentioned in lecture 5, solid angle is measured in steradians. Where radians are the length of an arc on the unit circle subtended by two directions, steradians are the surface on the unit sphere subtended by a shape. In this lecture, we used: A cos θ r 2, which is only an approximation, except when the shape is a segment of a sphere and cos θ = 1. For r A, this approximation is good enough.

Advanced Graphics 39 Additional literature: Slides for lecture 9 of the Advanced Computer Graphics course of the University of Freiburg, by Matthias Teschner: http://cg.informatik.uni-freiburg.de/course_notes/graphics2_09_pathtracing.pdf Blog: A graphics guy s note: https://agraphicsguy.wordpress.com Monte Carlo, Path Hanrahan: http://cs.brown.edu/courses/cs224/papers/mc_pathtracing.pdf - Theoretical Foundation, by Vidar Nelson: http://www.vidarnel.com/post/path_tracing Importance Sampling for Production Rendering, SIGGRAPH 2010 course: http://igorsklyar.com/system/documents/papers/4/fiscourse.comp.pdf Please share additional resources on the forum.