Texture Filtering

When Direct3D renders a primitive, it maps the 3-D primitive onto a 2-D screen. If the primitive has a texture, Direct3D must use that texture to produce a color for each pixel in the primitive's 2-D rendered image. For every pixel in the primitive's on-screen image, it must obtain a color value from the texture. This process is called texture filtering.

When a texture filter operation is performed, the texture being used is typically also being magnified or minified. In other words, it is being mapped onto a primitive image that is larger or smaller than itself. Magnification of a texture can result in many pixels being mapped to one texel. The result can be a chunky appearance. Minification of a texture often means that a single pixel is mapped to many texels. The resulting image can be blurry or aliased. To resolve these problems, some blending of the texel colors must be performed to arrive at a color for the pixel.

Direct3D simplifies the complex process of texture filtering. It provides developers with three types of texture filtering—linear filtering, anisotropic filtering, and mipmap filtering. If you select no texture filtering, Direct3D utilizes a technique called nearest point sampling.

Each type of texture filtering has advantages and disadvantages. For instance, linear texture filtering can produce jagged edges or a chunky appearance in the final image. However, it is a computationally low-overhead method of texture filtering. On the other hand, filtering with mipmaps usually produces the best results, especially when combined with anisotropic filtering. However it requires the most memory of the techniques that Direct3D supports.

If your application uses texture handles, it should set the current texture filtering method by invoking the IDirect3DDevice3::SetRenderState method. The first parameter must be either D3DRENDERSTATE_TEXTUREMAG or D3DRENDERSTATE_TEXTUREMIN. It must pass a member of the D3DTEXTUREFILTER enumerated type as the value of the second parameter. See Texture Filtering State.

Applications that use texture interface pointers should set the current texture filtering method by calling the IDirect3DDevice3::SetTextureStageState method. Set the value of the first parameter to the integer index number (0-7) of the texture for which you are selecting a texture filtering method. Pass either D3DTSS_MAGFILTER, D3DTSS_MINFILTER, or D3DTSS_MIPFILTER as the value of the second parameter. Set the third parameter to a member of the D3DTEXTUREMAGFILTER, D3DTEXTUREMINFILTER, or D3DTEXTUREMIPFILTER enumerated types respectively.

This section presents the texture filtering methods that Direct3D supports. It is organized into the following topics: