Index · Object → RefCounted → XRInterface → OpenXRInterface

OpenXRInterface

Our OpenXR interface.

Class Description

The OpenXR interface allows Godot to interact with OpenXR runtimes and make it possible to create XR experiences and games.

Due to the needs of OpenXR this interface works slightly different than other plugin based XR interfaces. It needs to be initialized when Godot starts. You need to enable OpenXR, settings for this can be found in your games project settings under the XR heading. You do need to mark a viewport for use with XR in order for Godot to know which render result should be output to the headset.

Properties

var display_refresh_rate: float = 0.0

The display refresh rate for the current HMD. Only functional if this feature is supported by the OpenXR runtime and after the interface has been initialized.

var foveation_dynamic: bool = false

If true, enables dynamic foveation adjustment. The interface must be initialized before this is accessible. If enabled, foveation will automatically be adjusted between low and foveation_level.

var foveation_level: int = 0

The foveation level, from 0 (off) to 3 (high). The interface must be initialized before this is accessible.

var foveation_with_subsampled_images: bool = false

If true, enables subsampled images with foveation, which can provide a performance boost on Vulkan.

var render_target_size_multiplier: float = 1.0

The render size multiplier for the current HMD. Must be set before the interface has been initialized.

var vrs_min_radius: float = 20.0

The minimum radius around the focal point where full quality is guaranteed if VRS is used as a percentage of screen size.

Note: Mobile and Forward+ renderers only. Requires Viewport.vrs_mode to be set to Viewport.VRS_XR.

var vrs_strength: float = 1.0

The strength used to calculate the VRS density map. The greater this value, the more noticeable VRS is. This improves performance at the cost of quality.

Note: Mobile and Forward+ renderers only. Requires Viewport.vrs_mode to be set to Viewport.VRS_XR.

Inherited from XRInterface (4)

Methods

func get_action_sets() -> Array

Returns a list of action sets registered with Godot (loaded from the action map at runtime).

func get_available_display_refresh_rates() -> Array

Returns a list of display refresh rates supported by the current HMD. Only returned if this feature is supported by the OpenXR runtime and after the interface has been initialized.

func get_hand_joint_angular_velocity(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> Vector3

If handtracking is enabled, returns the angular velocity of a joint (joint) of a hand (hand) as provided by OpenXR. This is relative to XROrigin3D!

func get_hand_joint_flags(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> OpenXRInterface.HandJointFlags

If handtracking is enabled, returns flags that inform us of the validity of the tracking data.

func get_hand_joint_linear_velocity(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> Vector3

If handtracking is enabled, returns the linear velocity of a joint (joint) of a hand (hand) as provided by OpenXR. This is relative to XROrigin3D without worldscale applied!

func get_hand_joint_position(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> Vector3

If handtracking is enabled, returns the position of a joint (joint) of a hand (hand) as provided by OpenXR. This is relative to XROrigin3D without worldscale applied!

func get_hand_joint_radius(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> float

If handtracking is enabled, returns the radius of a joint (joint) of a hand (hand) as provided by OpenXR. This is without worldscale applied!

func get_hand_joint_rotation(hand: OpenXRInterface.Hand, joint: OpenXRInterface.HandJoints) -> Quaternion

If handtracking is enabled, returns the rotation of a joint (joint) of a hand (hand) as provided by OpenXR.

func get_hand_tracking_source(hand: OpenXRInterface.Hand) -> OpenXRInterface.HandTrackedSource

If handtracking is enabled and hand tracking source is supported, gets the source of the hand tracking data for hand.

func get_motion_range(hand: OpenXRInterface.Hand) -> OpenXRInterface.HandMotionRange

If handtracking is enabled and motion range is supported, gets the currently configured motion range for hand.

func get_session_state() -> OpenXRInterface.SessionState

Returns the current state of our OpenXR session.

func is_action_set_active(name: String) -> bool

Returns true if the given action set is active.

func is_eye_gaze_interaction_supported() -> bool

Returns the capabilities of the eye gaze interaction extension.

Note: This only returns a valid value after OpenXR has been initialized.

func is_foveation_supported() -> bool

Returns true if OpenXR's foveation extension is supported. The interface must be initialized before this returns a valid value.

Note: When using the Vulkan rendering driver, Viewport.vrs_mode must be set to Viewport.VRS_XR to support foveation.

func is_hand_interaction_supported() -> bool

Returns true if OpenXR's hand interaction profile is supported and enabled.

Note: This only returns a valid value after OpenXR has been initialized.

func is_hand_tracking_supported() -> bool

Returns true if OpenXR's hand tracking is supported and enabled.

Note: This only returns a valid value after OpenXR has been initialized.

func is_user_presence_supported() -> bool

Returns true if OpenXR's user presence extension is supported and enabled.

Note: This only returns a valid value after OpenXR has been initialized.

func is_user_present() -> bool

Returns true if system has detected the presence of a user in the XR experience.

func set_action_set_active(name: String, active: bool) -> void

Sets the given action set as active or inactive.

func set_cpu_level(level: OpenXRInterface.PerfSettingsLevel) -> void

Sets the CPU performance level of the OpenXR device.

func set_gpu_level(level: OpenXRInterface.PerfSettingsLevel) -> void

Sets the GPU performance level of the OpenXR device.

func set_motion_range(hand: OpenXRInterface.Hand, motion_range: OpenXRInterface.HandMotionRange) -> void

If handtracking is enabled and motion range is supported, sets the currently configured motion range for hand to motion_range.

Inherited from XRInterface (22)
func get_projection_for_view(view: int, aspect: float, near: float, far: float) -> Projection
func get_transform_for_view(view: int, cam_transform: Transform3D) -> Transform3D
func initialize() -> bool
func stop_passthrough() -> void
func trigger_haptic_pulse(action_name: String, tracker_name: StringName, frequency: float, amplitude: float, duration_sec: float, delay_sec: float) -> void
func uninitialize() -> void
Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

signal cpu_level_changed(sub_domain: int, from_level: int, to_level: int)

Informs the device CPU performance level has changed in the specified subdomain.

signal gpu_level_changed(sub_domain: int, from_level: int, to_level: int)

Informs the device GPU performance level has changed in the specified subdomain.

signal instance_exiting()

Informs our OpenXR instance is exiting.

signal pose_recentered()

Informs the user queued a recenter of the player position.

signal refresh_rate_changed(refresh_rate: float)

Informs the user the HMD refresh rate has changed.

Note: Only emitted if XR runtime supports the refresh rate extension.

signal session_begun()

Informs our OpenXR session has been started.

signal session_focussed()

Informs our OpenXR session now has focus, for example output is sent to the HMD and we're receiving XR input.

signal session_loss_pending()

Informs our OpenXR session is in the process of being lost.

signal session_stopping()

Informs our OpenXR session is stopping.

signal session_synchronized()

Informs our OpenXR session has been synchronized.

signal session_visible()

Informs our OpenXR session is now visible, for example output is sent to the HMD but we don't receive XR input.

signal user_presence_changed(is_user_present: bool)

Signal emitted when the user presence value changes.

Note: This signal will not be emitted during application startup and application shutdown. Developers should assume user presence is gained on startup and lost on shutdown.

Inherited from XRInterface (1)
signal play_area_changed(mode: int)
Inherited from Object (2)

Enums & Constants

enum SessionState
SESSION_STATE_UNKNOWN = 0

The state of the session is unknown, we haven't tried setting up OpenXR yet.

SESSION_STATE_IDLE = 1

The initial state after the OpenXR session is created or after the session is destroyed.

SESSION_STATE_READY = 2

OpenXR is ready to begin our session. session_begun is emitted when we change to this state.

SESSION_STATE_SYNCHRONIZED = 3

The application has synched its frame loop with the runtime but we're not rendering anything. session_synchronized is emitted when we change to this state.

SESSION_STATE_VISIBLE = 4

The application has synched its frame loop with the runtime and we're rendering output to the user, however we receive no user input. session_visible is emitted when we change to this state.

Note: This is the current state just before we get the focused state, whenever the user opens a system menu, switches to another application, or takes off their headset.

SESSION_STATE_FOCUSED = 5

The application has synched its frame loop with the runtime, we're rendering output to the user and we're receiving XR input. session_focussed is emitted when we change to this state.

Note: This is the state OpenXR will be in when the user can fully interact with your game.

SESSION_STATE_STOPPING = 6

Our session is being stopped. session_stopping is emitted when we change to this state.

SESSION_STATE_LOSS_PENDING = 7

The session is about to be lost. session_loss_pending is emitted when we change to this state.

SESSION_STATE_EXITING = 8

The OpenXR instance is about to be destroyed and we're exiting. instance_exiting is emitted when we change to this state.

enum Hand
HAND_LEFT = 0

Left hand.

HAND_RIGHT = 1

Right hand.

HAND_MAX = 2

Maximum value for the hand enum.

enum HandMotionRange
HAND_MOTION_RANGE_UNOBSTRUCTED = 0

Full hand range, if user closes their hands, we make a full fist.

HAND_MOTION_RANGE_CONFORM_TO_CONTROLLER = 1

Conform to controller, if user closes their hands, the tracked data conforms to the shape of the controller.

HAND_MOTION_RANGE_MAX = 2

Maximum value for the motion range enum.

enum HandTrackedSource
HAND_TRACKED_SOURCE_UNKNOWN = 0

The source of hand tracking data is unknown (the extension is likely unsupported).

HAND_TRACKED_SOURCE_UNOBSTRUCTED = 1

The source of hand tracking is unobstructed, this means that an accurate method of hand tracking is used, e.g. optical hand tracking, data gloves, etc.

HAND_TRACKED_SOURCE_CONTROLLER = 2

The source of hand tracking is a controller, bone positions are inferred from controller inputs.

HAND_TRACKED_SOURCE_MAX = 3

Represents the size of the HandTrackedSource enum.

enum HandJoints
HAND_JOINT_PALM = 0

Palm joint.

HAND_JOINT_WRIST = 1

Wrist joint.

HAND_JOINT_THUMB_METACARPAL = 2

Thumb metacarpal joint.

HAND_JOINT_THUMB_PROXIMAL = 3

Thumb proximal joint.

HAND_JOINT_THUMB_DISTAL = 4

Thumb distal joint.

HAND_JOINT_THUMB_TIP = 5

Thumb tip joint.

HAND_JOINT_INDEX_METACARPAL = 6

Index finger metacarpal joint.

HAND_JOINT_INDEX_PROXIMAL = 7

Index finger phalanx proximal joint.

HAND_JOINT_INDEX_INTERMEDIATE = 8

Index finger phalanx intermediate joint.

HAND_JOINT_INDEX_DISTAL = 9

Index finger phalanx distal joint.

HAND_JOINT_INDEX_TIP = 10

Index finger tip joint.

HAND_JOINT_MIDDLE_METACARPAL = 11

Middle finger metacarpal joint.

HAND_JOINT_MIDDLE_PROXIMAL = 12

Middle finger phalanx proximal joint.

HAND_JOINT_MIDDLE_INTERMEDIATE = 13

Middle finger phalanx intermediate joint.

HAND_JOINT_MIDDLE_DISTAL = 14

Middle finger phalanx distal joint.

HAND_JOINT_MIDDLE_TIP = 15

Middle finger tip joint.

HAND_JOINT_RING_METACARPAL = 16

Ring finger metacarpal joint.

HAND_JOINT_RING_PROXIMAL = 17

Ring finger phalanx proximal joint.

HAND_JOINT_RING_INTERMEDIATE = 18

Ring finger phalanx intermediate joint.

HAND_JOINT_RING_DISTAL = 19

Ring finger phalanx distal joint.

HAND_JOINT_RING_TIP = 20

Ring finger tip joint.

HAND_JOINT_LITTLE_METACARPAL = 21

Pinky finger metacarpal joint.

HAND_JOINT_LITTLE_PROXIMAL = 22

Pinky finger phalanx proximal joint.

HAND_JOINT_LITTLE_INTERMEDIATE = 23

Pinky finger phalanx intermediate joint.

HAND_JOINT_LITTLE_DISTAL = 24

Pinky finger phalanx distal joint.

HAND_JOINT_LITTLE_TIP = 25

Pinky finger tip joint.

HAND_JOINT_MAX = 26

Represents the size of the HandJoints enum.

enum PerfSettingsLevel
PERF_SETTINGS_LEVEL_POWER_SAVINGS = 0

The application has entered a non-XR section (head-locked / static screen), during which power savings are to be prioritized.

PERF_SETTINGS_LEVEL_SUSTAINED_LOW = 1

The application has entered a low and stable complexity section, during which reducing power is more important than occasional late rendering frames.

PERF_SETTINGS_LEVEL_SUSTAINED_HIGH = 2

The application has entered a high or dynamic complexity section, during which the XR Runtime strives for consistent XR compositing and frame rendering within a thermally sustainable range.

PERF_SETTINGS_LEVEL_BOOST = 3

The application has entered a section with very high complexity, during which the XR Runtime is allowed to step up beyond the thermally sustainable range.

enum PerfSettingsSubDomain
PERF_SETTINGS_SUB_DOMAIN_COMPOSITING = 0

The compositing performance within the runtime has reached a new level.

PERF_SETTINGS_SUB_DOMAIN_RENDERING = 1

The application rendering performance has reached a new level.

PERF_SETTINGS_SUB_DOMAIN_THERMAL = 2

The temperature of the device has reached a new level.

enum PerfSettingsNotificationLevel
PERF_SETTINGS_NOTIF_LEVEL_NORMAL = 0

The sub-domain has reached a level where no further actions other than currently applied are necessary.

PERF_SETTINGS_NOTIF_LEVEL_WARNING = 1

The sub-domain has reached an early warning level where the application should start proactive mitigation actions.

PERF_SETTINGS_NOTIF_LEVEL_IMPAIRED = 2

The sub-domain has reached a critical level where the application should start drastic mitigation actions.

enum HandJointFlags
HAND_JOINT_NONE = 0

No flags are set.

HAND_JOINT_ORIENTATION_VALID = 1

If set, the orientation data is valid, otherwise, the orientation data is unreliable and should not be used.

HAND_JOINT_ORIENTATION_TRACKED = 2

If set, the orientation data comes from tracking data, otherwise, the orientation data contains predicted data.

HAND_JOINT_POSITION_VALID = 4

If set, the positional data is valid, otherwise, the positional data is unreliable and should not be used.

HAND_JOINT_POSITION_TRACKED = 8

If set, the positional data comes from tracking data, otherwise, the positional data contains predicted data.

HAND_JOINT_LINEAR_VELOCITY_VALID = 16

If set, our linear velocity data is valid, otherwise, the linear velocity data is unreliable and should not be used.

HAND_JOINT_ANGULAR_VELOCITY_VALID = 32

If set, our angular velocity data is valid, otherwise, the angular velocity data is unreliable and should not be used.