0
33kviews
Write and explain the depth buffer(Z-buffer) algorithm for detecting visible surface. OR Write short note on depth buffer algorithm.
1 Answer
3
1.9kviews

(Z-Buffer) Depth Buffer Method:-

One of the simplest and commonly used image space approach 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 the z-axis of a viewing system. When object description is converted to projection co-ordinates (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 range from 0 at the back clipping plane to 1 at the front clipping plane. The implementation requites 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 colour. Each surface listed in the display file is then processed, one scan line at a time, calculating the depth (z-value) at each (x, y) pixel position. The calculated depth value is compared to the value previously stored in the Z-buffer at that position. If the calculated depth values are 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 figure (e) shown below, among three surfaces, surface S1 has the smallest depth at view position (x, y) and hence highest z value. So it is visible at that position.

enter image description here

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) = Ibackground
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) = Isurface(x, y) 
3. Stop

Note that, Ibackground is the value for the background intensity, and Isurface 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

enter image description here

Note, if at (x, y) the above equation evaluates to z1, then at (x + ∆x, y) the value of z. is,

enter image description here

Only one subtraction is needed to calculate z(x + 1. y), given z(x, y). Since the quotient A/C is constant and ∆x = 1. A similar incremental calculation can be performed to determine the first value of z on the next scan line, decrementing by B/C for each ∆y.

Advantages:-

I. It is easy to implement.

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

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

Disadvantages:-

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

  1. It is a time consuming process as it requires comparison for each pixel instead of for the entire polygon.
Please log in to add an answer.