Shader Type
The syntax for declaring a shader variable in an effect changed from Direct3D 9 to Direct3D 10.
Shader Type for Direct3D 10
Declare a shader variable within an effect pass (in Direct3D 10) using the shader type syntax:
SetPixelShader Compile( ShaderTarget, ShaderFunction ); SetGeometryShader Compile( ShaderTarget, ShaderFunction ); SetVertexShader Compile( ShaderTarget, ShaderFunction ); |
Parameters
Item | Description |
---|---|
SetXXXShader |
The Direct3D API call that creates the shader object. Can be either: SetPixelShader or SetGeometryShader or SetVertexShader. |
ShaderTarget |
The shader model to compile against. This is valid for any target including all Direct3D 9 targets plus the shader model 4 targets: vs_4_0, gs_4_0, and ps_4_0. |
ShaderFunction |
An ASCII string that contains the name of the shader entry point function; this is the function that begins execution when the shader is invoked. The (...) represents the shader arguments; these are the same arguments passed to the shader creation API's: VSSetShader or GSSetShader or PSSetShader. |
Example
Here is an example that creates a vertex shader and pixel shader object, compiled for a particular shader model. In the Direct3D 10 example, there is no geometry shader, so the pointer is set to NULL.
// Direct3D 10
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
}
}
Shader Type for Direct3D 9
Declare a shader variable within an effect pass (for Direct3D 9) using the shader type syntax:
PixelShader = compile ShaderTarget ShaderFunction(...);VertexShader = compile ShaderTarget ShaderFunction(...); |
Parameters
Item | Description |
---|---|
XXXShader |
A shader variable, which represents the compiled shader. Can be either: PixelShader or VertexShader. |
ShaderTarget |
The shader model to compile against; depends on the type of shader variable. |
ShaderFunction(...) |
An ASCII string that contains the name of the shader entry point function; this is the function that begins execution when the shader is invoked. The (...) represents the shader arguments; these are the same arguments passed to the shader creation API's: SetVertexShader or SetPixelShader. |
Example
Here is an example of a vertex shader and pixel shader object, compiled for a particular shader model.
// Direct3D 9
technique RenderSceneWithTexture1Light
{
pass P0
{
VertexShader = compile vs_2_0 RenderSceneVS( 1, true, true );
PixelShader = compile ps_2_0 RenderScenePS( true );
}
}