First you create a 3D lighting texture.
Then you put your base texture into Texture Unit 0 and your 3D lightmap into Texture Unit 1.
Put into the texcoords of TU 0 your usual texcoords and into the texcoords of TU 1 you put the vertex-position (so you need 3 texcoords on TU 1).
The activate TU 1 and call:
glMatrixMode (GL_TEXTURE);
glLoadIdentity ();
glScalef (1 / Lighradius, 1 / Lightradius, 1 / Lightradius);
glTransform (-Lightpos.x + (Lightradius/2), -Lightpos.y + (Lightradius/2), -Lightpos.z + (Lightradius/2));
glMatrixMode (GL_MODELVIEW);
That´s it. With this setup you can perform dynamic lighting (without bumpmapping). When doing bumpmapping, it gets a bit harder. For bumpmapping vertex-shaders come in VERY handy + you need to use register combiners or fragment programs (nVidia vs. ATI).
Anyway, you might like to read this article:
http://www.ronfrazier.net/apparition/
(under “Research Project”). It´s quite helpful.
Hope that helps you.
Jan.
EDIT:
With this line i´m not so sure:
glScalef (1 / Lighradius, 1 / Lightradius, 1 / Lightradius);
glTransform (-Lightpos.x + (Lightradius/2), -Lightpos.y + (Lightradius/2), -Lightpos.z + (Lightradius/2));
It could be, that you first have to transfom and than to scale (but i don´t think so) and it could be, that you don´t need to negate the Lightposition in the transformation. But i think it´s shown correctly in the article i mentioned.
[This message has been edited by Jan2000 (edited 08-05-2003).]