diff options
author | ceLoFaN <ncefalo@pm.me> | 2022-09-04 13:23:49 +0300 |
---|---|---|
committer | ceLoFaN <ncefalo@pm.me> | 2022-09-05 21:38:40 +0300 |
commit | e844b95eafb4bd8504979c70b05b0569837a66f5 (patch) | |
tree | 98a3ab16d7a338780efa15c91d29da83aecffc95 /servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl | |
parent | b6d102c7c2d5e9f39f368bf1ebc91a48bf762c42 (diff) |
Fix DoF artifacting at high blur amounts
Diffstat (limited to 'servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl b/servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl index bdf84bb03a..fe770ac065 100644 --- a/servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl @@ -186,6 +186,7 @@ void main() { uv += pixel_size * 0.5; //half pixel to read centers vec4 color = texture(color_texture, uv); + float initial_blur = color.a; float accum = 1.0; float radius = params.blur_scale; @@ -193,8 +194,8 @@ void main() { vec2 suv = uv + vec2(cos(ang), sin(ang)) * pixel_size * radius; vec4 sample_color = texture(color_texture, suv); float sample_size = abs(sample_color.a); - if (sample_color.a > color.a) { - sample_size = clamp(sample_size, 0.0, abs(color.a) * 2.0); + if (sample_color.a > initial_blur) { + sample_size = clamp(sample_size, 0.0, abs(initial_blur) * 2.0); } float m = smoothstep(radius - 0.5, radius + 0.5, sample_size); |