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}},
197 friend ShadowPunctual;
198 friend ShadowDirectional;
199 friend ShadowPipeline;
200 friend ShadowTileMapPool;
221 bool update_casters_ =
false;
227 PassSimple tilemap_setup_ps_ = {
"TilemapSetup"};
228 PassMain tilemap_usage_ps_ = {
"TagUsage"};
229 PassSimple tilemap_update_ps_ = {
"TilemapUpdate"};
232 gpu::Batch *box_batch_ =
nullptr;
234 gpu::Texture *src_depth_tx_ =
nullptr;
236 Framebuffer usage_tag_fb;
238 PassSimple caster_update_ps_ = {
"CasterUpdate"};
239 PassSimple jittered_transparent_caster_update_ps_ = {
"TransparentCasterUpdate"};
241 StorageVectorBuffer<uint, 128> past_casters_updated_ = {
"PastCastersUpdated"};
242 StorageVectorBuffer<uint, 128> curr_casters_updated_ = {
"CurrCastersUpdated"};
243 StorageVectorBuffer<uint, 128> jittered_transparent_casters_ = {
"JitteredTransparentCasters"};
245 StorageVectorBuffer<uint, 128> curr_casters_ = {
"CurrCasters"};
252 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> dst_coord_buf_ = {
"dst_coord_buf"};
254 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> src_coord_buf_ = {
"src_coord_buf"};
256 StorageArrayBuffer<uint, SHADOW_RENDER_MAP_SIZE, true> render_map_buf_ = {
"render_map_buf"};
260 int3 dispatch_depth_scan_size_;
261 int2 usage_tag_fb_resolution_;
262 int usage_tag_fb_lod_ = 5;
263 int max_view_per_tilemap_ = 1;
264 int2 input_depth_extent_;
267 SwapChain<ShadowStatisticsBuf, 5> statistics_buf_;
277 Texture atlas_tx_ = {
"shadow_atlas_tx_"};
286 int3 copy_dispatch_size_;
287 int3 scan_dispatch_size_;
288 int rendering_tilemap_;
290 bool do_full_update_ =
true;
298 class ShadowView :
public View {
313 bool debug_freeze)
override;
317 ShadowView shadow_multi_view_ = {
"ShadowMultiView", inst_, render_view_buf_};
319 Framebuffer render_fb_ = {
"shadow_write_framebuffer"};
324 Texture shadow_depth_fb_tx_ = {
"shadow_depth_fb_tx_"};
325 Texture shadow_depth_accum_tx_ = {
"shadow_depth_accum_tx_"};
328 std::array<int4, 16> multi_viewports_;
344 float global_lod_bias_ = 0.0f;
350 bool enabled_ =
true;
368 bool has_transparent_shadows);
396 return global_lod_bias_;
402 do_full_update_ =
true;
411 void remove_unused();
412 bool shadow_update_finished(
int loop_count);
415 float tilemap_pixel_radius();
418 int max_view_per_tilemap();
438 : shadows_(other.shadows_), tilemaps_(std::move(other.tilemaps_)) {};
442 shadows_.tilemap_pool.release(tilemaps_);
467 : shadows_(other.shadows_), tilemaps_(std::move(other.tilemaps_)) {};
471 shadows_.tilemap_pool.release(tilemaps_);
506 void cascade_tilemaps_distribution(
Light &light,
const Camera &camera);
507 void clipmap_tilemaps_distribution(
Light &light,
const Camera &camera);
509 void cascade_tilemaps_distribution_near_far_points(
const Camera &camera,
static void View(GHOST_IWindow *window, bool stereo, int eye=0)
#define GPU_BATCH_DISCARD_SAFE(batch)
BMesh const char void * data
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()
void sync_object(const Object *ob, const ObjectHandle &handle, const ResourceHandleRange &resource_handle, bool is_alpha_blend, bool has_transparent_shadows)
float global_lod_bias() const
Pool< ShadowDirectional > directional_pool
void bind_resources(PassType &pass)
static float screen_pixel_radius(const float4x4 &wininv, bool is_perspective, const int2 &extent)
void set_view(View &view, int2 extent)
Pool< ShadowPunctual > punctual_pool
void debug_draw(View &view, gpu::FrameBuffer *view_fb)
static ShadowTechnique shadow_technique
ShadowPunctual(ShadowPunctual &&other)
ShadowPunctual(ShadowModule &module)
void release_excess_tilemaps(const Light &light)
void end_sync(Light &light)
#define SHADOW_TILEMAP_RES
#define SHADOW_MAX_TILEMAP
#define SHADOW_TILEMAP_PER_ROW
#define SHADOW_TILEDATA_PER_TILEMAP
#define SHADOW_ATLAS_TEX_SLOT
#define SHADOW_TILEMAPS_TEX_SLOT
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
VecBase< float, 3 > float3
static struct PyModuleDef module
static MatBase identity()
ResourceHandleRange 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))