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 | |
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')
4 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index 85bd15757dc..bf45227d793 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -815,6 +815,7 @@ void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata) psl->color_downsample_ps = DRW_pass_create("Downsample", DRW_STATE_WRITE_COLOR); DRWShadingGroup *grp = DRW_shgroup_create(e_data.downsample_sh, psl->color_downsample_ps); DRW_shgroup_uniform_buffer(grp, "source", &e_data.color_src); + DRW_shgroup_uniform_float(grp, "fireflyFactor", &effects->ssr_firefly_fac, 1); DRW_shgroup_call_add(grp, quad, NULL); } diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 7a446d221fa..b3774698e4f 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -434,6 +434,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *veda struct Gwn_Batch *geom = DRW_cache_fullscreen_quad_get(); DRWShadingGroup *grp = stl->g_data->planar_downsample = DRW_shgroup_instance_create(e_data.probe_planar_downsample_sh, psl->probe_planar_downsample_ps, geom); DRW_shgroup_uniform_buffer(grp, "source", &txl->planar_pool); + DRW_shgroup_uniform_float(grp, "fireflyFactor", &stl->effects->ssr_firefly_fac, 1); DRW_shgroup_uniform_vec2(grp, "texelSize", stl->g_data->texel_size, 1); } } 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 diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl index 44e0c176010..3b3abdef00c 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_downsample_frag.glsl @@ -3,13 +3,18 @@ **/ uniform sampler2DArray source; -uniform vec2 texelSize; +uniform float fireflyFactor; in vec2 uvs; flat in float layer; out vec4 FragColor; +float brightness(vec3 c) +{ + return max(max(c.r, c.g), c.b); +} + void main() { #if 0 @@ -27,5 +32,9 @@ void main() FragColor += textureLod(source, vec3(uvs + ofs.zy, layer), 0.0); FragColor += textureLod(source, vec3(uvs + ofs.zw, layer), 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 |