Game Development Reference
In-Depth Information
Example :
Device->SetTexture(0, _stonewall);
Note: In Direct3D, you can set up to eight textures that can be com-
bined to create a more detailed image. This is called multitexturing.
We do not use multitexturing in this topic until Part IV; therefore we
always set the textures stage to 0, for now.
To disable a texture at a particular texturing stage, set pTexture to 0.
For instance, if we don't want to render an object with a texture, we
would write:
Device->SetTexture(0, 0);
renderObjectWithoutTexture();
If our scene has triangles that use different textures, we would have to
do something similar to the following code:
Device->SetTexture(0, _tex0);
drawTrisUsingTex0();
Device->SetTexture(0, _tex1);
drawTrisUsingTex1();
6.3 Filters
As mentioned previously, textures are mapped to triangles in screen
space. Usually, the texture triangle is not the same size as the screen
triangle. When the texture triangle is smaller than the screen triangle,
the texture triangle is magnified to fit. When the texture triangle is
larger than the screen triangle, the texture triangle is minified to fit. In
both cases, distortion will occur. Filtering is a technique Direct3D uses
to help smooth out these distortions.
Direct3D provides three different types of filters; each one pro-
vides a different level of quality. The better the quality, the slower it is,
so you must make the trade-off between quality and speed. Texture fil-
ters are set with the IDirect3DDevice9::SetSamplerState
method.
Nearest point sampling —This is the default filtering method and
produces the worst-looking results, but it is also the fastest to com-
pute. The following code sets nearest point sampling as the
minification and magnification filter:
Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
Linear filtering —This type of filtering produces fairly good
results and can be done very fast on today's hardware. It is
Team-Fly ®
Search WWH ::




Custom Search