Hallo,
Vor einer Weile gab mir Oliver2S einen Multitexturing Shader. Er soll angeblich super laufen, bei mir gibt es jedoch ein Problem: Die Texturen werden zugleich als Alphamaps verwendet. Die eigentlichen Alphamaps nehmen keinen Einfluss auf den Shader.
(Die Texturen sind als externe Dateien gespeichert, die Blendmaps als Entity Skins 1-3, die 4.Skin ist eine Shadowmap)
Code:
BMAP detail1_bmp = "tex3.tga";
BMAP detail2_bmp = "tex4.tga";
BMAP detail3_bmp = "tex1.tga";
BMAP detail4_bmp = "tex2.tga";
FUNCTION mtl_terraintex_init()
{
mtl.matrix11 = float(27); // default u scale
mtl.matrix22 = float(27); // default v scale
bmap_to_mipmap(mtl.skin1);
bmap_to_mipmap(mtl.skin2);
bmap_to_mipmap(mtl.skin3);
bmap_to_mipmap(mtl.skin4);
}
MATERIAL mat_ffp_multitex
{
event = mtl_terraintex_init;
skin1 = detail1_bmp; //Textur 1
skin2 = detail2_bmp; //Textur 2
skin3 = detail3_bmp; //Textur 3
skin4 = detail4_bmp; //Textur 4
effect
"
TEXTURE entSkin1; //Blendmap1
TEXTURE entSkin2; //Blendmap1
TEXTURE entSkin3; //Blendmap1
TEXTURE entSkin4; //Shadowmap
TEXTURE mtlSkin1;
TEXTURE mtlSkin2;
TEXTURE mtlSkin3;
TEXTURE mtlSkin4;
matrix matMtl;
technique ffp_terrain_tex
{
pass P0
//////////////////////////////////////////////////////
//// Lets lay the first TEXTURE down. no alpha work
//// This will tile across the entire HMP
//////////////////////////////////////////////////////
{
LIGHTING = false;
CULLMODE = CCW;
alphablendenable=false;
alphatestenable=false;
zenable=true;
zwriteenable=true;
////////////////////////////////////////
// Stage 0
///////////////////////////////////////
TEXTURE[0] = <mtlSkin4>;
magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
zenable=true;
zwriteenable=true;
magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
TEXTURETransformFlags[0] = Count2;
TEXTURETransform[0] = <matMtl>;
texcoordindex[0]=1;
COLORARG1[0] = TEXTURE;
ColorOp[0] = MODULATE;
ALPHAARG1[0] = CURRENT | ALPHAREPLICATE;
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
LIGHTING = false;
CULLMODE = CCW;
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] = <entSkin1>;
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] = <mtlSkin1>;
// 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
////////////////////////////////////////////////////
//// A ditto of Pass p1 but with different a different
//// TEXTURE and alphamap
///////////////////////////////////////////////////
{
////////////////////////////////////////
// Stage 0
////////////////////////////////////////
LIGHTING = false;
CULLMODE = CCW;
alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;
alphatestenable=true;
alpharef=0x00000000;
alphafunc=Greater;
TEXTURE[0] = <entSkin2>;
magFilter[0]=linear;
minFilter[0]=linear;
mipFilter[0]=linear;
TEXTURETransformFlags[0] = disable;
texcoordindex[0]=0;
COLORARG1[0] = CURRENT;
ColorOp[0] = selectarg1;
ALPHAARG1[0] = TEXTURE | ALPHAREPLICATE;
alphaop[0]=selectarg1;
/////////////////////////////////////////
// Stage 1
/////////////////////////////////////////
TEXTURE[1] = <mtlSkin2>;
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;
} // End of Pass P2
pass P3
////////////////////////////////////////////////////
//// A ditto of Pass p1 but with different a different
//// TEXTURE and alphamap
///////////////////////////////////////////////////
{
////////////////////////////////////////
// Stage 0
////////////////////////////////////////
LIGHTING = false;
CULLMODE = CCW;
alphablendenable=true;
srcblend=srcalpha;
destblend=invsrcalpha;
alphatestenable=true;
alpharef=0x00000000;
alphafunc=Greater;
TEXTURE[0] = <entSkin3>;
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] = <mtlSkin3>;
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 P3
pass p4
{
LIGHTING = false;
CULLMODE = CCW;
alphablendenable=true;
srcblend=zero;
destblend=srccolor;
zenable=true;
zwriteenable=true;
ditherenable=true;
COLORARG1[0] = DIFFUSE;
ColorOp[0] = Modulate2x;
ColorArg2[0] = Current;
alphaop[0]=disable;
Texture[1] = <entSkin4>;
magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;
COLORARG1[1] = TEXTURE;
ColorOp[1] = Modulate2x;
TexCoordIndex[1]=0;
TextureTransformFlags[1]=Count2;
TextureTransform[1]=
{
1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,0.0,0.0,
0.0,0.0,0.0,0.0
};
}
} // End of Technique
";
}
An der Graka kanns doch nicht liegen, dass die falschen Texturen als Blendmaps verwendet werden?!
Bitte helft mir weiter,
zero