Skip to content

OpenXR: Add support for render models extension #107388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

BastiaanOlij
Copy link
Contributor

@BastiaanOlij BastiaanOlij commented Jun 11, 2025

This PR adds support for the new XR_EXT_render_model and XR_EXT_interaction_render_model extensions introduced in OpenXR 1.1.49

These extensions, when enabled and supported, will give an application access to fully animated models of the controllers currently held by the users, including tracking data for these controllers.

This PR adds a new extension class called OpenXRRenderModelExtension that, when enabled, will keep track of all the render models detected by the XR runtime. This class also contains a number of lower level methods that allow custom consumption of the data and enables vendor extensions to register additional render models in the system.

The PR also adds two helper nodes, OpenXRRenderModels and OpenXRRenderModel that makes the render models logic easily accessible. A user simply adds the OpenXRRenderModels as a child node of the `XROrigin3D`` node to make the system work.

Documentation PR can be found here: godotengine/godot-docs#11014
Demo project that uses this feature: https://github.com/BastiaanOlij/godot-xr-flynn-demo

Note: implementations in runtimes are still locked preventing the general public from using these features, but support should be rolling out for headsets very soon.

Contributed by Khronos Group through the Godot Integration Project

Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I did a quick skim of the code, and this is looking great! I only had a handful of minor comments

Copy link
Contributor

@devloglogan devloglogan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick scan through the docs, planning to take a look through the rest tomorrow! 🙂

@BastiaanOlij BastiaanOlij force-pushed the openxr_render_models_ext branch from 6784e2d to 1ba9394 Compare June 13, 2025 07:45
Comment on lines 347 to 377
Vector<const char *> supported_gltf_extensions = {
"KHR_lights_punctual",
"KHR_materials_pbrSpecularGlossiness",
"KHR_texture_transform",
"KHR_materials_unlit",
"KHR_materials_emissive_strength"
};

// Now find anything we support through plugins, which is a bit of a pain as they are converted to Strings
// and we need to convert them back.
Vector<CharString> char_extensions; // Just for temp storage of our c-strings.
Vector<Ref<GLTFDocumentExtension>> gltf_document_extensions = GLTFDocument::get_all_gltf_document_extensions();
for (Ref<GLTFDocumentExtension> &gltf_document_extension : gltf_document_extensions) {
Vector<String> supported_extensions = gltf_document_extension->get_supported_extensions();
for (String &extension : supported_extensions) {
char_extensions.push_back(extension.utf8());
}
}

// Now we can add them to our supported extensions list.
for (CharString &cs : char_extensions) {
supported_gltf_extensions.push_back(cs.get_data());
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect the gltf extensions to change during runtime? If not, we can populate the list once and just reuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't know for sure. I assume we could load this once and re-use but in theory there could be an order of execution issue as I believe plugins can add support for extensions.

That said, there isn't much overhead in this. It's not likely we would load more than a few individual models and the processing of the GLTF will far outweigh creating this list of extensions.

@BastiaanOlij BastiaanOlij force-pushed the openxr_render_models_ext branch 2 times, most recently from 4b818e3 to 6b96fe9 Compare June 18, 2025 11:29
@BastiaanOlij BastiaanOlij force-pushed the openxr_render_models_ext branch from 6b96fe9 to 60a9b88 Compare June 19, 2025 00:52
@BastiaanOlij
Copy link
Contributor Author

Got one more small fix coming in a few minutes after testing on Pico 4 ultra. Animatable child nodes can be any level deep so instead of get_node_or_null we need to use find_node, and as there is an extra cost to that I now cache those.

We had made that change some time ago but missed merging it into our main branch. Oops.

@BastiaanOlij BastiaanOlij force-pushed the openxr_render_models_ext branch from 60a9b88 to b65b367 Compare June 19, 2025 09:16
@BastiaanOlij
Copy link
Contributor Author

Ok, verified the fix works! Tested it on two separate XR runtimes that will have support for this soon. Hopefully I can share when it is made public soon.

Anyway, I think this can be merged now.

@Repiteo Repiteo modified the milestones: 4.6, 4.5 Jun 20, 2025
@Repiteo Repiteo merged commit c7d2ea4 into godotengine:master Jun 20, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 20, 2025

Thanks!

@BastiaanOlij BastiaanOlij deleted the openxr_render_models_ext branch June 21, 2025 10:31
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.

6 participants