Hello,
I am trying to create a shader that when I attach it to the object, the object will always appear in front of any other object. I copied the standard shader that unity has and modified it a bit so that ZWrite
and Cull
are OFF and ZTest
is set to Always. You can view the changes below and also the entire shader file here which is the entire standard shader Unity uses, plus my changes:
Shader "CustomShader"
{
Properties{...}
....
SubShader
{
Tags{....}
Cull Off
ZTest Always
ZWrite Off
}
....
SubShader
{
Tags{....}
Cull Off
ZTest Always
ZWrite Off
}
It works for the most part, however I am getting a weird issue where the faces are all appearing in front of each other. Here is an example where the camera is placed inside a sphere which has a texture attached to it. There is a gameobject in the scene that is a house which I’ve attached my shader to. The house appears to be in front of sphere all the time, however you notice that the faces of the houses are in front of each other. You can have a view of the issue through the link provided below.
I found a post on the answers forum here that has an answer that says to add the code below to avoid this issue:
SubShader {
Cull Off
Pass{
ZTest Greater
}
Pass{
ZTest Less
}
Pass{
ZTest Always
}
However adding this still did not resolve this issue. Any help would be greatly appreciated, and if there is anything else I can better explain please let me know!
Thanks.