Depth Texture has different result than ToggleDebugVisualization

  • Issue category: Depth
  • Issue Environment : On Device
  • ARDK version: 1.0.1
  • Unity Version: 2020.3 LTS
  • OS: Windows
  • Device Type: Android
  • IDE: Rider

I am following the Intermediate Depth Tutorial and I am finding that the depth map produced by the Depth Manager texture looks worse than the depth map produced when toggling on ToggleDebugVisualization. Here are two images showing the difference:

You can note that the first image is able to resolve the doorway behind the bottle, while the depth texture one to the right cannot resolve depth in the distance.

Why do these two versions diverge? What is ToggleDebugVisualization doing that makes it superior to the custom approach?

Hello Will, I’d like to get our team a little more information about your project so we can repro the issue to get this issue resolved as soon as possible. Can you please provide the below details?

Unity version:
Device type:
OS:
IDE:
Any other helpful info:
Thank you.

I updated the header to fill in those fields. The most critical thing is the screenshot which I shared which shows the difference.

I wanted to update with a solution. I looked at the existing shaders and augmented my frag function in the shader to look like:

fixed4 frag (v2f i) : SV_Target
{
     float2 depthUV = float2(i.depth_uv.x / i.depth_uv.z, i.depth_uv.y / i.depth_uv.z);
     float rawDepth = tex2D(_DepthTex, depthUV).r;

     float scaledDepth = rawDepth * (_DepthScaleMax - _DepthScaleMin) + _DepthScaleMin;

     float scaledDisparity = 1.0f / scaledDepth;
     float normDisparity = scaledDisparity / _MaxDisparity;

     return normDisparity;
}

And I am setting _MaxDisparity to 4 and _DepthScaleMax to 1 and _DepthScaleMin to 0.

This produces an effect more consistent with ToggleDebugVisualization.

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.