Effect Technique Syntax (Direct3D 11)

An effect technique is declared with the syntax described in this section.

TechniqueVersion TechniqueName [ <Annotations > ]

{

pass *PassName* \[ <*Annotations* > \] {
\[ *SetStateGroup*; \] \[ *SetStateGroup*; \] ... \[ *SetStateGroup*; \]
}

}

Parameters

Item Description
TechniqueVersion
Either technique10 or technique11. Techniques which use functionality new to Direct3D 11 (5_0 shaders, BindInterfaces, etc) must use technique11.
TechniqueName
Optional. An ASCII string that uniquely identifies the name of the effect technique.
<Annotations >
[in] Optional. One or more pieces of user-supplied information (metadata) that is ignored by the effect system. For syntax, see Annotation Syntax (Direct3D 11).
pass
Required keyword.
PassName
[in] Optional. An ASCII string that uniquely identifies the name of the pass.
SetStateGroup
[in] Set one or more state groups such as:
StateGroup Syntax
Blend State
SetBlendState( arguments ); 

See [ID3D11DeviceContext::OMSetBlendState](/windows/desktop/api/D3D11/nf-d3d11-id3d11devicecontext-omsetblendstate) for the argument list.

Depth-stencil State
SetDepthStencilState( arguments ); 

See ID3D11DeviceContext::OMSetDepthStencilState for the argument list.

Rasterizer State
SetRasterizerState( arguments ); 

See [ID3D11DeviceContext::RSSetState](/windows/desktop/api/D3D11/nf-d3d11-id3d11devicecontext-rssetstate) for the argument list.

Shader State
SetXXXShader( Shader );

SetXXXShader is one of SetVertexShader, SetDomainShader, SetHullShader, SetGeometryShader, SetPixelShader or SetComputeShader (which are similar to the API methods ID3D11DeviceContext::VSSetShader, ID3D11DeviceContext::DSSetShader, ID3D11DeviceContext::HSSetShader, ID3D11DeviceContext::GSSetShader, ID3D11DeviceContext::PSSetShader and ID3D11DeviceContext::CSSetShader).

Shader is a shader variable, which can be obtained in many ways:

SetXXXShader( CompileShader( shader_profile, ShaderFunction( args ) ) );
SetXXXShader( CompileShader( NULL ) );
SetXXXShader( NULL );
SetXXXShader( myShaderVar );
SetXXXShader( myShaderArray[2] );
SetXXXShader( myShaderArray[uIndex] );
SetGeometryShader( ConstructGSWithSO( Shader, strStream0 ) );
SetGeometryShader( ConstructGSWithSO( Shader, strStream0, strStream1, strStream2, strStream3, RastStream ) );
Render Target State One of:
SetRenderTargets( RTV0, DSV );
SetRenderTargets( RTV0, RTV1, DSV );
...
SetRenderTargets( RTV0, RTV1, RTV2, RTV3, RTV4, RTV5, RTV6, RTV7, DSV );

Similar to ID3D11DeviceContext::OMSetRenderTargets.

Examples

This example sets blending state.

BlendState NoBlend
{ 
    BlendEnable[0] = False;
};

...

technique10
{
    pass p2 
    {
        ...
        SetBlendState( NoBlend, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

This example sets up the rasterizer state to render an object in wireframe.

RasterizerState rsWireframe { FillMode = WireFrame; };

...

technique10
{
    pass p1 
    {
        ....
        SetRasterizerState( rsWireframe );
    }
}

This example sets shader state.

technique10 RenderSceneWithTexture1Light
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, RenderSceneVS( 1, true, true ) ) );
        SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, RenderScenePS( true ) ) );
    }
}

Effect Format

Effect Group Syntax (Direct3D 11)

Effect State Groups