O'Reilly logo

GPU PRO 3 by Wolfgang Engel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3
V
Implementing a
Directionally Adaptive Edge
AA Filter Using DirectX 11
Matthew Johnson
3.1 Introduction
With the advent of DirectX 10 and beyond, more and more features are being
offloaded from fixed-function hardware to programmable shaders. Until recently,
the lack of flexible access to the sample information in antialiased (AA) buffers
required developers to rely on fixed-function hardware filtering to convert these
buffers 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-fit gradient line along the direction
of candidate primitive edges to construct a filter 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-
solve
1
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 filtering/interpolation. At primitive edges,
1
The process of taking a buffer with multiple samples per pixel and generating a buffer with
a single sample per pixel is defined as resolving the buffer.
275
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 filter.
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 filter resolve will calculate the final pixel color as
3 × red + 1 × blue
4
. (3.1)
Although the box filter is sufficient in many cases, it is not a panacea: the
box filter 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 filter can be constructed.
3.1.2 Directionally Adaptive Edge Multisampling
As demonstrated in Equation (3.1), a simple box filter 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-

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required