07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Texture filtering 213<br />

Filtering methods<br />

This section lists the most common texture filtering methods, in increasing order of computational cost and image<br />

quality.<br />

Nearest-neighbor interpolation<br />

Nearest-neighbor interpolation is the fastest and crudest filtering method — it simply uses the color of the texel<br />

closest to the pixel center for the pixel color. While fast, this results in a large number of artifacts - texture<br />

'blockiness' during magnification, and aliasing and shimmering during minification.<br />

Nearest-neighbor with mipmapping<br />

This method still uses nearest neighbor interpolation, but adds mipmapping — first the nearest mipmap level is<br />

chosen according to distance, then the nearest texel center is sampled to get the pixel color. This reduces the aliasing<br />

and shimmering significantly, but does not help with blockiness.<br />

Bilinear filtering<br />

Bilinear filtering is the next step up. In this method the four nearest texels to the pixel center are sampled (at the<br />

closest mipmap level), and their colors are combined by weighted average according to distance. This removes the<br />

'blockiness' seen during magnification, as there is now a smooth gradient of color change from one texel to the next,<br />

instead of an abrupt jump as the pixel center crosses the texel boundary. Bilinear filtering is almost invariably used<br />

with mipmapping; though it can be used without, it would suffer the same aliasing and shimmering problems as its<br />

nearest neighbor.<br />

Trilinear filtering<br />

Trilinear filtering is a remedy to a common artifact seen in mipmapped bilinearly filtered images: an abrupt and very<br />

noticeable change in quality at boundaries where the renderer switches from one mipmap level to the next. Trilinear<br />

filtering solves this by doing a texture lookup and bilinear filtering on the two closest mipmap levels (one higher and<br />

one lower quality), and then linearly interpolating the results. This results in a smooth degradation of texture quality<br />

as distance from the viewer increases, rather than a series of sudden drops. Of course, closer than Level 0 there is<br />

only one mipmap level available, and the algorithm reverts to bilinear filtering.<br />

Anisotropic filtering<br />

Anisotropic filtering is the highest quality filtering available in current consumer <strong>3D</strong> <strong>graphics</strong> cards. Simpler,<br />

"isotropic" techniques use only square mipmaps which are then interpolated using bi– or trilinear filtering. (Isotropic<br />

means same in all directions, and hence is used to describe a system in which all the maps are squares rather than<br />

rectangles or other quadrilaterals.)<br />

When a surface is at a high angle relative to the camera, the fill area for a texture will not be approximately square.<br />

Consider the common case of a floor in a game: the fill area is far wider than it is tall. In this case, none of the square<br />

maps are a good fit. The result is blurriness and/or shimmering, depending on how the fit is chosen. Anisotropic<br />

filtering corrects this by sampling the texture as a non-square shape. Some implementations simply use rectangles<br />

instead of squares, which are a much better fit than the original square and offer a good approximation.<br />

However, going back to the example of the floor, the fill area is not just compressed vertically, there are also more<br />

pixels across the near edge than the far edge. Consequently, more advanced implementations will use trapezoidal<br />

maps for an even better approximation (at the expense of greater processing).<br />

In either rectangular or trapezoidal implementations, the filtering produces a map, which is then bi– or trilinearly<br />

filtered, using the same filtering algorithms used to filter the square maps of traditional mipmapping.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!