shaderlib: Add alpha_blend function, extend place_texture example, update autocomplete - implements #23

This commit is contained in:
ChaoticByte 2024-12-30 17:02:19 +01:00
parent 3abaf38400
commit 1635cd5b82
No known key found for this signature in database
3 changed files with 21 additions and 8 deletions

View file

@ -0,0 +1,9 @@
// Alpha Blending a over b after Bruce A. Wallace
// sources:
// - https://en.wikipedia.org/wiki/Alpha_compositing
vec4 alpha_blend(vec4 b, vec4 a) {
float alpha = a.a + (b.a * (1.0 - a.a));
vec3 col = ((a.rgb*a.a) + ((b.rgb*b.a) * (1.0 - a.a)) / alpha);
return vec4(col.r, col.g, col.b, alpha);
}