[Bf-blender-cvs] [f24e9bb0380] blender-v2.83-release: GPencil: Add new parameter for SMAA threshold

Antonio Vazquez noreply at git.blender.org
Tue May 12 17:50:51 CEST 2020


Commit: f24e9bb0380936bcaf6c194b54342a2977784cff
Author: Antonio Vazquez
Date:   Tue May 12 17:47:48 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBf24e9bb0380936bcaf6c194b54342a2977784cff

GPencil: Add new parameter for SMAA threshold

This parameter allows to define the threshold for SMAA algorithm.

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

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

M	release/scripts/startup/bl_ui/properties_render.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/gpencil/gpencil_antialiasing.c
M	source/blender/draw/engines/gpencil/gpencil_shader.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index fd4859f3620..30094da20c8 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -543,6 +543,27 @@ class RENDER_PT_eevee_performance(RenderButtonsPanel, Panel):
         layout.prop(rd, "use_high_quality_normals")
 
 
+class RENDER_PT_gpencil(RenderButtonsPanel, Panel):
+    bl_label = "Grease Pencil"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False  # No animation.
+
+        scene = context.scene
+        props = scene.grease_pencil_settings
+
+        col = layout.column()
+        col.prop(props, "antialias_threshold")
+
+
+
 class RENDER_PT_opengl_sampling(RenderButtonsPanel, Panel):
     bl_label = "Sampling"
     COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
@@ -697,6 +718,7 @@ classes = (
     RENDER_PT_eevee_indirect_lighting_display,
     RENDER_PT_eevee_film,
     RENDER_PT_eevee_film_overscan,
+    RENDER_PT_gpencil,
     RENDER_PT_opengl_sampling,
     RENDER_PT_opengl_lighting,
     RENDER_PT_opengl_color,
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index c9b70d681f4..52a603ede72 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 283
-#define BLENDER_SUBVERSION 15
+#define BLENDER_SUBVERSION 16
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 72d85f596ec..410d5b41057 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -155,6 +155,9 @@ static void scene_init_data(ID *id)
   scene->unit.mass_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_MASS);
   scene->unit.time_unit = (uchar)bUnit_GetBaseUnitOfType(USER_UNIT_METRIC, B_UNIT_TIME);
 
+  /* Anti-aliasing threshold. */
+  scene->grease_pencil_settings.smaa_threshold = 1.0f;
+
   {
     ParticleEditSettings *pset;
     pset = &scene->toolsettings->particle;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index d246eadb381..ff3909f5e1a 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -5052,6 +5052,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 283, 16)) {
+    /* Init SMAA threshold for grease pencil render. */
+    LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+      scene->grease_pencil_settings.smaa_threshold = 1.0f;
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
index e81073db4a5..4dd5e3b2da1 100644
--- a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
+++ b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c
@@ -115,6 +115,8 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata)
     DRW_shgroup_uniform_texture(grp, "colorTex", pd->color_tx);
     DRW_shgroup_uniform_texture(grp, "revealTex", pd->reveal_tx);
     DRW_shgroup_uniform_vec4_copy(grp, "viewportMetrics", metrics);
+    DRW_shgroup_uniform_float_copy(
+        grp, "lumaWeight", pd->scene->grease_pencil_settings.smaa_threshold);
 
     DRW_shgroup_clear_framebuffer(grp, GPU_COLOR_BIT, 0, 0, 0, 0, 0.0f, 0x0);
     DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c
index fe095b1b916..6284e0a648c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader.c
@@ -135,10 +135,11 @@ GPUShader *GPENCIL_shader_antialiasing(int stage)
             },
         .defs =
             (const char *[]){
+                "uniform float lumaWeight;\n",
                 "#define SMAA_GLSL_3\n",
                 "#define SMAA_RT_METRICS viewportMetrics\n",
                 "#define SMAA_PRESET_HIGH\n",
-                "#define SMAA_LUMA_WEIGHT float4(1.0, 1.0, 1.0, 0.0)\n",
+                "#define SMAA_LUMA_WEIGHT float4(lumaWeight, lumaWeight, lumaWeight, 0.0)\n",
                 "#define SMAA_NO_DISCARD\n",
                 stage_define,
                 NULL,
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index f4834355223..2c931e68875 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1644,6 +1644,11 @@ typedef struct SceneEEVEE {
   float light_threshold;
 } SceneEEVEE;
 
+typedef struct SceneGpencil {
+  float smaa_threshold;
+  char _pad[4];
+} SceneGpencil;
+
 /* *************************************************************** */
 /* Scene ID-Block */
 
@@ -1775,6 +1780,7 @@ typedef struct Scene {
 
   struct SceneDisplay display;
   struct SceneEEVEE eevee;
+  struct SceneGpencil grease_pencil_settings;
 } Scene;
 
 /* **************** RENDERDATA ********************* */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index ac57d7a1b18..b16eb17747b 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1137,6 +1137,11 @@ static char *rna_SceneEEVEE_path(PointerRNA *UNUSED(ptr))
   return BLI_strdup("eevee");
 }
 
+static char *rna_SceneGpencil_path(PointerRNA *UNUSED(ptr))
+{
+  return BLI_strdup("grease_pencil_settings");
+}
+
 static int rna_RenderSettings_stereoViews_skip(CollectionPropertyIterator *iter,
                                                void *UNUSED(data))
 {
@@ -7194,6 +7199,28 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
 }
 
+static void rna_def_scene_gpencil(BlenderRNA *brna)
+{
+  StructRNA *srna;
+  PropertyRNA *prop;
+
+  srna = RNA_def_struct(brna, "SceneGpencil", NULL);
+  RNA_def_struct_path_func(srna, "rna_SceneGpencil_path");
+  RNA_def_struct_ui_text(srna, "Grease Pencil Render", "Render settings");
+
+  prop = RNA_def_property(srna, "antialias_threshold", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "smaa_threshold");
+  RNA_def_property_float_default(prop, 1.0f);
+  RNA_def_property_range(prop, 0.0f, FLT_MAX);
+  RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
+  RNA_def_property_ui_text(prop,
+                           "Anti-Aliasing Threshold",
+                           "Threshold for edge detection algorithm (higher values might overblur "
+                           "some part of the image)");
+  RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+  RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
+}
+
 void RNA_def_scene(BlenderRNA *brna)
 {
   StructRNA *srna;
@@ -7667,6 +7694,11 @@ void RNA_def_scene(BlenderRNA *brna)
   RNA_def_property_struct_type(prop, "SceneEEVEE");
   RNA_def_property_ui_text(prop, "EEVEE", "EEVEE settings for the scene");
 
+  /* Grease Pencil */
+  prop = RNA_def_property(srna, "grease_pencil_settings", PROP_POINTER, PROP_NONE);
+  RNA_def_property_struct_type(prop, "SceneGpencil");
+  RNA_def_property_ui_text(prop, "Grease Pencil", "Grease Pencil settings for the scene");
+
   /* Nestled Data  */
   /* *** Non-Animated *** */
   RNA_define_animate_sdna(false);
@@ -7685,6 +7717,7 @@ void RNA_def_scene(BlenderRNA *brna)
   rna_def_scene_display(brna);
   rna_def_scene_eevee(brna);
   rna_def_view_layer_eevee(brna);
+  rna_def_scene_gpencil(brna);
   RNA_define_animate_sdna(true);
   /* *** Animated *** */
   rna_def_scene_render_data(brna);



More information about the Bf-blender-cvs mailing list