Now Playing: Melody Day Caribou from Andorra Released August 21, 2007.

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.
Light Issues in Computer Graphics Presented by Saleema Amershi.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
Ray Tracing Tutorial. Ray Casting One type of visibility algorithm.
Christian Lauterbach COMP 770, 2/11/2009
Chapter 11: Advanced Rendering Part 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Ray Tracing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
IMGD 1001: Illumination by Mark Claypool
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 Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
7M836 Animation & Rendering
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
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.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Ray Tracing 1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009.
Now Playing: Quicksand Under Carpet New Radiant Storm King from Leftover Blues: Released 2004.
Course Website: Computer Graphics 16: Illumination.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
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.
CSE 681 Ray Tracing Geometry. The Camera Model Based on a simpile pin-hole camera model –Simplest lens model –Pure geometric optics – based on similar.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
COMP 175: Computer Graphics March 24, 2015
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
1 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
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.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Week 10 - Wednesday.  What did we talk about last time?  Shadow volumes and shadow mapping  Ambient occlusion.
Introduction to 3D Graphics Lecture 2: Mathematics of the Simple Camera Anthony Steed University College London.
Computer Graphics Zhen Jiang West Chester University.
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.
Ray Tracing. 2 Introduction OpenGL is based on a pipeline model in which primitives are rendered one at time ­No shadows (except by tricks or multiple.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CS 480/680 Computer Graphics Compositing and Blending Dr. Frederick C Harris, Jr.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
RENDERING : Global Illumination
OpenGL and You I Cast, Therefore I Am. Ray Casting Idea is simple, implementation takes some work –Cast rays as if you were the camera –Determine intersection.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
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
Basics Reflection Mirrors Plane mirrors Spherical mirrors Concave mirrors Convex mirrors Refraction Lenses Concave lenses Convex lenses.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
CS552: Computer Graphics Lecture 36: Ray Tracing.
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Basic Ray Tracing CMSC 435/634.
Photorealistic Rendering vs. Interactive 3D Graphics
© University of Wisconsin, CS559 Fall 2004
CSE 470 Introduction to Computer Graphics Arizona State University
GR2 Advanced Computer Graphics AGR
Presentation transcript:

Now Playing: Melody Day Caribou from Andorra Released August 21, 2007

Movie: Knick Knack Pixar, 1989

Ray Casting Rick Skarbez, Instructor COMP 575 October 25, 2007

Announcements Programming Assignment 2 (3D graphics in OpenGL) is due TONIGHT by 11:59pm Programming Assignment 3 (Rasterization) is out Due NEXT Saturday, November 3 by 11:59pm If you do hand in by Thursday midnight, +10 bonus points

Last Time Reviewed light transport Lights Materials Cameras Talked about some features of real cameras Lens effects Film

Today Doing the math to cast rays

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 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 Ray-Tracing Algorithm Ray Casting

This is what we’re going to discuss today As we saw on the last slide, ray casting is part of ray tracing Can also be used on its own Basically gives you OpenGL-like results No reflection/refraction

Generating an Image 1. Generate the rays from the eye One (or more) for each pixel 2. Figure out if those rays “see” anything Compute ray-object intersections 3. Determine the color seen by the ray Compute object-light interactions

Rays Recall that a ray is just a vector with a starting point Ray = (Point, Vector)

Rays Let a ray be defined by point S and vector V The parametric form of a ray expresses it as a function as some scalar t, giving the set of all points the ray passes through: r(t) = S + tV, 0 ≤ t ≤∞ This is the form we will use

Computing Ray- Object Intersections If a ray intersects an object, want to know the value of t where the intersection occurs: t < 0: Intersection is behind the ray, ignore it t = 0: Undefined t > 0: Good intersection If there are multiple intersections, we want the one with the smallest t This will be the closest surface r(t) = p + td

The Sphere For today’s lecture, we’re only going to consider one type of shape The sphere The implicit equation for a sphere is: r 2 = (x - x 0 ) 2 + (y - y 0 ) 2 + (z - z 0 ) 2 If we assume it’s centered at the origin: r 2 = x 2 + y 2 + z 2

Ray-Sphere Intersections So, we want to find out where (or if) a ray intersects a sphere Need to figure out what points on a ray represent valid solutions for the sphere equation

Ray-Sphere Intersections Implicit SphereParametric Ray Equation Combined

Ray-Sphere Intersections Want to solve for the value(s) of t that make this statement true: Expand Rearrange

Ray-Sphere Intersections Note that this is in the form at 2 + bt + c = 0 Can solve with the quadratic formula:

There are three cases: No intersection 1 intersection 2 intersections How do we detect them? Check the discriminant! Ray-Sphere Intersections

Using the discriminant D = b 2 - 4ac If D = 0, there is one root If D > 0, there are 2 real roots If D < 0, there are 2 imaginary roots Ray-Sphere Intersections D < 0 D > 0 D = 0

Ray-Sphere Intersections So, for the 3 cases D < 0: Ray does not intersect the object D = 0: One intersection; solve for t D > 0: Two intersections But we know we only want the closest Can throw out the other solution

Ray-Object Intersections We derived the math for sphere objects in detail The process is similar for other objects Just need to work through the math Using implicit surface definitions makes it easy

Generating an Image 1. Generate the rays from the eye One (or more) for each pixel 2. Figure out if those rays “see” anything Compute ray-object intersections 3. Determine the color seen by the ray Compute object-light interactions

Generating Rays Now, given a ray, we know how to test if it intersects an object But we don’t yet know how to generate the rays We talked a bit about lenses last time, but an ideal pinhole camera is still the simplest model So let’s assume that

Generating Rays Recall the pinhole camera model Every point p in the image is imaged through the center of projection C onto the image plane Note that this means every point in the scene maps to a ray, originating at C That is, r(t) = C + tV C is the same for every ray, so just need to compute new Vs

Generating Rays Note that since this isn’t a real camera, we can put the virtual image plane in front of the pinhole This means we can solve for the ray directions and not worry about flipping the scene

Generating Rays in 2D Eye Once we know this ray, the rest are easy This is referred to as a “Pencil of Rays”

2D Frustum Note that this is the same idea as the frusta that we used in OpenGL: Eye Near Plane Far Plane Image Plane

Building a Frustum So we need to know the same things that we did to build an OpenGL view frustum Field of View Aspect Ratio Do we need near and far planes? Except now we need to build the camera matrix ourselves

Field of View Recall that the field of view is how “wide” the view is “LookAt” Unit Vector +x +y θ θ2θ2 θ2θ2 tan Not in terms of pixels, but in terms of viewing angle (θ) V0V0 V 0 =

Finding the Other Rays This tells us all we need to know At least in 2D All the other rays are just “offset” from the first “LookAt” Unit Vector +x +y θ θ2θ2 V0V0 DD V2V2 V1V1 V 1 = V 0 + D V 2 = V 1 + D D = NOTE: hRes is the horizontal resolution NOTE: hRes is the horizontal resolution

Generating Rays in 2D Note that we’re assuming one ray per pixel Can have more For all i from 0 to hRes: V i = [D V 0 ]

Extending to 3D So, this is all we need to know for 2D Just generates a single row of rays For 3D, need to also know the vertical resolution In the form of the aspect ratio

Quick Aside about Aspect Ratios With our virtual cameras, we can use any aspect ratio we want In the real world, though, some are most commonly used 4:3 (standard video) 16:9 (widescreen video) 2.35:1 (many movies)

Aspect Ratios Example 2.35:116:94:3 Cinerama (2.59:1)

Generating Rays in 3D Eye +x +y +z D v = D u = V0V0 DvDv DuDu V 0 =

Generating Rays in 3D D u = D v = V 0 =V i,j = [D u D v V 0 ]

A Basic 3D Camera Matrix Assumes: Camera on the z-axis Looking down -z Ideal pinhole model Fixed focal length (focal length = 1)

Generating an Image 1. Generate the rays from the eye One (or more) for each pixel 2. Figure out if those rays “see” anything Compute ray-object intersections 3. Determine the color seen by the ray Compute object-light interactions

Bonus Movie: Portal Half-Life 2 Mod Available online:

Determining Color Since we’re not yet talking about tracing rays Really just talking about OpenGL-style lighting and shading Since surfaces are implicitly defined, can solve Phong lighting equation at every intersection

Review: Phong Lighting I = I a (R a, L a ) + I d (n, l, R d, L d, a, b, c, d) + I s (r, v, R s, L s, n, a, b, c,d) R something represents how reflective the surface is L something represents the intensity of the light In practice, these are each 3-vectors One each for R, G, and B AmbientDiffuse Specular

Phong Reflection Model: Ambient Term Assume that ambient light is the same everywhere Is this generally true? I a (R a, L a ) = R a * L a The contribution of ambient light at a point is just the intensity of the light modulated by how reflective the surface is (for that color)

Phong Reflection Model: Diffuse Term I d (n, l, R d, L d, a, b, c, d) = (R d / (a + bd + cd 2 )) * max(l n, 0) * L d a, b, c : user-defined constants d : distance from the point to the light Let’s consider these parts

Lambert’s Cosine Law The incident angle of the incoming light affects its apparent intensity Does the sun seem brighter at noon or 6pm? Why? “Noon”“Evening”

Phong Reflection Model: Diffuse Term We already know how to get the cosine between the light direction and the normal n l What happens if the surface is facing away from the light? That’s why we use max(n l, 0) Why not just take |n l|?

Phong Reflection Model: Diffuse Term In the real world, lights seem to get dimmer as they get further away Intensity decreases with distance We can simulate that by adding an attenuation term (R d / (a + bd + cd 2 )) User can choose the a,b,c constants to achieve the desired “look”

Phong Reflection Model: Specular Term I s (r, v, R s, L s, n, a, b, c, d) = (R s / (a + bd + cd 2 )) * max(r v, 0) n * L s Why r v? Reflection is strongest in the direction of the reflection vector r v is maximized when the viewpoint vector (or really the vector to the viewpoint) is in the same direction as r What is n? “Shininess” coefficient

Generating an Image 1. Generate the rays from the eye One (or more) for each pixel 2. Figure out if those rays “see” anything Compute ray-object intersections 3. Determine the color seen by the ray Compute object-light interactions

Review Reviewed the basic ray tracing algorithm Talked about how ray casting is used Derived the math for generating camera rays Derived the math for computing ray intersections For a sphere

Next Time Extending the camera matrix to be more general Covering some software engineering notes relating to building a ray tracer