Texture-space shadows

Hey,

Just wanted to share a technique with you all on how to make transparent texture-space shadows easily applicable to sprites.
Steps:

  • Use the provided shader (based on Sprites-Default). It samples the texture twice (once normally, once with an offset) and blends the two colours in the fragment shader.
  • If using a tight mesh, specify a large enough Extrude property to have enough texture space for the effect.
  • Note: this will not work with packed sprites because the shader can sample outside of the packed sprite area.

Here’s a familiar character (FullRect mode) dropping a red shadow:
1427715--75572--$shadow.jpg

1427715–75571–$Sprites-DropShadow.shader (2.18 KB)