Log in or register to post comments

Depthbuffer show backside of cylinder target

September 5, 2019 - 11:36pm #1

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

AttachmentSize
Image icon back-buffer-issue.png107.64 KB

Depthbuffer show backside of cylinder target

September 20, 2019 - 7:43am #2

I found that switching shader for the cylinder-target from the default "unlit" to a "standard" shader fixed my problem.

Log in or register to post comments