Hi everyone, i experimented a bit with the depth texture. I noticed that if a mesh has Lines Topology then the lines won't be rendered to the depth texture. This is what the scene looks like: And this is what the depth texture looks like: In the wireframe shader i set ZTest to Always and ZWrite to On: Code (CSharp): Shader "Custom/Lines" { SubShader { Pass { ZTest Always ZWrite On CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct vertexInput { float4 vertex : POSITION; float3 texCoord : TEXCOORD0; }; struct vertexOutput { float4 pos : SV_POSITION; float3 texCoord : TEXCOORD0; }; vertexOutput vert(vertexInput input) { vertexOutput output; output.pos = UnityObjectToClipPos(input.vertex); output.texCoord = input.texCoord; return output; } float4 frag(vertexOutput input) : COLOR { return float4(1,1,1,1); } ENDCG } } } I simply render only the depth with post processing. This is the Post Processing shader: Code (CSharp): Shader "Post/DepthTexture" { SubShader { Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; v2f vert(appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = v.uv; return o; } sampler2D _CameraDepthTexture; float4 frag(v2f input) : SV_Target { float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, input.uv); depth = Linear01Depth(depth); return depth; } ENDCG } } } I enabled the depth texture for the camera and adjusted the far clipping plane to get this result. If the lines intersect with the cube the z culling works fine. Only the depth texture is missing the lines... So is it on purpose that the lines are not rendered to the depth texture? Can i somehow enable it? Thank you very much!
Unity's camera depth texture is generated with a separate pass of the scene using each shader's shadow caster pass. Your shader doesn't have a shadow caster pass, or a fallback which has one, so it doesn't get rendered into the depth texture.