Index · Object → RefCounted → XRInterface → MobileVRInterface

MobileVRInterface

Generic mobile VR implementation.

Class Description

This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect, you need a mobile phone with a gyroscope and accelerometer.

Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting eye_height.

You can initialize this interface as follows:

var interface = XRServer.find_interface("Native mobile")
if interface and interface.initialize():
	get_viewport().use_xr = true

Note: For Android, ProjectSettings.input_devices/sensors/enable_accelerometer, ProjectSettings.input_devices/sensors/enable_gravity, ProjectSettings.input_devices/sensors/enable_gyroscope and ProjectSettings.input_devices/sensors/enable_magnetometer must be enabled.

Properties

var display_to_lens: float = 4.0

The distance between the display and the lenses inside of the device in centimeters.

var display_width: float = 14.5

The width of the display in centimeters.

var eye_height: float = 1.85

The height at which the camera is placed in relation to the ground (i.e. XROrigin3D node).

var iod: float = 6.0

The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.

var k1: float = 0.215

The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect.

var k2: float = 0.215

The k2 lens factor, see k1.

var offset_rect: Rect2 = Rect2(0, 0, 1, 1)

Set the offset rect relative to the area being rendered. A length of 1 represents the whole rendering area on that axis.

var oversample: float = 1.5

The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance.

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.

var xr_play_area_mode: XRInterface.PlayAreaMode = 1
Inherited from XRInterface (4)

Methods

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

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