Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
atomrc committed Jun 19, 2024
1 parent 986ecac commit 19052c8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/script/media/BackgroundBlurrer/fragmentShader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ void main() {
colorSum += texture2D(u_image, v_texCoord + onePixel * vec2(i, j));
}
}
// This is the blurred version of the pixel we are currently rendering
vec4 blurredPixel = vec4((colorSum / (pow(float(BLUR_QUALITY), 2.0) * 4.0)).rgb, 1);

float blend;
for (int i = -SMOOTH; i < SMOOTH; i++) {
for (int j = -SMOOTH; j < SMOOTH; j++) {
blend += texture2D(u_mask, v_texCoord + onePixel * vec2(i, j)).r == 1.0 ? 1.0 : 0.0;
}
}
blend = blend / pow(float((SMOOTH) * 2), 2.0);
//blend = texture2D(u_mask, v_texCoord).r;
// This is the clear version of the pixel we are currently rendering
vec4 clearPixel = texture2D(u_image, v_texCoord);

blend = texture2D(u_mask, v_texCoord).r;

// The gl_FragColor is a mix between the blurred and the clear pixel depending on the segmentation mask given
gl_FragColor = mix(blurredPixel, clearPixel, blend);
}

0 comments on commit 19052c8

Please sign in to comment.