Fragment Declaration Syntax (Direct3D 9 HLSL)

Each Microsoft 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:

Value Description
fragmentKeyword Required keyword. Either pixelfragment or vertexfragment.
FragmentName An ASCII text string that specifies the compiled fragment name.
compile_fragment Required keyword.
shaderProfile The 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.

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.

Note

Fragment linker was a Microsoft Direct3D 9 technology in D3DX 9. Fragment linker was a tool (Flink.exe), a D3DX 9 API, and an HLSL enhancement. Fragment linker was dropped as of the August 2009 DirectX SDK release. Fragment linker never applied to Microsoft Direct3D 10, Microsoft Direct3D 10.1, or Microsoft Direct3D 11.

 

Shader Model 3 (DirectX HLSL)