Microsoft DirectX 8.0 (C++)

Effect File Components

An effect file defines the techniques that will be used. The basic layout of an effect file starts with one or more declarations and then defines each technique for that effect. The sample below shows a basic effect file that contains two textures and two techniques.

The effect file starts by declaring two textures that will be used for the effect.

texture tex0; //First texture
texture tex1; //Second texture

The first technique uses one pass to render the scene.

technique t0
{
    pass p0
    {
        Texture[0] = <tex0>;
        Texture[1] = <tex1>;
        
        ColorOp[0] = SelectArg1;
        ColorArg1[0] = Texture;
        
        ColorOp[1] = Add;
        ColorArg1[0] = Texture;
        ColorArg2[0] = Current;
        
        ColorOp[2] = Disable;
    }
}

The second technique uses multiple passes to render the scene. This technique would be used if the current device did not support single-pass rendering for multiple textures.

technique t1
{
    pass p0
    {
        Texture[0] = <tex0>;
        
        ColorOp[0] = SelectArg1;
        ColorArg1[0] = Texture;
        ColorOp[1] = Disable;  
    }
    
    pass p1
    {
        AlphaBlendEnable = True;
        SrcBlend = One;
        DestBlend = One;

        Texture[0] = <tex1>;
               
        ColorOp[0] = SelectArg1;
        ColorArg1[0] = Texture;
        ColorOp[1] = Disable;  
    }
}

This effect file enables a device that doesn't support single-pass rendering for two textures to use multiple passes to render the textures. For more information on the layout of an effect file, see Effect File Format.