GPU Broad Phase Collision Detection GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from GPU Gems III.

Slides:



Advertisements
Similar presentations
List Ranking and Parallel Prefix
Advertisements

Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
An Array-Based Algorithm for Simultaneous Multidimensional Aggregates By Yihong Zhao, Prasad M. Desphande and Jeffrey F. Naughton Presented by Kia Hall.
1 Spatial Join. 2 Papers to Present “Efficient Processing of Spatial Joins using R-trees”, T. Brinkhoff, H-P Kriegel and B. Seeger, Proc. SIGMOD, 1993.
Spatial Join Queries. Spatial Queries Given a collection of geometric objects (points, lines, polygons,...) organize them on disk, to answer point queries.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
Two-Level Grids for Ray Tracing on GPUs
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
CS447/ Realistic Rendering -- Solids Modeling -- Introduction to 2D and 3D Computer Graphics.
Experiences with Streaming Construction of SAH KD Trees Stefan Popov, Johannes Günther, Hans-Peter Seidel, Philipp Slusallek.
K-structure, Separating Chain, Gap Tree, and Layered DAG Presented by Dave Tahmoush.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last Time: Convex Hulls Today: Plane Sweep Algorithms, Segment Intersection, + (Element Uniqueness,
Chapter 11: File System Implementation
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Data Parallel Algorithms Presented By: M.Mohsin Butt
Collision Detection on the GPU Mike Donovan CIS 665 Summer 2009.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Parallel Prefix Sum (Scan) GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from GPU Gems III.
Adapted from: CULLIDE: Interactive Collision Detection Between Complex Models in Large Environments using Graphics Hardware Naga K. Govindaraju, Stephane.
Space Partitioning for Broad Sweep Collision Detection Part 1 - Grids Game Design Experience Professor Jim Whitehead February 11, 2009 Creative Commons.
Spatial Information Systems (SIS) COMP Spatial access methods: Indexing.
Haptic Cloth Rendering 6th Dutch-Belgian Haptics Meeting TUDelft, 21 st June 2006 Lode Vanacken Expertise centre for Digital Media (EDM) Hasselt University.
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Collision Detection David Johnson Cs6360 – Virtual Reality.
Computer graphics & visualization Collision Detection – Narrow Phase.
Maps A map is an object that maps keys to values Each key can map to at most one value, and a map cannot contain duplicate keys KeyValue Map Examples Dictionaries:
INTERACTION TECHNIQUES Collision Detection and Other Interactions Collision Detection and Other Interactions.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
Discrete Element Method Midterm Project: Option 1 1.
1 Speeding Up Ray Tracing Images from Virtual Light Field Project ©Slides Anthony Steed 1999 & Mel Slater 2004.
Introduction to CUDA 1 of 2 Patrick Cozzi University of Pennsylvania CIS Fall 2012.
Efficient Maintenance and Self- Collision Testing for Kinematic Chains Itay Lotan Fabian Schwarzer Dan Halperin Jean-Claude Latombe.
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Trevor Brown – University of Toronto B-slack trees: Space efficient B-trees.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
Chapter 7: Sorting Algorithms Insertion Sort. Sorting Algorithms  Insertion Sort  Shell Sort  Heap Sort  Merge Sort  Quick Sort 2.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Parallel Algorithms Patrick Cozzi University of Pennsylvania CIS Spring 2012.
Parallel Algorithms Patrick Cozzi University of Pennsylvania CIS Fall 2013.
Real-time Graphics for VR Chapter 23. What is it about? In this part of the course we will look at how to render images given the constrains of VR: –we.
1 5. Abstract Data Structures & Algorithms 5.2 Static Data Structures.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Fast BVH Construction on GPUs (Eurographics 2009) Park, Soonchan KAIST (Korea Advanced Institute of Science and Technology)
Collision Detection Design & Final Project Topic Brandon Smith November 5, 2008 ME 964.
Hashing Hashing is another method for sorting and searching data.
Chapter 12 Hash Table. ● So far, the best worst-case time for searching is O(log n). ● Hash tables  average search time of O(1).  worst case search.
Hierarchical Penumbra Casting Samuli Laine Timo Aila Helsinki University of Technology Hybrid Graphics, Ltd.
© David Kirk/NVIDIA, Wen-mei W. Hwu, and John Stratton, ECE 498AL, University of Illinois, Urbana-Champaign 1 CUDA Lecture 7: Reductions and.
Chapter 15 A External Methods. © 2004 Pearson Addison-Wesley. All rights reserved 15 A-2 A Look At External Storage External storage –Exists beyond the.
Parallel Algorithms Continued Patrick Cozzi University of Pennsylvania CIS Spring 2012.
An Efficient CUDA Implementation of the Tree-Based Barnes Hut n-body Algorithm By Martin Burtscher and Keshav Pingali Jason Wengert.
CHAPTER 9 HASH TABLES, MAPS, AND SKIP LISTS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++,
GPGPU: Parallel Reduction and Scan Joseph Kider University of Pennsylvania CIS Fall 2011 Credit: Patrick Cozzi, Mark Harris Suresh Venkatensuramenan.
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
CSC 413/513: Intro to Algorithms Hash Tables. ● Hash table: ■ Given a table T and a record x, with key (= symbol) and satellite data, we need to support:
CSC 143T 1 CSC 143 Highlights of Tables and Hashing [Chapter 11 p (Tables)] [Chapter 12 p (Hashing)]
1 What is it? A side order for your eggs? A form of narcotic intake? A combination of the two?
Midterm Project Toby Heyn ME964 11/18/2008.
Introduction to Polygons
Distance Computation “Efficient Distance Computation Between Non-Convex Objects” Sean Quinlan Stanford, 1994 Presentation by Julie Letchner.
Collision Detection Spring 2004.
Dictionaries Dictionaries 07/27/16 16:46 07/27/16 16:46 Hash Tables 
Chapter 4.2 Collision Detection and Resolution
GPGPU: Parallel Reduction and Scan
Collision Detection.
David Johnson Cs6360 – Virtual Reality
Presentation transcript:

GPU Broad Phase Collision Detection GPU Graphics Gary J. Katz University of Pennsylvania CIS 665 Adapted from articles taken from GPU Gems III

Basic Collision Detection  Broad Phase Reviews the whole simulation Looks at coarse view of objects (usually bounding boxes) Determines if objects may intersect Fast  Narrow Phase Reviews objects that may intersect (determined by broad phase) Looks at detailed view of objects Determines if objects actually intersect Slow

Current Broad Phase Methods  Brute Force: n objects need n(n-1)/2 collision tests Complexity = O(n 2 )  Sort and Sweep: Average Complexity = O(n log n) Worst-Case Complexity O(n 2 )  Spatial Subdivision: Average Complexity = O(n log n) Worst-Case Complexity O(n 2 )

Sort and Sweep  Bounding volume is projected onto x, y, z axis  Determine collision interval for each object [b i, e i ]  Two objects who’s collision intervals do not overlap can not collide O1O1 O3O3 O2O2 Sorting Axis B1B3E1B2E3E2

Sort and Sweep Sorted List: B1 B3 E1 B2 E3 E2 Active Objects: Add an object i to the active objects list when Bi is reached and remove when Ei is reached Check for intersection between object i and all other object in the active objects list at the time Bi is reached Objects to compare against: 1: 2: 3: O1O1 O3O3 O2O2 B1B3E1B2E3 E2

Spatial Subdivision Images from pg 699, 700 GPU Gems III O1O1 O2O2 O3O3 O4O Example

Parallel Spatial Subdivision  Complications: 1. Single object can be involved in multiple collision tests 2. Need to prevent multiple threads updating the state of an object at the same time Ways to solve this?

Guaranteed Individual Collision Tests  Prove: No two cells updated in parallel may contain the same object that is being updated Constraints 1. Each cell is as large as the bounding volume of the largest object 2. Each cell processed in parallel must be separated by each other cell by at least one intervening cell In 2d this takes _____ number of passes In 3d this takes _____ number of passes 4 8

Example of Parallel Spatial Subdivision O1O1 O2O2 O3O3 O4O O1O1 O2O2 O3O3 O4O

Avoiding Extra Collision Testing 1. Associate each object a set of control bits to test where its centroid resides 2. Scale the bounding sphere of each object by sqrt(2) to ensure the grid cell is at least 1.5 times larger than the largest object Case 1 Case 2

Implementing in CUDA  Store list of object IDs, cell IDs in device memory  Build the list of cell IDs from object’s bounding boxes  Sorting list from previous step  Build an index table to traverse the sorted list  Schedule pairs of objects for narrow phase collision detection

Initialization Cell ID Array OBJ 1 Cell ID 1 OBJ 1 Cell ID 2 OBJ 1 Cell ID 3 OBJ 1 Cell ID 4 OBJ 2 Cell ID 1 OBJ 2 Cell ID 2 OBJ 2 Cell ID 3 OBJ 2 Cell ID 4. Object ID Array OBJ 1 ID, Control Bits OBJ 2 ID, Control Bits.

Construct the Cell ID Array Host Cells (H – Cells) Contain the centroid of the object Phantom Cells (P-Cells) Overlap with bounding volume but do not contain the centroid H-Cell Hash = (pos.x / CELLSIZE) << XSHIFT) | (pos.y / CELLSIZE) << YSHIFT) | (pos.z / CELLSIZE) << ZSHIFT) P PP P HP P PP P-Cells – Test the 3 d -1 cells surrounding the H cell There can be as many as 2 d -1 P cells

Sorting the Cell ID Array  What we want: Sorted by Cell ID H cells of an ID occur before P cells of an ID  Starting with a partial sort H cells are before P cells, but array is not sorted by Cell ID  Solution: Radix Sort Radix Sort ensures identical cell IDs remain in the same order as before sorting.

Sorting Cell Array n n n n n Cell ID Array n n n n 111 n n Sorted Cell ID Array Invalid Cell Home Cell Phantom Cell Object ID Cell ID Legend

Spatial Subdivision Images from pg 699, 700 GPU Gems III O1O1 O2O2 O3O3 O4O Example 1.Assign to each cell the list of bounding volumes whose objects intersect with the cell 2.Perform Collision test only if both objects are in the cell and one has a centroid in the cell

Create the Collision Cell List  Scan sorted cell ID array for changes of cell ID Mark by end of the list of occupants of one cell and beginning of another 1. Count number of objects each collision cell contains and convert them into offsets using scan 2. Create entries for each collision cell in new array 1. Start 2. Number of H occupants 3. Number of P occupants

Create Collision Cell List n n n n 111 n n Sorted Cell ID Array Cell Index & Size Array ID H P ID = Cell index in sorted Cell ID Array H = Number of Home Cell IDs P = Number of Phantom Cell IDs

Traverse Collision Cell List Cell Index & Size Array X p q T 0T 1T 2... T 3T 4 T n Perform Collision Test Per Cell Number of Collisions / Thread Array …

Credits  Based upon GPU Gems article Chapter 32  Chapter Author: Scott Le Grand  This presentation was put together without the approval of the author and should only be used for educational purposes

Backup

Spatial Subdivision  Partition space into uniform grid  Grid cell is at least as large as largest object  Each cell contains list of each object whose centroid is in the cell  Collision tests are performed between objects who are in same cell or adjacent cells Images from pg 699, 700 GPU Gems III O1O1 O2O2 O3O3 O4O4 Implementation: 1.Create list of object IDs along with hashing of cell IDs in which they reside 2.Sort list by cell ID 3.Traverse swaths of identical cell IDs 4.Perform collision tests on all objects that share same cell ID Example