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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user