Spatial Data Structures and Acceleration Algorithms Real-time Renderg Performance Goals Spatial Structures Boundg Volume Hierarchies (BVH) Bary Space Partiong(BSP) Trees, Octrees Scene Graphs Cullg Techniques Backface Cullg View Frustum, Portal Cullg Occlusion Cullg Level of Detail Renderg ITCS 4010/5010:Game Enge Design 1 Spatial Structures/ Acceleration Algorithms
Real-Time Renderg Performance Goals High frame rate (60-85 fps) High resolution (1600 by 1200) More realistic objects : no upper limit, Boeg 777 model - 500M polygons! Spatial data structures, cullg techniques and LOD renderg work towards these goals. ITCS 4010/5010:Game Enge Design 2 Spatial Structures/ Acceleration Algorithms
Spatial Data Structures Data structures that organize geometry 2D or 3D or higher The goal is faster processg Needed for most speed-up techniques Primary Applications: Games, movie production renderg tools permittg Faster real-time renderg, tersection testg, collision detection, ray tracg, global illumation ITCS 4010/5010:Game Enge Design 3 Spatial Structures/ Acceleration Algorithms
Spatial Data Structures Organize geometry to some type of a hierarchy In general, parents enclose the children s (geometry) extents. Performance Advantage: Generally from O(n) to O(lg n) Construction is expensive, done as preprocess. ITCS 4010/5010:Game Enge Design 4 Spatial Structures/ Acceleration Algorithms
Spatial Data Structures: Why? Example: Want to pick the object user clicks on (shoot a monster, move towards an object) A hierarchcy can be used to improve performance of spatial queries: Test the root first Descend recursively as needed Termate traversal when possible ITCS 4010/5010:Game Enge Design 5 Spatial Structures/ Acceleration Algorithms
Boundg Volume Hierarchies (BVH) Sphere, Boxes (Axis- Most common boundg volumes (BVs): aligned (AABB) and Oriented OBB) The BV does not contibute to the rendered image rather, encloses an object Data Structure is a k-ary tree Leaf nodes have geometry Internal nodes have at most k children Internal nodes BV encloses all geometry its subtree ITCS 4010/5010:Game Enge Design 6 Spatial Structures/ Acceleration Algorithms
Tree Structures Height of tree, h: longest path from root to leaf Balanced Tree: All leaves at height h or h + 1 Height of balanced tree with n nodes: lg k n k = 2 (bary tree) is most common, also k = 4, 8, quadtrees and octrees. ITCS 4010/5010:Game Enge Design 7 Spatial Structures/ Acceleration Algorithms
Buildg a BVH Example: Axis-aligned BB, top-down approach Split along longest axis ITCS 4010/5010:Game Enge Design 8 Spatial Structures/ Acceleration Algorithms
Buildg a BVH:Termation Criteria Boundg Volume is empty When only one primitive (e.g. triangle) is side BV Less than n (user defed) primitives is side BV When recursion level l has been reached ITCS 4010/5010:Game Enge Design 9 Spatial Structures/ Acceleration Algorithms
Bary Space Partitiong Trees Pioneered by Sutherland, advanced by Naylor (1978) Idea: Recursive subdivision of space: Divide space with a planes Sort geometry to the space it belongs Resultg orderg is view dependent The earliest games to use BSP trees : Doom (early 90s) Applications: visible surface determation, ray tracg, collision detection Two types: Axis-aligned, Polygon alighned ITCS 4010/5010:Game Enge Design 10 Spatial Structures/ Acceleration Algorithms
Axis-Aligned BSP Tree Partitiong planes are aligned with the prcipal axes, X, Y, Z ITCS 4010/5010:Game Enge Design 11 Spatial Structures/ Acceleration Algorithms
Axis-Alighned BSP Tree Each ternal node holds a partitiong plane Leaf nodes hold geometry Different from Boundg Volume Hierarchy: Encloses entire space and provides sortg (approximate) The BV hierarchy can be constructed any way (no sort), use any BV ITCS 4010/5010:Game Enge Design 12 Spatial Structures/ Acceleration Algorithms
Usg an Axis-Alighned BSP Tree Test the planes agast view pot, startg from the root. Contue on the far side to sort front to back Rough sortg order. ITCS 4010/5010:Game Enge Design 13 Spatial Structures/ Acceleration Algorithms
Polygon (Plane)-Aligned BSP Tree Partitioners are aligned with polygon faces Provides an exact sortg order Orderg can be generated near real-time for any viewg position; no z-buffer required ITCS 4010/5010:Game Enge Design 14 Spatial Structures/ Acceleration Algorithms
Polygon (Plane)-Aligned BSP Tree Contuous Space Representation. Represents geometry with hyperplanes. Convex decomposition of space by recursive subdivision. Internal nodes conta discontuities(planes), leaf nodes represent convex regions. a a c d b c b Viewer d ITCS 4010/5010:Game Enge Design 15 Spatial Structures/ Acceleration Algorithms
Polygon Aligned BSP Tree: Tree Construction a c d b ITCS 4010/5010:Game Enge Design 16 Spatial Structures/ Acceleration Algorithms
a c d b a ITCS 4010/5010:Game Enge Design 17 Spatial Structures/ Acceleration Algorithms
a c d b a b ITCS 4010/5010:Game Enge Design 18 Spatial Structures/ Acceleration Algorithms
a c d b a c b ITCS 4010/5010:Game Enge Design 19 Spatial Structures/ Acceleration Algorithms
a c d b a c b d ITCS 4010/5010:Game Enge Design 20 Spatial Structures/ Acceleration Algorithms
Determg Visible Surface usg the BSP Tree a a c d b c b Viewer d Pat faces back to front, as faces front cannot obscure those that are behd. Classification is performed recursively, resultg generatg a priority order of faces, for a given viewer position. The BSP tree is dependent of viewer location, so long as the objects ITCS 4010/5010:Game Enge Design 21 Spatial Structures/ Acceleration Algorithms
Octrees Similar to axis-aligned BSP trees, but subdivision is done simultaneously along all 3 dimensions 2D variant is the quadtree, shown above: In 3D each square (or rectangle) becomes a box, and 8 children ITCS 4010/5010:Game Enge Design 22 Spatial Structures/ Acceleration Algorithms
Octrees Expensive to rebuild (as are BSPs) Loose octrees: a relaxation to avoid problems Octrees can be used to Speed up ray tracg Faster pickg Cullg techniques Are not used that often real-time contexts ITCS 4010/5010:Game Enge Design 23 Spatial Structures/ Acceleration Algorithms
Scene Graphs Boundg Volume Hierarchies have 2 advantages, (1) Simple to understand, (2) Simple to implement BVHs store only geometry Scene Graph is an extended BVH with lights, textures, transforms, and more. ITCS 4010/5010:Game Enge Design 24 Spatial Structures/ Acceleration Algorithms
Scene Graphs Scene Graphs add structure to environments Instancg (hierarchical modelg) makes this structure graph (rather than a tree) Origally troduced SGI Inventor, followed by VRML, Java3D, etc. Scene Graph Traversal: top to bottom, left to right ITCS 4010/5010:Game Enge Design 25 Spatial Structures/ Acceleration Algorithms
ITCS 4010/5010:Game Enge Design 26 Spatial Structures/ Acceleration Algorithms