Yesterday I fixed a bug where directional lights weren't matching between the level editor and the engine. In the process, I fixed the arrow that represents the light direction to visually match in the editor.
Once I got that sorted, I noticed that several of the character shadows were getting cut off at the legs or feet. I figured it was due to the bounding sphere used for shadow creation not being the right size. I was right - I had old code in there that shrunk the bounding sphere to 80% of its real radius so as to make the collisions feel better. I fixed it to use a bigger radius, which solved the shadow clipping problems. This won't hurt the collisions, b/c I'm using an AA ellipsoid for those anyway.
I also started work on a real level. I'm tired of test levels, and wanted to make something that actually looks cool. So, far, so good. I was pleasantly surprised when I brought it up in the game - I thought - this game is going to be !@#!@#$ cool!!
It's easy to get bogged down in the technical crap and forget the whole point sometimes, so it's good to be reminded of the cool factor driving the whole project.
Here's a shot of the level I've made so far.
I have probably spent more time on shadowing than any other aspect of the Ancient Galaxy engine. I suppose that's because shadowing is a very difficult thing to get right for
many types of scenes.
My friends from the movie rendering side of things tell me that in the movies, they cheat by allowing the artist to specify how big the shadow maps are for each frame of the movie, and similar manual tweaks. Also, they often use 4k x 4k shadow maps - not exactly practical for real-time on a gf3!
As I mentioned yesterday, I use per-caster shadow maps. Each shadow map is packed into an atlas for speed purposes.
Here is a diagram of how the light position and object bounding sphere together define the shadow frustum.
I take the character's bounding sphere, and use this to make a frustum that exactly encloses it.
One of the things I need to improve about my shadow maps still is to line up the shadow maps in local object space. This should do a better job with texel distribution, as well as make objects fit better when they are tilted. Here is a shot of an ellipsoidal boulder that is taking up too much space in the shadow atlas, due to being tilted.
I also use the bounding diameter to map the light-space depth function. If you do per-caster shadow maps, you don't need every object in the scene in the same shadow map. That has several advantages : one is that you can use less shadow texels overall as your shadows are tightly restricted to what the casters need. The next is that you can use less depth precision. For a character not under extreme zoom, 255 depth values is plenty for self-shadowing and for the character shadowing nearby objects.
For a long time, I wasn't doing depth shadow maps, but just black on white shadow maps, and it worked great. I would get occasional artifacts when a character was close to a stair, but it wasn't common. As I worked on making more realistic levels with the level editor, I added things like sarcophagi and fountains, and other low objects that can intersect the shadow frustum and the casterbounding sphere at the same time. This causes the projected shadow to leak towards the light, which looks awful and distracting.
So, it took me about a day to extend the per-caster shadow maps I already had to use 8-bit depth maps. This way the character's depth is rendered into the shadow map, and any receiving objects
map into the same depth range, and test their depth vs the depth already in the shadow map to see if they should be shadowed or not. This completely fixed the artifacts I was having, at a slight speed hit. I could have also used 8-bit object id maps instead, but that would not have worked for self-shadowing objects or characters, which I may add later on.