156 CHAPTER 5: Textures^
than a pixel, and that is called minification. Filtering is the process used to determine
how to correlate a pixel’s color with the underlying texel, or texels. Tables 5-3 and 5-4,
respectively, show the possible variants of this.
Table 5-3. Texture Filter Types in OpenGL ES for Minification
Name Purpose
GL_LINEAR Smooths texturing using the four nearest texels closest to the
center of the pixel being textured
GL_LINEAR_MIPMAP_LINEAR Similar to GL_LINEAR but uses the two nearest mipmaps closest
to the rendered pixel
GL_LINEAR_MIPMAP_NEAREST Similar to GL_LINEAR but uses the one nearest mipmap closest to
the rendered pixel
GL_NEAREST Returns the nearest texel value to the pixel being rendered
GL_NEAREST_MIPMAP_NEAREST Similar to GL_NEAREST but uses the texel from the nearest
mipmap
Table 5-4. Texture Filter Types in OpenGL ES for Magnification
Name Purpose
GL_LINEAR Smooths texturing using the four nearest texels closest to the center of the pixel
being textured
GL_NEAREST Returns the nearest texel value to the pixel being rendered
There are three main approaches to filtering:
Point sampling (called nearest in OpenGL lingo): A pixel’s color is
based on the texel that is nearest to the pixel’s center. This is the
simplest, is the fastest, and naturally yields the least satisfactory
image.
Bilinear sampling, otherwise called just linear: A pixel’s coloring is
based on a weighted average of a 2 ̄2 array of texels nearest to the
pixel’s center. This can smooth out an image considerably.
Trilinear sampling: Requires mipmaps and takes the two closest
mipmap levels to the final rendering on the screen, performs a bilinear
selection on each, and then takes a weighted average of the two
individual values.
It’s the trilinear sampling that you saw in action in the previous exercise, and it results in
a pretty dramatic increase in perceived image quality.
Figure 5-20a shows a close-up of Hedly with the filtering off, while Figure 5-20b has it
switched on. If you go back and look at the mipmap code, you’ll see that both images