PDA

View Full Version : ARB_vp and Attenuation?



Lurking
12-13-2003, 11:47 AM
Im trying to do per vertex lighting using my own vertex program. Right now im trying to add attenuation to it. Can someone explain to me how i could do that using arb_vertex_program. Ive tried many things and just cant get them to work. I think im supposed to use the DST but i get weird outputs from that i guess. Here's my shader:
!!ARBvp1.0
ATTRIB iPos = vertex.position;
ATTRIB iCol = vertex.color;
ATTRIB iNor = vertex.normal;
ATTRIB iTex = vertex.texcoord;

PARAM mvp[4] = { state.matrix.mvp };
PARAM mvinv[4] = { state.matrix.modelview.invtrans };

PARAM lPos = state.light[0].position;
PARAM lHalf = state.light[0].half;
PARAM lDiff = state.light[0].diffuse;
PARAM lAmb = state.light[0].ambient;
PARAM lSpc = state.light[0].specular;

OUTPUT oPos = result.position;
OUTPUT oCol = result.color;
OUTPUT oTex = result.texcoord;

TEMP temp,eyeNormal,light,half,dots,att;

DP4 oPos.x, mvp[0], iPos;
DP4 oPos.y, mvp[1], iPos;
DP4 oPos.z, mvp[2], iPos;
DP4 oPos.w, mvp[3], iPos;

DP3 eyeNormal.x, mvinv[0], iNor;
DP3 eyeNormal.y, mvinv[1], iNor;
DP3 eyeNormal.z, mvinv[2], iNor;

SUB light,lPos, iPos;
DP3 light.w, light, light;
RSQ light.w, light.w;
MUL light.xyz, light, light.w;

DP3 dots.x, light, eyeNormal;
DP3 dots.y, lHalf, eyeNormal;
MOV dots.w, 32.0;
LIT dots, dots;

MUL temp, dots.y, lDiff;
MAD temp, dots.z,lSpc,temp;
ADD temp,temp, lAmb;
MOV oCol.xyz, temp;
MOV oCol.w, lDiff.w;
MOV oTex, iTex;
END