Shader Text - Multi-Techniques
Currently, there are a lot sort of graphic accelerators in consumer market. The different sort of accelerators have different graphic capabilities. So in a shader text file, can allow exist multiple techniques which can use different graphic capabilities; but only one active technique at one time. When the program load a shader text file, it'll try to search a valid technique from start for current graphic device, and activate the first valid technique. But you also can do your own configuration by the functions of material:
findValidTechnique()
setTechnique()
validateEffect()
While restore graphic device, the program will reload shader texts; so setup techniques in the OnRestoreDevice function of User Script File is a good practice.
Example:
texture tTX1;
texture tTX2;
technique T0
{
pass P0
{
// stage0
ColorOp[0] = SelectArg1;
ColorArg1[0] = Texture;
TexCoordIndex[0] = 0;
// stage1
ColorOp[1] = BumpEnvMap;
ColorArg1[1] = Texture;
ColorArg2[1] = Current;
Texture[1] = <tTX1>;
TexCoordIndex[1] = 0;
MipFilter[1]=Point;
// stage2
ColorOp[2] = Modulate;
Texture[2] = <tTX2>;
MipFilter[2]=None;
TexCoordIndex[2]=1;
}
}
// technique 2 for those devices which does not support
BumpEnvMap
technique T1
{
pass P0
{
// stage0
ColorOp[0] = SelectArg1;
ColorArg1[0] = Texture;
TexCoordIndex[0] = 0;
// stage1
ColorOp[1] = Modulate;
Texture[1] = <tTX2>;
MipFilter[1]=None;
}
}