Class reference
OpenXRCompositionLayer
Inherits Node3D
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
bool alpha_blend = falseEnables the blending the layer using its alpha channel. Can be combined with Viewport.transparent_bg to give the layer a transparent background.
Vector2i android_surface_size = Vector2i(1024, 1024)
Vector2i android_surface_size = Vector2i(1024, 1024)The size of the Android surface to create if use_android_surface is enabled.
bool enable_hole_punch = false
bool enable_hole_punch = falseEnables 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.
SubViewport layer_viewport
SubViewport layer_viewportThe SubViewport to render on the composition layer.
int sort_order = 1
int sort_order = 1The 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
int swapchain_state_alpha_swizzle = 3The 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
int swapchain_state_blue_swizzle = 2The 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)
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
int swapchain_state_green_swizzle = 1The 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
int swapchain_state_horizontal_wrap = 0The 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
int swapchain_state_mag_filter = 1The 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
float swapchain_state_max_anisotropy = 1.0The 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
int swapchain_state_min_filter = 1The 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
int swapchain_state_mipmap_mode = 2The 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
int swapchain_state_red_swizzle = 0The 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
int swapchain_state_vertical_wrap = 0The 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
bool use_android_surface = falseIf 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()
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
Vector2 intersects_ray(Vector3 origin, Vector3 direction) constReturns 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
bool is_natively_supported() constReturns 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
Perform nearest-neighbor filtering when sampling the texture.
FILTER_LINEAR = 1
Perform linear filtering when sampling the texture.
FILTER_CUBIC = 2
Perform cubic filtering when sampling the texture.
MIPMAP_MODE_DISABLED = 0
Disable mipmapping. Note: Mipmapping can only be disabled in the Compatibility renderer.
MIPMAP_MODE_NEAREST = 1
Use the mipmap of the nearest resolution.
MIPMAP_MODE_LINEAR = 2
Use linear interpolation of the two mipmaps of the nearest resolution.
WRAP_CLAMP_TO_BORDER = 0
Clamp the texture to its specified border color.
WRAP_CLAMP_TO_EDGE = 1
Clamp the texture to its edge color.
WRAP_REPEAT = 2
Repeat the texture infinitely.
WRAP_MIRRORED_REPEAT = 3
Repeat the texture infinitely, mirroring it on each repeat.
WRAP_MIRROR_CLAMP_TO_EDGE = 4
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
Maps a color channel to the value of the red channel.
SWIZZLE_GREEN = 1
Maps a color channel to the value of the green channel.
SWIZZLE_BLUE = 2
Maps a color channel to the value of the blue channel.
SWIZZLE_ALPHA = 3
Maps a color channel to the value of the alpha channel.
SWIZZLE_ZERO = 4
Maps a color channel to the value of zero.
SWIZZLE_ONE = 5
Maps a color channel to the value of one.