One of the simplest and commonly used image space
approaches to eliminate hidden surfaces is the

**Z-buffer**or**depth buffer**algorithm. It is developed by Catmull. This algorithm compares surface depths at each pixel position on the projection plane. The surface depth is measured from the view plane along z axis of a viewing system. When object description is converted to projection coordinates (x, y, z), each pixel position on the view plane is specified by x and y coordinate, and z value gives the depth information. Thus object depths can be compared by comparing the z-values.
The Z-buffer algorithm is usually implemented in the
normalized coordinates, so that z values from 0 at the back clipping plane to 1
at the front clipping plane. The implementation requires another buffer memory
called Z-buffer along with the frame buffer memory required for raster display
devices. A Z-buffer is used to store depth values for each (x, y) position as
surfaces are processed, and the frame buffer stores the intensity values for
each position. At the beginning Z-buffer is initialized to zero, representing
the z-value at the back clipping plane, and the frame buffer is initialized to
the background color. Each surface listed in the display file is then
processed, one scan line at a time, calculating the depth (z-value) at each
pixel position. Then calculated depth value is compared to the value previously
stored in the z-buffer at that position. If the calculated depth value is
greater than the value stored in the Z-buffer, the new depth value is stored,
and the surface intensity at that position is determined and placed in the same
xy location in the frame buffer.

For example, in the above figure among three surfaces,
surface SI has the smallest depth at the view position (x, y) and hence highest
z value. So it is visible at that position.

**Z-BUFFER ALGORITHM**

1. Initialize the Z-buffer and frame buffer so
that for all buffer positions Z-buffer (x, y) = 0 and frame-buffer (x, y) = I

_{background}
2. During scan conversion process, for each
position on each polygon surface, compare depth values to previously stored
values in the depth buffer to determine visibility. Calculate z-value for each
(x, y) position on the polygon If z > Z-buffer (x, y), then set Z-buffer (x,
y) = z, frame-buffer (x, y) = I

_{surface}(x, y)
3. Stop

Note that, I

_{background}is the value for the back ground intensity, and I_{surface}is the projected intensity value for the surface at pixel position (x, y). After processing of all surfaces, the Z-buffer contains depth values for the visible surfaces and the frame buffer contains the corresponding intensity values for those surfaces.
To calculate z-values, the plane equation

Ax + By + Cz + D = 0

is used where (x, y, z) is any point on the plane, and
the coefficient A, B, C and D are constants describing the spatial properties
of the plane.

Therefore, we can write Z = (- Ax - By - D) / C

**ADVANTAGES**

1. It is easy to
implement.

2. It can be implemented in hardware to
overcome the speed problem.

3. Since the algorithm processes objects one
at a time, the total number of polygons in a picture can be arbitrarily large.

**DISADVANTAGES**

1. It requires an additional buffer and hence
the large memory.

2. It is a time consuming process as it
requires comparison for each pixel instead of for the entire polygon.

## No comments:

## Post a Comment