ZBuffer AlgorithmIt is also called a Depth Buffer Algorithm. Depth buffer algorithm is simplest image space algorithm. For each pixel on the display screen, we keep a record of the depth of an object within the pixel that lies closest to the observer. In addition to depth, we also record the intensity that should be displayed to show the object. Depth buffer is an extension of the frame buffer. Depth buffer algorithm requires 2 arrays, intensity and depth each of which is indexed by pixel coordinates (x, y). AlgorithmFor all pixels on the screen, set depth [x, y] to 1.0 and intensity [x, y] to a background value. For each polygon in the scene, find all pixels (x, y) that lie within the boundaries of a polygon when projected onto the screen. For each of these pixels: (a) Calculate the depth z of the polygon at (x, y) (b) If z < depth [x, y], this polygon is closer to the observer than others already recorded for this pixel. In this case, set depth [x, y] to z and intensity [x, y] to a value corresponding to polygon's shading. If instead z > depth [x, y], the polygon already recorded at (x, y) lies closer to the observer than does this new polygon, and no action is taken. 3. After all, polygons have been processed; the intensity array will contain the solution. 4. The depth buffer algorithm illustrates several features common to all hidden surface algorithms. 5. First, it requires a representation of all opaque surface in scene polygon in this case. 6. These polygons may be faces of polyhedral recorded in the model of scene or may simply represent thin opaque 'sheets' in the scene. 7. The IInd important feature of the algorithm is its use of a screen coordinate system. Before step 1, all polygons in the scene are transformed into a screen coordinate system using matrix multiplication. Limitations of Depth Buffer
Next TopicPainter Algorithm
