Posted By: sarahlover_247
Need Help with Terrain Multitexturing Shader - 03/11/05 07:10
I am using the Shader from the Wiki, and I get this message:
Error in effect:
mat_terrain_multitexture(2) : syntax error
Heres the code I am using:
In the main wdl:
path "D:\\Miscellaneous\\3D Gamestudio Stuff\\work";
include <multitexture.wdl>;
action terrain
{
my.skill41=float(10);
my.skill42=float(20);
my.skill43=float(5);
my.skill44=float(10);
my.flare=off;
my.transparent=off;
my.material=mat_terrain_multitexture;
}
in the multitexture.wdl:
material mat_terrain_multitexture
{
effect=
"
texture entSkin1.tga;
texture entSkin2.tga;
texture entSkin3.tga;
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
vector vecSunDir;
vector vecDiffuse;
vector vecAmbient;
vector vecLight;
vector vecFog;
vector vecSkill41;
technique multitexture
{
pass p
{
texture[0]=<entSkin1.tga>; // colormap1
texture[1]=<entSkin2.tga>; // colormap2
texture[2]=<entSkin3.tga>; // macromap
magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;
zWriteEnable=true;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[8]=<matWorldView>;
vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[17]=<vecDiffuse>;
vertexShaderConstant[18]=<vecAmbient>;
vertexShaderConstant[19]=<vecLight>;
vertexShaderConstant[20]=<vecFog>;
vertexShaderConstant[64]=<vecSkill41>; // u_scale1,v_scale1,u_scale2,v_scale2
vertexShaderConstant[95]=(0.0f,0.0f,0.0f,0.0f);
vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //uv
}
asm
{
vs.1.1
m4x4 oPos,v0,c0 // transform position to clip space
mul oT0.xy,v7.xy,c64.xy // output scaled uvs - colormap1
mul oT1.xy,v7.xy,c64.zw // output scaled uvs - colormap2
mov oT2.xy,v7.xy // output uvs - macromap
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 r0,r0,-c16 // normal.light -> lighting constant
mul r0.xyz,r0,c17 // modulate against material diffuse color
add oD0.xyz,r0,c19 // add environment light
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
};
pixelShader=
asm
{
ps.1.3
def c0,0,0,0,1
tex t0 // sample colormap1
tex t1 // sample colormap2
tex t2 // sample macromap
lrp r0.rgb,t2.a,t0,t1 // blend t0 with t1 using the alpha channel of t2
+mov r0.a,c0
//add r0.rgb,r0,t2_bias // add(signed) rgb of t2
mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting
};
}
}
";
}
Error in effect:
mat_terrain_multitexture(2) : syntax error
Heres the code I am using:
In the main wdl:
path "D:\\Miscellaneous\\3D Gamestudio Stuff\\work";
include <multitexture.wdl>;
action terrain
{
my.skill41=float(10);
my.skill42=float(20);
my.skill43=float(5);
my.skill44=float(10);
my.flare=off;
my.transparent=off;
my.material=mat_terrain_multitexture;
}
in the multitexture.wdl:
material mat_terrain_multitexture
{
effect=
"
texture entSkin1.tga;
texture entSkin2.tga;
texture entSkin3.tga;
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
vector vecSunDir;
vector vecDiffuse;
vector vecAmbient;
vector vecLight;
vector vecFog;
vector vecSkill41;
technique multitexture
{
pass p
{
texture[0]=<entSkin1.tga>; // colormap1
texture[1]=<entSkin2.tga>; // colormap2
texture[2]=<entSkin3.tga>; // macromap
magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;
zWriteEnable=true;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[8]=<matWorldView>;
vertexShaderConstant[16]=<vecSunDir>;
vertexShaderConstant[17]=<vecDiffuse>;
vertexShaderConstant[18]=<vecAmbient>;
vertexShaderConstant[19]=<vecLight>;
vertexShaderConstant[20]=<vecFog>;
vertexShaderConstant[64]=<vecSkill41>; // u_scale1,v_scale1,u_scale2,v_scale2
vertexShaderConstant[95]=(0.0f,0.0f,0.0f,0.0f);
vertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[2]; //uv
}
asm
{
vs.1.1
m4x4 oPos,v0,c0 // transform position to clip space
mul oT0.xy,v7.xy,c64.xy // output scaled uvs - colormap1
mul oT1.xy,v7.xy,c64.zw // output scaled uvs - colormap2
mov oT2.xy,v7.xy // output uvs - macromap
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 r0,r0,-c16 // normal.light -> lighting constant
mul r0.xyz,r0,c17 // modulate against material diffuse color
add oD0.xyz,r0,c19 // add environment light
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
};
pixelShader=
asm
{
ps.1.3
def c0,0,0,0,1
tex t0 // sample colormap1
tex t1 // sample colormap2
tex t2 // sample macromap
lrp r0.rgb,t2.a,t0,t1 // blend t0 with t1 using the alpha channel of t2
+mov r0.a,c0
//add r0.rgb,r0,t2_bias // add(signed) rgb of t2
mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting
};
}
}
";
}