Quote:Original post by ZemedelecIt will not discard any fragments when you draw your scene, but that is what you want, too. You do want to draw those fragments.
This will discard fragments, *after* the pixel shader is executed for them.
When you draw your 5 fullscreen quads, it will discard the sky fragments after the depth test, but *before* running the pixel shader, and this is what you want. It would of course be yet more efficient if you could exploit the z buffer for that, but this isn't easy, and it would probably be slower due to some necessary state changes and an extra pass (albeit double-speed).
There used to be a "Humus Demo" a few years ago which used the stencil buffer technique to implement dynamic branching on hardware that per se was unable to do so, reducing of calculations for many small, local lights.
Personally, I didn't like the unjustified contra-nVidia, pro-ATI propaganda that came with the demo, but the technique in the demo nevertheless remains entirely valid.