Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”

Similar presentations


Presentation on theme: "1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”"— Presentation transcript:

1 1 Advanced Scene Management

2 2 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 Advanced Scene Graphs

3 3 Hierarchical structure of bounding spheres R B Bounding Volume Hierarchies (BVHs)

4 4 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. BSP Tree

5 5 plane1 plane0 plane2 plane3 0 1 2 3 Axis-aligned BSP Tree

6 6 A B C D E F G A B C D E FG Polygon-aligned BSP Tree

7 7 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) Why BSP Tree ?

8 8 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 & Quadtree

9 9 Quadtree - Example

10 10 Data structure coherence Apply visibility culling from parents Split or not split ? Outdoor game scene ? Octree – Some Discussion

11 11 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 (1/2)

12 12 eye View frustum Visibility culling Backface culling Occlusion culling Culling (2/2)

13 A Pre-processor A Pre-processor –Space partition the scene data from artist –Generate the BSP data structure –Generate the PVS BSP Walk Through BSP Walk Through –Identify the room where you are –Show/hide the rooms according to the PVS 13 BSP Implementation

14 Input 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 Output –A BSP file »BSP Tree »PVS »Geometry Data 14 BSP Preprocessor (1/2)

15 Process 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) 15 BSP Preprocessor (2/2)

16 Effectiveness of PVS Effectiveness of PVS –Data set Dynamic Objects Dynamic Objects Room size Room size 16 BSP Challenges

17 Spatial Partition: Grid Cells Divide the space into grid cells regularly. Divide the space into grid cells regularly. Hash objects to grid cells based on their positions. Hash objects to grid cells based on their positions. Use link list to maintain the objects which lay in the same grid cell. Use link list to maintain the objects which lay in the same grid cell.

18 Searching for neighboring objects Use the linked list to search 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

19 Linked List: Examples struct ObjList { Obj*myObj; ObjList *next; }; struct ObjList { intobjID; int nextListID; };

20 Grid Cells: Hashing Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Grid dimension N x × N y × N z Grid dimension N x × N y × N z Given position (x, y, z), compute ( I x, I y, I z ) Given position (x, y, z), compute ( I x, I y, I z ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 )

21 Grid Cells: Hashing Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Grid dimension N x × N y × N z Grid dimension N x × N y × N z Given position (x, y, z), compute ( I x, I y, I z ) Given position (x, y, z), compute ( I x, I y, I z ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) Do you see the problem? Do you see the problem?

22 Grid Cells: Hashing Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Space dimension [x 0, x 1 ] × [y 0, y 1 ] × [z 0, z 1 ] Grid dimension N x × N y × N z Grid dimension N x × N y × N z Given position (x, y, z), compute ( I x, I y, I z ) Given position (x, y, z), compute ( I x, I y, I z ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) Do you see the problem? Do you see the problem? E.g., I x in [0, N x ]. I x = N x only when x = x 1. E.g., I x in [0, N x ]. I x = N x only when x = x 1. Clamp I x to [ 0, N x – 1 ]. Do it for I y and I z too. Clamp I x to [ 0, N x – 1 ]. Do it for I y and I z too.

23 Grid Cells: Hashing Use if then to clamp? Use if then to clamp? I x = N x * (x - x 0 ) / (x 1 - x 0 ) I x = N x * (x - x 0 ) / (x 1 - x 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I y = N y * (y - y 0 ) / (y 1 - y 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) I z = N z * (z - z 0 ) / (z 1 - z 0 ) Do you see the problem? Do you see the problem? E.g., I x in [0, N x ]. I x = N x only when x = x 1. E.g., I x in [0, N x ]. I x = N x only when x = x 1. Clamp I x to [ 0, N x – 1 ]. Do it for I y and I z too. Clamp I x to [ 0, N x – 1 ]. Do it for I y and I z too.

24 Grid Cells: Hashing To do so, we do this: To do so, we do this: I x = N x * (x - x 0 ) / (x 1 - x 0 + ε) I x = N x * (x - x 0 ) / (x 1 - x 0 + ε) I y = N y * (y - y 0 ) / (y 1 - y 0 + ε) I y = N y * (y - y 0 ) / (y 1 - y 0 + ε) I z = N z * (z - z 0 ) / (z 1 - z 0 + ε) I z = N z * (z - z 0 ) / (z 1 - z 0 + ε) where ε > 0 and its value is much smaller than where ε > 0 and its value is much smaller than min ( x 1 - x 0, y 1 - y 0, z 1 - z 0 ) - Other methods?

25 Spatial Partition: Grid Cells But some objects overlap with more than one grid cell. 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. Thus, we need larger regions for searching the neighboring objects, e.g. 3x3 or 5x5, etc.


Download ppt "1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”"

Similar presentations


Ads by Google