title: Write to the depth buffer in a Unity 3D unlit shader?
body: <p>I admit I'm a bit lost when it comes to shaders. Below is my unlit shader. What can I add to this to write to the depth buffer and depth texture? Also, am I doing anything wrong or unnecessary in this shader?</p>
  
  <pre><code>Shader "Unlit/Environment Texture" {
  Properties {
      _MainTex ("Base (RGB)", 2D) = "white" {}
      _MainTexBias ("Mip Bias (-1 to 1)", float) = -1
  }
  
  SubShader {
      Tags { "RenderType"="Opaque" }
  
      Lighting Off
      Fog { Mode off }
  
          Pass {  
              CGPROGRAM
                  #pragma vertex vert
                  #pragma fragment frag
  
                  #include "UnityCG.cginc"
  
                  struct appdata_t {
                      float4 vertex : POSITION;
                      float2 texcoord : TEXCOORD0;
                  };
  
                  struct v2f {
                      float4 vertex : SV_POSITION;
                      half2 texcoord : TEXCOORD0;
                  };
  
                  sampler2D _MainTex;
                  float4 _MainTex_ST;
                  half _MainTexBias;
  
                  v2f vert (appdata_t v)
                  {
                      v2f o;
                      o.vertex = UnityObjectToClipPos(v.vertex);
                      o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                      return o;
                  }
  
                  fixed4 frag (v2f i) : SV_Target
                  {
                      fixed4 col = tex2Dbias(_MainTex, half4(i.texcoord.x,i.texcoord.y,0.0,_MainTexBias));
                      return col;
                  }
              ENDCG
          }
      }
  }
  </code></pre>