I’m still trying to sort out the best way to get this cleaned up into a state where I can contribute it (or even keep it) but it was an interesting bit of code.
The idea was to have simple “Mario” style drop-shadows instead of full-up proper shadows. In a game like Mythruna, proper shadows are problematic for several reasons but objects also feel like they are floating without some indication of “presence”.
The interesting thing is that the shadows are actually rendered as boxes during a post-processing pass. So when the box is rendered, the frag shader knows what the frag depth is and it has access to the scene’s depth texture. With these and some other parameters, I can (turns out pretty trivially) calculate where in the volume the existing scene pixel is.
In the above pics, the shadow volumes extend a bit above the base of the object and then well below it. I normalize the 3D volume coordinate into a 3D texture coordinate and then calculate a distance from the center (basically) to determine how much shading to provide. Thus, anything inside the volume will be darkened based on its proximity to the center of the box.
The shader is really simple at the moment but the rest of the code is a bit unorthodox and inefficient. When it’s cleaned up a bit more, I plan to contribute it.
This sort of 3D volume mapping could be used for other things, too, I guess. At some point, I want to see what it looks like to do the reverse and have a light volume done this way. It’s pretty trivial to bring back the sides of the box when calculating the color values and I think it would make a pretty cool “god rays” effect. Solid light beams that also light up what’s “inside” them.