Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What exactly does "Shared depth buffer" do?

Discussion in 'VR' started by optijapan, May 27, 2019.

  1. optijapan

    optijapan

    Joined:
    Nov 22, 2017
    Posts:
    11
    Hello!
    I am getting heavy rendering distortion and visual artifacts when the option at at XR Settings > Oculus >"Shared depth buffer" is enabled.
    It is enabled by default in newer Unity versions and disabling it fixes the issue but I would like to know what it is for.

    Can anyone throw me a bone please?

    Thank you!
     
  2. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
  3. ArminRigo42

    ArminRigo42

    Joined:
    Oct 29, 2022
    Posts:
    4
    Late answer: I may have an idea about why it sometimes causes heavy distortion (which is absolutely not clear from the official documentation). I think it's because with this option enabled, the driver takes the depth into account to correct for missing frames if your application doesn't produce the expected frame rate. This is done by moving parts of the image around, by more or less pixels depending on the depth (pixels that are far away move less than nearby pixels when your head moves sideways).

    This is only an approximation, though. It can lead to heavy distortion in some cases---with low FPS, and particularly if the depth buffer is locally incorrect. For example, I have a dialog box that is a standard world-space UI canvas; half of it is "supported" by a thin panel (a box) being drawn behind, while the other half is not. In this case, the depth buffer ends up correct for the supported part but not for the unsupported one (because Unity's UI doesn't write to the depth buffer, with the default shaders). As a result, when we look at that dialog box and move our head slightly sideways, the dialog box gets completely distorted.

    I guess I could reduce the impact of this particular case by writing to the depth or by extending the supporting panel, but I also think that some wobbly effects will always remain (e.g. the borders of the panel wobble to some degree anyway, which I think is due to the high difference between the depth value of one pixel and the next). It's just not a good idea in some applications.