Game Engine Architecture by Jason Gregory

Game Engine Architecture by Jason Gregory

Author:Jason Gregory [Gregory, Jason]
Language: eng
Format: epub, pdf
Publisher: CRC Press
Published: 2014-08-14T21:00:00+00:00


506

10. The Rendering Engine

Figure 10.45. No antialiasing (left), 4× MSAA (center) and Nvidia’s FXAA, preset 3 (right). Image from Nvidia’s FXAA white paper by Timothy Lottes (http://bit.ly/1mIzCTv). (See Color Plate XVIII.) technique has unique performance, memory-usage and quality characteristics. Figure 10.45 shows a scene rendered first without antialiasing, then with

4× MLAA and finally with Nvidia’s FXAA technique.

10.2.7.1

Full-Screen Antialiasing (FSAA)

In this technique, also known as super-sampled antialiasing (SSAA), the scene is

rendered into a frame buffer that is larger than the actual screen. Once render-

ing of the frame is complete, the resulting oversized image is downsampled to

the desired resolution. In 4× supersampling, the rendered image is twice as

wide and twice as tall as the screen, resulting in a frame buffer that occupies

four times the memory. It also requires four times the GPU processing power

because the pixel shader must be run four times for each screen pixel. As you

can see, FSAA is an incredibly expensive technique both in terms of memory

consumption and GPU cycles. As such, it is rarely used in practice.

10.2.7.2

Multisampled Antialiasing (MSAA)

Multisampled antialiasing is a technique that provides visual quality com-

parable to that of FSAA, while consuming a great deal less GPU bandwidth

(and the same amount of video RAM). The MSAA approach is based on the

observation that, thanks to the natural antialiasing effect of texture mipmap-

10.2. The Rendering Pipeline

507

ping, aliasing tends to be a problem primarily at the edges of triangles, not in

their interiors.

To understand how MSAA works, recall that the process of rasterizing a

triangle really boils down to three distinct operations: (1) Determining which

pixels the triangle overlaps (coverage), (2) determining whether or not each

pixel is occluded by some other triangle (depth testing) and (3) determining

the color of each pixel, presuming that the coverage and depth tests tell us

that the pixel should in fact be drawn (pixel shading).

When rasterizing a triangle without antialiasing, the coverage test, depth

test and pixel shading operations are all run at a single idealized point within

each screen pixel, usually located at its center. In MSAA, the coverage and

depth tests are run for N points known as subsamples within each screen pixel.

N is typically chosen to be 2, 4, 5, 8 or 16. However, the pixel shader is only

run once per screen pixel, no matter how many subsamples we use. This gives

MSAA a big advantage over FSAA in terms of GPU bandwidth, because shad-

ing is typically a great deal more expensive than coverage and depth testing.

In N × MSAA, the depth, stencil and color buffers are each allocated to

be N times as large as they would otherwise be. For each screen pixel, these

buffers contain N “slots,” one slot for each subsample. When rasterizing a

triangle, the coverage and depth tests are run N times for the N subsamples

within each fragment of the triangle. If at least one of the N tests indicates

that the fragment should be drawn, the pixel shader is run once. The color

obtained from the pixel shader is then stored only into those slots that cor-

respond to the subsamples that fell inside the triangle. Once the entire



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.