More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Christian Lauterbach COMP 770, 2/11/2009
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Alla Sheffer Advanced Rendering Week.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
RAY TRACING.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest.
CS 376 Introduction to Computer Graphics 04 / 06 / 2007 Instructor: Michael Eckmann.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
© 2005 Pearson Prentice Hall This work is protected by United States copyright laws and is provided solely for the use of instructors in teaching their.
BSP Trees, Quadtrees & Octrees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January 28, 2004.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
An Introduction to Ray Tracing CS /27/1998 Vic Baker.
Presentation by Dr. David Cline Oklahoma State University
COMP 175: Computer Graphics March 24, 2015
Polygon Lists & 3-D File Formats Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, February 18, 2002.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
Ray Tracing Sang Il Park SEjong University With lots of slides stolen from Jehee Lee, Doug James, Steve Seitz, Shree Nayar, Alexei Efros, Fredo Durand.
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Data Structures for Scenes, The Basics of Scene Graphs Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday,
Last Word on Chapter 22 Geometric Optics Images in a Plane Mirror.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
Shadows via Projection Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, November 5, 2003.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Gene Au-yeung, Daniel Quach, Jeffrey Su, Albert Wang, Jessica Wang, David Woo.
More on Drawable Objects, Hierarchical Objects Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January.
Advanced HSR Methods Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Friday, January 30, 2004.
Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
More on Environment Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, December 10, 2003.
Recursion and Data Structures in Computer Graphics Ray Tracing 1.
Lighting Review & Example Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, November 17, 2003.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
Ray Tracer Spring 2008 Help Session. Outline Project Web Resources What do you have to do for this project? Ray Class Isect Class Requirements Tricks.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Alex YAU Important Notes Website for Assignment #2 You.
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
CS 376 Introduction to Computer Graphics 04 / 02 / 2007 Instructor: Michael Eckmann.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
CS3241 C OMPUTER G RAPHICS Tutorial 8. Q UESTION #1 Given an object represented in polygons, how to find its bounding sphere?
RENDERING : Global Illumination
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.
Basic Ray Tracing CMSC 435/634.
Photorealistic Rendering vs. Interactive 3D Graphics
Ray Tracer Autumn 2005 Help Session.
Presentation transcript:

More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004

14 Apr 2004CS 481/6812 Review: Basic Ray Tracing [1/5] In “normal” rendering: We deal with a series of objects, made of primitives. For each primitive, we determine which pixels it affects, if any. Ray tracing turns this around: We deal with pixels, one by one. For each pixel, we ask what we see (which primitive?) when we look at it.

14 Apr 2004CS 481/6813 Review: Basic Ray Tracing [2/5] The way we determine what we see when we look at a pixel is to draw an imaginary ray from the viewing position, through the pixel, into the scene. We ask which objects in the scene the ray hits. The first hit is the one that counts. First hit Current pixel Image Scene objects

14 Apr 2004CS 481/6814 Review: Basic Ray Tracing [3/5] What do we do when we have a hit? We determine what color the object is at that point. Light sources and the object’s normal may affect the computation. We can also do true specular reflection: Reflect the ray and do the ray tracing computation again. We can also do true refraction, for translucent objects. Normal Original ray Reflected ray

14 Apr 2004CS 481/6815 Review: Basic Ray Tracing [4/5] Our discussion was centered around two questions to be answered: Does a ray hit an object; if so, where? If a ray hits an object, then, looking along the ray, what color do we see? We outlined a simple OO design based on answering these questions. Our design is simple, robust, and easy to extend.

14 Apr 2004CS 481/6816 Review: Basic Ray Tracing [5/5] Classes Ray A ray is defined by its starting position and its direction. For convenience, rays know how to reflect and refract. Object Knows how to answer the two questions (for itself). Object classes are derived from a common base class. The two questions are answered via virtual functions. Hit Stores the result of a hit test. For convenience, holds: whether there was a hit, and if so, how far along the ray, where, and the object normal at the hit point.

14 Apr 2004CS 481/6817 More on Ray Tracing: Topics Next topics: A few notes. Hit testing. Example ray-tracing code. Adding features to a ray tracer.

14 Apr 2004CS 481/6818 Ray Tracing Notes: A Third Method We know about “normal” rendering and ray tracing. There is a third option: photon tracing. Here, we trace photons forward from the light source. Since most photons do not hit the viewer’s eye, this is very inefficient. However, it is also very accurate, esp. for things like caustics. Quick Summary “Normal” Main loop goes over primitives. Which pixels does this primitive affect? Ray Tracing Main loop goes over pixels. What to I see when I look in this direction? Photon Tracing Main loop goes over photons. Where does this light end up?

14 Apr 2004CS 481/6819 Ray Tracing Notes: The Design Back to the ray tracer. I will add two more classes to the design: Object List This holds the entire scene. If true specular reflection is to be performed, an object needs to have access to information about the other objects. Essentially one member function: trace a ray through the scene and return a color. Needs to know what color to return if the ray does not hit an object. Light List It is easy to implement cheap-ish diffuse reflection, shadows, etc., in a ray tracer, if the location of light- sources is known. I put this in my ray tracer, but it is currently not used.

14 Apr 2004CS 481/68110 Hit Testing: Introduction The easiest type of 3-D object to render with the “normal” method is a triangle. In ray tracing, “easy” means a quick hit test and color determination. The easiest type of object to include in a ray-traced scene is a sphere. This is why most early ray-traced scenes involved shiny balls.

14 Apr 2004CS 481/68111 Hit Testing: Ray-Sphere Intersection [1/4] We look at how to do a ray-sphere intersection. Suppose we have a ray with start position E and direction vector V. We want to do a hit test with a sphere having center O and radius r. V E O r ???

14 Apr 2004CS 481/68112 Hit Testing: Ray-Sphere Intersection [2/4] The vector from E to O is EO = O – E. Let v be the dot product of EO and V. The value of v is the distance from E to the point halfway between the hits, if there are any hits. So |EO| 2 – v 2 is the square of the distance from O to this halfway point. If it exists! V E O r EO v sqrt[|EO| 2 – v 2 ]

14 Apr 2004CS 481/68113 Hit Testing: Ray-Sphere Intersection [3/4] So: disc = r 2 – [|EO| 2 – v 2 ] is the square of half the distance between the hit points. If the hits exist! The quantity disc is called the discriminant. If disc < 0, then there are no hits! V E O r EO sqrt[|EO| 2 – v 2 ] sqrt[disc]

14 Apr 2004CS 481/68114 Hit Testing: Ray-Sphere Intersection [4/4] The distances to the two hits, are v – sqrt[disc] and v + sqrt[disc]. Based on all this, we can come up with a relatively simple algorithm to do hit testing on a sphere. See grtobject.cpp for an implementation.

14 Apr 2004CS 481/68115 Hit Testing: Convex Polygons Of course, we would like to be able to put polygons into a ray-traced scene. We need only deal with convex polygons. We need to know how to do a hit test on a convex polygon. Here is an outline: Find the plane the polygon lies in. Do ray-plane intersection to find the point at which the ray hits the plane (unless it is parallel to the plane). Check the hit point to see if it lies in the polygon. This is done by looping over the edges of the polygon. For each edge, we check whether the point lies on the inside of the line through it. If the point lies on the inside of all the edges, then it is inside the polygon, and we have a hit. The normal is the normal of the plane.

14 Apr 2004CS 481/68116 Ray Tracing Code: Example Now we look at the GRT program. “GRT” = “Glenn’s Ray Tracer”. In class, we went over the source to grtmain.cpp, grtray.cpp, grtobject.cpp, grttypes.cpp. These files are on the web page.