Depth-Sorting
Method &
BSP-Tree
Method
Depth-Sorting Method
Is an algorithm which used in Computer graphics for visible surface determination. It
works on polygon-by-polygon basis and sorts the polygons within the image by their
depth, placing each polygon in order from the farthest to the closest object.
This algorithm extends the painter’s algorithm for polygons to produce correct output in
all cases. The ordering used by the algorithm is called a ‘depth order’ and does not have
to respect the numerical distances to the parts of the scene. The essential property of this
ordering is rather, that if one object obscures part of another object, then the first object is
painted after the object that it obscures.
Thus, a valid ordering can be described as a topological ordering of a directed acyclic
graph representing occlusion between objects.
Depth-Sorting Algorithm. Works as follows:
1.
Sort each polygon by depth.
2.
Sort all polygons from farthest to nearest.
3.
Detect cases where two polygons have ambiguous ordering.
Subdivide such polygons until the pieces have an explicit ordering,
and place those in the sort list in the correct priority order.
4.
Render all polygons in priority order, from farthest to nearest.
The ordering of two polygons is considered as ambiguous under this algorithm if
their z-extents overlap and one polygon intersects the plane of the other
Depth-Sorting Method
1
2
The distant mountains are painted first, followed by the closer grass,
finally the trees are painted. Although some trees are more distant from
the viewpoint than some part of grass, the ordering (mountains, grass,
trees) forms a valid depth order, because no object in the ordering
obscures any part of a later object
3
Cyclical Overlapping
In the case of cyclic overlap, as shown in the figure below, Polygons A, B and C overlap each other in
such a way that it is impossible to determine which polygon is above the others. In this case the
offending polygons must be cut to allow sorting.
B
A
C
Cyclical Overlapping
C’
B
A
B’
C
A’
Binary Space
Partitioning
(BSP)
What is Binary Space Partitioning (BSP)
Binary Space Partitioning. Is a method for space partitioning which recursively subdivides a
Euclidian space into two convex sets by using hyperplanes as partitions.
This process of subdividing gives rise to a representation of objects within the space in the form of a
tree data structure known as a BSP tree.
Binary Space Partitioning was developed in the context of Computer graphics in 1969. the structure
of a BSP tree is useful in rendering because it can efficiently give spatial information about the objects
in a scene, such as objects being ordered from front-to-back with respect to a viewer at a given location.
Building BSP-Trees (Cont..)
1.
Choose a polygon P from the list.
2.
Make a node N in the BSP tree, and add P to the list of polygons at that node.
3.
For each other polygon in the list:
 If that polygon is wholly in front of the plane containing P, move that polygon to the
list of nodes in front of P.
 If that polygon is wholly behind the plane containing P, move that polygon to the list
of nodes behind P.
If that polygon is intersected by the plane containing P, split it into two polygons and
move them to the respective lists of polygons behind and in front of P.
If that polygon lies in the plane containing P, add it to the list of polygons at node N.
Building BSP-Trees
A
4. Apply this algorithm to the list of polygons in front of P.
5. Apply this algorithm to the list of polygons behind P.
B1
D1
A
B
D
C1
B2
C2
D2
C
Back
Front
D3
Start with a list of lines, (or in 3D, polygons) making up the scene. Nodes in the BSP tree are denoted
by Circles.
In the spatial diagram of the lines, the direction chosen to be the ‘front’ of a line is denoted by an
arrow.
Building BSP-Trees
STEP 01:
A
B1
D1
B
D
D2
C1
A
B2
C2
C
B1
B2
C1
C2
D1
D2
Building BSP-Trees
STEP 02:
A
B1
D1
B
D
C1
A
B2
B1
B2
C2
C
C1
D2
D1
D3
C2
D3
D2
Building BSP-Trees
STEP 03:
A
B1
D1
A
B
D
C1
B2
C2
D2
B2
B1
C
C1
D1
C2
D3
D3
D2
Building BSP-Trees
STEP 04:
A
B1
D1
A
B
D
C1
B2
B1
B2
C2
C
D2
C1
D1
C2
D3
D3
D2