Shadow Mapping

Posted by

One of the features we'd like to add to Elium is shadows. My understanding is that the Nebula 2 engine, which the game is currently using, supports shadow volumes, but we'd prefer to use shadow maps, which would be better suited to large outdoor environments (where you've got lots of shadow-casting objects like trees, rocks, etc). So I figured, fine, I'll just implement shadow mapping. Shouldn't take more than a few days, right?

Shadows in War WorldsWrong! Couldn't be more wrong, apparently. After many days of fumbling around, I'm still trying to figure out how it would "fit" in with the rest of the engine. So last weekend I thought, "that's it, either I'm going crazy or something is wrong here!" So I decided to take some time to try and implement shadow mapping in my own engine - which I'm obviously much more familiar with.

The screenshot to the left is the result of that work. It took not much more than an afternoon (I'd read quite a lot about shadow mapping in my previous attempts in Nebula, so I was already pretty familiar with the theory). It's not perfect and it's only basic shadow mapping, but it works pretty well. And it works! I'm not crazy!

(By the way, in case you're wondering, the light blue square is the shadowmap texture)

So why is it so hard to get going in Nebula? To be honest, I don't know. Of course, my engine is currently reeeally simple, so there's not a lot going on to begin with. Nebula is quite a complex beast, with support for multiple render paths, a data-driven multi-pass shader architecture, and so on. The biggest thing I'm struggling with is just getting the shadow map properly rendered in the first place. I don't know if I'm defining the camera incorrectly or what, but I can't seem to get it to render the scene from the angle I want it to render. It just seems to render some random junk...

Anyway, I've taken a break and am currently working on a system for defining entities in the game in a data-driven way (rather than via a script - the way it works now). That might be the subject of another post, though...

But now that I've seen that I can do it, it's boosted my confidence that I can do it in Nebula, too.

blog comments powered by Disqus