using arb_vertex_program and arb_fragment_program im working on getting per-pixel lighting w/ bumpmapping working in my engine. The problem is that im using md2 models to test out my lighting. So im using the knight from nvidia cause it has the normal maps and decal already made for me. So i try to get it working and im running into a problem. it seems that its doing the lighting when its first created but as i rotate the model the lighting doesn’t seem to change at all. I think that my tangent and binormals are ok cause i render the diffuse lighting and the bumps are there (http://blar2blar.tripod.com/bumpProb.bmp). Here are my shaders and if you need anything else to help me find out where i missed something or did something wrong just ask.
Vert Shader:
!!ARBvp1.0
ATTRIB iPosition = vertex.position;
ATTRIB iNormal = vertex.normal;
ATTRIB iColor = vertex.color;
ATTRIB iTex0 = vertex.texcoord[0];
ATTRIB tangent = vertex.attrib[8];
ATTRIB binormal = vertex.attrib[9];
PARAM lPos = state.light[0].position;
PARAM lHalf = state.light[0].half;
PARAM mvp[4] = { state.matrix.mvp };
PARAM mvinv[4] = { state.matrix.modelview.invtrans };
PARAM one = {1.0, 1.0, 1.0, 1.0};
OUTPUT oPosition = result.position;
OUTPUT oTex0 = result.texcoord[0];
TEMP light,temp,eyeNormal,tLight,tHalf;
DP4 oPosition.x, mvp[0],iPosition;
DP4 oPosition.y, mvp[1],iPosition;
DP4 oPosition.z, mvp[2],iPosition;
DP4 oPosition.w, mvp[3],iPosition;
DP3 eyeNormal.x, mvinv[0], iNormal;
DP3 eyeNormal.y, mvinv[1], iNormal;
DP3 eyeNormal.z, mvinv[2], iNormal;
SUB light, lPos, iPosition;
DP3 tLight.x, tangent,light;
DP3 tLight.y, binormal,light;
DP3 tLight.z, iNormal,light;
MOV tLight.w, one;
DP3 temp, tLight,tLight;
RSQ temp, temp.x;
MUL tLight,tLight,temp;
DP3 tHalf.x, tangent,lHalf;
DP3 tHalf.y, binormal,lHalf;
DP3 tHalf.z, iNormal,lHalf;
MOV tHalf.w, one;
DP3 temp, tHalf, tHalf;
RSQ temp, temp.x;
MUL tHalf, tHalf, temp;
MOV oTex0, iTex0;
MOV result.texcoord[1],tLight;
MOV result.texcoord[2],tHalf;
MOV result.color,vertex.color;
END
Frag Shader:
!!ARBfp1.0
ATTRIB tLight = fragment.texcoord[1];
ATTRIB tHalf = fragment.texcoord[2];
TEMP bump,decal;
TEX decal, fragment.texcoord[0], texture[0], 2D;
TEX bump, fragment.texcoord[0],texture[1], 2D;
TEMP temp,light,half,dots,final;
Steps for Bumpmapping
1. remove scale/bias from bumpmap
2. normalize bumpmap
3. do dots/lit
Step 1
SUB bump, bump, 0.5;
MUL bump, bump, 1.0;
Step 2
DP3 temp, bump, bump;
RSQ temp, temp.r;
MUL bump, bump, temp;
DP3 temp, tLight,tLight;
RSQ temp, temp.r;
MUL light, tLight,temp;
DP3 temp, tHalf, tHalf;
RSQ temp, temp.r;
MUL half, tHalf, temp;
DP3 dots.r, bump,light;
DP3 dots.g, half, bump;
#LIT dots,dots;
#MUL_SAT final, decal, dots.r;
MOV final, dots.rrrr;
MOV result.color,final;
END
Thanks!