residualvm/residualvm — pull request #956 by Akz- (2014-07-06 21:55:46+00:00)
Title: EMI: Shadows

This adds support for projected shadows (visible for example in sets wed, law and pop) and also enables the shadow sprites which are seen under characters in some sets.

c1ea2e4 changes the way shadows are rendered in the OpenGL renderer slightly. Previously, for each actor, the shadow planes (the sectors which form the receiving surface) were first drawn to the stencil buffer. Then the actor's shadow projection was drawn with the shadow color, clipped against the stencil buffer. The clipping ensured the shadow wasn't drawn outside of the receiving surface.

I changed this so the actor's shadow projection is first drawn to the stencil buffer. Then the shadow planes are drawn with the shadow color, clipped against the stencil buffer. This gives the same visual result as the method used before in Grim, but this also allows the shadow to have a different color on each shadow plane, which is needed in EMI (for example in the set pop).

Currently I've only implemented this change for the OpenGL renderer. TinyGL draws shadows similarly as OpenGL did before, but the shadow mask (equivalent to the stencil buffer in OpenGL) is only rendered when the camera setup changes. This optimization is possible because the shadow planes never move. If this change was implemented in TinyGL, it would be necessary to render the shadow mask each frame for each actor that casts a shadow, which would likely slow down the renderer.

For this reason, a different solution is needed to enable shadow plane specific shadow colors in TinyGL.