Rasterization : Z Buffering
by bkenwright@xbdev.net
Well you draw all those triangles...but sometimes they overlap....and this is where we come to depth management.
A simple analogy of this is painting - when you paint a picture with a paint brush - you paint the objects at the back first, then the nearer overlapping ones last.
In computer graphics, when you draw the triangles - you have to make sure they're drawn in the correct order.
The 'painter' method is whereby the triangles (or objects) are sorted along the camera direction - then drawn correctly. However, this fails when the triangles are intersecting.
An alternative, and the most common method - is to use a depth buffer - which keeps track of the drawn color for each pixel. As each triangle is drawn - it's broken down into pixels - for each pixel - you check the value in the depth buffer - if it's less than what you have for the new pixel - you ignore and don't write. Otherwise, you write the color to the pixel and update the depth buffer.
Easy eh?
Most modern rasterization engines now support depth buffers (or z-buffer) - which is an extra buffer for keeping track of the depth values - in addition to the rgb color values for each pixel.
|