Commit: a9de546daabc42cf0f30a8d95a72eaba7c2d82b7 Author: YimingWu Date: Wed May 18 15:43:59 2022 +0800 Branches: lineart-shadow https://developer.blender.org/rBa9de546daabc42cf0f30a8d95a72eaba7c2d82b7
Merge branch 'temp-lineart-contained' into lineart-shadow =================================================================== =================================================================== diff --cc source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index e5eec589dde,f9722ec94c1..86298f2f319 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@@ -513,26 -382,11 +490,15 @@@ typedef struct LineartObjectInfo LineartElementLinkNode *eln; int usage; uint8_t override_intersection_mask; + uint8_t silhouette_group; int global_i_offset; + /* Shifted LRT_OBINDEX_SHIFT bits to be combined with object triangle index. */ + int obindex; + bool free_use_mesh; - /* Threads will add lines inside here, when all threads are done, we combine those into the - * ones in LineartRenderBuffer. */ - ListBase contour; - ListBase intersection; - ListBase crease; - ListBase material; - ListBase edge_mark; - ListBase floating; - ListBase light_contour; - ListBase shadow; - - /* Note: Data here are allocated with MEM_xxx call instead of in pool. */ + /* Note: Data inside #pending_edges are allocated with MEM_xxx call instead of in pool. */ struct LineartPendingEdges pending_edges; } LineartObjectInfo; diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index e61df9e2639,9a7d066c12a..ee7c82311d8 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@@ -2319,11 -2153,11 +2298,11 @@@ static void lineart_geometry_object_loa continue; } - bool edge_added = false; + LineartEdge *edge_added = NULL; /* See eLineartEdgeFlag for details. */ - for (int flag_bit = 0; flag_bit < LRT_EDGE_FLAG_TYPE_MAX_BITS; flag_bit++) { - char use_type = 1 << flag_bit; + for (int flag_bit = 0; flag_bit < LRT_MESH_EDGE_TYPES_COUNT; flag_bit++) { + int use_type = LRT_MESH_EDGE_TYPES[flag_bit]; if (!(use_type & edge_nabr->flags)) { continue; } @@@ -2344,33 -2178,17 +2323,37 @@@ } la_edge->flags = use_type; la_edge->object_ref = orig_ob; + la_edge->from_shadow = (LineartEdge *)LRT_EDGE_IDENTIFIER(ob_info, la_edge); + la_edge->silhouette_group = (re_buf->shadow_use_silhouette && + (la_edge->t1 || (la_edge->t1 && la_edge->t2 && + la_edge->t1->silhouette_group == + la_edge->t2->silhouette_group))) ? + la_edge->t1->silhouette_group : + 0; + la_seg->silhouette_group = la_edge->silhouette_group; BLI_addtail(&la_edge->segments, la_seg); + + if (shadow_eln) { + /* TODO(Yiming): It's gonna be faster to do this operation after second stage occlusion if + * we only need visible segments to have shadow info, however that way we lose information + * on "shadow behind transparency window" type of region. */ + LineartEdge *shadow_e = lineart_find_matching_edge(shadow_eln, + (uint64_t)la_edge->from_shadow); + if (shadow_e) { + lineart_register_shadow_cuts(re_buf, la_edge, shadow_e); + } + } + if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || usage == OBJECT_LRT_NO_INTERSECTION) { - lineart_add_edge_to_list_thread(ob_info, la_edge); + lineart_add_edge_to_array_thread(ob_info, la_edge); } - edge_added = true; + if (edge_added) { + edge_added->flags |= LRT_EDGE_FLAG_NEXT_IS_DUPLICATION; + } + + edge_added = la_edge; la_edge++; la_seg++; @@@ -2412,12 -2230,14 +2395,12 @@@ static void lineart_object_load_worker( //- Print size of pending objects. //- Try to feed this with an array instead of via the pool instead of a custom list //- Assign the number of objects instead of number of threads - // printf("thread start: %d\n", olti->thread_id); for (LineartObjectInfo *obi = olti->pending; obi; obi = obi->next) { - lineart_geometry_object_load(obi, olti->rb); + lineart_geometry_object_load(obi, olti->rb, olti->shadow_elns); if (G.debug_value == 4000) { - printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); + // printf("thread id: %d processed: %d\n", olti->thread_id, obi->original_me->totpoly); } } - // printf("thread end: %d\n", olti->thread_id); } static uchar lineart_intersection_mask_check(Collection *c, Object *ob) @@@ -2610,22 -2468,15 +2654,14 @@@ static void lineart_main_load_geometrie BLI_listbase_clear(&rb->triangle_buffer_pointers); BLI_listbase_clear(&rb->vertex_buffer_pointers); - int flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | - DEG_ITER_OBJECT_FLAG_VISIBLE; - - /* Instance duplicated & particles. */ - if (allow_duplicates) { - flags |= DEG_ITER_OBJECT_FLAG_DUPLI; - } - + double t_start; + if (G.debug_value == 4000) { + t_start = PIL_check_seconds_timer(); + } + int thread_count = rb->thread_count; + int bound_box_discard_count = 0; + int obindex = 0; /* This memory is in render buffer memory pool. So we don't need to free those after loading. */ @@@ -2748,12 -2552,11 +2739,11 @@@ } /* Register a global index increment. See #lineart_triangle_share_edge() and * #lineart_main_load_geometries() for detailed. It's okay that global_vindex might - * eventually overflow, in such large scene it's virtually impossible for two vertex of the - * same numeric index to come close together. */ + * eventually overflow, in such large scene it's virtually impossible for two vertex of + * the same numeric index to come close together. */ obi->global_i_offset = global_i; global_i += v_count; - - lineart_finalize_object_edge_list(&rb->pending_edges, obi); + lineart_finalize_object_edge_array(&rb->pending_edges, obi); } } diff --cc source/blender/makesdna/DNA_lineart_types.h index 46da2abf63c,3b0f2baa310..3cd763367d1 --- a/source/blender/makesdna/DNA_lineart_types.h +++ b/source/blender/makesdna/DNA_lineart_types.h @@@ -68,8 -59,10 +68,10 @@@ typedef enum eLineartEdgeFlag /** For object loading code to use only. */ LRT_EDGE_FLAG_INHIBIT = (1 << 14), + /** For discarding duplicated edge types in culling stage. */ + LRT_EDGE_FLAG_NEXT_IS_DUPLICATION = (1 << 15), } eLineartEdgeFlag; -#define LRT_EDGE_FLAG_ALL_TYPE 0x7f +#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 _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs