[Bf-blender-cvs] [11a390e85e2] master: GPencil: Implement antialiasing parameter to Pixel FX

Antonio Vazquez noreply at git.blender.org
Tue Jun 23 19:20:07 CEST 2020


Commit: 11a390e85e2b1358f2167d86490a1c9abec17ea6
Author: Antonio Vazquez
Date:   Tue Jun 23 19:11:52 2020 +0200
Branches: master
https://developer.blender.org/rB11a390e85e2b1358f2167d86490a1c9abec17ea6

GPencil: Implement antialiasing parameter to Pixel FX

Related to T78153

Differential Revision: https://developer.blender.org/D8100

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

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_pixel.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 7ce7a726bb7..cf6e78f4702 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -262,6 +262,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
   mul_v3_m4v3(ob_center, persmat, ob->obmat[3]);
   mul_v3_fl(ob_center, 1.0f / w);
 
+  const bool use_antialiasing = ((fx->flag & FX_PIXEL_FILTER_NEAREST) == 0);
+
   /* Convert to uvs. */
   mul_v2_fl(ob_center, 0.5f);
   add_v2_fl(ob_center, 0.5f);
@@ -285,7 +287,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
     DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform);
     DRW_shgroup_uniform_vec2_copy(grp, "targetPixelOffset", ob_center);
     DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){pixel_size[0], 0.0f});
-    DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1);
+    int samp_count = (pixel_size[0] / vp_size_inv[0] > 3.0) ? 2 : 1;
+    DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0);
     DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
   }
 
@@ -294,7 +297,8 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
     grp = gpencil_vfx_pass_create("Fx Pixelize Y", state, iter, sh);
     DRW_shgroup_uniform_vec2_copy(grp, "targetPixelSize", pixsize_uniform);
     DRW_shgroup_uniform_vec2_copy(grp, "accumOffset", (float[2]){0.0f, pixel_size[1]});
-    DRW_shgroup_uniform_int_copy(grp, "sampCount", (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1);
+    int samp_count = (pixel_size[1] / vp_size_inv[1] > 3.0) ? 2 : 1;
+    DRW_shgroup_uniform_int_copy(grp, "sampCount", use_antialiasing ? samp_count : 0);
     DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
   }
 }
diff --git a/source/blender/makesdna/DNA_shader_fx_types.h b/source/blender/makesdna/DNA_shader_fx_types.h
index 2ccff2da993..39d38c66d45 100644
--- a/source/blender/makesdna/DNA_shader_fx_types.h
+++ b/source/blender/makesdna/DNA_shader_fx_types.h
@@ -172,6 +172,10 @@ typedef struct PixelShaderFxData {
   ShaderFxData_Runtime runtime;
 } PixelShaderFxData;
 
+typedef enum ePixelShaderFx_Flag {
+  FX_PIXEL_FILTER_NEAREST = (1 << 0),
+} ePixelShaderFx_Flag;
+
 typedef struct RimShaderFxData {
   ShaderFxData shaderfx;
   int offset[2];
diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c
index d0565bb3aab..80f3cab147c 100644
--- a/source/blender/makesrna/intern/rna_shader_fx.c
+++ b/source/blender/makesrna/intern/rna_shader_fx.c
@@ -336,11 +336,9 @@ static void rna_def_shader_fx_pixel(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Size", "Pixel size");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
 
-  prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
-  RNA_def_property_range(prop, 0.0, 1.0);
-  RNA_def_property_float_sdna(prop, NULL, "rgba");
-  RNA_def_property_array(prop, 4);
-  RNA_def_property_ui_text(prop, "Color", "Color used for lines");
+  prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FX_PIXEL_FILTER_NEAREST);
+  RNA_def_property_ui_text(prop, "Antialiasing", "Antialiase pixels");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_ShaderFx_update");
 }
 
diff --git a/source/blender/shader_fx/intern/FX_shader_pixel.c b/source/blender/shader_fx/intern/FX_shader_pixel.c
index b22dae1064d..bdc4f141017 100644
--- a/source/blender/shader_fx/intern/FX_shader_pixel.c
+++ b/source/blender/shader_fx/intern/FX_shader_pixel.c
@@ -68,6 +68,8 @@ static void panel_draw(const bContext *C, Panel *panel)
   uiItemFullR(col, &ptr, prop, 0, 0, 0, IFACE_("Size X"), ICON_NONE);
   uiItemFullR(col, &ptr, prop, 1, 0, 0, IFACE_("Y"), ICON_NONE);
 
+  uiItemR(layout, &ptr, "use_antialiasing", 0, NULL, ICON_NONE);
+
   shaderfx_panel_end(layout, &ptr);
 }



More information about the Bf-blender-cvs mailing list