Recall: Inside Triangle Test

Similar documents
Parallel Physically Based Path-tracing and Shading Part 3 of 2. CIS565 Fall 2012 University of Pennsylvania by Yining Karl Li

Computer Graphics. - Spatial Index Structures - Philipp Slusallek

Ray Tracing Acceleration Data Structures

Intersection Acceleration

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Spatial Data Structures

Acceleration Data Structures

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Acceleration. Welcome!

Accelerated Raytracing

Spatial Data Structures

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Bounding Volume Hierarchies

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Spatial Data Structures

CS535 Fall Department of Computer Science Purdue University

Lecture 2 - Acceleration Structures

Ray Tracing with Spatial Hierarchies. Jeff Mahovsky & Brian Wyvill CSC 305

Ray Tracing Acceleration. CS 4620 Lecture 20

Spatial Data Structures

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Acceleration Structures. CS 6965 Fall 2011

Spatial Data Structures

Today. Acceleration Data Structures for Ray Tracing. Cool results from Assignment 2. Last Week: Questions? Schedule

Using Bounding Volume Hierarchies Efficient Collision Detection for Several Hundreds of Objects

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Ray Tracing Acceleration. CS 4620 Lecture 22

Collision Detection. Jane Li Assistant Professor Mechanical Engineering & Robotics Engineering

Ray-tracing Acceleration. Acceleration Data Structures for Ray Tracing. Shadows. Shadows & Light Sources. Antialiasing Supersampling.

Lesson 05. Mid Phase. Collision Detection

Collision Detection based on Spatial Partitioning

improving raytracing speed

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

Computer Graphics. - Ray-Tracing II - Hendrik Lensch. Computer Graphics WS07/08 Ray Tracing II

CPSC / Sonny Chan - University of Calgary. Collision Detection II

EDAN30 Photorealistic Computer Graphics. Seminar 2, Bounding Volume Hierarchy. Magnus Andersson, PhD student

Accelerating Ray-Tracing

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

MSBVH: An Efficient Acceleration Data Structure for Ray Traced Motion Blur

Spatial Data Structures. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

CS 563 Advanced Topics in Computer Graphics Culling and Acceleration Techniques Part 1 by Mark Vessella

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology

Lecture 11: Ray tracing (cont.)

Point Cloud Filtering using Ray Casting by Eric Jensen 2012 The Basic Methodology

Computer Graphics Ray Casting. Matthias Teschner

Advanced Ray Tracing

Simulation in Computer Graphics Space Subdivision. Matthias Teschner

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

Speeding up your game

More Hidden Surface Removal

Questions from Last Week? Extra rays needed for these effects. Shadows Motivation

CS 431/636 Advanced Rendering Techniques

Lecture 17: Solid Modeling.... a cubit on the one side, and a cubit on the other side Exodus 26:13

Bounding Volume Hierarchies. CS 6965 Fall 2011

Collision and Proximity Queries

Collision Detection with Bounding Volume Hierarchies

Universiteit Leiden Computer Science

Ray Intersection Acceleration

Spatial Data Structures and Acceleration Algorithms

Collision Detection II. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Advanced 3D-Data Structures

Dynamic Collision Detection

Ray Intersection Acceleration

Real-Time Collision Detection for Dynamic Virtual Environments

CS580: Ray Tracing. Sung-Eui Yoon ( 윤성의 ) Course URL:

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

Spatial Data Structures and Acceleration Algorithms

Geometric data structures:

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

INFOMAGR Advanced Graphics. Jacco Bikker - February April Welcome!

Logistics. CS 586/480 Computer Graphics II. Questions from Last Week? Slide Credits

Dynamic Bounding Volume Hierarchies. Erin Catto, Blizzard Entertainment

Lecture 4 - Real-time Ray Tracing

Finding point-pairs. Engineering Research Center for Computer Integrated Surgical Systems and Technology. Copyright CISST ERC, 2000

Collision Detection. Motivation - Dynamic Simulation ETH Zurich. Motivation - Path Planning ETH Zurich. Motivation - Biomedical Simulation ETH Zurich

9. Visible-Surface Detection Methods

Spatial Data Structures for Computer Graphics

Ray Tracing: Intersection

VIII. Visibility algorithms (II)

11 - Spatial Data Structures

Ray Genealogy. Raytracing: Performance. Bounding Volumes. Bounding Volume. Acceleration Classification. Acceleration Classification

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Sung-Eui Yoon ( 윤성의 )

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Acceleration Data Structures for Ray Tracing

CMSC 754 Computational Geometry 1

Geometry proxies (in 2D): a Convex Polygon

l Without collision detection (CD), it is practically impossible to construct e.g., games, movie production tools (e.g., Avatar)

Overview. Collision Detection. A Simple Collision Detection Algorithm. Collision Detection in a Dynamic Environment. Query Types.

Exploiting Local Orientation Similarity for Efficient Ray Traversal of Hair and Fur

Solid Modeling. Ron Goldman Department of Computer Science Rice University

Acceleration Data Structures. Michael Doggett Department of Computer Science Lund university

Transcription:

1/45

Recall: Inside Triangle Test 2D Bounding Boxes rasterize( vert v[3] ) { bbox b; bound3(v, b); line l0, l1, l2; makeline(v[0],v[1],l2); makeline(v[1],v[2],l0); makeline(v[2],v[0],l1); for( y=b.ymin; y<b.ymax, y++ ) for( x=b.xmin; x<b.xmax, x++ ){ e0 = l0.a * x + l0.b * y + l0.c; e1 = l1.a * x + l1.b * y + l1.c; e2 = l2.a * x + l2.b * y + l2.c; if( inside(e0,l0)&&inside(e1,l1)&&inside(e2,l2) ) fragment(x,y); } } 2/45

Bounding Volumes Enclose a complex object within a simpler piece of geometry: Sphere Box (axis-aligned, object-aligned) If the ray does not hit the bounding volume, it cannot hit the enclosed complex object Avoid a significantly more expensive intersection test with the complex object 3/45

4/45

Bounding Sphere A sphere enclosing all of the vertices of the object. Fastest bounding volume for an intersection test with a ray Minimize the radius of the bounding sphere For a triangle or a tetrahedron, the minimal radius is simply the radius of its circumsphere What about more complex objects? 5/45

Bounding Sphere A straightforward construction: Compute the centroid PC of all the vertices Loop through the vertices and compute the maximal Pi-PC 2 to find the farthest vertex Pfarthest from PC Pfarthest-PC is the minimal radius For a crowd of points with one discrete point far away, the radius calculated in this way is around twice as big as the minimal one A hierarchical construction: Build the bounding sphere for each triangle Recursively merge the neighboring spheres into larger ones until all the spheres are merged into a single sphere The radius of that sphere is more minimal 6/45

Pros and Cons Advantages: Constructing a bounding sphere is fast Ray-sphere intersection test is fast No need to change the bounding sphere when the o je t rotates rotati g a sphere does t ha ge it Disadvantages: Cannot tightly enclose the object in some cases, e.g. long and thin objects leads to many false positives 7/45

Axis-Aligned Bounding Boxes 8/45

Axis-Aligned Bounding Box (AABB) An axis-aligned box containing the object Constructing an AABB is trivial: Loop through all vertices and find the min and max values in each dimension Use the min/max values as the diagonal corners of the bounding box 9/45

Ray-AABB Intersection A box is the interior of the intersection of 3 pairs of planes Detect the intersection between the ray and the box by detecting the intersections between the ray and the three pairs of planes For each pair of planes there are two intersection points Pnear and Pfar 6 intersection points in total If the maximal Pnear is before the minimal Pfar on the ray, the ray misses the box; otherwise it hits the box 10/45

Pros and Cons Advantages Constructing an AABB is simple and efficient Scanning the vertices to find min and max values in each dimension takes O(n) time Ray-box intersection test is fast Disadvantages Need to recalculate the bounding box any time an object rotates (unless the ray is transformed into object space!) Cannot tightly enclose the object (similar to spheres) 11/45

Oriented Bounding Boxes 12/45

Oriented Bounding Box (OBB) The orientation of the box depends on the orientation of the object Do t eed to re o pute the o whe the o je t rotates Can pre-compute the OBB in object space and transform it to world space with the object (note, the same is true for spheres) 13/45

Constructing an OBB To compute the principle orientation of the object: Singular Value Decomposition (SVD) Compute the covariance matrix, and the eigenvalues and corresponding eigenvectors of this 3x3 matrix Using these eigenvectors as the basis of the local coordinate system of the bounding box Similar to moment of inertia calculations for rigid bodies (except with a homogeneous mass density) Or just estimate the principal directions with some heuristi s 14/45

Ray-OBB Intersection Similar to Ray-AABB intersection Calculate the maximum tnear and the minimum tfar The planes are not axis aligned any more Recall how to compute intersection between a ray and an arbitrary plane in 3D space (lecture 11) 15/45 Ray-AABB intersection Ray-OBB intersection

Or tra sfor the ra Transform the ray into the OBB coordinate system and perform the ray-aabb intersection test World Coordinates OBB Coordinates 16/45

Pros and Cons Advantages Fits the object tighter than an AABB or sphere, so it prunes out more rays Disadvantages Extra cost for ray-box intersection Finding an OBB is computationally expensive (but can usually be done as a pre-computation) Finding the minimal OBB can be difficult (but an approximation is usually good enough) 17/45

Bounding Volume Hierarchies 18/45

Bounding Volume Hierarchies (BVHs) Subparts of objects can be contained in their own bounding boxes in a hierarchical fashion For example, sub-obbs can be constructed by recursively splitting an OBB using center points along the longest axis [Gottschalk et.al. 96] [Kamat and Martinez, 2007] 19/45

BVH Tree Structure Each leaf represents a bounding volume at the lowest level of the hierarchy Nodes at higher levels of the tree represent bounding volumes that enclose all the bounding volumes of that ode s hildre 20/45

Constructing BVHs Top down Begin with the bounding volume for the entire object Recursively split the object into smaller pieces according to some criteria, and construct bounding volumes for these sub-pieces E.g., split primitives w.r.t the longest coordinate axis Stop when some tolerance is reached for leaf nodes Bottom up Begin with a bounding volume for each subpart of an object Recursively merge them into larger volumes according to some criteria e.g., merge nearest neighbors Stop when there is only a single bounding volume at the root 21/45

Hierarchal Ray Traversal Intersect child bounding volumes only if intersections are found with the parent Intersect low level geometry only if a leaf node is reached and the ray intersects its bounding volume 22/45

Early Termination Here, every node and triangle needs to be checked, except for the triangle in F which is skipped since the ray does not intersect sphere F However, sorting the intersections based on the ray parameter, and finding the intersection with the triangle in G before checking the triangles in H and I allows those intersection tests to be skipped 23/45

24/45

Ray-Scene Intersection Each object should have a BV or BVH Traversing all objects in the scene for each ray is inefficient Need auxiliary structures to accelerate this process 25/45

Two Uses for BVHs Create a BVH for an individual object to serve as its bounding volume (we already considered this) The BVH is in object space As long as we transform the rays into object space, the BVH can be precomputed and does not need to be updated Create a BVH for unioning together all the bounding volumes of all the objects in the scene (new) If an object has its own object BVH, just use the root BV of the BVH This newly constructed global (scene) BVH is in world space Must be updated whenever something moves in the scene Do both! 26/45

Glo al S e e BVHs do t alwa s work well If many similar sized objects are approximately uniformly distributed in space, the global BVH hierarchy is vertically traversed quite a bit looking for the object the ray intersects O e a do etter Shorebirds by Jim Charter 2000 http://hof.povray.org/shorebir.html "Warm Up" by Norbert Kern (2001) http://hof.povray.org/warm_up.html 27/45

28/45

Uniform Spatial Partition Partition all of space and register objects with the cells that their bounding volumes overlap 29/45

Uniform Grids Divide 3D space into nx*ny*nz axis-aligned grid cells Perform ray-object intersection tests only when the ray hits a grid cell containing an object The size of the grid s ells is ru ial to the perfor a e No speedup if the cell size is too big; no pruning, if everything is in one cell A lot of empty cells, if the cell size is too small; the same object may be in too many different cells A practical way to choose cell size is to average the edge lengths of the bounding volumes of all the objects 30/45

Constructing a Uniform Grid Find a bounding box for the entire scene Initialize the grid with that bounding box and a properly chosen cell size Each cell maintains a list (or an array) to store the objects whose bounding volumes overlap that cell Insert objects into cells The same object may be inserted into multiple cells 31/45

Ray Traversal Traverse all the cells pierced by the ray until the ray intersects with a primitive or reaches the boundary of the uniform grid 32/45

Ray Traversal An incremental algorithm similar to line rasterization From the current intersection point P on the face of cell (i, j, k), perform ray-plane intersection tests with the next 3 grid planes along the ray direction to get the 3 candidate intersection points for the next intersection The next intersection point is the nearest one among the 3 candidates Update the cell index according to the new intersection point. Perform rayprimitive intersection tests in the new cell Repeat the above process until the ray intersects with a primitive or reaches the boundary of the bounding box 33/45

Ray Traversal Optimization The intersections with the grid planes have the same spacing in each independent dimension Use precomputed δtx, δty, and δtz in order to avoid ray-plane intersection tests δtx =Cx/Dx, δty =Cy/Dy, δtz =Cz/Dz, in which (Cx, Cy, Cz) is the cell size and (Dx, Dy, Dz) is the ray direction 34/45

Avoid Redundant Intersection Tests A primitive may be stored in multiple cells An intersection test on that primitive may accidently be performed repeatedly for every cell that it is in Store a bool with each primitive If the primitive has already been determined to not intersect the ray, or is not the closest intersecting primitive, store false Before an actual ray-primitive intersection test, check the bool to see if the intersection was already performed 35/45

36/45

Viewing Frustums Se d ra s i a era spa e Create a uniform grid in the frustum space Avoid the traversal steps and plane intersection tests Cache coherent, all the cells are aligned along the ray! Can traverse a bundle of rays at the same time 37/45

38/45

Optimizing the Uniform Grid Optimizing storage Spatial Hashing: use a hash table instead of a 3D array Avoid the extra storage for a large number of empty cells Optimizing performance Adaptive grids: rectilinear grid, grid hierarchy, octree Rectilinear Grid Grid Hierarchy Octree 39/45

40/45

Octree Each node has 0 or 8 children Each node can equally subdivide its space (an AABB) into eight subboxes by 3 midplanes Children of a node are contained within the box of the node itself 41/45

Constructing an Octree Top-down: Find the global bounding box that contains all the primitives and make it the root Recursively partition a node into 8 octants by 3 midplanes If a primitive belongs to multiple octants, put it in all of them Recursion stops when the termination criteria are satisfied. e.g., maximum depth, minimum number of primitives in a node, etc. 42/45

Ray Traversal Traverse all leaf nodes in the octree passed through by the ray and perform intersection tests for the primitives inside those leaves Si ilar to the sa e as a BVH 43/45

Observation For a given ray and parent box, the subboxes that intersect the ray and their order of intersection is determined by the intersection points of the parent box 44/45

Find the Next Subnode Build an automaton whose states correspond to the boxes and whose transitions are associated to the movements between neighboring sub-nodes visited sequentially by the ray 45/45

E a ple 46/45

47/45

Hybrid Structure Start with a uniform grid and subdivide each node Each node of a uniform grid can contain its own octree Improves performance over that of a standard octree: no need to traverse the tree from a single root every time 48/45 [Losasso et.al. 2006]

49/45

K-d Tree Use a hyperplane translated in one dimension 50/45

K-d Tree A binary tree for space searching: Every non-leaf node can be thought of as implicitly generating a splitting hyperplane that divides space into two parts Points to the left of this hyperplane are represented by the left subtree of that node and points to the right of this hyperplane are represented by the right subtree 51/45

Constructing a K-d Tree Top-down: Begin with the global bounding box containing all primitives. Choose an axis and a splitting plane perpendicular to that axis Subdivide the primitives on both sides of the plane into two groups Stop when the number of primitives in each single group is below a threshold 52/45

Ray Traversal Traverse all leaf nodes in the k-d tree passed through by the ray 53/45

Recursive Traversal Similar to recursive traversal in an octree Each interior node has two children, there are 3 cases for subnode intersections: left child only, the right child only, and both The number of intersected subboxes and its sequence can be determined by the intersection points Notice the difference with an octree; the splitting plane is not necessarily in the middle of the box 54/45

Non-Recursive Traversal Recursion is expensive on the GPU for real-time ray tracing Kd-Restart Restart the traversal at the root every time it reaches a leaf Kd-Backtrack return to parent nodes to enable traversing other unvisited nodes Neighbor-link Each leaf stores ropes that directly link it to the adjacent node via its 6 faces Octrees typically have these neighbor structures too 55/45 [Popov et.al. 07]

56/45

Question 1 Describe a smart use of acceleration structures for our s e e 57/45