33 {{+1, +0, +0}, {+0, +1, +0}, {+0, +0, +1}},
34 {{+0, +0, -1}, {-1, +0, +0}, {+0, +1, +0}},
35 {{+0, +0, +1}, {+1, +0, +0}, {+0, +1, +0}},
36 {{+1, +0, +0}, {+0, +0, -1}, {+0, +1, +0}},
37 {{-1, +0, +0}, {+0, +0, +1}, {+0, +1, +0}},
38 {{+1, +0, +0}, {+0, -1, +0}, {+0, +0, -1}},
43 {0, SHADOW_TILEMAP_RES / 2, 0, 0},
183 friend ShadowPunctual;
184 friend ShadowDirectional;
185 friend ShadowPipeline;
186 friend ShadowTileMapPool;
204 bool update_casters_ =
false;
211 int needed_views_ = 0;
217 PassSimple tilemap_setup_ps_ = {
"TilemapSetup"};
218 PassMain tilemap_usage_ps_ = {
"TagUsage"};
219 PassSimple tilemap_update_ps_ = {
"TilemapUpdate"};
222 gpu::Batch *box_batch_ =
nullptr;
224 gpu::Texture *src_depth_tx_ =
nullptr;
226 Framebuffer usage_tag_fb;
228 PassSimple caster_update_ps_ = {
"CasterUpdate"};
229 PassSimple jittered_transparent_caster_update_ps_ = {
"TransparentCasterUpdate"};
230 PassSimple update_propagate_ps_ = {
"CasterUpdatePropagate"};
232 StorageVectorBuffer<uint, 128> past_casters_updated_ = {
"PastCastersUpdated"};
233 StorageVectorBuffer<uint, 128> curr_casters_updated_ = {
"CurrCastersUpdated"};
234 StorageVectorBuffer<uint, 128> jittered_transparent_casters_ = {
"JitteredTransparentCasters"};
236 StorageVectorBuffer<uint, 128> curr_casters_ = {
"CurrCasters"};
238 Framebuffer update_tag_fb_ = {
"update_tag_fb"};
245 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> dst_coord_buf_ = {
"dst_coord_buf"};
247 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> src_coord_buf_ = {
"src_coord_buf"};
249 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> render_map_buf_ = {
"render_map_buf"};
253 int3 dispatch_depth_scan_size_;
254 int2 usage_tag_fb_resolution_;
255 int usage_tag_fb_lod_ = 5;
256 int max_view_per_tilemap_ = 1;
257 int2 input_depth_extent_;
260 SwapChain<ShadowStatisticsBuf, 5> statistics_buf_;
270 Texture atlas_tx_ = {
"shadow_atlas_tx_"};
279 int3 copy_dispatch_size_;
280 int3 scan_dispatch_size_;
281 int rendering_tilemap_;
283 bool do_full_update_ =
true;
291 class ShadowView :
public View {
297 :
View(name, SHADOW_VIEW_MAX,
true), inst_(inst), render_view_buf_(render_view_buf)
306 bool debug_freeze)
override;
310 ShadowView shadow_multi_view_ = {
"ShadowMultiView", inst_, render_view_buf_};
312 Framebuffer render_fb_ = {
"shadow_write_framebuffer"};
315 std::array<int4, 16> multi_viewports_;
331 float global_lod_bias_ = 0.0f;
333 int shadow_page_size_ = SHADOW_PAGE_RES;
335 int shadow_page_len_ = SHADOW_MAX_TILEMAP;
337 bool enabled_ =
true;
352 bool is_alpha_blend_or_has_offset_shadow,
353 bool has_transparent_shadows,
354 bool has_time_dependent_shadows,
355 bool has_offset_shadows);
384 return global_lod_bias_;
390 do_full_update_ =
true;
394 void remove_unused();
395 bool shadow_update_finished(
int loop_count);
398 float tilemap_pixel_radius();
401 int max_view_per_tilemap();
421 : shadows_(other.shadows_), tilemaps_(std::move(other.tilemaps_)) {};
425 shadows_.tilemap_pool.release(tilemaps_);
450 : shadows_(other.shadows_), tilemaps_(std::move(other.tilemaps_)) {};
454 shadows_.tilemap_pool.release(tilemaps_);
492 void cascade_tilemaps_distribution_near_far_points(
const Camera &
camera,
#define GPU_BATCH_DISCARD_SAFE(batch)
constexpr IndexRange()=default
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
View(const char *name, int view_len=1, bool procedural=false)
detail::PassBase< command::DrawMultiBuf > Sub
A running instance of the engine.
static float coverage_get(int lvl)
ShadowDirectional(ShadowModule &module)
static float tile_size_get(int lvl)
void end_sync(Light &light, const Camera &camera)
ShadowDirectional(ShadowDirectional &&other)
void release_excess_tilemaps(const Light &light, const Camera &camera)
ShadowModule(Instance &inst, ShadowSceneData &data)
ShadowTileMapPool tilemap_pool
const ShadowSceneData & get_data()
float global_lod_bias() const
Pool< ShadowDirectional > directional_pool
void bind_resources(PassType &pass)
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)
Pool< ShadowPunctual > punctual_pool
void debug_draw(View &view, gpu::FrameBuffer *view_fb)
void render(View &view, int2 extent)
ShadowPunctual(ShadowPunctual &&other)
ShadowPunctual(ShadowModule &module)
void release_excess_tilemaps(const Light &light)
void end_sync(Light &light)
#define SHADOW_ATLAS_TEX_SLOT
#define SHADOW_TILEMAPS_TEX_SLOT
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
detail::Pass< command::DrawCommandBuf > PassSimple
draw::StorageBuffer< DrawCommand, true > DrawIndirectBuf
detail::Pass< command::DrawMultiBuf > PassMain
StorageArrayBuffer< ObjectBounds, 128 > ObjectBoundsBuf
draw::StorageBuffer< DispatchCommand > DispatchIndirectBuf
StorageArrayBuffer< ObjectInfos, 128 > ObjectInfosBuf
draw::StorageBuffer< ShadowPagesInfoData > ShadowPagesInfoDataBuf
static constexpr const float shadow_face_mat[6][3][3]
draw::StorageArrayBuffer< ShadowTileDataPacked, SHADOW_MAX_TILE, true > ShadowTileDataBuf
draw::StorageArrayBuffer< ShadowTileMapClip, SHADOW_MAX_TILEMAP, true > ShadowTileMapClipBuf
draw::StorageArrayBuffer< uint2, SHADOW_MAX_PAGE, true > ShadowPageCacheBuf
draw::StorageArrayBuffer< ShadowRenderView, SHADOW_VIEW_MAX, true > ShadowRenderViewBuf
draw::StorageBuffer< ShadowStatistics > ShadowStatisticsBuf
draw::StorageVectorBuffer< ShadowTileMapData, SHADOW_MAX_TILEMAP > ShadowTileMapDataBuf
static constexpr const float shadow_clipmap_scale_mat[4][4]
draw::StorageVectorBuffer< uint, SHADOW_MAX_PAGE > ShadowPageHeapBuf
VecBase< uint32_t, 2 > uint2
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< int32_t, 3 > int3
BMesh const char void * data
VecBase< float, 3 > float3
static MatBase identity()
ResourceHandle resource_handle
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
static constexpr int64_t tiles_count
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))