HoloprojStreaming/Assets/DepthOnlyShader.shader
2025-01-29 21:54:42 -08:00

36 lines
878 B
Plaintext

Shader "Custom/DepthOnly"
{
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float depth : TEXCOORD0;
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.depth = o.pos.z / o.pos.w;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
// Output depth as grayscale
return fixed4((i.depth / 2), (i.depth / 2), (i.depth / 2), 1.0);
}
ENDCG
}
}
FallBack "Diffuse"
}