Sunday 21 January 2007

Shadow Volumes/Map interactions

Been a while huh? Ive been too busy studying about the breast/axilla and various other organs of the body. Tis pretty neat. Anyways, onto the meat of this post.

With shadow maps, after calculating which point is in complete shadow and which point isn't, you add a small ambient value so that things look half decent (*cough* unlike Doom3 *cough*). All nice and rosy. Until you meet shadow volumes. Shadow volumes require that you have an ambient pass, then render an alpha'd full screen quad with certain alpha values to get the ambient you want. Can you see the problem?

If you mix both maps and volumes, getting the same colour for both volumes and maps is going to be dam hard since the alpha value doesn't directly correspond to a colour per say.

The solution to the problem is to render the stencil buffer to texture, and sample from a fragment shader and add the ambient factor just like shadow maps. However, FBOs dont support rendering to stencil alone. Apparently, OGL implementations interleave depth and stencil since depth is usually 24bits and stencil 8bits => fits perfectly into 32bits

EXT_packed_depth_stencil to the rescue. You can have 1 texture that is both depth and stencil, which means that the shadow map is the depth value and the stencil buffer for stencil shadows is the stencil 8bit packed value. Tis very neat.

In the wise words of borat: I like!

No comments: