By dmulvang
on Fri, 09/06/2019 - 06:36
I am reading out the depthbuffer in a shader (see code below). When looking at the result it seems that the backside of my cylinder target is drawn to the depth buffer, instead of the front side. (see attached image) Am I generating the texture coordinates (suv) correct?
Vertex shader: v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.screenPos = ComputeScreenPos(o.vertex);
Fragment shader: float2 suv = i.screenPos.xy / i.screenPos.w; float depth = tex2D(_CameraDepthTexture, suv).r; return fixed4(depth, 0, 0, 1);
-- Dag Magne
I found that switching shader
I found that switching shader for the cylinder-target from the default "unlit" to a "standard" shader fixed my problem.