summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd/shaders
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-09-15 00:03:40 +0200
committerGitHub <noreply@github.com>2022-09-15 00:03:40 +0200
commitecaa7b634e17cf2220c0d10f4cba035309b9dc8c (patch)
tree840c91176e4b966465171afd4b5bb9b1028e055b /servers/rendering/renderer_rd/shaders
parent6fd3f6a287a459e99fb99ce4473e644c7333d88b (diff)
parente844b95eafb4bd8504979c70b05b0569837a66f5 (diff)
Merge pull request #65322 from ceLoFaN/fix-dof-artifact-at-high-blur
Diffstat (limited to 'servers/rendering/renderer_rd/shaders')
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/bokeh_dof.glsl5
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl9
2 files changed, 6 insertions, 8 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);
diff --git a/servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl b/servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl
index a2bdc2e90e..1b487835d2 100644
--- a/servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/bokeh_dof_raster.glsl
@@ -221,12 +221,9 @@ void main() {
vec4 sample_color = texture(source_color, uv_adj);
sample_color.a = texture(source_weight, uv_adj).r;
- float limit;
-
- if (sample_color.a < color.a) {
- limit = abs(sample_color.a);
- } else {
- limit = abs(color.a);
+ float limit = abs(sample_color.a);
+ if (sample_color.a > color.a) {
+ limit = clamp(limit, 0.0, abs(color.a) * 2.0);
}
limit -= DEPTH_GAP;