Tweaks, optimisations, texture-based shadows

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

The last few days have been a bit fragmented, I’ve added a few additional optimisations like being able to make shadows turn off at a given distance, and I’ve implemented the D3D versions of projective textures. Ogre could actually do projective textures before, it was just a little awkward. Now you can just attach a Frustum object to the texture unit, and it does it all for you, which is pretty slick. _mental_ is working on the GL implementation now.

Tonight I promoted a whole bunch of features to Frustum and rationalised the code more between it and Camera to remove some unnecessary duplication. I’m planning on using these features to do orthographic projection of shadows from the Frustum object.

I’ve been researching the next shadow type, which was going to be perspective shadowmaps, however the reading I’ve done has convinced me that they are not worth the effort - many people including Jonathon Blow (smart chap) have tried to get them to look good, with little success, one of the main problems appears to be the ‘swimming’ effect of the shadows when the view is changing, and the degenerate cases not looking good.

Another problem is that shadowmaps are actually quite poorly supported. nVidia have supported them the best it seems, and they are available in the GF3 and above through GL_ARB_shadow and through a ‘magic’ feature of D3D; it’s ‘magic’ because it is not specified in D3D - in fact no part of the D3D spec mentions using depth textures fro shadowmaps. However, binding a depth texture on an nVidia card magically enables GL_ARB_shadow behaviour; but this does not happen on ATI cards. It seems like the only reliable way to use depth shadow maps across all cards is to use a fragment program.

So, my current strategy is to try to use a tiled set of projected textures as scene shadow projectors; using standard modulative blending on the world geometry. This has several limitations, such as being usable for directional lights only, and not supporting self-shadowing. Also the tiling is essentially 2D so relies on their being a natural ‘ground’ dimension. If it works, I may add a shadowmap version of it later on, if I get time.

Here’s a very quick hack test of the texture based shadows, ignore the colours for now, it’s the shape that matters…