Omni-directional lights using cubemap shadows

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).