Commit: 09b2374ac0d7d8185200bf5738afaf845aa6d745
Author: YimingWu
Date: Sun Aug 16 16:49:18 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB09b2374ac0d7d8185200bf5738afaf845aa6d745
LineArt: Transparency mask selection in modifier.
===================================================================
M source/blender/editors/include/ED_lineart.h
M source/blender/editors/lineart/lineart_chain.c
M source/blender/editors/lineart/lineart_cpu.c
M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M source/blender/makesdna/DNA_gpencil_modifier_types.h
M source/blender/makesrna/intern/rna_gpencil_modifier.c
===================================================================
diff --git a/source/blender/editors/include/ED_lineart.h
b/source/blender/editors/include/ED_lineart.h
index 8daaacabfba..0d1dab89ee5 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -539,6 +539,8 @@ void ED_lineart_gpencil_generate_from_chain(struct
Depsgraph *depsgraph,
int material_nr,
struct Collection *col,
int types,
+ unsigned char transparency_flags,
+ unsigned char transparency_mask,
short thickness,
float opacity,
float pre_sample_length);
@@ -552,6 +554,8 @@ void ED_lineart_gpencil_generate_strokes_direct(struct
Depsgraph *depsgraph,
int level_end,
int mat_nr,
short line_types,
+ unsigned char
transparency_flags,
+ unsigned char
transparency_mask,
short thickness,
float opacity,
float pre_sample_length);
diff --git a/source/blender/editors/lineart/lineart_chain.c
b/source/blender/editors/lineart/lineart_chain.c
index 55c1ec3ab4e..eee5d8f63c6 100644
--- a/source/blender/editors/lineart/lineart_chain.c
+++ b/source/blender/editors/lineart/lineart_chain.c
@@ -627,12 +627,14 @@ void
ED_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
rlci->normal,
rlci->line_type,
fixed_occ,
- rlci->transparency_mask);
+ fixed_mask);
new_rlc->object_ref = rlc->object_ref;
new_rlc->type = rlc->type;
rlc = new_rlc;
fixed_occ = rlci->occlusion;
+ fixed_mask = rlci->transparency_mask;
rlc->level = fixed_occ;
+ rlc->transparency_mask = fixed_mask;
}
}
}
diff --git a/source/blender/editors/lineart/lineart_cpu.c
b/source/blender/editors/lineart/lineart_cpu.c
index 18ff8ad25c1..997c1892667 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -1499,7 +1499,7 @@ static void lineart_geometry_object_load(Object *ob,
rt->rl[2] = &orl[BM_elem_index_get(loop->e)];
rt->material_id = f->mat_nr;
- Material *mat = BKE_object_material_get(ob, f->mat_nr);
+ Material *mat = BKE_object_material_get(ob, f->mat_nr + 1);
rt->transparency_mask = ((mat && (mat->lineart.flags &
LRT_MATERIAL_TRANSPARENCY_ENABLED)) ?
mat->lineart.transparency_mask :
0);
@@ -3658,6 +3658,8 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph
*UNUSED(depsgraph),
int material_nr,
Collection *col,
int types,
+ unsigned char transparency_flags,
+ unsigned char transparency_mask,
short thickness,
float opacity,
float pre_sample_length)
@@ -3717,6 +3719,18 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph
*UNUSED(depsgraph),
continue;
}
}
+ if (transparency_flags & LRT_GPENCIL_TRANSPARENCY_ENABLE) {
+ if (transparency_flags & LRT_GPENCIL_TRANSPARENCY_MATCH) {
+ if (rlc->transparency_mask != transparency_mask) {
+ continue;
+ }
+ }
+ else {
+ if (!(rlc->transparency_mask & transparency_mask)) {
+ continue;
+ }
+ }
+ }
/* Modifier for different GP objects are not evaluated in order, thus
picked flag doesn't quite
* make sense. Should have a batter solution if we don't want to pick the
same stroke twice. */
@@ -3764,6 +3778,8 @@ void ED_lineart_gpencil_generate_strokes_direct(Depsgraph
*depsgraph,
int level_end,
int mat_nr,
short line_types,
+ unsigned char
transparency_flags,
+ unsigned char
transparency_mask,
short thickness,
float opacity,
float pre_sample_length)
@@ -3794,6 +3810,8 @@ void ED_lineart_gpencil_generate_strokes_direct(Depsgraph
*depsgraph,
mat_nr,
source_collection,
use_types,
+ transparency_flags,
+ transparency_mask,
thickness,
opacity,
pre_sample_length);
@@ -3896,6 +3914,8 @@ static int lineart_gpencil_bake_strokes_exec(bContext *C,
wmOperator *UNUSED(op)
BKE_gpencil_object_material_index_get(ob,
lmd->target_material) :
0,
use_types,
+ lmd->transparency_flags,
+ lmd->transparency_mask,
lmd->thickness,
lmd->opacity,
lmd->pre_sample_length);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 0aaa8c19390..fea3757a3f6 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -103,6 +103,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->line_types,
+ lmd->transparency_flags,
+ lmd->transparency_mask,
lmd->thickness,
lmd->opacity,
lmd->pre_sample_length);
@@ -374,6 +376,7 @@ static void occlusion_panel_draw(const bContext *C, Panel
*panel)
uiItemR(layout, &ptr, "pre_sample_length", UI_ITEM_R_SLIDER, NULL,
ICON_NONE);
bool use_multiple_levels = RNA_boolean_get(&ptr, "use_multiple_levels");
+ bool use_transparency = RNA_boolean_get(&ptr, "use_transparency");
uiItemR(layout, &ptr, "use_multiple_levels", 0, "Multiple Levels",
ICON_NONE);
@@ -385,6 +388,20 @@ static void occlusion_panel_draw(const bContext *C, Panel
*panel)
else {
uiItemR(layout, &ptr, "level_start", 0, "Level", ICON_NONE);
}
+
+ uiItemR(layout, &ptr, "use_transparency", 0, "Transparency", ICON_NONE);
+
+ if (use_transparency) {
+ uiLayout *col = uiLayoutRow(layout, true);
+ uiItemR(col, &ptr, "transparency_mask_0", UI_ITEM_R_TOGGLE, "0",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_1", UI_ITEM_R_TOGGLE, "1",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_2", UI_ITEM_R_TOGGLE, "2",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_3", UI_ITEM_R_TOGGLE, "3",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_4", UI_ITEM_R_TOGGLE, "4",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_5", UI_ITEM_R_TOGGLE, "5",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_6", UI_ITEM_R_TOGGLE, "6",
ICON_NONE);
+ uiItemR(col, &ptr, "transparency_mask_7", UI_ITEM_R_TOGGLE, "7",
ICON_NONE);
+ }
}
static void panelRegister(ARegionType *region_type)
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h
b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index b312517ffe3..7ac07c7673f 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -802,6 +802,12 @@ typedef enum eLineartGpencilModifierSource {
LRT_SOURCE_OBJECT = 1,
} eLineartGpencilModifierSource;
+typedef enum eLineartGpencilTransparencyFlags {
+ LRT_GPENCIL_TRANSPARENCY_ENABLE = (1 << 0),
+ /** Set to true means using "and" instead of "or" logic on mask bits. */
+ LRT_GPENCIL_TRANSPARENCY_MATCH = (1 << 1),
+} eLineartGpencilTransparencyFlags;
+
typedef struct LineartGpencilModifierData {
GpencilModifierData modifier;
@@ -821,10 +827,11 @@ typedef struct LineartGpencilModifierData {
float opacity;
short thickness;
- short _pad;
+
+ unsigned char transparency_flags; /* eLineartGpencilTransparencyFlags */
+ unsigned char transparency_mask;
float pre_sample_length;
int _pad2;
} LineartGpencilModifierData;
-
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c
b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 7ae3a34fa73..48a76d31116 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2418,6 +2418,67 @@ static void rna_def_modifier_gpencillineart(BlenderRNA
*brna)
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 2);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "use_transparency", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "transparency_flags",
LRT_GPENCIL_TRANSPARENCY_ENABLE);
+ RNA_def_property_boolean_default(prop, 0);
+ RNA_def_property_ui_text(
+ prop, "Use Transparency", "Use transparency mask from this material in
Line Art");
+ RNA_def_property_update(prop,
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs