Hi,
can someone of the shader-gurus change this multitexturing code to a dx9 compatible version ? I think the original is from stempie or ventilator ...
Code:
material mtl_multitexture
{
effect=
"
texture entSkin1;
texture entSkin2;
texture entSkin3;
texture entSkin4;
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
vector vecSunDir;
vector vecFog;
technique multitexture
{
pass p0
{
Texture[0]=<entSkin1>; // colormap1
Texture[1]=<entSkin3>; // colormap2
Texture[2]=<entSkin2>; // colormap3
Texture[3]=<entSkin4>; // macromap
magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;
magFilter[3]=linear;
minFilter[3]=linear;
mipFilter[3]=linear;
zWriteEnable=true;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[8]=<matWorldView>;
vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[20]=<vecFog>;
vertexShaderConstant[64]=(10.0f,10.0f,16.0f,16.0f);
vertexShaderConstant[65]=(8.0f,8.0f,0.0f,0.0f); // u_scale3,v_scale3
vertexShaderConstant[95]=(0.5f,1.0f,2.0f,0.0f);
vertexShader=
asm
{
vs_1_1
dcl_position v0
dcl_normal v3
dcl_texcoord0 v7
m4x4 oPos,v0,c0 // transform position to clip space
m3x3 r0,v3,c4 // transform normal to world space
dp3 r0.w,r0,r0 // renormalize it
rsq r0.w,r0.w
mul r0,r0,r0.w
dp3 oD0,r0,-c16 // normal.light -> lighting constant
mov r1.w,c20.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position
add r0,r0,-c20.x // distance-fog_start
mad r0.x,-r0.x,c20.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog.x,r0.x,c95.w // clamp with custom max value
mul oT0.xy,v7.xy,c64.xy // output scaled uvs - colormap1
mul oT1.xy,v7.xy,c64.zw // output scaled uvs - colormap2
mul oT2.xy,v7.xy,c65.xy // output scaled uvs - colormap3
mov oT3.xy,v7.xy // output uvs - macromap
};
pixelShader=
asm
{
ps.1.1
def c0,1,1,1,1
tex t0 // sample colormap1
tex t1 // sample colormap2
tex t2 // sample colormap3
tex t3 // sample macromap
mov r1,t1
lrp r0.rgb,t3.a,t0,r1 // blend t0 with t1 depending on t3 alpha
+mov r0.a,c0
mov r1.a,t3.b
lrp r0.rgb,r1.a,r0,t2 // blend the result with t2 depending on t3 blue
+mov r0.a,c0
mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting
};
}
}
technique fallback { pass p0 { } }
";
}