Hi there, I am trying to implement shadow mapping in LWJGL, but have run into a problem, and am now stuck. I have done depth-mapping, render to texture etc. but I am stuck at the most vital part, using said shadow map, my problem is, I need to find out where the fragment I am shading is located on the shadow map.
For example:
I have a fragment called A, it's located at coordinates X,Y,Z.
It is rendered from the light's viewport onto my shadow map.
When I render the scene from a different camera, at coordinates S,T,U. for example, I now need to find out the location of the fragment A on the shadow map, so I can get the Z value from it, and compare it to another Z value I will generate using the coordinates of the original camera that rendered the shadow map.
The issue is that I don't have a clue of how I would get the location of A on the shadow map, meaning I can't tell wether or not it's in shadow. If anyone could help me to calculate shadow map coordinates of a point, that would be much appreciated.
Sorry if it's a bit long and over-complicated, but I am trying to explain my situation in as much detail as possible. If you want a simpler explanation of what I am trying to get: I basically need a replacement of gl_FragCoord that can be used in relation to a different camera/viewport's location/size/etc. to find out the location of a fragment on a render to texture.
Again, I know this is waaaaayyy too long, and my apologies, and thanks in advance to anyone who can help!