- Home /
Render a sprite only when it's on the parent but not other sprites.
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.
hey,
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.