Showing results for 
Search instead for 
Did you mean: 

OVROverlay not rendering in correct order with depth buffer

Level 2
Hi everyone, 

I'm trying to take advantage of the improved image clarity that OVROverlay provides compared to standard Unity UI to render interfaces.
I have a scene with multiple tablets that the user can grab and interact with, and since these can be moved arbitrarily using grab manipulation mechanics, I need to make sure that they a) intersect correctly with the scenario and b) intersect correctly with each other or at least can have their sorting order changed at runtime depending on which one is in front.

I already managed to make it work by using OVROverlayCanvas and having OVROverlays in underlay mode. But I cannot get the rendering to meet all conditions:

  • If I set overlay.noDepthBufferTesting to false, I get correct intersections between the two tablets but they will always render on top of the scenario. There is no depth interaction between the overlays and the 3D.
  • If I set overlay.noDepthBufferTesting to true, which the OVROverlayCanvas component does by default, I get nice intersection between the tablets and the scenario, even correct transparencies. The problem is that the tablets don't render correctly when they overlap because one gets rendered always before the other.
    Using compositionDepth doesn't fix anything because for some reason, the internal call OVRPlugin.EnqueueSetupLayer() only seems to work the first time the depth is assigned, but not on subsequent calls. I added code that calls OVRPlugin.EnqueueSetupLayer() to be able to change the depth but the render order remains the same. Ultimately this call goes to OVRP_1_28_0.ovrp_EnqueueSetupLayer2(), which returns Result.Success. Is this a bug?
  • As a last resort I tried to destroy and re-create the layer with the new depth value and this seems to work, but it's not something I want to add to production code 🙂

So basically my question is if there is a way to make overlays intersect with the scenario and at the same time intersect correclty with each other.

Kind regards,

   Enrique, VRMADA.

Level 2

This issue has been resolved in Oculus Integuration v28 (2021/04/29)!


Oculus Developer Release Notes: v28 


OVROverlay composition depth is now dynamic. If the value is changed at runtime, the layer's composition depth will now update properly.