[Bf-blender-cvs] [f8661a89f5f] greasepencil-refactor: Revert "GPencil: Refactor: Change Mask Behavior"

Clément Foucault noreply at git.blender.org
Sun Dec 15 03:43:14 CET 2019


Commit: f8661a89f5f9f9540810855aaee0b1c050f362b3
Author: Clément Foucault
Date:   Sat Dec 14 20:30:50 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBf8661a89f5f9f9540810855aaee0b1c050f362b3

Revert "GPencil: Refactor: Change Mask Behavior"

This reverts commit eb3fe4c8486fe1253cf8725b6083238dca7d256e.

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

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 4a63702638a..00a9b1c05e9 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -76,26 +76,18 @@ GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
     }
 
     if (!pd->draw_depth_only) {
-      state |= DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+      if (gpl->flag & GP_LAYER_USE_MASK) {
+        state |= DRW_STATE_STENCIL_EQUAL;
+      }
+      else {
+        state |= DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
+      }
     }
 
     tgp_layer->geom_ps = DRW_pass_create("GPencil Layer", state);
   }
 
-  if (gpl->flag & GP_LAYER_USE_MASK) {
-    DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL |
-                     DRW_STATE_BLEND_ALPHA_PREMUL;
-    tgp_layer->blend_ps = DRW_pass_create("GPencil Mask Layer", state);
-
-    GPUShader *sh = GPENCIL_shader_layer_blend_get(&en_data);
-    DRWShadingGroup *grp = DRW_shgroup_create(sh, tgp_layer->blend_ps);
-    DRW_shgroup_uniform_int_copy(grp, "blendMode", 333);
-    DRW_shgroup_uniform_texture_ref(grp, "colorBuf", &pd->reveal_layer_tx);
-    DRW_shgroup_uniform_texture_ref(grp, "revealBuf", &pd->reveal_layer_tx);
-    DRW_shgroup_stencil_mask(grp, 0xFF);
-    DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
-  }
-  else if ((gpl->blend_mode != eGplBlendMode_Regular) || (gpl->opacity < 1.0f)) {
+  if ((gpl->blend_mode != eGplBlendMode_Regular) || (gpl->opacity < 1.0f)) {
     DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_STENCIL_EQUAL;
     switch (gpl->blend_mode) {
       case eGplBlendMode_Regular:
@@ -130,6 +122,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
     DRW_shgroup_uniform_texture_ref(grp, "colorBuf", &pd->color_layer_tx);
     DRW_shgroup_uniform_texture_ref(grp, "revealBuf", &pd->reveal_layer_tx);
     DRW_shgroup_stencil_mask(grp, 0xFF);
+    /* TODO only blend pixels that have been rendered. */
     DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
 
     if (gpl->blend_mode == eGplBlendMode_Overlay) {
@@ -140,6 +133,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add_new(GPENCIL_PrivateData *pd, Object *ob,
       DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ADD);
       DRW_shgroup_uniform_int_copy(grp, "blendMode", 999);
       DRW_shgroup_uniform_texture_ref(grp, "colorBuf", &pd->color_layer_tx);
+      /* TODO only blend pixels that have been rendered. */
       DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
     }
   }
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 1398e6deadd..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
@@ -18,7 +18,6 @@ layout(location = 1) out vec4 fragRevealage;
 #define MODE_SUB 3
 #define MODE_MULTIPLY 4
 #define MODE_DIVIDE 5
-#define MODE_MASK 333
 #define MODE_OVERLAY_SECOND_PASS 999
 
 void main()
@@ -79,10 +78,5 @@ void main()
       fragColor = color * color.a;
       fragRevealage = vec4(0.0);
       break;
-    case MODE_MASK:
-      /* Reminder: Blending func is premult alpha blend (dst.rgba * (1 - src.a) + src.rgb).*/
-      fragColor = vec4(0.0, 0.0, 0.0, 1.0 - color.a);
-      fragRevealage = vec4(1.0 - color.aaa, 1.0 - color.a);
-      break;
   }
 }



More information about the Bf-blender-cvs mailing list