250 likes | 333 Views
Advanced Scene Management. Advanced Scene Graphs. This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake” Octree PVS (Potentially visible set) Culling Skills. Bounding Volume Hierarchies (BVHs).
E N D
Advanced Scene Management
Advanced Scene Graphs • This is a game-type-oriented issue • Bounding Volume Hierarchies (BVHs) • Binary space partition trees (BSP Trees) • “Quake” • Octree • PVS (Potentially visible set) • Culling Skills
Bounding Volume Hierarchies (BVHs) • Hierarchical structure of bounding spheres R B
BSP Tree • Two varients • Axis-aligned • Polygon-aligned • The trees are created by using a plane to divide the space into two, and then sorting the geometry into two spaces.
Axis-aligned BSP Tree 0 plane0 2 plane3 1 plane2 plane1 3
Polygon-aligned BSP Tree A F C G B A B C D E D F G E
Why BSP Tree ? • Quickly to identify where you are • BSP = Sorting • Need a pre-processor to generate the PVS • Visibility culling + occlusion culling • PVS : Potentially Visible Set • Optimized for in-door game environment • [Fuch80] • Fuchs, H., • On Visible Surface Generation by a Priori Tree Structures, • Computer Graphics, 14, 124-33, (Proc. SIGGRAPH’80)
Octree & Quadtree • Octree • Similar to axis-aligned BSP tree • A box is split simultaneously along all three axes • The split point must be the center of the box • This creates eight new smaller boxes • Quadtree is the 2D version of octree
Octree – Some Discussion • Data structure coherence • Apply visibility culling from parents • Split or not split ? • Outdoor game scene ?
Culling (1/2) • Culling means “remove from a flock” • Visibility culling • Remove the object not in view frustum • A “must” for game engine • Backface culling • Remove the polygons facing away from camera • Hardware standard • Occlusion culling • Remove the objects hidden by the others
Culling (2/2) View frustum Occlusion culling eye Visibility culling Backface culling
BSP Implementation • A Pre-processor • Space partition the scene data from artist • Generate the BSP data structure • Generate the PVS • BSP Walk Through • Identify the room where you are • Show/hide the rooms according to the PVS
BSP Preprocessor (1/2) • Input • A scene from artist • Cutting planes (optional) • Can be procedurally generated by algorithm • Cutting policy • Split or not split • Ray casting resolution for PVS • Output • A BSP file • BSP Tree • PVS • Geometry Data
BSP Preprocessor (2/2) • Process • Generate the BSP tree according to the cutting policy • Split or sort the geometry into BSP room (leaves) • For each “room”, perform ray casting for all rooms to generate the possible visible room set • 3D • Time consuming • Pre-processing process (can be done off-line)
BSP Challenges • Effectiveness of PVS • Data set • Dynamic Objects • Room size
Spatial Partition: Grid Cells Divide the space into grid cells regularly. Hash objects to grid cells based on their positions. Use link list to maintain the objects which lay in the same grid cell.
Searching for neighboring objects • Use the linked list to search for neighboring objects • Determine the grid coordinates to obtain the grid cell • Search the objects at the grid cell
Linked List: Examples struct ObjList { Obj *myObj; ObjList *next; }; struct ObjList { int objID; int nextListID; };
Grid Cells: Hashing Space dimension [x0, x1] × [y0, y1] × [z0, z1] Grid dimension Nx × Ny × Nz Given position (x, y, z), compute ( Ix,Iy,Iz ) Ix = Nx * (x - x0) / (x1 -x0) Iy = Ny * (y - y0) / (y1 -y0) Iz = Nz * (z - z0) / (z1 -z0)
Grid Cells: Hashing Space dimension [x0, x1] × [y0, y1] × [z0, z1] Grid dimension Nx × Ny × Nz Given position (x, y, z), compute ( Ix,Iy,Iz ) Ix = Nx * (x - x0) / (x1 -x0) Iy = Ny * (y - y0) / (y1 -y0) Iz = Nz * (z - z0) / (z1 -z0) Do you see the problem?
Grid Cells: Hashing Space dimension [x0, x1] × [y0, y1] × [z0, z1] Grid dimension Nx × Ny × Nz Given position (x, y, z), compute ( Ix,Iy,Iz ) Ix = Nx * (x - x0) / (x1 -x0) Iy = Ny * (y - y0) / (y1 -y0) Iz = Nz * (z - z0) / (z1 -z0) Do you see the problem? E.g., Ix in [0, Nx]. Ix = Nx only when x = x1. Clamp Ix to [ 0, Nx – 1 ]. Do it for Iy and Iz too.
Grid Cells: Hashing Use if then to clamp? Ix = Nx * (x - x0) / (x1 -x0) Iy = Ny * (y - y0) / (y1 -y0) Iz = Nz * (z - z0) / (z1 -z0) Do you see the problem? E.g., Ix in [0, Nx]. Ix = Nx only when x = x1. Clamp Ix to [ 0, Nx – 1 ]. Do it for Iy and Iz too.
Grid Cells: Hashing To do so, we do this: Ix = Nx * (x - x0) / (x1 -x0 + ε) Iy = Ny * (y - y0) / (y1 -y0 + ε) Iz = Nz * (z - z0) / (z1 -z0 + ε) where ε > 0 and its value is much smaller than min ( x1 -x0 , y1 -y0 , z1 -z0 ) - Other methods?
Spatial Partition: Grid Cells But some objects overlap with more than one grid cell. Thus, we need larger regions for searching the neighboring objects, e.g. 3x3 or 5x5, etc.