Search Unity

Shader to always show up, before lwrp worked 90% of the time, now works 40% of the time. How to?

Discussion in 'Shaders' started by wirelessdreamer, Apr 7, 2019.

  1. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    134
    Code (CSharp):
    1. Shader "Custom/AlwaysShow"
    2. {
    3.     Properties
    4.     {
    5.         _MainTex ("Texture", 2D) = "white" {}
    6.         _Color("Always visible color", Color) = (0,0,0,0)
    7.     }
    8.     SubShader
    9.     {
    10.         Tags { "Queue"="Transparent" }
    11.         LOD 100
    12.  
    13.         Pass{
    14.             Cull Off
    15.             ZWrite Off
    16.             Lighting Off
    17.             ZTest Always
    18.  
    19.             CGPROGRAM
    20.             #pragma vertex vert
    21.             #pragma fragment frag
    22.  
    23.             #include "UnityCG.cginc"
    24.      
    25.             struct appdata
    26.             {
    27.                 float4 vertex : POSITION;
    28.                 float2 uv : TEXCOORD0;
    29.             };
    30.  
    31.             struct v2f
    32.             {
    33.                 float2 uv : TEXCOORD0;
    34.                 float4 vertex : SV_POSITION;
    35.             };
    36.  
    37.             float4 _Color;
    38.  
    39.             v2f vert(appdata v)
    40.             {
    41.                 v2f o;
    42.                 o.vertex = UnityObjectToClipPos(v.vertex);
    43.                 return o;
    44.             }
    45.  
    46.             fixed4 frag(v2f i) : SV_Target
    47.             {
    48.                 return _Color;
    49.             }
    50.  
    51.             ENDCG
    52.         }
    53.     }
    54. }
    Often when the object is below the ground the object will dissapear, some times when behind other objects it disappears for part of the time its behind them. I haven't been able to ever find a solution to always make the object show up.

    On the material that uses this shader i've tried values from 500 to 4001 and seen no difference in behaviour, just for a complete test.

    I've also tried setting ZTest to Off
    Changing the Queue to Overlay :
    Tags { "Queue"="Overlay+1" }

    I don't care if I use this shader or not, but from the research i've done online I thought it was supposed to be how to make a magic always show this gameobject shader. I'm just trying to find a shader that won't have the objects sometimes dissapear.

    Thanks :)
     
    Last edited: Apr 7, 2019