[Bf-blender-cvs] [ca2f80fe5a6] greasepencil-object: GPencil: Convert Blur size to float and avoid unedeed passes if size is 0

Antonio Vazquez noreply at git.blender.org
Fri Feb 14 18:08:24 CET 2020


Commit: ca2f80fe5a613719732076668fc5e7df88d9bad9
Author: Antonio Vazquez
Date:   Fri Feb 14 18:07:39 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBca2f80fe5a613719732076668fc5e7df88d9bad9

GPencil: Convert Blur size to float and avoid unedeed passes if size is 0

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

M	source/blender/draw/engines/gpencil/gpencil_shader_fx.c
M	source/blender/makesdna/DNA_shader_fx_types.h
M	source/blender/makesrna/intern/rna_shader_fx.c
M	source/blender/shader_fx/intern/FX_shader_blur.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 5087f9ec885..0e1313dc86f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -95,6 +95,10 @@ static DRWShadingGroup *gpencil_vfx_pass_create(const char *name,
 
 static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *iter)
 {
+  if (fx->radius[0] == 0.0f && fx->radius[1] == 0.0f) {
+    return;
+  }
+
   DRWShadingGroup *grp;
 
   float winmat[4][4], persmat[4][4];
@@ -120,15 +124,18 @@ static void gpencil_vfx_blur(BlurShaderFxData *fx, Object *ob, gpIterVfxData *it
   GPUShader *sh = GPENCIL_shader_fx_blur_get();
 
   DRWState state = DRW_STATE_WRITE_COLOR;
-  grp = gpencil_vfx_pass_create("Fx Blur H", state, iter, sh);
-  DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){blur_size[0], 0.0f});
-  DRW_shgroup_uniform_int_copy(grp, "sampCount", max_ii(1, min_ii(fx->samples, blur_size[0])));
-  DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
-
-  grp = gpencil_vfx_pass_create("Fx Blur V", state, iter, sh);
-  DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){0.0f, blur_size[1]});
-  DRW_shgroup_uniform_int_copy(grp, "sampCount", max_ii(1, min_ii(fx->samples, blur_size[1])));
-  DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
+  if (blur_size[0] > 0.0f) {
+    grp = gpencil_vfx_pass_create("Fx Blur H", state, iter, sh);
+    DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){blur_size[0], 0.0f});
+    DRW_shgroup_uniform_int_copy(grp, "sampCount", max_ii(1, min_ii(fx->samples, blur_size[0])));
+    DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
+  }
+  if (blur_size[1] > 0.0f) {
+    grp = gpencil_vfx_pass_create("Fx Blur V", state, iter, sh);
+    DRW_shgroup_uniform_vec2_copy(grp, "offset", (float[2]){0.0f, blur_size[1]});
+    DRW_shgroup_uniform_int_copy(grp, "sampCount", max_ii(1, min_ii(fx->samples, blur_size[1])));
+    DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
+  }
 }
 
 static void gpencil_vfx_colorize(ColorizeShaderFxData *fx, Object *UNUSED(ob), gpIterVfxData *iter)
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 99e70acb55a..8b13da3cf9c 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -81,7 +81,7 @@ typedef struct ShaderFxData_Runtime {
 
 typedef struct BlurShaderFxData {
   ShaderFxData shaderfx;
-  int radius[2];
+  float radius[2];
   /** Flags. */
   int flag;
   /** Number of samples. */
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index 5d58ecd3153..cfee388ea70 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -207,9 +207,9 @@ static void rna_def_shader_fx_blur(BlenderRNA *brna)
   RNA_def_struct_sdna(srna, "BlurShaderFxData");
   RNA_def_struct_ui_icon(srna, ICON_SHADERFX);
 
-  prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL);
-  RNA_def_property_int_sdna(prop, NULL, "radius");
-  RNA_def_property_range(prop, 0, SHRT_MAX);
+  prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "radius");
+  RNA_def_property_range(prop, 0.0f, FLT_MAX);
   RNA_def_property_ui_text(prop, "Size", "Factor of Blur");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
 
diff --git a/source/blender/shader_fx/intern/FX_shader_blur.c b/source/blender/shader_fx/intern/FX_shader_blur.c
index 0f7394b4c46..dea53ed1451 100644
--- a/source/blender/shader_fx/intern/FX_shader_blur.c
+++ b/source/blender/shader_fx/intern/FX_shader_blur.c
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 
+#include "BLI_math.h"
 #include "BLI_utildefines.h"
 
 #include "FX_shader_types.h"
@@ -30,7 +31,7 @@
 static void initData(ShaderFxData *fx)
 {
   BlurShaderFxData *gpfx = (BlurShaderFxData *)fx;
-  ARRAY_SET_ITEMS(gpfx->radius, 5, 5);
+  copy_v2_fl(gpfx->radius, 20.0f);
   gpfx->samples = 2;
 }



More information about the Bf-blender-cvs mailing list