From 90c1d5832e40f4f58dfc4cf8e0265edca7bf62ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 18 Jun 2024 17:27:11 +0200 Subject: [PATCH] Fix: EEVEE: AO: Only clip occluders based on front sample This is cheaper but avoid loosing the sample influence when thickness is large. --- .../shaders/eevee_horizon_scan_eval_lib.glsl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/shaders/eevee_horizon_scan_eval_lib.glsl b/source/blender/draw/engines/eevee_next/shaders/eevee_horizon_scan_eval_lib.glsl index 9d0c9809d9a..4199fb7c46c 100644 --- a/source/blender/draw/engines/eevee_next/shaders/eevee_horizon_scan_eval_lib.glsl +++ b/source/blender/draw/engines/eevee_next/shaders/eevee_horizon_scan_eval_lib.glsl @@ -156,16 +156,12 @@ HorizonScanResult horizon_scan_eval(vec3 vP, const float bias = 2.0 * 2.4e-7; sample_depth += reversed ? -bias : bias; - vec3 vP_sample = drw_point_screen_to_view(vec3(sample_uv, sample_depth)); + vec3 vP_sample_front = drw_point_screen_to_view(vec3(sample_uv, sample_depth)); + vec3 vP_sample_back = vP_sample_front - vV * thickness_near; float sample_distance; - vec3 vL_front = normalize_and_get_length(vP_sample - vP, sample_distance); - if (sample_distance > search_distance) { - continue; - } - - vec3 vL_back = normalize_and_get_length((vP_sample - vV * thickness_near) - vP, - sample_distance); + vec3 vL_front = normalize_and_get_length(vP_sample_front - vP, sample_distance); + vec3 vL_back = normalize(vP_sample_back - vP); if (sample_distance > search_distance) { continue; }