From GameStudio Wiki
matrix matMtl;
texture mtlSkin1; // Blending map for Pass P1
texture mtlSkin2; // Blending map for Pass P2
texture mtlSkin3; // The Shadow map
texture entSkin1; // Tileable Tex (ie, Grass)
texture entSkin2; // Tileable Tex (ie, Sand)
texture entSkin3; // Tileable Tex (ie, Shale)
technique ffp_terrain_shadow{
pass P0{
// Lets lay the first texture down. no alpha work
AlphaBlendEnable = False;
AlphaTestEnable = False;
ZEnable = True;
ZWriteEnable = True;
// Stage 0
Texture[0] = <entSkin1>;
MagFilter[0] = Linear;
MinFilter[0] = Linear;
MipFilter[0] = Linear;
TextureTransformFlags[0] = Count2;
// Adjust The UV Tiling Scale here
TextureTransform[0] = <matMtl>;
texcoordindex[0] = 0;
ColorArg1[0] = Texture;
ColorOp[0] = selectarg1;
AlphaOp[0] = Disable;
//stage 1
ColorOp[1] = Disable;
AlphaOp[1] = Disable;
}
pass P1{
// Now we blend another texture using an alphamap
// Stage 0
// We need to enable alphablending
AlphaBlendEnable = True;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
// AlphaTestEnable uses the AlphaRef and AlphaFunc to
// determine which pixels get drawn.
// In this case, anything greater that 0 will be drawn.
AlphaTestEnable = True;
AlphaRef = 0x00000000; //Reference Value
AlphaFunc = Greater; //Comparison Function
ZEnable = False;
ZWriteEnable = False;
Texture[0] = <mtlSkin1>;
MagFilter[0] = Linear;
MinFilter[0] = Linear;
MipFilter[0] = Linear;
// We don't want the alphamap to tile
TextureTransformFlags[0] = Disable;
TexCoordIndex[0] = 0;
ColorArg1[0] = Current;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture | AlphaReplicate;
AlphaOp[0] = SelectArg1;
// Stage 1
Texture[1] = <entSkin2>;
// Zenable is supposed to default to true.
// This enables depth testing to determine what pixels
// are visible to the viewer
ZEnable = True;
ZWriteEnable = True;
MagFilter[1] = Linear;
MinFilter[1] = Linear;
MipFilter[1] = Linear;
TextureTransformFlags[1] = Count2;
// Adjust The UV Tiling Scale here
TextureTransform[1] = <matMtl>;
TexCoordIndex[1] = 1;
ColorArg1[1] = Texture;
ColorOp[1] = Modulate;
AlphaArg1[1] = Current | AlphaReplicate;
AlphaOp[1] = Disable;
// Stage 2
ColorOp[2] = Disable;
AlphaOp[2] = Disable;
}
pass P2{
// A ditto of Pass p1 but with different a different texture and alphamap
// Stage 0
AlphaBlendEnable = True;
SrcBlend = SrcAlpha;
DestBlend = InvSrcAlpha;
AlphaTestEnable = True;
AlphaRef = 0x00000000;
AlphaFunc = Greater;
Texture[0] = <mtlSkin2>;
ZEnable = True;
ZWriteEnable = True;
MagFilter[0] = Linear;
MinFilter[0] = Linear;
MipFilter[0] = Linear;
TextureTransformFlags[0] = Disable;
TexCoordIndex[0] = 1;
ColorArg1[0] = Current;
ColorOp[0] = SelectArg1;
AlphaArg1[0] = Texture | AlphaReplicate;
AlphaOp[0] = SelectArg1;
// Stage 1
Texture[1] = <entSkin3>;
ZEnable = True;
ZWriteEnable = True;
MagFilter[1] = Linear;
MinFilter[1] = Linear;
MipFilter[1] = Linear;
TextureTransformFlags[1] = Count2;
// Adjust The UV Tiling Scale here
TextureTransform[1] = matMtl>;
TexCoordIndex[1] = 0;
ColorArg1[1] = Texture;
ColorOp[1] = Modulate;
AlphaArg1[1] = Current | AlphaReplicate;
AlphaOp[1] = Disable;
// Stage 2
ColorOp[2] = Disable;
AlphaOp[2] = Disable;
} // End of Pass P2
Pass p3{
// Lets do some lighting and shadows
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = SrcColor;
ZEnable = True;
ZWriteEnable = True;
DitherEnable = True;
// Stage 0 - Lighting
ColorArg1[0] = Diffuse;
ColorOp[0] = Modulate2x;
ColorArg2[0] = Current;
AlphaOp[0]=Disable;
// Stage 1 - Lighting
Texture[1] = <mtlSkin3>;
MagFilter[1] = Linear;
MinFilter[1] = Linear;
MipFilter[1] = Linear;
ColorArg1[1] = Texture;
ColorOp[1] = Modulate2x;
TextureTransformFlags[1] = Disable;
TexCoordIndex[1] = 1;
} // End of Pass P3
} // End of Technique
technique fallback { pass p0 { } } // empty fallback causes normal rendering without effect