I have been asked by many to explain how to make shadowmapping and GLSL to work together, and because I am lazy I will try to explain it all here. ;)
First off: if you don’t know C++, OpenGL and some basics about shadowmapping, you need to go read up on that first. Other people descibe how to get that working, so I will not repeat (badly) what they write.
If you havn’t read it, read this shadowmapping tutorial straight away.
Here is the fixed function code to set up the projection of the shadow (still using the texture matrix, easier to switch to GLSL from that position):
In the GLSL version, only the texgen stuff needs to be moved into the GLSL program. The texture-matrix is still used, but from the vertex-program.
.. and then projected into the scene in the Fragment program:
This GLSL program is very bare, just to show the bare essential to get shadows working.
I will try and create a tiny program with source. Right now the code is entangled in, lots of other code I can’t relase.