Share via


複数のテクニック

複数のテクニック

エフェクト ファイルは、使用するテクニックを定義する。エフェクト ファイルの定義は、基本的には 1 つまたは複数の宣言で始まり、その後にエフェクトの各テクニックの定義を続ける。このサンプルは、2 つのテクスチャおよび 2 つのテクニックを定義するエフェクト ファイルである。

このエフェクト ファイルにより、デバイスが 2 つのテクスチャに対するシングルパス レンダリングをサポートしていない場合には、複数のパスを使ってテクスチャをレンダリングできる。

// Declare two textures.
texture tex0;        // First texture
texture tex1;        // Second texture

// Technique 't0' will render the scene in one pass.The color 
//   for each pixel is calculated to be tex0 + tex1.  Because it uses 
//   two textures at once, it will work only on cards that support 
//   multitexture.

technique t0
{
    pass p0
    {
        Texture[0] = (tex0);
        ColorOp[0] = SelectArg1;
        ColorArg1[0] = Texture;

        Texture[1] = (tex1);
        ColorOp[1] = Add;
        ColorArg1[1] = Texture;
        ColorArg2[1] = Current;

        ColorOp[2] = Disable;
    }
}

// Technique 't1' renders the scene in two passes.  The first pass sets 
//   each pixel to the color of tex0.  The second pass adds in the color 
//   of tex1.  The result should end up looking identical to the first 
//   technique.  However, this technique can be used on cards that do not 
//   support multitexture.

technique t1
{
    pass p0
    {
        AlphaBlendEnable = False;

        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;
        ColorArg[0] = Texture;
        ColorOp[1] = Disable;
    }
}