advanced scene management
DESCRIPTION
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). - PowerPoint PPT PresentationTRANSCRIPT
1
AdvancedAdvancedScene ManagementScene Management
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 GraphsAdvanced Scene Graphs
3
Hierarchical structure of bounding spheres
R
B
Bounding Volume Hierarchies (BVHs)Bounding Volume Hierarchies (BVHs)
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 TreeBSP Tree
5
plane1
plane
0
plane2
plane
3
0
1 2
3
Axis-aligned BSP TreeAxis-aligned BSP Tree
6
AB
C
D
E
F
G
A
B C
D E F G
Polygon-aligned BSP TreePolygon-aligned BSP Tree
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 ?Why BSP Tree ?
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 & QuadtreeOctree & Quadtree
9
Quadtree - ExampleQuadtree - Example
10
Data structure coherence Apply visibility culling from parents Split or not split ? Outdoor game scene ?
Octree – Some DiscussionOctree – Some Discussion
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)Culling (1/2)
12
eye
View frustum
Visibilityculling
Backfaceculling
Occlusionculling
Culling (2/2)Culling (2/2)
A Pre-processorA Pre-processor– Space partition the scene data from artistSpace partition the scene data from artist– Generate the BSP data structureGenerate the BSP data structure– Generate the PVSGenerate the PVS
BSP Walk ThroughBSP Walk Through– Identify the room where you areIdentify the room where you are– Show/hide the rooms according to the PVSShow/hide the rooms according to the PVS
13
BSP ImplementationBSP Implementation
InputInput– A scene from artistA scene from artist– Cutting planes (optional)Cutting planes (optional)
» Can be procedurally generated by algorithmCan be procedurally generated by algorithm
– Cutting policyCutting policy» Split or not splitSplit or not split
– Ray casting resolution for PVSRay casting resolution for PVS OutputOutput
– A BSP fileA BSP file» BSP TreeBSP Tree» PVSPVS» Geometry DataGeometry Data
14
BSP Preprocessor (1/2)BSP Preprocessor (1/2)
ProcessProcess– Generate the BSP tree according to the cutting policyGenerate the BSP tree according to the cutting policy– Split or sort the geometry into BSP room (leaves)Split or sort the geometry into BSP room (leaves)– For each “room”, perform ray casting for all rooms to For each “room”, perform ray casting for all rooms to
generate the possible visible room setgenerate the possible visible room set– 3D3D– Time consumingTime consuming– Pre-processing process (can be done off-line)Pre-processing process (can be done off-line)
15
BSP Preprocessor (2/2)BSP Preprocessor (2/2)
Effectiveness of PVSEffectiveness of PVS– Data setData set
Dynamic ObjectsDynamic Objects Room sizeRoom size
16
BSP ChallengesBSP Challenges
Spatial Partition: Grid CellsSpatial 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 Hash objects to grid cells based on their
positions.positions. Use link list to maintain the objects which lay in Use link list to maintain the objects which lay in
the same grid cell.the same grid cell.
Searching for neighboring Searching for neighboring objectsobjects
Use the linked list to search for neighboring objectsUse the linked list to search for neighboring objects– Determine the grid coordinates to obtain the grid cellDetermine the grid coordinates to obtain the grid cell– Search the objects at the grid cellSearch the objects at the grid cell
Linked List: ExamplesLinked List: Examples
struct ObjList {struct ObjList {
ObjObj *myObj;*myObj;
ObjList *next;ObjList *next;
};};
struct ObjList {struct ObjList {
intint objID;objID;
int nextListID;int nextListID;
};};
Grid Cells: HashingGrid Cells: Hashing
Space dimension [xSpace dimension [x00, x, x11] × [y] × [y00, y, y11] × [z] × [z00, z, z11]]
Grid dimension NGrid dimension Nxx × N × Nyy × N × Nzz
Given position (x, y, z), compute ( IGiven position (x, y, z), compute ( Ixx,, IIyy,, IIz z ))
IIx x = N= Nxx * (x - x * (x - x00) / (x) / (x1 1 -- xx00))
IIy y = N= Nyy * (y - y * (y - y00) / (y) / (y1 1 -- yy00))
IIz z = N= Nzz * (z - z * (z - z00) / (z) / (z1 1 -- zz00))
Grid Cells: HashingGrid Cells: Hashing
Space dimension [xSpace dimension [x00, x, x11] × [y] × [y00, y, y11] × [z] × [z00, z, z11]]
Grid dimension NGrid dimension Nxx × N × Nyy × N × Nzz
Given position (x, y, z), compute ( IGiven position (x, y, z), compute ( Ixx,, IIyy,, IIz z ))
IIx x = N= Nxx * (x - x * (x - x00) / (x) / (x1 1 -- xx00))
IIy y = N= Nyy * (y - y * (y - y00) / (y) / (y1 1 -- yy00))
IIz z = N= Nzz * (z - z * (z - z00) / (z) / (z1 1 -- zz00))
Do you see the problem?Do you see the problem?
Grid Cells: HashingGrid Cells: Hashing Space dimension [xSpace dimension [x00, x, x11] × [y] × [y00, y, y11] × [z] × [z00, z, z11]]
Grid dimension NGrid dimension Nxx × N × Nyy × N × Nzz
Given position (x, y, z), compute ( IGiven position (x, y, z), compute ( Ixx,, IIyy,, IIz z ))
IIx x = N= Nxx * (x - x * (x - x00) / (x) / (x1 1 -- xx00))
IIy y = N= Nyy * (y - y * (y - y00) / (y) / (y1 1 -- yy00))
IIz z = N= Nzz * (z - z * (z - z00) / (z) / (z1 1 -- zz00))
Do you see the problem?Do you see the problem? E.g., IE.g., Ix x in [0, Nin [0, Nxx]. I]. Ixx = N = Nxx only when x = x only when x = x1. 1.
Clamp IClamp Ixx to [ 0, N to [ 0, Nx x – 1 ]. Do it for I– 1 ]. Do it for Iyy and I and Izz too. too.
Grid Cells: HashingGrid Cells: Hashing Use Use if then if then to clamp?to clamp?
IIx x = N= Nxx * (x - x * (x - x00) / (x) / (x1 1 -- xx00))
IIy y = N= Nyy * (y - y * (y - y00) / (y) / (y1 1 -- yy00))
IIz z = N= Nzz * (z - z * (z - z00) / (z) / (z1 1 -- zz00))
Do you see the problem?Do you see the problem? E.g., IE.g., Ix x in [0, Nin [0, Nxx]. I]. Ixx = N = Nxx only when x = x only when x = x1. 1.
Clamp IClamp Ixx to [ 0, N to [ 0, Nx x – 1 ]. Do it for I– 1 ]. Do it for Iyy and I and Izz too. too.
Grid Cells: HashingGrid Cells: Hashing
To do so, we do this:To do so, we do this: IIx x = N= Nxx * (x - x * (x - x00) / (x) / (x1 1 -- xx0 0 + + εε))
IIy y = N= Nyy * (y - y * (y - y00) / (y) / (y1 1 -- yy0 0 + + εε))
IIz z = N= Nzz * (z - z * (z - z00) / (z) / (z1 1 -- zz00 + + εε))
where where ε ε > 0 and its value is much smaller than > 0 and its value is much smaller than
min ( xmin ( x1 1 -- xx0 0 , y, y1 1 -- yy0 0 , z, z1 1 -- zz00 ) )
- Other methods?- Other methods?
Spatial Partition: Grid CellsSpatial Partition: Grid Cells
But some objects overlap with more than But some objects overlap with more than one grid cell.one grid cell.
Thus, we need larger regions for searching Thus, we need larger regions for searching the neighboring objects, e.g. 3x3 or 5x5, the neighboring objects, e.g. 3x3 or 5x5, etc.etc.