Game Engine Architecture

(Ben Green) #1

442 10. The Rendering Engine


ing, aliasing arises because we are using a discrete set of pixels to sample an
image that is really a smooth, continuous two-dimensional signal. (In the fre-
quency domain, sampling causes a signal to be shift ed and copied multiple
times along the frequency axis. Aliasing literally means that these copies of
the signal overlap and get confused with one another.)
Antialiasing is a technique that reduces the visual artifacts caused by alias-
ing. In eff ect, antialiasing causes the edges of the triangle to be blended with
the surrounding colors in the frame buff er.
There are a number of ways to antialias a 3D rendered image. In full-screen
antialiasing (FSAA), the image is rendered into a frame buff er that is twice
as wide and twice as tall as the actual screen. The resulting image is down-
sampled to the desired resolution aft erwards. FSAA can be expensive because
rendering a double-sized frame means fi lling four times the number of pixels.
FSAA frame buff ers also consume four times the memory of a regular frame
buff er.
Modern graphics hardware can antialias a rendered image without ac-
tually rendering a double-size image, via a technique called multisample an-
tialiasing (MSAA). The basic idea is to break a triangle down into more than
one fragment per pixel. These supersampled fragments are combined into a
single pixel at the end of the pipeline. MSAA does not require a double-width
frame buff er, and it can handle higher levels of supersampling as well. (4× and
8× supersampling are commonly supported by modern GPUs.)

10.1.4.8. Occlusion and the Depth Buffer
When rendering two triangles that overlap each other in screen space, we
need some way of ensuring that the triangle that is closer to the camera will
appear on top. We could accomplish this by always rendering our triangles in

Figure 10.37. The painter’s algorithm renders triangles in a back-to-front order to produce
proper triangle occlusion. However, the algorithm breaks down when triangles intersect one
another.
Free download pdf