90 int3 input_coord =
clamp(texel_coord,
int3(0), grid_size - 1);
92 bool is_padding_voxel = !
all(
equal(texel_coord, input_coord));
95 IrradianceBrick brick = irradiance_brick_unpack(lvd.bricks_infos_buf[brick_index]);
96 int2 output_coord =
int2(brick.atlas_coord);
100 float validity =
texelFetch(srt.validity_tx, input_coord, 0).r;
101 if (validity > srt.dilation_threshold) {
103 sh_local = srt.irradiance_load(input_coord);
109 float weight_accum = 1e-8f;
111 int radius = int(srt.dilation_radius);
112 for (
int x = -radius;
x <= radius;
x++) {
113 for (
int y = -radius;
y <= radius;
y++) {
114 for (
int z = -radius;
z <= radius;
z++) {
115 if (
x == 0 &&
y == 0 &&
z == 0) {
119 int3 neighbor_coord = input_coord + offset;
120 float neighbor_validity =
texelFetch(srt.validity_tx, neighbor_coord, 0).r;
122 if (neighbor_validity < srt.dilation_threshold) {
126 if (dist_sqr >
square(srt.dilation_radius)) {
129 float weight = 1.0f / dist_sqr;
131 srt.irradiance_load(neighbor_coord), weight, sh_local);
132 weight_accum += weight;
136 float inv_weight_accum =
safe_rcp(weight_accum);
142 to_float3x3(lvd.grids_infos_buf[srt.grid_index].world_to_grid_transposed));
146 sh_visibility.
L0.M0 = sh_local.
L0.M0.aaaa;
147 sh_visibility.
L1.Mn1 = sh_local.
L1.Mn1.aaaa;
148 sh_visibility.
L1.M0 = sh_local.
L1.M0.aaaa;
149 sh_visibility.
L1.Mp1 = sh_local.
L1.Mp1.aaaa;
152 srt.grid_local_to_world, grid_size, input_coord);
155 P, srt.grid_start_index);
157 if (is_padding_voxel) {
159 sh_local = sh_distant;
172 atlas.store(sh_local.
L0.M0, output_coord, 0, local_id);
173 atlas.store(sh_local.
L1.Mn1, output_coord, 1, local_id);
174 atlas.store(sh_local.
L1.M0, output_coord, 2, local_id);
175 atlas.store(sh_local.
L1.Mp1, output_coord, 3, local_id);
177 if ((local_id.z % 4u) == 0u) {
181 for (
int cell = 0; cell < 4; cell++) [[
unroll]] {
182 for (
int i = 0; i < 8; i++) {
184 int3 coord_texel = texel_coord +
int3(0, 0, cell) + sample_position;
185 int3 coord_input =
clamp(coord_texel,
int3(0), grid_size - 1);
186 float validity =
texelFetch(srt.validity_tx, coord_input, 0).r;
187 bool is_padding_voxel = !
all(
equal(coord_texel, coord_input));
188 if ((validity > srt.validity_threshold) || is_padding_voxel) {
189 cell_validity_bits[cell] |= (1 << i);
195 atlas.store(
float4(cell_validity_bits), output_coord, 4, local_id);
218 int brick_index = lvd.grids_infos_buf[srt.grid_index].brick_offset;
221 IrradianceBrick brick = irradiance_brick_unpack(lvd.bricks_infos_buf[brick_index]);
222 int2 output_coord =
int2(brick.atlas_coord);
225 sh.
L0.M0 = srt.harmonic_buf.L0_M0;
226 sh.
L1.Mn1 = srt.harmonic_buf.L1_Mn1;
227 sh.
L1.M0 = srt.harmonic_buf.L1_M0;
228 sh.
L1.Mp1 = srt.harmonic_buf.L1_Mp1;
232 atlas.store(sh.
L0.M0, output_coord, 0, local_id);
233 atlas.store(sh.
L1.Mn1, output_coord, 1, local_id);
234 atlas.store(sh.
L1.M0, output_coord, 2, local_id);
235 atlas.store(sh.
L1.Mp1, output_coord, 3, local_id);
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET