diff options
7 files changed, 59 insertions, 34 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index 77616ae13b6..6bb59f29b98 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -373,19 +373,16 @@ static void edge_types_panel_draw(const bContext *UNUSED(C), Panel *panel) } sub = uiLayoutRow(col, false); - uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE); - entry = uiLayoutColumn(sub, false); - uiItemL(entry, IFACE_("Crease"), ICON_NONE); - uiLayoutSetActive(entry, RNA_boolean_get(ptr, "use_crease") || is_first); if (use_cache && !is_first) { - uiItemL(entry, IFACE_("Crease Angle Cached"), ICON_INFO); + uiItemR(sub, ptr, "use_crease", 0, IFACE_("Crease (Angle Cached)"), ICON_NONE); } else { - uiItemR(entry, + uiItemR(sub, ptr, "use_crease", 0, "", ICON_NONE); + uiItemR(sub, ptr, "crease_threshold", UI_ITEM_R_SLIDER | UI_ITEM_R_FORCE_BLANK_DECORATE, - IFACE_("Default Angle"), + NULL, ICON_NONE); } @@ -447,8 +444,6 @@ static void options_light_reference_draw(const bContext *UNUSED(C), Panel *panel uiLayout *col = uiLayoutColumn(remaining, true); uiItemR(col, ptr, "shadow_camera_near", 0, "Near", ICON_NONE); uiItemR(col, ptr, "shadow_camera_far", 0, "Far", ICON_NONE); - - uiItemR(layout, ptr, "use_shadow_enclosed_shapes", 0, IFACE_("Enclosed Shapes"), ICON_NONE); } static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 5dd833fb12b..224146d0032 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -439,12 +439,17 @@ typedef enum eLineartTriangleFlags { } eLineartTriangleFlags; #define LRT_SHADOW_MASK_UNDEFINED 0 -#define LRT_SHADOW_MASK_LIT (1 << 0) +#define LRT_SHADOW_MASK_ILLUMINATED (1 << 0) #define LRT_SHADOW_MASK_SHADED (1 << 1) #define LRT_SHADOW_MASK_ENCLOSED_SHAPE (1 << 2) #define LRT_SHADOW_MASK_INHIBITED (1 << 3) #define LRT_SHADOW_SILHOUETTE_ERASED_GROUP (1 << 4) #define LRT_SHADOW_SILHOUETTE_ERASED_OBJECT (1 << 5) +#define LRT_SHADOW_MASK_ILLUMINATED_SHAPE (1 << 6) + +#define LRT_SHADOW_TEST_SHAPE_BITS \ + (LRT_SHADOW_MASK_ILLUMINATED | LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_INHIBITED | \ + LRT_SHADOW_MASK_ILLUMINATED_SHAPE) /** * Controls how many edges a worker thread is processing at one request. diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 874da3b88c9..011c79025c4 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -304,13 +304,12 @@ void lineart_edge_cut(LineartData *ld, /* The enclosed shape flag will override regular lit/shaded * flags. See LineartEdgeSegment::shadow_mask_bits for details. */ if (shadow_bits == LRT_SHADOW_MASK_ENCLOSED_SHAPE) { - if (seg->shadow_mask_bits & LRT_SHADOW_MASK_LIT || e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { - seg->shadow_mask_bits &= ~LRT_SHADOW_MASK_LIT; + if (seg->shadow_mask_bits & LRT_SHADOW_MASK_ILLUMINATED || + e->flags & LRT_EDGE_FLAG_LIGHT_CONTOUR) { seg->shadow_mask_bits |= LRT_SHADOW_MASK_INHIBITED; } else if (seg->shadow_mask_bits & LRT_SHADOW_MASK_SHADED) { - seg->shadow_mask_bits &= ~LRT_SHADOW_MASK_SHADED; - seg->shadow_mask_bits |= LRT_SHADOW_MASK_LIT; + seg->shadow_mask_bits |= LRT_SHADOW_MASK_ILLUMINATED_SHAPE; } } else { @@ -3643,7 +3642,8 @@ static LineartData *lineart_create_render_buffer(Scene *scene, (lmd->light_contour_object != NULL)); ld->conf.shadow_selection = lmd->shadow_selection_override; - ld->conf.shadow_enclose_shapes = (lmd->calculation_flags & LRT_SHADOW_ENCLOSED_SHAPES) != 0; + ld->conf.shadow_enclose_shapes = lmd->shadow_selection_override == + LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES; ld->conf.shadow_use_silhouette = lmd->shadow_use_silhouette_override != 0; ld->conf.use_back_face_culling = (lmd->calculation_flags & LRT_USE_BACK_FACE_CULLING) != 0; @@ -5227,13 +5227,22 @@ static void lineart_gpencil_generate(LineartCache *cache, } if (shaodow_selection) { if (ec->shadow_mask_bits != LRT_SHADOW_MASK_UNDEFINED) { - /* TODO(@Yiming): Give a behavior option for how to display undefined shadow info. */ - if ((shaodow_selection == LRT_SHADOW_FILTER_LIT && - (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_LIT))) || - (shaodow_selection == LRT_SHADOW_FILTER_SHADED && - (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_SHADED)))) { + /* TODO(Yiming): Give a behaviour option for how to display undefined shadow info. */ + if ((shaodow_selection == LRT_SHADOW_FILTER_ILLUMINATED && + (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_ILLUMINATED)))) { continue; } + else if ((shaodow_selection == LRT_SHADOW_FILTER_SHADED && + (!(ec->shadow_mask_bits & LRT_SHADOW_MASK_SHADED)))) { + continue; + } + else if (shaodow_selection == LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES) { + uint32_t test_bits = ec->shadow_mask_bits & LRT_SHADOW_TEST_SHAPE_BITS; + if ((test_bits != LRT_SHADOW_MASK_ILLUMINATED) && + (test_bits != (LRT_SHADOW_MASK_SHADED | LRT_SHADOW_MASK_ILLUMINATED_SHAPE))) { + continue; + } + } } } if (silhouette_mode && (ec->type & (LRT_EDGE_FLAG_CONTOUR))) { diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c index ad0137fe0f0..24762ce921d 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_shadow.c @@ -109,9 +109,10 @@ void lineart_register_shadow_cuts(LineartData *ld, LineartEdge *e, LineartEdge * la2 = la2 * e->v2->fbcoord[3] / (e->v1->fbcoord[3] - la2 * (e->v1->fbcoord[3] - e->v2->fbcoord[3])); unsigned char shadow_bits = (es->occlusion != 0) ? LRT_SHADOW_MASK_SHADED : - LRT_SHADOW_MASK_LIT; + LRT_SHADOW_MASK_ILLUMINATED; - if (lineart_contour_viewed_from_dark_side(ld, e) && shadow_bits == LRT_SHADOW_MASK_LIT) { + if (lineart_contour_viewed_from_dark_side(ld, e) && + shadow_bits == LRT_SHADOW_MASK_ILLUMINATED) { shadow_bits = LRT_SHADOW_MASK_SHADED; } diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 2bb95caddfb..7f8e436f007 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -999,9 +999,14 @@ typedef enum eLineartGpencilModifierSource { } eLineartGpencilModifierSource; typedef enum eLineartGpencilModifierShadowFilter { + /* These options need to be ordered in this way because those latter options requires line art to + run a few extra stages. Having those values set up this way will allow + #BKE_gpencil_get_lineart_modifier_limits() to find out maximum stages needed in multiple + cached line art modifiers. */ LRT_SHADOW_FILTER_NONE = 0, - LRT_SHADOW_FILTER_LIT = 1, + LRT_SHADOW_FILTER_ILLUMINATED = 1, LRT_SHADOW_FILTER_SHADED = 2, + LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES = 3, } eLineartGpencilModifierShadowFilter; typedef enum eLineartGpencilModifierSilhouetteFilter { diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h index 1ff656f85ed..05380325852 100644 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@ -38,7 +38,6 @@ typedef enum eLineartMainFlags { LRT_USE_BACK_FACE_CULLING = (1 << 19), LRT_USE_IMAGE_BOUNDARY_TRIMMING = (1 << 20), LRT_CHAIN_PRESERVE_DETAILS = (1 << 22), - LRT_SHADOW_ENCLOSED_SHAPES = (1 << 23), LRT_SHADOW_USE_SILHOUETTE = (1 << 24), } eLineartMainFlags; diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 0647bc62081..2dfd9d46665 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -3197,9 +3197,27 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) }; static const EnumPropertyItem modifier_lineart_shadow_region_filtering[] = { - {LRT_SHADOW_FILTER_NONE, "NONE", 0, "None", ""}, - {LRT_SHADOW_FILTER_LIT, "LIT", 0, "Lit", ""}, - {LRT_SHADOW_FILTER_SHADED, "SHADED", 0, "Shaded", ""}, + {LRT_SHADOW_FILTER_NONE, + "NONE", + 0, + "None", + "Not filtering any lines based on illumination region"}, + {LRT_SHADOW_FILTER_ILLUMINATED, + "ILLUMINATED", + 0, + "Illuminated", + "Only selecting lines from illuminated regions"}, + {LRT_SHADOW_FILTER_SHADED, + "SHADED", + 0, + "Shaded", + "Only selecting lines from shaded regions"}, + {LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES, + "ILLUMINATED_ENCLOSED", + 0, + "Illuminated (Enclosed Shapes)", + "Selecting lines from lit regions, and make the combination of contour, light contour and " + "shadow lines into enclosed shapes"}, {0, NULL, 0, NULL, NULL}, }; @@ -3464,13 +3482,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) "affect cast shadow and light contour since they are at the border"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); - prop = RNA_def_property(srna, "use_shadow_enclosed_shapes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_SHADOW_ENCLOSED_SHAPES); - RNA_def_property_ui_text(prop, - "Shadow Enclosed Shapes", - "Reproject visible lines again to get enclosed shadow shapes"); - RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); - prop = RNA_def_property(srna, "silhouette_filtering", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "silhouette_selection"); RNA_def_property_enum_items(prop, modifier_lineart_silhouette_filtering); |