Hire Our Expert Programmer & Technical Writer To Do Your Capstone Project
+1 vote
in Programming Languages & Algorithms by

1 Answer

+1 vote
selected by (user.guest)
Best answer

The z-buffer or depth buffer is one of the simplest of the visible surface or hidden surface algorithms and it is an image space algorithm. The z-buffer is a simple extension of a frame buffer idea. A frame buffer is used to store the attributes (intensity or shade) of each pixel in the image space. The z-buffer is a separate depth buffer used to store the z co ordinate or depth of every visible pixel in the image space. In use, the depth or z-value of a new pixel to be written to the frame buffer is compared to the depth of that pixel stored in the z-buffer. If the comparison indicates that the new pixel is in front of the pixel stored in the frame buffer, then the new pixel is written to the frame buffer and the z-buffer updated with new z-value. If not, no action is taken. Conceptually, the algorithm is a search over x, y for the largest value of z (x, y). This algorithm is frequently implemented for polygonally represented scenes and also applicable for any object for which depth and shading characteristics can be calculated. Scenes can contain mixed object types and may be of any complexity. 

It has basically two main disadvantages:

1. It requires large storage.

2. Difficulty and expense of implementing initializing transparency and translucency effects.


1. Set the frame buffer to the background intensity colour.

2. Set the z-buffer to the minimum z-value..

3. Scan converts each polygon in an arbitrary order.

4. For each pixel (x, y) in the polygon, calculate the depth z (x, y) at that pixel.

5. Compare the depth z (x, y) with the value stored in the 2-buffer at that location, z buffer (x, y) to determine the visibility.

6. If z(x, y) > z-buffer (x, y), then write the polygon attributes (intensity, colour, etc.) to the frame buffer at pixel location (x, y) and replace z-buffer (x, y) with z (x, y). Otherwise no action is taken.

7. Finally when all the polygons have been processed, the depth buffer contains depth value for the visible surfaces and the frame buffer contains the corresponding intensity values for those surfaces.

Related questions

Welcome to CPENTalk.com

Disclaimer: Every user is solely responsible for anything that he/she posts or uploads on CPENTalk.