[Bf-blender-cvs] [32c3c985680] temp-lineart-contained: LineArt: 8 bit transp flag for mat.
YimingWu
noreply at git.blender.org
Mon Jun 28 09:38:09 CEST 2021
Commit: 32c3c98568031308f573ad70cab06deb65b5fe87
Author: YimingWu
Date: Mon Jun 28 15:37:44 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB32c3c98568031308f573ad70cab06deb65b5fe87
LineArt: 8 bit transp flag for mat.
===================================================================
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_cpu.c
M source/blender/makesdna/DNA_material_types.h
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 6c7837237e4..80d62a63410 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -295,7 +295,7 @@ class MATERIAL_PT_lineart(MaterialButtonsPanel, Panel):
row = layout.row(align=True, heading="Masks")
row.active = lineart.use_transparency
- for i in range(6):
+ for i in range(8):
row.prop(lineart, "use_transparency_mask", text=str(i), index=i, toggle=True)
row = layout.row(align=True, heading="Custom occlusion effectiveness")
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 2af3f66eb75..097acd4f816 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -502,7 +502,7 @@ static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
char text[2] = "0";
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_transparency_mask");
- for (int i = 0; i < 6; i++, text[0]++) {
+ 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. */
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 2efc8b0030a..c04bcde9a94 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -54,6 +54,7 @@ typedef struct LineartTriangle {
unsigned char transparency_mask;
unsigned char intersection_mask;
+ unsigned char occlusion_effectiveness;
unsigned char flags; /* #eLineartTriangleFlags */
/**
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 1205a7cc56e..7698a513db6 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -147,8 +147,12 @@ static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb)
/**
* Cuts the edge in image space and mark occlusion level for each segment.
*/
-static void lineart_edge_cut(
- LineartRenderBuffer *rb, LineartEdge *e, double start, double end, uchar transparency_mask)
+static void lineart_edge_cut(LineartRenderBuffer *rb,
+ LineartEdge *e,
+ double start,
+ double end,
+ uchar transparency_mask,
+ uchar occlusion_effectiveness)
{
LineartEdgeSegment *es, *ies, *next_es, *prev_es;
LineartEdgeSegment *cut_start_before = 0, *cut_end_before = 0;
@@ -283,8 +287,8 @@ static void lineart_edge_cut(
/* Register 1 level of occlusion for all touched segments. */
for (es = ns; es && es != ns2; es = es->next) {
- es->occlusion += (transparency_mask & LRT_OCCLUSION_EFFECTIVE_BITS);
- es->transparency_mask |= (transparency_mask & LRT_TRANSPARENCY_BITS);
+ es->occlusion += occlusion_effectiveness;
+ es->transparency_mask |= transparency_mask;
}
/* Reduce adjacent cutting points of the same level, which saves memory. */
@@ -378,7 +382,7 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
lineart_occlusion_is_adjacent_intersection(e, (LineartTriangle *)tri) ||
/* Or if this triangle isn't effectively occluding anything nor it's providing a
transparency flag. */
- (!tri->base.transparency_mask)) {
+ (!tri->base.occlusion_effectiveness)) {
continue;
}
tri->testing_e[thread_id] = e;
@@ -394,7 +398,8 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
rb->shift_y,
&l,
&r)) {
- lineart_edge_cut(rb, e, l, r, tri->base.transparency_mask);
+ lineart_edge_cut(
+ rb, e, l, r, tri->base.transparency_mask, tri->base.occlusion_effectiveness);
if (e->min_occ > rb->max_occlusion_level) {
/* No need to calculate any longer on this line because no level more than set value is
* going to show up in the rendered result. */
@@ -1854,9 +1859,9 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu
/* bits are shifted to higher 6 bits. See MaterialLineArt::transparency_mask for details. */
Material *mat = BKE_object_material_get(orig_ob, f->mat_nr + 1);
tri->transparency_mask |= ((mat && (mat->lineart.flags & LRT_MATERIAL_TRANSPARENCY_ENABLED)) ?
- (mat->lineart.transparency_mask << 2) :
+ mat->lineart.transparency_mask :
0);
- tri->transparency_mask |=
+ tri->occlusion_effectiveness |=
((mat && (mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) ?
mat->lineart.occlusion_effectiveness & LRT_OCCLUSION_EFFECTIVE_BITS :
1);
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 4c328dd08fb..d6e82bd89f1 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -168,8 +168,6 @@ typedef enum eMaterialLineArtFlags {
LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS = (1 << 1),
} eMaterialLineArtFlags;
-#define LRT_TRANSPARENCY_BITS_DNA 0x3f /* Bits 1<<0 to 1<<6. */
-#define LRT_TRANSPARENCY_BITS 0xfc /* Bits 1<<2 to 1<<7. */
#define LRT_OCCLUSION_EFFECTIVE_BITS 0x03 /* Bits 1<<0 to 1<<1. */
typedef struct Material {
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index c0a9b7ba9d8..2a5c9f32d1c 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -698,7 +698,7 @@ static void rna_def_material_lineart(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_transparency_mask", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_boolean_sdna(prop, NULL, "transparency_mask", 1);
- RNA_def_property_array(prop, 6);
+ RNA_def_property_array(prop, 8);
RNA_def_property_ui_text(prop, "Mask", "");
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update");
More information about the Bf-blender-cvs
mailing list