My question is, why do I get this...


out of this code:

// Simple Toon Shader
// Works with vs1.1 and ps1.2 - so it will work on most cards
// Works with DX 9 so it works with the 6.30 and above
// This is a modified version of ventilators original Simple Toon shader.

// To make this work you copy this stuff or add ths script.
// You also need two image files:
// 1 - tsnormalise.tga - which will get made into a normalisation cube map
// 2 - A shade map that determines the level and numer of shade bands in the paint section
// By default this shader uses ts2tone.tga which gives two tone shading.

// Normaliser cubemap sprite
bmap bmp_normalizationcube=<tsnormalise.tga>;
// Paint shade map for toonshader
bmap bmp_tstonemap=<ts3tone.tga>; // <<< CHANGE THIS TO CHANGE PAINT SHADING

// This Starter function takes the normaliser sprite and convirts it to a D3D cubemap
// This function is started on game start and needs to occur before the toon shader will work
// It creates a cubemap and assigns it to the shaders skin1 texture.


entity* player;

// Ink and paint toon shader - Takes light direction from sun direction vector
material material_ToonShader
{
skin1=bmp_normalizationcube; // This is the normalisation cubemap created by the starter function
skin2=bmp_tstonemap; // This is the shademap that determines the "shading" of the paint part of the shader

effect
"
texture entSkin1; // The models skin texture
texture mtlSkin1; // The normalisation map
texture mtlSkin2; // The tone map
matrix matWorldViewProj;
matrix matWorld;
vector vecSunDir; // Sun direction vector

technique TwoToneToon
{
// -------------- Painter --------------------
pass p0
{
texture[0]=<mtlSkin1>; // The normalisation map
texture[1]=<mtlSkin2>; // The shade map
texture[2]=<entSkin1>; // The models skin texture

addressU[1]=clamp;
addressU[2]=wrap;
addressV[2]=wrap;
magFilter[2]=linear;
minFilter[2]=linear;
mipFilter[2]=linear;

vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[4]=<matWorld>;
vertexShaderConstant[16]=<vecSunDir>;

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
mov oT0.xyz,r0.xyz // output normal to oT0
mov oT1.xyz,-c16.xyz // output light direction to oT1
mov oT2.xy,v7.xy // output uvs to ot2
};
pixelShader=asm
{
ps.1.2
tex t0 // fetch normalized normal
texdp3tex t1,t0_bx2
tex t2 // sample color map
mul r0,t2,t1 // modulate with shading
};
}
// -------------- Outliner -------------------
pass p1
{
CULLMODE=CW;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=0.8; // outline_thickness, def0.8 << CHANGE THIS TO CHANGE OUTLINE THICKNESS

vertexShader=asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord v7

mov r0,v0
mul r1,c16.x,v3 // Scale the normal
add r0.xyz,r0.xyz,r1.xyz // Shell offset (vertex pos + Scaled Normal)
m4x4 oPos,r0,c0 // Transorm position to clip space
};
pixelShader=asm
{
ps.1.1
def c0,0,0,0,5 // outline rgba << CHANGE THIS TO CHANGE OUTLINE COLOUR
mov r0,c0
};
}
} // End of technique

technique fallback // empty fallback causes normal rendering without outline
{
pass p0 { }
}
"; // end of effect
}


starter mtl_toon_init()
{
bmap_to_cubemap(material_ToonShader.skin1);
}


action Model_Me
{
player = me;

my.material = material_ToonShader;

while (1)
{
if (key_w == on)
{
c_move (my, nullvector, vector(5 * time,0,0), GLIDE);
}

if (key_a == on)
{
c_move (my, nullvector, vector(0,5 * time,0), GLIDE);
}

if (key_d == on)
{
c_move (my, nullvector, vector(0,-5 * time,0), GLIDE);
}

if (key_s == on)
{
c_move (my, nullvector, vector(-5 * time,0,0), GLIDE);
}

wait (1);
}
}



"The GREAT LAW: Life is and always will be justly ordered, and that all past experiences, good and bad, were the equitable out working of our evolving, yet unevolved selves" - As A Man Thinketh