EEVEE-Next: Implement LOD bias for sun light

This reduces the impact of tagging volumes and transparent
object when a sunlight is present.
This commit is contained in:
Clément Foucault
2024-05-30 15:59:09 +02:00
parent 44e9544199
commit ef4644f3bb

View File

@@ -53,9 +53,11 @@ void shadow_tag_usage_tilemap_directional(uint l_idx, vec3 P, vec3 V, float radi
vec3 lP = light_world_to_local_direction(light, P);
/* TODO(Miguel Pozo): Implement lod_bias support. */
LightSunData sun = light_sun_data_get(light);
if (radius == 0.0) {
int level = shadow_directional_level(light, lP - light_position_get(light));
level = clamp(level + lod_bias, sun.clipmap_lod_min, sun.clipmap_lod_max);
ShadowCoordinates coord = shadow_directional_coordinates_at_level(light, lP, level);
shadow_tag_usage_tile(light, coord.tilemap_tile, 0, coord.tilemap_index);
}
@@ -64,6 +66,8 @@ void shadow_tag_usage_tilemap_directional(uint l_idx, vec3 P, vec3 V, float radi
vec3 end_lP = light_world_to_local_direction(light, P + V * radius);
int min_level = shadow_directional_level(light, start_lP - light_position_get(light));
int max_level = shadow_directional_level(light, end_lP - light_position_get(light));
min_level = clamp(min_level + lod_bias, sun.clipmap_lod_min, sun.clipmap_lod_max);
max_level = clamp(max_level + lod_bias, sun.clipmap_lod_min, sun.clipmap_lod_max);
for (int level = min_level; level <= max_level; level++) {
ShadowCoordinates coord_min = shadow_directional_coordinates_at_level(