Upload
rolf-hawkins
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
2
A tree-based or graph-based representation is good for 3D data A tree-based or graph-based representation is good for 3D data managementmanagement Scene treeScene tree Scene graphScene graph
3D data management including :3D data management including : Transformations for each 3D objectTransformations for each 3D object
Hierarchical relationshipHierarchical relationship Space coherenceSpace coherence Data instancingData instancing Geometric computationGeometric computation
Hit testHit test Collision detectionCollision detection Terrain followingTerrain following
Rendering managementRendering management VisibilityVisibility Alpha SortingAlpha Sorting
Scene Management in Hierarchical FormScene Management in Hierarchical Form
3
EtcEtc
ParametersParameters
Geometric DataGeometric Data
ShapeShape
TransformationTransformation MoveMove
Parent ObjectParent ObjectHierarchyHierarchy
Motion DataMotion Data
AnimationAnimation
CloneClone
An Object in the Scene (An Example from An Object in the Scene (An Example from TheFly)TheFly)
4
A tree-based representation A simplified scene graph
RootRoot
A Scene Tree (An Example) 1/2A Scene Tree (An Example) 1/2
5
A tree-based representation A simplified scene graph
A Scene Tree (An Example) 2/2A Scene Tree (An Example) 2/2
RootRoot
6
Bounding sphereBounding sphere
Bounding SphereBounding Sphere AABBAABB
OBBOBB
k-DOPk-DOP
Bounding VolumeBounding Volume
Bounding CylinderBounding Cylinder
Bounding cylinderBounding cylinder Axis-aligned bounding box (AABB)Axis-aligned bounding box (AABB) Oriented bounding box (OBB) Oriented bounding box (OBB)
Discrete oriented polytope (k-DOP)Discrete oriented polytope (k-DOP)
7
Collision detectionCollision detection VVisibility cullingisibility culling HHit testit test SSteering behaviorteering behavior
IIn “Game AI” sectionn “Game AI” section
Bounding Volume - ApplicationsBounding Volume - Applications
8
Bounding sphere BBounding sphere B11(c(c11, r, r11), B), B22(c(c22, r, r22))
If the distance between two bounding spheres isIf the distance between two bounding spheres islarger than the sum of radius of the spheres, thanlarger than the sum of radius of the spheres, thanthese two objects have no chance to collide.these two objects have no chance to collide.
D > Sum(rD > Sum(r11, r, r22))
DD
BB11
BB22
cc11
cc22
Application Example - Bounding SphereApplication Example - Bounding Sphere
9
Axis-aligned bounding box (AABB)Axis-aligned bounding box (AABB) SSimplified calculation using axis-alignment featureimplified calculation using axis-alignment feature BBut need run-timely to track the bounding boxut need run-timely to track the bounding box
AABBAABB
Application Example - AABBApplication Example - AABB
10
Oriented bounding box (OBB)Oriented bounding box (OBB) Need intersection calculation using the transformed Need intersection calculation using the transformed
OBB geometric dataOBB geometric data 3D containment test3D containment test Line intersection with planeLine intersection with plane
FFor games, or games,
OBBOBB
Application Example - OBBApplication Example - OBB
11
This is a game-type-oriented issue.This is a game-type-oriented issue. Bounding volume hierarchies (BVHs)Bounding volume hierarchies (BVHs) Binary space partition trees (BSP Trees)Binary space partition trees (BSP Trees)
““Quake”Quake” Octree & quadtreeOctree & quadtree Possible Visible SetPossible Visible Set Culling SkillsCulling Skills
Advanced Scene GraphsAdvanced Scene Graphs
12
Bounding spheres or AABB in hierarchy Can be used for dynamic scene objects
R
B
Bounding Volume Hierarchies (BVHs)Bounding Volume Hierarchies (BVHs)
13
LBVH Linear BVH Tree construction using Morton Code
BVH Construction - LBVHBVH Construction - LBVH
14
2D example
Morton Code (1/2)Morton Code (1/2)
Generate the Morton Code Convert the x and y coordinate numbers into binary Then “interleave” the bits to get the Morton number
-0-0-1 : 1 in binary1-0-1- : 5 in binaryxyxyxy100011 : 35 Your interleaved Morton number
15
Morton Code (2/2)Morton Code (2/2)
By constructing a 2kx2kx2k lattice within the AABB of the whole scene, we can quantize each of the 3 coordinates of the center of the bounding volume of the scene object.
The 3-bit Morton Code of the object is constructed by interleaving the successive bits of these coordinates.
Sorting the objects in increasing order along the Morton curve. We construct the 1st level split by examining the most
significant bit of all codes, placing those with 0 and 1 bits in the 1st and 2nd child, respectively, of the root.
Applying the bucketing procedures recursively in each child, looking at the 2nd most significant bit.
In each recursive step, we look at the next bit in the Morton code until all bits are consumed.
16
BVH Construction – SAH Hierarchy BVH Construction – SAH Hierarchy ConstructionConstruction SAH
Surface Area Heuristic method Calculate the cost to bin the tree node into two children
SAH cost function
SA(N) the surface area of the node’s bounding volumeKT & KI are constantsnl : object number of left child nodenr : object number of right child node
Can be applied to BVH and KD Tree.
17
Two variantsTwo variants Axis-alignedAxis-aligned
KD treeKD tree Polygon-alignedPolygon-aligned
The trees are created by using a plane to divide the space into The trees are created by using a plane to divide the space into two, and then sorting the geometry into two spaces.two, and then sorting the geometry into two spaces.
BSP TreeBSP Tree
18
plane1plane1
plane
plane
00
plane2plane2
plane
plane
33
00
11 22
33
Axis-aligned BSP TreeAxis-aligned BSP Tree
20
Quickly to identify where you areQuickly to identify where you are BSP = SortingBSP = Sorting
Need a pre-processor to generate the PVSNeed a pre-processor to generate the PVS Visibility culling + occlusion cullingVisibility culling + occlusion culling PVS : Possible Visible SetPVS : Possible Visible Set
Optimized for in-door game environmentOptimized for in-door game environment [Fuch80][Fuch80]
Fuchs, H.,Fuchs, H., On Visible Surface Generation by a Priori Tree StructuresOn Visible Surface Generation by a Priori Tree Structures, , Computer GraphicsComputer Graphics, , 1414, 124-33, (Proc. SIGGRAPH’80) , 124-33, (Proc. SIGGRAPH’80)
Why BSP Tree ?Why BSP Tree ?
21
Very similar to axis-aligned BSP tree.Very similar to axis-aligned BSP tree. Except that a box is split simultaneously along all three axes.Except that a box is split simultaneously along all three axes. The split point should be the center of the box.The split point should be the center of the box. This creates eight new boxes.This creates eight new boxes. Quadtree is the 2D version of octree.Quadtree is the 2D version of octree.
Octree & QuadtreeOctree & Quadtree
23
Data structure coherenceData structure coherence Apply visibility culling from parentsApply visibility culling from parents Split or not split ?Split or not split ? Outdoor game scene ?Outdoor game scene ?
Octree – Some DiscussionOctree – Some Discussion
24
Culling means “remove from a flock”Culling means “remove from a flock” Visibility cullingVisibility culling
Remove the object not in view frustumRemove the object not in view frustum A A “must”“must” feature within the game engine feature within the game engine
Backface cullingBackface culling Remove the polygons facing away from cameraRemove the polygons facing away from camera Hardware standardHardware standard
Occlusion cullingOcclusion culling Remove the objects hidden by the othersRemove the objects hidden by the others A complicated issue for gamesA complicated issue for games
Culling (1/2)Culling (1/2)
25
eyeeye
View frustumView frustum
VisibilityVisibilitycullingculling
BackfaceBackfacecullingculling
OcclusionOcclusioncullingculling
Culling (2/2)Culling (2/2)
26
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 Perform terrain following & collision detectionPerform terrain following & collision detection
Or all interaction between the player’s character and the Or all interaction between the player’s character and the scenescene
BSP ImplementationBSP Implementation
27
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
BSP Preprocessor (1/2)BSP Preprocessor (1/2)
28
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”, ray cast all rooms to generate the possible For each “room”, ray cast all rooms to generate the possible
visible room setvisible room set 2D layers or 3D2D layers or 3D Time consumingTime consuming
BSP Preprocessor (2/2)BSP Preprocessor (2/2)
29
Effectiveness of PVSEffectiveness of PVS Data set sizeData set size The rangeThe range
Hard for dynamic scene objectsHard for dynamic scene objects Apply BSP to static scene objectsApply BSP to static scene objects Apply visibility culling and collision detection to dynamic Apply visibility culling and collision detection to dynamic
scene objectsscene objects Room sizeRoom size
BSP ChallengesBSP Challenges