- Home /
2D Sprite Always Visible - Shader / Material not working (ZTest, ZWrite, Culling)
Hi,
I have been trying to add a material to my 2D sprite that I would like to always be visible on the screen, regardless of its z-position. No, I don't want to use a separate camera for other reasons specific to my game. I have read numerous times on different posts about using the following in my shader pass:
Cull Off
ZWrite Off
ZTest Always
All of the examples were for 3D games, and mine is 2D. I added that to my shader pass and it doesn't seem to be working correctly for me. The texture is rendered, it just doesn't appear in front of other objects like I would expect. Maybe there is a variant for 2D that I am missing? Any help on the matter would be greatly appreciated. If any clarification is needed, please comment so.
— Ty
Have you seen these? 1. https://answers.unity.com/questions/26486/display-complex-object-when-it-is-behind-the-wall.html
I'm also looking for a way to render parts of a 2D sprite in a flat colour when they're behind another object.
Answer by ValakhP · Oct 24, 2018 at 10:25 AM
Hello TyDoesStuff,
Well, for sorting sprites you actually don't need to go into shaders. There are settings for doing that. Look at sorting layer and sorting order of the sprite renderer. Just add another layer over all others and set it for your sprite.
Your answer
Follow this Question
Related Questions
Sprite Renderer Missing Material after running 1 Answer
SpriteManager 1 : Custom Material 1 Answer
Radial blur effect shader for textures to work with sprites? 1 Answer
Sprite Material help 0 Answers
How to fix this kind of shader error? 0 Answers