[Bf-blender-cvs] [cf21ba37efa] master: LineArt: Occlusion effectiveness support

YimingWu noreply at git.blender.org
Mon Jun 28 16:28:18 CEST 2021


Commit: cf21ba37efafbedc9e5d7f8624ce82370fe17a62
Author: YimingWu
Date:   Mon Jun 28 22:26:23 2021 +0800
Branches: master
https://developer.blender.org/rBcf21ba37efafbedc9e5d7f8624ce82370fe17a62

LineArt: Occlusion effectiveness support

This patch adds a function where you can specify occlusion effectiveness from 0 to 255 layers per face for a given mesh material.

Reviewed By: Sebastian Parborg (zeddb)

Ref D11308

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

M	release/scripts/startup/bl_ui/properties_material.py
M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
M	source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M	source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesdna/DNA_material_types.h
M	source/blender/makesdna/intern/dna_rename_defs.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 217ec248764..b217e33de12 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -291,12 +291,18 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
         mat = context.material
         lineart = mat.lineart
 
-        layout.prop(lineart, "use_transparency")
+        layout.prop(lineart, "use_material_mask")
 
         row = layout.row(align=True, heading="Masks")
-        row.active = lineart.use_transparency
+        row.active = lineart.use_material_mask
         for i in range(8):
-            row.prop(lineart, "use_transparency_mask", text=str(i), index=i, toggle=True)
+            row.prop(lineart, "use_material_mask_bits", text=str(i), index=i, toggle=True)
+
+        row = layout.row(align=True, heading="Custom Occlusion")
+        row.prop(lineart, "use_mat_occlusion", text="")
+        sub = row.row(align=False)
+        sub.active = lineart.use_mat_occlusion
+        sub.prop(lineart, "mat_occlusion", slider=True, text="Levels")
 
 
 classes = (
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index b87ed9e431a..99f2592030e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -101,8 +101,8 @@ static void generate_strokes_actual(
       lmd->use_multiple_levels ? lmd->level_end : lmd->level_start,
       lmd->target_material ? BKE_gpencil_object_material_index_get(ob, lmd->target_material) : 0,
       lmd->edge_types,
-      lmd->transparency_flags,
-      lmd->transparency_mask,
+      lmd->material_mask_flags,
+      lmd->material_mask_bits,
       lmd->thickness,
       lmd->opacity,
       lmd->source_vertex_group,
@@ -411,7 +411,7 @@ static void occlusion_panel_draw(const bContext *UNUSED(C), Panel *panel)
   }
 }
 
-static void transparency_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
+static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
 {
   uiLayout *layout = panel->layout;
   PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
@@ -419,10 +419,10 @@ static void transparency_panel_draw_header(const bContext *UNUSED(C), Panel *pan
   const bool is_baked = RNA_boolean_get(ptr, "is_baked");
   uiLayoutSetEnabled(layout, !is_baked);
 
-  uiItemR(layout, ptr, "use_transparency", 0, IFACE_("Transparency"), ICON_NONE);
+  uiItemR(layout, ptr, "use_material_mask", 0, IFACE_("Material Mask"), ICON_NONE);
 }
 
-static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
+static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
 {
   uiLayout *layout = panel->layout;
   PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
@@ -432,21 +432,21 @@ static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
 
   uiLayoutSetPropSep(layout, true);
 
-  uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_transparency"));
+  uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_material_mask"));
 
   uiLayout *row = uiLayoutRow(layout, true);
   uiLayoutSetPropDecorate(row, false);
   uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks"));
   char text[2] = "0";
 
-  PropertyRNA *prop = RNA_struct_find_property(ptr, "use_transparency_mask");
+  PropertyRNA *prop = RNA_struct_find_property(ptr, "use_material_mask_bits");
   for (int i = 0; i < 8; i++, text[0]++) {
     uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE);
   }
   uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */
 
   uiLayout *col = uiLayoutColumn(layout, true);
-  uiItemR(col, ptr, "use_transparency_match", 0, IFACE_("Match All Masks"), ICON_NONE);
+  uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Match All Masks"), ICON_NONE);
 }
 
 static void face_mark_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
@@ -606,10 +606,10 @@ static void panelRegister(ARegionType *region_type)
   PanelType *occlusion_panel = gpencil_modifier_subpanel_register(
       region_type, "occlusion", "Occlusion", NULL, occlusion_panel_draw, panel_type);
   gpencil_modifier_subpanel_register(region_type,
-                                     "transparency",
+                                     "material_mask",
                                      "",
-                                     transparency_panel_draw_header,
-                                     transparency_panel_draw,
+                                     material_mask_panel_draw_header,
+                                     material_mask_panel_draw,
                                      occlusion_panel);
   gpencil_modifier_subpanel_register(
       region_type, "face_mark", "", face_mark_panel_draw_header, face_mark_panel_draw, panel_type);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index d78cd862383..090c9d0f8fc 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -53,7 +53,8 @@ typedef struct LineartTriangle {
   double gn[3];
 
   /* Material flag is removed to save space. */
-  unsigned char transparency_mask;
+  unsigned char material_mask_bits;
+  unsigned char mat_occlusion;
   unsigned char flags; /* #eLineartTriangleFlags */
 
   /**
@@ -101,13 +102,8 @@ typedef struct LineartEdgeSegment {
   /** Occlusion level after "at" point */
   unsigned char occlusion;
 
-  /**
-   * For determining lines behind a glass window material.
-   * the size of this variable should also be dynamically decided, 1 byte to 8 byte,
-   * allows 8 to 64 materials for "transparent mask". 1 byte (8 materials) should be
-   * enough for most cases.
-   */
-  unsigned char transparency_mask;
+  /* Used to filter line art occlusion edges */
+  unsigned char material_mask_bits;
 } LineartEdgeSegment;
 
 typedef struct LineartVert {
@@ -177,7 +173,7 @@ typedef struct LineartEdgeChain {
 
   /** Chain now only contains one type of segments */
   int type;
-  unsigned char transparency_mask;
+  unsigned char material_mask_bits;
 
   struct Object *object_ref;
 } LineartEdgeChain;
@@ -191,7 +187,7 @@ typedef struct LineartEdgeChainItem {
   float normal[3];
   unsigned char line_type;
   char occlusion;
-  unsigned char transparency_mask;
+  unsigned char material_mask_bits;
   size_t index;
 } LineartEdgeChainItem;
 
@@ -616,8 +612,8 @@ void MOD_lineart_gpencil_generate(LineartCache *cache,
                                   int level_end,
                                   int mat_nr,
                                   short edge_types,
-                                  unsigned char transparency_flags,
-                                  unsigned char transparency_mask,
+                                  unsigned char material_mask_flags,
+                                  unsigned char material_mask_bits,
                                   short thickness,
                                   float opacity,
                                   const char *source_vgname,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 37ee93b5f0f..d14f0e0c7bf 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -103,7 +103,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
                                                         float *normal,
                                                         char type,
                                                         int level,
-                                                        unsigned char transparency_mask,
+                                                        unsigned char material_mask_bits,
                                                         size_t index)
 {
   LineartEdgeChainItem *eci;
@@ -115,7 +115,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
     LineartEdgeChainItem *old_rlci = ec->chain.last;
     old_rlci->line_type = type;
     old_rlci->occlusion = level;
-    old_rlci->transparency_mask = transparency_mask;
+    old_rlci->material_mask_bits = material_mask_bits;
     return old_rlci;
   }
 
@@ -127,7 +127,7 @@ static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
   copy_v3_v3(eci->normal, normal);
   eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
   eci->occlusion = level;
-  eci->transparency_mask = transparency_mask;
+  eci->material_mask_bits = material_mask_bits;
   BLI_addtail(&ec->chain, eci);
 
   return eci;
@@ -140,7 +140,7 @@ static LineartEdgeChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb
                                                          float *normal,
                                                          char type,
                                                          int level,
-                                                         unsigned char transparency_mask,
+                                                         unsigned char material_mask_bits,
                                                          size_t index)
 {
   LineartEdgeChainItem *eci;
@@ -157,7 +157,7 @@ static LineartEdgeChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb
   copy_v3_v3(eci->normal, normal);
   eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
   eci->occlusion = level;
-  eci->transparency_mask = transparency_mask;
+  eci->material_mask_bits = material_mask_bits;
   BLI_addhead(&ec->chain, eci);
 
   return eci;
@@ -228,7 +228,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
                                 N,
                                 e->flags,
                                 es->occlusion,
-                                es->transparency_mask,
+               

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list