Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Android depth texture precision issue.

Discussion in 'Universal Render Pipeline' started by Antony-Blackett, Apr 14, 2020.

  1. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,623
    Hi, I'm using the depth texture in Shader Graph in URP for water FX. The depth texture on Android seems a lot less precise than on PC or iOS. Have I done something wrong or is there a setting somewhere I'm not aware of?

    I have made sure the shader precision settings are set to Float.

    I'm using Unity 2019.3.6f1
    URP 7.2.1

    PCAndiOSDepthPrecision.png AndroidDepthPrecision.png
    Screenshot 2020-04-14 at 11.50.26 AM.png
     
  2. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    610
    Same issue here, but not with shadergraph. Anyone from Unity ?
     
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,667
    Hi!
    Can you please report a bug?
    Thanks!
     
  4. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,187
    This was fixed some time ago: https://github.com/Unity-Technologi...2e137de#diff-40ff810ada5f915c5fc97a2a6a9acfcf

    For mobile devices depth should always be sampled using a float sampler, for improved accuracy, which is what this fix does. Perhaps this wasn't implemented in Shader Graph yet. If not, my guess is it will be in URP 7.4.x

    @jimmikaelkael For custom shaders, you can add
    #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" then use
    SampleSceneDepth(float 2uv)
    to sample the depth texture, instead of declaring the depth texture yourself.
     
  5. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    610
    Yes I think it's possible to build a repro project.

    Before I do this, there's this PR: https://github.com/Unity-Technologies/Graphics/pull/26
    Might be related ? not sure...
    I let you clarify if this PR is intended to fix this problem first.
     
  6. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    610
    This is what I'm doing already.
     
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,667
  8. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    1,187
    Hah, well that's strange. That's exactly what should fix the issue :p
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    610
    Tim-C likes this.
  10. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,524
  11. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    114
    The problem is that DeclareDepthTexture didn't have _FLOAT in the depth texture declaration. That's what my PR is fixing and solves the depth precision issue.

    The PR you've been linking to is a backport to 7.x.x which means it will be part of the next 7.x.x release. Next one scheduled is 7.4 and should arrive in May.
    https://github.com/Unity-Technologies/Graphics/pull/26
     
  12. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,524
    Thanks. I manually changed the _FLOAT declaration and the issue on Quest seems to persists? Can you confirm if the issue is also fixed on Android VR platform (specifically Quest)?
     
  13. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    114
    Oh that's interesting. You might be dealing with a separate issue than what I was addressing.
    Can you file a bug so the XR team can take a look and fix?
     
  14. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,524
    Case 1232794.
     
    Elvar_Orn likes this.
  15. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,623
    Hey, finally got around to updating URP to 7.4.1 and it did fix my issue.

    Thanks.
     
    Kronnect likes this.
unityunity