Sample Positions

How samples are positioned within a pixel has a large impact on the final result, particularly with a small number of samples such as 2 or 4, which is the most common case in real-time graphics. In the previous example, the samples are positioned just as if they were the centres of a rendered image of four times the original size (16×16 pixels). This is intuitive, and very easy to achieve by simply rendering a larger image. This method is known as ordered grid anti-aliasing (OGAA), and also sometimes referred to as downsampling, particularly if it is achieved by forcing a higher rendering resolution than the native resolution of the output monitor.

However, an ordered grid is often suboptimal, particularly for near-vertical or near-horizontal lines, which are also the ones where aliasing artifacts are often most obvious. Figure 6 illustrates why this happens, and how a rotated or sparse sampling grid achieves a much better result:

For this near-vertical case, the ideal result with four samples should have 5 different shades of grey: black for no samples covered, 25% white for one sample, 50% for two and so on. However, rasterizing with an ordered grid only yields 3 shades: black, white and 50/50. This happens because the ordered samples are all in 2 columns each, and thus if one gets covered by the near-vertical primitive, the other is also very likely to be covered.

As the sparse sampling picture shows, this problem can be circumvented by repositioning the samples within each pixel. Ideal sample positions for anti-aliasing are sparse, which means that for N samples, no two samples share a single column, row or diagonal in an NxN grid. These patterns correspond to the solutions of the N-Queens problem. Anti-aliasing methods which use such grids are said to perform sparse grid anti-aliasing (SGAA).