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>2017-07-26 21:00:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-07-27 15:51:44 +0300
commitc6a74edcf86ceedd63678421635e231ae4e92de8 (patch)
treeb71243ac4f0ef536b3219079950aca5a9e075c3a /source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
parentec6170061e726ee2c2700f48f9e47ebf7e3ec875 (diff)
Eevee: Fix bloom once and for all.
... Hopefully ...
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
index 517605778e3..5bb9607d33c 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_bloom_frag.glsl
@@ -46,6 +46,12 @@ out vec4 FragColor;
/* -------------- Utils ------------- */
+vec3 safe_color(vec3 c)
+{
+ /* Clamp to avoid black square artifacts if a pixel goes NaN. */
+ return clamp(c, vec3(0.0), vec3(1e20)); /* 1e20 arbitrary. */
+}
+
float brightness(vec3 c)
{
return max(max(c.r, c.g), c.b);
@@ -136,14 +142,14 @@ vec4 step_blit(void)
#ifdef HIGH_QUALITY /* Anti flicker */
vec3 d = sourceBufferTexelSize.xyx * vec3(1, 1, 0);
- vec3 s0 = textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb;
- vec3 s1 = textureLod(sourceBuffer, uvcoordsvar.xy - d.xz, 0.0).rgb;
- vec3 s2 = textureLod(sourceBuffer, uvcoordsvar.xy + d.xz, 0.0).rgb;
- vec3 s3 = textureLod(sourceBuffer, uvcoordsvar.xy - d.zy, 0.0).rgb;
- vec3 s4 = textureLod(sourceBuffer, uvcoordsvar.xy + d.zy, 0.0).rgb;
+ vec3 s0 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb);
+ vec3 s1 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy - d.xz, 0.0).rgb);
+ vec3 s2 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy + d.xz, 0.0).rgb);
+ vec3 s3 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy - d.zy, 0.0).rgb);
+ vec3 s4 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy + d.zy, 0.0).rgb);
vec3 m = median(median(s0.rgb, s1, s2), s3, s4);
#else
- vec3 s0 = textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb;
+ vec3 s0 = safe_color(textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb);
vec3 m = s0.rgb;
#endif
@@ -157,9 +163,6 @@ vec4 step_blit(void)
/* Combine and apply the brightness response curve. */
m *= max(rq, br - curveThreshold.w) / max(br, 1e-5);
- /* Clamp to avoid black square artifacts if a pixel goes NaN. */
- clamp(m, vec3(0.0), vec3(1e20)); /* 1e20 arbitrary. */
-
return vec4(m, 1.0);
}