Game Development Reference
In-Depth Information
// Get a description of the constant:
D3DXCONSTANT_DESC FirstTexDesc;
UINT count;
MultiTexCT->GetConstantDesc(FirstTexHandle, &FirstTexDesc, &count);
.
.
.
// Set texture/sampler states for the sampler FirstTex. We identify
// the stage FirstTex is associated with from the
// D3DXCONSTANT_DESC::RegisterIndex member:
Device->SetTexture(FirstTexDesc.RegisterIndex,
Tex);
Device->SetSamplerState(FirstTexDesc.RegisterIndex,
D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(FirstTexDesc.RegisterIndex,
D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
Device->SetSamplerState(FirstTexDesc.RegisterIndex,
D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
Note: Alternatively, instead of using the sampler type, you can use
the more specific and strongly typed sampler1D , sampler2D ,
sampler3D , and samplerCube types. These types are more type safe
and ensure that they are only used with the appropriate tex* func-
tions. For example, a sampler2D object can only be used with tex2D*
functions. Similarly, a sampler3D object can only be used with tex3D*
functions.
18.5 Sample Application:
Multitexturing in a Pixel Shader
The sample application for this chapter demonstrates multitexturing
using a pixel shader. The sample will texture a quad based on the
“result” in Figure 18.2 by blending together a crate texture, a spotlight
texture, and a texture that contains the string “Pixel Shader Sample.”
Figure 18.2: Combining
the textures. Let b , s , and t
be the colors of corre-
sponding texels from the
crate texture, spotlight tex-
ture, and text texture,
respectively. We define
how these colors are com-
bined as c = b
s + t ,
where
denotes compo-
nent-wise multiplication.
Search WWH ::




Custom Search