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

Similar documents
Movie: Geri s Game. Announcements. Ray Casting 2. Programming 2 Recap. Programming 3 Info Test data for part 1 (Lines) is available

Photorealism: Ray Tracing

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

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

Assignment 6: Ray Tracing

Luxo Jr. (Pixar, 1986) Last Time. Real Cameras and Ray Tracing. Standard Rasterization. Lights, Cameras, Surfaces. Now Playing:

Lighting and Shading

COMP371 COMPUTER GRAPHICS

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

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

Shadows. COMP 575/770 Spring 2013

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

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

03 RENDERING PART TWO

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

Ray-Tracing. Misha Kazhdan

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

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

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

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

Assignment 2 Ray Tracing

Ray Tracer Due date: April 27, 2011

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

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

Announcements. Submitting Programs Upload source and executable(s) (Windows or Mac) to digital dropbox on Blackboard

MITOCW MIT6_172_F10_lec18_300k-mp4

COMPLETION OF Z-buffer Graphics Pipeline

For Intuition about Scene Lighting. Today. Limitations of Planar Shadows. Cast Shadows on Planar Surfaces. Shadow/View Duality.

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Real-Time Shadows. MIT EECS 6.837, Durand and Cutler

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

Practical 2: Ray Tracing

Ray tracing. EECS 487 March 19,

Raytracing CS148 AS3. Due :59pm PDT

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

Computer Graphics. Si Lu. Fall uter_graphics.htm 11/22/2017

Supplement to Lecture 16

Real-Time Shadows. Last Time? Schedule. Questions? Today. Why are Shadows Important?

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

Virtual Reality for Human Computer Interaction

Raytracing. COSC 4328/5327 Scott A. King

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

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

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

CS 325 Computer Graphics

Recursion and Data Structures in Computer Graphics. Ray Tracing

Real-Time Shadows. Computer Graphics. MIT EECS Durand 1

The Traditional Graphics Pipeline

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

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

Lecture 18: Primer on Ray Tracing Techniques

Sung-Eui Yoon ( 윤성의 )

Ray Tracing. Kjetil Babington

Intro to Ray-Tracing & Ray-Surface Acceleration

Practical Techniques for Ray Tracing in Games. Gareth Morgan (Imagination Technologies) Aras Pranckevičius (Unity Technologies) March, 2014

Shading, Advanced Rendering. Week 7, Wed Feb 28

CS 465 Program 5: Ray II

CEng 477 Introduction to Computer Graphics Fall 2007

CS 488. More Shading and Illumination. Luc RENAMBOT

Graphics for VEs. Ruth Aylett

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

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

Hidden Surface Elimination Raytracing. Pre-lecture business. Outline for today. Review Quiz. Image-Space vs. Object-Space

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

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

CS 184: Assignment 4 Simple Raytracer

The Traditional Graphics Pipeline

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

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Ray tracing. Methods of Programming DV2. Introduction to ray tracing and XML. Forward ray tracing. The image plane. Backward ray tracing

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

CS 4620 Program 4: Ray II

CENG 477 Introduction to Computer Graphics. Ray Tracing: Shading

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

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

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

Lighting and Shading. Slides: Tamar Shinar, Victor Zordon

RAYTRACING. Christopher Peters INTRODUCTION TO COMPUTER GRAPHICS AND INTERACTION. HPCViz, KTH Royal Institute of Technology, Sweden

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

CS Simple Raytracer for students new to Rendering

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

COMP 175 COMPUTER GRAPHICS. Ray Casting. COMP 175: Computer Graphics April 26, Erik Anderson 09 Ray Casting

CS Computer Graphics: Introduction to Ray Tracing

CS Computer Graphics: Introduction to Ray Tracing

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

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

Chapter 6- Lighting and Cameras

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

Lecture 10: Ray tracing

Introduction to Ray-tracing Objectives

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

Orthogonal Projection Matrices. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Reflection and Shading

Deferred Rendering Due: Wednesday November 15 at 10pm

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

Introduction to 3D Concepts

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

The Traditional Graphics Pipeline

Transcription:

Now Playing: Movie: For The Birds Pixar, 2000 Liar Built To Spill from You In Reverse Released April 11, 2006 Ray Tracing 1 Rick Skarbez, Instructor COMP 575 November 1, 2007 Announcements Programming Assignment 3 (Rasterization) is due THIS Saturday, November 3 by 11:59pm If you do hand in by tonight, +10 bonus points Assignment 3 (texture mapping and ray tracing) is out, due next Thursday by the end of class Remember that you need to talk to me about your final project Programming 2 Recap Spherical Coordinates Demo on board Per-Vertex Normals Demo on board Programming 3 Info Test data for part 1 (Lines) is available As C/C++ array, or just as a text file In both cases, each line has 7 parameters (x1, y1, x2, y2, R, G, B) This data set anticipates a 512x512 window To read the array (line.data), use something like the following code: 1

Programming 3 Info For parts 2 and 3, the program should respond to user input Can do this several ways Accept coordinates as command line input Prompt for user input while running Allow user to click and choose points (like polygon creation in assignment 1 Programming 3 Info For part 3 (line clipping), should display a window bigger than the clip window i.e. Viewport Clip against this Assignment 3 Overview Last Time Extended our camera to be much more general Arbitrary position / orientation / focal length Briefly discussed the software architecture of a raycaster Took a short course feedback survey Thanks very much to everyone who participated! Today Discussing how to implement shadows and reflections in a raytracer Ray-Tracing Algorithm for each pixel / subpixel shoot a ray into the scene find nearest object the ray intersects if surface is (nonreflecting OR light) color the pixel else calculate new ray direction recurse 2

Building a Frustum Du The Right Vector Dv So, we have: θ, hres, vres, eye, center, Up Want to use these to compute Du, Dv, V0 V0 These three vectors define the image plane Ey e +y Need a vector that points in the Du direction Note that LookAt and Up Any ideas? should be unit vectors Cross the look vector and the up vector Du = LookAt x Up +z +x LookAt Up Du +y The Down Vector So how to we find a vector perpendicular to two other vectors +z Cross product Dv = LookAt x Du +x Note that if LookAt and Up are both unit vectors, then Du and Dv are also unit vectors LookAt Dv Du +y Du Dv -Dv vres 2 +z +x Finding V0 -Du hres 2 -Dv vres 2 1 -Du hres 2? V0 1 LookAt Eye Given Points: Given Unit Vector: Given FOV Angle: Given Complete Frustum Specification Dimensions: Du = LookAt x Up Dv = LookAt x Du eye, center Up center - eye LookAt = θ center - eye vres, hres NOTE: Normalize Du and Dv! App For Each Pixel Pixel Color Raycaster System Overview Generates Camera Matrix Camera Ray Sphere Shade() Closest Object Test For Closest Shade() Linked List of Objects Plane Sphere Etc. Material #2 Surface Material Illuminated By Linked List of Materials Material #1 Material #2 Linked List of Lights Ambient #1 Point #1 Point #2 3

Standard Scene Scene With What causes shadows? An object lies between the shadowed surface and the light source That is, the second object blocks photons/rays from reaching the first object No shadow on bunny Bunny is in darkness So finding shadows is easy if all rays are starting at the light sources If the ray does not get to a surface, that surface is in shadow But, remember, we re tracing rays backward Starting at the camera This complicates matters a bit Assume we did our raycasting, and found that the ray intersected the plane Now we want to shade the point Which includes determining if it is in shadow We can test this with a ray from the point to the light And so we begin ray tracing... 4

Shade Ray Casting Recursive Ray Casting Shade Shadow Shadow Shade Ray Tracing Ray Traced Recursive Ray Same idea as Tracing recursive functions To solve one function/ray, do some simple work to generate inputs for a new function/ray Recurse til you re done And just like recursive functions, it means we have to be very careful programmers A small error in calculation or memory management can lead to catastrophe That said, now we can do some really cool stuff Implementing Shadow Ray All we do is generate a new ray, starting at the point and directed along the light vector Test it just like any other ray If an intersection occurs, then the point may be shadowed Implementing Here the point is shadowed Shadow Ray Here it is not To be thorough, we need to check the distance on the intersection The object is only in shadow if the t value for the intersection is less than the t value of the light Summary Can check if a point is in shadow by drawing a ray from that point to a light If that ray hits an object, the point is in shadow This is our first baby step into real ray tracing are EASY Already know the point and vector of the new ray Can use the existing intersection code Lights and Remember our different kinds of lights? Point lights (i.e light bulbs) Directional lights (i.e. the Sun) Spot lights Area lights How do these cause problems for us when doing shadows? 5

Directional Lights Point light sources at an infinite (or near infinite) distance How does this affect our shadow rays? Any intersection with a positive t is valid (generates a shadow) Spot Lights Similar to point lights, but intensity of emitted light varies by direction Need to make sure that the shadow ray is inside the cone Spot Lights S L anglemax Vector Similarity: S L L Point Being Shaded Can test your shadow ray against the extents of your spotlight If S L <= S anglemax, go ahead Area Lights The most difficult case No longer just one shadow ray Really, infinitely many shadow rays Can address by shooting many shadow rays for each light This is a sampling/reconstruction problem We ll come back to it later Lights and Summary Can still use the shadow ray technique with all the kinds of lights we consider Need to do a little bit more work for some Directional lights: intersections at any distance Spot lights: make sure ray is inside cone Area lights: need to shoot a whole mess of rays Now we re going to learn how to do reflections in our ray tracer This is one of the classic benefits of ray tracing Why do you think all these images have mirrored spheres in them? Most every other rendering technique has to use hacks for this 6

and Specularity Vector and specularity are really close R S Diffuse N Specular We ll use the reflection vector we computed for our specularity calculation as the new ray direction L R E Ray R L Define a ray with P = intersection point V = reflection vector of the eye vector, to be clear N E How to Integrate This? This was our shading equation before: Ambient Diffuse I = (1 - r)σ[ia(ra, La) + Id(n, l, Rd, Ld, a, Lights b, c, d) Specular + Is(r, v, Rs, Ls, n, a, b, c,d)] Add another term, say r * (refcolor) Where r is how reflective the surface is [0, 1] And refcolor is the color from the reflection ray Shading + So now we have: I = (1 - r)σ[ia(ra, La) + Id(n, l, Rd, Ld, a, b, c, d) Lights + Is(r, v, Rs, Ls, n, a, b, c,d)] + r(refcolor) Shading the Ray So how do we determine the value of refcolor? Just treat it exactly like a camera ray See if it intersects anything If so, shade as normal and, if necessary, reflect again If not, return the background color 7

Recursion Shade Ray Tracing No Recursion (But With ) 1 Recursion 2 3 4 8

Stopping the Madness Does anyone see the problem here? This could go on forever Think of 2 mirrors reflecting each other This would result in stack overflow and terribleness Need some way to stop it 5 Stopping the Madness Solution: Put a depth limit on the recursion Initialize each camera ray to have a depth of 0 Every child ray has depth = (parent s depth + 1) Do not allow any new rays to be created with depth > maxdepth Also, there s obviously no need to cast new rays if the reflection coefficient is 0 Summary adds a great deal of realism to rendered scenes We discussed: Generating reflection rays Similar to specularity calculation Shading with reflection Just add another term Preventing infinite recursion Refraction Refraction works just like reflection When a ray hits a surface Shade as normal Figure out if you need to cast a refraction ray If so, calculate the new ray Shade it as normal, and add it as yet another term to our shading equation Refraction Rays Need to store the index of refraction and a transparency coefficient or each material If the object is transparent, generate a new ray using Snell s law Continue just as in reflection n1 sinα1 = n2 sinα2 9

Refraction Example Next Time Filling in some of the gaps for how to build a real ray tracer Instantiation of multiple objects Some acceleration tricks and optimizations Identifying and fixing some tricky bits 10