PDA

View Full Version : z-fail shadow algorithm



Ia3n
12-17-2006, 12:25 AM
I've implemented z-pass shadows and now would like to work on z-fail shadows. I can handle the capping and the projection to infinite distance, but I have a few problems with how to initialize the stencil buffer. I am supposed to clear it to the number of shadow volumes that the camera is inside, right?
The first problem is that that causes the whole problem with having to put caps on the near clipping plane that z-fail shadows are meant to avoid. What if the picture plane intersects a shadow volume? Do I then need to draw polygons on the near clipping plane to initialize the stencil buffer to different counts for which parts are ouside or inside the shadow volume?
The other problem is just plain solving for how many volumes the camera is inside. It seems like all the usual methods for accelerating collision detection are screwed up by the fact that the shadow volumes are generated from scratch every frame and have infinite extent. Can anyone point me toward any resources for collision detection on arbitrary, potentially concave, infinitely large volumes?

Nikolai Timofeev
12-17-2006, 12:50 AM
With z-fail you must use both volume's caps +
infinte projection ( if NV_depth_clamp not available ) and change stencil test configuration for z-fail, i.e. INCR on depth fail for back faces and DECR on depth fail for front faces
Clear stencil as usual.