Sprite Mask & Mesh Renderer overlap issue

Hi,

I have an issue on masking a 2D sprite properly in 3D environment. For some reason the mesh renderer messes with the mask making sprite visible. See the below pictures that I hope make the issue clearer. I’ve run out of ideas on how to fix this. I have tried group sorting and fiddling with custom layers on the mask, but no avail.

To explain the picture below. The light green space is where the background meshrenderer exists. If this is not in the background sprite mask behaves correctly masking the sprite inside the card as shown on the right picture.

My version of unity is 2019.4.21f1. If that makes any difference. I’d rather not update unless absolutely necessary as there is always a risk of stuff exploding…

thank you in advance

Why didnt you make the 2D sprites in the 2D preset?

Hi, Sorry but I don’t understand the question. Could you elaborate on what you mean by “2D preset”?

Hi all, just giving this post a pump, as I still have this issue and am no closer to fixing it…

did you try sprite renderer instead of mesh renderer

can also try putting the mask inside a sorting group so it only affects things in that sorting group

Hi, rarac

The sprite mask is in fact inside a sorting group. I took a couple of new images that I hope make it more clear.

The background is a 3D object, hence the mesh renderer. The card root (3th image) has several spriterenderers inside of it and the sorting group is in the root Card gameobject. The card has several sprite renderers and a mask (4th image) and the sprite it should affecting (5th image)

Now what I do know is that the mask issue has something to do with materials used. I did manage to get the card to work properly if I used some custom materials with custom shaders on gameobjects, but replacing all like this is a lot of work and some 3D meshes use more complex material schemes. I should be able to get this to work by only editing the card not all other gameobjects around it…

My solution for now is quite ugly. I just make the images smaller, instead of relying on the mask to do its job. I just wonder whether this might be a bug in unity that is solved if I update to a newer version. Currently working on 2019.4.22f1…

7010671--829339--Screenshot 2021-04-06 at 15.07.00.png 7010671--829342--Screenshot 2021-04-06 at 15.07.23.png 7010671--829345--Screenshot 2021-04-06 at 15.08.04.png 7010671--829348--Screenshot 2021-04-06 at 15.08.35.png 7010671--829351--Screenshot 2021-04-06 at 15.08.44.png