diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index dac335798e..eebebf84db 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -238,7 +238,7 @@ class Heatmap extends VectorLayer { float sqRadius = texCoord.x * texCoord.x + texCoord.y * texCoord.y; float value = (1.0 - sqrt(sqRadius)) * u_blurSlope; float alpha = smoothstep(0.0, 1.0, value) * v_opacity; - gl_FragColor = vec4(1.0, 1.0, 1.0, alpha); + gl_FragColor = vec4(alpha, alpha, alpha, alpha); }`, uniforms: { u_size: function() { diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index ce40fc4c3e..f486476a21 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -110,8 +110,7 @@ const FRAGMENT_SHADER = ` * * The following uniform is used for the main texture: `u_texture`. * - * Please note that the main shader output should have premultiplied alpha, otherwise the colors will be blended - * additively. + * Please note that the main shader output should have premultiplied alpha, otherwise visual anomalies may occur. * * Points are rendered as quads with the following structure: * diff --git a/src/ol/webgl/PostProcessingPass.js b/src/ol/webgl/PostProcessingPass.js index 1563079605..1405398354 100644 --- a/src/ol/webgl/PostProcessingPass.js +++ b/src/ol/webgl/PostProcessingPass.js @@ -28,7 +28,6 @@ const DEFAULT_FRAGMENT_SHADER = ` void main() { gl_FragColor = texture2D(u_image, v_texCoord); - gl_FragColor.rgb *= gl_FragColor.a; } `; @@ -59,6 +58,9 @@ const DEFAULT_FRAGMENT_SHADER = ` * a pixel which is 100% red with an opacity of 50% must have a color of (r=0.5, g=0, b=0, a=0.5). * Failing to provide pixel colors with premultiplied alpha will result in render anomalies. * + * The default post-processing pass does *not* multiply color values with alpha value, it expects color values to be + * premultiplied. + * * Default shaders are shown hereafter: * * * Vertex shader: @@ -91,7 +93,6 @@ const DEFAULT_FRAGMENT_SHADER = ` * * void main() { * gl_FragColor = texture2D(u_image, v_texCoord); - * gl_FragColor.rgb *= gl_FragColor.a; * } * ``` *