🔧 Make alphaOver more readable

This commit is contained in:
Simon Schneegans
2022-12-19 20:14:41 +01:00
parent 69ae86f606
commit 1116b012e8
+2 -2
View File
@@ -121,8 +121,8 @@ void setOutputColor(vec4 outColor) { cogl_color_out = outColor; }
// The Shell.GLSLEffect uses straight alpha blending. This helper method allows
// compositing color values in the shader in the same way.
vec4 alphaOver(vec4 under, vec4 over) {
float alpha = over.a + under.a * (1.0 - over.a);
return vec4((over.rgb * over.a + under.rgb * under.a * (1.0 - over.a)) / alpha, alpha);
float alpha = mix(under.a, 1.0, over.a);
return vec4(mix(under.rgb * under.a, over.rgb, over.a) / alpha, alpha);
}
// ------------------------------------------------------------------------- color helpers