- Home /
Inverse Depth Masking 2D Sprites
I am prototyping a 2D game out with 4.3's new SpriteRenderer and pipeline.
I am trying to achieve the following effect:
I have a hidden "ground" layer that only appears once the character comes within a certain vicinity to it
The character has attached to it, a circular sprite that will act as this "cutout" effect
I ran across this post, that had a sort of "similar" look - http://forum.unity3d.com/threads/139858-Depth-Mask-with-Blending-Edge - but instead of having the world outside of the circle desaturated, it would be hidden; and the sprites within the circle would be shown.
Here is what I hope to accomplish (first: "ground" elements, second: red box = the clipping mesh, third: inverse mask result)
I have searched and read many forums/answers posts and unfortunately couldn't find anything that helped me. I know I will need to use a shader or possibly multiple cameras with depth masking set. I tinkered with this a bit in multiple cameras and had no luck. All of the shaders I have seen for cutout are for 3D, and using them on a 2D sprite complains in Unity.
Any help would be very welcome. Thanks!
Some more insights to this:
I was able to mask in/out at a certain alpha in a shader, however this gives the "opposite" effect of what I want.
I have a plane masking the part of the level which should be 'hidden' at the start
A mesh that overlays this plane should then un-mask and therefore 'show' the part of the level behind it
Is this at all possible with shaders, or does a 2-camera setup have to be done in tandem with shaders?
Your answer
Follow this Question
Related Questions
Rect Mask 2D won't update if I move 0 Answers
unity2d camera switch color palette with radical transition effect 0 Answers
How to implement a movable (!) 2D mask? 2 Answers
How to make a dynamic fog of war for a 2d maze? 1 Answer
2d lighting effect 1 Answer