diff options
author | Yiming Wu <xp8110@outlook.com> | 2022-06-29 17:54:29 +0300 |
---|---|---|
committer | Yiming Wu <xp8110@outlook.com> | 2022-06-29 17:54:29 +0300 |
commit | 6dd8ceef2a21f64cbb61a96560c50c162f9dae39 (patch) | |
tree | dff82af871b36d7df37213cdcc2a94dfd1ca70b2 /source/blender/makesrna | |
parent | 2ac5b55289d361de7fccc9be188b98df358ab932 (diff) |
LineArt: Shadow and related functionalities.
This patch includes the full shadow functionality for LineArt:
- Light contour and cast shadow lines.
- Lit/shaded region selection.
- Enclosed light/shadow shape calculation.
- Silhouette/anti-silhouette selection.
- Intersection priority based on shadow edge identifier.
Reviewed By: Sebastian Parborg (zeddb)
Differential Revision: https://developer.blender.org/D15109
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_collection.c | 16 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_gpencil_modifier.c | 92 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 16 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 16 |
4 files changed, 137 insertions, 3 deletions
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c index 599d36c0af7..8cd83ddcf12 100644 --- a/source/blender/makesrna/intern/rna_collection.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -549,6 +549,22 @@ void RNA_def_collections(BlenderRNA *brna) prop, "Masks", "Intersection generated by this collection will have this mask value"); RNA_def_property_update(prop, NC_SCENE, NULL); + prop = RNA_def_property(srna, "lineart_intersection_priority", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 255); + RNA_def_property_ui_text(prop, + "Intersection Priority", + "The intersection line will be included into the object with the " + "higher intersection priority value"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop = RNA_def_property(srna, "use_lineart_intersection_priority", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna( + prop, NULL, "lineart_flags", COLLECTION_LRT_USE_INTERSECTION_PRIORITY); + RNA_def_property_ui_text( + prop, "Use Intersection Priority", "Assign intersection priority value for this collection"); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop = RNA_def_property(srna, "color_tag", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "color_tag"); RNA_def_property_enum_funcs( diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c index 47bed955b54..89bfb5684e2 100644 --- a/source/blender/makesrna/intern/rna_gpencil_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c @@ -3196,6 +3196,20 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}, }; + 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", ""}, + {0, NULL, 0, NULL, NULL}, + }; + + static const EnumPropertyItem modifier_lineart_silhouette_filtering[] = { + {LRT_SILHOUETTE_FILTER_NONE, "NONE", 0, "Contour", ""}, + {LRT_SILHOUETTE_FILTER_GROUP, "GROUP", 0, "Silhouette", ""}, + {LRT_SILHOUETTE_FILTER_INDIVIDUAL, "INDIVIDUAL", 0, "Individual Silhouette", ""}, + {0, NULL, 0, NULL, NULL}, + }; + srna = RNA_def_struct(brna, "LineartGpencilModifier", "GpencilModifier"); RNA_def_struct_ui_text( srna, "Line Art Modifier", "Generate line art strokes from selected source"); @@ -3208,7 +3222,7 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_USE_CUSTOM_CAMERA); RNA_def_property_ui_text( prop, "Use Custom Camera", "Use custom camera instead of the active camera"); - RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); prop = RNA_def_property(srna, "use_fuzzy_intersections", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_INTERSECTION_AS_CONTOUR); @@ -3250,8 +3264,11 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_ANGLE); RNA_def_property_range(prop, 0, DEG2RAD(180.0f)); RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1); - RNA_def_property_ui_text( - prop, "Crease Threshold", "Angles smaller than this will be treated as creases"); + RNA_def_property_ui_text(prop, + "Crease Threshold", + "Angles smaller than this will be treated as creases. Crease angle " + "priority: object line art crease override > mesh auto smooth angle > " + "line art default crease."); RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update"); prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE); @@ -3367,6 +3384,14 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) prop, "Camera Object", "Use specified camera object for generating line art"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + prop = RNA_def_property(srna, "light_contour_object", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); + RNA_def_property_ui_text( + prop, "Light Object", "Use this light object to generate light contour"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + prop = RNA_def_property(srna, "source_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, modifier_lineart_source_type); RNA_def_property_ui_text(prop, "Source Type", "Line art stroke source type"); @@ -3417,6 +3442,41 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Intersection", "Generate strokes from intersections"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "use_light_contour", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", LRT_EDGE_FLAG_LIGHT_CONTOUR); + RNA_def_property_ui_text(prop, + "Use Light Contour", + "Generate light/shadow separation lines from a reference light object"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "use_shadow", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "edge_types", LRT_EDGE_FLAG_PROJECTED_SHADOW); + RNA_def_property_ui_text( + prop, "Use Shadow", "Project contour lines using a light shource object"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "shadow_region_filtering", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "shadow_selection"); + RNA_def_property_enum_items(prop, modifier_lineart_shadow_region_filtering); + RNA_def_property_ui_text(prop, + "Shadow Region Filtering", + "Select feature lines that comes from lit or shaded regions. Will not " + "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, "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); + RNA_def_property_ui_text(prop, "Silhouette Filtering", "Select contour or silhouette"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update"); + prop = RNA_def_property(srna, "use_multiple_levels", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_multiple_levels", 0); RNA_def_property_ui_text( @@ -3558,6 +3618,27 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) "different occlusion levels than when disabled"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "shadow_camera_near", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Shadow Camera Near", "Near clipping distance of shadow camera"); + RNA_def_property_ui_range(prop, 0.0f, 500.0f, 0.1f, 2); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "shadow_camera_far", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Shadow Camera Far", "Far clipping distance of shadow camera"); + RNA_def_property_ui_range(prop, 0.0f, 500.0f, 0.1f, 2); + RNA_def_property_range(prop, 0.0f, 10000.0f); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + + prop = RNA_def_property(srna, "shadow_camera_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, + "Shadow Camera Size", + "This value represent the \"Orthographic Scale\" of an ortho camera." + "If the camera is put at the lamps position with this scale, it will " + "represent the coverage of the shadow \"camera\" "); + RNA_def_property_ui_range(prop, 0.0f, 500.0f, 0.1f, 2); + RNA_def_property_range(prop, 0.0f, 10000.0f); + prop = RNA_def_property(srna, "use_invert_collection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_INVERT_COLLECTION); RNA_def_property_ui_text(prop, @@ -3565,6 +3646,11 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna) "Select everything except lines from specified collection"); RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + prop = RNA_def_property(srna, "use_invert_silhouette", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_INVERT_SILHOUETTE_FILTER); + RNA_def_property_ui_text(prop, "Invert Silhouette Filtering", "Select anti-silhouette lines"); + RNA_def_property_update(prop, 0, "rna_GpencilModifier_update"); + RNA_define_lib_overridable(false); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 4fb7495bac8..4a9bc608598 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -754,6 +754,22 @@ static void rna_def_material_lineart(BlenderRNA *brna) "Effectiveness", "Faces with this material will behave as if it has set number of layers in occlusion"); RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 255); + RNA_def_property_ui_text(prop, + "Intersection Priority", + "The intersection line will be included into the object with the " + "higher intersection priority value"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); + + prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_default(prop, 0); + RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY); + RNA_def_property_ui_text(prop, + "Use Intersection Priority", + "Override object and collection intersection priority value"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_MaterialLineArt_update"); } void RNA_def_material(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 46e8b3beb02..99315a580cf 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2950,6 +2950,22 @@ static void rna_def_object_lineart(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1); RNA_def_property_ui_text(prop, "Crease", "Angles smaller than this will be treated as creases"); RNA_def_property_update(prop, 0, "rna_object_lineart_update"); + + prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", OBJECT_LRT_OWN_INTERSECTION_PRIORITY); + RNA_def_property_ui_text( + prop, + "Use Intersection Priority", + "Use this object's intersection priority to override collection setting"); + RNA_def_property_update(prop, 0, "rna_object_lineart_update"); + + prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 255); + RNA_def_property_ui_text(prop, + "Intersection Priority", + "The intersection line will be included into the object with the " + "higher intersection priority value"); + RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_object_lineart_update"); } static void rna_def_object_visibility(StructRNA *srna) |