here is the complete shader again:

Code:

action ball // your entity's action
{
//bmap_to_normals(bmap_for_entity(my,1),16); // don't use this if you already have a normalmap
my.material=mat_diffuseperpixel;

while(1)
{
my.skill41=float(sun_pos.x); // use your own lightpos here
my.skill42=float(sun_pos.y);
my.skill43=float(sun_pos.z);
my.skill44=float(1);
wait(1);
}
...

material mat_diffuseperpixel
{
flags=tangent;
effect=
"
texture texSkin1;
texture texSkin2;
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
vector vecSkill41;
vector vecFog;

technique diffuseperpixel
{
pass p0
{
Texture[0]=<texSkin1>; // colormap (texture 1 of 2 in med's skin editor)
Texture[1]=<texSkin2>; // normalmap (texture 2 of 2 in med's skin editor) make sure you use a 24bit tga bitmap

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[8]=<matWorldView>;
VertexShaderConstant[16]=<vecSkill41>;
VertexShaderConstant[17]=<vecFog>;
VertexShaderConstant[95]=(0.5f,0.0f,0.0f,0.0f);

VertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv
float v8[3]; //tangent
}
asm
{
vs.1.1

m4x4 oPos,v0,c0 // transform vertexpos to clip space
mov oT0,v7 // output uvs
mov oT1,v7 // output uvs

m3x3 r5,v8,c4 // transform tangent to world space
m3x3 r7,v3,c4 // transform normal to world space

mul r0,r5.zxyw,-r7.yzxw // tangent x normal -> binormal
mad r6,r5.yzxw,-r7.zxyw,-r0

m4x4 r10,v0,c4 // transform vertexpos to world space
sub r10,r10,c16 // lightdir=vertexpos-lightpos
dp3 r10.w,r10,r10 // renormalize it
rsq r10.w,r10.w
mul r10,r10,r10.w

dp3 r8.x,r5,r10 // transform lightdir to texture space
dp3 r8.y,r6,r10
dp3 r8.z,r7,r10
mad oD0.xyz,r8.xyz,c95.x,c95.x

mov r1.w,c17.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position
add r0,r0,-c17.x // distance-fog_start
mad r0.x,-r0.x,c17.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
tex t0 // sample colormap
tex t1 // sample normalmap
dp3 r1,t1_bx2,v0_bx2 // normal . light
mul r0,t0,r1 // modulate against color
};
}
}
";
}