Directionally Adaptive Edge
AA Filter Using DirectX 11
With the advent of DirectX 10 and beyond, more and more features are being
oﬄoaded from ﬁxed-function hardware to programmable shaders. Until recently,
the lack of ﬂexible access to the sample information in antialiased (AA) buﬀers
required developers to rely on ﬁxed-function hardware ﬁltering to convert these
buﬀers to single-sample representations. Now, with access to sample information,
developers seek even higher quality results with the same memory footprint. This
allows the creation of new techniques to balance the performance and quality of
the rendered images being generated.
This chapter describes a postprocessing AA technique, directionally adaptive
edge antialiasing, based on the paper by [Iourcha et al. 09]. In this technique, the
sample information is used to calculate a best-ﬁt gradient line along the direction
of candidate primitive edges to construct a ﬁlter that gives a better representation
of edge information in the scene.
3.1.1 Standard Multisampling
Unlike supersampling, multisampling occurs at pixel (not sample) frequency for
color samples, using the coverage information at discrete sample points to re-
to a single sample texture. In the center of a triangle where the scan
converter is rendering an interior pixel, there is no image quality advantage with
multisampling aside from the texture ﬁltering/interpolation. At primitive edges,
The process of taking a buﬀer with multiple samples per pixel and generating a buﬀer with
a single sample per pixel is deﬁned as resolving the buﬀer.
276 V 3D Engine Design
A 3 × 3 block of pixels. After rasterization. After rasterization.
MSAA disabled. 4x MSAA.
Figure 3.1. A 3 × 3 region of pixels.
however, the hardware has access to the neighboring samples as well as coverage
information. The standard resolve operation will blend the color value of every
sample in a pixel using a simple box ﬁlter.
The performance win in multisampling is not necessarily in memory (a mul-
tisampled surface at 4x MSAA can be four times the size), but in performance.
Ideally (unlike supersampling), there is no need to execute the pixel shader more
than once per pixel.
When multisampling is disabled, any pixel center inside a triangle is drawn.
This is shown in Figure 3.1. When multisampling is enabled, if one or more
samples are covered by the triangle, then the pixel shader is executed once and
the resultant color is replicated for all covered pixels. In Direct3D 10.1 and above,
a pixel shader can also run at sample rate; however, this feature is orthogonal to
adaptive edge AA.
As shown in Figure 3.1, the 4x MSAA sample pattern in the upper left pixel
shows three out of four samples that are covered (e.g., an edge pixel). A simple
box ﬁlter resolve will calculate the ﬁnal pixel color as
3 × red + 1 × blue
Although the box ﬁlter is suﬃcient in many cases, it is not a panacea: the
box ﬁlter resolve utilizes no information about neighboring samples to determine
an even closer estimate of the actual slope of the primitive edge being rendered.
With additional information, an even better antialiasing ﬁlter can be constructed.
3.1.2 Directionally Adaptive Edge Multisampling
As demonstrated in Equation (3.1), a simple box ﬁlter only averages the samples
available to it in each individual pixel. This limitation is especially noticeable
at steep edges or low-frequency data, in which the gradual changes in gradient
between adjacent pixels can be lost. In the example of one red and one blue tri-