Depth Sorting

Depth sorting is just what it sounds like: figuring out what is farthest from the camera's point of view, which is important in rendering (drawing) 3D scenes. Many objects are opaque, meaning that you can not see through them. When rendering a scene, it is often important what order various parts of the image are drawn. If you don't pay attention to the rendering order, you might end up with a problem such as one opaque part obscuring a part that actually should be showing for the drawing to be accurate. The following two drawings illustrate that problem:

This is the correct drawing of the object:


This is an incorrect drawing which might be the result of drawing the parts in the wrong order:


One algorithm that would help us avoid the above problem incorporates hidden surface removal (HSR). The BSP tree is useful for implementing hidden surface removal and so is the painter's algorithm.