Blender
V3.3
|
#include "DRW_render.h"
#include "BKE_object.h"
#include "BLI_math.h"
#include "workbench_engine.h"
#include "workbench_private.h"
Go to the source code of this file.
Functions | |
static void | compute_parallel_lines_nor_and_dist (const float v1[2], const float v2[2], const float v3[2], float r_line[4]) |
static void | workbench_shadow_update (WORKBENCH_PrivateData *wpd) |
void | workbench_shadow_data_update (WORKBENCH_PrivateData *wpd, WORKBENCH_UBO_World *wd) |
void | workbench_shadow_cache_init (WORKBENCH_Data *data) |
static const BoundBox * | workbench_shadow_object_shadow_bbox_get (WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) |
static bool | workbench_shadow_object_cast_visible_shadow (WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) |
static float | workbench_shadow_object_shadow_distance (WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) |
static bool | workbench_shadow_camera_in_object_shadow (WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) |
static void | workbench_init_object_data (DrawData *dd) |
void | workbench_shadow_cache_populate (WORKBENCH_Data *data, Object *ob, const bool has_transp_mat) |
Shadow:
Use stencil shadow buffer to cast a sharp shadow over opaque surfaces.
After the main pre-pass we render shadow volumes using custom depth & stencil states to set the stencil of shadowed area to anything but 0.
Then the shading pass will shade the areas with stencil not equal 0 differently.
Definition in file workbench_shadow.c.
|
static |
Definition at line 26 of file workbench_shadow.c.
References dot_v2v2(), sub_v2_v2v2(), SWAP, v1, and v2.
Referenced by workbench_shadow_update().
Definition at line 286 of file workbench_shadow.c.
References data.
Referenced by workbench_shadow_cache_populate().
void workbench_shadow_cache_init | ( | WORKBENCH_Data * | data | ) |
Definition at line 125 of file workbench_shadow.c.
References data, DRW_PASS_CREATE, DRW_shgroup_create(), DRW_shgroup_stencil_mask(), DRW_STATE_BLEND_ADD_FULL, DRW_STATE_DEPTH_GREATER_EQUAL, DRW_STATE_DEPTH_LESS, DRW_STATE_STENCIL_ALWAYS, DRW_STATE_WRITE_COLOR, DRW_STATE_WRITE_STENCIL_SHADOW_FAIL, DRW_STATE_WRITE_STENCIL_SHADOW_PASS, NULL, sh, SHADOW_ENABLED, WORKBENCH_PrivateData::shadow_fail_caps_grp, WORKBENCH_PrivateData::shadow_fail_grp, WORKBENCH_PrivateData::shadow_pass_grp, WORKBENCH_PassList::shadow_ps, state, workbench_shader_shadow_fail_get(), workbench_shader_shadow_pass_get(), and workbench_shadow_update().
Referenced by workbench_cache_init().
void workbench_shadow_cache_populate | ( | WORKBENCH_Data * | data, |
Object * | ob, | ||
const bool | has_transp_mat | ||
) |
Definition at line 292 of file workbench_shadow.c.
References WORKBENCH_PrivateData::cull_state, data, draw_engine_workbench, DRW_cache_object_edge_detection_get(), DRW_cache_object_surface_get(), DRW_debug_bbox(), DRW_drawdata_ensure(), DRW_shgroup_call_no_cull, DRW_shgroup_create_sub(), DRW_shgroup_uniform_float_copy(), DRW_shgroup_uniform_vec3(), GPUBatch, Object::id, Object::imat, mul_v3_mat3_m4v3(), NULL, WORKBENCH_ObjectData::shadow_bbox, WORKBENCH_ObjectData::shadow_dir, WORKBENCH_PrivateData::shadow_direction_ws, WORKBENCH_PrivateData::shadow_fail_caps_grp, WORKBENCH_PrivateData::shadow_fail_grp, WORKBENCH_PrivateData::shadow_pass_grp, workbench_init_object_data(), workbench_shadow_camera_in_object_shadow(), workbench_shadow_object_cast_visible_shadow(), and workbench_shadow_object_shadow_distance().
Referenced by workbench_cache_populate().
|
static |
Definition at line 237 of file workbench_shadow.c.
References dot_v2v2(), WORKBENCH_ObjectData::shadow_max, WORKBENCH_ObjectData::shadow_min, WORKBENCH_PrivateData::shadow_near_max, WORKBENCH_PrivateData::shadow_near_min, WORKBENCH_PrivateData::shadow_near_sides, and workbench_shadow_object_shadow_bbox_get().
Referenced by workbench_shadow_cache_populate().
void workbench_shadow_data_update | ( | WORKBENCH_PrivateData * | wpd, |
WORKBENCH_UBO_World * | wd | ||
) |
Definition at line 93 of file workbench_shadow.c.
References clamp_f(), copy_v3_v3(), Scene::display, DRW_context_state_get(), DRW_view_viewmat_get(), SceneDisplay::light_direction, mul_v3_mat3_m4v3(), NULL, scene, DRWContextState::scene, WORKBENCH_PrivateData::shading, WORKBENCH_UBO_World::shadow_add, WORKBENCH_UBO_World::shadow_direction_vs, WORKBENCH_PrivateData::shadow_direction_ws, SHADOW_ENABLED, WORKBENCH_UBO_World::shadow_focus, SceneDisplay::shadow_focus, View3DShading::shadow_intensity, WORKBENCH_UBO_World::shadow_mul, WORKBENCH_UBO_World::shadow_shift, SceneDisplay::shadow_shift, and SWAP.
Referenced by workbench_update_world_ubo().
|
static |
Definition at line 202 of file workbench_shadow.c.
References DRW_culling_box_test(), DRW_view_default_get(), and workbench_shadow_object_shadow_bbox_get().
Referenced by workbench_shadow_cache_populate().
|
static |
Definition at line 169 of file workbench_shadow.c.
References BKE_boundbox_init_from_minmax(), BKE_object_boundbox_get(), INIT_MINMAX, minmax_v3v3_v3(), mul_m4_m4m4(), mul_m4_v3(), mul_v3_m4v3(), Object::obmat, WORKBENCH_ObjectData::shadow_bbox, WORKBENCH_ObjectData::shadow_bbox_dirty, WORKBENCH_PrivateData::shadow_changed, WORKBENCH_ObjectData::shadow_depth, WORKBENCH_PrivateData::shadow_inv, WORKBENCH_PrivateData::shadow_mat, WORKBENCH_ObjectData::shadow_max, WORKBENCH_ObjectData::shadow_min, and BoundBox::vec.
Referenced by workbench_shadow_camera_in_object_shadow(), workbench_shadow_object_cast_visible_shadow(), and workbench_shadow_object_shadow_distance().
|
static |
Definition at line 211 of file workbench_shadow.c.
References isect_ray_plane_v3(), max_ii(), WORKBENCH_PrivateData::shadow_cached_direction, WORKBENCH_ObjectData::shadow_depth, WORKBENCH_PrivateData::shadow_far_plane, BoundBox::vec, and workbench_shadow_object_shadow_bbox_get().
Referenced by workbench_shadow_cache_populate().
|
static |
Definition at line 44 of file workbench_shadow.c.
References compare_v3v3(), compute_parallel_lines_nor_and_dist(), copy_v3_v3(), copy_v4_v4(), cross_v3_v3v3(), DRW_culling_frustum_corners_get(), DRW_culling_frustum_planes_get(), INIT_MINMAX, invert_m4_m4(), minmax_v3v3_v3(), mul_v3_mat3_m4v3(), normalize_v3(), NULL, WORKBENCH_PrivateData::shadow_cached_direction, WORKBENCH_PrivateData::shadow_changed, WORKBENCH_PrivateData::shadow_direction_ws, WORKBENCH_PrivateData::shadow_far_plane, WORKBENCH_PrivateData::shadow_inv, WORKBENCH_PrivateData::shadow_mat, WORKBENCH_PrivateData::shadow_near_max, WORKBENCH_PrivateData::shadow_near_min, WORKBENCH_PrivateData::shadow_near_sides, unit_m4(), and BoundBox::vec.
Referenced by workbench_shadow_cache_init().