From eba8f4cbc6d3631c402eb249791b57e3af46d19c Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Wed, 30 Jan 2019 11:32:40 -0800 Subject: [PATCH] Set shader precission to mediump in Mobile. Fix problems with Adreno 300 series GPUs and improves perf. (fix #3971, #3523) --- src/core/scene/a-scene.js | 8 +++++++- src/index.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/scene/a-scene.js b/src/core/scene/a-scene.js index 478652886f6..756954ae091 100644 --- a/src/core/scene/a-scene.js +++ b/src/core/scene/a-scene.js @@ -548,7 +548,13 @@ module.exports.AScene = registerElement('a-scene', { var rendererAttrString; var rendererConfig; - rendererConfig = {alpha: true, antialias: !isMobile, canvas: this.canvas, logarithmicDepthBuffer: false}; + rendererConfig = { + alpha: true, + antialias: !isMobile, + canvas: this.canvas, + logarithmicDepthBuffer: false, + precision: isMobile && !window.hasNativeVR ? 'mediump' : 'highp' + }; this.maxCanvasSize = {height: 1920, width: 1920}; diff --git a/src/index.js b/src/index.js index 8fb5d59108e..55d14454604 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ window.Promise = window.Promise || require('promise-polyfill'); window.hasNativeWebVRImplementation = !!window.navigator.getVRDisplays || !!window.navigator.getVRDevices; window.hasNativeWebXRImplementation = navigator.xr !== undefined; +window.hasNativeVR = window.hasNativeWebVRImplementation || window.hasNativeWebXRImplementation; // If native WebXR or WebVR are defined WebVRPolyfill does not initialize. if (!window.hasNativeWebXRImplementation && !window.hasNativeWebVRImplementation) {