The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Geometric Computations on GPU: Proximity Queries Avneesh Sud &Dinesh Manocha
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL This Lecture Proximity Queries: Overview Visibility computations using GPUs Reliable GPU-based Computations Collision Detection Proximity Queries using Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Proximity Queries Collision Detection
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Proximity Queries Penetration Depth Contact forces
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Proximity Queries Separation Distance Repulsive force, time of contact
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Motivation: Driving Applications Computer animation Surgical simulation Robotics Haptics Bioinformatics
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Motivation Interactive proximity computation among general deformable models Inter-object queries among multiple models
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Motivation Interactive proximity computation among general deformable models Intra-object (self- proximity) queries in cloth simulation
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL This Lecture Proximity Queries: Overview Visibility computations using GPUs Reliable GPU-based Computations Collision Detection Proximity Queries using Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Graphics Processing Units (GPUs) Well-designed for visibility computations Rasterization – image-space visibility Massively parallel Render millions of polygons per second Well suited for image-based algorithms High growth rate
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Recent growth rate of Graphics Processing Units CardMillion triangles/sec Radeon 9700 Pro325 GeForce FX Radeon 9800 XT412 GeForce FX GeForce GeForce GeForce 8800?
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL GPUs: Geometric Computations Used for geometric applications Minkowski sums [ Kim et al. 02 ] CSG rendering [ Goldfeather et al. 89, Rossignac et al. 90 ] Voronoi computation [ Hoff et al. 01, 02, Sud et al. 04 ] Isosurface computation [ Pascucci 04 ] Map simplification [ Mustafa et al. 01 ] Collision Detection [ Govindaraju03, Govindaraju04 ] Proximity Computations [ Sud06 ]
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Graphics Processing Units (GPUs) Well-designed for visibility computations Rasterization – image-space visibility Massively parallel Render millions of polygons per second Well suited for image-based algorithms High growth rate
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Setup Engine Stream of transformed vertices Setup of setup commands and state Vertex Processing Engines Pixel Processing Engines Stream of visible pixels Alpha test Stencil test Depth test Stream of vertices IEEE Floating Point (32-bit) Limited Resolution! Draw stream of triangles CPU GPU Visibility of triangles GPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Draw stream of triangles CPU GPU Visibility of triangles Vertex Processing Engines Setup Engine Stream of vertices Stream of visible pixels Alpha test Pixel Processing Engines Stencil test Depth test Stream of transformed vertices Setup of setup commands and state count of visible pixels GPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL GPUs for Geometric Computations: Issues Precision Frame-buffer readbacks
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Pixel Processing Engines Stream of visible pixels Limited Resolution! Resolution along X, Y,Z X – 13 bits fixed precision Y – 13 bits fixed precision Z – 24 bits fixed precision* On CPU – 32-bit or 64-bit floating-point precision Frame-Buffer Precision
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Frame-Buffer Readback Involve stalls Affect throughput Slow!
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Frame-Buffer Readback Performance Data Courtesy: June 2004www.techreport.com Readback of 1Kx1K frame-buffer takes 18 ms over PCI-Express
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL GPU Growth Rate CPU Growth Rate AGP Bandwidth Growth Rate Courtesy: Anselmo Lastra
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Solutions Frame-Buffer Readbacks Minimize readback data (eg Visibility information) Precision Refine answer on CPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL NV Occlusion Query Extension name: NV_occlusion_query Returns pixel count – the no. of pixels that pass Provides an interface to issue multiple queries at once before asking for the result of any one Applications can now overlap the time it takes for the queries to return with other work increasing the parallelism between CPU and GPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL NV Occlusion Query – How to Use (1) (Optional) Disable Depth/Color Buffers (Optional) Disable any other irrelevant non-geometric state Generate occlusion queries Begin i th occlusion query Render i th (bounding) geometry End occlusion query Do other CPU computation while queries are being made (Optional) Enable Depth/Color Buffers (Optional) Re-enable other state Get pixel count of i th query If (count > MAX_COUNT) render i th geometry
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL NV Occlusion Query – How to Use (2) Generate occlusion queries Gluint queries[N]; GLuint pixelCount; glGenOcclusionQueriesNV(N, queries); Loop over queries for (i = 0; i < N; i++) { glBeginOcclusionQueryNV(queries[i]); // render i th geometry glEndOcclusionQueryNV(); } Get pixel counts for (i = 0; i < N; i++) { glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, &pixelCount); if (pixelCount > MAX_COUNT) // do work for i th geometry }
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL This Lecture Proximity Queries: Overview Visibility computations using GPUs Reliable GPU-based Computations Collision Detection Proximity Queries using Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL GPU: Culling Coprocessor AABB Culling Exact Tests 2.5D Overlap Tests Voronoi-Based Culling Collision Distance Potential Neighbor Set N-Objects GPU-Based Culling Potential Colliding Set
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Inaccuracies in GPU-Based Algorithms Image sampling Depth buffer precision [Govindaraju, Lin, Manocha, Special Issue on Best Papers of ACM VRST’04 in IEEE TVCG]
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Image Sampling Occurs when a primitive does not cover any pixels
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Image Sampling Primitives are rasterized but no intersecting points are sampled by hardware Viewport C = pixel center Intersecting point
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Depth Buffer Precision Intersecting points are sampled but precision is not sufficient Viewport C = pixel center Intersecting point T1T1
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Overcome Image Sampling Sufficiently fatten the triangles Use Minkowski sums Minkowski Sum A B = A B = {a + b: a A, b B}
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PLPL Minkowski Sum: Example P L
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL This Lecture Proximity Queries: Overview Visibility computations using GPUs Reliable GPU-based Computations Collision Detection Proximity Queries using Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Goal Interactive collision detection between complex objects Large number of objects High primitive count Non-convex objects Open and closed objects
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Non-rigid Motion Deformable objects Changing topology Self-collisions
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL CULLIDE: Overview Potentially Colliding Set (PCS) computation Exact collision tests on the PCS [Govindaraju, Redon, Lin, Manocha, ACM Graphics Hardware 2003]
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Algorithm Object-Level Pruning Subobject- Level Pruning Exact Tests GPU-based PCS computation Using CPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Potentially Colliding Set (PCS) PCS
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Potentially Colliding Set (PCS) PCS
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Algorithm Object-Level Pruning Subobject- Level Pruning Exact Tests
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Computations Lemma 1: An object O does not collide with a set of objects S if O is fully visible with respect to S
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility of Objects An object is fully visible if it is completely in front of the remaining objects O1O1 O View O2O2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility for Collisions: Geometric Interpretation Sufficient but not a necessary condition for existence of separating surface with unit depth complexity O1O1 O View O2O2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Pruning Prune objects that do not collide
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Pruning O 1 O 2 … O i-1 O i O i+1 … O n-1 O n
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation Each object tested against all objects but itself Naive algorithm is O(n 2 ) Linear time algorithm Uses two pass rendering approach Conservative solution
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL O 1 O 2 … O i-1 O i PCS Computation: First Pass Fully Visible? Render Yes. Does not collide with O 1,O 2,…,O i-1
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Render Fully Visible?
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: Second Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: Second Pass Render Fully Visible? O i O i+1 … O n-1 O n Yes. Does not collide with O i+1,…,O n-1,O n
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: Second Pass Render Fully Visible? O 1 O 2 … O i-1 O i O i+1 … O n-1 O n
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Fully Visible
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation O 1 O 2 O 3 … O i-1 O i O i+1 … O n-2 O n-1 O n O 1 O 3 … O i-1 O i+1 … O n-1
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Algorithm Object-Level Pruning Subobject- Level Pruning Exact Tests
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL CULLIDE Algorithm Object-Level Pruning Subobject- Level Pruning Exact Tests Exact overlap tests using CPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Full Visibility Queries on GPUs We require a query Tests if a primitive is fully visible or not Current hardware supports occlusion queries Test if only part of a primitive is visible or not Our solution Change the sign of the depth function
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Full Visibility Queries on GPUs Depth function GEQUALLESS All fragments Pass FailPass Fail PassFailPassFail Query not supported Occlusion query Examples - HP_Occlusion_test, NV_occlusion_query
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Bandwidth Analysis Read back only integer identifiers Computation at high screen resolutions
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Demo: CULLIDE
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Quick-CULLIDE Improved two-pass algorithm Utilize visibility relationships among objects across different views Handle intra-object collisions [Govindaraju, Lin, Manocha, IEEE Virtual Reality 2005]
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Quick-CULLIDE: Visibility Sets Decompose PCS into four disjoint sets FFV (First pass Fully Visible) SFV (Second pass Fully Visible) NFV (Not Fully Visible in either passes) BFV (Both passes Fully Visible) Visibility sets have five interesting properties!
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Sets: Properties FFV and SFV are collision-free sets
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i … O j … O n-1 O n Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i … O j … O n-1 O n Render Fully Visible
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Sets: Properties It is sufficient to test visibility of objects in FFV in second pass only
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL O 1 O 2 … O i-1 O i PCS Computation: First Pass Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Not Colliding Collision tested in Second pass
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Sets: Properties It is sufficient to render objects in FFV in first pass only!
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation: First Pass O 1 O 2 … O i-1 O i O i+1 … O n-1 O n
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL O 1 O 2 … O i-1 O i PCS Computation: First Pass Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL PCS Computation O 1 O 2 … O i-1 O i O i+1 … O n-1 O n Not Colliding Render
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Sets: Properties It is sufficient to test the visibility of objects in SFV in first pass only!
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Visibility Sets: Properties It is sufficient to render objects in SFV in second pass only!
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Quick-CULLIDE: Advantages Better culling efficiency Lower depth complexity than CULLIDE Always better than CULLIDE Faster computational performance Lower number of visibility queries and rendering operations Can handle self-collisions
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Self-Collisions: Definition Pairs of overlapping triangles in an object that are not neighboring
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Self-Collisions: Definition Pairs of overlapping triangles in an object that are not neighboring
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Self-Collisions Occur in most deformable simulations Image Courtesy: Baraff and Witkin, SIGGRAPH 2003 Artifacts
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Solution Classification of contacts between triangles in an object Touching contacts Penetrating contacts
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Contacts: Classification (a) (b)(c) Touching Contacts Penetrating Contact
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Solution Ignore touching contacts Consider only penetrating contacts Redefine fully visible We pass a fragment when a touching contact occurs Pass all fragments with depth ≤ corresponding depths in frame-buffer
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Demo: Quick-CULLIDE
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x Given a primitive P P
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x P x is the portion of P projecting inside pixel X Pixel X PxPx
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL S Reliability z x S is a sphere centered at origin bounding pixel X Pixel X PxPx
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x If we compute Minkowski sum P x S = P x S, Pixel X PxSPxS PxPx
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x PxPx then the rasterization of the Minkowski sum P x S generates two fragments Pixel X PxSPxS Sample Depths
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x PxPx and the fragments bound depth values in P x Pixel X PxSPxS Sample Depths
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x P1P1 Given two primitives P 1 and P 2 Pixel X P2P2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability d x P1P1 If P 1 and P 2 intersect in 3-D, Pixel X P2P2 P 1 and P 2 intersect in 3-D
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability d x P1P1 and we compute their Minkowski sums with a pixel-sized sphere centered at origin Pixel X P2P2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Reliability z x P1P1 rasterization of the Minkowski sums overlap in image-space Pixel X P2P2
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL z x Pixel X P1P1 P2P2 P1SP1S P2SP2S
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Bounding Offsets of a Triangle Exact Offsets Three edge-aligned cylinders, three spheres, two triangles Can be rendered using fragment programs Expensive! Oriented Bounding Box (OBB)
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Union of OBBs
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Demo: R-CULLIDE
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL This Lecture Proximity Queries: Overview Visibility computations using GPUs Reliable GPU-based Computations Collision Detection Proximity Queries using Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL N-Body Distance Query Given a set of sites, find all closest pairs Nearest-neighbor for each site 1 5 2 1 3 1 4 1 5 1 6
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Goal Compute N-Body distance efficiently Culling For each site, compute Potential Neighbor Set (PNS) of sites 5
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Goal Compute N-Body distance efficiently For each site, compute Potential Neighbor Set (PNS) of sites Contains nearest neighbor PNS(1) = {5,3}
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Outline Related work N-Body distance queries Culling using second order discrete Voronoi diagrams Results
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Voronoi Culling for N-Body Query AABB Culling Voronoi-based Culling N-Objects Stage IStage II Exact Distance Tests Potential Neighbor Set Stage III
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Second-order Voronoi Diagram Governors = 2 closest sites
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Benefit of Second-order Voronoi Diagram Voronoi diagram: Spatial partition based on proximity Second-order Voronoi diagram: Proximity to two sites Nearest neighbor information
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Culling using Second-order Voronoi Diagram Polygonal Objects
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Culling using Second-order Voronoi Diagram PNS(1) = Sites whose second order Voronoi regions intersect Second order Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Culling using Second-order Voronoi Diagram PNS(1) = Sites whose second order Voronoi regions intersect 1 PNS(1) = {2,3} Second order Voronoi diagram provides PNS for all sites 123 PNS(1)
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Culling using Second-order Voronoi Diagram PNS(1) = Sites whose second order Voronoi regions intersect 1 Second order Voronoi diagram provides PNS for all sites PNS(1) = {2,3} PNS(2) = {1,4,9} 12 PNS(2) 9 4
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Culling using Second-order Voronoi Diagram PNS(1) = Sites whose second order Voronoi regions intersect 1 Second order Voronoi diagram provides PNS for all sites PNS(1) = {2,3} PNS(2) = {1,4,9} … PNS(9) = {2,8} 2 PNS(9) 9 8
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Proximity Culling using Discrete Voronoi Diagram Computing exact Voronoi diagram difficult
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Proximity Culling using Discrete Voronoi Diagram Computing exact Voronoi diagram difficult Compute Discrete Voronoi Diagram (DVD) Interactive computation using GPU Second order details in thesis Discrete Voronoi Diagram
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Distance Bounds for Conservative Computation Under-sampling errors Provides approximate separation distance (SD) SD’ SD
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Distance Bounds for Conservative Computation Theorem (Distance bounds): SD’
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Distance Bounds for Conservative Computation Theorem (Distance bounds): SD’ - < SD < SD’ + SD’ = Approximate Separation Distance SD = Exact Separation Distance = Grid resolution SD
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Distance Bounds for Conservative Computation Compute PNS using distance bounds Exact tests on CPU
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Collision Detection Well studied Computer graphics, computational geometry etc. Widely used in games, simulations, virtual reality applications Often a computational bottleneck
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Interactive Collision Detection
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Interactive Collision Detection Visibility to reduce number of pair-wise overlap tests