[Bf-blender-cvs] [c2c6c62ea11] greasepencil-object: GPencil: Add a new parameter to material to disable Stencil

Antonioya noreply at git.blender.org
Tue Jun 18 19:24:53 CEST 2019


Commit: c2c6c62ea110a8e96b876c2b0a186f01877624c2
Author: Antonioya
Date:   Tue Jun 18 19:24:36 2019 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc2c6c62ea110a8e96b876c2b0a186f01877624c2

GPencil: Add a new parameter to material to disable Stencil

Sometimes is good to disable the stencil and get the overlap. With this parameter the artist has the option to disable it.

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

M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 7cd68f34e9e..2215fa40c27 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -144,6 +144,7 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
                 col.template_ID(gpcolor, "stroke_image", open="image.open")
                 if gpcolor.mode == 'LINE':
                     col.prop(gpcolor, "pixel_size", text="UV Factor")
+                    col.prop(gpcolor, "use_stencil_clipping")
 
                 col.prop(gpcolor, "use_stroke_pattern", text="Use As Pattern")
                 if gpcolor.use_stroke_pattern is False:
@@ -160,6 +161,8 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
 
             if gpcolor.mode in {'DOTS', 'BOX'}:
                 col.prop(gpcolor, "alignment_mode")
+            if gpcolor.mode == 'LINE':
+                col.prop(gpcolor, "use_stencil_clipping")
 
 
 class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index b48e093521b..6918f65897e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1461,6 +1461,12 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
               false,
               1.0f,
               (const int *)stl->storage->shade_render);
+
+          if (gp_style->flag & GP_STYLE_DISABLE_STENCIL) {
+            /* Disable stencil for this type */
+            DRW_shgroup_state_disable(stl->g_data->shgrps_drawing_stroke,
+                                      DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL);
+          }
         }
         else {
           stl->g_data->shgrps_drawing_stroke = DRW_gpencil_shgroup_point_create(
@@ -1687,8 +1693,16 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
         start_stroke = elm->vertex_idx;
 
         /* set stencil mask id */
-        DRW_shgroup_stencil_mask(shgrp, stencil_id);
-        stencil_id++;
+        if (gp_style->flag & GP_STYLE_DISABLE_STENCIL) {
+          /* Disable stencil for this type */
+          DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL);
+          /* set stencil mask id as not used */
+          DRW_shgroup_stencil_mask(shgrp, 0x00f);
+        }
+        else {
+          DRW_shgroup_stencil_mask(shgrp, stencil_id);
+          stencil_id++;
+        }
         break;
       }
       case eGpencilBatchGroupType_Point: {
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index d65a4896758..480e7cd397f 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -128,6 +128,8 @@ typedef enum eMaterialGPencilStyle_Flag {
   GP_STYLE_FILL_SHOW = (1 << 9),
   /* mix stroke texture */
   GP_STYLE_STROKE_TEX_MIX = (1 << 11),
+  /* disable stencil clipping */
+  GP_STYLE_DISABLE_STENCIL = (1 << 12),
 } eMaterialGPencilStyle_Flag;
 
 typedef enum eMaterialGPencilStyle_Mode {
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 3ff2e884d92..bc8d040587d 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -620,6 +620,12 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Pattern", "Use Fill Texture as a pattern to apply color");
   RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
 
+  prop = RNA_def_property(srna, "use_stencil_clipping", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_STYLE_DISABLE_STENCIL);
+  RNA_def_property_ui_text(
+      prop, "Stencil", "Use Stencil Clipping for avoiding glitches with alpha materials");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialGpencil_update");
+
   prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_SHOW);
   RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of this material");



More information about the Bf-blender-cvs mailing list