diff --git a/src/ol/renderer/webgl/PointsLayer.js b/src/ol/renderer/webgl/PointsLayer.js index f1945af4f7..02a69798c3 100644 --- a/src/ol/renderer/webgl/PointsLayer.js +++ b/src/ol/renderer/webgl/PointsLayer.js @@ -126,14 +126,13 @@ const FRAGMENT_SHADER = ` * * Fragment shader: * ``` * precision mediump float; - * uniform float u_opacity; * * varying vec2 v_texCoord; * varying float v_opacity; * * void main(void) { * gl_FragColor.rgb = vec3(1.0, 1.0, 1.0); - * float alpha = u_opacity * v_opacity; + * float alpha = v_opacity; * if (alpha == 0.0) { * discard; * } diff --git a/src/ol/webgl/PostProcessingPass.js b/src/ol/webgl/PostProcessingPass.js index 429d391abd..1563079605 100644 --- a/src/ol/webgl/PostProcessingPass.js +++ b/src/ol/webgl/PostProcessingPass.js @@ -55,6 +55,10 @@ const DEFAULT_FRAGMENT_SHADER = ` * This class is used to define Post Processing passes with custom shaders and uniforms. * This is used internally by {@link module:ol/webgl/Helper~WebGLHelper}. * + * Please note that the final output on the DOM canvas is expected to have premultiplied alpha, which means that + * 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. + * * Default shaders are shown hereafter: * * * Vertex shader: @@ -87,6 +91,7 @@ const DEFAULT_FRAGMENT_SHADER = ` * * void main() { * gl_FragColor = texture2D(u_image, v_texCoord); + * gl_FragColor.rgb *= gl_FragColor.a; * } * ``` *