34 uint2 shadow_set_membership_)
42 level = clipmap_level;
77 uint2 shadow_set_membership_)
123 const float4 debug_color[6] = {
124 {1.0f, 0.1f, 0.1f, 1.0f},
125 {0.1f, 1.0f, 0.1f, 1.0f},
126 {0.0f, 0.2f, 1.0f, 1.0f},
127 {1.0f, 1.0f, 0.3f, 1.0f},
128 {0.1f, 0.1f, 0.1f, 1.0f},
129 {1.0f, 1.0f, 1.0f, 1.0f},
149 for (
int i = SHADOW_MAX_TILEMAP - 1; i >= 0; i--) {
188 if (needed_tilemap_capacity != (
tiles_data.
size() / SHADOW_TILEDATA_PER_TILEMAP)) {
193 module.do_full_update_ = true;
198 if (newly_unused_count > 0) {
202 for (
uint index : newly_unused_indices) {
229 if (tilemaps_.size() <= tilemaps_needed) {
232 auto span = tilemaps_.as_span();
233 shadows_.tilemap_pool.release(span.drop_front(tilemaps_needed));
234 tilemaps_ = span.take_front(tilemaps_needed);
245 while (tilemaps_.size() < tilemaps_needed) {
246 tilemaps_.append(tilemap_pool.
acquire());
251 for (
int i : tilemaps_.index_range()) {
253 tilemaps_[face]->sync_cubeface(
257 light.local.tilemaps_count = tilemaps_needed;
262 tilemap->set_updated();
296void ShadowDirectional::cascade_tilemaps_distribution_near_far_points(
const Camera &
camera,
309IndexRange ShadowDirectional::cascade_level_range(
const Light &light,
const Camera &
camera)
317 const int max_tilemap_per_shadows = 16;
320 float3 near_point, far_point;
321 cascade_tilemaps_distribution_near_far_points(
camera, light, near_point, far_point);
325 float depth_range_in_shadow_space =
distance(far_point.xy(), near_point.xy());
326 float min_depth_tilemap_size = 2 * (depth_range_in_shadow_space / max_tilemap_per_shadows);
331 if (
camera.is_perspective()) {
339 min_diagonal_tilemap_size =
max(min_diagonal_tilemap_size, 0.5f);
343 int lod_level =
ceil(
log2(
max_ff(min_depth_tilemap_size, min_diagonal_tilemap_size)) + 0.5);
349 int tilemap_len =
ceil(0.5f + depth_range_in_shadow_space / per_tilemap_coverage);
353void ShadowDirectional::cascade_tilemaps_distribution(
Light &light,
const Camera &
camera)
355 using namespace blender::math;
357 float4x4 object_mat = light.object_to_world;
364 float3 near_point, far_point;
365 cascade_tilemaps_distribution_near_far_points(
camera, light, near_point, far_point);
367 float2 local_view_direction =
normalize(far_point.xy() - near_point.xy());
368 float2 farthest_tilemap_center = local_view_direction * half_size * (levels_range.size() - 1);
371 light.object_to_world.x.w = near_point.
x;
372 light.object_to_world.y.w = near_point.
y;
373 light.object_to_world.z.w = near_point.
z;
378 int2 offset_vector =
int2(
round(farthest_tilemap_center / tile_size));
380 light.sun.clipmap_base_offset_neg =
int2(0);
381 light.sun.clipmap_base_offset_pos = (offset_vector * (1 << 16)) /
382 max_ii(levels_range.size() - 1, 1);
385 int level = levels_range.first();
386 for (
int i :
IndexRange(levels_range.size())) {
387 ShadowTileMap *tilemap = tilemaps_[i];
390 int2 level_offset = origin_offset +
391 shadow_cascade_grid_offset(light.sun.clipmap_base_offset_pos, i);
396 shadows_.tilemap_pool.tilemaps_data.append(*tilemap);
400 light.sun.clipmap_origin =
float2(origin_offset) * tile_size;
406 light.sun.clipmap_lod_min = levels_range.first();
407 light.sun.clipmap_lod_max = levels_range.last();
414IndexRange ShadowDirectional::clipmap_level_range(
const Camera &cam)
416 using namespace blender::math;
421 int max_level =
ceil(
log2(cam.bound_radius() +
distance(cam.bound_center(), cam.position())));
423 max_level =
max(min_level, max_level) + 1;
424 IndexRange range(min_level, max_level - min_level + 1);
427 const int max_tilemap_per_shadows = 24;
429 range = range.take_back(max_tilemap_per_shadows);
434void ShadowDirectional::clipmap_tilemaps_distribution(
Light &light,
const Camera &
camera)
436 float4x4 object_mat = light.object_to_world;
439 for (
int lod :
IndexRange(levels_range.size())) {
440 ShadowTileMap *tilemap = tilemaps_[lod];
442 int level = levels_range.first() + lod;
454 shadows_.tilemap_pool.tilemaps_data.append(*tilemap);
460 for (
int lod :
IndexRange(levels_range.size() - 1)) {
466 int2 lvl_offset_next = tilemaps_[lod + 1]->grid_offset;
467 int2 lvl_offset = tilemaps_[lod]->grid_offset;
468 int2 lvl_delta = lvl_offset - (lvl_offset_next * 2);
475 light.sun.clipmap_base_offset_pos = pos_offset;
476 light.sun.clipmap_base_offset_neg = neg_offset;
479 int2 level_offset_max = tilemaps_[levels_range.size() - 1]->grid_offset;
486 light.object_to_world.x.w = location.
x;
487 light.object_to_world.y.w = location.
y;
488 light.object_to_world.z.w = location.
z;
490 light.sun.clipmap_origin =
float2(level_offset_max * tile_size_max);
492 light.sun.clipmap_lod_min = levels_range.first();
493 light.sun.clipmap_lod_max = levels_range.last();
499 cascade_level_range(light,
camera) :
500 clipmap_level_range(
camera);
502 if (levels_range == levels_new) {
507 IndexRange before_range(levels_range.start(), isect_range.
start() - levels_range.start());
511 auto span = tilemaps_.as_span();
512 shadows_.tilemap_pool.release(span.slice(before_range.
shift(-levels_range.start())));
513 shadows_.tilemap_pool.release(span.slice(after_range.
shift(-levels_range.start())));
514 tilemaps_ = span.slice(isect_range.
shift(-levels_range.start()));
515 levels_range = isect_range;
522 cascade_level_range(light,
camera) :
523 clipmap_level_range(
camera);
525 if (levels_range != levels_new) {
533 for (
int64_t i = 0; i < before_range; i++) {
534 tilemaps_.append(tilemap_pool.
acquire());
537 tilemaps_.extend(cached_tilemaps);
538 for (
int64_t i = 0; i < after_range; i++) {
539 tilemaps_.append(tilemap_pool.
acquire());
541 levels_range = levels_new;
546 light.
clip_far = int(0xFF7FFFFFu ^ 0x7FFFFFFFu);
549 cascade_tilemaps_distribution(light,
camera);
552 clipmap_tilemaps_distribution(light,
camera);
565 for (
int i = 0; i < statistics_buf_.size(); i++) {
567 statistics_buf_.current().clear_to_zero();
568 statistics_buf_.swap();
581 bool update_lights =
false;
583 bool use_jitter = enable_shadow &&
584 (inst_.is_image_render ||
585 (!inst_.is_navigating && !inst_.is_transforming && !inst_.is_playback &&
591 for (
Light &light : inst_.lights.light_map_.values()) {
592 light.initialized =
false;
602 data_.step_count = 1;
608 const size_t page_byte_size =
square_i(shadow_page_size_) *
sizeof(int);
609 shadow_page_len_ = int(
divide_ceil_ul(pool_byte_size, page_byte_size));
610 shadow_page_len_ =
min_ii(shadow_page_len_, SHADOW_MAX_PAGE);
612 const int2 atlas_extent = shadow_page_size_ *
int2(SHADOW_PAGE_PER_ROW, SHADOW_PAGE_PER_COL);
613 const int atlas_layers =
divide_ceil_u(shadow_page_len_, SHADOW_PAGE_PER_LAYER);
617 if (atlas_tx_.ensure_2d_array(atlas_type, atlas_extent, atlas_layers, tex_usage)) {
619 do_full_update_ =
true;
623 if (!atlas_tx_.is_valid()) {
624 atlas_tx_.ensure_2d_array(ShadowModule::atlas_type,
int2(1), 1);
625 inst_.info_append_i18n(
626 "Error: Could not allocate shadow atlas. Most likely out of GPU memory.");
630 if (inst_.is_viewport()) {
631 if (inst_.sampling.finished_viewport()) {
633 for (
int i = 0; i < statistics_buf_.size(); i++) {
634 statistics_buf_.swap();
638 statistics_buf_.swap();
640 statistics_buf_.current().read();
644 inst_.info_append_i18n(
645 "Error: Shadow buffer full, may result in missing shadows and lower "
646 "performance. ({} / {})",
651 inst_.info_append_i18n(
"Error: Too many shadow updates, some shadows might be incorrect.");
655 atlas_tx_.filter_mode(
false);
659 for (
int i = 0; i < multi_viewports_.size(); i++) {
662 int size_in_tile =
min_ii(1 << i, SHADOW_TILEMAP_RES);
663 multi_viewports_[i][0] = 0;
664 multi_viewports_[i][1] = 0;
665 multi_viewports_[i][2] = size_in_tile * shadow_page_size_;
666 multi_viewports_[i][3] = size_in_tile * shadow_page_size_;
672 past_casters_updated_.clear();
673 curr_casters_updated_.clear();
674 curr_casters_.clear();
675 jittered_transparent_casters_.clear();
676 update_casters_ =
true;
678 if (box_batch_ ==
nullptr) {
683 Manager &manager = *inst_.manager;
688 if (inst_.is_baking()) {
689 SurfelBuf &surfels_buf = inst_.volume_probes.bake.surfels_buf_;
690 CaptureInfoBuf &capture_info_buf = inst_.volume_probes.bake.capture_info_buf_;
691 float surfel_coverage_area = inst_.volume_probes.bake.surfel_density_;
695 int directional_level = std::max(0,
int(std::ceil(
log2(surfel_coverage_area / texel_size))));
701 sub.
bind_ssbo(
"surfel_buf", &surfels_buf);
702 sub.
bind_ssbo(
"capture_info_buf", &capture_info_buf);
706 sub.
dispatch(&inst_.volume_probes.bake.dispatch_per_surfel_);
719 sub.
push_constant(
"input_depth_extent", &input_depth_extent_);
723 sub.
dispatch(&dispatch_depth_scan_size_);
737 sub.
push_constant(
"fb_resolution", &usage_tag_fb_resolution_);
743 tilemap_usage_transparent_ps_ = ⊂
750 bool has_transparent_shadows,
751 bool has_time_dependent_shadows,
752 bool has_offset_shadows)
754 if ((is_alpha_blend && !inst_.is_baking()) || has_offset_shadows) {
755 tilemap_usage_transparent_ps_->draw(box_batch_, ob_handle.
res_handle);
759 if (!is_shadow_caster) {
763 const bool shape_changed = has_time_dependent_shadows && inst_.materials.material_time_changed;
767 shadow_ob.
used =
true;
769 const bool has_jittered_transparency = has_transparent_shadows && data_.use_jitter;
771 if (is_shadow_caster &&
772 (ob_handle.
recalc || !is_initialized || has_jittered_transparency || shape_changed))
774 if (ob_handle.
recalc && is_initialized) {
778 if (has_jittered_transparency) {
779 jittered_transparent_casters_.append(instance_handle.
raw());
782 curr_casters_updated_.append(instance_handle.
raw());
787 if (is_shadow_caster) {
788 curr_casters_.append(instance_handle.
raw());
796 for (
Light &light : inst_.lights.light_map_.values()) {
798 if ((!light.used || !enabled_) && !inst_.is_baking()) {
799 light.shadow_discard_safe(*
this);
801 else if (light.directional !=
nullptr) {
802 light.directional->release_excess_tilemaps(light, inst_.camera);
804 else if (light.punctual !=
nullptr) {
805 light.punctual->release_excess_tilemaps(light);
811 for (
Light &light : inst_.lights.light_map_.values()) {
812 if (enabled_ ==
false) {
815 else if (light.directional !=
nullptr) {
816 light.directional->end_sync(light, inst_.camera);
818 else if (light.punctual !=
nullptr) {
819 light.punctual->end_sync(light);
828 auto it_end = objects_.items().end();
829 for (
auto it = objects_.items().begin(); it != it_end; ++it) {
832 if (!shadow_ob.
used && !inst_.is_baking()) {
839 shadow_ob.
used =
false;
842 past_casters_updated_.push_update();
843 curr_casters_updated_.push_update();
844 jittered_transparent_casters_.push_update();
846 curr_casters_.push_update();
848 if (do_full_update_) {
849 do_full_update_ =
false;
852 uint3 page = {i % SHADOW_PAGE_PER_ROW,
853 (i / SHADOW_PAGE_PER_ROW) % SHADOW_PAGE_PER_COL,
854 i / SHADOW_PAGE_PER_LAYER};
855 pages_free_data_[i] = shadow_page_pack(page);
857 for (
uint i :
IndexRange(shadow_page_len_, SHADOW_MAX_PAGE - shadow_page_len_)) {
858 pages_free_data_[i] = 0xFFFFFFFFu;
860 pages_free_data_.push_update();
870 pages_infos_data_.page_free_count = shadow_page_len_;
871 pages_infos_data_.page_alloc_count = 0;
872 pages_infos_data_.page_cached_next = 0u;
873 pages_infos_data_.page_cached_start = 0u;
874 pages_infos_data_.page_cached_end = 0u;
875 pages_infos_data_.push_update();
879 Manager &manager = *inst_.manager;
902 sub.
bind_ssbo(
"casters_id_buf", curr_casters_);
905 sub.
bind_ssbo(
"light_buf_write", &inst_.lights.culling_light_buf_);
906 sub.
push_constant(
"resource_len",
int(curr_casters_.size()));
922 sub.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
944 if (past_casters_updated_.size() > 0) {
946 pass.
bind_ssbo(
"resource_ids_buf", past_casters_updated_);
950 if (curr_casters_updated_.size() > 0) {
952 pass.
bind_ssbo(
"resource_ids_buf", curr_casters_updated_);
960 PassSimple &pass = jittered_transparent_caster_update_ps_;
962 if (jittered_transparent_casters_.size() > 0) {
970 pass.
bind_ssbo(
"resource_ids_buf", jittered_transparent_casters_);
971 pass.
draw(box_batch_,
981 if (past_casters_updated_.size() > 0 || curr_casters_updated_.size() > 0 ||
982 jittered_transparent_casters_.size() > 0)
995 if (inst_.volume.needs_shadow_tagging() && !inst_.is_baking()) {
1017 sub.
push_constant(
"max_view_per_tilemap", &max_view_per_tilemap_);
1029 sub.
bind_ssbo(
"pages_infos_buf", pages_infos_data_);
1030 sub.
bind_ssbo(
"pages_free_buf", pages_free_data_);
1031 sub.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
1044 sub.
bind_ssbo(
"pages_infos_buf", pages_infos_data_);
1045 sub.
bind_ssbo(
"pages_free_buf", pages_free_data_);
1046 sub.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
1047 sub.
bind_ssbo(
"statistics_buf", &statistics_buf_.current());
1048 sub.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf_);
1049 sub.
bind_ssbo(
"tile_draw_buf", tile_draw_buf_);
1059 sub.
bind_ssbo(
"statistics_buf", &statistics_buf_.current());
1060 sub.
bind_ssbo(
"pages_infos_buf", pages_infos_data_);
1061 sub.
bind_ssbo(
"pages_free_buf", pages_free_data_);
1062 sub.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
1072 sub.
bind_ssbo(
"pages_infos_buf", &pages_infos_data_);
1073 sub.
bind_ssbo(
"statistics_buf", &statistics_buf_.current());
1074 sub.
bind_ssbo(
"view_infos_buf", &shadow_multi_view_.matrices_ubo_get());
1075 sub.
bind_ssbo(
"render_view_buf", &render_view_buf_);
1087 sub.
bind_ssbo(
"statistics_buf", &statistics_buf_.current());
1088 sub.
bind_ssbo(
"render_view_buf", &render_view_buf_);
1090 sub.
bind_ssbo(
"clear_dispatch_buf", &clear_dispatch_buf_);
1091 sub.
bind_ssbo(
"tile_draw_buf", &tile_draw_buf_);
1092 sub.
bind_ssbo(
"dst_coord_buf", &dst_coord_buf_);
1093 sub.
bind_ssbo(
"src_coord_buf", &src_coord_buf_);
1094 sub.
bind_ssbo(
"render_map_buf", &render_map_buf_);
1106 sub.
bind_ssbo(
"light_buf_write", &inst_.lights.culling_light_buf_);
1117 sub.
bind_ssbo(
"pages_infos_buf", pages_infos_data_);
1118 sub.
bind_ssbo(
"dst_coord_buf", dst_coord_buf_);
1119 sub.
bind_image(
"shadow_atlas_img", atlas_tx_);
1131 if (!
ELEM(inst_.debug_mode,
1142 debug_draw_ps_.init();
1144 int tilemap_index = -1;
1145 Object *object_active = inst_.draw_ctx->obact;
1146 if (object_active !=
nullptr) {
1148 if (inst_.lights.light_map_.contains(object_key)) {
1149 Light &light = inst_.lights.light_map_.lookup(object_key);
1163 debug_draw_ps_.state_set(
state);
1164 debug_draw_ps_.shader_set(inst_.shaders.static_shader_get(
SHADOW_DEBUG));
1165 debug_draw_ps_.push_constant(
"debug_mode",
int(inst_.debug_mode));
1166 debug_draw_ps_.push_constant(
"debug_tilemap_index", tilemap_index);
1169 debug_draw_ps_.bind_resources(inst_.uniform_data);
1170 debug_draw_ps_.bind_resources(inst_.hiz_buffer.front);
1171 debug_draw_ps_.bind_resources(inst_.lights);
1172 debug_draw_ps_.bind_resources(inst_.shadows);
1176bool ShadowModule::shadow_update_finished(
int loop_count)
1178 if (loop_count >= (SHADOW_MAX_TILEMAP * SHADOW_TILEMAP_LOD) / SHADOW_VIEW_MAX) {
1192 if (max_updated_view_count <= SHADOW_VIEW_MAX * loop_count) {
1198 if (loop_count == 1) {
1203 if (loop_count == 2) {
1207 statistics_buf_.current().async_flush_to_host();
1208 statistics_buf_.current().read();
1209 ShadowStatistics stats = statistics_buf_.current();
1212 inst_.info_append_i18n(
1213 "Error: Shadow buffer full, may result in missing shadows and lower "
1214 "performance. ({} / {})",
1223 needed_views_ -= SHADOW_VIEW_MAX;
1225 return needed_views_ <= 0;
1228int ShadowModule::max_view_per_tilemap()
1230 if (inst_.is_image_render) {
1233 return SHADOW_TILEMAP_LOD;
1237 int potential_view_count = 0;
1240 potential_view_count += SHADOW_TILEMAP_LOD;
1243 potential_view_count += 1;
1248 if (inst_.is_transforming || inst_.is_navigating) {
1249 max_view_count =
math::min(2, max_view_count);
1252 if (inst_.is_playback) {
1253 max_view_count =
math::min(1, max_view_count);
1256 return max_view_count;
1259void ShadowModule::ShadowView::compute_visibility(
ObjectBoundsBuf &bounds,
1269 resource_len * word_per_draw;
1301 if (enabled_ ==
false) {
1306 input_depth_extent_ = extent;
1312 max_view_per_tilemap_ = max_view_per_tilemap();
1315 usage_tag_fb.ensure(usage_tag_fb_resolution_);
1318 render_fb_.ensure(
int2(SHADOW_TILEMAP_RES * shadow_page_size_));
1320 update_tag_fb_.ensure(
int2(SHADOW_TILEMAP_RES));
1322 inst_.hiz_buffer.update();
1332 run_tagging_ = (loop_count == 0);
1334 inst_.manager->submit(tilemap_setup_ps_, view);
1335 if (loop_count == 0) {
1340 inst_.manager->submit(caster_update_ps_, view);
1342 inst_.manager->submit(jittered_transparent_caster_update_ps_, view);
1343 inst_.manager->submit(update_propagate_ps_, view);
1344 inst_.manager->submit(tilemap_usage_ps_, view);
1346 inst_.manager->submit(tilemap_update_ps_, view);
1348 shadow_multi_view_.compute_procedural_bounds();
1350 statistics_buf_.current().async_flush_to_host();
1353 bool use_flush = loop_count != 0;
1360 const int4 &largest_viewport = multi_viewports_[SHADOW_TILEMAP_LOD];
1363 reinterpret_cast<int (*)[4]
>(multi_viewports_.data()));
1373 largest_viewport.w);
1376 inst_.pipelines.shadow.render(shadow_multi_view_);
1388 }
while (!shadow_update_finished(loop_count));
1398 switch (inst_.debug_mode) {
1401 "Debug Mode: Shadow Tilemap (active light)\n"
1403 " - Yellow: Used & Updated\n"
1404 " - Purple: Cached\n");
1407 inst_.info_append(
"Debug Mode: Shadow Values (active light)");
1410 inst_.info_append(
"Debug Mode: Shadow Tile Random Color (active light)");
1413 inst_.info_append(
"Debug Mode: Shadow Tilemap Random Color (active light)");
1417 "Debug Mode: Shadow Atomic Cost\n"
1426 inst_.hiz_buffer.update();
1429 inst_.manager->submit(debug_draw_ps_, view);
constexpr int64_t one_after_last() const
constexpr IndexRange shift(int64_t n) const
constexpr IndexRange intersect(IndexRange other) const
constexpr IndexRange()=default
constexpr int64_t start() const
SwapChain< ObjectBoundsBuf, 2 > bounds_buf
ObjectRef(Object *ob, Object *dupli_parent=nullptr, DupliObject *dupli_object=nullptr)
int instances_count() const
ResourceHandle sub_handle(int index) const
void resize(int64_t new_size)
void append(const T &value)
bool ensure_2d(gpu::TextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
void clear(float4 values)
UniformArrayBuffer< ViewCullingData, DRW_VIEW_MAX > culling_
VisibilityBuf visibility_buf_
static float screen_pixel_radius(const float4x4 &wininv, bool is_perspective, const int2 &extent)
UniformArrayBuffer< ViewMatrices, DRW_VIEW_MAX > data_
int visibility_word_per_draw() const
void bind_resources(U &resources)
void framebuffer_set(gpu::FrameBuffer **framebuffer)
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void bind_image(const char *name, gpu::Texture *image)
PassBase< DrawCommandBufType > & sub(const char *name)
void dispatch(int group_len)
void state_set(DRWState state, int clip_plane_count=0)
void barrier(GPUBarrier type)
void state_stencil(uint8_t write_mask, uint8_t reference, uint8_t compare_mask)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
detail::PassBase< command::DrawMultiBuf > Sub
A running instance of the engine.
void info_append_i18n(const char *msg, Args &&...args)
static float coverage_get(int lvl)
static float tile_size_get(int lvl)
void end_sync(Light &light, const Camera &camera)
void release_excess_tilemaps(const Light &light, const Camera &camera)
ShadowModule(Instance &inst, ShadowSceneData &data)
ShadowTileMapPool tilemap_pool
void sync_object(const ObjectHandle &ob_handle, bool is_alpha_blend_or_has_offset_shadow, bool has_transparent_shadows, bool has_time_dependent_shadows, bool has_offset_shadows)
void set_view(View &view, int2 extent)
void debug_draw(View &view, gpu::FrameBuffer *view_fb)
void render(View &view, int2 extent)
void release_excess_tilemaps(const Light &light)
void end_sync(Light &light)
Simple API to draw debug shapes and log in the viewport.
#define DRW_VISIBILITY_GROUP_SIZE
#define DRW_VIEW_CULLING_UBO_SLOT
#define DRW_OBJ_INFOS_SLOT
#define DRW_VIEW_UBO_SLOT
#define VOLUME_GROUP_SIZE
VecBase< float, D > normalize(VecOp< float, D >) RET
float distance(float, float) RET
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
detail::Pass< command::DrawCommandBuf > PassSimple
detail::Pass< command::DrawMultiBuf > PassMain
void drw_debug_matrix_as_bbox(const float4x4 &mat, const float4 color, const uint lifetime)
StorageArrayBuffer< ObjectBounds, 128 > ObjectBoundsBuf
StorageArrayBuffer< ObjectInfos, 128 > ObjectInfosBuf
@ SHADOW_TILEMAP_TAG_USAGE_SURFELS
@ SHADOW_TILEMAP_RENDERMAP
@ SHADOW_TILEMAP_FINALIZE
@ SHADOW_TILEMAP_TAG_USAGE_OPAQUE
@ SHADOW_TILEMAP_TAG_USAGE_TRANSPARENT
@ SHADOW_TILEMAP_TAG_USAGE_VOLUME
@ SHADOW_TILEMAP_TAG_UPDATE_PROPAGATE
@ SHADOW_TILEMAP_TAG_UPDATE
draw::StorageArrayBuffer< Surfel, 64 > SurfelBuf
draw::StorageBuffer< CaptureInfoData > CaptureInfoBuf
@ DEBUG_SHADOW_TILE_RANDOM_COLOR
@ DEBUG_SHADOW_ATOMIC_COST
@ DEBUG_SHADOW_TILEMAP_RANDOM_COLOR
@ SHADOW_PROJECTION_CLIPMAP
@ SHADOW_PROJECTION_CASCADE
@ SHADOW_PROJECTION_CUBEFACE
MatBase< T, 4, 4 > orthographic(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to ...
MatBase< T, 4, 4 > perspective(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-...
MatBase< T, NumCol, NumRow > transpose(const MatBase< T, NumRow, NumCol > &mat)
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
T min(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T max(const T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
VecBase< uint32_t, 2 > uint2
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
gpu::FrameBuffer * GPU_framebuffer_active_get()
VecBase< int32_t, 4 > int4
bool assign_if_different(T &old_value, T &&new_value)
void GPU_framebuffer_viewport_set(gpu::FrameBuffer *fb, int x, int y, int width, int height)
MINLINE int square_i(int a)
VecBase< uint32_t, 4 > uint4
gpu::Batch * GPU_batch_unit_cube() ATTR_WARN_UNUSED_RESULT
MatBase< float, 2, 3 > float2x3
MINLINE int max_ii(int a, int b)
VecBase< uint32_t, 3 > uint3
MatBase< float, 4, 4 > float4x4
void GPU_compute_dispatch(gpu::Shader *shader, uint groups_x_len, uint groups_y_len, uint groups_z_len, const gpu::shader::SpecializationConstants *constants_state=nullptr)
int GPU_shader_get_ssbo_binding(gpu::Shader *shader, const char *name)
void GPU_storagebuf_clear(gpu::StorageBuf *ssbo, uint32_t clear_value)
VecBase< float, 4 > float4
@ SCE_EEVEE_SHADOW_JITTERED_VIEWPORT
@ SCE_EEVEE_SHADOW_ENABLED
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_ATOMIC
@ GPU_TEXTURE_USAGE_ATTACHMENT
MINLINE uint64_t divide_ceil_ul(uint64_t a, uint64_t b)
void GPU_memory_barrier(GPUBarrier barrier)
BMesh const char void * data
void GPU_framebuffer_multi_viewports_set(gpu::FrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4])
bool equals_m4m4(const float mat1[4][4], const float mat2[4][4])
MINLINE float int_as_float(int i)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_1i(gpu::Shader *sh, const char *name, int value)
@ GPU_BARRIER_TEXTURE_FETCH
@ GPU_BARRIER_SHADER_STORAGE
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
@ DRW_STATE_WRITE_STENCIL
void GPU_storagebuf_bind(gpu::StorageBuf *ssbo, int slot)
void GPU_uniformbuf_bind(gpu::UniformBuf *ubo, int slot)
MatBase< float, 3, 3 > float3x3
void GPU_debug_group_end()
T * DEG_get_original(T *id)
MINLINE float max_ff(float a, float b)
MINLINE uint divide_ceil_u(uint a, uint b)
bool GPU_multi_viewport_support()
void GPU_uniformbuf_clear_to_zero(gpu::UniformBuf *ubo)
MINLINE uint ceil_to_multiple_u(uint a, uint b)
VecBase< float, 3 > float3
MINLINE int min_ii(int a, int b)
MINLINE int clamp_i(int value, int min, int max)
void GPU_debug_group_begin(const char *name)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const c_style_mat & ptr() const
const MatView< T, ViewNumCol, ViewNumRow, NumCol, NumRow, SrcStartCol, SrcStartRow, Alignment > view() const
eObject_VisibilityFlag visibility_flag
float shadow_resolution_scale
float screen_diagonal_length
int local_tilemap_count() const
struct Transform object_to_world
uint2 shadow_set_membership
const ResourceHandleRange res_handle
ResourceHandle resource_handle
enum eLightType light_type
enum eShadowProjectionType projection_type
uint2 shadow_set_membership
ShadowTileMapDataBuf tilemaps_data
ShadowTileMapDataBuf tilemaps_unused
ShadowTileDataBuf tiles_data
void release(Span< ShadowTileMap * > free_list)
ShadowTileMapClipBuf tilemaps_clip
void end_sync(ShadowModule &module)
ShadowTileMap * acquire()
Vector< uint > free_indices
Pool< ShadowTileMap > tilemap_pool
static constexpr int64_t maps_per_row
void sync_orthographic(const float4x4 &object_mat_, int2 origin_offset, int clipmap_level, eShadowProjectionType projection_type_, uint2 shadow_set_membership_=~uint2(0))
static constexpr int64_t tile_map_resolution
ShadowTileMap(int tiles_index_)
void sync_cubeface(eLightType light_type_, const float4x4 &object_mat, float near, float far, eCubeFace face, uint2 shadow_set_membership_=~uint2(0))