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/makesdna | |
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/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_collection_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_modifier_defaults.h | 9 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_gpencil_modifier_types.h | 42 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_lineart_types.h | 25 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 5 |
6 files changed, 69 insertions, 23 deletions
diff --git a/source/blender/makesdna/DNA_collection_types.h b/source/blender/makesdna/DNA_collection_types.h index 8c437d69028..26011c990d4 100644 --- a/source/blender/makesdna/DNA_collection_types.h +++ b/source/blender/makesdna/DNA_collection_types.h @@ -40,6 +40,7 @@ enum eCollectionLineArt_Usage { enum eCollectionLineArt_Flags { COLLECTION_LRT_USE_INTERSECTION_MASK = (1 << 0), + COLLECTION_LRT_USE_INTERSECTION_PRIORITY = (1 << 1), }; typedef struct Collection { @@ -62,7 +63,8 @@ typedef struct Collection { short lineart_usage; /* eCollectionLineArt_Usage */ unsigned char lineart_flags; /* eCollectionLineArt_Flags */ unsigned char lineart_intersection_mask; - char _pad[6]; + unsigned char lineart_intersection_priority; + char _pad[5]; int16_t color_tag; diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h index ae47bf5d524..808e404cc1e 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h @@ -296,7 +296,7 @@ #define _DNA_DEFAULT_LineartGpencilModifierData \ { \ - .edge_types = LRT_EDGE_FLAG_ALL_TYPE, \ + .edge_types = LRT_EDGE_FLAG_INIT_TYPE, \ .thickness = 25, \ .opacity = 1.0f, \ .flags = LRT_GPENCIL_MATCH_OUTPUT_VGROUP, \ @@ -306,7 +306,12 @@ /* Do not split by default, this is for better chaining quality. */ \ .angle_splitting_threshold = 0.0f, \ .chaining_image_threshold = 0.001f, \ - .chain_smooth_tolerance = 0.2f,\ + .stroke_depth_offset = 0.05,\ + .chain_smooth_tolerance = 0.0f,\ + .overscan = 0.1f,\ + .shadow_camera_near = 0.1f, \ + .shadow_camera_far = 200.0f, \ + .shadow_camera_size = 200.0f, \ .stroke_depth_offset = 0.05,\ } diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h index 56963bae3e1..f6a54308efc 100644 --- a/source/blender/makesdna/DNA_gpencil_modifier_types.h +++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h @@ -998,6 +998,18 @@ typedef enum eLineartGpencilModifierSource { LRT_SOURCE_SCENE = 2, } eLineartGpencilModifierSource; +typedef enum eLineartGpencilModifierShadowFilter { + LRT_SHADOW_FILTER_NONE = 0, + LRT_SHADOW_FILTER_LIT = 1, + LRT_SHADOW_FILTER_SHADED = 2, +} eLineartGpencilModifierShadowFilter; + +typedef enum eLineartGpencilModifierSilhouetteFilter { + LRT_SILHOUETTE_FILTER_NONE = 0, + LRT_SILHOUETTE_FILTER_GROUP = (1 << 0), + LRT_SILHOUETTE_FILTER_INDIVIDUAL = (1 << 1), +} eLineartGpencilModifierSilhouetteFilter; + /* This enum is for modifier internal state only. */ typedef enum eLineArtGPencilModifierFlags { /* These two moved to #eLineartMainFlags to keep consistent with flag variable purpose. */ @@ -1008,6 +1020,7 @@ typedef enum eLineArtGPencilModifierFlags { LRT_GPENCIL_USE_CACHE = (1 << 4), LRT_GPENCIL_OFFSET_TOWARDS_CUSTOM_CAMERA = (1 << 5), LRT_GPENCIL_INVERT_COLLECTION = (1 << 6), + LRT_GPENCIL_INVERT_SILHOUETTE_FILTER = (1 << 7), } eLineArtGPencilModifierFlags; typedef enum eLineartGpencilMaskSwitches { @@ -1024,8 +1037,7 @@ struct LineartCache; typedef struct LineartGpencilModifierData { GpencilModifierData modifier; - /** Line type enable flags, bits in #eLineartEdgeFlag. */ - short edge_types; + uint16_t edge_types; /* line type enable flags, bits in eLineartEdgeFlag */ /** Object or Collection, from #eLineartGpencilModifierSource. */ char source_type; @@ -1035,6 +1047,7 @@ typedef struct LineartGpencilModifierData { short level_end; struct Object *source_camera; + struct Object *light_contour_object; struct Object *source_object; struct Collection *source_collection; @@ -1049,14 +1062,19 @@ typedef struct LineartGpencilModifierData { char source_vertex_group[64]; char vgname[64]; - /** - * Camera focal length is divided by `1 + overscan`, before calculation, which give a wider FOV, - * this doesn't change coordinates range internally (-1, 1), but makes the calculated frame + /* Camera focal length is divided by (1 + overscan), before caluclation, which give a wider FOV, + * this doesn't change coordinates range internally (-1, 1), but makes the caluclated frame * bigger than actual output. This is for the easier shifting calculation. A value of 0.5 means - * the "internal" focal length become 2/3 of the actual camera. - */ + * the "internal" focal length become 2/3 of the actual camera. */ float overscan; + /* Values for point light and directional (sun) light. */ + /* For point light, fov always gonna be 120 deg horizontal, with 3 "cameras" covering 360 deg. */ + float shadow_camera_fov; + float shadow_camera_size; + float shadow_camera_near; + float shadow_camera_far; + float opacity; short thickness; @@ -1064,7 +1082,9 @@ typedef struct LineartGpencilModifierData { unsigned char material_mask_bits; unsigned char intersection_mask; - char _pad[3]; + unsigned char shadow_selection; + unsigned char silhouette_selection; + char _pad[1]; /** `0..1` range for cosine angle */ float crease_threshold; @@ -1078,7 +1098,7 @@ typedef struct LineartGpencilModifierData { /* CPU mode */ float chaining_image_threshold; - /* Ported from SceneLineArt flags. */ + /* eLineartMainFlags, for one time calculation. */ int calculation_flags; /* #eLineArtGPencilModifierFlags, modifier internal state. */ @@ -1095,6 +1115,10 @@ typedef struct LineartGpencilModifierData { char level_start_override; char level_end_override; short edge_types_override; + char shadow_selection_override; + char shadow_use_silhouette_override; + + char _pad2[6]; struct LineartCache *cache; /* Keep a pointer to the render buffer so we can call destroy from ModifierData. */ diff --git a/source/blender/makesdna/DNA_lineart_types.h b/source/blender/makesdna/DNA_lineart_types.h index 444a0e6f247..4f736703203 100644 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@ -38,6 +38,8 @@ 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; typedef enum eLineartEdgeFlag { @@ -47,14 +49,19 @@ typedef enum eLineartEdgeFlag { LRT_EDGE_FLAG_MATERIAL = (1 << 3), LRT_EDGE_FLAG_INTERSECTION = (1 << 4), LRT_EDGE_FLAG_LOOSE = (1 << 5), + LRT_EDGE_FLAG_LIGHT_CONTOUR = (1 << 6), /* LRT_EDGE_FLAG_FOR_FUTURE = (1 << 7), */ - /** - * It's a legacy limit of 8 bits for feature lines that come from original mesh edges. It should - * not be needed in current object loading scheme, but might still be relevant if we are to - * implement edit-mesh loading, so don't exceed 8 bits just yet. - */ - LRT_EDGE_FLAG_CHAIN_PICKED = (1 << 8), - LRT_EDGE_FLAG_CLIPPED = (1 << 9), + /* It's a legacy limit of 8 bits for feature lines that come from original mesh edges. It should + not be needed in current object loading scheme, but might still be relevant if we are to + impelment EditMesh loading, so don't exceed 8 bits just yet. */ + LRT_EDGE_FLAG_PROJECTED_SHADOW = (1 << 8), + /* To determine an edge to be occluded from the front or back face it's lying on. */ + LRT_EDGE_FLAG_SHADOW_FACING_LIGHT = (1 << 9), + /** Also used as discarded line mark. */ + LRT_EDGE_FLAG_CHAIN_PICKED = (1 << 10), + LRT_EDGE_FLAG_CLIPPED = (1 << 11), + /** Used to specify contor from viewing camera when computing shadows. */ + LRT_EDGE_FLAG_CONTOUR_SECONDARY = (1 << 12), /** Limited to 16 bits for the entire thing. */ /** For object loading code to use only. */ @@ -63,4 +70,6 @@ typedef enum eLineartEdgeFlag { LRT_EDGE_FLAG_NEXT_IS_DUPLICATION = (1 << 15), } eLineartEdgeFlag; -#define LRT_EDGE_FLAG_ALL_TYPE 0x3f +#define LRT_EDGE_FLAG_ALL_TYPE 0x01ff +#define LRT_EDGE_FLAG_INIT_TYPE 0x37 /* Without material & light contour */ +#define LRT_EDGE_FLAG_TYPE_MAX_BITS 7 diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 332317142c7..460670225c8 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -150,14 +150,15 @@ typedef struct MaterialLineArt { /** Maximum 255 levels of equivalent occlusion. */ unsigned char mat_occlusion; - unsigned char _pad[2]; + unsigned char intersection_priority; + + char _pad; } MaterialLineArt; typedef enum eMaterialLineArtFlags { LRT_MATERIAL_MASK_ENABLED = (1 << 0), - - /* Deprecated, kept for versioning code. */ LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS = (1 << 1), + LRT_MATERIAL_CUSTOM_INTERSECTION_PRIORITY = (1 << 2), } eMaterialLineArtFlags; typedef struct Material { diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 698fbe8ee8f..db56c79de4e 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -215,6 +215,10 @@ typedef struct ObjectLineArt { /** if OBJECT_LRT_OWN_CREASE is set */ float crease_threshold; + + unsigned char intersection_priority; + + char _pad[7]; } ObjectLineArt; /** @@ -231,6 +235,7 @@ enum eObjectLineArt_Usage { enum eObjectLineArt_Flags { OBJECT_LRT_OWN_CREASE = (1 << 0), + OBJECT_LRT_OWN_INTERSECTION_PRIORITY = (1 << 1), }; typedef struct Object { |