- Home /
Shader that always renders in front but behind some objects
Hello! :D
Hope this question makes sense but is there a way to have a shader that always renders in front of another shader but always stays behind another shader? May sound strange but basically I need a shader that renders in between two other shaders.
I've attached a screen shot that may help. I want that green line material to always stay behind walls but always render in front of that button object.
Thanks for any help! :)
Answer by tanoshimi · Sep 22, 2013 at 08:54 PM
I'm note sure I quite understand what's going on the picture, but you can explicitly set the order in which shaders are rendered by assigning them to different render queues - http://docs.unity3d.com/Documentation/Components/SL-SubshaderTags.html
In addition to the built in "Geometry", "Transparent" etc., you can manually specify that a given shader should be rendered at Tags { "Queue" = "Geometry+10" }, which will be after all other normal objects, but before any transparent objects, for example. And you could have another shader with Tags { "Queue" = "Geometry+20" }, which will be rendered after the first. And a shader with Tags { "Queue" = "Geometry+15" } will be rendered between them.
Does that help?!
Hi tanoshimi, thanks for the help! :) It unfortunately didn't solve my problem but I figured out another way that kind of gets me the result I wanted. I just have a separate material that has ZTest set to Always and when needed, I apply that to objects that need to always be rendered on top of everything.