Search Unity

2D shader wanted: Sprite on top of sprite becomes partly transparent

Discussion in 'Shaders' started by nishifex, Feb 13, 2017.

  1. nishifex

    nishifex

    Joined:
    Jan 4, 2017
    Posts:
    13
    Hi everyone,

    I'm trying to build something like this for my top-down 2D game:
    A character (sprite) moves under a tree(top), where the treetop (sprite) is currently hiding the player. I want the character and a certain radius of the area around him to be visible despite being under the tree (by making the tree transparent in this area).

    I managed to make the entire treetop sprite transparent by setting material.color.a, but the next step is to make only part of the sprite transparent.

    The difficult thing is: I want the alpha to be a gradient as shown in the image below.

    How would I approach this problem? I'm a shader noob, so I'd be grateful for detailed advice.
    Thanks!
     

    Attached Files:

  2. nishifex

    nishifex

    Joined:
    Jan 4, 2017
    Posts:
    13
    bump... any ideas? :/