In order to render a scene, we proceed in several steps:
As we noted last lecture, the Z-buffer suffers from aliasing problems at boundaries. It is particularly prone to bad jagging at seams where one polygon penetrates another.
The A-Buffer method makes use of a sub-pixel bitmask to do approximate anti-aliasing. It is a scan-line algorithm.
First, sort the polygons by the y-coordinates of vertices. From this data, for any y value, you can get a list of all the polygons that intersect that y=const scan-line. Those polygons are called active.
For a given scan-line, sort the active polygons by minimum and maximum x-coordinate. As you step from pixel to pixel by increasing x, you add a polygon when you hit its minimum x-value, and remove it when you hit its maximum x-value. In this way, you have for each pixel, a list of the polygons that contain that pixel. Within the list, the polygons should be ordered by Z-coordinate.
Then for each point along the scan-line, we determine:
If the pixel is outside the closest polygon, try the next-closest polygon etc.
When the pixel is partly inside a polygon, clip that polygon using the pixel's square boundary. Use the clipped polygon to fill in a bitmap approximation to the pixel.
Recursively check the polygons behind, and fill in the other bits in the bitmap as needed.
The number of bits set in the bitmap for each polygon determines the relative weight of the color of that polygon that is used to determine the pixel color.
Because the A-buffer computes pixel colors by blending colors of the polygons that contain the pixel, it is easy to add transparency. For a transparent surface, there is a transparency factor T < 1 such that the color of a pixel is (1-T) times the color of the top surface plus T times the color of the surface(s) below.