Skip to main content

Compare Z-buffer, A-buffer; scan-line

Short answer

Z-buffer stores one surface per pixel, lacks transparency and anti-aliasing, while A-buffer stores a linked list per pixel with opacity and area coverage for blending. The scan-line method processes each scan line, maintaining an active edge list and polygon in/out flags; when multiple polygons are active, depths are computed to fill with the nearest colour.

Compare Z-buffer and A-Buffer algorithm. Also write algorithm to find visible surfaces using scan-line method.

Z-buffer vs A-buffer

PointZ-bufferA-buffer
Surfaces kept per pixelOne (nearest)Many (linked list)
Buffer fieldsDepth value only (plus frame buffer)Depth field and intensity/pointer field
TransparencyNot supportedSupported using opacity
Anti-aliasingNoYes, by area coverage (subpixel masks)
MemoryLessMore
SpeedFasterSlower
ComplexitySimpleComplex
ApplicationReal-time renderingHigh-quality offline rendering

Scan-line algorithm to find visible surfaces

Data: edge table (end points, slope, polygon id), polygon table (plane coefficients A, B, C, D, colour, in/out flag), active edge list.

Initialise: build edge table and polygon table, set all flags to OUT.
for each scan line y from top to bottom:
    add edges that start at y to the active edge list;
    remove edges that end; update x of each edge (x = x - 1/m, since y decreases by 1);
    sort active edges by x;
    for each x-interval between consecutive edges:
        toggle (IN/OUT) the flag of the polygon owning the edge crossed
        count = number of polygons with flag IN in the interval
        if count == 0:
            fill interval with the background colour
        else if count == 1:
            fill interval with the colour of that polygon
        else:
            for each polygon IN, compute depth z = (-A*x - B*y - D)/C
            fill interval with the colour of the polygon of smallest z
    next scan line

Optimisation: if the polygons do not intersect, depth is computed only at the start of the interval, and scan-line coherence reuses the previous scan line's data.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 7 questions →