How do I use these together? As I understand it the way shadow maps work is by projecting the texture over the scene normally, but instead of using the colour value they compute it using Cv = textureCoord.r >= Cf ? 1 : 0.
While my texture coordinates for s and t are valid it seems r is always 1 in my fragment program… Actually r doesn’t seem to be 1, it is far greater than 1. It seems I need to normalize it.
How do I normalize my r coordinate if this is the case?
With this matrix you transform the coordinate system from window/screen space to texture space (is that the correct expression?).
By doing these transformations correctly, you normally have a r-coordinate between 0 and 1. Maybe you forgot to do a homogeneous divide in your vertex program.
[This message has been edited by mako (edited 07-31-2003).]
[This message has been edited by mako (edited 07-31-2003).]
Originally posted by titan:
[b]How do I use these together? As I understand it the way shadow maps work is by projecting the texture over the scene normally, but instead of using the colour value they compute it using Cv = textureCoord.r >= Cf ? 1 : 0.
How do I normalize my r coordinate if this is the case?[/b]
The q-coordinate in (s,t,r,q) is not necessarily 1.0 when you receive it after interpolation in the fragment program. Try to divide (s,t,r,q) by q. It worked for me when I did shadow mapping and PCF in a fragment program.
Originally posted by SFRuckus: Try to divide (s,t,r,q) by q. It worked for me when I did shadow mapping and PCF in a fragment program.
Of course. I don’t know why I wasn’t doing that. While this does give me a grey similar to the that of the texture I can’t do the a valid compare of coordinate.z (after *(1/q)) with the result of the TXP function. Any idea what I could be missing?
Originally posted by titan: Of course. I don’t know why I wasn’t doing that. While this does give me a grey similar to the that of the texture I can’t do the a valid compare of coordinate.z (after *(1/q)) with the result of the TXP function. Any idea what I could be missing?
Here is what I do: shCoord holds projected and biased position of fragment (relative to the light). The shadow map is in texture[0].
After