Skip to content

Commit

Permalink
Expose multiview extension through the renderer system
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarcos committed Oct 20, 2023
1 parent 3119ca0 commit 875cbda
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/components/renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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.
4 changes: 4 additions & 0 deletions src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/systems/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']},
Expand Down

0 comments on commit 875cbda

Please sign in to comment.