Game Development Reference
In-Depth Information
technique T1
{
// first pass
pass P0
{
...[specify pass device states, shaders, samplers, etc.]
}
// second pass
pass P1
{
...[specify pass device states, shaders, samplers, etc.]
}
}
19.2
More HLSL Intrinsic Objects
There are some additional built-in object types in HLSL. We didn't
cover them earlier because they're used primarily in the effects
framework.
19.2.1
Texture Objects
The HLSL intrinsic
texture
type represents an
IDirect3DTex-
ture9
object. By using
texture
objects we can associate the texture
for a particular sampler stage directly in the effect file.
Texture
objects have the following data members that can be accessed:
type
—The type of texture (e.g., 2D, 3D)
format
—The pixel format of the texture
width
—The width of the texture in pixels
height
—The height of the texture in pixels
depth
—The depth (if a 3D volume texture) of the texture in pixels
Aside:
So far we have only used textures to store image data, but
as you get into more advanced techniques, you will find that textures
are used to hold arbitrary table info. In other words, textures are just
tables of data; they don't have to contain image data necessarily. For
example, in bump mapping we use what is called a
normal map
,
which is a texture that contains normal vectors at each entry.
19.2.2
Sampler Objects and Sampler States
We discussed the
sampler
object in Chapter 18; however, the effects
framework exposes the new
sampler_state
keyword. Using the
sampler_state
keyword, we can initialize a
sampler
object (that is,
set the texture and sampler states for that sampler object directly
within an effect file). The following example illustrates this:
Search WWH ::
Custom Search