[Bf-blender-cvs] [db5c8c0393b] master: GPencil: Fix clamp alpha problems when using Regular blend

Antonioya noreply at git.blender.org
Wed Jun 12 16:55:32 CEST 2019


Commit: db5c8c0393ba94f7ff523e1079ce4642fee661a8
Author: Antonioya
Date:   Wed Jun 12 16:55:24 2019 +0200
Branches: master
https://developer.blender.org/rBdb5c8c0393ba94f7ff523e1079ce4642fee661a8

GPencil: Fix clamp alpha problems when using Regular blend

The problem was the alpha was not premult and the opacity factor was applied two times.

===================================================================

M	source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl

===================================================================

diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
index 4a6025fcd24..658c708ee19 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl
@@ -115,7 +115,11 @@ void main()
   if (mode == MODE_REGULAR) {
     if (stroke_color.a > 0) {
       if (mix_color.a > 0) {
-        FragColor = vec4(mix(stroke_color.rgb, mix_color.rgb, mix_color.a * blend_opacity),
+      /* premult */
+        stroke_color = vec4(vec3(stroke_color.rgb / stroke_color.a), stroke_color.a);
+        mix_color = vec4(vec3(mix_color.rgb / mix_color.a), mix_color.a);
+
+        FragColor = vec4(mix(stroke_color.rgb, mix_color.rgb, mix_color.a),
                          stroke_color.a);
         gl_FragDepth = mix_depth;
       }



More information about the Bf-blender-cvs mailing list