Game Development Reference
In-Depth Information
recommended that you use linear filtering as a minimum. The fol-
lowing code sets linear filtering as the minification and magnifica-
tion filter:
Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
Anisotropic filtering —This type of filtering produces the best
results but also takes the longest to compute. The following code
sets anisotropic filtering as the minification and magnification filter:
Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_
ANISOTROPIC);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_
ANISOTROPIC);
When using anisotropic filtering, we must also set the D3DSAMP_
MAXANISOTROPY level, which determines the quality of the anisotropic
filtering. The higher this value, the better the results. Check the
D3DCAPS9 structure for the valid range that your device supports. The
following code sets this value to 4:
Device->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 4);
6.4 Mipmaps
As said in section 6.3, the triangle on the screen is usually not the same
size as the texture triangle. In an effort to make the size difference less
drastic, we can create a chain of mipmaps for a texture. The idea is to
take a texture and create a series of smaller lower resolution textures
but customize the filtering for each of these levels so it preserves the
detail that is important for us (see Figure 6.4).
Figure 6.4: A chain of mipmaps; notice that each successive mipmap is
half the size of the previous mipmap.
Search WWH ::




Custom Search