Texture Filtering State

How your application sets texture filtering states depends largely on which version of the Direct3D device interface it uses. If your application uses the IDirect3DDevice3 interface, the render states discussed here are effectively superseded by the texture filtering options offered by the IDirect3DDevice3::SetTextureStageState method. For a conceptual overview and more information on using SetTextureStageState for texture filtering, see Texture Filtering.

Note  Although the render states discussed here are superseded by texture stage states, the IDirect3DDevice3::SetRenderState (as opposed to the IDirect3DDevice2 version) does not fail if you attempt to use them. Rather, the system maps the effects of these render states to the first stage in the multi-texture cascade, stage 0. Applications should not mix the legacy render states with their corresponding texture stage states, as unpredictable results can occur.

If your application is using the legacy IDirect3DDevice2 interface, you set texture filtering states through the IDirect3DDevice2::SetRenderState method. Direct3D supports nearest point sampling, bilinear filtering, anisotropic texture filtering, and mipmap filtering. The filtering method is selected using the D3DTEXTUREFILTER enumerated type.

When an application magnifies a texture, it can use Direct3D devices to select a texture filtering method by passing the D3DRENDERSTATE_TEXTUREMAG enumerated value as the first parameter to the IDirect3DDevice2::SetRenderState method. It must pass one of the enumerated values in the D3DTEXTUREFILTER enumerated type as the second parameter. To select the filtering method used when the texture is being made smaller, set the first parameter of the IDirect3DDevice2::SetRenderState method to D3DRENDERSTATE_TEXTUREMIN. Set the second parameter to one of the enumerated values in the D3DTEXTUREFILTER enumerated type. When applications use software-emulated devices, they should use the same filtering methods for both D3DRENDERSTATE_TEXTUREMAG and D3DRENDERSTATE_TEXTUREMIN. Performance degradation will occur if they are not the same. Direct3D hardware devices (HAL and MMX) do not have this performance limitation.

Anisotropic filtering is disabled when the D3DRENDERSTATE_TEXTUREMAG state is set to D3DFILTER_NEAREST. Anisotropic filtering is only enabled when the D3DRENDERSTATE_TEXTUREMAG state is set to D3DFILTER_LINEAR. For the filter controlled by the D3DRENDERSTATE_TEXTUREMIN enumerated value, anisotropy is enabled when its state is set to D3DFILTER_LINEAR, D3DFILTER_MIPLINEAR, or D3DFILTER_LINEARMIPLINEAR.

Applications that use anisotropic texture filtering should set the degree of filtering to a value that is appropriate for their use. Anisotropic filtering is disabled when it is set to 1, and enabled by setting it to a value greater than 1. See Anisotropic Texture Filtering. and D3DRENDERSTATE_ANISOTROPY.

When using mipmap filtering, your application can select either mipmap near-point sampling or linear mipmap filtering. Mipmap near-point sampling selects the mipmap texture that most closely approximates the resolution of the final output texture, then uses nearest point sampling to obtain the color information. Linear mipmap filtering selects a color from the two closest mipmaps, then linearly interpolates color data between them. See Texture Filtering With Mipmaps and D3DTEXTUREFILTER.

Applications can perform special filtering effects by controlling the mipmap level of detail (LOD) bias. A positive bias on a mipmap texture results in a sharper, but more aliased image. A negative bias causes a texture image to appear blurred. See D3DRENDERSTATE_MIPMAPLODBIAS.