Monday, December 29, 2008

PSVSM Shadows And Texture Updates

It's been a while since my last post so a lot has happened - mostly Christmas related stuff, but some planet work as well.

I implemented a second LOD for the textures so that when you view the planet from just outside the atmosphere the textures don't look like they repeat so much and there isn't a mipmap problem with the texture tiling so much which makes the texture really grainy. I also added back a temporary water sphere surface with some specular and normal mapping, to look like water, but it won't really look like water till it is animated, and it has uv problems at the top and bottom. Eventually I plan on coming up with a way to always have the water mesh face the camera at point where the uv isn't stretched and then do a mini-quad tree on it so that I can actually animate the vertices when you're close to the surface (but I'm getting waaayyy ahead of myself there).

After implementing that stuff I got in over my head implementing shadows.

My first success was with Ogre's PSSM shadow demo, but that had a major drawback because the shadows had a gap between where the shadow started and the base of the shadow casting triangles. Also the shadows swam a lot when you moved the camera and they were very pixelated because of the large amount of terrain that was covered.

This image shows the shadow "beards" and uses 3 512x512 shadow maps.

Later I found that this was a typical problem for basic PSSM shadows, and I read that VSM shadows didn't seem to have this problem (although they have their own drawbacks - namely light bleeding, which sounds weird to say)

I posted my latest GLSL shader code for the shadow caster and shadow receiver materials as well as the Ogre material code - and my set up code too so hopefully it can be tweaked to make it perform and look better.

These images show PSVSM using 3 1024x1024 shadow maps. I'll probably have to scale back to 512x512, unless I can come up with a way to gain back fps dramatically.

I plan on tweaking the shadow, terrain texture and water texture code next before moving on to a basic atmosphere.