What is a Z-Buffer
(3/5/00 4:13:01 pm)

Can someone explain what a Zbuffer is and what it's good for.


Voodoo VB  
(3/5/00 7:08:19 pm)

It's used in 3D apps and is used so the polygons currently not in view are not drawn.


Daniel Netz
(3/6/00 6:58:49 am)

That's not really what it does, the Z buffer takes care of a problem called Z-fighting that occurs when two polygons have the same depth (z), if they do and a z buffer is not available, it will most likely flip between the two polygons and it's gonna look odd.

A z buffer stores the polygon depth and helps prevent z-fighting from occuring, it can also be used for hidden surface removal.

Edited by Daniel Netz at: 3/6/00 6:58:49 am

Eric Coleman  
(3/6/00 11:27:30 pm)

Actually Peter is right. Z-buffering is an algorithm that is used to help with hidden surface removal.

There is an alternate to the z-buffer algorithm, called the painter's algorithm. Its more complicated than z-buffers, but less intensive on the cpu. 

Technically, a z buffer is an screen buffer the same size as the video screen. For example, 640 x 480 matrix of 16 bit numbers for a 16 bit z-buffer, or integers, or whatever preicsion is needed.
All the polygons are projected onto the view plane, then the x,y values for the points in the plane correspond to coordinates in the z buffer. Then the color of the z value that is nearest to the view plane is stored in the z-buffer. After all is done, the z-buffer contains a finished image of what is to be displayed.

As for a pixel having two or more identical z values, then one would need to increase the precision of the z-buffer.