Search Unity

Texture-space shadows

Discussion in '2D' started by TomasJ, Nov 21, 2013.

  1. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Hey,

    Just wanted to share a technique with you all on how to make transparent texture-space shadows easily applicable to sprites.
    Steps:
    1. 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.
    2. If using a tight mesh, specify a large enough Extrude property to have enough texture space for the effect.
    3. 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:
    $shadow.jpg
     

    Attached Files:

    Last edited: Nov 21, 2013