Search Unity

Question Sprite Mask Alpha Cutoff

Discussion in '2D' started by Kaikoura_, Feb 14, 2023.

  1. Kaikoura_

    Kaikoura_

    Joined:
    Nov 4, 2021
    Posts:
    5
    Hey,
    I want to create a smooth sprite mask, If I use the build in mask in Unity it looks like this sadly:



    The alpha cutoff of the sprite mask makes hard edges instead of smooth transitions on the alpha channel.
    I found an old post where they talk about solutions:
    https://forum.unity.com/threads/feathered-soft-sprite-mask.498764/

    I need a solution in which I can have multiple masks. For example like in the light system of "Don´t starve".
    someone suggested to make a shader. How could I make one to achive this effect?
    I found pretty much nothing online, thanks for helping me out :)
     
    Lorhus and hellobody like this.
  2. flasker

    flasker

    Joined:
    Aug 5, 2022
    Posts:
    193
    i will give you the fast answer, what you are trying to do is not possible in unity, this topic has been discussed to death and a solution was never found( it is also unlikely that unity will ever push this feature due to how their stencil pass is implemented)

    some workaround might be found with shaders but its increadibly convoluted and only works for 1 mask, multiple masks will mess with eachother, it doesnt hold up for a large scale project

    there are assets on the asset store trying to cater to this niche but if you go and read the reviews you will find that there are always tons of problems that happen mainly when they try to use more than 1 mask, make mask apply only to certain objects, etc
     
    Last edited: Feb 15, 2023
    hellobody and Kaikoura_ like this.
  3. Kaikoura_

    Kaikoura_

    Joined:
    Nov 4, 2021
    Posts:
    5
    Oh wow,
    So in my case it´s probably better to use Unitys light system. It just seemed easier to do it with a mask.
    Thanks for saving me the time to try even longer!
     
    hellobody and flasker like this.
  4. Lorhus

    Lorhus

    Joined:
    Nov 15, 2020
    Posts:
    2
    I'm running into this exact same problem now. Pretty sad to see this is simply not possible.
    May I ask you how you planned to do this ? And did you find a solution to the mask alpha issue ?
     
  5. karderos

    karderos

    Joined:
    Mar 28, 2023
    Posts:
    376
    no, theres only silence for a solution for sprite mask with alpha
     
  6. Lorhus

    Lorhus

    Joined:
    Nov 15, 2020
    Posts:
    2
    Kaikoura_ said they could use the light system instead, I just want to know what they meant by that. I'm willing to use anything if it works, not necessarily a sprite mask