Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

WebXR: No longer require the WebXR Layers API

David Snopeka360b0e2d14b
diff --git a/modules/webxr/doc_classes/WebXRInterface.xml b/modules/webxr/doc_classes/WebXRInterface.xml
index 7ef2d30cebb..5b64e394f23 100644
--- a/modules/webxr/doc_classes/WebXRInterface.xml
+++ b/modules/webxr/doc_classes/WebXRInterface.xml
@@ -157,6 +157,11 @@
</method>
</methods>
<members>
+ <member name="disable_webxr_layers" type="bool" setter="set_disable_webxr_layers" getter="get_disable_webxr_layers">
+ If [code]true[/code], the WebXR Layers API won't be used even when the browser supports it.
+ Godot falls back to this mode automatically when the browser doesn't support WebXR Layers and the polyfill isn't in use.
+ This doesn't have any effect on the interface when already initialized.
+ </member>
<member name="enabled_features" type="String" setter="" getter="get_enabled_features">
A comma-separated list of features that were successfully enabled by [method XRInterface.initialize] when setting up the WebXR session.
This may include features requested by setting [member required_features] and [member optional_features], and will only be available after [signal session_started] has been emitted.
diff --git a/modules/webxr/godot_webxr.h b/modules/webxr/godot_webxr.h
index f7e7794c24f..5fd7b03dea9 100644
--- a/modules/webxr/godot_webxr.h
+++ b/modules/webxr/godot_webxr.h
@@ -56,6 +56,7 @@ extern void godot_webxr_initialize(
const char *p_required_features,
const char *p_optional_features,
const char *p_requested_reference_space_types,
+ bool p_disable_webxr_layers,
GodotWebXRStartedCallback p_on_session_started,
GodotWebXREndedCallback p_on_session_ended,
GodotWebXRFailedCallback p_on_session_failed,
@@ -70,6 +71,7 @@ extern bool godot_webxr_get_projection_for_view(int p_view, float *r_transform);
extern unsigned int godot_webxr_get_color_texture();
extern unsigned int godot_webxr_get_depth_texture();
extern unsigned int godot_webxr_get_velocity_texture();
+extern void godot_webxr_commit_render_target(unsigned int p_texture_id, int p_layer_count);
extern bool godot_webxr_update_input_source(
int p_input_source_id,
diff --git a/modules/webxr/native/library_godot_webxr.js b/modules/webxr/native/library_godot_webxr.js
index b56585653c9..707de5faf74 100644
--- a/modules/webxr/native/library_godot_webxr.js
+++ b/modules/webxr/native/library_godot_webxr.js
@@ -35,6 +35,7 @@ const GodotWebXR = {
session: null,
gl_binding: null,
+ disable_webxr_layers: false,
layer: null,
space: null,
frame: null,
@@ -88,24 +89,33 @@ const GodotWebXR = {
const new_view_count = (GodotWebXR.pose) ? GodotWebXR.pose.views.length : 1;
let layer = GodotWebXR.layer;
- // If the view count hasn't changed since creating this layer, then
- // we can simply return it.
- if (layer && GodotWebXR.view_count === new_view_count) {
+ if (layer && (GodotWebXR.disable_webxr_layers || GodotWebXR.view_count === new_view_count)) {
return layer;
}
- if (!GodotWebXR.session || !GodotWebXR.gl_binding || !GodotWebXR.gl_binding.createProjectionLayer) {
+ if (!GodotWebXR.session) {
return null;
}
const gl = GodotWebXR.gl;
- layer = GodotWebXR.gl_binding.createProjectionLayer({
- textureType: new_view_count > 1 ? 'texture-array' : 'texture',
- colorFormat: gl.RGBA8,
- depthFormat: gl.DEPTH_COMPONENT24,
- });
- GodotWebXR.session.updateRenderState({ layers: [layer] });
+ if (GodotWebXR.disable_webxr_layers) {
+ layer = new XRWebGLLayer(GodotWebXR.session, gl, {
+ antialias: false,
+ });
+ GodotWebXR.session.updateRenderState({ baseLayer: layer });
+ } else {
+ if (!GodotWebXR.gl_binding || !GodotWebXR.gl_binding.createProjectionLayer) {
+ return null;
+ }
+
+ layer = GodotWebXR.gl_binding.createProjectionLayer({
+ textureType: new_view_count > 1 ? 'texture-array' : 'texture',
+ colorFormat: gl.RGBA8,
+ depthFormat: gl.DEPTH_COMPONENT24,
+ });
+ GodotWebXR.session.updateRenderState({ layers: [layer] });
+ }
GodotWebXR.layer = layer;
GodotWebXR.view_count = new_view_count;
@@ -113,7 +123,7 @@ const GodotWebXR = {
},
getSubImage: () => {
- if (!GodotWebXR.pose) {
+ if (!GodotWebXR.pose || GodotWebXR.disable_webxr_layers) {
return null;
}
const layer = GodotWebXR.getLayer();
@@ -127,6 +137,215 @@ const GodotWebXR = {
return GodotWebXR.gl_binding.getViewSubImage(layer, GodotWebXR.pose.views[0]);
},
+ getViewport: () => {
+ if (!GodotWebXR.pose) {
+ return null;
+ }
+ if (GodotWebXR.disable_webxr_layers) {
+ const layer = GodotWebXR.getLayer();
+ if (layer === null) {
+ return null;
+ }
+ return layer.getViewport(GodotWebXR.pose.views[0]);
+ }
+ const subimage = GodotWebXR.getSubImage();
+ if (subimage === null) {
+ return null;
+ }
+ return subimage.viewport;
+ },
+
+ // Some custom WebGL code for blitting our eye textures to the
+ // framebuffer we get from WebXR.
+ shaderPrograms: {},
+ programInfos: {},
+ buffer: null,
+ sampler: null,
+ // Vertex shader source.
+ vsSource: `#version 300 es
+ const vec2 scale = vec2(0.5, -0.5);
+ const vec2 offset = vec2(0.5, 0.5);
+ in vec4 aVertexPosition;
+
+ out highp vec2 vTextureCoord;
+
+ void main () {
+ gl_Position = aVertexPosition;
+ vTextureCoord = aVertexPosition.xy * scale + offset;
+ }
+ `,
+ // Fragment shader source.
+ fsSource: `#version 300 es
+ precision highp float;
+
+ in highp vec2 vTextureCoord;
+
+ uniform sampler2D uSampler;
+
+ out vec4 fragColor;
+
+ void main() {
+ fragColor = texture(uSampler, vTextureCoord);
+ }
+ `,
+ // Fragment shader source for texture arrays (one layer per view).
+ fsSourceArray: `#version 300 es
+ precision highp float;
+ precision highp sampler2DArray;
+
+ in highp vec2 vTextureCoord;
+
+ uniform sampler2DArray uSampler;
+ uniform float uLayer;
+
+ out vec4 fragColor;
+
+ void main() {
+ fragColor = texture(uSampler, vec3(vTextureCoord, uLayer));
+ }
+ `,
+
+ initShaderProgram: (gl, vsSource, fsSource) => {
+ const vertexShader = GodotWebXR.loadShader(gl, gl.VERTEX_SHADER, vsSource);
+ const fragmentShader = GodotWebXR.loadShader(gl, gl.FRAGMENT_SHADER, fsSource);
+
+ const shaderProgram = gl.createProgram();
+ gl.attachShader(shaderProgram, vertexShader);
+ gl.attachShader(shaderProgram, fragmentShader);
+ gl.linkProgram(shaderProgram);
+
+ if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
+ GodotRuntime.error(`Unable to initialize the shader program: ${gl.getProgramInfoLog(shaderProgram)}`);
+ return null;
+ }
+
+ return shaderProgram;
+ },
+ loadShader: (gl, type, source) => {
+ const shader = gl.createShader(type);
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+ GodotRuntime.error(`An error occurred compiling the shader: ${gl.getShaderInfoLog(shader)}`);
+ gl.deleteShader(shader);
+ return null;
+ }
+
+ return shader;
+ },
+ initBuffer: (gl) => {
+ const positionBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
+ const positions = [
+ -1.0, -1.0,
+ 1.0, -1.0,
+ -1.0, 1.0,
+ 1.0, 1.0,
+ ];
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
+ return positionBuffer;
+ },
+ initSampler: (gl) => {
+ const sampler = gl.createSampler();
+ gl.samplerParameteri(sampler, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+ gl.samplerParameteri(sampler, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+ gl.samplerParameteri(sampler, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.samplerParameteri(sampler, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+ return sampler;
+ },
+ getProgramInfo: (gl, is_array) => {
+ const key = is_array ? 'array' : '2d';
+ if (!GodotWebXR.shaderPrograms[key]) {
+ const shaderProgram = GodotWebXR.initShaderProgram(gl, GodotWebXR.vsSource, is_array ? GodotWebXR.fsSourceArray : GodotWebXR.fsSource);
+ GodotWebXR.shaderPrograms[key] = shaderProgram;
+ GodotWebXR.programInfos[key] = {
+ program: shaderProgram,
+ attribLocations: {
+ vertexPosition: gl.getAttribLocation(shaderProgram, 'aVertexPosition'),
+ },
+ uniformLocations: {
+ uSampler: gl.getUniformLocation(shaderProgram, 'uSampler'),
+ uLayer: gl.getUniformLocation(shaderProgram, 'uLayer'),
+ },
+ };
+ }
+ return GodotWebXR.programInfos[key];
+ },
+ blitTexture: (gl, texture, is_array, layer) => {
+ const programInfo = GodotWebXR.getProgramInfo(gl, is_array);
+ if (GodotWebXR.buffer === null) {
+ GodotWebXR.buffer = GodotWebXR.initBuffer(gl);
+ }
+ if (GodotWebXR.sampler === null) {
+ GodotWebXR.sampler = GodotWebXR.initSampler(gl);
+ }
+ const texture_target = is_array ? gl.TEXTURE_2D_ARRAY : gl.TEXTURE_2D;
+
+ const orig_program = gl.getParameter(gl.CURRENT_PROGRAM);
+ gl.useProgram(programInfo.program);
+
+ const orig_vertex_array = gl.getParameter(gl.VERTEX_ARRAY_BINDING);
+ gl.bindVertexArray(null);
+ gl.bindBuffer(gl.ARRAY_BUFFER, GodotWebXR.buffer);
+ gl.vertexAttribPointer(programInfo.attribLocations.vertexPosition, 2, gl.FLOAT, false, 0, 0);
+ gl.enableVertexAttribArray(programInfo.attribLocations.vertexPosition);
+
+ gl.activeTexture(gl.TEXTURE0);
+ gl.bindTexture(texture_target, texture);
+ gl.bindSampler(0, GodotWebXR.sampler);
+ gl.uniform1i(programInfo.uniformLocations.uSampler, 0);
+ if (is_array) {
+ gl.uniform1f(programInfo.uniformLocations.uLayer, layer);
+ }
+
+ const blend_enabled = gl.getParameter(gl.BLEND);
+ if (blend_enabled) {
+ gl.disable(gl.BLEND);
+ }
+ const depth_test_enabled = gl.getParameter(gl.DEPTH_TEST);
+ if (depth_test_enabled) {
+ gl.disable(gl.DEPTH_TEST);
+ }
+ const cull_face_enabled = gl.getParameter(gl.CULL_FACE);
+ if (cull_face_enabled) {
+ gl.disable(gl.CULL_FACE);
+ }
+ const scissor_test_enabled = gl.getParameter(gl.SCISSOR_TEST);
+ if (scissor_test_enabled) {
+ gl.disable(gl.SCISSOR_TEST);
+ }
+ const stencil_test_enabled = gl.getParameter(gl.STENCIL_TEST);
+ if (stencil_test_enabled) {
+ gl.disable(gl.STENCIL_TEST);
+ }
+
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+
+ // Restore state.
+ gl.bindSampler(0, null);
+ gl.bindTexture(texture_target, null);
+ gl.disableVertexAttribArray(programInfo.attribLocations.vertexPosition);
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
+ gl.bindVertexArray(orig_vertex_array);
+ gl.useProgram(orig_program);
+ if (blend_enabled) {
+ gl.enable(gl.BLEND);
+ }
+ if (depth_test_enabled) {
+ gl.enable(gl.DEPTH_TEST);
+ }
+ if (cull_face_enabled) {
+ gl.enable(gl.CULL_FACE);
+ }
+ if (scissor_test_enabled) {
+ gl.enable(gl.SCISSOR_TEST);
+ }
+ if (stencil_test_enabled) {
+ gl.enable(gl.STENCIL_TEST);
+ }
+ },
+
getTextureId: (texture) => {
if (texture.name !== undefined) {
return texture.name;
@@ -234,8 +453,8 @@ const GodotWebXR = {
godot_webxr_initialize__deps: ['emscripten_webgl_get_current_context'],
godot_webxr_initialize__proxy: 'sync',
- godot_webxr_initialize__sig: 'viiiiiiiii',
- godot_webxr_initialize: function (p_session_mode, p_required_features, p_optional_features, p_requested_reference_spaces, p_on_session_started, p_on_session_ended, p_on_session_failed, p_on_input_event, p_on_simple_event) {
+ godot_webxr_initialize__sig: 'viiiiiiiiii',
+ godot_webxr_initialize: function (p_session_mode, p_required_features, p_optional_features, p_requested_reference_spaces, p_disable_webxr_layers, p_on_session_started, p_on_session_ended, p_on_session_failed, p_on_input_event, p_on_simple_event) {
GodotWebXR.monkeyPatchRequestAnimationFrame(true);
const session_mode = GodotRuntime.parseString(p_session_mode);
@@ -248,6 +467,8 @@ const GodotWebXR = {
const oninputevent = GodotRuntime.get_func(p_on_input_event);
const onsimpleevent = GodotRuntime.get_func(p_on_simple_event);
+ let disable_webxr_layers = !!p_disable_webxr_layers || typeof XRWebGLBinding === 'undefined';
+
const session_init = {};
if (required_features.length > 0) {
session_init['requiredFeatures'] = required_features;
@@ -293,24 +514,23 @@ const GodotWebXR = {
GodotWebXR.gl = gl;
gl.makeXRCompatible().then(function () {
- const throwNoWebXRLayersError = () => {
- throw new Error('This browser doesn\'t support WebXR Layers (which Godot requires) nor is the polyfill in use. If you are the developer of this application, please consider including the polyfill.');
- };
-
- try {
- GodotWebXR.gl_binding = new XRWebGLBinding(session, gl);
- } catch (error) {
- // We'll end up here for browsers that don't have XRWebGLBinding at all, or if the browser does support WebXR Layers,
- // but is using the WebXR polyfill, so calling native XRWebGLBinding with the polyfilled XRSession won't work.
- throwNoWebXRLayersError();
+ if (!disable_webxr_layers) {
+ try {
+ GodotWebXR.gl_binding = new XRWebGLBinding(session, gl);
+ } catch (error) {
+ console.log('WebXR: Unable to create XRWebGLBinding (disabling WebXR Layers): ', error); // eslint-disable-line no-console
+ disable_webxr_layers = true;
+ }
}
- if (!GodotWebXR.gl_binding.createProjectionLayer) {
- // On other browsers, XRWebGLBinding exists and works, but it doesn't support creating projection layers (which is
- // contrary to the spec, which says this MUST be supported) and so the polyfill is required.
- throwNoWebXRLayersError();
+ if (!disable_webxr_layers && !GodotWebXR.gl_binding.createProjectionLayer) {
+ console.log('WebXR: XRWebGLBinding.createProjectionLayer is missing (disabling WebXR Layers)'); // eslint-disable-line no-console
+ disable_webxr_layers = true;
+ GodotWebXR.gl_binding = null;
}
+ GodotWebXR.disable_webxr_layers = disable_webxr_layers;
+
// This will trigger the layer to get created.
const layer = GodotWebXR.getLayer();
if (!layer) {
@@ -389,6 +609,8 @@ const GodotWebXR = {
.catch((e) => { });
}
+ GodotWebXR.disable_webxr_layers = false;
+
GodotWebXR.session = null;
GodotWebXR.gl_binding = null;
GodotWebXR.layer = null;
@@ -419,13 +641,13 @@ const GodotWebXR = {
godot_webxr_get_render_target_size__proxy: 'sync',
godot_webxr_get_render_target_size__sig: 'ii',
godot_webxr_get_render_target_size: function (r_size) {
- const subimage = GodotWebXR.getSubImage();
- if (subimage === null) {
+ const viewport = GodotWebXR.getViewport();
+ if (viewport === null) {
return false;
}
- GodotRuntime.setHeapValue(r_size + 0, subimage.viewport.width, 'i32');
- GodotRuntime.setHeapValue(r_size + 4, subimage.viewport.height, 'i32');
+ GodotRuntime.setHeapValue(r_size + 0, viewport.width, 'i32');
+ GodotRuntime.setHeapValue(r_size + 4, viewport.height, 'i32');
return true;
},
@@ -504,6 +726,41 @@ const GodotWebXR = {
return GodotWebXR.getTextureId(subimage.motionVectorTexture);
},
+ godot_webxr_commit_render_target__proxy: 'sync',
+ godot_webxr_commit_render_target__sig: 'vii',
+ godot_webxr_commit_render_target: function (p_texture_id, p_layer_count) {
+ if (!GodotWebXR.session || !GodotWebXR.pose || !GodotWebXR.disable_webxr_layers) {
+ return;
+ }
+
+ const glLayer = GodotWebXR.getLayer();
+ const texture = GL.textures[p_texture_id];
+ if (glLayer === null || !texture) {
+ return;
+ }
+
+ const gl = GodotWebXR.gl;
+ const is_array = p_layer_count > 1;
+
+ const orig_framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
+ const orig_viewport = gl.getParameter(gl.VIEWPORT);
+
+ // Bind to WebXR's framebuffer.
+ gl.bindFramebuffer(gl.FRAMEBUFFER, glLayer.framebuffer);
+
+ // Drawn rather than blitted: with foveated rendering (visionOS) the reported
+ // viewports are in screen space and only rasterization goes through the rate map.
+ GodotWebXR.pose.views.forEach((view, view_index) => {
+ const viewport = glLayer.getViewport(view);
+ gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
+ GodotWebXR.blitTexture(gl, texture, is_array, view_index);
+ });
+
+ // Restore state.
+ gl.bindFramebuffer(gl.FRAMEBUFFER, orig_framebuffer);
+ gl.viewport(orig_viewport[0], orig_viewport[1], orig_viewport[2], orig_viewport[3]);
+ },
+
godot_webxr_update_input_source__proxy: 'sync',
godot_webxr_update_input_source__sig: 'iiiiiiiiiiiiiii',
godot_webxr_update_input_source: function (p_input_source_id, r_target_pose, r_target_ray_mode, r_touch_index, r_has_grip_pose, r_grip_pose, r_has_standard_mapping, r_button_count, r_buttons, r_axes_count, r_axes, r_has_hand_data, r_hand_joints, r_hand_radii) {
diff --git a/modules/webxr/webxr_interface.cpp b/modules/webxr/webxr_interface.cpp
index 63213196f21..c7798a48dd2 100644
--- a/modules/webxr/webxr_interface.cpp
+++ b/modules/webxr/webxr_interface.cpp
@@ -45,6 +45,8 @@ void WebXRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_enabled_features"), &WebXRInterface::get_enabled_features);
ClassDB::bind_method(D_METHOD("set_requested_reference_space_types", "requested_reference_space_types"), &WebXRInterface::set_requested_reference_space_types);
ClassDB::bind_method(D_METHOD("get_requested_reference_space_types"), &WebXRInterface::get_requested_reference_space_types);
+ ClassDB::bind_method(D_METHOD("set_disable_webxr_layers", "disable"), &WebXRInterface::set_disable_webxr_layers);
+ ClassDB::bind_method(D_METHOD("get_disable_webxr_layers"), &WebXRInterface::get_disable_webxr_layers);
ClassDB::bind_method(D_METHOD("is_input_source_active", "input_source_id"), &WebXRInterface::is_input_source_active);
ClassDB::bind_method(D_METHOD("get_input_source_tracker", "input_source_id"), &WebXRInterface::get_input_source_tracker);
ClassDB::bind_method(D_METHOD("get_input_source_target_ray_mode", "input_source_id"), &WebXRInterface::get_input_source_target_ray_mode);
@@ -57,6 +59,7 @@ void WebXRInterface::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "required_features", PROPERTY_HINT_NONE), "set_required_features", "get_required_features");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "optional_features", PROPERTY_HINT_NONE), "set_optional_features", "get_optional_features");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "requested_reference_space_types", PROPERTY_HINT_NONE), "set_requested_reference_space_types", "get_requested_reference_space_types");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_webxr_layers", PROPERTY_HINT_NONE), "set_disable_webxr_layers", "get_disable_webxr_layers");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "reference_space_type", PROPERTY_HINT_NONE), "", "get_reference_space_type");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "enabled_features", PROPERTY_HINT_NONE), "", "get_enabled_features");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "visibility_state", PROPERTY_HINT_NONE), "", "get_visibility_state");
diff --git a/modules/webxr/webxr_interface.h b/modules/webxr/webxr_interface.h
index 238d8fbecb4..66dc191c227 100644
--- a/modules/webxr/webxr_interface.h
+++ b/modules/webxr/webxr_interface.h
@@ -67,6 +67,8 @@ public:
virtual String get_requested_reference_space_types() const = 0;
virtual String get_reference_space_type() const = 0;
virtual String get_enabled_features() const = 0;
+ virtual void set_disable_webxr_layers(bool p_disable_webxr_layers) = 0;
+ virtual bool get_disable_webxr_layers() const = 0;
virtual bool is_input_source_active(int p_input_source_id) const = 0;
virtual Ref<XRControllerTracker> get_input_source_tracker(int p_input_source_id) const = 0;
virtual TargetRayMode get_input_source_target_ray_mode(int p_input_source_id) const = 0;
diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp
index 94ea3ce6900..8487594ed8c 100644
--- a/modules/webxr/webxr_interface_js.cpp
+++ b/modules/webxr/webxr_interface_js.cpp
@@ -161,6 +161,14 @@ String WebXRInterfaceJS::get_enabled_features() const {
return enabled_features;
}
+void WebXRInterfaceJS::set_disable_webxr_layers(bool p_disable_webxr_layers) {
+ disable_webxr_layers = p_disable_webxr_layers;
+}
+
+bool WebXRInterfaceJS::get_disable_webxr_layers() const {
+ return disable_webxr_layers;
+}
+
bool WebXRInterfaceJS::is_input_source_active(int p_input_source_id) const {
ERR_FAIL_INDEX_V(p_input_source_id, input_source_count, false);
return input_sources[p_input_source_id].active;
@@ -332,6 +340,7 @@ bool WebXRInterfaceJS::initialize() {
required_features.utf8().get_data(),
optional_features.utf8().get_data(),
requested_reference_space_types.utf8().get_data(),
+ disable_webxr_layers,
&_emwebxr_on_session_started,
&_emwebxr_on_session_ended,
&_emwebxr_on_session_failed,
@@ -615,6 +624,12 @@ Vector<RenderingServerTypes::BlitToScreen> WebXRInterfaceJS::post_draw_viewport(
texture_storage->render_target_set_reattach_textures(p_render_target, false);
+ GLES3::Texture *texture = texture_storage->get_texture(texture_storage->render_target_get_texture(p_render_target));
+ if (texture != nullptr) {
+ int layer_count = texture->target == GL_TEXTURE_2D_ARRAY ? texture->layers : 1;
+ godot_webxr_commit_render_target(texture->tex_id, layer_count);
+ }
+
return blit_to_screen;
}
diff --git a/modules/webxr/webxr_interface_js.h b/modules/webxr/webxr_interface_js.h
index 5395f5cd06c..e9754b254ca 100644
--- a/modules/webxr/webxr_interface_js.h
+++ b/modules/webxr/webxr_interface_js.h
@@ -60,6 +60,7 @@ private:
String requested_reference_space_types;
String reference_space_type;
String enabled_features;
+ bool disable_webxr_layers = false;
XRInterface::EnvironmentBlendMode environment_blend_mode = XRInterface::XR_ENV_BLEND_MODE_OPAQUE;
@@ -106,6 +107,8 @@ public:
virtual String get_requested_reference_space_types() const override;
virtual String get_reference_space_type() const override;
virtual String get_enabled_features() const override;
+ virtual void set_disable_webxr_layers(bool p_disable_webxr_layers) override;
+ virtual bool get_disable_webxr_layers() const override;
virtual bool is_input_source_active(int p_input_source_id) const override;
virtual Ref<XRControllerTracker> get_input_source_tracker(int p_input_source_id) const override;
virtual TargetRayMode get_input_source_target_ray_mode(int p_input_source_id) const override;