summaryrefslogtreecommitdiffstats
path: root/DepthBlit.shader
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-01-17 17:35:13 -0800
committeryum <yum.food.vr@gmail.com>2026-01-17 17:37:06 -0800
commitb925b4b1bf79e3d6f930a4d799a7194673b62bde (patch)
tree1c45dbf95f66c4948ef6bcf64d9622b259fce624 /DepthBlit.shader
parentc6923a553c98da7805407fe1fbfdb6c69c8d7530 (diff)
Impostors: continue work on depth, getting closer
Diffstat (limited to 'DepthBlit.shader')
-rw-r--r--DepthBlit.shader11
1 files changed, 9 insertions, 2 deletions
diff --git a/DepthBlit.shader b/DepthBlit.shader
index 4094fe5..b2a512f 100644
--- a/DepthBlit.shader
+++ b/DepthBlit.shader
@@ -20,7 +20,7 @@ Shader "Hidden/yum_food/DepthBlit"
#include "UnityCG.cginc"
- sampler2D _DepthTex;
+ UNITY_DECLARE_DEPTH_TEXTURE(_DepthTex);
float _Near;
float _Far;
@@ -41,7 +41,14 @@ Shader "Hidden/yum_food/DepthBlit"
float4 frag(v2f i) : SV_Target
{
// 0 = near clip plane, 1 = far clip plane.
- return tex2D(_DepthTex, i.uv).r;
+ float rawDepth = SAMPLE_DEPTH_TEXTURE(_DepthTex, i.uv);
+ // Unity uses reversed-Z on most platforms: 1 at near, 0 at far.
+ // Flip to get linear 0-1 (0=near, 1=far) for orthographic cameras.
+ #if defined(UNITY_REVERSED_Z)
+ return 1.0 - rawDepth;
+ #else
+ return rawDepth;
+ #endif
}
ENDCG
}