title: How to write a Unity Shader that respects sorting layers?
body: <p>I want to sort my Sprites using Unitys sorting Layers. I attached a custom Shader to one of my Sprites. Sadly the Sprite with this shader always draws behind the other Sprites disrespecting the sorting layer. </p>
  
  <p>How to implement sorting layer respect in my Shader?</p>
  
  <p>That's the shader in question:
  Thanks in advance</p>
  
  
  
  <pre><code>Properties {
      _Color ("Color", Color) = (1,1,1,1)
      _MainTex ("Main Tex (RGBA)", 2D) = "white" {}
      _Progress ("Progress", Range(0.0,1.0)) = 0.0
  }
  
  SubShader {
  
      Pass {
  
  CGPROGRAM
  #pragma vertex vert
  #pragma fragment frag
  #include "UnityCG.cginc"
  
  uniform sampler2D _MainTex;
  uniform float4 _Color;
  uniform float _Progress;
  
  struct v2f {
      float4 pos : POSITION;
      float2 uv : TEXCOORD0;
  };
  
  v2f vert (appdata_base v)
  {
      v2f o;
      o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
      o.uv = TRANSFORM_UV(0);
  
      return o;
  }
  
  half4 frag( v2f i ) : COLOR
  {
      half4 color = tex2D( _MainTex, i.uv);
      float a = color.a;
      if(i.uv.y &lt; _Progress){
      color = _Color;
      } 
      color.a = a;
      return color;
  }
  
  ENDCG
  
      }
  }
  
  }
  </code></pre>
  
  <p>I know that i need to set some tags like this, but i can't find a proper reference and trial and error lead to nothing:</p>
  
  <pre><code>Tags { "Queue"="Overlay+1" }
  ZTest Off
  Blend SrcAlpha OneMinusSrcAlpha
  Lighting Off
  ZWrite On
  </code></pre>