Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 381 – Advanced Game Programming Scene Management

Similar presentations


Presentation on theme: "CSE 381 – Advanced Game Programming Scene Management"— Presentation transcript:

1 CSE 381 – Advanced Game Programming Scene Management
Data Structures & Algorithms World of Warcraft, Blizzard

2 Common Types of Scene Graphs
Bounding Sphere Trees Portals Binary Space Partitions Quadtrees Octrees Adaptive Binary Trees

3 Bounding Sphere Trees Scene graph & frustum culling
Subdivides world hierarchically Uses spherical regions Leaves of tree contain bounding sphere of model Models grouped in parent spheres Groups grouped into larger spheres Root sphere has entire scene

4 Bounding Sphere Tree Culling
1) Make root node the current node 2) If frustum collides with current node sphere: a) if current node is a leaf, put in display list b) else send each child node to Step 2) as current node

5 Spatial Partitioning Bonus
Reduces what's sent to rendering system Reduces collision tests Only test models against models in the same group leaf vs. leaf

6 Portals First, world/map is divided into Sectors
i.e. areas/zones Sectors are connected via Portals typically placed manually by level designers Sector Sector Portals Sector

7 Players and Portals Players move about level
When player is in a Sector: send items in that sector for frustum culling Players move between sectors Players may see from one sector into another Sector Sector

8 Concave vs. Convex Sectors are typically Convex Why?

9 Designer Strategy Sectors are not typically uniformly shaped
But must be closed geometry No intersecting faces No holes How can the game designer specify sectors? place portals placed as very thin box add occluders to level: walls, fences, buildings, (cannot be planes) separate and hide objects in sector from rest of level automatically calculate sectors

10 Solid vs. Hollow Objects
Models are solid objects normals face out Rooms (interiors) are hollow objects normals face in may not be viewable from outside Combinations of these are used to build levels

11 Occluders Mesh Laid out by level designer
Joins all occluder meshes in one mesh. Ex: in modeler, combine and rename OCCLUDER_MESH specify all portals as PORTAL_... build and export the level mesh A low-res mesh simple wall geometry typically less than 200 triangles so cheap rendering

12 Exporting the Mesh Example
Done using a script Search for the OCCLUDERS_MESH Invert OCCLUDERS_MESH normals i.e. make it solid Subtract all PORTAL_*s from OCCLUDERS_MESH Invert the normals for the resulting mesh i.e. make it hollow Export the resulting mesh, the OCCLUDERS_MESH, and the portals to a map file

13 Sector Generation Remember, this must be a closed geometry
Walk through the vertices: visit all those in each closed geometry mark each group in common sector

14 What do you use it for? Sector testing. Ex: find the sector a point lies in Kind of like frustum culling Start at the root node Walk down to find sector Scene Graph Culling. Ex: render Occluder mesh (cheap) test portals against frustum render sectors connected to portals that pass

15 BSP Trees Binary Space Partition
to determine what sector an object is in Each level uses splitter plane to divide into half spaces convex half spaces Three Types: regular, leafy, and solid node (SNBSP)

16 It's all about the splitter planes
They separate objects

17 Alternative Representation
B-Rep? boundary representation

18 BSPs help with collision stuff too
Higher priorities for testing against stuff on the same side

19 Object to Plane testing
Dictates much of BSP construction To Build BSPs test objects against splitter put into different groups

20 Painter's Algorithm Uses regular BSP type
Separates polygons by half-spaces Why? polygon-to-polygon occlusion testing We don't need this. Why? hardware does this anyway

21 NULL represents hollow region
SNBSPs Good for sector testing Build them once: select starting splitter plane maintains nodes for each sector. Ex: struct SnBSPNode { plane splitPlane; int area; // sector ID SnBSPNode frontNode; SnBSPNode backNode; } NULL represents hollow region

22 Portals vs. BSPs Commonly used together Think a hybrid scene graph
good for scene graph culling (to reduce rendering) BSPs: good for collision test culling

23 Quadtrees Partitions world in 2D used for 2D and 3D games

24 To build a quadtree Compute AABB for each object
Compute AABB for entire scene, put objects into this root node Divide scene AABB into 4 boxes not necessarily the same size Put each object in current parent node into a box child node according to location Repeat a-b until decomposition limit reached Note: all objects end up in leaf nodes may choose to limit at most 2 objects per leaf

25 To use a quadtree Walk down the tree to test points
for placing objects What’s this good for? What quads are currently in frustum? Scene graph culling How far are quads from camera LOD for terrain

26 Octrees An extension of quadtrees Work well with outdoor scenes
or scenes with large empty spaces px-Octree2.svg.png 26

27 Octree Rendering Frustum cull as you move down the tree
Make root node test node If test node is leaf Render leaf contents and exit Else if node is not in frustum Exit Else For each child node: Set child node to test node and go to step 2.

28 Node Confusion With Quad/Octrees, what if an object overlaps a box?
split the geometry and put in two nodes? store object in common parent node? loose octree use Adaptive Binary Trees (ABT)?

29 ABT Nodes can overlap Nodes can change
Good at managing dynamic geometry at runtime By the way, there are many other custom techniques used as well

30 So which approach is best?
There is no “best”? Modern game engines usually use hybrid Ex: Ogre3D Use BSPs for closed areas Use Octrees for open areas

31 Octrees Example

32 ABT Example

33 References A tutorial on Binary Space Partitioning Trees by Bruce F. Naylor, Spatial Labs, Inc. 463/2001/pub/www/notes/bsp_tutorial.pdf


Download ppt "CSE 381 – Advanced Game Programming Scene Management"

Similar presentations


Ads by Google