From 4cf60a2abf2b862788daf9b0874b5c99e9d57b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 20 Apr 2021 15:55:31 +0200 Subject: Fix T87369 EEVEE: Ambient Oclussion: Firefly caused by degenerated normal This was caused by some sort of degenerated normals. --- .../blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/draw/engines') diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl index bf5b63cba65..cdc453eed40 100644 --- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl @@ -210,14 +210,14 @@ void occlusion_eval(OcclusionData data, bool early_out = (inverted != 0.0) ? (max_v4(abs(data.horizons)) == 0.0) : (min_v4(abs(data.horizons)) == M_PI); if (early_out) { - visibility = dot(N, Ng) * 0.5 + 0.5; + visibility = saturate(dot(N, Ng) * 0.5 + 0.5); visibility = min(visibility, data.custom_occlusion); if ((int(aoSettings) & USE_BENT_NORMAL) == 0) { bent_normal = N; } else { - bent_normal = normalize(N + Ng); + bent_normal = safe_normalize(N + Ng); } return; } @@ -283,7 +283,9 @@ void occlusion_eval(OcclusionData data, bent_normal = N; } else { - bent_normal = normalize(mix(bent_normal, N, sqr(sqr(sqr(visibility))))); + /* Note: using pow(visibility, 6.0) produces NaN (see T87369). */ + float tmp = saturate(pow6(visibility)); + bent_normal = normalize(mix(bent_normal, N, tmp)); } } -- cgit v1.2.3