diff --git a/CHANGES.md b/CHANGES.md index 7c240ae8a1d3..3efc558a930e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +### 1.73 - 2020-09-01 + +##### Fixes :wrench: + +- Fixed several artifcats on mobile devices caused by using insufficient precision. [#9064](https://github.com/CesiumGS/cesium/pull/9064) + ### 1.72 - 2020-08-03 ##### Breaking Changes :mega: diff --git a/Source/Renderer/ShaderSource.js b/Source/Renderer/ShaderSource.js index a611e4131a5f..9ed28326e831 100644 --- a/Source/Renderer/ShaderSource.js +++ b/Source/Renderer/ShaderSource.js @@ -235,12 +235,16 @@ function combineShader(shaderSource, isFragmentShader, context) { } if (isFragmentShader) { + // If high precision isn't support replace occurrences of highp with mediump + // The highp keyword is not always available on older mobile devices + // See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#In_WebGL_1_highp_float_support_is_optional_in_fragment_shaders result += "\ #ifdef GL_FRAGMENT_PRECISION_HIGH\n\ precision highp float;\n\ #else\n\ precision mediump float;\n\ + #define highp mediump\n\ #endif\n\n"; } diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index 497e4d1ce210..8df6d6e348ae 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -76,7 +76,7 @@ function executeDebugGlobeDepth(globeDepth, context, passState, useLogDepth) { useLogDepth !== globeDepth._useLogDepth ) { var fsSource = - "uniform sampler2D u_depthTexture;\n" + + "uniform highp sampler2D u_depthTexture;\n" + "varying vec2 v_textureCoordinates;\n" + "void main()\n" + "{\n" + diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index b9256c278561..87684b0140b9 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -29,7 +29,7 @@ function executeDebugPickDepth(pickDepth, context, passState, useLogDepth) { useLogDepth !== pickDepth._useLogDepth ) { var fsSource = - "uniform sampler2D u_texture;\n" + + "uniform highp sampler2D u_texture;\n" + "varying vec2 v_textureCoordinates;\n" + "void main()\n" + "{\n" + @@ -116,7 +116,7 @@ function updateFramebuffers(pickDepth, context, depthTexture) { function updateCopyCommands(pickDepth, context, depthTexture) { if (!defined(pickDepth._copyDepthCommand)) { var fs = - "uniform sampler2D u_texture;\n" + + "uniform highp sampler2D u_texture;\n" + "varying vec2 v_textureCoordinates;\n" + "void main()\n" + "{\n" + diff --git a/Source/Shaders/Builtin/Functions/shadowDepthCompare.glsl b/Source/Shaders/Builtin/Functions/shadowDepthCompare.glsl index 2125c2b659a9..ea7bec62ecc0 100644 --- a/Source/Shaders/Builtin/Functions/shadowDepthCompare.glsl +++ b/Source/Shaders/Builtin/Functions/shadowDepthCompare.glsl @@ -1,10 +1,10 @@ -float czm_sampleShadowMap(samplerCube shadowMap, vec3 d) +float czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d) { return czm_unpackDepth(textureCube(shadowMap, d)); } -float czm_sampleShadowMap(sampler2D shadowMap, vec2 uv) +float czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv) { #ifdef USE_SHADOW_DEPTH_TEXTURE return texture2D(shadowMap, uv).r; diff --git a/Source/Shaders/PostProcessStages/PassThroughDepth.glsl b/Source/Shaders/PostProcessStages/PassThroughDepth.glsl index e25361c41d48..e04fce01cdbb 100644 --- a/Source/Shaders/PostProcessStages/PassThroughDepth.glsl +++ b/Source/Shaders/PostProcessStages/PassThroughDepth.glsl @@ -1,4 +1,4 @@ -uniform sampler2D u_depthTexture; +uniform highp sampler2D u_depthTexture; varying vec2 v_textureCoordinates;