Spotlights texture calculations in vertex programs

Hi guys!
I use this example to simulate per-pixel lights http://users.ox.ac.uk/~univ1234/opengl/ppatten/ppatten.htm
Works fine but it use fixed functions to calculate texture coordinates that passed to vertex program:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glTranslatef(0.5f, 0.5f, 0.5f);
glScalef(0.5f, 0.5f, 0.5f);
glScalef(1/lightRadius, 1/lightRadius, 1/lightRadius);
glTranslatef(-lightPosition.x, -lightPosition.y, -lightPosition.z);
glMatrixMode(GL_MODELVIEW);
And after that in vertex shader we simply do
#transform position by texture matrix 0 to get 3d tex coords for attenuation
#put (s,t,r) -> (s1, t1, s2) for texture atten and (s,t,r)->(s1, t1, r1) for pass through atten
DP4 o[TEX1].x, c[4], v[OPOS];
DP4 o[TEX1].y, c[5], v[OPOS];
DP4 o[TEX2].x, c[6], v[OPOS];
DP4 o[TEX1].z, c[6], v[OPOS];
How can be fixed functions translated to vertex program?
Thanx in advance
Bye

!!ARBvp1.0
PARAM mvp[4]={ state.matrix.mvp };
PARAM LightPosition=program.env[0]; # Light Position
PARAM LightRadius=program.env[1]; # 1 / Light Radius

TEMP Temp;

DP4 result.position.x, mvp[0], vertex.position;
DP4 result.position.y, mvp[1], vertex.position;
DP4 result.position.z, mvp[2], vertex.position;
DP4 result.position.w, mvp[3], vertex.position;

SUB Temp, LightPosition, vertex.position;
MUL Temp, Temp, LightRadius.x;

MOV result.texcoord[0].xy, Temp;
MOV result.texcoord[1].x, Temp.z;

END

That should work.

Edit:
Unless I misunderstood the question, and you just want to do a texture matrix multiply in a vertex program…

[This message has been edited by NitroGL (edited 04-22-2003).]

Thanx
But I can understand why you done
DP4 result.position.x, mvp[0], vertex.position; and don’t use it
and what about this statements:
glTranslatef(0.5f, 0.5f, 0.5f);
glScalef(0.5f, 0.5f, 0.5f);
maybe you send your code to my e-mail to understand your way
Thanx in advance
Bye

Translate is just an addition and Scale is just a multiplication. Both of these operations can be done in a vertex program with ADD and MUL.

-SirKnight