I try to just show the Depth Texture in a post effect, on most devices it’s working, but on some devices like HTC One I get only a black texture. Is there another reason than the shader that this is not working on some devices?
Thanks!
Shader code:
Pass{
Tags{
"Queue"="Geometry"
"IgnoreProjector"="True"
"RenderType"="Opaque"
}
//cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "unityCG.cginc"
sampler2D _CameraDepthTexture;
half4 _MainTex_TexelSize;
float4 _CurveParams;
struct vertexInput{
float4 texcoord : TEXCOORD0;
float4 vertex : POSITION;
};
struct vertexOutput{
float4 pos : SV_POSITION;
float4 texcoord : TEXCOORD0;
};
vertexOutput vert(vertexInput v) {
vertexOutput o;
o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
o.texcoord.xy = v.texcoord.xy;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0)
o.texcoord.xy = o.texcoord.xy * half2(1,-1)+half2(0,1);
#endif
return o;
}
fixed4 frag(vertexOutput i) : SV_Target
{
float depth = UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, i.texcoord));
depth = Linear01Depth(depth);
return saturate(depth);
}
ENDCG
}