You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Jitter shadow map dithering pattern across frames when TAA is enabled
This improves shadow quality by reducing the visibility of the noisy pattern caused by dithering. This jittering also applies when FSR2 is enabled, as it provides its own form of temporal antialiasing. Co-authored-by: Clay John <claynjohn@gmail.com>
This commit is contained in:
@@ -1886,7 +1886,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
float range_begin = directional_lights.data[i].shadow_range_begin.x;
|
||||
float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
|
||||
vec2 tex_scale = directional_lights.data[i].uv_scale1 * test_radius;
|
||||
shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
shadow = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
blend_count++;
|
||||
}
|
||||
|
||||
@@ -1902,7 +1902,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
float range_begin = directional_lights.data[i].shadow_range_begin.y;
|
||||
float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
|
||||
vec2 tex_scale = directional_lights.data[i].uv_scale2 * test_radius;
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
|
||||
if (blend_count == 0) {
|
||||
shadow = s;
|
||||
@@ -1927,7 +1927,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
float range_begin = directional_lights.data[i].shadow_range_begin.z;
|
||||
float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
|
||||
vec2 tex_scale = directional_lights.data[i].uv_scale3 * test_radius;
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
|
||||
if (blend_count == 0) {
|
||||
shadow = s;
|
||||
@@ -1952,7 +1952,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
float range_begin = directional_lights.data[i].shadow_range_begin.w;
|
||||
float test_radius = (range_pos - range_begin) * directional_lights.data[i].softshadow_angle;
|
||||
vec2 tex_scale = directional_lights.data[i].uv_scale4 * test_radius;
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
float s = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
|
||||
if (blend_count == 0) {
|
||||
shadow = s;
|
||||
@@ -2003,7 +2003,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
|
||||
pssm_coord /= pssm_coord.w;
|
||||
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * (blur_factor + (1.0 - blur_factor) * float(directional_lights.data[i].blend_splits)), pssm_coord);
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * (blur_factor + (1.0 - blur_factor) * float(directional_lights.data[i].blend_splits)), pssm_coord, scene_data.taa_frame_count);
|
||||
|
||||
if (directional_lights.data[i].blend_splits) {
|
||||
float pssm_blend;
|
||||
@@ -2037,7 +2037,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
|
||||
pssm_coord /= pssm_coord.w;
|
||||
|
||||
float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * (blur_factor2 + (1.0 - blur_factor2) * float(directional_lights.data[i].blend_splits)), pssm_coord);
|
||||
float shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale * (blur_factor2 + (1.0 - blur_factor2) * float(directional_lights.data[i].blend_splits)), pssm_coord, scene_data.taa_frame_count);
|
||||
shadow = mix(shadow, shadow2, pssm_blend);
|
||||
}
|
||||
}
|
||||
@@ -2220,7 +2220,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
continue; // Statically baked light and object uses lightmap, skip
|
||||
}
|
||||
|
||||
float shadow = light_process_omni_shadow(light_index, vertex, normal);
|
||||
float shadow = light_process_omni_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
|
||||
|
||||
shadow = blur_shadow(shadow);
|
||||
|
||||
@@ -2292,7 +2292,7 @@ void fragment_shader(in SceneData scene_data) {
|
||||
continue; // Statically baked light and object uses lightmap, skip
|
||||
}
|
||||
|
||||
float shadow = light_process_spot_shadow(light_index, vertex, normal);
|
||||
float shadow = light_process_spot_shadow(light_index, vertex, normal, scene_data.taa_frame_count);
|
||||
|
||||
shadow = blur_shadow(shadow);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user