diff --git a/libs/gfx/source/effect/blur.cpp b/libs/gfx/source/effect/blur.cpp index fff3d60f..2d00238a 100644 --- a/libs/gfx/source/effect/blur.cpp +++ b/libs/gfx/source/effect/blur.cpp @@ -55,9 +55,15 @@ void main() vec4 result = vec4(0.0); for (int i = -BLUR_SIZE; i <= BLUR_SIZE; ++i) { - result += texture(u_texture, texcoord + float(i) * direction * u_inv_texture_size) * coeffs[i + BLUR_SIZE]; + vec4 p = texture(u_texture, texcoord + float(i) * direction * u_inv_texture_size); + float c = coeffs[i + BLUR_SIZE]; + result.rgb += p.rgb * p.a * c; + result.a += p.a * c; } - out_color = result; + if (result.a == 0.0) + out_color = result; + else + out_color = vec4(result.rgb / result.a, result.a); } )";