Quad layer on top of everything?

Hi,
I am experimenting with quad layers for making a UI panel in the scene. I had read that the layers are drawn in the order that they’re submitted in xrEndFrame(), so first the projection layer, then the quad, but it really struck me when I saw it in practice: The quad layer was being rendered on top of everything, even scene objects (e.g. my rendered hands) that were virtually closer to my eyes than the panel. Needless to say, it wasn’t impressive :slight_smile: Did I expect too much?

So my question is, what are some proper ways to deal with this “problem”? I’m also submitting depth images with the projection layer views (using XR_KHR_composition_layer_depth), is this supposed to help? Maybe I have a bug there that prevents it from working correctly?

Thanks in advance!

If you are using SteamVR, I believe having a quad layer as the first one is broken in the runtime. Regardless, it will only do alpha blending, so the layer below will only be visible where the top layer has cutouts in its alpha channel. It won’t do depth composition unless you have an extension like XR_FB_composition_layer_depth_test (which is only supported on Metas mobile runtime).

Hm, then I suppose a common working alternative would be to have textured quads as part of the world objects?

Yeah, that’s usually the best option. The only real benefit of using composition layers is improved UI quality, since the compositor can sample the texture taking reprojection and lens distortion into account.

I see, ok then. Thank you @Rectus !

So the key word here is that there is no “depth testing” for quad rendering, it’s using “painters algorithm” instead. Depth testing of composition layers is a fairly common request, I should ask around and see what people are thinking these days.

2 Likes

Both Meta and Varjo have their own _composition_layer_depth_test extensions with complementing features. The Meta one allows setting the compare operation, while Varjo allows setting a depth range to perform testing at. Both features seem useful for an official extension.

I’ve partially implemented the Varjo extension in an API layer to allow depth testing for passthrough, and it’s a quick and simple way of showing the users hands in front of virtual content.