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

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

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

Implementation Issues

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

COMP371 COMPUTER GRAPHICS

Raytracing. COSC 4328/5327 Scott A. King

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

Reflection and Refraction

Ray tracing. EECS 487 March 19,

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

Reflection and Refraction

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

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

Ray Tracing. Kjetil Babington

Photorealism: Ray Tracing

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

LIGHT. Speed of light Law of Reflection Refraction Snell s Law Mirrors Lenses

LECTURE 15 REFLECTION & REFRACTION. Instructor: Kazumi Tolich

Lecture 10: Ray tracing

Ray-Tracing. Misha Kazhdan

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

Recursion and Data Structures in Computer Graphics. Ray Tracing

COMP30019 Graphics and Interaction Ray Tracing

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

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

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

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

Sung-Eui Yoon ( 윤성의 )

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

Ray Tracing. CS116B Chris Pollett Apr 20, 2004.

CPSC GLOBAL ILLUMINATION

Lighting and Shading

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

Reflection and Shading

Intro to Ray-Tracing & Ray-Surface Acceleration

Ray Tracing. Foley & Van Dam, Chapters 15 and 16

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Indirect Illumination

Lecture 19: All Together with Refraction

COMPLETION OF Z-buffer Graphics Pipeline

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

CS 4204 Computer Graphics

Indirect Illumination

Experiment 9. Law of reflection and refraction of light

CS 325 Computer Graphics

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

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

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

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

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

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

Supplement to Lecture 16

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

COMP environment mapping Mar. 12, r = 2n(n v) v

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

Visible Surface Detection Methods

CS 488. More Shading and Illumination. Luc RENAMBOT

Outline The Refraction of Light Forming Images with a Plane Mirror 26-3 Spherical Mirror 26-4 Ray Tracing and the Mirror Equation

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Recall: Basic Ray Tracer

Shading, Advanced Rendering. Week 7, Wed Feb 28

EECS 487: Interactive Computer Graphics

Advanced Ray Tracing

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

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

Ray casting. Ray casting/ray tracing

Physics 1C. Lecture 22A. "There are two ways of spreading light: to be the candle or the mirror that reflects it." --Edith Wharton

Lecture 11: Ray tracing (cont.)

Reflection & refraction

Distribution Ray-Tracing. Programação 3D Simulação e Jogos

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

CS 465 Program 5: Ray II

CS 6620 Shading. Steve Parker Peter Shirley

Introduction to Ray-tracing Objectives

Ray Tracing through Viewing Portals

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

Distributed Ray Tracing

SAMPLING AND NOISE. Increasing the number of samples per pixel gives an anti-aliased image which better represents the actual scene.

CS3500 Computer Graphics Module: Lighting and Shading

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Real Time Reflections Han-Wei Shen

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

Ray Tracer Due date: April 27, 2011

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

Raytracing CS148 AS3. Due :59pm PDT

Ray Tracing. Local Illumination. Object Space: Global Illumination. Image Space: Backward Ray Tracing. First idea: Forward Ray Tracing

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

speed of light in vacuum = speed of light in the material

CS-184: Computer Graphics. Administrative

CS 4620 Program 4: Ray II

Sampling: Antialiasing - Intro

BCC Sphere Transition

Global Illumination. Connelly Barnes CS 4810: Graphics

Lecture 11. More Ray Casting/Tracing

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

Introduction to Computer Graphics. Ray Tracing Review

11.2 Refraction. December 10, Wednesday, 11 December, 13

Introduction to 2D and 3D Computer Graphics. Realistic Rendering. -- Ray Tracing--

Practical 2: Ray Tracing

Transcription:

Recursive Ray Tracing Ron Goldman Department of Computer Science Rice University

Setup 1. Eye Point 2. Viewing Screen 3. Light Sources 4. Objects in Scene a. Reflectivity b. Transparency c. Index of Refraction 5. Bounding Boxes {Optional}

Algorithm For each pixel Find all intersections of ray from eye to pixel with every object in the scene. {Line Surface Intersection) Keep the intersection closest to the eye. {Smallest positive parameter value along the line.} Compute the color and intensity of the light at this intersection point. {Recursion -- see below.} Display the scene.

Color and Intensity at a Point Binary Light Tree I = I direct + k s I reflected + k t I refracted I direct = I ambiant + I diffuse + I specular I direct k s k t I reflected I refracted k s k t k s k t I reflected I refracted I reflected I refracted M Tree truncated at specified depth to avoid infinite recursion.

Reflections, Refractions, and Shadows For each object in the scene Decide whether it is reflecting, transparent, semi-transparent, or opaque. Assign values for k s = reflectivity k t = transparency {for shadowing and refraction} c i = index of refraction opaque = 0 air = 1 Note: if transparent, then I direct = 0

Shadows Algorithm For each visible point cast a virtual ray to each light source. If the virtual ray hits an opaque object before it hits the light source {0<t<1}, then omit the contribution of this light source. I diffuse = I specular = 0 Note: an object may be self shadowed -- lie in its own shadow (e.g. sphere) -- so we must compute intersections even with the object containing the point. If the virtual ray hits a transparent or semi transparent object before it hits the light source, then scale the contribution of this light source and continue to look for further intersections.

Shadows (continued) Shadow Coherence To speed up the algorithm Store current shadowing object. Test it first for next ray. Problem Shadow rays not refracted (if they were they would not hit the light source!). Solution Trace rays starting from light sources. Very expensive. Not generally done.

Reflection For each visible point on a reflecting object: Treat the point as a virtual eye Use the law of mirrors: angle of incidence = angle of reflection to calculate a reflected secondary ray. {See calculation of R(t) below.} Find all intersections of the reflected ray with every object in the scene. Keep the intersection closest to the virtual eye. {Smallest positive parameter value along the line.} Compute the color and intensity of the light at this intersection recursively and add a scaled version of this contribution to the color and intensity of the original point as k s I reflected. {Note: some algorithms also scale by distance.}

Reflection N Eye V (V N)N (V N)N V V (V N)N θ θ W P Surface R(t) = P + tw W = 2(V N)N V {virtual (secondary) ray}

Refraction For each visible point on a transparent object: Treat the point as a virtual eye. c Use Snell s Law: 2 = sin(θ 2) c 1 sin(θ 1 ) to find the refracted secondary ray {See calculation of R(t) below.} Find all intersections of the refracted ray with every object in the scene Keep the intersection closest to the virtual eye. {Smallest positive parameter value along the line.} Compute the color and intensity of the light at this intersection recursively and add a scaled contribution to the color and intensity of the original point as k t I refracted. {Note again some algorithms also scale by distance.}

Refraction Setup N = unit vector normal to surface {known} V = unit vector from surface to eye {known} W = refracted ray {to be computed} R(t) = P + tw {virtual (refracted) ray}

Refraction N Eye V θ 1 P Surface θ 2 N W

Refraction Made Simple Snell s Law c 2 = sin(θ 2) c 1 sin(θ 1 ) Rotation Matrix rot(θ 2,u) = cos(θ 2 )I + ( 1 cos(θ 2 ))(u u)+sin(θ 2 )(u _) sin(θ 2 ) = c 2 c 1 sin(θ 1 ) cos(θ 2 ) = 1 sin 2 θ 2 u = N V N V (unit vector normal to the plane of N and V) Refraction Vector W = N rot(θ 2,u)

Refraction Made Simple (continued) Refraction Vector W = N rot(θ 2,u) = cos(θ 2 )N ( 1 cos(θ 2 ))(N {)u u sin(θ 2 )(u N) =0 = cos(θ 2 )N + sin(θ 2 )(N u) Further Simplification u = N V N V = N V { N {sin(θ V 1 ) = N V sin(θ 1 ) =1 =1 W = cos(θ 2 )N + sin(θ 2) sin(θ 1 ) N (N V) = cos(θ 2 )N + c 2 c 1 N (N V )

Refraction Made Simple (continued) Further Simplification A (B C) = (A C)B (A B)C N (N V) = (N V)N (N1 2 N 3 )V = (N V )N V =1 Refraction Vector W = cos(θ 2 )N + c 2 ((N V)N V) c 1 cos(θ 2 ) = 1 sin 2 θ 2 = 1 c 2 2 2 c sin2 θ 1 = 1 c 2 2 2 1 c (1- cos2 θ 1 ) 1 cos(θ 2 ) = 1 c 2 c 1 2 ( 1-(N V) 2 )

Total Reflection May occur when c 2 c 1 > 1. c 2 c 1 sin(θ 1 ) >1 sin(θ 2 ) cannot exist. Test for total reflection ( 1-(N V)2) >1 1-(N V)2 > c 1 2 c 2 2 c 1 c 2 2 Must check for this case. Be careful!

Observations 1. Refraction is caused by different speeds of light in different mediums. 2. Note that for each color, we use the same index of refraction and therefore the same refracted ray. Technically this is incorrect, but it saves tremendously on computation.

Extents 1. Ray Surface intersections are expensive to compute. 2. Lots of rays are caste -- m(2 n 1) m = number of light sources n = depth of ray tree Even more rays for antialiasing! 3. To speed computations, bound the objects in the scene with simple objects. Each object comes equiped (after some preprocessing) with a. a bounding box in 3-space; b. a bounding rectangle in the viewing plane. 4. Quick reject if ray fails to intersect the bound.

Bounding Boxes and Bounding Rectangles Bounding Boxes -- 3-Space For secondary and virtual rays Sides parallel to axes for faster computation -- coordinate dependent Sides in arbitrary orientations for tighter fit -- view independent Bounding Rectangles -- Viewing Plane Rectangle surrounding projection of bounding box in 3-space View dependent and coordinate dependent -- speed If pixel not within rectangle bound, do not bother to intersect ray with object

Parallel Computations 1. Independent rays can be cast in parallel. 2. Reflection, Refraction, and Shadow rays can be caste in parallel. 3. Ray Surface intersection can be calculated independently for each surface.

Antialiasing Caste rays through corners of pixel instead of center. If 4 corner values are close, take their average. Otherwise Subdivide the pixel into 4 virtual pixels. Recursively compute the intensity of each virtual pixel. Take the average intensity of the 4 virtual pixels. {Equivalently take the average of all the subpixels weighted by area.} Stop subdiving when the 4 coner values are close or the vitual pixel is small. Aliasing is caused by discrete and regular sampling of points Distrributed ray tracing randomly jitters the location of the pixels from their centers