File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed
src/script/media/BackgroundBlurrer Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
#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)
3
2
4
3
precision mediump float ;
5
4
@@ -21,16 +20,14 @@ void main() {
21
20
colorSum += texture2D (u_image, v_texCoord + onePixel * vec2 (i, j));
22
21
}
23
22
}
23
+ // This is the blurred version of the pixel we are currently rendering
24
24
vec4 blurredPixel = vec4 ((colorSum / (pow (float (BLUR_QUALITY), 2.0 ) * 4.0 )).rgb, 1 );
25
25
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
34
27
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
35
32
gl_FragColor = mix (blurredPixel, clearPixel, blend);
36
33
}
You can’t perform that action at this time.
0 commit comments