diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-04-30 13:25:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-04-30 17:39:26 +0300 |
commit | 41431eacfa1afc66533f5d27cc21dfa58024e26c (patch) | |
tree | 11f582e11d426087293bb8519ae2fc8b6681bec3 /source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl | |
parent | 630c24fc61329bb1a161653f355fad887aa1d08d (diff) |
Eevee: TAA: Use safe color when outputing the final color.
This prevent any NANs pixel to spear accross the history. This does not
mean we should allow NANs at all!
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl index d4fbac21563..8d07ae45b6b 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_temporal_aa.glsl @@ -4,6 +4,12 @@ uniform sampler2D velocityBuffer; out vec4 FragColor; +vec4 safe_color(vec4 c) +{ + /* Clamp to avoid black square artifacts if a pixel goes NaN. */ + return clamp(c, vec4(0.0), vec4(1e20)); /* 1e20 arbitrary. */ +} + #ifdef USE_REPROJECTION /** @@ -85,7 +91,7 @@ void main() bool out_of_view = any(greaterThanEqual(abs(uv_history - 0.5), vec2(0.5))); color_history = (out_of_view) ? color : color_history; - FragColor = color_history; + FragColor = safe_color(color_history); } #else @@ -97,6 +103,6 @@ void main() ivec2 texel = ivec2(gl_FragCoord.xy); vec4 color = texelFetch(colorBuffer, texel, 0); vec4 color_history = texelFetch(colorHistoryBuffer, texel, 0); - FragColor = mix(color_history, color, alpha); + FragColor = safe_color(mix(color_history, color, alpha)); } #endif |