Sampling-based Anti-Aliasing Techniques

Now armed with an understanding of aliasing artifacts, and all the types of aliasing that can occur when rendering a 3D scene, we can begin to investigate the anti-aliasing techniques which have been developed so far. These techniques can be broadly categorized into two distinct sets: those that try to reduce aliasing by increasing the sample count generated during rendering, and those that try to mitigate aliasing artifacts by analysing and post-processing generated images. The former category of sampling-based anti-aliasing techniques is somewhat more straight-forward, and therefore a good point to start.

Let's consider our initial triangle example on the 8×8 pixel grid again. The problem with the standard rendering was that we only sample at the centre of each pixel, which generates an ugly staircase pattern for edges that are not fully horizontal or vertical. On the other hand, calculating the exact coverage for each pixel is not feasible in real-time.

One intuitive step would be to simply increase the number of samples taken per pixel. Figure 5 illustrates this concept.

Figure 5:Triangle rasterised with 4 ordered samples per pixel

Again, pixel centres are marked by red dots. However, for each pixel, four separate locations are actually sampled – these are marked by cyan dots. If the triangle covers none of these samples, the pixel is black, and if it covers all of them it is white. Where it gets interesting is if only some of the samples are covered: if one out of four is covered, the pixel will turn 25% white and 75% black. For two out of four, the ratio is 50/50, and three covered samples will result in a lighter tone of 75% white.

This simple idea is the basis of all sampling-based anti-aliasing methods. One interesting aspect to note in this context is that, when the number of samples per pixel converges towards infinity, the result of this process will converge towards the "perfect" anti-aliased example shown earlier. Clearly, the quality of the result is highly dependent on the number of samples used – but so is performance. Common numbers of samples per pixel in use in games are 2 and 4, with 8 or more primarily of use on high-end PCs.

There are some important parameters in addition to the number of samples which can be varied to influence the quality of the results achieved using these sampling-based anti-aliasing methods, primarily sample positions, sample type and sample aggregation.