From 875cbda1821b68b01ea10ba37213933db49d5552 Mon Sep 17 00:00:00 2001 From: Diego Marcos Segura Date: Fri, 20 Oct 2023 13:12:12 -0700 Subject: [PATCH] Expose multiview extension through the renderer system --- docs/components/renderer.md | 7 +++++-- src/core/scene/a-scene.js | 4 ++++ src/systems/renderer.js | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/components/renderer.md b/docs/components/renderer.md index 565f170210b..8a3c75d53a0 100644 --- a/docs/components/renderer.md +++ b/docs/components/renderer.md @@ -36,6 +36,7 @@ It also configures presentation attributes when entering WebVR/WebXR. | physicallyCorrectLights | Whether to use physically-correct light attenuation. | false | | maxCanvasWidth | Maximum canvas width. Uses the size multiplied by device pixel ratio. Does not limit canvas width if set to -1. | 1920 | | maxCanvasHeight | Maximum canvas height. Behaves the same as maxCanvasWidth. | 1920 | +| multiviewStereo | Enables the use of the OCULUS_multiview extension. | false | | logarithmicDepthBuffer | Whether to use a logarithmic depth buffer. | auto | | precision | Fragment shader [precision][precision] : low, medium or high. | high | | alpha | Whether the canvas should contain an alpha buffer. | true | @@ -83,7 +84,6 @@ when in stereo rendering mode on certain systems. The value should be in the ran 0 is the minimum and 1 the maximum amount of foveation. This is currently supported by the Oculus Browser. - ### sortTransparentObjects [sorting]: ../introduction/faq.md#what-order-does-a-frame-render-objects-in @@ -97,7 +97,6 @@ use of `renderer="sortObjects: true"` may cause unwanted changes as the camera m Some more background on how A-Frame sorts objects for rendering can be found [here][sorting] - ### physicallyCorrectLights By default, point and spot lights attenuate (or, appear dimmer as they become farther away) @@ -120,3 +119,7 @@ Set precision in fragment shaders. Main use is to address issues in older hardwa ### alpha Whether the canvas should contain an alpha buffer. If this is true the renderer will have a transparent backbuffer and the canvas can be composited with the rest of the webpage. [See here for more info.](https://webglfundamentals.org/webgl/lessons/webgl-and-alpha.html) + +### multiviewStereo + +Performance improvement for applications that are CPU limited and draw count bound. Most experiences will get a free perf gain from this extension at not visual cost but there are limitations to consider. multiview builds on the multisampled render to texture extension that discards the frame buffer if there are other texture operations during rendering. Problem outlined in https://github.com/KhronosGroup/WebGL/issues/2912. Until browsers and drivers allow more control of when multisample is resolved we have a workaround with some drawbacks. As a temporary solution when enabling multiview the upload of texture data is deferred until the rendering of the main scene has ended, adding one extra frame of latency to texture uploads. Scenarios affected are for example skeletal meshes that upload bone textures with TexImage. With the workadound in place all bone animations will lag by one frame. Another issue is rendering mirror reflexions or rendering another view in the middle of the scene. The logic would have to move to the beginning of the frame to make sure it's not interrupted by the multiview frame. Because of the limitations this flag is disabled by default so developers can address any issues before enabling. diff --git a/src/core/scene/a-scene.js b/src/core/scene/a-scene.js index 3629f7faa7a..fca1773c875 100644 --- a/src/core/scene/a-scene.js +++ b/src/core/scene/a-scene.js @@ -610,6 +610,10 @@ class AScene extends AEntity { rendererConfig.alpha = rendererAttr.alpha === 'true'; } + if (rendererAttr.multiviewStereo) { + rendererConfig.multiviewStereo = rendererAttr.multiviewStereo === 'true'; + } + this.maxCanvasSize = { width: rendererAttr.maxCanvasWidth ? parseInt(rendererAttr.maxCanvasWidth) diff --git a/src/systems/renderer.js b/src/systems/renderer.js index 147b5f0b29e..011704bb126 100644 --- a/src/systems/renderer.js +++ b/src/systems/renderer.js @@ -15,6 +15,7 @@ module.exports.System = registerSystem('renderer', { logarithmicDepthBuffer: {default: 'auto', oneOf: ['true', 'false', 'auto']}, maxCanvasWidth: {default: 1920}, maxCanvasHeight: {default: 1920}, + multiviewStereo: {default: false}, physicallyCorrectLights: {default: false}, exposure: {default: 1, if: {toneMapping: ['ACESFilmic', 'linear', 'reinhard', 'cineon']}}, toneMapping: {default: 'no', oneOf: ['no', 'ACESFilmic', 'linear', 'reinhard', 'cineon']},