Skip to content

Commit a827511

Browse files
authored
runfix: Improve background edge blurring (#17615)
1 parent 0ce9c81 commit a827511

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/script/media/BackgroundBlurrer/fragmentShader.glsl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define BLUR_QUALITY 14 //The higher the value, the more blur. Must be an even number.
2-
#define SMOOTH 3 // This will create a smooth transition between the blurred and the clear part (the higher the value, the smoother)
32

43
precision mediump float;
54

@@ -21,16 +20,14 @@ void main() {
2120
colorSum += texture2D(u_image, v_texCoord + onePixel * vec2(i, j));
2221
}
2322
}
23+
// This is the blurred version of the pixel we are currently rendering
2424
vec4 blurredPixel = vec4((colorSum / (pow(float(BLUR_QUALITY), 2.0) * 4.0)).rgb, 1);
2525

26-
float blend;
27-
for (int i = -SMOOTH; i < SMOOTH; i++) {
28-
for (int j = -SMOOTH; j < SMOOTH; j++) {
29-
blend += texture2D(u_mask, v_texCoord + onePixel * vec2(i, j)).r == 1.0 ? 1.0 : 0.0;
30-
}
31-
}
32-
blend = blend / pow(float((SMOOTH) * 2), 2.0);
33-
//blend = texture2D(u_mask, v_texCoord).r == 1.0 ? 1.0 : 0.0;
26+
// This is the clear version of the pixel we are currently rendering
3427
vec4 clearPixel = texture2D(u_image, v_texCoord);
28+
29+
float blend = texture2D(u_mask, v_texCoord).r;
30+
31+
// The gl_FragColor is a mix between the blurred and the clear pixel depending on the segmentation mask given
3532
gl_FragColor = mix(blurredPixel, clearPixel, blend);
3633
}

0 commit comments

Comments
 (0)