I'm trying to add some sort of decals on top of the sprites, but I want to re-use the same sprite because of performance reasons. Currently I have a setup like so:
The planets have a stencil shader material on top of them so that they can be seen through the layer, but the background hides whatever is around the planet. This works quite well for singular objects and objects that aren't too near to each other. Of course when I try to put the square towards the right side of the planet, the other planet also renders it, because they're the same prefab.
What I want to do is to render the square (which is a child object of the planet on the left) only on its parent but nowhere else. Something like this:
I'm willing to try other methods but currently, I'm doing this with a stencil shader which only removes the first layer it comes across (even if did remove other layers this could also mean that the decals get removed too).
I've worked around the issue by keeping objects further apart (didn't really want to) but the question will stay because that's not really an answer.
What about using a "mask". I know there is for UI stuff, but maybe there also is for sprites.
I haven't been able to find any masks that work in that way (there's something close on assetstore but I'm not sure if it'll work like I want it to and I can't risk the money), this is already using a mask to do what I'm doing though. I have tried making sprite shader masks but they never seem to work the way I intended. If I ever get this working I'll most likely post an answer though.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
5 People are following this question.
Sprite Decal Blending At Same Z Depth
Shader for 2D Sprite "Always Rendered on Top" Problem
How to implement stencil shadows/shadow volumes
Shadows in my rendered "Portal" Don't Render
Stencil on iOS