You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +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:
@@ -1450,9 +1450,9 @@ void main() {
|
||||
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);
|
||||
} else {
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
} else if (depth_z < directional_lights.data[i].shadow_split_offsets.y) {
|
||||
vec4 v = vec4(vertex, 1.0);
|
||||
@@ -1467,9 +1467,9 @@ void main() {
|
||||
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;
|
||||
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);
|
||||
} else {
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
} else if (depth_z < directional_lights.data[i].shadow_split_offsets.z) {
|
||||
vec4 v = vec4(vertex, 1.0);
|
||||
@@ -1484,9 +1484,9 @@ void main() {
|
||||
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;
|
||||
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);
|
||||
} else {
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
} else {
|
||||
vec4 v = vec4(vertex, 1.0);
|
||||
@@ -1501,9 +1501,9 @@ void main() {
|
||||
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;
|
||||
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);
|
||||
} else {
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1522,9 +1522,9 @@ void main() {
|
||||
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;
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
} else {
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
|
||||
pssm_blend = smoothstep(0.0, directional_lights.data[i].shadow_split_offsets.x, depth_z);
|
||||
@@ -1539,9 +1539,9 @@ void main() {
|
||||
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;
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
} else {
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
|
||||
pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.x, directional_lights.data[i].shadow_split_offsets.y, depth_z);
|
||||
@@ -1555,9 +1555,9 @@ void main() {
|
||||
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;
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale);
|
||||
shadow2 = sample_directional_soft_shadow(directional_shadow_atlas, pssm_coord.xyz, tex_scale * directional_lights.data[i].soft_shadow_scale, scene_data.taa_frame_count);
|
||||
} else {
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord);
|
||||
shadow2 = sample_directional_pcf_shadow(directional_shadow_atlas, scene_data.directional_shadow_pixel_size * directional_lights.data[i].soft_shadow_scale, pssm_coord, scene_data.taa_frame_count);
|
||||
}
|
||||
|
||||
pssm_blend = smoothstep(directional_lights.data[i].shadow_split_offsets.y, directional_lights.data[i].shadow_split_offsets.z, depth_z);
|
||||
@@ -1627,7 +1627,7 @@ void main() {
|
||||
|
||||
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;
|
||||
@@ -1661,7 +1661,7 @@ void main() {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1767,7 +1767,7 @@ void main() {
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -1812,7 +1812,7 @@ void main() {
|
||||
break;
|
||||
}
|
||||
|
||||
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