Light and Dark Caps

· by Steve · Read in about 2 min · (366 Words)

They say the dark side of the Force is easier and more seductive; well, it turns out the same applies for shadow volume caps. 😀They’re needed whenever you enter the projection of the shadow volume (towards or away from the light), at the time when you need to use the ‘zfail’ volume rendering method (otherwise known as the Carmack method), because otherwise you can see out the ‘tube’ which is formed by the extrusion of the silhouette edges. Some engines use zfail all the time, but because it’s more expensive because of the caps, I flip between zpass and zfail as required.

The dark cap was a piece of cake, it worked instantly. I used the method of tracing the silhouette edge and rendering a fan on it, rather than rendering all the dark-facing triangles, which worked really well.

The light cap decided to be entertaining though. I’ve hit all sorts of issues with it, and whilst I have eliminated a number of them, I still have some annoying glitches when rendering the light cap in an area which is being self-shadowed, or is receiving a shadow from something else. It’s driving me nuts, I hope to fix it soon though because it must be something stupid; conceptually it’s a very simple thing.

The other things that’s driving me nuts is the fact that no shadows are getting rendered for hardware skinned entities. These are special cased when using stencil shadows so that we do software blending of positions only (not normals) in order to provide the data required for the silhouette, but hardware skinning is still used for the model itself (saves uploading data across the bus for one). The crazt thing is, it all looks fine; I can debug any section of the code I like and everything seems dandy - I even get the right number of polys being rendered. But there’s zip on the screen. I can’t even see the debug volumes when I turn them on, which I should be able to see _somewhere_ if it was a vertex winding issue, or a transform issue. Bizarre. Ah well, lets hope I have some non-grey hair by the end of the week.