advanced scene management

25
1 Advanced Advanced Scene Management Scene Management

Upload: torgny

Post on 23-Jan-2016

26 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Advanced Scene Management

1

AdvancedAdvancedScene ManagementScene Management

Page 2: Advanced Scene 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

Page 3: Advanced Scene Management

3

Hierarchical structure of bounding spheres

R

B

Bounding Volume Hierarchies (BVHs)Bounding Volume Hierarchies (BVHs)

Page 4: Advanced Scene Management

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

Page 5: Advanced Scene Management

5

plane1

plane

0

plane2

plane

3

0

1 2

3

Axis-aligned BSP TreeAxis-aligned BSP Tree

Page 6: Advanced Scene Management

6

AB

C

D

E

F

G

A

B C

D E F G

Polygon-aligned BSP TreePolygon-aligned BSP Tree

Page 7: Advanced Scene Management

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 ?

Page 8: Advanced Scene Management

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

Page 9: Advanced Scene Management

9

Quadtree - ExampleQuadtree - Example

Page 10: Advanced Scene Management

10

Data structure coherence Apply visibility culling from parents Split or not split ? Outdoor game scene ?

Octree – Some DiscussionOctree – Some Discussion

Page 11: Advanced Scene Management

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)

Page 12: Advanced Scene Management

12

eye

View frustum

Visibilityculling

Backfaceculling

Occlusionculling

Culling (2/2)Culling (2/2)

Page 13: Advanced Scene Management

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

Page 14: Advanced Scene Management

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)

Page 15: Advanced Scene Management

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)

Page 16: Advanced Scene Management

Effectiveness of PVSEffectiveness of PVS– Data setData set

Dynamic ObjectsDynamic Objects Room sizeRoom size

16

BSP ChallengesBSP Challenges

Page 17: Advanced Scene Management

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.

Page 18: Advanced Scene Management

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

Page 19: Advanced Scene Management

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;

};};

Page 20: Advanced Scene Management

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))

Page 21: Advanced Scene Management

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?

Page 22: Advanced Scene Management

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.

Page 23: Advanced Scene Management

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.

Page 24: Advanced Scene Management

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?

Page 25: Advanced Scene Management

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.