Skip to content

Commit

Permalink
Merge pull request #9064 from dennisadams/fix-highp
Browse files Browse the repository at this point in the history
Fix highp samplers issues
  • Loading branch information
lilleyse authored Aug 5, 2020
2 parents 680de81 + 274542b commit 9b2e80b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 4 additions & 0 deletions Source/Renderer/ShaderSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/GlobeDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/PickDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down Expand Up @@ -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" +
Expand Down
4 changes: 2 additions & 2 deletions Source/Shaders/Builtin/Functions/shadowDepthCompare.glsl
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/PostProcessStages/PassThroughDepth.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uniform sampler2D u_depthTexture;
uniform highp sampler2D u_depthTexture;

varying vec2 v_textureCoordinates;

Expand Down

0 comments on commit 9b2e80b

Please sign in to comment.