[Bf-blender-cvs] [7480b2381db] greasepencil-object: New fill style using patterns

Antonio Vazquez noreply at git.blender.org
Tue Jun 6 17:19:59 CEST 2017


Commit: 7480b2381dbc143abe91428f5fe19d79780fd50f
Author: Antonio Vazquez
Date:   Tue Jun 6 17:19:48 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB7480b2381dbc143abe91428f5fe19d79780fd50f

New fill style using patterns

Now it is possible to use a texture to define the fill color pattern, similar to the use of noncolor textures.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_palette.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index e9e93425195..7c8be59dc3c 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -406,7 +406,7 @@ class GreasePencilStrokeSculptPanel:
             else:
                 return bool(gpd.is_stroke_sculpt_mode)
 
-        return false
+        return False
 
     @staticmethod
     def draw(self, context):
@@ -1205,13 +1205,13 @@ class GreasePencilPaletteColorPanel:
                 col.prop(pcolor, "mix_factor", text="Mix", slider=True)
 
         if pcolor.fill_style in ('GRADIENT', 'RADIAL', 'CHESSBOARD'):
-            if pcolor.texture_mix is False or pcolor.fill_style  == 'CHESSBOARD':
+            if pcolor.texture_mix is False or pcolor.fill_style == 'CHESSBOARD':
                 col.prop(pcolor, "mix_color", text="")
             split = col.split(percentage=0.5)
             subcol = split.column(align=True)
             subcol.prop(pcolor, "pattern_shift", text="Location")
             subrow = subcol.row(align=True)
-            if pcolor.fill_style  == 'RADIAL':
+            if pcolor.fill_style == 'RADIAL':
                 subrow.enabled = False
             subrow.prop(pcolor, "pattern_angle", text="Angle")
             subcol.prop(pcolor, "flip", text="Flip")
@@ -1219,19 +1219,19 @@ class GreasePencilPaletteColorPanel:
             subcol = split.column(align=True)
             subcol.prop(pcolor, "pattern_scale", text="Scale")
             subrow = subcol.row(align=True)
-            if pcolor.fill_style  != 'RADIAL':
+            if pcolor.fill_style != 'RADIAL':
                 subrow.enabled = False
             subrow.prop(pcolor, "pattern_radius", text="Radius")
             subrow = subcol.row(align=True)
-            if pcolor.fill_style  != 'CHESSBOARD':
+            if pcolor.fill_style != 'CHESSBOARD':
                 subrow.enabled = False
             subrow.prop(pcolor, "pattern_boxsize", text="Box")
         
         col.separator()
         col.label("Texture")
-        if pcolor.fill_style != 'TEXTURE':
+        if pcolor.fill_style not in ('TEXTURE', 'PATTERN'):
             col.prop(pcolor, "texture_mix", text="Mix Texture")
-        if pcolor.fill_style == 'TEXTURE' or pcolor.texture_mix is True:
+        if pcolor.fill_style in ('TEXTURE', 'PATTERN') or pcolor.texture_mix is True:
             col.template_ID(pcolor, "image", open="image.open")
             split = col.split(percentage=0.5)
             subcol = split.column(align=True)
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 6a2b6bc267e..d334088016d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -259,7 +259,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(GPENCIL_Data *vedata, DR
 	DRW_shgroup_uniform_int(grp, "xraymode", (const int *) &gpd->xray_mode, 1);
 
 	/* image texture */
-	if ((palcolor->fill_style == FILL_STYLE_TEXTURE) || (palcolor->flag & PAC_COLOR_TEX_MIX)) {
+	if ((palcolor->fill_style == FILL_STYLE_TEXTURE) || (palcolor->fill_style == FILL_STYLE_PATTERN) || (palcolor->flag & PAC_COLOR_TEX_MIX)) {
 		ImBuf *ibuf;
 		Image *image = palcolor->ima;
 		ImageUser iuser = { NULL };
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index 79171424e6a..84928530219 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -25,6 +25,7 @@ uniform int t_clamp;
 #define RADIAL 2
 #define CHESS 3
 #define TEXTURE 4
+#define PATTERN 5
 
 #define GP_XRAY_FRONT 0
 #define GP_XRAY_3DSPACE 1
@@ -174,6 +175,12 @@ void main()
 		if (fill_type == TEXTURE) {
 			fragColor = text_color;
 		}
+		/* pattern */
+		if (fill_type == PATTERN) {
+			/* normalize texture color */
+			float nvalue = 1.0 - ((text_color.x + text_color.y + text_color.z) / 3.0);
+			fragColor = mix(vec4(0.0, 0.0, 0.0, 0.0), finalColor, nvalue);
+		}
 	}
 
 	/* set zdepth */
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index d4eaa6219f1..4c9ab007360 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -383,5 +383,6 @@ typedef enum BlurKernelType {
 #define FILL_STYLE_RADIAL	2
 #define FILL_STYLE_CHESSBOARD 3
 #define FILL_STYLE_TEXTURE 4
+#define FILL_STYLE_PATTERN 5
 
 #endif  /* __DNA_BRUSH_TYPES_H__ */
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index 3b34d793a35..928bd43129b 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -220,6 +220,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
 		{ FILL_STYLE_RADIAL, "RADIAL", 0, "Radial", "Fill area with radial gradient" },
 		{ FILL_STYLE_CHESSBOARD, "CHESSBOARD", 0, "Chessboard", "Fill area with chessboard pattern" },
 		{ FILL_STYLE_TEXTURE, "TEXTURE", 0, "Texture", "Fill area with image texture" },
+		{ FILL_STYLE_PATTERN, "PATTERN", 0, "Pattern", "Fill area with color but use image texture as pattern to distribute color" },
 		{ 0, NULL, 0, NULL, NULL }
 	};




More information about the Bf-blender-cvs mailing list