Search Unity

get position within sprite

Discussion in 'Shaders' started by sschoellhammer, Jan 5, 2017.

  1. sschoellhammer

    sschoellhammer

    Joined:
    Feb 15, 2013
    Posts:
    46
    Hello,

    So I have a set of (possibly atlassed) sprites.
    Now I want to draw a gradient so that it ranges from the bottom to the top of the individual sprites.
    How is that possible? My shader works just fine if I have one sprite and I can just map vertex from
    struct appdata
    {
    float4 vertex : POSITION;

    to a color. If I have more than (strangely) 2 of the same sprite I seem to be getting a big world space mesh and now my gradient sits on the world axis...
    Similarly, with an atlas I cannot use uvs.

    So what can I do? Would I have to write my own sprite renderer that lets me feed in a second uv set? ugh.

    Thanks for any hints!

    seb