OpenGL guy said:
Xmas said:
A surface that is far away from an attenuated light source will never be affected by it. From the position of the light source, you can derive a depth range outside of which you don' have to check whether a pixel is in shadow. It will simply always be in shadow.
I don't think so. Imagine a plane that is parallel to the screen with a spotlight on it. The whole plane is at the same depth value but you need to attenuate the light... Your method doesn't help here.
I don't understand what you're arguing here. Of course you need to attenuate the light. But you don't need to calculate the lighting/shadows for pixels which you already know are outside of the range of the light.
Imagine the light source as a huge "sphere of effect". Everything inside this sphere
may be affected by the light. Everything outside this sphere can not be affected by the light source because it's too far away.
Now, if you know that a certain pixel/surface is outside of the sphere, you can instantly drop any shadow calculations for that pixel/light source pair.
This sphere of effect has min/max extents on all three axes. For X and Y, you can use a scissor rectangle to limit the calculations only to those pixels that are possibly within the range of the light. For Z this is more difficult, because you don't have to check the depth value of the shadow volumes, but the depth values of the
scene that's already laid out in the depth buffer.
Remember, you use stencil shadow volumes to count how many times an eye ray crosses shadow volume boundaries before it hits a visible surface. If you know beforehands that this surface is too far away, you don't have to render stencil shadows at this position.