Shadow Mapping Math Problems

I’ve implemented a systems that uses vertex and fragment programs for all rendering. I’ve gotten to the point of starting shadows, and I’ve gotten stuck with correctly indexing the pbuffer texture.

I take the lightModelview, lightProjection, biasScale, and cameraModelViewInverse, and multiply them together like so:

texMat = biasScale * lightProjection * lightModelview * cameraModelViewInverse;

Then I take the transpose, and pass in the rows to VERTEX program 'local’s.

I then do this:
DP4 shadowMapTexcoord.x, texMat1,vertex.position;
DP4 shadowMapTexcoord.y, texMat2,vertex.position;
DP4 shadowMapTexcoord.z, texMat3,vertex.position;
DP4 shadowMapTexcoord.w, texMat4,vertex.position;

I finally pass the shadowMapTexcoord to the fragment program, and use it to reference the pbuffer texture with a texture projection:

TXP shadowDist, shadowMapTexcoord, smTex,2D;

I am getting “shadows”, if you can even call them that… they seem to relate to my camera location in space, as well as the light location. I can’t see any of the actual shadow receiver in the light areas though…

I would appreciate any help with this!