Shader "Hidden/yum_food/DepthBlit" { // Reads from depth texture and outputs linearized depth to color Properties { _MainTex ("", 2D) = "white" {} } SubShader { Cull Off ZWrite Off ZTest Always Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" sampler2D _DepthTex; struct v2f { float4 pos : SV_POSITION; float2 uv : TEXCOORD0; }; v2f vert(float4 vertex : POSITION, float2 uv : TEXCOORD0) { v2f o; o.pos = UnityObjectToClipPos(vertex); o.uv = uv; return o; } float4 frag(v2f i) : SV_Target { float rawDepth = tex2D(_DepthTex, i.uv).r; // Orthographic depth is already linear. // We just need to handle the platform-specific Z-buffer direction. #if defined(UNITY_REVERSED_Z) return 1.0 - rawDepth; #else return rawDepth; #endif } ENDCG } } }