Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.

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.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
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.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
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.
MC930/MO603 Ray Casting. Light is bouncing photons.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Now Playing: Melody Day Caribou from Andorra Released August 21, 2007.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
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.
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.
Lecture 5: 3D Rendering Pipeline (II) Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology.
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.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Computer graphics & visualization Ray-Tracing – A Quick review.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
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.
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.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
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.
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
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.
MIT EECS 6.837, Cutler and Durand 1 Ray Casting II.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
CSCE 441: Computer Graphics Ray Tracing
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Lighting Lighting.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
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.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CSE 681 Object Intersection. CSE 681 Object Representation Implicit forms F(x,y,z) = 0 Explicit forms Analytic form x = F(y,z) testing generating Parametric.
CS 376 Introduction to Computer Graphics 04 / 18 / 2007 Instructor: Michael Eckmann.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Rendering Pipeline Fall, 2015.
MIT EECS 6.837, Cutler and Durand
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Tracing Geometry CSE 681.
Ray Tracing Geometry CSE 681.
© University of Wisconsin, CS559 Fall 2004
Ray Tracing.
Lecture 13 Clipping & Scan Conversion
GR2 Advanced Computer Graphics AGR
Presentation transcript:

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 2 Ray tracing idea

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 3 Ray tracing algorithm for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image }

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 4 Pinhole camera Box with a tiny hole Image is inverted Perfect image if hole infinitely small Pure geometric optics based on similar triangles No depth of field issue

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 5 Camera Obscura

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 6 Abelardo Morell Photographer who turns hotel room into a camera obscura (pinhole optics)

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 7 Durer’s Ray casting machine Albrecht Durer, 16 th century

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 8 Durer’s Ray casting machine Albrecht Durer, 16 th century

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 9 Durer’s Ray casting machine Albrecht Durer, 16 th century

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 10 Plane projection in drawing [CS 417 Spring 2002]

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 11 Plane projection in photography This is another model for what we are doing –applies more directly in realistic rendering [CS 417 Spring 2002]

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 12 Simplified pinhole camera Eye-image pyramid (frustum) Note that the distance/size of image are arbitrary

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 13 Generating eye rays Use window analogy directly

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 14 Vector math review Vectors and points Vector operations –addition –scalar product More products –dot product –cross product

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 15 Ray: a half line Standard representation: point p and direction d –this is a parametric equation for the line –lets us directly generate the points on the line –if we restrict to t > 0 then we have a ray –note replacing d with ad doesn’t change ray (a > 0)

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 16 Generating eye rays Just need to compute the view plane point q: –we won’t worry about the details for now

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 17 Sphere equation Sphere equation (implicit): Assume unit dimensions, centered at origin

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 18 Explicit vs. implicit? Sphere equation is implicit –Solution of an equation –Does not tell us how to generate a point on the sphere –Tells us how to check that a point is on the sphere Ray equation is explicit –Parametric –How to generate points –Harder to verify that a point is on the ray

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 19 Ray-sphere intersection: algebraic Condition 1: point is on ray Condition 2: point is on sphere –assume unit sphere Substitute: –this is a quadratic equation in t

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 20 Ray-sphere intersection: algebraic Solution for t by quadratic formula: –simpler form holds when d is a unit vector but we won’t assume this in practice (reason later) –I’ll use the unit-vector form to make the geometric interpretation

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 21 Ray-sphere intersection: algebraic

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 22 Ray-sphere intersection: geometric What geometric information is important? –Inside/outside –Closest point –Direction Geometric considerations can help shortcut calculations –easy reject R r O D

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 23 Ray-sphere intersection: geometric Find if the ray’s origin is outside the sphere –R 2 >r 2 –If inside, it intersects –If on the sphere, it does not intersect (avoid degeneracy) R r O D

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 24 Ray-sphere intersection: geometric Find if the ray’s origin is outside the sphere Find the closest point to the sphere center –t P =RO.D –If t P <0, no hit R r O D tPtP P

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 25 Ray-sphere intersection: geometric Find if the ray’s origin is outside the sphere Find the closest point to the sphere center –If t P <0, no hit Else find squared distance d 2 –Pythagoras: d 2 =R 2 -t P 2 –…–… R r O D P tPtP d if d 2 > r 2 no hit

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 26 Ray-sphere intersection: geometric Find if the ray’s origin is outside the sphere Find the closest point to the sphere center –If t P <0, no hit Else find squared distance d 2 –if d 2 > r 2 no hit If outside t = t P -t’ –t’ 2 +d 2 =r 2 If inside t = t P +t’ R r O D P tPtP d t t’

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 27 Ray-sphere intersection: geometric

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 28 Geometric vs. algebraic Algebraic was more simple (and more generic) Geometric is more efficient –Timely tests –In particular for outside and pointing away

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 29 Image so far With eye ray generation and sphere intersection Surface s = new Sphere((0.0, 0.0, 0.0), 1.0); for 0 <= iy < ny for 0 <= ix < nx { ray = camera.getRay(ix, iy); if (s.intersect(ray, 0, +inf) < +inf) image.set(ix, iy, white); }

Cornell CS465 Fall 2004 Lecture 3© 2003 Steve Marschner 30 Ray-box intersection Could intersect with 6 faces individually If axis-aligned, box is the intersection of 3 slabs

Cornell CS465 Fall 2004 Lecture 3 2D example 3D is the same © 2003 Steve Marschner 31 Ray-slab intersection

Cornell CS465 Fall 2004 Lecture 3© 2003 Steve Marschner 32 Intersection ranges Each intersection is an interval Want last entry point and first exit point

Cornell CS417 Spring 2003 Lecture 33© 2003 Steve Marschner 33 General Ray-plane intersection Condition 1: point is on ray Condition 2: point is on plane Condition 3: point is on the inside of all edges First solve 1&2 (ray–plane intersection) –substitute and solve for t:

Cornell CS417 Spring 2003 Lecture 33© 2003 Steve Marschner 34 Ray-triangle intersection In plane, triangle is the intersection of 3 half spaces

Cornell CS417 Spring 2003 Lecture 33© 2003 Steve Marschner 35 Inside-edge test Need outside vs. inside Reduce to clockwise vs. counterclockwise –vector of edge to vector to x Use cross product to decide

Cornell CS417 Spring 2003 Lecture 33© 2003 Steve Marschner 36 Ray-triangle intersection

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 37 Intersection against many shapes The basic idea is: –this is linear in the number of shapes but there are sublinear methods (acceleration structures) hit (ray, tMin, tMax) { tBest = +inf; hitSurface = null; for surface in surfaceList { t = surface.intersect(ray, tMin, tMax); if t < tBest { tBest = t; hitSurface = surface; } return hitSurface, t; }

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 38 Image so far With eye ray generation and scene intersection Geometry g = new Sphere((0.0, 0.0, 0.0), 1.0); for 0 <= iy < ny for 0 <= ix < nx { ray = camera.getRay(ix, iy); c = scene.trace(ray, 0, +inf); image.set(ix, iy, c); } … trace(ray, tMin, tMax) { surface, t = hit(ray, tMin, tMax); if (surface != null) return surface.color(); else return black; }

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 39 Shading Compute light reflected toward camera Inputs: –eye direction –light direction (for each of many lights) –surface normal –surface parameters (color, shininess, …) More on this in the next lecture

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 40 Image so far trace(Ray ray, tMin, tMax) { surface, t = hit(ray, tMin, tMax); if (surface != null) { point = ray.evaluate(t); normal = surface.getNormal(point); return surface.shade(ray, point, normal, light); } else return black; } … shade(ray, point, normal, light) { v_E = –normalize(ray.direction); v_L = normalize(light.pos - point); // compute shading }

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 41 Shadows Surface is only illuminated if nothing blocks its view of the light. With ray tracing it’s easy to check –just intersect a ray with the scene!

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 42 Image so far shade(ray, point, normal, light) { shadRay = (point, light.pos - point); if (shadRay not blocked) { v_E = –normalize(ray.direction); v_L = normalize(light.pos - point); // compute shading } return black; }

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 43 Multiple lights Important to fill in black shadows Just loop over lights, add contributions Ambient shading –black shadows are not really right –one solution: dim light at camera –alternative: all surface receive a bit more light just add a constant “ambient” color to the shading…

Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 44 Image so far shade(ray, point, normal, lights) { result = ambient; for light in lights { if (shadow ray not blocked) { result += shading contribution; } return result; }