Faking Flickering Shadows with Static Lightmaps

For mobile games today you don’t have much options for at least environment shadows, you almost always have to use static lightmaps. This was the case for my current game in development, code named “Defender 3D”. But static lightmaps are kind of boring and I have some torches and fires around the game scene so it would make sense to move the shadows somehow, so I came up with a very simple shader which does just that. Word of warning, this shader has very little application, only usable in very strict conditions thankfully Defender 3D has. But it can be extended to be used in other situations maybe (hey smart shader programmers 😉 ).


Below is how it looks in various surfaces. (Excuse the low frame rate)


Before we get to the shader code itself, let’s talk a bit about how it works and what caveats it has. This is a vertex/fragment shader (not a surface shader). It simply pans the second/lightmap UV through a sine function where you can customize the flicker speed and magnitude through the material inspector. That’s all there is to it.


  • Ridiculously low-cost performance wise.
  • A good way to fake dynamic lighting, especially for top-down/isometric games.
  • Shadows can move to non-neighbor surfaces based on the flicker magnitude and lightmap uv atlas arrangement
  • Shadows won’t move realistically, they will just sway between two positions, this is a fake effect


So below is the shader code, for demonstration purposes and to keep it simple I just made it a lightmapped diffuse, feel free to add more properties to it. As always, check out the verbose comments if you need them. Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *