in a 3D scene, shapes overlap. A cup sits in front of a wall, so some wall pixels are hidden. If you simply draw everything, whatever is drawn last wins, even if it's behind. The first fix was the painter's algorithm: sort shapes from farthest to nearest and draw in
that order, like a painter doing the background first. It has two problems. Sorting every frame is expensive, and some arrangements can't be sorted at all (three shapes that each overlap the next, in a circle).
commit d7f8136