The vertex shader 3.0 model supports texture lookup in the vertex shader using the texldl - vs texture load statement. The vertex engine contains four texture sampler stages, named D3DVERTEXTEXTURESAMPLER0, D3DVERTEXTEXTURESAMPLER1, D3DVERTEXTEXTURESAMPLER2, and D3DVERTEXTEXTURESAMPLER3. These are distinct from the displacement map sampler and texture samplers in the pixel engine.
To sample textures set at those four stages, you can use the vertex engine and program the stages with the IDirect3D9::CheckDeviceFormat method. Set textures at those stages using IDirect3DDevice9::SetTexture, with the stage index D3DVERTEXTEXTURESAMPLER0 through D3DVERTEXTEXTURESAMPLER3. A new register has been introduced in the vertex shader, the sampler register (like in ps_2_0), which represents the vertex texture sampler. This register needs to be defined in the shader before using it.
An application can query if a format is supported as a vertex texture by calling IDirect3D9::CheckDeviceFormat with D3DUSAGE_QUERY_VERTEXTEXTURE.
Note This is a query flag so it is not accepted in any Createxxx function. A vertex texture created in the default pool can be set as a pixel texture and vice versa. However, to use the software vertex processing, the vertex texture must be created in the scratch pool (no matter if it is a mixed-mode device or a software vertex processing device).
The functionality is identical to the pixel textures, except for the following:
Restrictions include:
A sampling stage register identifies a sampling unit that can be used in texture load statements. A sampling unit corresponds to the texture sampling stage, encapsulating the sampling-specific state provided in IDirect3DDevice9::SetSamplerState.
Each sampler uniquely identifies a single texture surface that is set to the corresponding sampler using IDirect3DDevice9::SetTexture. However, the same texture surface can be set at multiple samplers.
At draw time, a texture cannot be simultaneously set as a render target and a texture at a stage.
Because vs_3_0 supports four samplers, up to four texture surfaces can be read from in a single shader pass. A sampler register might appear only as an argument in the texture load statement: texldl - vs.
In vs_3_0, if you use a sampler, it must be declared at the beginning of the shader program, using the dcl_samplerType - vs (as in ps_2_0).
This feature will be supported in software vertex processing. The specific filter types supported can be checked by calling IDirect3DDevice9::GetDeviceCaps and checking VertexTextureFilterCaps. All published texture formats will be supported as vertex textures in software vertex processing.
Applications can check if a particular texture format is supported in the software vertex processing mode by calling IDirect3D9::CheckDeviceFormat and providing (D3DVERTEXTEXTURESAMPLER | D3DUSAGE_SOFTWAREPROCESSING) as usage. All formats are supported for software vertex processing. The scratch pool is required for software vertex processing.
// New define #define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1) #define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2) #define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3) #define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4) #define D3DVERTEXTEXTURESAMPLER (0x00100000L) // New caps field in D3DCAPS9 DWORD VertexTextureFilterCaps;