?/TD> |
Microsoft DirectX 9.0 |
This shader model supports texture lookup in the vertex shader using texldl. The vertex engine contains four texture sampler stages, named D3DVERTEXTEXTURESAMPLER, D3DVERTEXTEXTURESAMPLER+1, D3DVERTEXTEXTURESAMPLER+2, and D3DVERTEXTEXTURESAMPLER+3 (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 IDirect3D9::CheckDeviceFormat. Set textures at those stages using IDirect3DDevice9::SetTexture, with the stage index D3DVERTEXTEXTURESAMPLER through D3DVERTEXTEXTURESAMPLER+3. 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.
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.
In vs_3_0, if you use a sampler, it must be declared at the beginning of the shader program, using the dcl_textureType (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 the VertexTextureFilterCaps member of D3DCAPS9. 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 (D3DUSAGE_QUERY_VERTEXTEXTURE | D3DUSAGE_SOFTWAREPROCESSING) as usage. All formats are supported for software vertex processing. POOL_SCRATCH is required for software vertex processing.
// New define #define D3DVERTEXTEXTURESAMPLER0 (D3DDMAPSAMPLER+1) #define D3DVERTEXTEXTURESAMPLER1 (D3DDMAPSAMPLER+2) #define D3DVERTEXTEXTURESAMPLER2 (D3DDMAPSAMPLER+3) #define D3DVERTEXTEXTURESAMPLER3 (D3DDMAPSAMPLER+4) // New usage #define D3DUSAGE_QUERY_VERTEXTEXTURE (0x00100000L) // New caps field in D3DCAPS9 DWORD VertexTextureFilterCaps;