Skip to content

Add OpenXR XR_EXTX_overlay extension support#87522

Draft
CheesecakeCG wants to merge 8 commits intogodotengine:masterfrom
CheesecakeCG:XR-Overlay-Support
Draft

Add OpenXR XR_EXTX_overlay extension support#87522
CheesecakeCG wants to merge 8 commits intogodotengine:masterfrom
CheesecakeCG:XR-Overlay-Support

Conversation

@CheesecakeCG
Copy link
Copy Markdown
Contributor

@CheesecakeCG CheesecakeCG commented Jan 24, 2024

I took a shot at adding support for the XR_EXTX_overlay extension based on GodotVR/godot_openxr_for_godot_3.x#101. This should allow Godot to be used to create overlays for Monado (and maybe other OpenXR runtimes?).

I was not able to get it working, Monado still treats Godot games as normal apps when using this. This also still needs:

  • The ability to detect when the application becomes invisible
  • To be exposed to GDScript
  • To be exposed the project settings.

This is my first time adding a feature to Godot or really writing C++, so I've probably missed something else too.

Comment thread modules/openxr/extensions/openxr_overlay_extension.cpp Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.h Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.h Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.h Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.cpp Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.cpp Outdated
Comment thread modules/openxr/extensions/openxr_overlay_extension.cpp Outdated
Comment thread modules/openxr/openxr_api.cpp Outdated
@CheesecakeCG
Copy link
Copy Markdown
Contributor Author

For the layer placement setting, I'm still not sure if it's better to have two separate options here with presets or just show the one int? I think most of the time it makes the most sense to just always set it to the maximum or minimum (Listed as Front & Back), but there are definitely cases where setting it to a specific value does make more sense (starting multiple related overlays).
image

@CheesecakeCG CheesecakeCG force-pushed the XR-Overlay-Support branch 2 times, most recently from 55b0364 to 47f17dd Compare January 24, 2024 20:38
@SpookySkeletons
Copy link
Copy Markdown

SpookySkeletons commented Jan 25, 2024

Setting to zero places it on the same layer as the base in the compositor, whatever comes active lastly shows on top if two values are the same.

LOVR engine is already handling it as a single int, anything above 0 counts as overlay so that behavior is fine.

LOVR engine is now separating the toggle and the layer height values.

Really good time to specify because of how the layering works, it's more likely than not you want the application end user to be able to configure this int as it can very easily not be set to a preferable setting by the developer.

@BastiaanOlij
Copy link
Copy Markdown
Contributor

Cool! thanks for working on this @CheesecakeCG , I need to find some time to properly dive into it but looks like a good start.

@beniwtv
Copy link
Copy Markdown
Contributor

beniwtv commented Jan 30, 2024

I also had planned to implement this (but life got in the way), gonna have a look at this.

@beniwtv
Copy link
Copy Markdown
Contributor

beniwtv commented Apr 13, 2024

So, I now had some time to look at this, for now I also haven't been able to show the actual overlay, will try some more though.

@CheesecakeCG
Copy link
Copy Markdown
Contributor Author

I've pushed some of the changes I made a few weeks ago, and rebased it so I could check if it still works with OpenXR composition layers enabled at the same time (it does). I'm still figuring out how to restart the OpenXR interface with a different layer placement, but I haven't had much time to work on this.

@CheesecakeCG
Copy link
Copy Markdown
Contributor Author

So, I now had some time to look at this, for now I also haven't been able to show the actual overlay, will try some more though.

Make sure you're using an OpenXR runtime that implements the extension, so far I think Monado is the only one that does natively, but there's an API Layer for it:
https://github.com/LunarG/OpenXR-OverlayLayer

In my test project, I set the environment set to have a transparent sky and I have script that runs:

get_viewport().transparent_bg = true
get_viewport().use_xr = true

CheesecakeCG and others added 5 commits May 18, 2025 14:01
This adds support starting OpenXR sessions in overlay mode with the Monado OpenXR runtime.
Co-authored-by: A Thousand Ships <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants