openxr_hand_tracking.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. .. _doc_openxr_hand_tracking:
  2. The OpenXR hand tracking
  3. ========================
  4. Hand tracking is the process by which the position and orientation of the players hands are tracked,
  5. including the orientation of the players fingers.
  6. We can identify 3 categories of this:
  7. One, hand tracking through external sensors such as cameras.
  8. This is what Hololens, Quest, UltraLeap and similar devices do.
  9. This often results in very accurate tracking of all fingers of the players hands.
  10. Two, hand tracking through VR gloves.
  11. This method is still mostly experimental but is likely to gain popularity soon.
  12. Gloves often have good finger tracking capabilities but their real selling point is the ability to restrict movement.
  13. This allows the sensation of touch.
  14. Gloves are often also recognised as controllers and often will have additional controls such as buttons embedded.
  15. Three, inferred hand tracking.
  16. This has been the defacto approach since the early days of VR.
  17. As we know the player is holding a controller and we know the position of this controller,
  18. we can infer where to render the players hand.
  19. Fingers can be positioned based on the controls the player is interacting with.
  20. Many modern VR controllers have additional sensors to help determine finger positions on the controller.
  21. .. note::
  22. Traditionally inferred hand tracking has been the responsibility of the game.
  23. However the principles behind the action map have somewhat limited the viable options here.
  24. Valve is currently the only XR Runtime that has implemented inferred hand tracking as part of the hand tracking extension.
  25. There is an expectation that other XR Runtimes will follow this example in the near future.
  26. Until then we recommend that if your game depends on inferred hand tracking,
  27. to use the hand assets that are part of Godot XR Tools.
  28. Tracking through interaction profiles
  29. -------------------------------------
  30. Tracking the location and state of controllers are performed through interaction profiles.
  31. Bindings can be set within the :ref:`action map <doc_xr_action_map>`.
  32. However it is important to realise that in OpenXR controllers are bound to paths indicating the usage of these controllers.
  33. I.e. the controller held in the players left hand is bound to ``/user/hand/left``
  34. while the controller in the players right hand is bound to ``/user/hand/right``.
  35. And while not yet supported outside of the HTC tracker extension,
  36. it is likely OpenXR will be extended with paths such as ``/user/foot/left`` and ``/user/foot/right`` at some point.
  37. .. warning::
  38. This paradigm therefore begs the question what happens to a controller that is not being held by a user.
  39. There is no answer to this question yet, this is still being debated and the specification may change in the near future.
  40. The behavior is thus undefined and can be different for different platforms.
  41. The most common is that the controller will remain bound regardless of whether the player is actually holding the controller.
  42. However there are runtimes, such as the Quest, that can unbind a controller when it is not being held by the user.
  43. This may become the norm in the future and the expectation is that the action map system will be enhanced accordingly.
  44. The hand tracking extension
  45. ---------------------------
  46. OpenXR has an extension that exposes hand tracking functionality.
  47. This extension allows a game to request the hand skeleton with all bone positions for each hand.
  48. .. figure:: img/openxr_hand_skeleton.webp
  49. :align: center
  50. Copyright (c) 2017-2022, The Khronos Group Inc. SPDX-License-Identifier: CC-BY-4.0
  51. The above image shows the joints that have to be provided by each XR runtime that implements this extension.
  52. Currently Godot exposes this functionality through the :ref:`OpenXRHand <class_openxrhand>` node.
  53. This is a helper node that will retrieve the hand tracking data from OpenXR and apply it to a skeleton in Godot.
  54. You select either the left or right hand through the ``hand`` property on this node.
  55. The hand asset itself has to be provided by the developer and is thus separate from the OpenXRHand node.
  56. You set the ``hand_skeleton`` on the OpenXRHand node to the skeleton it needs to apply the tracking data to.
  57. If supported by the XR runtime you can also set the ``motion_range`` property to limit how far the hand can close.
  58. The skeleton for this asset has to have the following bones:
  59. .. list-table:: OpenXR hand skeleton
  60. :widths: 50 50
  61. :header-rows: 1
  62. * - Left hand
  63. - Right hand
  64. * - Palm_L
  65. - Palm_R
  66. * - Wrist_L
  67. - Wrist_R
  68. * - Thumb_Metacarpal_L
  69. - Thumb_Metacarpal_R
  70. * - Thumb_Proximal_L
  71. - Thumb_Proximal_R
  72. * - Thumb_Distal_L
  73. - Thumb_Distal_R
  74. * - Thumb_Tip_L
  75. - Thumb_Tip_R
  76. * - Index_Metacarpal_L
  77. - Index_Metacarpal_R
  78. * - Index_Proximal_L
  79. - Index_Proximal_R
  80. * - Index_Intermediate_L
  81. - Index_Intermediate_R
  82. * - Index_Distal_L
  83. - Index_Distal_R
  84. * - Index_Tip_L
  85. - Index_Tip_R
  86. * - Middle_Metacarpal_L
  87. - Middle_Metacarpal_R
  88. * - Middle_Proximal_L
  89. - Middle_Proximal_R
  90. * - Middle_Intermediate_L
  91. - Middle_Intermediate_R
  92. * - Middle_Distal_L
  93. - Middle_Distal_R
  94. * - Middle_Tip_L
  95. - Middle_Tip_R
  96. * - Ring_Metacarpal_L
  97. - Ring_Metacarpal_R
  98. * - Ring_Proximal_L
  99. - Ring_Proximal_R
  100. * - Ring_Intermediate_L
  101. - Ring_Intermediate_R
  102. * - Ring_Distal_L
  103. - Ring_Distal_R
  104. * - Ring_Tip_L
  105. - Ring_Tip_R
  106. * - Little_Metacarpal_L
  107. - Little_Metacarpal_R
  108. * - Little_Proximal_L
  109. - Little_Proximal_R
  110. * - Little_Intermediate_L
  111. - Little_Intermediate_R
  112. * - Little_Distal_L
  113. - Little_Distal_R
  114. * - Little_Tip_L
  115. - Little_Tip_R
  116. .. warning::
  117. The skeleton data returned from different XR runtimes are often not compatible which poses a problem for cross platform development.
  118. For instance both Microsoft and Meta runtimes base the skeleton on the actual hands of the player.
  119. These skeletons will thus conform to the size of the players hand.
  120. Contrast that to Valve where a fixed skeleton is used if inferred hand tracking is applied.
  121. We are still gathering experience on how best to deal with these differences in the platforms.
  122. When exporting to Meta Quest you need to enable the following setting:
  123. .. image:: img/xr_enable_handtracking.webp
  124. Body tracking
  125. -------------
  126. At the time of writing, OpenXR does not support body tracking as part of the core spec.
  127. We are expecting this to change in the near future as more and more body tracking solutions are hitting the market.
  128. For now the only option available here is through HTC trackers.
  129. There is an extension that becomes available if HTC trackers are supported by the XR runtime.
  130. These are fully exposed through the action map system.
  131. Godot has full support for these and you can setup the trackers in the action map.
  132. Each tracker is assigned a usage within the SteamVR interface.
  133. These are exposed through the following trackers:
  134. .. list-table:: HTC trackers
  135. :widths: 100
  136. :header-rows: 0
  137. * - /user/vive_tracker_htcx/role/handheld_object
  138. * - /user/vive_tracker_htcx/role/left_foot
  139. * - /user/vive_tracker_htcx/role/right_foot
  140. * - /user/vive_tracker_htcx/role/left_shoulder
  141. * - /user/vive_tracker_htcx/role/right_shoulder
  142. * - /user/vive_tracker_htcx/role/left_elbow
  143. * - /user/vive_tracker_htcx/role/right_elbow
  144. * - /user/vive_tracker_htcx/role/left_knee
  145. * - /user/vive_tracker_htcx/role/right_knee
  146. * - /user/vive_tracker_htcx/role/waist
  147. * - /user/vive_tracker_htcx/role/chest
  148. * - /user/vive_tracker_htcx/role/camera
  149. * - /user/vive_tracker_htcx/role/keyboard
  150. Some final words
  151. ----------------
  152. Hand tracking is an area that is still under active development and we are expecting improvements in the near future.
  153. The underlying principle that we're hoping will eventuate is that the action map will be used to handle interactions,
  154. while the hand tracking extension will primarily be a means for visualising the players hand.
  155. The hope here is that improvements to the OpenXR specification will ensure better portability between platforms.