---
title: "Compare Z-buffer, A-buffer; scan-line"
subject: "Computer Graphics"
chapter: 7
key: "semester_5/computer_graphics:compare-z-a-buffer-scan-line"
source: https://www.bctengineer.com/q/semester_5/computer_graphics/compare-z-a-buffer-scan-line
site: BCT Engineering
---

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

Computer Graphics · Chapter 7: Visible Surface Determination

- Asked in: 2072 Kartik, 10 marks
- Video: [LECTURE 13 :Z BUFFER ,A BUFFER,SCAN LINE ALGORITHM](https://www.youtube.com/watch?v=-vO2tIs--H4) — Vyas Kaushik
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/computer_graphics/compare-z-a-buffer-scan-line
- Whole chapter: https://www.bctengineer.com/md/semester_5/computer_graphics/chapter-7

## Question

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

## 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.

## Answer

#### Z-buffer vs A-buffer

| Point | Z-buffer | A-buffer |
|---|---|---|
| Surfaces kept per pixel | One (nearest) | Many (linked list) |
| Buffer fields | Depth value only (plus frame buffer) | Depth field and intensity/pointer field |
| Transparency | Not supported | Supported using opacity |
| Anti-aliasing | No | Yes, by area coverage (subpixel masks) |
| Memory | Less | More |
| Speed | Faster | Slower |
| Complexity | Simple | Complex |
| Application | Real-time rendering | High-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.

```text
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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How many surfaces per pixel do Z-buffer and A-buffer keep?
   A. Z: one; A: many
   B. Z: many; A: one
   C. Both one
   D. Both many
   Answer: A. The A-buffer uses a linked list. (Key point: Surfaces per pixel)

2. Compared with the Z-buffer, the A-buffer is:
   A. Faster and uses less memory
   B. Slower and uses more memory
   C. Faster but more memory
   D. Same speed, less memory
   Answer: B. Extra data per pixel and blending cost more. (Key point: Speed and memory)

3. In the scan-line algorithm, what is done at each edge crossing?
   A. Clear all flags
   B. Sort polygons by colour
   C. Toggle the in/out flag of the polygon owning the edge
   D. Reset the active edge list
   Answer: C. Flags tell which polygons cover each interval. (Key point: Scan-line flags)

4. If several polygons are in an interval, which colour is used?
   A. Polygon with the largest z
   B. Average colour
   C. First polygon in the table
   D. Polygon with the smallest z (nearest)
   Answer: D. Smallest depth is nearest to the viewer. (Key point: Smallest z)

## Related in Computer Graphics

- [Scan-line method of visible surface](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Ascan-line-visible-surface) — Computer Graphics, chapter 7, asked 3×
- [A-buffer method](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Aa-buffer-method) — Computer Graphics, chapter 7, asked 2×
- [Z-buffer method with limitation](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Az-buffer-with-limitation) — Computer Graphics, chapter 7, asked 3×
- [VSD factors, classes, Z/A-buffer](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Avisible-surface-factors-classes) — Computer Graphics, chapter 7
- [DDA versus Bresenham line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Adda-vs-bresenham-line) — Computer Graphics, chapter 2, asked 6×
- [Write Bresenham's line algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_graphics%3Abresenham-line-algorithm) — Computer Graphics, chapter 2, asked 3×
