[Bf-blender-cvs] [fd548dea3cb] greasepencil-refactor: GPencil: Refactor: Fix Overlay Blend mode

Clément Foucault noreply at git.blender.org
Sat Dec 14 03:31:23 CET 2019


Commit: fd548dea3cb82add6befac809d53e8a3b2debba0
Author: Clément Foucault
Date:   Sat Dec 14 03:21:29 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBfd548dea3cb82add6befac809d53e8a3b2debba0

GPencil: Refactor: Fix Overlay Blend mode

There was a mistake in the implementation. The step were reversed and
alpha was affecting the blend result.

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

M	source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M	source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index 47c87fb2559..a22a4741f3c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -84,7 +84,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
         state |= DRW_STATE_BLEND_ALPHA_PREMUL;
         break;
       case eGplBlendMode_Add:
-        state |= DRW_STATE_BLEND_ADD;
+        state |= DRW_STATE_BLEND_ADD_FULL;
         break;
       case eGplBlendMode_Subtract:
         /* Caveat. This effect only propagates if target buffer has
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
index 88d700ac3f4..ed3a6c53b4b 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl
@@ -63,13 +63,13 @@ void main()
        * rtn = (- 1 + 2 * src) + dst * (2 - 2 * src);
        **/
       color = mix(vec4(0.5), color, color.a * blendOpacity);
-      vec4 s = step(0.5, color);
+      vec4 s = step(-0.5, -color);
       fragRevealage = fragColor = 2.0 * s + 2.0 * color * (1.0 - s * 2.0);
       break;
     case MODE_OVERLAY_SECOND_PASS:
       /* Reminder: Blending func is additive blend (dst.rgba + src.rgba).*/
       color = mix(vec4(0.5), color, color.a * blendOpacity);
-      fragRevealage = fragColor = (-1.0 + 2.0 * color) * step(0.5, color);
+      fragRevealage = fragColor = (-1.0 + 2.0 * color) * step(-0.5, -color);
       break;
     case MODE_SUB:
     case MODE_ADD:



More information about the Bf-blender-cvs mailing list