Skip to content

Commit

Permalink
fix(ColorLayer): Fix rendering issue on white to invisible effect
Browse files Browse the repository at this point in the history
Closes #2236:
- Fix undefined value passed to uniforms effect_type and
  effect_parameter
- Remove useless intensity parameter of applyWhiteToInvisibleEffect
  function
  • Loading branch information
Desplandis committed Dec 22, 2023
1 parent d46cd44 commit 04cad6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Layer/ColorLayer.js
Expand Up @@ -90,6 +90,9 @@ class ColorLayer extends RasterLayer {
this.transparent = config.transparent || (this.opacity < 1.0);
this.noTextureParentOutsideLimit = config.source ? config.source.isFileSource : false;

this.effect_type = config.effect_type ?? 0;
this.effect_parameter = config.effect_parameter ?? 1.0;

// Feature options
this.buildExtent = true;
this.structure = '2d';
Expand Down
6 changes: 3 additions & 3 deletions src/Renderer/Shader/Chunk/color_layers_pars_fragment.glsl
Expand Up @@ -23,10 +23,10 @@ float getBorderDistance(vec2 uv) {

float tolerance = 0.99;

vec4 applyWhiteToInvisibleEffect(vec4 color, float intensity) {
vec4 applyWhiteToInvisibleEffect(vec4 color) {
float a = dot(color.rgb, vec3(0.333333333));
if (a >= tolerance) {
color.a *= 1.0 - pow(abs(a), intensity);
color.a = 0.0;
}
return color;
}
Expand Down Expand Up @@ -72,7 +72,7 @@ vec4 getLayerColor(int textureOffset, sampler2D tex, vec4 offsetScale, Layer lay
if (layer.effect_type == 1) {
color = applyLightColorToInvisibleEffect(color, layer.effect_parameter);
} else if (layer.effect_type == 2) {
color = applyWhiteToInvisibleEffect(color, layer.effect_parameter);
color = applyWhiteToInvisibleEffect(color);
}
}
color.a *= layer.opacity;
Expand Down

0 comments on commit 04cad6c

Please sign in to comment.