Make blur effect alpha-aware
This commit is contained in:
parent
3f758e845d
commit
50b75bdd27
1 changed files with 8 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue