Commit a0451d2
committed
[visionOS] Implement visionOS XR module
The visionOS XR module only supports the Mobile renderer for now, the Forward+ renderer is not supported.
To use the visionOS XR module you must set the new 'application/app_role' export setting to Immersive. You can choose if you want passthrough or not by the new 'application/immersion_style' export option.
Then, initialize the visionOS VR module in a script:
```
var interface = XRServer.find_interface("visionOS")
if interface and interface.initialize():
var viewport : Viewport = get_viewport()
viewport.use_xr = true
viewport.vrs_mode = Viewport.VRS_XR
```
Implementation details:
- The visionOS platform now has two different execution paths implemented by the `GodotWindowScene` and `CompositorServicesImmersiveSpace` scenes in `app_visionos.swift`. The `application/app_role` export setting controls which scene is used.
- The visionOS VR interface tries to be as close to the OpenXR interface as possible, to keep main renderer code changes to a minimum. It adopts Compositor Services and ARKit APIs, which is how you render Metal content on visionOS.
- `XRInterface` has these new methods to spport the platform: `get_viewports_are_hdr()` (which avoids the sRGB conversion step on the tonemapper), `get_viewport_for_view()` (which provides individual viewports for each eye, which are larger than the render area when foveation is on).
- We obtain and set the head pose twice, once in `process()` so scripts can use it if needed, and another in `pre_render()`, so the pose is more accurate for rendering.
- The projection matrices returned by visionOS have an inverse depth correction applied (visionOS uses the [0, 1] z space, but Godot expects the [-1, 1] z space until the rendering step).
- The `rasterizationRateMap` (the structure that supports foveation on visionOS) is provided through the `get_vrs_texture()` function, using the new `XR_VRS_TEXTURE_FORMAT_RASTERIZATION_RATE_MAP` texture type. It's' passed through the renderer when creating passes/subpasses, to be ultimately set by the Metal driver.
- The Metal driver now needs to be able to set several viewports (one for each eye), so the DrawListInstructions `TYPE_SET_VIEWPORT` and TYPE_SET_SCISSOR have been replaced by `TYPE_SET_VIEWPORTS` and `TYPE_SET_SCISSORS`. If you pass a single viewport to the functions, they work as it used to.
- The skybox shader has a new `SKY_VERSION_BACKGROUND_MULTIVIEW_WRITE_DEPTH` variant, because visionOS in immersive mode needs to write appropriate depth values.
- Apple Vision Pro's' minimum supported near plane is `0.1`. There's a new editor warning emited by `XRCamera3D` if you set it to a lower value.
- `XROrigin3D` emits a new editor warning if you change the scale, as it causes the rendered depth texture values to be incongruent to what XR platforms expect to perform reprojection (this applies to OpenXR platforms as well).1 parent 06827c9 commit a0451d2
File tree
80 files changed
+2162
-223
lines changed- doc/classes
- drivers
- apple_embedded
- metal
- editor/export
- misc/dist/apple_embedded_xcode/godot_apple_embedded
- modules/visionos_xr
- doc_classes
- platform
- ios
- export
- visionos
- doc_classes
- export
- scene
- 3d/xr
- main
- servers
- rendering
- renderer_rd
- environment
- forward_mobile
- shaders/environment
- storage_rd
- xr
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
80 files changed
+2162
-223
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5336 | 5336 | | |
5337 | 5337 | | |
5338 | 5338 | | |
5339 | | - | |
| 5339 | + | |
| 5340 | + | |
| 5341 | + | |
| 5342 | + | |
5340 | 5343 | | |
5341 | 5344 | | |
5342 | 5345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
89 | 102 | | |
90 | 103 | | |
91 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
35 | 34 | | |
36 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | | - | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
0 commit comments