1.23k likes | 1.41k Views
CHAPTER 13 Scene Management. ( 友鈞 , 思元 , 紘瑋 , 章民 , 昭泉 , 琮凱 , 冠逸 ). Introduction ( 友鈞 ) The Concept of Scene Management ( 友鈞 ) Scene Management Techniques ( 紘瑋 ) Implementing a BSP Tree ( 思元 ) Class Declaration ( 章民 ) Implementing an Octree ( 琮凱 )
E N D
CHAPTER 13Scene Management (友鈞,思元,紘瑋,章民,昭泉,琮凱,冠逸) 13. Scene Management
Introduction (友鈞) • The Concept of Scene Management (友鈞) • Scene Management Techniques (紘瑋) • Implementing a BSP Tree (思元) • Class Declaration (章民) • Implementing an Octree (琮凱) • Demo Application: Octree and BSP Tree (冠逸) • One Look Back, Two Steps Forward (昭泉) Agenda 13. Scene Management
Introduction & The Concept of Scene Management Speaker: Icarus 13. Scene Management
■ Learning the concepts of scene management • ■ Understanding quadtrees and terrain rendering • ■ Using BSP trees and octrees for collision detection • ■ Understanding what a portal engine is • ■ Implementing a BSP tree and an octree • ■ Using the code in the demo application Introduction 13. Scene Management
The term scene management describes algorithms and methods that let you select only the polygons that are needed for a certain location and orientation of the viewer out of the whole set of a hundred thousand polygons of the level.Most of those polygons are not visible to the user. The Concept of Scene Management 13. Scene Management
The removal of polygons that cannot be seen from a certain position and orientation of the viewer (because they are completely hidden behind other polygons) is called hidden surface removal, or HSR. • Another term for this is occlusion culling --------------------HOM, Occlusion frustum • View frustum culling The Concept of Scene Management 13. Scene Management
Q&A 13. Scene Management
Scene Management Techniques Speaker: XJACK, Hsu GAMELab/CSIE/NDHU 13. Scene Management 8
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 9
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 10
Overview • You should always separate your algorithm in terms of the setting in which they should be used • Types of games • Indoor • Outdoor • No-door GAMELab/CSIE/NDHU 13. Scene Management 11
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 12
No Solution Is Also a Solution The basic method : brute force approach In outdoor games that feature a number of small buildings Using this to save you a lot of development time and headaches GAMELab/CSIE/NDHU 13. Scene Management 13
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 14
Continuous and Discrete Level of Detail • Scene management • Not only about removing whole objects from scene • More you can do • Level of detail (LOD) GAMELab/CSIE/NDHU 13. Scene Management 15
Continuous and Discrete Level of Detail • Discreet LOD • Continuous LOD • Start from the most detailed version of the model and calculates a less detailed version on-the-fly • Suited for big, complex objects GAMELab/CSIE/NDHU 13. Scene Management 16
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 17
Quadtrees • You already know the frustum culling text • Disadvantage • You have to test each object in the game • Quadtrees • Suited to tread 2D problem • 3D => 2D GAMELab/CSIE/NDHU 13. Scene Management 18
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 19
Quadtrees • Suppose the game is played in first-person view with the player walking around village • Why? • Less calculate • How? • Start from the root by subdividing the big rectangle in to 4 rectangles • When? • A leaf must not contain polygons from more than a single house GAMELab/CSIE/NDHU 13. Scene Management 20
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 21
Quadtrees Heightmap is the most common way to represent the data of a terrain GAMELab/CSIE/NDHU 13. Scene Management 22
Quadtrees It is rather stupid to generate four rectangles with eight triangles You can achieve the same result by using only one rectangle with two triangles GAMELab/CSIE/NDHU 13. Scene Management 23
Quadtrees • The theory of applying quadtrees to terrain rendering • For example • 9 * 9 heightmap • 3 * 3 terrain block GAMELab/CSIE/NDHU 13. Scene Management 24
Quadtrees The theory of applying quadtrees to terrain rendering GAMELab/CSIE/NDHU 13. Scene Management 25
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 26
Quadtrees No gain in performance? Normal view frustum culling with the nodes bounding boxes If a node is not inside, you can ignore it and all of its child nodes Implement LOD GAMELab/CSIE/NDHU 13. Scene Management 27
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 28
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 29
Quadtrees GAMELab/CSIE/NDHU 13. Scene Management 30
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 31
Octrees The same thing that you do with quadtrees in 2D can be done in 3D Octrees GAMELab/CSIE/NDHU 13. Scene Management 32
Octrees • The stop condition is basically the same as in the quatree • Two solution for the situation of when an object will not fit completely into one single node • Cut the object into two separate objects • Not cut but store them only on the node where their point lies • We implement an octree at the end of this chapter GAMELab/CSIE/NDHU 13. Scene Management 33
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 34
Binary Space Partitioning Trees • The BSP tree can partition the space or the geometry that occupies space using arbitrary partitioning planes • Advantage • You do not need to split as many polygons • You can even adjust the algorithm’s heuristic to avoid splits • The BSP tree is a data structure that stores the result of the BSP algorithm GAMELab/CSIE/NDHU 13. Scene Management 35
Binary Space Partitioning Trees • Convex polygon Concave polygon GAMELab/CSIE/NDHU 13. Scene Management 36
Binary Space Partitioning Trees A collection of polygons in 3D space is convex when you can go into each position inside the convex and look in each direction By dividing a complex 3D level into a lot of convex groups, you can render a whole level without the need for a depth buffer GAMELab/CSIE/NDHU 13. Scene Management 37
Binary Space Partitioning Trees GAMELab/CSIE/NDHU 13. Scene Management 38
Binary Space Partitioning Trees GAMELab/CSIE/NDHU 13. Scene Management 39
History of BSP tree in Video games BSP algorithm was originally developed in the end of the 1970s at the university of Texas at Dallas Henry Fuchs and Zvi Kedem Bruce Naylor Predetermining Visibility Priority in 3D Scenes [SIGGRAPH 79] On Visible Surface Generation by A Priori Tree Structures[SIGGRAPH 80] A priori Based Techniques for Determining Visibility Priority for 3D Scenes GAMELab/CSIE/NDHU 13. Scene Management 40
History of BSP tree in Video games DOOM 1 in December 1993 GAMELab/CSIE/NDHU 13. Scene Management 41
History of BSP tree in Video games DOOM 1 uses a 2D BSP algorithm and BSP tree GAMELab/CSIE/NDHU 13. Scene Management 42
History of BSP tree in Video games Quake 1 by id software in June 1996 This was the first video game that used a real 3D BSP algorithm GAMELab/CSIE/NDHU 13. Scene Management 43
Finding the best splitter(BSP) • The BSP algorithm is not very complicated • The secret of the algorithm is to select one of the polygons at each node as splitter to divide the list of polygons into two smaller lists • Which polygon do you choose as a splitter? • Two attributes • How many polygons get cut by a certain splitter? • The balance of the tree GAMELab/CSIE/NDHU 13. Scene Management 44
Finding the best splitter(BSP) Score GAMELab/CSIE/NDHU 13. Scene Management 45
Finding the best splitter(BSP) GAMELab/CSIE/NDHU 13. Scene Management 46
Finding the best splitter(BSP) GAMELab/CSIE/NDHU 13. Scene Management 47
BSP Tree Variants • Three variants • Node-Based BSP Trees • To do collision detection without doing any kind of calculation • Leafy BSP Tree • You do not retain the solid information • Solid BSP Tree • Combines both of the advantages of the approaches into a single BSP tree GAMELab/CSIE/NDHU 13. Scene Management 48
Outline Overview No Solution Is Also a Solution Continuous and Discrete Level of Detail Quadtrees Octrees Binary Space Partitioning Trees Portal Engines Potential Visibility Set GAMELab/CSIE/NDHU 13. Scene Management 49
Portal Engines There was another scene management approach working its way into the industry Portal Engines It is not a tree structure GAMELab/CSIE/NDHU 13. Scene Management 50