Depth sorting Flashcards
What is Depth Sorting?
First draw the distant objects than the
closer objects. Pixels of each object overwrites the previous objects.
Depth sorting is also known as
painters algorithm
What is depth sort algorithm?
- Sort all the polygons based on their farthest z -coordinate
- Resolve ambiguities
- Draw the polygons in order from back to front
what is the complexity of the depth sort algorithm?
This algorithm would be very simple if the z coordinates of the
polygons were guaranteed never to overlap. Unfortunately that is
usually not the case, which means that step 2 can be somewhat
complex
When do ambiguities of two z extents arise?
Ambiguities arise when the Z extent of two surfaces overlap
The test’s in Depth Sort Algorithm
if any of this does the test fails
Do P and Q x’s and y’s overlap
Is P entirely on the opposite side of Q’s plane from the viewport?
Is Q entirely on the same side P’s plane as the viewport?
Do the projections P and Q onto the (x,y) not overlap?
What to do if all the tests fail?
Then reverse P and Q in the list of surfaces sorted by the maximum depth
Set a flag to say that the test has been performed
if the test fails a second time then it is necessary to split the surfaces and repeat the algorithm on the 4 new split surfaces