PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION

Similar documents
Computer Graphics Global Illumination (2): Monte-Carlo Ray Tracing and Photon Mapping. Lecture 15 Taku Komura

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

CSE168 Computer Graphics II, Rendering. Spring 2006 Matthias Zwicker

Path Tracing - Literature Research. Rick de Bruijne May 17, 2011

path tracing computer graphics path tracing 2009 fabio pellacini 1

Monte Carlo Path Tracing

Specular reflection. Dielectrics and Distribution in Ray Tracing. Snell s Law. Ray tracing dielectrics

Path Tracing. Michael Doggett Department of Computer Science Lund university Michael Doggett

Monte Carlo Path Tracing

INTRODUCTION TO RENDERING TECHNIQUES

Photon Mapping Made Easy

PHOTON mapping is a practical approach for computing global illumination within complex

Chapter 10. Bidirectional Path Tracing

CS 431/636 Advanced Rendering Techniques"

A Short Introduction to Computer Graphics

Path tracing everything. D.A. Forsyth

Dhiren Bhatia Carnegie Mellon University

Advanced Computer Graphics. Rendering Equation. Matthias Teschner. Computer Science Department University of Freiburg

Computer Animation: Art, Science and Criticism

Teaching Introductory Computer Graphics Via Ray Tracing

A Theoretical Framework for Physically Based Rendering

The RADIANCE Lighting Simulation and Rendering System

Efficient Implementation of Bi-directional Path Tracer on GPU

Rendering Area Sources D.A. Forsyth

Computer Applications in Textile Engineering. Computer Applications in Textile Engineering

Mathematics for Global Illumination

PRODUCT LIFECYCLE MANAGEMENT COMPETENCY CENTRE RENDERING. PLMCC, JSS Academy of Technical Education, Noida Rendering 1 of 16

Thea Omni Light. Thea Spot Light. Light setup & Optimization

Deferred Shading & Screen Space Effects

So, you want to make a photo-realistic rendering of the Earth from orbit, eh? And you want it to look just like what astronauts see from the shuttle

SkillsUSA 2014 Contest Projects 3-D Visualization and Animation

Lezione 4: Grafica 3D*(II)

Course Overview. CSCI 480 Computer Graphics Lecture 1. Administrative Issues Modeling Animation Rendering OpenGL Programming [Angel Ch.

Path Tracing Overview

Light Control and Efficacy using Light Guides and Diffusers

Using Photorealistic RenderMan for High-Quality Direct Volume Rendering

Introduction to Computer Graphics

Lighting & Rendering in Maya: Lights and Shadows

Adding Animation With Cinema 4D XL

REAL-TIME IMAGE BASED LIGHTING FOR OUTDOOR AUGMENTED REALITY UNDER DYNAMICALLY CHANGING ILLUMINATION CONDITIONS

ADVANCED THEORIES FOR CG LIGHTING

Volumetric Path Tracing

GUI GRAPHICS AND USER INTERFACES. Welcome to GUI! Mechanics. Mihail Gaianu 26/02/2014 1

IN previous chapters we assumed that all lighting interactions occurred at surfaces. In particular,

CS 371 Project 5: Midterm Meta-Specification

Contents Rendering Reference

Cork Education and Training Board. Programme Module for. 3 Dimensional Computer Graphics. Leading to. Level 5 FETAC

COMP175: Computer Graphics. Lecture 1 Introduction and Display Technologies

CUBE-MAP DATA STRUCTURE FOR INTERACTIVE GLOBAL ILLUMINATION COMPUTATION IN DYNAMIC DIFFUSE ENVIRONMENTS

Making natural looking Volumetric Clouds In Blender 2.48a

Acceleration Methods for Ray Tracing based Global Illumination

How To Improve Efficiency In Ray Tracing

ABS 731 Lighting Design & Technology. Spring 2006

Introduction Week 1, Lecture 1

Hi everyone, my name is Michał Iwanicki. I m an engine programmer at Naughty Dog and this talk is entitled: Lighting technology of The Last of Us,

A Ray Tracing Solution for Diffuse Interreflection

MCRT: L6. Initial weight of packet: W = L / N MC At each interaction multiply weight by probability of scattering: W = a W

Approval Sheet. Interactive Illumination Using Large Sets of Point Lights

Hunting Ghosts. For the development of imaging optical STRAY LIGHT ANALYSIS IN IMAGING OPTICS

Instructor. Goals. Image Synthesis Examples. Applications. Computer Graphics. Why Study 3D Computer Graphics?

DYNAMIC RANGE IMPROVEMENT THROUGH MULTIPLE EXPOSURES. Mark A. Robertson, Sean Borman, and Robert L. Stevenson

Optical Design Tools for Backlight Displays

Maya 2014 Still Life Part 1 Texturing & Lighting

Waves Sound and Light

Monte Carlo (MC) Model of Light Transport in Turbid Media

Introduction to Computer Graphics. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Getting Started with iray in 3ds Max 2014

Introduction to Computer Graphics. Reading: Angel ch.1 or Hill Ch1.

MicroStation Visualization V8i (SELECTseries 1) Luxology Update 1

One Step Closer to a Fully Realistic 3D World on the Consumer PC A White Paper on the 3dfx T-Buffer

Improved predictive modeling of white LEDs with accurate luminescence simulation and practical inputs

Computer Animation of Extensive Air Showers Interacting with the Milagro Water Cherenkov Detector

Data Visualization Study at Earth Simulator Center

Monte Carlo Ray Tracing

Advanced Rendering for Engineering & Styling

3D Producer - Reader

Design, Analysis, and Optimization of LCD Backlight Unit using Ray Tracing Simulation

Lecture Notes, CEng 477

Treasure Hunt. Lecture 2 How does Light Interact with the Environment? EMR Principles and Properties. EMR and Remote Sensing

Practical Calculation of Expected and Unexpected Losses in Operational Risk by Simulation Methods

VARIANCE REDUCTION TECHNIQUES FOR IMPLICIT MONTE CARLO SIMULATIONS

Reflection and Refraction

Sensor Modeling for a Walking Robot Simulation. 1 Introduction

GRAFICA - A COMPUTER GRAPHICS TEACHING ASSISTANT. Andreas Savva, George Ioannou, Vasso Stylianou, and George Portides, University of Nicosia Cyprus

Using simulation to calculate the NPV of a project

Graphical displays are generally of two types: vector displays and raster displays. Vector displays

GRADES 7, 8, AND 9 BIG IDEAS

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 9 The Game Engine

Computer Graphics. Introduction. Computer graphics. What is computer graphics? Yung-Yu Chuang

Accelerating the bidirectional path tracing algorithm using a dedicated intersection processor

Photo Studio. Site Map Preface What`s New? Getting Started Basic Tasks Advanced Tasks Workbench Description Customizing Glossary Index

CSE452 Computer Graphics

mental ray Production Shader Library

Parallel Ray Tracing using MPI: A Dynamic Load-balancing Approach

CAUSTICS are complex patterns of shimmering

Transcription:

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION ROBERT CARR AND BYRON HULCHER Abstract. In this paper we detail the implementation of a path tracing renderer, providing a non-biased solution to the rendering equation. Path tracing is an algorithm, which in attempting to model the behavior of light as closely as possible, accurately captures eects such as: Caustics, Soft Shadows, and Ambient Occlusion. The algorithm may be extended with techniques from distribution ray tracing in order to simulate eects such as glossy reections, depth of eld, and motion blur. In this paper we detail a practical implementation of a C++ path tracer. Part 1. Background Introduction Rendering techniques may be largely divided in to two categories: Real time non-photorealistic algorithms (such as scanline type approaches), and photorealistic methods attempting to accurately simulate the transport of light. Photorealistic rendering methods are largely described by the ray tracing category of algorithms, introduced in Whitted, 1980[8]. In nature light is emitted from Date: Mon, May 10. 2009. Key words and phrases. Path Tracing, Rendering Equation, Ray Tracing. Figure 0.1. Image produced by path tracer illustrating caustic eects. 1

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 2 Figure 0.2. Comparison of path and ray traced images, note the caustic eects present in the path traced result. a light source, and eventually through a series of surface interactions (absorption, reection, refraction, or uorescence) may reach the a viewer. Ray tracing approximates this interaction by generating rays from the eye, to each pixel, and nding which object we intersect. Then by using object properties, the shading at that point may be determined. The genius in the algorithm, is perhaps it's recursive nature, allowing intersections to spawn reection, refraction, or shadow rays, in order to model some global eects. Ray tracing, while able to create very realistic images, fails to capture many non local eects, such as: Caustics, and Color Bleeding. Furthermore, while ray tracing may simulate eects such as soft shadows[1], we are perhaps now begining to deviate from our goal of photorealism. The Rendering Equation The rendering equation refers to an integral equation for computing the radiance at a point from a certain direction. The rendering equation was introduced to the eld of computer graphics in Kajiya's 1986 SIGRAPH paper[4]. Given in the following form: ˆ L 0 (x, ω, λ, t) = L e (x, ω, λ, t) + f r (x, ω, ω, λ, t)l i (x, ω, λ, t)( ω n)dω Ω While recent to computer graphics, the physical basis for the equation is relatively simple, and based on the law of conservation of energy. We say that the radiance at a point viewed from a particular direction, is the sum of the emitted light, and the reected light, where the reected light is the sum of all incoming light, shaded by the surface properties, and multiplied by the cosine of the incident angle. True photorealism is approached when solving, or closely approximating the rendering equation. Such an approach will allow us to accurately capture global illumination eects based on the interaction of diuse surfaces, an element missed in the classical ray tracing algorithm. The most popular approach (preferred for performance) is based on nite element methods, and is referred to as the radiosity algorithm[3]. This is often used to supplement an existing ray tracerin this paper however, we intend to explore the Monte Carlo methods of solution, perhaps best characterized by the path tracing algorithm.

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 3 Figure 0.3. Ray and Path traced renderings of the Cornell box. Note the color bleeding eects visible in the path traced rendering. This eect requires modelling of the interaction of light from light sources between diuse objects. Path Tracing The path tracing algorithm is described in it's earliest form, in Kajiya's 1986 paper on The Rendering Equation[4], and provides a Monte Carlo method of solving the Rendering Equation. Path tracing operates in a similar manner to ray tracing, however in fact traces the entire path of light rays: From the camera to a light source. It is important to distinguish this from the ray tracing approach. In ray tracing, upon intersection with a diuse surface, lights are directly sampled in order to determine shading. In path tracing, we spawn a random ray within the hemisphere of the object, and trace until we hit a light. In general it is quite unlikely that a path will intersect a light, and so we continue to rene our image by averaging multiple image samples. This is perhaps the curse of path tracing, in that most traced paths do not contribute to our rendering, and we must use a large number of samples to obtain a suitably noise free image. Path tracing however, has many advantages to other rendering algorithms as well, this can be demonstrated by considering the kinds of paths that certain ray tracing techniques, using a convenient notation proposed by Peter Shirley (can't nd original citation). We will describe components of paths as follows: E: the eye. L: the light. D: diuse interaction G: glossy reection S: specular reection or refraction Then we can describe the paths generated by algorithms using a regular expression notation: Ray Casting Recursive Ray Tracing Radiosity Path Tracing E(D G)L E[S ](D G)L ED L E[(D G S) + (D G)]L We can see then for example, that while recursive ray tracing will trace paths of any length, all must begin with a mirror reection or refraction. Furthermore consider a path of the form E(D G)S L, describing the paths which lead to caustic

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 4 Figure 0.4. Comparison of renderings at: 100, 250, 1000, 2500, 5000 and 10000 samples. eects. Even radiosity fails to generate these eects 1. Path tracing is shown to have an unbiased nature in Kajiya, that is to say as the number of samples approaches innity, the solution converges correctly. In our experience, while an image may become quickly recognizable, it may take many thousand samples to achieve an acceptably low level of noise. Part 2. Basic Implementation Scene Definition and data structures Before implementing a path tracer, we must rst have a way of dening what we wish to render. Our implementation contains a RayTracer object, which contains a mesh composed of primitives. Primitives are assigned materials, which describes the diuse, reective, and emittive colors of the object, along with the index of refraction. Primitives implement an Primitive::Intersectmethod, which is used to determine intersection of a ray with primitive, and if applicable return hit information. For primitives such as spheres, this is a simple matter of substiting equations and is described in more detail in the recursive ray tracing paper[8]. Rendering Loop The overall rendering loop of our tracer, is described in pseudo code as follows: def TracePixel ( i, j ) : r = generate_ray ( i, j ) r eturn TracePath ( r ) def render ( ) : samples [ width h e i g h t ] = {0,} f o r number_of_samples : 1 Though this may be approximated using techniques such as Photon Mapping as in Global Illimunation Using Photon Maps, Henrik Wann Jensen, 1996.

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 5 f o r i = 0 to h e i g h t : f o r j = 0 to width : samples [ width i+j ]+= TracePath ( i, j )/ number_of_samples save_samples ( ) ; In addition, we keep track of a running average of time per sample in order to compute progress estimates. Diffuse Interactions To implement the logic of path tracing, we will start with diuse interactions, the algorithm dictates that when impacting a diuse surface, we emit a ray in a random direction constrained within the hemisphere of our surface normal. This may be described as follows: def CastRay ( ray ) : # I n t e r s e c t ray with scene p r i m i t i v e s # and return h i t i n f o r m a t i o n f o r # n e a r e s t i n t e r s e c t i o n. d e f TracePath ( ray, bounce_count ) : ( hit, m a t e r i a l ) = CastRay ( ray ) answer = Color ( 0, 0, 0 ) i f h i t == n u l l : r eturn answer i f m a t e r i a l. emittance. Length ( ) > 0 : r eturn emittance ; i f m a t e r i a l. d i f f u s e. Length ( ) > 0 : d i r = RandomDirectionInHemisphere ( h i t. normal ) n = Ray( point+d i r.00001, d i r ) dp = d i r. Dot3 ( h i t. normal ) r eturn Some points of note: answer += TracePath ( n, bounce_count +1) m a t t e r i a l. d i f f u s e dp answer When constructing our new ray, the slight oset is used to avoid oating point error Incoming light is shaded according to cosine, as in the rendering equation. Already we can begin to create some renderings: Mirror Reflections To calculate the reected ray R from the intersection of a ray (with incident direction V ) with a surface (with normal at intersection N), we use the following formula: R = V 2( V N) N

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 6 Figure 0.5. A rendering of the Cornell Box at 1000 samples, note the eects from diuse surface interaction. Figure 0.6. A Path Traced reective sphere, and an example of oating point error caused by not using an epsilon. In the framework of our code this looks something like the following addition to our TracePath function. i f m a t e r i a l. r e f l e c t i o n. Length ( ) > 0 : d i r = ray. d i r e c t i o n (2 ray. d i r e c t i o n. dot ( h i t. normal ) ) h i t. normal n = Ray( point+d i r.00001, d i r ) answer += TracePath (n, bounce_count+1) m a t e r i a l. r e f l e c t i o n We can now produce a rendering demonstrating our results: Refraction Refraction refers to the eect of a change in direction in wave due to a change in speed, perhaps most commonly observed in light passing from one medium to a second. The bending of the rays depends on a property of the two mediums referred to as the refractive index, dened for a medium m as: η = c/c m

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 7 Figure 0.7. A refractive sphere with c denoting the speed of light in a vacuum, and c m denoting the speed of light in m. For example, air has a refractive index of approximately 1.0003, while the human cornea has an index of 1.38[6]. For a detailed discussion of the mathematics, we found the paper Reections and Refractions in Ray Tracing[2] to provide a satisfactory description. To implement this in our TracePath, we must rst extend the function with an additional argument: last_index, or the index of the material which a spawned ray will travel through, we give this a default value of 1.0003 for air. To compute the correct normal, it is important to dierentiate from intersections entering an object from another material, and intersections originating from inside the same object, we do this by having our intersection routine return an integer value: 0 for miss, 1 for hit, and -1 for hit inside the primitive. Implementation in our TracePath function is as follows: i f ( h i t. m a t e r i a l. r e f r a c t i o n!= 0 ) : index = h i t. m a t e r i a l. r e f r a c t i o n n = last_index / index N = h i t. normal i n t e r s e c t ; c o s I = N. Dot3 ( ray. d i r e c t i o n ) cost2 = 1.0 n n (1.0 c o s I c o s I ) i f cost2 > 0. 0 : d i r = ( n ray. d i r e c t i o n )+(n cosi s q r t ( cost2 ) ) N n = Ray( point+d i r.00001, d i r ) answer += TracePath (n, bounce_count+1, index ) An example image demonstrating refraction: Part 3. Implementation Improvements Russian Roulette In order to terminate paths which are likely to never hit lights, we implement a Russian Roulette, which introduces a random chance of killing paths with length

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 8 Figure 0.8. A refractive sphere with Beer's Law greater than a variable number of bounces, this looks something like the following at the beginning of our TracePath i f ( ( bounce_count > max_bounces ) && ( RandomDouble ( ) < max( d i f f u s e. r, d i f f u s e. g, d i f f u s e. b ) : r eturn Color ( 0, 0, 0 ) d i f f u s e = d i f f u s e 1/p Beers Law In fact, our prior implementation of refraction was somewhat incomplete. To accurately shade our materials, we must respect Beer's Law, which states that the eect of a colored medium is stronger over longer distances. This involves changing our refraction calculation as: r c o l, d i s t a n c e = TracePath (n, bounce_count+1, index ) absorb = d i f f u s e 0.15 d i s t a n c e transparency = Color ( exp ( absorb. x ), exp ( absorb. y ), exp ( absorb. z ) Implementing this dramatically improves results as shown in Figure 0.8. Ambient Lighting During testing, we often found it was frustrating to slowly wait for images to converge, and so we implemented an ambient lighting term, as follows in TracePath: i f i n t e r s e c t == f a l s e : i f bounce_count >= 1 : r eturn ambient_light e l s e : r eturn Color ( 0, 0, 0 )

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 9 Figure 0.9. Reective ring at 50 samples with and without ambient lighting term. Figure 0.10. Rendering of reective ring at 200 samples with and without hybrid rendering. While drastically reducing the quality of images at higher noise ratios, it can be used to obtain quickly converging results while testing, as in Figure 0.9. Hybrid Tracing For another attempt at improving convergence, we implemented a hybrid tracing method, which generates a nal image by averaging a recursively ray traced image, and a path traced image. This allows us to quickly create ray traced images preserving some global eects: Distribution Ray Tracing Effects The 1984 paper Distributed Ray Tracing describes a renement of the ray tracing algorithm allowing it so simulate soft phenomena[1]. Essentially by oversampling various ray parameters, various eects are described. Glossy Reections. In the real world, objects rarely reect in perfect mirror fashion, consider for example the surface of a matte-poster, likely to give a very blurry reection. This is the material property referred to as: Gloss. To simulate gloss as described by Cook, we scatter a number of reection samples in a cone around the mirror direction to compute our reected color. Each material is given a gloss property between 0 and 1, indicating the degree of scattering (with 0 being mirror reection, and 1 being in fact a diuse surface (with enough samples...). Additional Distribution Ray Tracing Eects. Many other eects can be implemented with a similar technique: Depth of eld, by sampling the ray starting positions over a lens. Antialiasing, by multisampling within pixels.

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 10 Figure 0.11. Cornell box, containing a sphere with a gloss coeffecient of.3 Motion blur, by multisampling over time. However, we ran out of time to complete these additional eects for our project. Parallel Rendering With recent versions of the g++ compiler, path tracing samples will automatically be computed in paralllel with our implementation, this is achieved via the use of the OpenMP framework, with the following pragma annotating our outer rendering loop: #pragma omp p a r a l l e l f o r s c h e d u l e ( s t a t i c ) Near linear speedud with number of processors is observed. Part 4. Implementation Notes Future Possibilities Despite the core simplicity of the path tracing algorithm, there is a lot left that we could implement. Several algorithms based on path tracing exist, designed to improve the convergence time including bidirectional path-tracing[5], an algorithm which uses a combination of eye->light and light->eye rays to accelerate convergence, and Metropolis light transport[7], an algorithm which perturbs previously computed paths to improve convergence. A clear gap in our path tracer is proper support of distribution eects, such as depth of eld and antialiasing. With the long render times however, we just ran out of time to properly implement and test these features. I believe that multisample antialiasing would drastically improve the resulting image quality. Several conveniences could be added to the codebase, such as an iterative preview of the image up to our current sample. References [1] Porter Cook and Carpenter. Distributed ray tracing. 1984. [2] Bram de Greve. Reections and refractions in ray tracing. 2004. [3] Goral et al. Modeling the interaction of light between diuse surfaces. 1984.

PATH TRACING: A NON-BIASED SOLUTION TO THE RENDERING EQUATION 11 [4] Kajiya. The rendering equation. 1986. [5] Eric P. Lafortune. Bi-directional path tracing. 1993. [6] robinwood.com. Refractive index list of substances. [7] Eric Veah and Leonidas J. Guibas. Metropolis light transport. 1997. [8] Turned Whitted. An improved illumination model for shaded display. 1980. E-mail address: racarr@gnome.org, byronhulcher@gmail.com