Scan Line Z-Buffer Algorithm

It is an extension of the method of scan converting a solid polygon and it can be treated as a special case of the z-buffer algorithm. The working principle of the algorithm can be summarized through the following steps:

1. For each scan line (y=constant) of the pixel grid

    a. Set the frame buffer to the background intensity.
    b. Set the z-buffer to zmin

2. For each polygon in the scene (Arbitrary order)

    a. Find the intersection, if any of the polygon’s 2D projections with the scan line.
    b. For each pixel (in left to right order) on the scan line between the intersection pairs compare its depth (z value) to the depth recorded in the z-buffer at that location.

Note: If the pixel depth is greater than that in the z-buffer then this line segment from the left intersection to the current pixel is currently visible. Hence the polygon attribute for this line segment is written to the frame buffer and the z-buffer is updated.