Spotlights texture calculations in vertex programs

Hi guys!
I use this example to simulate per-pixel lights
Works fine but it use fixed functions to calculate texture coordinates that passed to vertex program:
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);
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

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;


That should work.

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).]

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

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.