|
Blender V5.0
|
#include "MOD_lineart.hh"#include "lineart_intern.hh"#include "BKE_global.hh"#include "BKE_grease_pencil.hh"#include "BKE_grease_pencil_legacy_convert.hh"#include "BKE_object.hh"#include "BLI_math_matrix.h"#include "BLI_math_rotation.h"#include "BLI_task.h"#include "BLI_time.h"#include "DNA_light_types.h"#include "DNA_modifier_types.h"#include "MEM_guardedalloc.h"Go to the source code of this file.
Classes | |
| struct | LineartShadowFinalizeData |
Macros | |
| #define | DISCARD_NONSENSE_SEGMENTS |
| #define | GET_RATIO(n) |
Functions | |
| LineartElementLinkNode * | lineart_find_matching_eln (ListBase *shadow_elns, int obindex) |
| LineartEdge * | lineart_find_matching_edge (LineartElementLinkNode *shadow_eln, uint64_t edge_identifier) |
| static bool | lineart_contour_viewed_from_dark_side (LineartData *ld, LineartEdge *e) |
| void | lineart_register_shadow_cuts (LineartData *ld, LineartEdge *e, LineartEdge *shadow_edge) |
| void | lineart_register_intersection_shadow_cuts (LineartData *ld, ListBase *shadow_elns) |
| static LineartShadowSegment * | lineart_give_shadow_segment (LineartData *ld) |
| static void | lineart_shadow_segment_slice_get (double *fb_co_1, double *fb_co_2, double *gloc_1, double *gloc_2, double ratio, double at_1, double at_2, double *r_fb_co, double *r_gloc) |
| static bool | lineart_do_closest_segment (bool is_persp, double *s1_fb_co_1, double *s1_fb_co_2, double *s2_fb_co_1, double *s2_fb_co_2, double *s1_gloc_1, double *s1_gloc_2, double *s2_gloc_1, double *s2_gloc_2, double *r_fb_co_1, double *r_fb_co_2, double *r_gloc_1, double *r_gloc_2, double *r_new_in_the_middle, double *r_new_in_the_middle_global, double *r_new_at, bool *is_side_2r, bool *use_new_ref) |
| static void | lineart_shadow_create_shadow_edge_array (LineartData *ld, bool transform_edge_cuts, bool do_light_contour) |
| static void | lineart_shadow_edge_cut (LineartData *ld, LineartShadowEdge *e, double start, double end, double *start_gloc, double *end_gloc, double *start_fb_co, double *end_fb_co, bool facing_light, uint32_t target_reference) |
| static bool | lineart_shadow_cast_onto_triangle (LineartData *ld, LineartTriangle *tri, LineartShadowEdge *sedge, double *r_at_1, double *r_at_2, double *r_fb_co_1, double *r_fb_co_2, double *r_gloc_1, double *r_gloc_2, bool *r_facing_light) |
| static void | lineart_shadow_cast (LineartData *ld, bool transform_edge_cuts, bool do_light_contour) |
| static bool | lineart_shadow_cast_generate_edges (LineartData *ld, bool do_original_edges, LineartElementLinkNode **r_veln, LineartElementLinkNode **r_eeln) |
| static void | lineart_shadow_register_silhouette (LineartData *ld) |
| static void | lineart_shadow_register_enclosed_shapes (LineartData *ld, LineartData *shadow_ld) |
| bool | lineart_main_try_generate_shadow_v3 (Depsgraph *depsgraph, Scene *scene, LineartData *original_ld, GreasePencilLineartModifierData *lmd, LineartStaticMemPool *shadow_data_pool, LineartElementLinkNode **r_veln, LineartElementLinkNode **r_eeln, ListBase *r_calculated_edges_eln_list, LineartData **r_shadow_ld_if_reproject) |
| bool | lineart_main_try_generate_shadow (Depsgraph *depsgraph, Scene *scene, LineartData *original_ld, LineartGpencilModifierData *lmd_legacy, LineartStaticMemPool *shadow_data_pool, LineartElementLinkNode **r_veln, LineartElementLinkNode **r_eeln, ListBase *r_calculated_edges_eln_list, LineartData **r_shadow_ld_if_reproject) |
| static void | lineart_shadow_transform_task (void *__restrict userdata, const int element_index, const TaskParallelTLS *__restrict) |
| static void | lineart_shadow_finalize_shadow_edges_task (void *__restrict userdata, const int i, const TaskParallelTLS *__restrict) |
| void | lineart_main_transform_and_add_shadow (LineartData *ld, LineartElementLinkNode *veln, LineartElementLinkNode *eeln) |
| void | lineart_main_make_enclosed_shapes (LineartData *ld, LineartData *shadow_ld) |
| #define DISCARD_NONSENSE_SEGMENTS |
Referenced by lineart_shadow_create_shadow_edge_array().
| #define GET_RATIO | ( | n | ) |
Referenced by lineart_shadow_register_enclosed_shapes().
|
static |
Definition at line 52 of file lineart_shadow.cc.
References LineartData::_conf::cam_is_persp, LineartData::_conf::cam_is_persp_secondary, LineartData::_conf::camera_pos, LineartData::_conf::camera_pos_secondary, LineartData::conf, copy_v3_v3_db(), dot_v3v3_db(), e, MOD_LINEART_EDGE_FLAG_CONTOUR, MOD_LINEART_EDGE_FLAG_CONTOUR_SECONDARY, sub_v3_v3v3_db(), LineartData::_conf::view_vector, and LineartData::_conf::view_vector_secondary.
Referenced by lineart_register_shadow_cuts(), and lineart_shadow_cast_generate_edges().
|
static |
This function tries to get the closest projected segments along two end points. The x,y of s1, s2 are aligned in frame-buffer coordinates, only z,w are different. We will get the closest z/w as well as the corresponding global coordinates.
Returns true when a new cut (c) is needed in the middle, otherwise returns false, and *r_new_xxx are not touched.
Definition at line 221 of file lineart_shadow.cc.
References copy_v3_v3_db(), copy_v4_v4_db(), interp_v3_v3v3_db(), interpd(), and ratiod().
Referenced by lineart_shadow_edge_cut().
| LineartEdge * lineart_find_matching_edge | ( | LineartElementLinkNode * | shadow_eln, |
| uint64_t | edge_identifier ) |
Definition at line 40 of file lineart_shadow.cc.
References LineartElementLinkNode::element_count, i, and LineartElementLinkNode::pointer.
Referenced by lineart_geometry_object_load(), and lineart_register_intersection_shadow_cuts().
| LineartElementLinkNode * lineart_find_matching_eln | ( | ListBase * | shadow_elns, |
| int | obindex ) |
Definition at line 30 of file lineart_shadow.cc.
References LISTBASE_FOREACH.
Referenced by lineart_create_edges_from_isec_data(), lineart_geometry_object_load(), lineart_shadow_finalize_shadow_edges_task(), and MOD_lineart_chain_find_silhouette_backdrop_objects().
|
static |
Definition at line 156 of file lineart_shadow.cc.
References BLI_pophead(), BLI_spin_lock(), BLI_spin_unlock(), ListBase::first, lineart_mem_acquire_thread(), LineartData::lock_cuts, LineartData::render_data_pool, and LineartData::wasted_shadow_cuts.
Referenced by lineart_shadow_edge_cut().
| void lineart_main_make_enclosed_shapes | ( | struct LineartData * | ld, |
| struct LineartData * | shadow_ld ) |
Does the 3rd stage reprojection, will not re-load objects because #shadow_ld is not deleted. Only re-projects view camera edges and check visibility in light camera, then we can determine whether an edge landed on a lit or shaded area.
Definition at line 1411 of file lineart_shadow.cc.
References LineartPendingEdges::array, BLI_time_now_seconds(), LineartData::_conf::cam_is_persp, LineartData::conf, LineartElementLinkNode::element_count, G, i, lineart_add_edge_to_array(), lineart_finalize_object_edge_array_reserve(), lineart_main_clear_linked_edges(), lineart_main_link_lines(), lineart_main_occlusion_begin(), lineart_shadow_cast(), lineart_shadow_cast_generate_edges(), lineart_shadow_register_enclosed_shapes(), lineart_shadow_register_silhouette(), LineartPendingEdges::max, MEM_freeN(), mul_v3db_db(), mul_v4_m4v3_db(), LineartPendingEdges::next, LineartData::pending_edges, LineartElementLinkNode::pointer, printf, LineartData::render_data_pool, LineartData::scheduled_count, LineartData::shadow_data_pool, LineartData::_conf::shadow_use_silhouette, v, and LineartData::_conf::view_projection.
Referenced by MOD_lineart_compute_feature_lines_v3().
| void lineart_main_transform_and_add_shadow | ( | struct LineartData * | ld, |
| struct LineartElementLinkNode * | veln, | ||
| struct LineartElementLinkNode * | eeln ) |
Shadow segments needs to be transformed to view-camera space, just like any other objects.
Definition at line 1381 of file lineart_shadow.cc.
References BLI_addtail(), BLI_parallel_range_settings_defaults(), BLI_task_parallel_range(), data, LineartElementLinkNode::element_count, LineartData::geom, i, LineartData::_geom::line_buffer_pointers, lineart_add_edge_to_array(), lineart_shadow_finalize_shadow_edges_task(), lineart_shadow_transform_task(), TaskParallelSettings::min_iter_per_thread, LineartData::pending_edges, LineartElementLinkNode::pointer, and LineartData::_geom::vertex_buffer_pointers.
Referenced by MOD_lineart_compute_feature_lines_v3().
| bool lineart_main_try_generate_shadow | ( | struct Depsgraph * | depsgraph, |
| struct Scene * | scene, | ||
| struct LineartData * | original_ld, | ||
| struct LineartGpencilModifierData * | lmd_legacy, | ||
| struct LineartStaticMemPool * | shadow_data_pool, | ||
| struct LineartElementLinkNode ** | r_veln, | ||
| struct LineartElementLinkNode ** | r_eeln, | ||
| struct ListBase * | r_calculated_edges_eln_list, | ||
| struct LineartData ** | r_shadow_ld_if_reproject ) |
This call would internally duplicate #original_ld, override necessary configurations for shadow computations. It will return:
1) Generated shadow edges in format of LineartElementLinkNode which can be directly loaded into later main view camera occlusion stage. 2) Shadow render buffer if 3rd stage reprojection is need for silhouette/lit/shaded region selection. Otherwise the shadow render buffer is deleted before this function returns.
Definition at line 1312 of file lineart_shadow.cc.
References depsgraph, lineart_main_try_generate_shadow_v3(), blender::bke::greasepencil::convert::lineart_unwrap_v3(), blender::bke::greasepencil::convert::lineart_wrap_v3(), and ret.
| bool lineart_main_try_generate_shadow_v3 | ( | Depsgraph * | depsgraph, |
| Scene * | scene, | ||
| LineartData * | original_ld, | ||
| GreasePencilLineartModifierData * | lmd, | ||
| LineartStaticMemPool * | shadow_data_pool, | ||
| LineartElementLinkNode ** | r_veln, | ||
| LineartElementLinkNode ** | r_eeln, | ||
| ListBase * | r_calculated_edges_eln_list, | ||
| LineartData ** | r_shadow_ld_if_reproject ) |
Definition at line 1145 of file lineart_shadow.cc.
References LineartData::_conf::allow_duplicated_types, BLI_spin_init(), BLI_time_now_seconds(), LineartData::_conf::cam_is_persp, LineartData::_conf::cam_is_persp_secondary, LineartData::_conf::cam_obmat, LineartData::_conf::cam_obmat_secondary, LineartData::_conf::camera_pos, LineartData::_conf::camera_pos_secondary, LineartData::conf, copy_m4_m4(), copy_m4_m4_db(), copy_v3_v3_db(), copy_v3db_v3fl(), Object::data, DEG2RAD, depsgraph, LineartData::_conf::do_shadow_cast, LineartData::edge_data_pool, LineartData::_conf::far_clip, ListBase::first, GreasePencilLineartModifierData::flags, G, LineartData::geom, LineartData::h, invert_m4_m4(), LA_SUN, GreasePencilLineartModifierData::light_contour_object, LineartData::_geom::line_buffer_pointers, lineart_destroy_render_data_keep_init(), lineart_main_add_triangles(), lineart_main_bounding_area_make_initial(), lineart_main_bounding_areas_connect_post(), lineart_main_cull_triangles(), lineart_main_discard_out_of_frame_edges(), lineart_main_free_adjacent_data(), lineart_main_get_view_vector(), lineart_main_link_lines(), lineart_main_load_geometries(), lineart_main_occlusion_begin(), lineart_main_perspective_division(), lineart_matrix_ortho_44d(), lineart_matrix_perspective_44d(), lineart_shadow_cast(), lineart_shadow_cast_generate_edges(), LineartData::lock_cuts, LineartStaticMemPool::lock_mem, LineartData::lock_task, LRT_TILE_RECURSIVE_ORTHO, LRT_TILE_RECURSIVE_PERSPECTIVE, LineartData::_conf::max_occlusion_level, MEM_freeN(), MEM_mallocN(), MOD_LINEART_ALLOW_DUPLI_OBJECTS, mul_m4db_m4db_m4fl(), LineartData::_conf::near_clip, OB_LAMP, LineartModifierRuntime::object_dependencies, printf, LineartData::qtree, LineartData::_qtree::recursive_level, LineartData::render_data_pool, result, GreasePencilLineartModifierData::runtime, GreasePencilLineartModifierData::shadow_camera_far, GreasePencilLineartModifierData::shadow_camera_near, GreasePencilLineartModifierData::shadow_camera_size, LineartData::shadow_data_pool, LineartData::_conf::shadow_enclose_shapes, LineartData::_conf::shadow_selection, Light::type, Object::type, unit_m4_db(), LineartData::_conf::use_back_face_culling, LineartData::_conf::use_contour, LineartData::_conf::use_contour_secondary, LineartData::_conf::use_crease, LineartData::_conf::use_edge_marks, LineartData::_conf::use_intersections, LineartData::_conf::use_light_contour, LineartData::_conf::use_loose, LineartData::_conf::use_material, LineartData::_conf::use_shadow, LineartData::_geom::vertex_buffer_pointers, LineartData::_conf::view, view, LineartData::_conf::view_projection, and LineartData::w.
Referenced by lineart_main_try_generate_shadow(), and MOD_lineart_compute_feature_lines_v3().
| void lineart_register_intersection_shadow_cuts | ( | LineartData * | ld, |
| ListBase * | shadow_elns ) |
Definition at line 118 of file lineart_shadow.cc.
References e, LineartElementLinkNode::element_count, LineartData::geom, i, LineartData::_geom::line_buffer_pointers, lineart_find_matching_edge(), lineart_register_shadow_cuts(), LISTBASE_FOREACH, LRT_ELEMENT_INTERSECTION_DATA, and LineartElementLinkNode::pointer.
Referenced by MOD_lineart_compute_feature_lines_v3().
| void lineart_register_shadow_cuts | ( | struct LineartData * | ld, |
| struct LineartEdge * | e, | ||
| struct LineartEdge * | shadow_edge ) |
Cuts the original edge based on the occlusion results under light-camera, if segment is occluded in light-camera, then that segment on the original edge must be shaded.
Definition at line 96 of file lineart_shadow.cc.
References e, lineart_contour_viewed_from_dark_side(), lineart_edge_cut(), LISTBASE_FOREACH, LRT_SHADOW_MASK_ILLUMINATED, LRT_SHADOW_MASK_SHADED, and LineartEdge::segments.
Referenced by lineart_geometry_object_load(), and lineart_register_intersection_shadow_cuts().
|
static |
Definition at line 899 of file lineart_shadow.cc.
References LineartData::_conf::allow_overlapping_edges, LineartTriangleThread::base, LineartData::conf, LineartShadowEdge::e_ref, LineartShadowEdge::fbc1, LineartShadowEdge::fbc2, i, lineart_edge_from_triangle(), lineart_shadow_cast_onto_triangle(), lineart_shadow_create_shadow_edge_array(), lineart_shadow_edge_cut(), LRT_EDGE_BA_MARCHING_BEGIN, LRT_EDGE_BA_MARCHING_END, LRT_EDGE_BA_MARCHING_NEXT, LineartTriangle::mat_occlusion, LineartData::shadow_edges, LineartData::shadow_edges_count, LineartTriangle::target_reference, and LineartTriangleThread::testing_e.
Referenced by lineart_main_make_enclosed_shapes(), and lineart_main_try_generate_shadow_v3().
|
static |
Definition at line 958 of file lineart_shadow.cc.
References BLI_addtail(), copy_v3_v3_db(), e, LineartShadowEdge::e_ref, LineartShadowEdge::e_ref_light_contour, LineartEdge::edge_identifier, LineartElementLinkNode::element_count, G, LineartShadowEdge::g1, LineartShadowEdge::g2, LineartVert::gloc, i, LineartVert::index, lineart_contour_viewed_from_dark_side(), lineart_edge_cut(), lineart_mem_acquire(), LISTBASE_FOREACH, LRT_SHADOW_CASTED, LRT_SHADOW_FACING_LIGHT, LRT_SHADOW_MASK_SHADED, MOD_LINEART_EDGE_FLAG_LIGHT_CONTOUR, MOD_LINEART_EDGE_FLAG_PROJECTED_SHADOW, MOD_LINEART_EDGE_FLAG_SHADOW_FACING_LIGHT, LineartElementLinkNode::pointer, printf, LineartData::shadow_data_pool, LineartData::shadow_edges, LineartData::shadow_edges_count, LineartShadowEdge::shadow_segments, LineartEdge::t1, LineartEdge::t2, LineartTriangle::target_reference, LineartEdge::v1, LineartEdge::v2, and v2.
Referenced by lineart_main_make_enclosed_shapes(), and lineart_main_try_generate_shadow_v3().
|
static |
Definition at line 730 of file lineart_shadow.cc.
References LineartData::_conf::cam_is_persp, LineartData::_conf::camera_pos, LineartData::conf, copy_v3_v3_db(), copy_v4_v4_db(), dot_v3v3_db(), fabs(), LineartShadowEdge::fbc1, LineartShadowEdge::fbc2, LineartVert::fbcoord, LineartVert::gloc, LineartTriangle::gn, interp_v3_v3v3_db(), interpd(), lineart_line_isec_2d_ignore_line2pos(), LRT_DOUBLE_CLOSE_ENOUGH, mul_v3db_db(), mul_v4_m4v3_db(), ratiod(), sub_v3_v3v3_db(), LineartTriangle::v, v2, LineartData::_conf::view_projection, and LineartData::_conf::view_vector.
Referenced by lineart_shadow_cast().
|
static |
Definition at line 308 of file lineart_shadow.cc.
References BLI_addtail(), LineartData::_conf::cam_is_persp, LineartData::_conf::camera_pos, LineartData::conf, copy_v4_v4_db(), DISCARD_NONSENSE_SEGMENTS, dot_v3v3_db(), e, G, LineartVert::gloc, LineartTriangle::gn, i, interp_v3_v3v3_db(), lineart_mem_acquire(), LISTBASE_FOREACH, LRT_ITER_ALL_LINES_BEGIN, LRT_ITER_ALL_LINES_END, MOD_LINEART_EDGE_FLAG_CONTOUR, MOD_LINEART_EDGE_FLAG_LIGHT_CONTOUR, MOD_LINEART_EDGE_FLAG_LOOSE, printf, LineartShadowSegment::ratio, LineartData::render_data_pool, result, LineartData::shadow_edges, LineartData::shadow_edges_count, sub_v3_v3v3_db(), LineartEdge::t1, LineartEdge::t2, LineartEdge::v1, and LineartData::_conf::view_vector.
Referenced by lineart_shadow_cast().
|
static |
Definition at line 499 of file lineart_shadow.cc.
References BLI_insertlinkafter(), BLI_insertlinkbefore(), LineartData::_conf::cam_is_persp, LineartData::conf, copy_v3_v3_db(), copy_v4_v4_db(), e, LineartShadowSegment::fbc1, LineartShadowSegment::fbc2, LineartShadowSegment::flag, LineartShadowSegment::g1, LineartShadowSegment::g2, interpf(), lineart_do_closest_segment(), lineart_give_shadow_segment(), lineart_shadow_segment_slice_get(), LISTBASE_FOREACH, LRT_DOUBLE_CLOSE_ENOUGH, LRT_SHADOW_CASTED, LRT_SHADOW_FACING_LIGHT, LineartShadowSegment::next, LineartShadowSegment::ratio, LineartShadowSegment::target_reference, and UNLIKELY.
Referenced by lineart_shadow_cast().
|
static |
Definition at line 1354 of file lineart_shadow.cc.
References data, e, LineartData::geom, i, lineart_find_matching_eln(), LRT_CLOSE_LOOSER_v3, LRT_OBINDEX_HIGHER, LRT_OBINDEX_LOWER, MOD_LINEART_EDGE_FLAG_LIGHT_CONTOUR, LineartElementLinkNode::pointer, v, v2, and LineartData::_geom::vertex_buffer_pointers.
Referenced by lineart_main_transform_and_add_shadow().
|
static |
Definition at line 1090 of file lineart_shadow.cc.
References LineartPendingEdges::array, LineartData::_conf::cam_is_persp, LineartData::conf, e, GET_RATIO, i, interp_v3_v3v3_db(), lineart_edge_cut(), LISTBASE_FOREACH, LRT_SHADOW_MASK_ENCLOSED_SHAPE, mul_v3db_db(), mul_v4_m4v3_db(), LineartPendingEdges::next, LineartData::pending_edges, LineartData::_conf::shift_x, LineartData::_conf::shift_y, and LineartData::_conf::view_projection.
Referenced by lineart_main_make_enclosed_shapes().
|
static |
Definition at line 1059 of file lineart_shadow.cc.
References e, LineartShadowEdge::e_ref, LineartShadowEdge::es_ref, i, interpd(), lineart_edge_cut(), LISTBASE_FOREACH, LRT_OBINDEX_HIGHER, LRT_SHADOW_CASTED, LRT_SHADOW_SILHOUETTE_ERASED_GROUP, LineartEdgeSegment::next, LineartEdgeSegment::ratio, LineartData::shadow_edges, LineartData::shadow_edges_count, and LineartShadowEdge::shadow_segments.
Referenced by lineart_main_make_enclosed_shapes().
|
static |
Definition at line 174 of file lineart_shadow.cc.
References interp_v3_v3v3_db(), and interpd().
Referenced by lineart_shadow_edge_cut().
|
static |
Definition at line 1344 of file lineart_shadow.cc.
References LineartData::conf, data, mul_v4_m4v3_db(), v, and LineartData::_conf::view_projection.
Referenced by lineart_main_transform_and_add_shadow().