Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix highp samplers issues #9064

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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