I'm trying to implement the shadow mapping, but I can't understanding the exact theory behind it. My problem lies in the second pass where I need to compare the depth stored in the shadow map with the current pixel depth.
Assume now in the second render pass I have the depth of one pixel, which value in shadow map should I compare to? how can I get that value?
I read some tutorial online, which says I need to calculate the distance between light source and the pixel in the second pass, but I don't know how.
Can someone elaborate the above part of the algorithm to me? Thanks in advance.