diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-08-11 02:24:09 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-08-11 02:26:05 +0300 |
commit | aa575a3152ade77db68a6420fc978158c34d8dd9 (patch) | |
tree | c9a89f10e65ab98fbea3135d0824c0386caeeeec /source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl | |
parent | 0665f58a57b54c874f9d944cb0fbf3422cb214b0 (diff) |
Eevee: SSR Clamp color when blurring buffers.
This effectivly reduce firefly bleeding all over the place.
We still need the clamp in the resolve pass because the level 0 has not been clamped.
NOTE: I did not clamped each sample individually for performance BUT I did not profile it to know how much it cost.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl index fc29079cf19..156be108a14 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_downsample_frag.glsl @@ -3,9 +3,15 @@ **/ uniform sampler2D source; +uniform float fireflyFactor; out vec4 FragColor; +float brightness(vec3 c) +{ + return max(max(c.r, c.g), c.b); +} + void main() { #if 0 @@ -23,5 +29,9 @@ void main() FragColor += textureLod(source, uvs + ofs.zy, 0.0); FragColor += textureLod(source, uvs + ofs.zw, 0.0); FragColor *= 0.25; + + /* Clamped brightness. */ + float luma = max(1e-8, brightness(FragColor.rgb)); + FragColor *= 1.0 - max(0.0, luma - fireflyFactor) / luma; #endif }
\ No newline at end of file |