XRWebGLLayerInit.framebufferScaleFactor

Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The XRWebGLLayerInit dictionary's framebufferScaleFactor property, when specified upon instantiating a new XRWebGLLayer using its constructor, XRWebGLLayer(), specifies the scaling factor to use when determining the size of the frame buffer to use when rendering the scene, relative to the default XR device display resolution.

For example, a value of 1.0 indicates that the frame buffer should be the same resolution as the actual display, while a value of 0.5 indicates that the frame buffer should be half the resolution of the display. A value of 2.0, on the other hand, creates a frame buffer whose resolution is double that of the actual display buffer.

There are valid use cases for all of these kinds of scaling. See Managing rendering quality in WebXR performance guide for more information.

You can determine the scaling factor that you would need to apply to match the default frame buffer resolution by using the XRWebGLLayer.getNativeFramebufferScaleFactor() static function.

Syntax

let layerInit = {
  framebufferScaleFactor: scaleFactor
};
let glLayer = new XRWebGLLayer(xrSession, gl, layerInit);

let glLayer = new XRWebGLLayer(xrSession, gl, { framebufferScaleFactor: scaleFactor });

Value

A floating-point value indicating a multiplier to apply to the default frame buffer resolution in order to determine the resolution of the frame buffer for the XRWebGLLayer.

Example

In this example, a new XRWebGLLayer is created for a WebXR session, xrSession, with a frame buffer whose resolution is half that of the default display resolution of the XR device.

xrSession.updateRenderState({
  baseLayer: new XRWebGLLayer(xrSession, gl, {
     framebufferScaleFactor: 0.5
  });
});

Specifications

Specification Status Comment
WebXR Device API
The definition of 'XRWebGLLayerInit.framebufferScaleFactor' in that specification.
Working Draft Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
framebufferScaleFactorChrome Full support 79Edge Full support 79Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android Full support 79Chrome Android Full support 79Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 11.2

Legend

Full support
Full support
No support
No support

See also