Presentation is loading. Please wait.

Presentation is loading. Please wait.

Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye 2001. 12. 04.

Similar presentations


Presentation on theme: "Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye 2001. 12. 04."— Presentation transcript:

1 Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye 2001. 12. 04

2 Graphics Laboratory Korea University -2- Chung ji hye Overview Why do you use Sorting? Correct drawing of a scene To avoid drawing a pixel on the screen multiple times Type of sorting Quadtrees and Octrees Use of portals BSP trees

3 Graphics Laboratory Korea University -3- Chung ji hye Quadtrees & Octrees Construction of a scene graph can be based on planar locations : Quadtrees Spatial locations : Octrees Quadtrees & Octrees Attempt to setup visibility graph based on structure of the world and the objects Partition the world into cell

4 Graphics Laboratory Korea University -4- Chung ji hye Quadtrees & Octrees cameraBlock = GetBlockOf(renderer.camera); visibleList = GetVisibleCellsFrom(cameraBlock); for(each node in visibleList) renderer.Draw(node);

5 Graphics Laboratory Korea University -5- Chung ji hye Portals Portal systems Requires less interaction to setup visibility graph Specify additional planes that trim down the view frustum into smaller pieces Doorway is a portal Allows you to see inside the contents Objects hidden by the walls can be culling Partially hidden by the walls can be clipping Useful for indoor style game Many walls and other objects obstruct the view

6 Graphics Laboratory Korea University -6- Chung ji hye Portals Illustration of visibility through a portal

7 Graphics Laboratory Korea University -7- Chung ji hye Portals Culling mechanism Keep track of a flag of six bits Each bit indicating whether or not the object is culled Flag can be extended to have any number of bits Camera can store additional planes for culling purposes Partition into convex regions Rendering algorithm Back to front order

8 Graphics Laboratory Korea University -8- Chung ji hye Binary Space Partitioning Data structure used to represent the partitioning Object is on the positive side associated with the front child of the node Object is on the negative side associated with the back child of the node Sorting polygon by way of a depth first traversal of the tree

9 Graphics Laboratory Korea University -9- Chung ji hye BSP Tree P0P0 P0P0 P2P2 P1P1 P1P1 P2P2 c0c0 c3c3 c4c4 P3P3 C0C0 P3P3 C3C3 C4C4 c1c1 c2c2 C1C1 C2C2 + - + - + - + -

10 Graphics Laboratory Korea University -10- Chung ji hye Hidden Surface Removal Back to Front Drawing Background first and foreground last Positive side of the plane Dot products used to determine the object is in the cone of the view frustum Partition plane Intersects the view frustum

11 Graphics Laboratory Korea University -11- Chung ji hye Hidden Surface Removal Front to Back Drawing Draw the polygons closet to the eye point Pixel don ’ t be overwritten Only use when it is known what order the polygons are

12 Graphics Laboratory Korea University -12- Chung ji hye Scan Line Masks Scan Line Method Keep track of each scan line separately Interval [x 0, x 1 ) Left end point is included, right end point is not included

13 Graphics Laboratory Korea University -13- Chung ji hye Scan Line Masks Screen width is W pixel [0,W) Triangle is rasterized on that scan line in the interval [x 0, x 1 ) Value X 0 causes split [0,x 0 ), [ x 0,w) [0,w) [0, x 0 )[ x 0,w) x0x0 x1x1 [ x 1,w) [x0,x1)[x0,x1)

14 Graphics Laboratory Korea University -14- Chung ji hye Scan Line Masks New initial interval [x 2, x 3 ) Supposed that 0<= x 0 <x 2 <x 1 <x 3 <= w Comparing x 2 against x 1 Left child is interval of drawn pixel no splitting occur Comparing x 3 against leaf node [ x 1,w) Undrawn pixel Splitting occur [x 1, x 3 ) and [x 1, w)

15 Graphics Laboratory Korea University -15- Chung ji hye Scan Line Masks Representing BSP Tree [0,w) [0,x 0 )[x 0,w) x0x0 x1x1 [x 1,w) [x 0,x 1 ) x2x2 x3x3 [x 1,x 3 )[x 3,w)

16 Graphics Laboratory Korea University -16- Chung ji hye Visibility Determination Deciding what part of the world are visible from that location Knowing what is visible helps to minimize the data is sent to the renderer Can be used for occlusion culling View space method Visibility tree Screen space method World tree

17 Graphics Laboratory Korea University -17- Chung ji hye View Space Method Three dimension Represents the view frustum Compares objects and parts of objects to each other

18 Graphics Laboratory Korea University -18- Chung ji hye Screen Space Method Two Dimension Initially represents the rectangle corresponding to the drawable pixels on the screen World tree sorts the polygons from Front to back Visible subpolygon obtained in the clipping Subpolygons can be stored in a list Whatever purposes the application requires

19 Graphics Laboratory Korea University -19- Chung ji hye Quadtrees & Octrees


Download ppt "Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye 2001. 12. 04."

Similar presentations


Ads by Google