Skip to content

OpenXR: Add support for spatial entities image tracking - #123275

Open
BastiaanOlij wants to merge 1 commit into
godotengine:masterfrom
BastiaanOlij:openxr_add_spatial_image_tracking
Open

BastiaanOlij wants to merge 1 commit into
godotengine:masterfrom
BastiaanOlij:openxr_add_spatial_image_tracking

Conversation

@BastiaanOlij

@BastiaanOlij BastiaanOlij commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

What problem(s) does this PR solve?

This PR implements the new OpenXR spatial entities image tracking API. When supported by the XR runtime, this allows an XR device to use its cameras to detect an image that has been supplied to the runtime before hand.
The location and orientation of the image is then communicated to the application and virtual content can be anchored to the real world image.

Additional information

The specification for this API can be found here: https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#XR_EXT_spatial_image_tracking

I have a PR with an update demo implementation here: https://github.com/BastiaanOlij/spatial-entities-demo/tree/test_image_tracking

One of the images the demo tracks is our Godot logo : )
image

I had some difficulty adding the meta data for the images into our project settings, ended up creating a resource to hold the data. As the image tracking is immutable, it won't register data right away when setting stuff but only when finally submitting the image database to OpenXR.

In the demo there is a small example script that lets you manage this data on a node yet still use the built-in logic, it actually works nicer than setting it in the project settings, but it's up to the dev to choose what they prefer.

@BastiaanOlij BastiaanOlij added this to the 4.8 milestone Sep 7, 2026
@BastiaanOlij BastiaanOlij self-assigned this Sep 7, 2026
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from ad3347f to 1a0d332 Compare September 21, 2026 10:54
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from 1a0d332 to cb08e54 Compare October 1, 2026 21:35
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from cb08e54 to 2c9d447 Compare October 16, 2026 14:55
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from 2c9d447 to 0bc3204 Compare October 29, 2026 15:48
@BastiaanOlij

Copy link
Copy Markdown
Contributor Author

Finally got this working, just need a little cleanup and a few cross the t's and dot the i's thingies.

@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from 0bc3204 to 982cc35 Compare November 2, 2026 08:28
@BastiaanOlij
BastiaanOlij marked this pull request as ready for review November 2, 2026 08:28
@BastiaanOlij
BastiaanOlij requested review from a team as code owners November 2, 2026 08:28
@BastiaanOlij BastiaanOlij modified the milestones: 4.8, 4.9 Nov 2, 2026
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch 3 times, most recently from 56d6a81 to b84acc3 Compare November 2, 2026 09:39
@BastiaanOlij BastiaanOlij mentioned this pull request Nov 12, 2026
3 of 4 tasks
Resource for storing image data that can be submitted to the spatial entities image tracking system.
</brief_description>
<description>
This resource stores image data that can be submitted to the spatial entities image tracking system. This allows you to configure the images that should be tracked within the editor. As image tracking data is immutable, image data is not submitted to OpenXR until tracking is initialized.

@dsnopek dsnopek Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know how this will appear on the website or the in-editor help, but there's nothing in the XML to indicate that images are added by setting image/x/image properties. We should probably include some examples here of how to make an image database in code via image_database.set("images/0/image", image)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or, actually, it would probably be better to add some functions that are intended to be used to add images from code? That would be easier to use and easier to document :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I'll work on that when I have a moment.

@dsnopek

dsnopek commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

I tested the demo project on Xreal Aura and it worked for me! My printer is out of ink, so I just brought up the Godot XR logo on each of my screens and saw the detected entity move around that way. After I'm got some new ink, I'll try it on a piece of paper :-)

@devloglogan devloglogan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will continue to review the implementation but here are some review notes on the docs for now. :)

Comment on lines +4 to +7
Spatial entity tracker for our spatial entity image tracking extension.
</brief_description>
<description>
Spatial entity tracker for our spatial entity image tracking extension. These trackers identify entities in our real space by recognizing an image.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Our spatial entity image tracking extension" seems like non-standard wording to me for the docs, I'd maybe swap it out for "the spatial entity image tracking OpenXR extension" .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We probably need to do similar changes to some of the other extensions as well, but I agree with this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dsnopek @m4gr3d @devloglogan something I chanced here too is:

Suggested change
Spatial entity tracker for our spatial entity image tracking extension.
</brief_description>
<description>
Spatial entity tracker for our spatial entity image tracking extension. These trackers identify entities in our real space by recognizing an image.
Spatial entity tracker for the OpenXR spatial entity image tracking extension.
</brief_description>
<description>
Spatial entity tracker for the [url=https://registry.khronos.org/OpenXR/specs/1.1/html/xrspec.html#XR_EXT_spatial_image_tracking]OpenXR spatial entity image tracking extension[/url]. These trackers identify entities in our real space by recognizing an image.

So add in a hyperlink to the documentation of the extension here. Might be better placed in the configuration class than the tracker class, but it was something that was raised a little while ago in the WG as an idea.

<method name="has_images">
<return type="bool" />
<description>
Returns [code]true[/code] if this object has valid image data. Note that there will always be one empty image entry that is ignored by this check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mega nit: I don't like how the method above this uses "Note:" and that this one uses "Note that", unsure if there's a convention here but I would make them uniform and make both of them use "Note:".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed it to the usual [b]Note:[/b] formatting.

Comment on lines +12 to +25
<method name="get_image_tracking_database" qualifiers="const">
<return type="RID" />
<param index="0" name="index" type="int" />
<description>
The RID of the image tracking database containing this image.
</description>
</method>
<method name="get_reference_image_index" qualifiers="const">
<return type="int" />
<param index="0" name="index" type="int" />
<description>
The index of the image within the image tracking database.
</description>
</method>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd explicitly state what the index parameter is supposed to be in these method descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, that might get lengthy, might be better for a documentation page..

@dsnopek

dsnopek commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

I finally have new printer ink, so I tested with a printed version of the godot_xr_logo.png and it worked, but much, much less reliably than when I have the image up on one of my monitors.

If I put it on a monitor, it'll be recognized after ~1 second, and if I move it to another monitor, it'll take ~1 second for the marker to move to the new location.

But on paper, it's very "hit or miss" with it sometimes recognizing it after ~1 second, but most frequently not recognizing it, or taking much longer before it decides it's seen it. Moving the paper will sometimes show the marker move, but it's only after ~1 second or longer - it doesn't "stick" to the image the way I recall marker tracking working

In any case, I don't think the low speed and accuracy of this is the fault of this PR, it's most likely on the OpenXR runtime's side

@devloglogan

Copy link
Copy Markdown
Contributor

Compared to @dsnopek's testing on printed images, my device (also an Aura) seemed to recognize the images pretty well, though on occasion it did seem to fail or take a bit. It does seem like the tracking doesn't update dynamically though, whenever a position is "updated" I think it's because it's just freeing and discovering a new tracker. Looking at marker tracking, I'm guessing something like this needs to be added?

@BastiaanOlij

Copy link
Copy Markdown
Contributor Author

Compared to @dsnopek's testing on printed images, my device (also an Aura) seemed to recognize the images pretty well, though on occasion it did seem to fail or take a bit. It does seem like the tracking doesn't update dynamically though, whenever a position is "updated" I think it's because it's just freeing and discovering a new tracker. Looking at marker tracking, I'm guessing something like this needs to be added?

Good call Logan, yes that is needed for dynamic tracking of images assuming it is supported by the runtime and assuming the image wasn't marked as static. I'll work on that tomorrow.

@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch 2 times, most recently from 8c416a6 to 1335705 Compare November 26, 2026 09:22
@BastiaanOlij
BastiaanOlij force-pushed the openxr_add_spatial_image_tracking branch from 1335705 to 4976bb2 Compare November 26, 2026 09:29
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.

3 participants