If the memory requirements of the regular z buffer are too large, then we can use the scan line z buffer method. This method only needs a z buffer large enough for one scan line but requires more pre-processing.
Note that this table is similar to the edge list we created in scan converting a polygon. Where as before we had pointers to indicate the active edges for the polygon scan, now we have pointers (first, last) to indicate the active polygons . A polygon is included in the active list if(assuming decreasing Y values as we scan , i.e. scan from Ytop ® 0)
first checks Ymax to see if the polygon is in the current scan line (should be added to active list) last checks Ymin to see if the polygon has dropped off the active list
Then the z-buffer scan line algorithm:
/* We now have an even number of sorted x-intersections (2*n intersections: note n = 1 for a triangle) */
Look at analysis of storage requirements for the scan line z buffer algorithm
Assume 640 x 480 resolution) then z_buffer = 640 x 2 (16 bit) = 1280
For the polygon list: (assume triangles)
For each polygon store
3 vertices * 2 coordinates/vertex * 2 bytes/coordinate = 12 bytes
In polygon table store:
Ymax (2 bytes) + Ymin (2 bytes) + ABCD (16 bytes) + index to poly vertices (2 bytes) =
22 bytes/ polygon
So total of 34 bytes/polygon (36 if use linked list)
So for scan line version memory = 1280 + N * 36 Now regular Z-buffer for 640 x 480 x 2 = 614,000 bytes so scan line requires less memory up to about 17,000 polygons.