Filtering

Applying a texture involves sampling - for each pixel drawn on the screen, OpenGL must compute a value from the texture image data to use.

The pixels of the texture (texels) rarely match up exactly 1-to-1 with the pixels on the screen.

The different filtering modes select what to do when the texels are larger than screen pixels (magnification), or when the texels are smaller than screen pixels (minification).

Minification:
Magnification:

The filter options for magnification are:

The filter options for minification are:

For example:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                GL_LINEAR_MIPMAP_LINEAR);

Mipmapping

Mipmapping is a method that uses smaller versions of the texture image, to effectively pre-compute the average of many texels.

As a texture gets more and more minified, many texels will correspond to a single screen pixel, and using a GL_NEAREST or GL_LINEAR filter will not compute an accurate result. The texture will appear to flicker as the object moves.

A mipmapped texture avoids the flickering problem when minified. It often looks a bit fuzzier, however.

GL_LINEAR   GL_LINEAR_MIPMAP_LINEAR
   
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, xdim, ydim,
                  GL_RGBA, GL_UNSIGNED_BYTE, image);


next