?/TD> |
Microsoft DirectX 9.0 |
An effect file defines the techniques used. The basic layout of an effect file starts with one or more declarations and then defines each technique for that effect. This sample shows a basic effect file that contains two textures and two techniques.
This effect file allows a device that doesn't support single pass rendering for two textures to use multiple passes to render the textures.
// 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; } }