Fragment Declaration Syntax
Microsoft DirectX 9.0 SDK Update (October 2004)

Fragment Declaration Syntax


Each high-level shader language (HLSL) function can be converted into a shader fragment with the addition of a fragment declaration.

Syntax

fragmentKeyword FragmentName = compile_fragment shaderProfile FunctionName();

where:

fragmentKeywordRequired keyword. Either pixelfragment or vertexfragment.
FragmentNameAn ASCII text string that specifies the compiled fragment name.
compile_fragmentRequired keyword.
shaderProfileThe shader model to compile against. Any valid vertex shader profile (see D3DXGetVertexShaderProfile) or pixel shader profile (see D3DXGetPixelShaderProfile).
FunctionName()The shader function name, followed by parentheses.

Shared fragment parameters are marked by adding an 'r_' prefix to their semantic. Here is an example of a vertex shader fragment declaration from the FragmentLinker Sample:

void AmbientDiffuse( float3 vPosWorld: r_PosWorld,
                     float3 vNormalWorld: r_NormalWorld,
                     out float4 vColor: COLOR0 )
{  
    // Compute the light vector
    float3 vLight = normalize( g_vLightPosition - vPosWorld );
    
    // Compute the ambient and diffuse components of illumination
    vColor = g_vLightColor * g_vMaterialAmbient;
    vColor += g_vLightColor * g_vMaterialDiffuse * saturate( dot( vLight, vNormalWorld ) );
}
vertexfragment AmbientDiffuseFragment = compile_fragment vs_1_1 AmbientDiffuse();

In this example, the r_PosWorld and r_NormalWorld semantics identify that these two parameters are shared parameters among other fragments.



© 2004 Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center.