MIT EECS 6.837, Cutler and Durand 1 Ray Casting II.

Slides:



Advertisements
Similar presentations
Transformations in Ray Tracing MIT EECS 6.837, Durand and Cutler.
Advertisements

2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
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.
Transformations.
3D Graphics Rendering and Terrain Modeling
MIT EECS 6.837, Durand and Cutler Transformations.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Introduction to 3D Graphics Lecture 5: From Realism to Real-Time Anthony Steed University College London.
1 of 25 Assignment Orthographic Wireframe Elevation Orthographic Wireframe Plan Orthographic Wireframe End-Elevation Perspective View.
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
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.
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.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
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.
Week 13 - Wednesday CS361.
CS-321 Dr. Mark L. Hornick 1 3-D Object Modeling.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Computer graphics & visualization Ray-Tracing – A Quick review.
CS 431/636 Advanced Rendering Techniques Dr. David Breen University Crossings 149 Tuesday 6PM  8:50PM Presentation 2 4/7/09.
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.
Graphics Pipeline Rasterization CMSC 435/634. Drawing Terms Primitive – Basic shape, drawn directly – Compare to building from simpler shapes Rasterization.
Collision handling: detection and response
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
1 Ray Casting. CLASS 1 Ray Casting 2 3 Overview of Today Ray Casting Basics Camera and Ray Generation Ray-Plane Intersection.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
MIT EECS 6.837, Durand and Cutler Real-Time Shadows.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
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.
MIT EECS 6.837, Durand and Cutler Transformations.
Geometric Objects and Transformation
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
Interactive Rendering With Coherent Ray Tracing Eurogaphics 2001 Wald, Slusallek, Benthin, Wagner Comp 238, UNC-CH, September 10, 2001 Joshua Stough.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Computer Graphics Zhen Jiang West Chester University.
1 Dr. Scott Schaefer Intersecting Simple Surfaces.
MIT EECS Frédo Durand and Barb Cutler
Basic Ray Tracing CMSC 435/634.
Computer Graphics Lecture 08 Fasih ur Rehman. Last Class Ray Tracing.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
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.
CSCE 441: Computer Graphics Ray Tracing
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Line Clipping & Line Rasterization.
CS 551/651: Advanced Computer Graphics
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
Solid Modeling Dr. Scott Schaefer.
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.
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.
Basic Ray Tracing CMSC 435/634.
Rendering Pipeline Fall, 2015.
MIT EECS 6.837, Cutler and Durand
3D Graphics Rendering PPT By Ricardo Veguilla.
Ray Casting II MIT EECS Frédo Durand and Barb Cutler
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Presentation transcript:

MIT EECS 6.837, Cutler and Durand 1 Ray Casting II

MIT EECS 6.837, Cutler and Durand 2 Last Time? Ray Casting / Tracing Orthographic Camera Ray Representation –P(t) = origin + t * direction Ray-Sphere Intersection Ray-Plane Intersection Implicit vs. Explicit Representations

MIT EECS 6.837, Cutler and Durand 3 Explicit vs. Implicit? Explicit –Parametric –Generates points –Hard to verify that a point is on the object Implicit –Solution of an equation –Does not generate points –Verifies that a point is on the object

MIT EECS 6.837, Cutler and Durand 4 Assignment 1: Ray Casting Write a basic ray caster –Orthographic camera –Sphere Intersection –Main loop rendering –2 Display modes: color and distance We provide: –Ray (origin, direction) –Hit (t, Material) –Scene Parsing

MIT EECS 6.837, Cutler and Durand 5 Object-Oriented Design We want to be able to add primitives easily –Inheritance and virtual methods Even the scene is derived from Object3D! Object3D bool intersect(Ray, Hit, tmin) Plane bool intersect(Ray, Hit, tmin) Sphere bool intersect(Ray, Hit, tmin) Triangle bool intersect(Ray, Hit, tmin) Group bool intersect(Ray, Hit, tmin)

MIT EECS 6.837, Cutler and Durand 6 Graphics Textbooks Recommended for 6.837: Peter Shirley Fundamentals of Computer Graphics AK Peters Ray Tracing

MIT EECS 6.837, Cutler and Durand 7 Linear Algebra Review Session Monday Sept. 20 (this Monday!) Room (we hope) 7:30 – 9 PM

MIT EECS 6.837, Cutler and Durand 8 Questions? Image by Henrik Wann Jensen

MIT EECS 6.837, Cutler and Durand 9 Overview of Today Ray-Box Intersection Ray-Polygon Intersection Ray-Triangle Intersection Ray-Bunny Intersection & extra topics…

MIT EECS 6.837, Cutler and Durand 10 Ray-Box Intersection Axis-aligned Box: (X 1, Y 1, Z 1 ) → (X 2, Y 2, Z 2 ) Ray: P(t) = R o + tR d y=Y 2 y=Y 1 x=X 1 x=X 2 RoRo RdRd

MIT EECS 6.837, Cutler and Durand 11 Naïve Ray-Box Intersection 6 plane equations: compute all intersections Return closest intersection inside the box –Verify intersections are on the correct side of each plane: Ax+By+Cz+D < 0 y=Y 2 y=Y 1 x=X 1 x=X 2 RoRo RdRd

MIT EECS 6.837, Cutler and Durand 12 Reducing Total Computation Pairs of planes have the same normal Normals have only one non-0 component Do computations one dimension at a time y=Y 2 y=Y 1 x=X 1 x=X 2 RoRo RdRd

MIT EECS 6.837, Cutler and Durand 13 Test if Parallel If R dx = 0 (ray is parallel) AND R ox X 2 → no intersection y=Y 2 y=Y 1 x=X 1 x=X 2 RoRo RdRd

MIT EECS 6.837, Cutler and Durand 14 Find Intersections Per Dimension Calculate intersection distance t 1 and t 2 –t 1 = (X 1 - R ox ) / R dx –t 2 = (X 2 - R ox ) / R dx t1t1 t2t2 RoRo RdRd y=Y 2 y=Y 1 x=X 1 x=X 2

MIT EECS 6.837, Cutler and Durand 15 Maintain t near & t far Closest & farthest intersections on the object –If t 1 > t near, t near = t 1 –If t 2 < t far, t far = t 2 t near t far y=Y 2 y=Y 1 x=X 1 x=X 2 t1t1 t2t2

MIT EECS 6.837, Cutler and Durand 16 Is there an Intersection? If t near > t far → box is missed t near t far y=Y 2 y=Y 1 x=X 1 x=X 2

MIT EECS 6.837, Cutler and Durand 17 Is the Box Behind the Eyepoint? If t far < t min → box is behind t near t far y=Y 2 y=Y 1 x=X 1 x=X 2

MIT EECS 6.837, Cutler and Durand 18 Return the Correct Intersection If t near > t min → closest intersection at t near Else → closest intersection at t far t near t far y=Y 2 y=Y 1 x=X 1 x=X 2

MIT EECS 6.837, Cutler and Durand 19 Ray-Box Intersection Summary For each dimension, –If R dx = 0 (ray is parallel) AND R ox X 2 → no intersection For each dimension, calculate intersection distances t 1 and t 2 –t 1 = (X 1 - R ox ) / R dx t 2 = (X 2 - R ox ) / R dx –If t 1 > t 2, swap –Maintain t near and t far (closest & farthest intersections so far) –If t 1 > t near, t near = t 1 If t 2 < t far, t far = t 2 If t near > t far → box is missed If t far < t min → box is behind If t near > t min → closest intersection at t near Else → closest intersection at t far

MIT EECS 6.837, Cutler and Durand 20 Efficiency Issues 1/R dx, 1/R dy and 1/R dz can be pre-computed and shared for many boxes Unroll the loop –Loops are costly (because of termination if) –Avoid the t near & t far comparison for first dimension

MIT EECS 6.837, Cutler and Durand 21 Questions? Image by Henrik Wann Jensen

MIT EECS 6.837, Cutler and Durand 22 Overview of Today Ray-Box Intersection Ray-Polygon Intersection Ray-Triangle Intersection Ray-Bunny Intersection & extra topics…

MIT EECS 6.837, Cutler and Durand 23 Ray-Polygon Intersection Ray-plane intersection Test if intersection is in the polygon –Solve in the 2D plane

MIT EECS 6.837, Cutler and Durand 24 Point Inside/Outside Polygon Ray intersection definition: –Cast a ray in any direction (axis-aligned is smarter) –Count intersections –If odd number, point is inside Works for concave and star-shaped

MIT EECS 6.837, Cutler and Durand 25 Precision Issue What if we intersect a vertex? –We might wrongly count an intersection for exactly one adjacent edge Decide that the vertex is always above the ray

MIT EECS 6.837, Cutler and Durand 26 Winding Number To solve problem with star pentagon: –Oriented edges –Signed count of intersections –Outside if 0 intersections

MIT EECS 6.837, Cutler and Durand 27 Alternative Definition Sum of the signed angles from point to edges ±360°, ± 720°, … → point is inside 0° → point is outside

MIT EECS 6.837, Cutler and Durand 28 How Do We Project into 2D? Along normal –Costly Along axis –Smarter (just drop 1 coordinate) –Beware of degeneracies!

MIT EECS 6.837, Cutler and Durand 29 Questions? Image by Henrik Wann Jensen

MIT EECS 6.837, Cutler and Durand 30 Overview of Today Ray-Box Intersection Ray-Polygon Intersection Ray-Triangle Intersection Ray-Bunny Intersection & extra topics…

MIT EECS 6.837, Cutler and Durand 31 Ray-Triangle Intersection Use ray-polygon Or try to be smarter –Use barycentric coordinates RoRo RdRd c a b P

MIT EECS 6.837, Cutler and Durand 32 Barycentric Definition of a Plane P(  ) =  a +  b +  c with  =1 Is it explicit or implicit? [Möbius, 1827] c a b P P is the barycenter: the single point upon which the plane would balance if weights of size  are placed on points a, b, & c.

MIT EECS 6.837, Cutler and Durand 33 Barycentric Definition of a Triangle P(  ) =  a +  b +  c with  =1 AND 0 <  < 1 & 0 <  < 1 & 0 <  < 1 c a b P

MIT EECS 6.837, Cutler and Durand 34 How Do We Compute  Ratio of opposite sub-triangle area to total area –  = A a /A  = A b /A  = A c /A Use signed areas for points outside the triangle  c a b P AaAa A

MIT EECS 6.837, Cutler and Durand 35 Intuition Behind Area Formula P is barycenter of a and Q A a is the interpolation coefficient on aQ All points on lines parallel to bc have the same   All such triangles have same height/area) Q c a b P AaAa A

MIT EECS 6.837, Cutler and Durand 36 Simplify Since  =1, we can write  P(  ) =  a +  b +  c P(  ) =  a +  b +  c = a +  b-a) +  c-a) c a b P Non-orthogonal coordinate system of the plane rewrite

MIT EECS 6.837, Cutler and Durand 37 Intersection with Barycentric Triangle Set ray equation equal to barycentric equation P(t) = P(  ) R o + t * R d = a +  b-a) +  c-a) Intersection if  0 (and t > t min … ) RoRo RdRd c a b P

MIT EECS 6.837, Cutler and Durand 38 Intersection with Barycentric Triangle R o + t * R d = a +  b-a) +  c-a) R ox + tR dx = a x +  b x -a x ) +  c x -a x ) R oy + tR dy = a y +  b y -a y ) +  c y -a y ) R oz + tR dz = a z +  b z -a z ) +  c z -a z ) Regroup & write in matrix form: 3 equations, 3 unknowns      ozz oyy oxx dzzzzz dyyyyy dxxxxx Ra Ra Ra Rcaba Rcaba Rcaba                                t  

MIT EECS 6.837, Cutler and Durand 39 Cramer’s Rule A RRaba RRaba RRaba dzozzzz dyoyyyy dxoxxxx     A Racaba Racaba Racaba t ozzzzzz oyyyyyy oxxxxxx     A RcaRa RcaRa RcaRa dzzzozz dyyyoyy dxxxoxx     | | denotes the determinant Can be copied mechanically into code Used to solve for one variable at a time in system of equations

MIT EECS 6.837, Cutler and Durand 40 Advantages of Barycentric Intersection Efficient Stores no plane equation Get the barycentric coordinates for free –Useful for interpolation, texture mapping RoRo RdRd c a b P

MIT EECS 6.837, Cutler and Durand 41 Questions? Image computed using the RADIANCE system by Greg Ward

MIT EECS 6.837, Cutler and Durand 42 Overview of Today Ray-Box Intersection Ray-Polygon Intersection Ray-Triangle Intersection Ray-Bunny Intersection & extra topics…

MIT EECS 6.837, Cutler and Durand 43 Triangle Meshes (.obj) v v v v v v v v f f f f f f f f f f f f vertices triangles

MIT EECS 6.837, Cutler and Durand 44 Acquiring Geometry 3D Scanning CyberwareDigital Michealangelo Project (Stanford)

MIT EECS 6.837, Cutler and Durand 45 Precision What happens when –Origin is on an object? –Grazing rays? Problem with floating-point approximation

MIT EECS 6.837, Cutler and Durand 46 The evil  In ray tracing, do NOT report intersection for rays starting at the surface (no false positive) –Because secondary rays –Requires epsilons reflection refraction shadow

MIT EECS 6.837, Cutler and Durand 47 The evil  a hint of nightmare Edges in triangle meshes –Must report intersection (otherwise not watertight) –No false negative

MIT EECS 6.837, Cutler and Durand 48 Constructive Solid Geometry (CSG) Given overlapping shapes A and B: Union Intersection Subtraction

MIT EECS 6.837, Cutler and Durand 49 For example:

MIT EECS 6.837, Cutler and Durand 50 How can we implement CSG? Union Intersection Subtraction Points on A, Outside of B Points on B, Outside of A Points on B, Inside of A Points on A, Inside of B

MIT EECS 6.837, Cutler and Durand 51 Collect all the intersections Union Intersection Subtraction

MIT EECS 6.837, Cutler and Durand 52 Implementing CSG 1.Test "inside" intersections: Find intersections with A, test if they are inside/outside B Find intersections with B, test if they are inside/outside A 2.Overlapping intervals: Find the intervals of "inside" along the ray for A and B Compute union/intersection/subtraction of the intervals

MIT EECS 6.837, Cutler and Durand 53 Early CSG Raytraced Image

MIT EECS 6.837, Cutler and Durand 54 Questions?

MIT EECS 6.837, Cutler and Durand 55 Next week: Transformations