Occluding of 2D Menus in XR

Godot Version

4.2

Question

When implementing menus in XR, typically you do something like hang a 2d viewport in 3D space, as shown here.

But what could do you do if you want to open a pause a menu in front of the player at any time, when there could be other geometry from the scene (e.g. a wall) occluding the menu?

In flatscreen of course I’d just use a viewport container but that doesn’t work here. I guess you could use the camera’s cull mask and render layers to hide the scene geometry and show the menu only, but is there another way?

You disable the menu’s depth test.

Works like a charm. For those of you wondering how to do this, if you are using the XRTools Viewport2Din3D, in the inspector rendering section add a material and set the “no depth test” flag.

While you are there, probably set unshaded on the material, disable receive shadows, maybe alpha scissor etc.

You will also need to set the laser material on XRToolsFunctionPointer to disable depth test or the menus will hide the laser pointer making it quite hard to operate them.

2 Likes

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