From ad551018904f13b8af0d1c4c2aa8380ac57de89a Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 13 Jan 2026 20:42:27 -0800 Subject: Impostors: fix depth capture --- DepthBlit.shader | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 DepthBlit.shader (limited to 'DepthBlit.shader') diff --git a/DepthBlit.shader b/DepthBlit.shader new file mode 100644 index 0000000..04187c2 --- /dev/null +++ b/DepthBlit.shader @@ -0,0 +1,52 @@ +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 + } + } +} -- cgit v1.2.3