I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 1/42 Raytracing Basics.

Slides:



Advertisements
Similar presentations
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Advertisements

Graphics Pipeline.
Cs123 INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Andries van Dam Texture Mapping Beautification of Surfaces 1/23.
3D Graphics Rendering and Terrain Modeling
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
Light Issues in Computer Graphics Presented by Saleema Amershi.
ATEC Procedural Animation Introduction to Procedural Methods in 3D Computer Animation Dr. Midori Kitagawa.
Christian Lauterbach COMP 770, 2/11/2009
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Alla Sheffer Advanced Rendering Week.
(conventional Cartesian reference system)
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
CS485/685 Computer Vision Prof. George Bebis
Computer Graphics (Fall 2008) COMS 4160, Lecture 19: Illumination and Shading 2
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Coordinate Systems X Y Z (conventional Cartesian reference system) X Y Z.
Now Playing: Quicksand Under Carpet New Radiant Storm King from Leftover Blues: Released 2004.
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.
CS 445 / 645: Introductory Computer Graphics
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
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.
MIT EECS 6.837, Durand and Cutler Local Illumination.
-Global Illumination Techniques
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 14 Going-through.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D Computer Graphics.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 445 / 645: Introductory Computer Graphics Light.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 1/42 Raytracing Basics Part 2 of 2.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Surface Rendering Methods 고려대학교 컴퓨터 그래픽스 연구실.
1 of 50 CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © October 27, 2015 Ray Tracing Rendering and Techniques Images: (Left)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Ray Tracing Ray Tracing.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Projective Transformations.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
CSCE 441: Computer Graphics Ray Tracing
In the name of God Computer Graphics. Last Time Some techniques for modeling Today Global illumination and raytracing.
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Stochastic Path Tracing Algorithms K. H. Ko School of Mechatronics Gwangju.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
CS 445 / 645 Introduction to Computer Graphics Lecture 16 Radiosity Radiosity.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
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.
Global Illumination (3) Path Tracing. Overview Light Transport Notation Path Tracing Photon Mapping.
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
CS552: Computer Graphics Lecture 33: Illumination and Shading.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Rendering Pipeline Fall, 2015.
CSCE 441 Computer Graphics 3-D Viewing
3D Graphics Rendering PPT By Ricardo Veguilla.
Image synthesis using classical optics
CS5500 Computer Graphics May 29, 2006
Presentation transcript:

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 1/42 Raytracing Basics

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 2/42 Illumination Review (1/3) Key points Global, physically-based illumination models describe energy transport and radiation - subject to the properties of light and materials - subject to the geometry of light, objects and viewer For each surface, there is a distribution that characterizes its absorption and reflection at each wavelength -also some other properties that we will ignore for the sake of brevity All illumination models are, by definition, approximate -based on sampling geometry, light distribution and material properties, and taking rendering shortcuts

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 3/42 Illumination Review (2/3) Important illumination models Local (single-surface element) model -ambient approximates indirect global illumination as constant -Lambertian diffuse reflection (outgoing energy is proportional to the cosine of the angle between the vector to the light and the surface normal, due to geometry) -Phong approximation to specular reflection -these model part of the BRDF (itself an approx!): Global (multi-surface element) models shadows indirect illumination – from other objects specular and diffuse reflection, refraction ii rr ii rr LiLi LrLr Surface

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 4/42 Illumination Review (3/3) Important illumination models The illumination models most commonly in use today are tied to the particulars of scan-conversion and raytracing Z-buffered scan-conversion -highly specialized and parallelized hardware: fast -but more limited -eye rays, shadow rays, specular reflections (only from planar surfaces) Raytracing -targeted shooting of rays (more accurate, but slower) -shadows, recursive specular (but not diffuse) reflection, refractive transmission

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 5/42 Rendering with Raytracing (1/2) Generalizing from Durer’s painting showing perspective projection Durer: Put eye at center of projection on wall and record color of objects along each of those strings Raytracing: shoot rays from eye through sample point (e.g., a pixel center) of a virtual photo -compute what color/intensity you see at the corresponding sample point on the object out there; paint this on “photo” at the ray-photo intersection point “What you see out there” -combination of the color of the material of the surface element you hit first and the colors of light that hit it and reflect towards you Raytracing, a simple idea: instead of forward mapping an infinite number of rays from light source to object to viewer, backmap finite number of rays from viewer through each pixel to object to light source (or other object)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 6/42 Rendering with Raytracing (2/2) Subproblems to solve Generate primary (‘eye’) ray Find closest object along ray path - find the first intersection of a ray that goes out from the eye through a pixel center (or any other sample point on image plane) into the scene Light sample -use illumination model to determine light at closest surface element -generate ‘secondary’ rays from object

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 7/42 Raycasting Raycasting versus scan conversion scan conversion raycasting for each triangle in scene… for each sample in pixel image…

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 8/42 Raycasting Raycasting versus scan conversion How is raycasting different from what you’ve been doing in your assignments? In shapes you did: for each object in scene for each triangular facet of object pass vertex geometry and colors to OpenGL, which paints all interior points of the triangle in the framebuffer This is fine if you’re just using the simple hardware lighting model, and just using triangles We’re trying to solve a different problem: for each sample in our image determine which object in scene database the ray through that sample intersects paint that sample the color of the object at that point

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 9/42 Generating Rays (1/4) Ray origin Let’s look at the geometry of the problem in untransformed world-space - we’ll see why later We start a ray from an “eye point”: P We send it out in some direction  d from your eye toward a typical point on the film plane whose color we want to know Points along the ray have the form P + td where -P is the base point of the ray: the camera’s “eye point” -d is the unit vector direction of the ray -t is a nonnegative real number The “eye point” is the center of projection in the perspective view volume (we use perspective coords to avoid having to deal with the inverse of a perspective transformation later)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 10/42 Generating Rays (2/4) Ray direction We start raycasting with screen-space points (pixels). Need to find a point in 3-D that lies on the corresponding ray - we will use ray to intersect with the original objects in the original, untransformed world coordinate system Transform 2D screen-space points into points on the camera’s 3D film plane Any planes orthogonal to the look vector is a convenient film plane: constant z in canonical view volume Choose a plane to be the film plane and then create a function that maps screen-space points onto it -what’s a convenient plane? Try the far plane :-) -to convert, we just have to scale integer screen-space coordinates into floating point values between -1 and 1 canonical view volume Any plane z=k, -1<= k < 0 can be the film plane

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 11/42 Generating Rays (3/4) Ray direction(cont.) Transform film plane point into world-space point - we can make the direction vector between the eye and this world-space point -we need direction to be in world space so that we can intersect with the original object in the original, untransformed world coordinate system Normalizing transformation takes world-space points to points in the canonical view volume - translate to the origin, orient with the axes, scale x and y to adjust viewing angles, scale so that z: [-1, 0]; x,y: [-1, 1] Apply the inverse of the normalizing transformation: the Viewing Transformation

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 12/42 Generating Rays (4/4) Summary Start the ray at the center of projection (eye point) Transform 2D integer screen-space point onto the 3D film plane -use the far clip plane as the film plane -scale the points to fit between -1 and 1 -set their z to -1 so that they lie on the far clip plane Transform the 3D film plane point into the untransformed world coordinate system -need to undo the normalizing transformation (i.e., viewing transformation) Construct the direction vector -point minus point is a vector -world-space point minus eye point

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 13/42 Ray-Object Intersection (1/6) Implicit objects If an object is defined implicitly by a function f such that f(Q) = 0 if and only if Q is a point on the surface of the object, then ray-object intersection is comparatively easy -we can define many objects implicitly -implicit functions give you potentially infinite resolution -tessellating implicit functions is more difficult than using them directly For example, a circle of radius R is an implicit object in the plane, and its equation is points where f(x, y) = 0 are points on the circle An infinite plane is defined by the function: A sphere of radius R in 3-space: (A,B,C) (0,0,0) -D

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 14/42 Ray-Object Intersection (2/6) Implicit objects(cont.) At what points (if any) does the ray intersect the object? Points on the ray have the form P + td - t is any nonnegative real A point Q lying on the object has the property that f(Q) = 0 Combining, we want to know “For which values of t is f(P + td) = 0 ?” (if any) We are solving a system of simultaneous equations in x, y (in 2D) or x, y, z (in 3D)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 15/42 An Explicit Example (1/3) 2D ray-circle intersection example Consider the eye-point P = (-3, 1), the direction vector d = (.8, -.6) and the unit circle given by: A typical point of the ray is: Plugging this into the equation of the circle: Expanding, we get: Setting this to zero, we get:

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 16/42 An Explicit Example (2/3) 2D ray-circle intersection example (cont.) Using the quadratic formula: We get: Because we have a root of multiplicity 2, our ray intersects the circle at one point (i.e., it’s tangent to the circle) We can use the discriminant D = b 2 - 4ac to quickly determine if a ray intersects a curve or not - if D < 0, imaginary roots; no intersection -if D = 0, double root; ray is tangent -if D > 0, two real roots; ray intersects circle at two points Smallest non-negative real t represents intersection nearest to eye-point

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 17/42 An Explicit Example (3/3) 2D ray-circle intersection example (cont.) Generalizing: our approach will be to take an arbitrary implicit surface with an equation f(Q) = 0 and a ray P + td, and plug the latter into the former: This results, after some algebra, in an equation with t as unknown We then solve for t, analytically or numerically

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 18/42 Ray-Object Intersection (3/6) Implicit objects-multiple conditions For objects like cylinders, the equation in 3-space defines an infinite cylinder of unit radius, running along the y-axis Usually, it’s more useful to work with finite objects, e.g. such a unit cylinder truncated with the limits But how do we do the “caps?” The cap is the inside of the cylinder at the y extrema of the cylinder

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Picture We want intersections satisfying the cylinder: or top cap: or bottom cap: Andries van Dam, John Alex October 28, 2003 Raytracing 19/42 Ray-Object Intersection (4/6) Multiple conditions (cont.)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 20/42 Solve in a case-by-case approach Ray_inter_finite_cylinder: // Check for intersection with infinite cylinder ray_inter_infinite_cylinder(t1, t2) compute P + t1*d, P + t2*d // If intersection, is it between the “end caps”? if y > 1 or y < -1 for either t1 or t2, toss it // Check for intersection with top end cap Compute ray_inter_plane(t3, plane y = 1) Compute P + t3*d // If it intersects, is it within the “circle” on // the end? If x 2 + z 2 > 1, toss out t3 // Check intersection with other end cap Compute ray_inter_plane(t4, plane y = -1) Compute P + t4*d // If it intersects, is it within the “circle” on // the end? If x 2 + z 2 > 1, toss out t4 Among all the t’s that remain (1-4), select the smallest non-negative one Ray-Object Intersection (5/6) Multiple conditions-cylinder pseudocode

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 21/42 Ray-Object Intersection (6/6) Implicit surface strategy summary Turn an implicit surface equation into an equation for t and solve The thing you see “first” from eye point is at the smallest non-negative t-value For complicated objects (not defined by a single equation), write out a set of equalities and inequalities and then code as cases… Latter approach can be generalized cleverly to handle all sorts of complex combinations of objects -Constructive Solid Geometry (CSG), where objects are stored as a hierarchy of primitives and 3-D set operations (union, intersection, difference) -“blobby objects”, which are implicit surfaces defined by sums of implicit equations

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 22/42 World-Space Intersection One way to do intersection is to compute the equation of your object in world- space Example: a sphere translated to (3, 4, 5) after it was scaled by 2 in the x- direction has equation One can then take the ray P+td and plug it into the equation Solve the resulting equation for t Always start with the untransformed object definition in its own coordinate system We then try to derive what the transformed version should be, given the CTM (call it M) - this is not easy for general transformations, and furthermore, the transformed version of the equation is always more complicated and thus more expensive to compute -can we just work with the object in its own coordinate system? Yes, as follows: World space - a global view

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 23/42 Object-Space Intersection Express world-space point of intersection as MQ, where Q is some point in object- space: If is the equation of the untransformed object, we just have to solve -note d is probably not a unit vector -the parameter t along this vector and its world space counterpart always have the same value. Normalizing d would alter this relationship. Do NOT normalize d. Transform ray into object-space (0,0,0) MQ Q

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam, John Alex October 28, 2003 Raytracing 24/42 World-Space vs. Object-Space To compute world-space intersections, you have to transform the implicit equation of your canonical object defined in object space - often difficult But to compute intersections in object-space, you need only apply a matrix (M -1 ) to P and d, which is much simpler. -does M -1 exist? -M was composed from two parts: the cumulative modeling transformation that positions the object in world-space, and the camera’s normalizing transformation -the modeling transformations are just translations, rotations, and scales (all invertible) -the normalizing transformation also consists of translations, rotations and scales (also invertible); no perspective! (Now you see why we used the “hinged” perspective view volume) When you’re done, you get a t-value This t can be used in two ways: -P + td is the world-space location of the intersection of the ray with the transformed object -P + td is the corresponding point on the untransformed object (in object space) Use object-space if objects defined there