Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Sprite Mask (Mask Visiable Outside Mask) Does not work

Discussion in '2D Experimental Preview' started by castor76, Oct 8, 2020.

  1. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Like the topic says, when you set Mask type to be Visible Outside Mask, it does not work as expected.

    It behaves just like None type.

    When set to Visible Inside Mask, It works as intended.

    Is this a bug or known issue? Using 2020.2b5
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    After some more experiments, I found that visible outside mask does not work when used with shader that writes depth value and the mask is behind the sprite.

    If I bring the mask before the sprite in z position then it seems to work.

    However, masking seems to work but it still writes to the depth buffer causing the other sprites behind to be not visible, even if they are set to none for mask setting.

    I think this is weird and should not behave this way. If pixel is masked out for whatever reason then masked out, clipped pixels should not write to depth buffer neither.

    Is this a bug?
     
  3. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    Here's a dev's comments on how the SpriteMask feature works:
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Exactly.

    So masked out pixels should be discarded completely without writing to the depth buffer even if the sprite shader is writing to the depth buffer. Because it should have been discarded due to the masked , stencil test.