Posted By: XNASorcerer
Problem with Steempipes' CubicEnvMap w alpha mask - 08/21/05 01:42

I am trying to use this shader with an alpha mask channel and this is what I am getting. The refletions areas are ok, but the parts where I donīt want to be refleted are wierd.
Here is the code with a few changes that I made (Trying to remove the Dot3 NOrmapMap parts):
Code:
//////////////////////////////////////////////////////////
// This effect will take a texture and bumpmap it.
// Then it will display the cubicenv map based
// on a mask that is in the A channel of skintex.
//
// By: Eric Hendrickson-Lambert (Steempipe)
bmap maskedenvmap_cube= <sk_free2_256+6.tga>; // CubicEnvMap
bmap maskedenvmap_skintex=<AuditTexture.tga>; // Colormap + mask in alpha
function MaskedEnvMap_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
}
function MaskedEnvMap_init()
{
bmap_to_cubemap(bmap_to_mipmap(mtl.skin1));
mtl.event=MaskedEnvMap_view;
mtl.enable_view=on;
}
material MaskedEnvMap
{
skin1=maskedenvmap_cube;
skin2=maskedenvmap_skintex;
//skin3=maskedenvmap_bumptex;
event=MaskedEnvMap_init;
effect=
"
texture mtlSkin2;
texture mtlSkin1;
//texture mtlSkin3;
matrix matMtl;
//dword mtlSkill4; // the light vector
vector vecAmbient; // Ambient Light Vector
technique envmap
{
pass p0
/////////////////////////////////////////////////
//This pass will do DOT3 Bumpmapping
{
Texture[0]=<mtlSkin1>; // The Normalmap
Texture[1]=<mtlSkin2>; // The Colormap + the mask in alpha
AlphaBlendEnable=False;
MagFilter[0]=linear;
MinFilter[0]=linear;
MipFilter[0]=linear;
MagFilter[1]=linear;
MinFilter[1]=linear;
MipFilter[1]=linear;
ColorArg1[0] = Texture; // stage 0 = DOT3 Normalmap
ColorOp[0] = AddSigned;
ColorArg2[0] = Current;
ColorArg1[1] = Texture; // stage 1 - Colormap
ColorOp[1] = AddSigned;
ColorArg2[1] = Current;
ColorOp[2]=disable;
AlphaOp[2]=disable;
}
pass p0
///////////////////////////////////////
// This pass will apply the Cubemap to a mask
//
{
Texture[0]=<mtlSkin2>; // The blendmap in Alpha
Texture[1]=<mtlSkin1>; // The cubemap
MagFilter[0]=linear;
MinFilter[0]=linear;
MipFilter[0]=linear;
MagFilter[1]=linear;
MinFilter[1]=linear;
MipFilter[1]=linear;
AlphaBlendEnable=True;
SrcBlend=SrcAlpha;
DestBlend=InvSrcAlpha;
Zenable=True;
ZwriteEnable=True;
TextureTransformFlags[0] = disable;
TexCoordIndex[0]=0;
ColorArg1[0] = current;
ColorOp[0] = selectarg1;
AddressU[1]=Clamp;
AddressV[1]=Clamp;
TexCoordIndex[1]=CameraSpaceReflectionVector;
TextureTransformFlags[1]=Count3;
TextureTransform[1]=<matMtl>;
colorArg1[1]=Texture;
textureFactor=0x40FFFFFF; // -> C0=75%, 80=50%, 40=25%
colorOp[1]=blendFactorAlpha;
}
}
";
}
action ffp_MaskedEnvMap
{
sun_angle.pan=80;
sun_angle.tilt=30;
my.material = MaskedEnvMap;
}

