Omni-directional lights using cubemap shadows - (4. March 2010) |
|
Filed under: Default — Sascha Willems @ 22:27
It looks like my dungeon crawler prototype isn’t actually evolving into a game, but much more into a personal testbed for more-or-less current rendering techniques (due to Projekt “W” I’ve been lacking in the field of recent rendering techniques a bit). And so one of the things I always wanted to implement were shadows for omni-directional light sources. I’ve been doing that with stencil shadows years ago, but stencil shadows aren’t the preferred way of doing this nowadays due to their limitations, including sharp edges (yes, there are ways to get around this, but they’re expensive in terms of computing) and a high demand for fillrate. And I’ve also done shadow mapping some time ago, but back then only for a spotlight, and that’s pretty easy (basically it’s just a way of projecting something onto the scene). But omni-directional lights are a step further and It took me some time to get them to work. One of the hardest things holding me back were troubles using depth cubemaps in my shader. So now I’m using a normal cubemap (RGBA) for the light source and each face stores a custom calculated depth value (done in a separate shader) that’s then used in the final calculation to apply shadows to the scene (done in the same shader that does lighting and parallax mapping). |
3 Comments » |



Very cool stuff sascha, saw your generator a while back on delphigl and was wondering when you would ever make it into a wolfenstein like environment. Anyway I been lookin searching for some good articles on doing shadowmapping for pointlights for some time now. Could you point me into some resources u used?
I don’t know why, but actually I wasn’t able to find tutorials or documents on cubemap shadow maps anywhere. But maybe it’s because not many people use this technique (I guess for many scenarios dual paraboloid shadowmaps are better suited) or because it’s so easy to implement. Basically it’s just rendering to the six cubemap faces from the light’s point of view and then using a shader to see if a fragment is in the shadow. Pretty easy.
But maybe take a look at the demos over at humus.name , I think he is using cubemap shadows in some of them and also includes source.
Got it working:) http://www.pascalgamedevelopment.com/forum/index.php?topic=6159.msg50020;boardseen#new for a little demo. Could get depht cubemaps and fbo working on my 4890 so I also used an rgba cubemap. Do you do any filtering when rendering the shadows btw? I was thinken of using a simple kernel filter to smooth out the edges. Still thinken of how to calculate the offset vectors though.