Class reference

OpenXRCompositionLayer

Inherits Node3D

Experimental.

The parent class of all OpenXR composition layer nodes.

Description

Composition layers allow 2D viewports to be displayed inside of the headset by the XR compositor through special projections that retain their quality. This allows for rendering clear text while keeping the layer at a native resolution. Note: If the OpenXR runtime doesn't support the given composition layer type, a fallback mesh can be generated with a ViewportTexture, in order to emulate the composition layer.

Properties

bool alpha_blend = false

Enables the blending the layer using its alpha channel. Can be combined with Viewport.transparent_bg to give the layer a transparent background.

bool enable_hole_punch = false

Enables a technique called "hole punching", which allows putting the composition layer behind the main projection layer (i.e. setting sort_order to a negative value) while "punching a hole" through everything rendered by Redot so that the layer is still visible. This can be used to create the illusion that the composition layer exists in the same 3D space as everything rendered by Redot, allowing objects to appear to pass both behind or in front of the composition layer.

int sort_order = 1

The sort order for this composition layer. Higher numbers will be shown in front of lower numbers. Note: This will have no effect if a fallback mesh is being used.

int swapchain_state_alpha_swizzle = 3

The swizzle value for the alpha channel of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_blue_swizzle = 2

The swizzle value for the blue channel of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

Color swapchain_state_border_color = Color(0, 0, 0, 0)

The border color of the swapchain state that is used when the wrap mode clamps to the border. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_green_swizzle = 1

The swizzle value for the green channel of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_horizontal_wrap = 0

The horizontal wrap mode of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_mag_filter = 1

The magnification filter of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

float swapchain_state_max_anisotropy = 1.0

The max anisotropy of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_min_filter = 1

The minification filter of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_mipmap_mode = 2

The mipmap mode of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_red_swizzle = 0

The swizzle value for the red channel of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

int swapchain_state_vertical_wrap = 0

The vertical wrap mode of the swapchain state. Note: This property only has an effect on devices that support the OpenXR XR_FB_swapchain_update_state OpenGLES/Vulkan extensions.

bool use_android_surface = false

If enabled, an Android surface will be created (with the dimensions from android_surface_size) which will provide the 2D content for the composition layer, rather than using layer_viewport. See get_android_surface() for information about how to get the surface so that your application can draw to it. Note: This will only work in Android builds.

Methods

JavaObject get_android_surface()

Returns a JavaObject representing an android.view.Surface if use_android_surface is enabled and OpenXR has created the surface. Otherwise, this will return null. Note: The surface can only be created during an active OpenXR session. So, if use_android_surface is enabled outside of an OpenXR session, it won't be created until a new session fully starts.

Vector2 intersects_ray(Vector3 origin, Vector3 direction) const

Returns UV coordinates where the given ray intersects with the composition layer. origin and direction must be in global space. Returns Vector2(-1.0, -1.0) if the ray doesn't intersect.

bool is_natively_supported() const

Returns true if the OpenXR runtime natively supports this composition layer type. Note: This will only return an accurate result after the OpenXR session has started.

Constants

FILTER_NEAREST = 0

Enum: Filter

Perform nearest-neighbor filtering when sampling the texture.

FILTER_LINEAR = 1

Enum: Filter

Perform linear filtering when sampling the texture.

FILTER_CUBIC = 2

Enum: Filter

Perform cubic filtering when sampling the texture.

MIPMAP_MODE_DISABLED = 0

Enum: MipmapMode

Disable mipmapping. Note: Mipmapping can only be disabled in the Compatibility renderer.

MIPMAP_MODE_NEAREST = 1

Enum: MipmapMode

Use the mipmap of the nearest resolution.

MIPMAP_MODE_LINEAR = 2

Enum: MipmapMode

Use linear interpolation of the two mipmaps of the nearest resolution.

WRAP_CLAMP_TO_BORDER = 0

Enum: Wrap

Clamp the texture to its specified border color.

WRAP_CLAMP_TO_EDGE = 1

Enum: Wrap

Clamp the texture to its edge color.

WRAP_REPEAT = 2

Enum: Wrap

Repeat the texture infinitely.

WRAP_MIRRORED_REPEAT = 3

Enum: Wrap

Repeat the texture infinitely, mirroring it on each repeat.

WRAP_MIRROR_CLAMP_TO_EDGE = 4

Enum: Wrap

Mirror the texture once and then clamp the texture to its edge color. Note: This wrap mode is not available in the Compatibility renderer.

SWIZZLE_RED = 0

Enum: Swizzle

Maps a color channel to the value of the red channel.

SWIZZLE_GREEN = 1

Enum: Swizzle

Maps a color channel to the value of the green channel.

SWIZZLE_BLUE = 2

Enum: Swizzle

Maps a color channel to the value of the blue channel.

SWIZZLE_ALPHA = 3

Enum: Swizzle

Maps a color channel to the value of the alpha channel.

SWIZZLE_ZERO = 4

Enum: Swizzle

Maps a color channel to the value of zero.

SWIZZLE_ONE = 5

Enum: Swizzle

Maps a color channel to the value of one.

Source revision 4f5b14abade2
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.