Texture Filtering

After the mapping is computed and the texture is warped, the image must be resampled on the screen grid. This process is called filtering. The cheapest texture filtering method is point sampling, wherein the pixel nearest the desired sample point is used. It works relatively well on unscaled images, but for stretched images the texture pixels are visible as large blocks, and for shrunken images aliasing can cause distracting moire patterns (moire pattern applet).

Two filtering operations are necessary in texture mapping;

  1. Magnification; the pixel is smaller than the corresponding texel
  2. Minification; the pixel is larger than corresponding texel

Point Sampling

Find nearest texel to the sample point to colour pixel. Show's texel as large blocks when close-up, suffers from moire patterns for repeating patterns.

 

Bilinear Filtering

Find a weight average of 4 texel's around sample point. The weightings depend on sample points distance from the center of each texel.

Bilinear filtering is rather accurate until the scaling of the texture gets below half or above double the original size of the texture - that is, if the texture was 256 pixels in each direction, scaling it to below 128 or above 512 pixels can make the texture look bad, because of missing pixels or too much smoothness.

Bilinear filtering in available on all modern graphics cards, so is free.

Mipmapping (Multim Im Parvo [MIP], "Much in little space")

To overcome the scaling problems of Bilinear filtering. Mipmaps were introduced to provide alternate textures at smaller scales. These textures can be computed off-line using expensive antialiasing algorithms.

Mipmaps are optimized collections of bitmap images that accompany a main texture, intended to increase rendering speed and reduce artifacts. Normally each mipmap is a sequence of texture images, each image, half the size of the last. In this format, the mipmap images occupy 1/3 of the original texture (three textures and their mipmaps can be stored in the same area as 4 textures).

Image storing mipmaps for 3 textures

A rendering system will normally choose the mipmap where the pixel size is closed to the texel size. But this may cause an abrupt seam where there is a change from one mipmap to another.

Trilinear Filtering

Trilinear filtering attempts to solve the problems of bilinear filtering by performing bilinear filtering on the two closest mipmaps. [the two closest mipmaps are those, whose texel size is most similar to the pixel size].

Trilinear filtering then interpolates between these two values depending on the relative distance of the mipmaps.

 

Read this wikipedia article for more details

 

Anisotropic filtering

Like bilinear and trilinear filtering Anisotropic filtering eliminates aliasing effects, but introduces less blur in the process and thus preserves more detail. Anisotropic filtering is computationally relatively expensive and has only recently become a standard feature of consumer-level graphics cards.

When the texture is sampled, several samples of the texture around the center point are taken, but on a sample grid skewed according to view perspective.

This makes anisotropic filtering extremely bandwidth intensive. Each sample is four bytes (32 bits) so each anisotropic pixel has required 64 bytes (for 16 sample) from texture memory. A display can easily contain over a million pixels, so the hit on texture memory can get very high (tens to hundreds of gigabytes per second) very quickly.

Comparison between tri-linear, 4 point anisotropic and 16 point anisotropic filtering
(image borrowed from http://mirror.garry.tv/img/cssource/texture-filtering.jpg)