Lecture 10: Ray tracing

Similar documents
Lecture 11: Ray tracing (cont.)

Lecture 17: Recursive Ray Tracing. Where is the way where light dwelleth? Job 38:19

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

CS 428: Fall Introduction to. Raytracing. Andrew Nealen, Rutgers, /18/2009 1

Lighting and Shading

MIT Ray Tracing Ray Tracing

Ray Tracing. Last Time? Reading for Today. Reading for Today

CS354 Computer Graphics Ray Tracing. Qixing Huang Januray 24th 2017

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

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

Supplement to Lecture 16

COMP 175 COMPUTER GRAPHICS. Lecture 11: Recursive Ray Tracer. COMP 175: Computer Graphics April 9, Erik Anderson 11 Recursive Ray Tracer

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required:

Visual cues to 3D geometry. Light Reflection and Advanced Shading. Shading. Recognizing materials. size (perspective) occlusion shading

Illumination Algorithms

COMP371 COMPUTER GRAPHICS

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

Ray Tracing. Quiz Discussion. Announcements: Final Projects. Last Time? Durer s Ray Casting Machine. Today

Ray Tracing. Last Time? Today. Ray Casting. Durer s Ray Casting Machine. Reading for Today

Recursive Ray Tracing. Ron Goldman Department of Computer Science Rice University

Ø Sampling Theory" Ø Fourier Analysis Ø Anti-aliasing Ø Supersampling Strategies" Ø The Hall illumination model. Ø Original ray tracing paper

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

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

Reading. Ray Tracing. Eye vs. light ray tracing. Geometric optics. Required: Watt, sections , (handout) Further reading:

Indirect Illumination

Intro to Ray-Tracing & Ray-Surface Acceleration

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

Lecture 7 - Path Tracing

Ray Tracing. Kjetil Babington

Photorealism: Ray Tracing

Lecture 19: All Together with Refraction

Recall: Basic Ray Tracer

Ray-Tracing. Misha Kazhdan

Sung-Eui Yoon ( 윤성의 )

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

Ray Tracing. CS334 Fall Daniel G. Aliaga Department of Computer Science Purdue University

Ray Tracing. Announcements: Quiz. Last Time? Today. Durer s Ray Casting Machine. Ray Casting

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

Lighting affects appearance

Effects needed for Realism. Computer Graphics (Fall 2008) Ray Tracing. Ray Tracing: History. Outline

Geometric optics. The University of Texas at Austin CS384G Computer Graphics Don Fussell

Raytracing. COSC 4328/5327 Scott A. King

Lecture 18: Primer on Ray Tracing Techniques

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Implementation Issues

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

Ray Tracing. Johns Hopkins Department of Computer Science Course : Rendering Techniques, Professor: Jonathan Cohen

Indirect Illumination

Ray tracing. EECS 487 March 19,

Shading, Advanced Rendering. Week 7, Wed Feb 28

Reflection and Refraction

CS-184: Computer Graphics. Administrative

Reflection and Refraction

Consider a partially transparent object that is illuminated with two lights, one visible from each side of the object. Start with a ray from the eye

Global Illumination. Connelly Barnes CS 4810: Graphics

03 RENDERING PART TWO

The Rendering Equation and Path Tracing

COMP30019 Graphics and Interaction Ray Tracing

CPSC GLOBAL ILLUMINATION

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

Ray Tracing: Special Topics CSCI 4239/5239 Advanced Computer Graphics Spring 2018

Complex Shading Algorithms

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Lighting and Reflectance COS 426

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

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

Global Illumination. COMP 575/770 Spring 2013

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

Computer Graphics. - Ray Tracing I - Marcus Magnor Philipp Slusallek. Computer Graphics WS05/06 Ray Tracing I

EDAN30 Photorealistic Computer Graphics. Ray tracing. Michael Doggett Department of Computer Science Lund university. Copyright 2011 Michael Doggett

CS 325 Computer Graphics

Ray Tracing. Outline. Ray Tracing: History

The Rendering Equation. Computer Graphics CMU /15-662

Monte Carlo Ray-tracing and Rendering

Last Time? Ray Casting. Administrivia: Lab & Office Hours. Notes on Assignments. Ray Casting. Overview of Today

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

A Little Background. Motivation. Motivation

MITOCW MIT6_172_F10_lec18_300k-mp4

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

Global Illumination The Game of Light Transport. Jian Huang

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

Computer Graphics. Shi-Min Hu. Tsinghua University

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

Movie: For The Birds. Announcements. Ray Tracing 1. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Raytracing CS148 AS3. Due :59pm PDT

Illumination. Courtesy of Adam Finkelstein, Princeton University

Illumination. Michael Kazhdan ( /657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

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

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

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

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

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

Introduction to Visualization and Computer Graphics

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

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Transcription:

Interactive Computer Graphics Lecture 10: Ray tracing Graphics Lecture 10: Slide 1 Some slides adopted from H. Pfister, Harvard Graphics Lecture 10: Slide 2 Direct and Global Illumination Direct illumination: A surface point receives light directly from all light sources in the scene. Computed by the direct illumination model. Global illumination: A surface point receives light after the light rays interact with other objects in the scene. Points may be in shadow. Rays may refract through transparent material. Computed by reflection and transmission rays. Graphics Lecture 10: Slide 3 Graphics Lecture 10: Slide 4 1

Albrecht Dürer s Ray Casting Machine Albrecht Dürer, 16 th century Arthur Appel, 1968 On calculating the illusion of reality, 1968 Cast one ray per pixel (ray casting). For each intersection, trace one ray to the light to check for shadows Only a local illumination model Developed for pen-plotters Graphics Lecture 10: Slide 5 Graphics Lecture 10: Slide 6 Ray casting Ray Casting cast ray Intersect all objects color = ambient term For every light cast shadow ray col += local shading term Graphics Lecture 10: Slide 7 Graphics Lecture 10: Slide 8 2

Turner Whitted, 1980 Turner Whitted, 1980 An Improved Illumination Model for Shaded Display, 1980 First global illumination model: An object s color is influenced by lights and other objects in the scene Simulates specular reflection and refractive transmission Graphics Lecture 10: Slide 9 Graphics Lecture 10: Slide 10 Recursive ray casting trace ray Intersect all objects color = ambient term For every light cast shadow ray col += local shading term If mirror col += k_refl * trace reflected ray If transparent col += k_trans * trace transmitted ray Does it ever end? Stopping criteria: Recursion depth: Stop after a number of bounces Ray contribution: Stop if reflected / transmitted contribution becomes too small Graphics Lecture 10: Slide 11 Graphics Lecture 10: Slide 12 3

Ray tracing: Primary rays For each ray we need to test which objects are intersecting the ray: If the object has an intersection with the ray we calculate the distance between viewpoint and intersection If the ray has more than one intersection, the smallest distance identifies the visible surface. Primary rays are rays from the view point to the nearest intersection point Local illumination is computed as before: Ray tracing: Secondary rays Secondary rays are rays originating at the intersection points Secondary rays are caused by rays reflected off the intersection point in the direction of reflection rays transmitted through transparent materials in the direction of refraction shadow rays Graphics Lecture 10: Slide 13 Graphics Lecture 10: Slide 14 Recursive ray tracing: Putting it all together Illumination can be expressed as Recursive Ray Tracing: Ray Tree primary ray primary ray secondary rays Graphics Lecture 10: Slide 15 Graphics Lecture 10: Slide 16 4

Precision Problems Precision Problems In ray tracing, the origin of (secondary) rays is often on the surface of objects Theoretically, the intersection point should be on the surface Practically, calculation imprecision creeps in, and the origin of the new ray is slightly beneath the surface Result: the surface area is shadowing itself Graphics Lecture 10: Slide 17 Graphics Lecture 10: Slide 18 ε to the rescue... Check if t is within some epsilon tolerance: if abs(µ) < ε point is on the surface else point is inside/outside Choose the ε tolerance empirically Move the intersection point by epsilon along the surface normal so it is outside of the object Check if point is inside/outside surface by checking the sign of the implicit (sphere etc.) equation Mirror reflection Compute mirror contribution Cast ray in direction symmetric wrt. normal Multiply by reflection coefficient (color) Graphics Lecture 10: Slide 19 Graphics Lecture 10: Slide 20 5

Mirror reflection Mirror reflection Don t for get to add epsilon to the ray primary ray n secondary ray v φ in φ out v Graphics Lecture 10: Slide 21 Graphics Lecture 10: Slide 22 Mirror reflection To calculate illumination as a result of reflections calculate the direction of the secondary ray at the intersection of the primary ray with the object. given that n is the unit surface normal v is the direction of the primary ray v is the direction of the secondary ray as a result of reflections v ' = v " ( 2v! n) n Mirror reflection The v, v and n are unit vectors and coplanar so: v = α v + β n Taking the dot product with n yields the eq.: n v = α v n + β = v n Requiring v to be a unit vector yields the second eq.: 1 = v v = α 2 + 2 α β v n + β 2 Solving both equations yields: v ' = v " ( 2v! n) n Graphics Lecture 10: Slide 23 Graphics Lecture 10: Slide 24 6

Transparency Compute transmitted contribution Cast ray in refracted direction Multiply by transparency coefficient Refraction The angle of the refracted ray can be determined by Snell s law: k 1 sin(! 1) = k2 sin(! 2) η 1 is a constant for medium 1 η 2 is a constant for medium 2 φ 1 is the angle between the incident ray and the surface normal φ 2 is the angle between the refracted ray and the surface normal v Medium 2 (eg glass) n φ 1 Medium 1 (eg air) φ 2 v Graphics Lecture 10: Slide 25 Graphics Lecture 10: Slide 26 Refraction Refraction In vector notation Snell s law can be written: k1( v! n) = k2( v'! n) The direction of the refracted ray is v " = # %, 1 (n$ v) 2 + # 2 % ( / ( '. 2 ' * +1 + n$ v1 # 2. & # - 1 ) 1 $ n + v * ' * & 0 ) This equation only has a solution if % (n" v) 2 >1# $ ( 2 ' * & ) This illustrates the physical phenomenon of the limiting angle: if light passes from one medium to another medium whose index of refraction is low, the angle of the refracted ray is greater than the angle of the incident ray if the angle of the incident ray is large, the angle of the refracted ray is larger than 90 o the ray is reflected rather than refracted $ 1 2 Graphics Lecture 10: Slide 27 Graphics Lecture 10: Slide 28 7

Refraction Make sure you know whether you are entering or leaving the transmissive material Amount of reflection and refraction Traditional (hacky) ray tracing Constant coefficient reflectioncolor Component per component multiplication Better: Mix reflected and refracted light according to the Fresnel factor. L = k fresnel L reflected + (1" k fresnel )L refracted Graphics Lecture 10: Slide 29 Graphics Lecture 10: Slide 30 Fresnel factor Fresnel factor More reflection at grazing angle Graphics Lecture 10: Slide 31 Graphics Lecture 10: Slide 32 8

Schlick s Approximation Example Schlick s approximation k fresnel (") = k fresnel (0) + (1# k fresnel (0))(1# (n$ l)) 5 k fresnel (0) = Fresnel factor at zero degrees Choose k fresnel (0) = 0.8, this will look like stainless steel Graphics Lecture 10: Slide 33 Graphics Lecture 10: Slide 34 How do we add shadows? How do we add shadows? Graphics Lecture 10: Slide 35 Graphics Lecture 10: Slide 36 " s = 0 if light source is obscured # $ 1 if light source is not obscured 9

Shadows: Problems? Example Make sure to avoid self-shadowing Graphics Lecture 10: Slide 37 Graphics Lecture 10: Slide 38 Shadows One shadow ray per intersection per point light source Soft shadows Multiple shadow rays to sample area light source Graphics Lecture 10: Slide 39 Graphics Lecture 10: Slide 40 10

Reflection: Conventional ray tracing One reflection per intersection Reflection: Conventional ray tracing How can we create effects like this? Graphics Lecture 10: Slide 41 Graphics Lecture 10: Slide 42 Reflection: Monte Carlo ray tracing Glossy surfaces Random reflection rays around mirror direction Graphics Lecture 10: Slide 43 Graphics Lecture 10: Slide 44 11

Ray tracing Cast a ray from the eye through each pixel Trace secondary rays (light, reflection, refraction) Monte-Carlo Ray Tracing Cast a ray from the eye through each pixel Cast random rays from the visible point Accumulate radiance contribution Graphics Lecture 10: Slide 45 Graphics Lecture 10: Slide 46 Monte-Carlo Ray Tracing Cast a ray from the eye through each pixel Cast random rays from the visible point Recurse Monte-Carlo Ray Tracing Cast a ray from the eye through each pixel Cast random rays from the visible point Recurse Graphics Lecture 10: Slide 47 Graphics Lecture 10: Slide 48 12

Monte Carlo Path Tracing Trace only one secondary ray per recursion But send many primary rays per pixel Monte Carlo Ray Tracing Send rays to light Graphics Lecture 10: Slide 49 Graphics Lecture 10: Slide 50 Example Example 1 sample per pixel 256 samples per pixel Graphics Lecture 10: Slide 51 Graphics Lecture 10: Slide 52 13

Some cool pictures Graphics Lecture 10: Slide 53 Some cool pictures Graphics Lecture 10: Slide 55 Some cool pictures Graphics Lecture 10: Slide 54 Some cool pictures Graphics Lecture 10: Slide 56 14

Some cool pictures Graphics Lecture 10: Slide 57 took 4.5 days to render! 15