From 38b180f236ccabdccc7d291c4ee0780706baa025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Sat, 16 Mar 2024 15:20:46 +0100 Subject: [PATCH] EEVEE-Next: Shadow: Hide banding artifact at projection edges This affect all local lights (non-sun light). We hide the artifact caused by different tracing results from two adjacent projection. This is visible as the shading point switches projections. We fix this by randomizing which shadow map projection (face) to trace. We do that by using the point at half the ray instead of the shading point to choose the projection. This gives a soft enough look proportional to the light shape. This also has the benefit of being stupidly simple. Pull Request: https://projects.blender.org/blender/blender/pulls/119555 --- .../engines/eevee_next/shaders/eevee_shadow_tracing_lib.glsl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tracing_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tracing_lib.glsl index 565a60cd0ea..b13ef58182e 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tracing_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tracing_lib.glsl @@ -365,7 +365,9 @@ ShadowRayPunctual shadow_ray_generate_punctual(LightData light, vec3 local_ray_start = lP + projection_origin; vec3 local_ray_end = local_ray_start + direction; - int face_id = shadow_punctual_face_index_get(local_ray_start); + /* Use an offset in the ray direction to jitter which face is traced. + * This helps hiding some harsh discontinuity. */ + int face_id = shadow_punctual_face_index_get(local_ray_start + direction * 0.5); /* Local Light Space > Face Local (View) Space. */ vec3 view_ray_start = shadow_punctual_local_position_to_face_local(face_id, local_ray_start); vec3 view_ray_end = shadow_punctual_local_position_to_face_local(face_id, local_ray_end);