Search Unity

[Released] Sprite Mask - masking system for Unity Sprite

Discussion in 'Assets and Asset Store' started by PoL231, Jan 21, 2015.

  1. HoldingSword

    HoldingSword

    Joined:
    Aug 9, 2017
    Posts:
    2
    Hi,In the 2017.2.0f3, if several Sprite Mask were used, the color would not appear in the black block.
     
  2. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Hello !!

    Does it work on Textmesh pro Unity UI?
    If not then please add supports for Textmesh pro unity UI !!
     
  3. HightTreeGames

    HightTreeGames

    Joined:
    Dec 2, 2017
    Posts:
    1
    Hi.
    Why do you use

    Code (CSharp):
    1. m = defaultSpriteMaterial;
    2. r.sharedMaterial = m;

    but not
    Code (CSharp):
    1.  
    2. r.sharedMaterial.shader = defaultSpriteMaterial.shader;
    3.  
    Your variant just delete mesh material, when i use it during runtime
     
  4. ury2ok2000

    ury2ok2000

    Joined:
    Dec 29, 2012
    Posts:
    46
    Hello, enjoy the asset and it works really well. Was wondering if there is a way to exclude a child object from being a part of the mask. The issue is the child is using a different stencil shader (its an outline of the object), so i need its material and shader to not be absormed into the mask. At runtime if i replace the material with the one i want i get the effect i want, however if in code i do the same it gets overwritten by the spritmask.

    vr
     
  5. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Hi,

    Just add SkipMasking component to your GameObject. SpriteMask will skip masking that object.

    Cheers!
     
  6. shovelware

    shovelware

    Joined:
    Sep 27, 2014
    Posts:
    1
    Does this still work? How would one use SpriteMask to affect an entire Canvas? It doesn't seem to function when simply adding the canvas game component to the list of Masked Objects on the Sprite Mask component.
     
  7. adey_sawafetah

    adey_sawafetah

    Joined:
    Jan 26, 2018
    Posts:
    2
    Hi

    Can I use custom mesh to mask particles
    like this:

     
  8. qkjosh

    qkjosh

    Joined:
    Nov 29, 2015
    Posts:
    32
    Hi there, I'm trying to use 2 inverted masks (custom mesh) on one background image, but I'm not sure how to set that up. It seems like the background image needs to either be a child of the mask or have a sprite masking component pointing to the mask - in either case, it only allows for a single mask.
     
  9. Jeps66

    Jeps66

    Joined:
    Jun 23, 2015
    Posts:
    9
    Hi
    I don't know if you're still active here, but if you are I could use a bit of advice. I used Sprite Mask in a project that I made in Unity 5.5.0 and it worked perfectly. Now I have to extend and update the project, and I can't get it to work in any later versions of Unity. Something strange is happening to the Spritemask material on the masked objects. The rectangle nest to the material has turned grey, and the sprites look they have a strange alpha or some sort of color mixed in. This is the case both in later versions of unity 5.5 and in 5.6 (where I have imported version 1.6 of the asset). When I open a clean project and import the asset the example scenes start out looking fine, but when I play the scene or touch any property on the sprite (like order in layer) the material changes color and things look wrong.
    Have you got any ideas as to what could be going on?

    Best regards

    Jeppe
     
  10. tabisharooj

    tabisharooj

    Joined:
    Nov 26, 2018
    Posts:
    2
    hi i want to use sprite mask nd my unity player settings is here ... but i cant get sprite mask as option when i want to add as an child of sprite renderer.. kindly give suggestions
     

    Attached Files:

    • kk.PNG
      kk.PNG
      File size:
      87.1 KB
      Views:
      393
  11. miya_omaru

    miya_omaru

    Joined:
    Aug 8, 2017
    Posts:
    3
    Hi,
    I`m using my own shader. I already added the code to supports Stencil buffer to my own shader.
    However, when running multiple instances, only one of the sprite masks will work.
    Can a custom shader mask multiple objects like the 'Sprites/Default' shader?

    ss197.png
     
  12. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Hi miya_omaru,

    The problem is that all 'bg' objects use the same material. Masking using Stencil buffer works on all Materials, so all objects using the same material are masked by one mask.
     
  13. miya_omaru

    miya_omaru

    Joined:
    Aug 8, 2017
    Posts:
    3
    Thank you very much for your quick reply!
    Well, the default behavior is automatically created new material and attached, right?
    How can I make my own shader behave like the default behavior if I edit the script?
     
  14. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    127
  15. Deadcow_

    Deadcow_

    Joined:
    Mar 13, 2014
    Posts:
    127
    Yeah, by the way is your asset able to handle blurred edges and alter alpha cutoff in runtime? I want to create something like dissolve feature, but for all sprites at a time. And also I use HDRP
     
  16. miya_omaru

    miya_omaru

    Joined:
    Aug 8, 2017
    Posts:
    3
    This was solved in another way.
    Thank you :)
     
  17. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    65
    hi there,
    im looking for inverted mask but with alpha blend on the edges. i would like that the mask edges will have some transparency in order to blend nicely with the other background texture.
    i would like to control the texture of the mask and the level of the blend.

    is this possible with your asset?
     
  18. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    65
    i see that someone already asked....
    did you manage to find a way to do this since?
     
    PoL231 likes this.
  19. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Hi ahacharoz,
    Unfortunately not. SpriteMask works on Stencil buffer which operates on two states per pixel: masked or not.
     
  20. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    65
    is there a non-stencil semi transparent mask ?
    on a non-UI situation? on a sprite?
    or is this something that is technically impossible?
    mmm...
     
  21. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    469
    Hi ! Will this work on a normal quad with a MeshRenderer on it?

    So just a normal texture-on-a-mesh in the scene? Thanks!
     
  22. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Yes it will work.
     
    Fattie likes this.
  23. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    469
    thanks for the prompt reply! @PoL231
     
  24. Aleolix

    Aleolix

    Joined:
    Jun 16, 2017
    Posts:
    2
    Hi there, bought this asset and it's great! I'm having one major problem however that I'm hoping you could help me with. I have objects using the SpriteMask script with custom meshes. They themselves work fine but when they are in the same layer and have the same order in layer one spritemask cuts out the other as you can see in the attached image. Any idea how to solve this?
     

    Attached Files:

  25. hdxpmc

    hdxpmc

    Joined:
    May 1, 2016
    Posts:
    43
    Hello
    We have bought the package, and it run well.
    We have problem: we want to apply outline shader to sprite. With sprite mask, the outline not appear at masked edge. How to make sprite mask run before outline shader (mask first, then outline later to have outline appear around mask)

    Best regards
     
  26. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Hi hdxpmc,

    I'm not sure exacly what do you mean, but if you want to have the outline shader after masking, then the renderer with the outline shader should have a sorting order bigger than the masked objects.

    I hope this will help.
     
  27. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    353
    Would this work to make a child object define a 'cutout' region of its parent?

    Lets say I have a full screen panel that is a solid black, and as a child of that I have an object that should define a cutout area. Wherever the child object overlaps its parent, the (solid black) parent should not be rendered.

    I see some old post about gradient / alpha support, is this now a thing?
     
  28. PoL231

    PoL231

    Joined:
    Jun 27, 2014
    Posts:
    148
    Something like this? This is done using inverted masking.

    Masking with alpha is not supported due to used masking technique... Stencil buffer
     
unityunity