If you read through the thread below on dot 3 bump mapping
you will see that ventilator has devised a per-pixel diffuse shader. This is far beyond the dot 3 example which is a really a fixed function routine. here is the shader code that i have implemented based on ventilators code:
Code:
 material mat_diffuseperpixel
{

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

technique diffuseperpixel
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<texSkin2>;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[8]=<matWorldView>;
VertexShaderConstant[16]=<vecSkill41>;
VertexShaderConstant[17]=<vecFog>;
VertexShaderConstant[18]=<vecLight>;
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

mov oD1,c18 //output light color

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_sat r1,t1_bx2,v0_bx2 // normal . light

// mul_x2 r1,r1,v1 // modulate light intensity against light color

add r1,r1,v1 //add light

mul r0,t0,r1 // modulate against base color


};
}
}
";
}



this is still an evolving effect.. and lacks some things like true ambience.. right now i hacked in the ambient value.. alhough it is setup for point lights it needs a function to pass particular light vectors..i assume this can be developed with the next beta.. which i believe will have beter support for lighting.. But try it though and you will sold forever on per-pixel lighting



Sphere Engine--the premier A6 graphics plugin.