From 143cb72f8afbbfc693505956f109aaa8361dcf6d Mon Sep 17 00:00:00 2001 From: mrmaxm Date: Wed, 21 Feb 2024 18:53:45 +0200 Subject: [PATCH 1/2] webxr fixed foveation --- src/framework/xr/xr-manager.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/framework/xr/xr-manager.js b/src/framework/xr/xr-manager.js index e4ff3e8ec24..136e7a66b71 100644 --- a/src/framework/xr/xr-manager.js +++ b/src/framework/xr/xr-manager.js @@ -959,6 +959,30 @@ class XrManager extends EventHandler { return this._framebufferScaleFactor; } + /** + * Set fixed foveation to the value between 0 and 1. Where 0 - no foveation, and 1 - highest + * foveation. It only can be set during an active XR session. + * Fixed foveation will reduce the resolution of the back buffer at the edges of the sceen, + * which can improve rendering performance. + * + * @type {number} + */ + set fixedFoveation(value) { + if ((this._baseLayer?.fixedFoveation ?? null) !== null) { + this._baseLayer.fixedFoveation = value; + } + } + + /** + * Current fixed foveation level, which is between 0 and 1. 0 - no forveation, and 1 - highest + * foveation. If fixed foveation is not supported, this value returns null. + * + * @type {number|null} + */ + get fixedFoveation() { + return this._baseLayer?.fixedFoveation ?? null; + } + /** * Active camera for which XR session is running or null. * From dbe02f7b58917f359a2bc4410ebbc8a6221cbded Mon Sep 17 00:00:00 2001 From: mrmaxm Date: Thu, 22 Feb 2024 14:56:15 +0200 Subject: [PATCH 2/2] fixed foveation + anti-aliasing warning --- src/framework/xr/xr-manager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/framework/xr/xr-manager.js b/src/framework/xr/xr-manager.js index 07d858f8d12..f992730b932 100644 --- a/src/framework/xr/xr-manager.js +++ b/src/framework/xr/xr-manager.js @@ -1028,6 +1028,10 @@ class XrManager extends EventHandler { */ set fixedFoveation(value) { if ((this._baseLayer?.fixedFoveation ?? null) !== null) { + if (this.app.graphicsDevice.samples > 1) { + Debug.warn('Fixed Foveation is ignored. Disable anti-aliasing for it to be effective.'); + } + this._baseLayer.fixedFoveation = value; } }