Z-Buffer algorithm vs Painter's algorithm? In hidden surface removal, how does the Z-buffer algorithm work vs. painter's algorithm?
In the painter's algorithm, you first sort all graphics elements
on depth (deepest first) and
then one-by-one fully paint them into the image on top of each other.
That way, deeper elements are obscured by less deep element.
(Intersecting graphics element require special attention.)
In the depth-buffering algorithm,
you store the current depth of each pixel in the image
(in addition to other pixel info),
and fully paint each graphics element pixel-by-pixel,
where an image pixel is updated
only if its depth is more than that of the new pixel.


So, there is a time-memory tradeoff:


The painter's algorithm requires an extra sorting step (costs time),
but avoids storing additional (depth) information per pixel (saves memory).
Depth-buffering avoids sorting (saves time),
but stores extra (depth) information per pixel (costs memory).