Alright, I have this code now:
Code:
material mat_ffp_multitex
{
event = mtl_terraintex_init;
skin1 = blendmap1; //Blendmap for texture 2
skin2 = blendmap2; //Blendmap for texture 3
effect
"
TEXTURE entSkin1;
TEXTURE entSkin2;
TEXTURE entSkin3;
TEXTURE mtlSkin1;
TEXTURE mtlSkin2;
matrix matMtl;
technique ffp_terrain_tex
{
pass P0
//////////////////////////////////////////////////////
//// Lets lay the first TEXTURE down. no alpha work
//// This will tile across the entire HMP
//////////////////////////////////////////////////////
{
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;
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
//// This TEXTURE will be blended
//////////////////////////////////////////////////////
{
//////////////////////////////////////
// Stage 0 - Setup the alphamap
//////////////////////////////////////
// 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
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 -- This is the TEXTURE to splat
//////////////////////////////////////////////
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;
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
{
////////////////////////////////////////
// Stage 0
////////////////////////////////////////
alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;
alphatestenable=true;
alpharef=0x00000000;
alphafunc=Greater;
TEXTURE[0] = <mtlSkin2>;
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;
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
} // End of Technique
";
}
three textures, they all blend perfectly. Now a last question: Is it possible to use dynamic lights on them? This is really important for the game.
The terrains reacts on fog but not dynamic light.