Ray Intersection Acceleration

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
An Introduction to Light Fields Mel Slater. Outline Introduction Rendering Representing Light Fields Practical Issues Conclusions.
CSE 681 Bounding Volumes. CSE 681 Bounding Volumes Use simple volume enclose object(s) tradeoff for rays where there is extra intersection test for object.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Ray Tracing Ray Tracing 1 Basic algorithm Overview of pbrt Ray-surface intersection (triangles, …) Ray Tracing 2 Brute force: Acceleration data structures.
IIIT Hyderabad Hybrid Ray Tracing and Path Tracing of Bezier Surfaces using a mixed hierarchy Rohit Nigam, P. J. Narayanan CVIT, IIIT Hyderabad, Hyderabad,
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Ray Tracing CMSC 635. Basic idea How many intersections?  Pixels  ~10 3 to ~10 7  Rays per Pixel  1 to ~10  Primitives  ~10 to ~10 7  Every ray.
CS 445 Greg Humphreys, Spring 2003 Ray Tracing 2: Acceleration.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Ray Tracing Variants Distributed ray tracing Generalized rays Cone Tracing Beam Tracing Pencil.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Ray Tracing Acceleration Structures Solomon Boulos 4/16/2004.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
18.1 Si31_2001 SI31 Advanced Computer Graphics AGR Lecture 18 Image-based Rendering Light Maps What We Did Not Cover Learning More...
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
1 View Coherence Acceleration for Ray Traced Animation University of Colorado at Colorado Springs Master’s Thesis Defense by Philip Glen Gage April 19,
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Ray Tracing Primer Ref: SIGGRAPH HyperGraphHyperGraph.
Acceleration Digital Image Synthesis Yung-Yu Chuang 10/4/2005 with slides by Mario Costa Sousa and Pat Hanrahan.
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
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.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
Collision handling: detection and response
David Luebke10/9/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CS 376 Introduction to Computer Graphics 04 / 16 / 2007 Instructor: Michael Eckmann.
Graphics Graphics Korea University cgvr.korea.ac.kr Solid Modeling 고려대학교 컴퓨터 그래픽스 연구실.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
Visible-Surface Detection Jehee Lee Seoul National University.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
College of Computer and Information Science, Northeastern UniversityOctober 31, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2009.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Shapes Digital Image Synthesis Yung-Yu Chuang with slides by Pat Hanrahan.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Dynamic Scenes Paul Arthur Navrátil ParallelismJustIsn’tEnough.
Shapes Digital Image Synthesis Yung-Yu Chuang 10/05/2006 with slides by Pat Hanrahan.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection.
Maths & Technologies for Games Spatial Partitioning 2
Advanced topics Advanced Multimedia Technology: Computer Graphics Yung-Yu Chuang 2006/01/04 with slides by Brian Curless, Zoran Popovic, Mario Costa Sousa.
3D Object Representations 2011, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
MIT EECS 6.837, Durand and Cutler Acceleration Data Structures for Ray Tracing.
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
RENDERING : Global Illumination
CSE 681 Introduction to Ray Tracing. CSE 681 Ray Tracing Shoot a ray through each pixel; Find first object intersected by ray. Image plane Eye Compute.
Ray Tracing Acceleration (5). Ray Tracing Acceleration Techniques Too Slow! Uniform grids Spatial hierarchies K-D Octtree BSP Hierarchical grids Hierarchical.
David Luebke3/12/2016 Advanced Computer Graphics Lecture 3: More Ray Tracing David Luebke
Shapes Digital Image Synthesis Yung-Yu Chuang 10/1/2008 with slides by Pat Hanrahan.
Ray Tracing Acceleration (1). Acceleration of Ray Tracing Goal: Reduce the number of ray/primitive intersections.
Solid Modeling Dr. Scott Schaefer.
3D Object Representations 2009, Fall. Introduction What is CG?  Imaging : Representing 2D images  Modeling : Representing 3D objects  Rendering : Constructing.
Ray Tracing Acceleration (3)
Bounding Volume Hierarchies and Spatial Partitioning
Computational Geometry
Bounding Volume Hierarchies and Spatial Partitioning
Real-Time Ray Tracing Stefan Popov.
Ray Tracing Acceleration Techniques
3D Object Representations
CMSC 635 Ray Tracing.
Digital Image Synthesis Yung-Yu Chuang 10/4/2005
Collision Detection.
Presentation transcript:

Ray Intersection Acceleration CIS782 Advanced Computer Graphics Raghu Machiraju Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Reading Chapter 2, 3, 4 of “Physically Based Rendering” by Pharr&Humphreys Please add as you see fit Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Ray Tracing Shoot a ray through each pixel; Find first object intersected by ray Compute ray. (More linear algebra.) Compute ray-object intersection. Spawn more rays for reflection and refraction Image plane Eye Torsten Möller, Raghu Machiraju

Ray Tracing Architecture Sample Generator Scene Image LRT TIFF Parse Film Camera Primitives Radiance Eye rays Rays Shape intersect Shadow, reflection, refraction rays Lights Integrator Material Surf Torsten Möller, Raghu Machiraju

Optimizing Ray Tracing Main computation load is ray-object intersection 50-90% of run time when profiled Test for possible intersection before committing to computing intersections Where did you get the stats from? Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Consider this  Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Complexity ! I rays or pixels in image N objects O(NI) Can we do O(I logN) ? Torsten Möller, Raghu Machiraju

Ray Intersection Acceleration Where did you get this image from? Torsten Möller, Raghu Machiraju

Pbrt and Intersections Primitive base class Shapes are subclasses of primitive Aggregate class Methods WorldBound CanIntersect Intersect IntersectP Refine First four return Intersection structures Last returns Primitives Primitives Shape Lights See Pharr, Humphreys p.171 Worldbound - bounding box CanIntersect - is the shape able to compute intersections?: sometimes we just have a place holder; out-of-core geometry Intersect - returns geometry of the intersection point intersectP - just a yes/no whether there is an intersections Refine - refine the geometry for more accurate intersection testing (especially if CanIntersect is false) Material Torsten Möller, Raghu Machiraju

Intersection Geometry Shape independent representation for intersections DifferentialGeometry Intersection::dg Point P Normal N Parametric (u,v) Partial derivatives Tangents: dpdu, dpdv change in normal: dndu, dndv See Pharr, Humphreys p. 83, 172 Torsten Möller, Raghu Machiraju

Object-based vs. World-based Common dichotomy in graphics objects situated in (world) space (world) space in which objects reside Bounding volumes are object-based Spatial Subdivision is world-based approach Sub-linear search – logarithmic ? Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Bounding Volumes Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Bounding Volumes Surround object with a simple volume Test ray against volume first Test object-space or world-space bound? (pros and cons) Cost model - N*cb + pi*N*co N (number of rays) is given pi – fraction of rays intersecting bounding volume Minimize cb (cost of intersecting bounding volume) and co (cost of intersecting object) Reduce ray path Minimize cost/fit ratio Bounding sphere Difficult to compute good one Easy to test for intersection Bounding box Easy to compute for given object Relatively difficult to intersect (maybe ?) Reduce ray path Arvo&Kirk-Glassner pp.209 Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Pbrt’s Bounding Boxes Virtual BBox ObjectBound() const=0; Virtual BBox WorldBound() const { return ObjectToWorld(ObjectBound()); } Bool BBox::IntersectP(Const Ray &ray, Float *hit0, Float *hitt1) const { } Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Bounding Box Compute min/max for x,y,z 3 options Compute in world space Chance of ill fitting b-box Compute in object space and transform w/object Object space b-box probably better fit than world space Need to intersect ray with arbitrary hexahedral in world sp. Compute in object space and test in object space Inverse transform ray into object space Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Ray & Cube P(t) = s + tc Y = y2 Z = z2 tx1 = (x1 - sx)/cx X = x1 X = x2 Z = z1 tx2 = (x2 - sx)/cx Y = y1 ty1 = (y1 - sx)/cx … Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Square/Cube Note entering and leaving intersections separately Ray is inside after last entering and before first leaving Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Algorithm set Tnear = - infinity, Tfar = infinity Ray (t) = O + t * Ray For each pair of planes P associated with X, Y, and Z do: (example using X planes) if direction Rayx = 0 then the ray is parallel to the X planes if origin Ox is not between the slabs ( Ox < Xl or Ox > Xh) then return false else if the ray is not parallel to the plane then begin compute the intersection distance of the planes T1 = (Xl - Ox) / Xd T2 = (Xh - Ox) / Xd If T1 > T2 swap (T1, T2) - since T1 intersection with near plane If T1 > Tnear Tnear =T1 - want largest Tnear If T2 < Tfar Tfar="T2" - want smallest Tfar If Tnear > Tfar - box is missed so return false If Tfar < 0 - box is behind ray return false end If Box survived all above tests, return true with intersection point Tnear and exit point Tfar. Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Bounding Sphere Find min/max points in x,y,z -> 3 pairs Use maximally separated pair to define initial sphere For each point If point is outside of current sphere, increase old sphere to just include new point Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju P C R rad P C R rad P P R newrad = (R+rad)/2 newC P P newrad newrad R newC C newC = P+(newrad/R)(C-P) Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Bounding Slabs More complex to compute Better fit of object Use multiple pairs of parallel planes to bound object Can add more slabs to get tighter fit © 2004 Pharr, Humphreys Torsten Möller, Raghu Machiraju

Approximate Convex Hull Find highest vertex Find plane through vertex parallel to ground plane Find second vertex that makes minimum angle with first vertex and up vector Find third vertex that makes plane whose normal makes minimum angle with up vector Where did you get this image from? Also - I don’t understand your algorithm! Where can I read up on this? Slabs - More effort to compute, better fit Torsten Möller, Raghu Machiraju

Hierarchical Bounding Volumes Compute bounding volume for groups of objects Compute bounding volume for groups of groups of objects Torsten Möller, Raghu Machiraju

Hierarchical Bounding Volumes Create tree of bounding volumes Children are contained within parent Creation preprocess From model hierarchy Automatic clustering Search intersect(node,ray,hits) { if( intersectp(node->bound,ray) if( leaf(node) ) intersect(nodeprims,ray,hits) else for each child intersect(child,ray,hits) } Return the closest of all hits ! Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Problem Subtrees overlap Does not contain all objects it overlaps Balance Tree Organization Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Spatial Enumeration Divide space into ‘voxels’ Bucket sort objects in voxels they intersect Object goes into each voxel it touches Reuse results from one voxel calculation Determine voxels that a ray intersects Only deal with the objects in those voxels Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Spatial Enumeration Identifying voxels hit is like a line drawing algorithm Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Uniform Grids Preprocess scene Find Big bounding box Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Uniform Grids Preprocess scene Find Big bounding box Determine grid resolution (how ?) What’s the trade-off here in grid resolution? Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Uniform Grids Preprocess scene Find bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Uniform Grids Preprocess scene Find Big bounding box Determine grid resolution Place object in cell if its bounding box overlaps the cell Check that object overlaps cell (expensive!) How would you check that the object overlaps a cell actually you need to check that the surface of the object intersects a cell as shown in slide Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Add Sorting If objects/voxels/cells are processed in front-to-back sorted order, stop processing when first intersection is detected e.g., process cells in bottom to top, left to right order and stop at first intersection Looks like it should be bottom to top, left to right OR left to right, bottom to top Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Uniform Grids Preprocess scene Traverse grid 3D line = 3D-DDA 6-connected line pbrt algorithm (grid accelarator) Why 6-connected line? Torsten Möller, Raghu Machiraju

Amanatides & Woo Algorithm J. Amanatides and A. Woo, "A Fast Voxel Traversal Algorithm for Ray Tracing", Proc. Eurographics '87, Amsterdam, The Netherlands, August 1987, pp 1-10. tMax[X,Y] are t values of next intersection of ray with x|y grid lines Step[X,Y] +/- 1 tMax[X,Y] – first intersection tDelta[X,Y] - voxel distance in [X,Y] Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju A&W Algorithm Find smallest of x,y,z and step that one Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju A&W Algorithm Results Rendering time for different levels of subdivision Goes up at end – too much subdivision Why? Torsten Möller, Raghu Machiraju

Objects Across Multiple Voxels Mailboxes eliminate redundant intersection tests Objects have mailboxes Assign rays numbers check against objects last tested ray number Intersection must be within current voxel Mailboxing - a ray id is stored with each primitive, that was last tested for intersections with this ray already. (Pharr, Humphreys, p. 183) Torsten Möller, Raghu Machiraju

Hierarchical Spatial Subdivision Recursive subdivision of space 1-1 Relationship between scene points and leaf nodes Example: point location by recursive search(log time) Solves the lack-of-adaptability problem DDA works Effective in practice Course subdivision – if there’s an object inside, subdivide and step through again It looks like more subdivision in the tested voxels would help. Where? Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Variations Variations on subdivision – alternatively along coordinate planes, along object boundaries (not shown quite so) KD tree octtree BSP tree Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Example A D B B C C D Did you create this? A Leaves are unique regions in space Recursive search KdTreeAccel - pbrt Torsten Möller, Raghu Machiraju

Creating Spatial Hierarchies insert(node,prim) { if( overlap(node->bound,prim) ) if( leaf(node) ) { if( node->nprims > MAXPRIMS && node->depth < MAXDEPTH ) { subdivide(node); foreach child in node insert(child,prim) } else list_insert(node->prims,prim); else // Typically MAXDEPTH=16, MAXPRIMS=2-8 Insert primitive into node; if prim overlaps node – if this is a leaf node, subdivide it (if able to), and insert prim into children Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Comparison Scheme Spheres Rings Tree Uniform grid D=1 244 129 1517 D=20 38 83 781 Hierarchical grid 34 116 See “A Proposal for Standard Graphics Environments”, IEEE Computer Graphics and Applications, vol. 7, no. 11, November 1987, pp. 3-5 Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Questions? Some complexity numbers Triangle Sphere Scenes to render? “Teapot in a stadium” versus uniform distribution Multiplicative constants important Adaptability allows robustness Cache effects are important See http://sgi.felk.cvut.cz/BES/ Best Efficiency Scheme Project “teapot in a stadium” - “If there is a small region of space with a lot of geometry in it, all that geometry might fall in a single voxel, and performance will suffer when a ray passes through this voxel, as many intersection tests will be performed.” (Pharr, Humphreys p. 181) Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Figure 7 Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Figure 9 Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju L, G for Ellipsoids Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Ellipsoid Blend Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju Ellipsoid Blend Torsten Möller, Raghu Machiraju

Torsten Möller, Raghu Machiraju What is next? Where did you get the images from? Torsten Möller, Raghu Machiraju