Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-04-20 16:55:31 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-04-20 17:07:45 +0300
commit4cf60a2abf2b862788daf9b0874b5c99e9d57b65 (patch)
tree2057b13c868027c0737fb40b4530267191324ab1 /source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl
parent2125ee4305c0f22c2c30795669b0f38404e4eb72 (diff)
Fix T87369 EEVEE: Ambient Oclussion: Firefly caused by degenerated normal
This was caused by some sort of degenerated normals.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl8
1 files changed, 5 insertions, 3 deletions
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));
}
}