WIP: eevee-next-world-irradiance #108304
|
@ -50,10 +50,20 @@ void IrradianceCache::init()
|
||||||
brick_pool_.clear();
|
brick_pool_.clear();
|
||||||
/* Fill with all the available bricks. */
|
/* Fill with all the available bricks. */
|
||||||
for (auto i : IndexRange(atlas_row_count * atlas_col_count)) {
|
for (auto i : IndexRange(atlas_row_count * atlas_col_count)) {
|
||||||
IrradianceBrick brick;
|
if (i == 0) {
|
||||||
brick.atlas_coord = uint2(i % atlas_col_count, i / atlas_col_count) *
|
/* Reserve one brick for the world. */
|
||||||
IRRADIANCE_GRID_BRICK_SIZE;
|
world_brick_index_ = 0;
|
||||||
brick_pool_.append(irradiance_brick_pack(brick));
|
}
|
||||||
|
else {
|
||||||
|
IrradianceBrick brick;
|
||||||
|
brick.atlas_coord = uint2(i % atlas_col_count, i / atlas_col_count) *
|
||||||
|
IRRADIANCE_GRID_BRICK_SIZE;
|
||||||
|
brick_pool_.append(irradiance_brick_pack(brick));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (irradiance_atlas_tx_.is_valid()) {
|
||||||
|
irradiance_atlas_tx_.clear(float4(0.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +127,8 @@ void IrradianceCache::set_view(View & /*view*/)
|
||||||
|
|
||||||
/* TODO frustum cull and only load visible grids. */
|
/* TODO frustum cull and only load visible grids. */
|
||||||
|
|
||||||
if (grids_len >= IRRADIANCE_GRID_MAX) {
|
/* Note that we reserve 1 slot for the world irradiance. */
|
||||||
|
if (grids_len >= IRRADIANCE_GRID_MAX - 1) {
|
||||||
inst_.info = "Error: Too many grid visible";
|
inst_.info = "Error: Too many grid visible";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +164,17 @@ void IrradianceCache::set_view(View & /*view*/)
|
||||||
grid.grid_index = grids_len;
|
grid.grid_index = grids_len;
|
||||||
grids_infos_buf_[grids_len++] = grid;
|
grids_infos_buf_[grids_len++] = grid;
|
||||||
}
|
}
|
||||||
|
/* TODO: Stable sorting of grids. */
|
||||||
|
|
||||||
/* TODO(fclem): Insert world grid here. */
|
{
|
||||||
|
/* Insert world grid last. */
|
||||||
|
IrradianceGridData grid;
|
||||||
|
grid.world_to_grid_transposed = float3x4::identity();
|
||||||
|
grid.grid_size = int3(1);
|
||||||
|
grid.brick_offset = bricks_infos_buf_.size();
|
||||||
|
grids_infos_buf_[grids_len++] = grid;
|
||||||
|
bricks_infos_buf_.append(world_brick_index_);
|
||||||
|
}
|
||||||
|
|
||||||
if (grids_len < IRRADIANCE_GRID_MAX) {
|
if (grids_len < IRRADIANCE_GRID_MAX) {
|
||||||
/* Tag last grid as invalid to stop the iteration. */
|
/* Tag last grid as invalid to stop the iteration. */
|
||||||
|
|
|
@ -128,6 +128,8 @@ class IrradianceCache {
|
||||||
|
|
||||||
/** Atlas 3D texture containing all loaded grid data. */
|
/** Atlas 3D texture containing all loaded grid data. */
|
||||||
Texture irradiance_atlas_tx_ = {"irradiance_atlas_tx_"};
|
Texture irradiance_atlas_tx_ = {"irradiance_atlas_tx_"};
|
||||||
|
/** Reserved atlas brick for world irradiance. */
|
||||||
|
int world_brick_index_ = 0;
|
||||||
/** Data structure used to index irradiance cache pages inside the atlas. */
|
/** Data structure used to index irradiance cache pages inside the atlas. */
|
||||||
IrradianceGridDataBuf grids_infos_buf_ = {"grids_infos_buf_"};
|
IrradianceGridDataBuf grids_infos_buf_ = {"grids_infos_buf_"};
|
||||||
IrradianceBrickBuf bricks_infos_buf_ = {"bricks_infos_buf_"};
|
IrradianceBrickBuf bricks_infos_buf_ = {"bricks_infos_buf_"};
|
||||||
|
|
Loading…
Reference in New Issue