openxr_settings.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. .. _doc_openxr_settings:
  2. OpenXR Settings
  3. ===============
  4. OpenXR has its own set of settings that are applied when OpenXR starts.
  5. While it is possible for OpenXR extensions implemented through Godot plugins to add additional settings,
  6. we will only discuss the settings in the core of Godot here.
  7. .. image:: img/openxr_settings.png
  8. Enabled
  9. -------
  10. This setting enables the OpenXR module when Godot starts.
  11. This is required when the Vulkan backend is used.
  12. For other backends you can enable OpenXR at any time by calling ``initialize`` on the :ref:`OpenXRInterface <class_openxrinterface>`.
  13. This also needs to be enabled to get access to the action map editor.
  14. You can use the ``--xr-mode on`` command line switch to force this to on.
  15. Default Action Map
  16. ------------------
  17. This specifies the path of the action map file that OpenXR will load and communicate to the XR Runtime.
  18. Form Factor
  19. -----------
  20. This specifies whether your game is designed for:
  21. - ``Head Mounted`` devices such as a Meta Quest, Valve Index, or Magic Leap,
  22. - ``Handheld`` devices such as phones.
  23. If the device on which you run your game does not match the selection here, OpenXR will fail to initialise.
  24. View Configuration
  25. ------------------
  26. This specifies the view configuration your game is designed for:
  27. - ``Mono``, your game provides a single image output. E.g. phone based AR;
  28. - ``Stereo``, your game provides stereo image output. E.g. head mounted devices.
  29. If the device on which you run your game does not match the selection here, OpenXR will fail to initialise.
  30. .. note::
  31. OpenXR has additional view configurations for very specific devices that Godot doesn't support yet.
  32. For instance, Varjo headsets have a quad view configuration that outputs two sets of stereo images.
  33. These may be supported in the near future.
  34. Reference Space
  35. ---------------
  36. Within XR all elements like the player's head and hands are tracked within a tracking volume.
  37. At the base of this tracking volume is our origin point, which maps our virtual space to the real space.
  38. There are however different scenarios that place this point in different locations,
  39. depending on the XR system used.
  40. In OpenXR these scenarios are well defined and selected by setting a reference space.
  41. Local
  42. ^^^^^
  43. The local reference space places our origin point at the player's head by default.
  44. Some XR runtimes will do this each time your game starts, others will make the position persist over sessions.
  45. This reference space however does not prevent the user from walking away so you will need to detect if the user does so
  46. if you wish to prevent the user from leaving the vehicle they are controlling, which could potentially be game breaking.
  47. This reference space is the best option for games like flight simulators or racing simulators
  48. where we want to place the :ref:`XROrigin3D <class_xrorigin3d>` node where the player's head should be.
  49. When the user enacts the recenter option on their headset, the method of which is different per XR runtime,
  50. the XR runtime will move the :ref:`XRCamera3D <class_xrcamera3d>` to the :ref:`XROrigin3D <class_xrorigin3d>` node.
  51. The :ref:`OpenXRInterface <class_openxrinterface>` will also emit the ``pose_recentered`` signal
  52. so your game can react accordingly.
  53. .. Note::
  54. Any other XR tracked elements such as controllers or anchors will also be adjusted accordingly.
  55. .. Warning::
  56. You should **not** call ``center_on_hmd`` when using this reference space.
  57. Stage
  58. ^^^^^
  59. The stage reference space is our default reference space and places our origin point at the center of our play space.
  60. For XR runtimes that allow you to draw out a guardian boundary this location and its orientation is often set by the user.
  61. Other XR runtimes may decide on the placement of this point by other means.
  62. It is however a stationary point in the real world.
  63. This reference space is the best option for room scale games where the user is expected to walk around a larger space,
  64. or for games where there is a need to switch between game modes.
  65. See :ref:`Room Scale <doc_xr_room_scale>` for more information.
  66. When the user enacts the recenter option on their headset, the method of which is different per XR runtime,
  67. the XR runtime will not change the origin point.
  68. The :ref:`OpenXRInterface <class_openxrinterface>` will emit the ``pose_recentered`` signal
  69. and it is up to the game to react appropriately.
  70. Not doing so will prevent your game from being accepted on various stores.
  71. In Godot you can do this by calling the ``center_on_hmd`` function on the :ref:`XRServer <class_xrserver>`:
  72. - Calling ``XRServer.center_on_hmd(XRServer.RESET_BUT_KEEP_TILT, true)`` will move the :ref:`XRCamera3D <class_xrcamera3d>` node
  73. to the :ref:`XROrigin3D <class_xrorigin3d>` node similar to the ``Local`` reference space.
  74. - Calling ``XRServer.center_on_hmd(XRServer.RESET_BUT_KEEP_TILT, true)`` will move the :ref:`XRCamera3D <class_xrcamera3d>` node
  75. above the :ref:`XROrigin3D <class_xrorigin3d>` node keeping the player's height, similar to the ``Local Floor`` reference space.
  76. .. Note::
  77. Any other XR tracked elements such as controllers or anchors will also be adjusted accordingly.
  78. Local Floor
  79. ^^^^^^^^^^^
  80. The local floor reference space is similar to the local reference space as it positions the origin point where the player is.
  81. In this mode however the height of the player is kept.
  82. Same as with the local reference space, some XR runtimes will persist this location over sessions.
  83. It is thus not guaranteed the player will be standing on the origin point,
  84. the only guarantee is that they were standing there when the user last recentered.
  85. The player is thus also free to walk away.
  86. This reference space is the best option of games where the user is expected to stand in the same location
  87. or for AR type games where the user's interface elements are bound to the origin node
  88. and are quickly placed at the player's location on recenter.
  89. When the user enacts the recenter option on their headset, the method of which is different per XR runtime,
  90. the XR runtime will move the :ref:`XRCamera3D <class_xrcamera3d>` above the :ref:`XROrigin3D <class_xrorigin3d>` node
  91. but keeping the player's height.
  92. The :ref:`OpenXRInterface <class_openxrinterface>` will also emit the ``pose_recentered`` signal
  93. so your game can react accordingly.
  94. .. Warning::
  95. Be careful using this mode in combination with virtual movement of the player.
  96. The user recentering in this scenario can be unpredictable unless you counter the move when handling the recenter signal.
  97. This can even be game breaking as the effect in this scenario would be the player teleporting to whatever abstract location
  98. the origin point was placed at during virtual movement, including the ability for players teleporting into
  99. locations that should be off limits.
  100. It is better to use the Stage mode in this scenario and limit resetting to orientation only when a ``pose_recentered`` signal is received.
  101. .. Note::
  102. Any other XR tracked elements such as controllers or anchors will also be adjusted accordingly.
  103. .. Warning::
  104. You should **not** call ``center_on_hmd`` when using this reference space.
  105. Environment Blend Mode
  106. ----------------------
  107. The environment blend mode defines how our rendered output is blended into "the real world" provided this is supported by the headset.
  108. - ``Opaque`` means our output obscures the real world, we are in VR mode.
  109. - ``Additive`` means our output is added to the real world,
  110. this is an AR mode where optics do not allow us to fully obscure the real world (e.g. Hololens),
  111. - ``Alpha`` means our output is blended with the real world using the alpha output (viewport should have transparent background enabled),
  112. this is an AR mode where optics can fully obscure the real world (Magic Leap, all pass through devices, etc.).
  113. If a mode is selected that is not supported by the headset, the first available mode will be selected.
  114. .. Note::
  115. Some OpenXR devices have separate systems for enabling/disabling passthrough.
  116. From Godot 4.3 onwards selecting the alpha blend mode will also perform these extra steps.
  117. This does require the latest vendor plugin to be installed.
  118. Foveation Level
  119. ---------------
  120. Sets the foveation level used when rendering provided this feature is supported by the hardware used.
  121. Foveation is a technique where the further away from the center of the viewport we render content, the lower resolution we render at.
  122. Most XR runtimes only support fixed foveation, but some will take eye tracking into account and use the focal point for this effect.
  123. The higher the level, the better the performance gains, but also the more reduction in quality there is in the users peripheral vision.
  124. .. Note::
  125. **Compatibility renderer only**,
  126. for Mobile and Forward+ renderer, set the ``vrs_mode`` property on :ref:`Viewport <class_viewport>` to ``VRS_XR``.
  127. .. Warning::
  128. This feature is disabled if post effects are used such as glow, bloom, or DOF.
  129. Foveation Dynamic
  130. -----------------
  131. When enabled the foveation level will be adjusted automatically depending on current GPU load.
  132. It will be adjusted between low and the select foveation level in the previous setting.
  133. It is therefore best to combine this setting with foveation level set to high.
  134. .. Note::
  135. **Compatibility renderer only**
  136. Submit Depth Buffer
  137. -------------------
  138. If enabled an OpenXR supplied depth buffer will be used while rendering which is submitted alongside the rendered image.
  139. The XR runtime can use this for improved reprojection.
  140. .. Note::
  141. Enabling this feature will disable stencil support during rendering.
  142. Not many XR runtimes make use of this,
  143. it is advised to leave this setting off unless it provides noticeable benefits for your use case.
  144. Startup Alert
  145. -------------
  146. If enabled, this will result in an alert message presented to the user if OpenXR fails to start.
  147. We don't always receive feedback from the XR system as to why starting fails. If we do, we log this to the console.
  148. Common failure reasons are:
  149. - No OpenXR runtime is installed on the host system.
  150. - Microsoft's WMR OpenXR runtime is currently active, this only supports DirectX and will fail if OpenGL or Vulkan is used.
  151. - SteamVR is used but no headset is connected/turned on.
  152. Disable this if you support a fallback mode in your game so it can be played in desktop mode when no VR headset is connected,
  153. or if you're handling the failure condition yourself by checking ``OpenXRInterface.is_initialized()``.
  154. Extensions
  155. ----------
  156. This subsection provides access to various optional OpenXR extensions.
  157. Hand Tracking
  158. ^^^^^^^^^^^^^
  159. This enables the hand tracking extension when supported by the device used. This is on by default for legacy reasons.
  160. The hand tracking extension provides access to data that allows you to visualise the user's hands with correct finger positions.
  161. Depending on platform capabilities the hand tracking data can be inferred from controller inputs, come from data gloves,
  162. come from optical hand tracking sensors or any other applicable source.
  163. If your game only supports controllers this should be turned off.
  164. See the chapter on :ref:`hand tracking <doc_openxr_hand_tracking>` for additional details.
  165. Eye Gaze Interaction
  166. ^^^^^^^^^^^^^^^^^^^^
  167. This enables the eye gaze interaction extension when supported by the device used.
  168. When enabled we will get feedback from eye tracking through a pose situated between the user's eyes
  169. orientated in the direction the user is looking. This will be a unified orientation.
  170. In order to use this functionality you need to edit your action map and add a new pose action,
  171. say ``eye_pose``.
  172. Now add a new interaction profile for the eye gaze interaction and map the ``eye_pose``:
  173. .. image:: img/openxr_eye_gaze_interaction.webp
  174. Don't forget to save!
  175. Next add a new :ref:`XRController3D <class_xrcontroller3d>` node to your origin node
  176. and set its ``tracker`` property to ``/user/eyes_ext``
  177. and set its ``pose`` property to ``eye_pose``.
  178. Now you can add things to this controller node such as a raycast, and control things with your eyes.