private final Vector4 _function(Vector4 c0, Vector4 c1) {
float alpha = c1.w;
if (invertAlpha.get()) alpha = 1.0f - alpha;
final Vector4 color = new Vector4(c1);
final int func = blendFunction.getEnumPos();
alpha *= (opacity.get());
// apply the blending function without alpha:
if (func == 0) { // normal
// do nothing
} else if (func == 1) { // Multiply
color.multComp_ip(c0);
} else if (func == 2) { // Divide
color.multComp_ip(1/(c0.x + 1), 1/(c0.y + 1), 1/(c0.z + 1), 1);
} else if (func == 3) { // Screen
color.set(1-(1-c0.x)*(1-c1.x), 1-(1-c0.y)*(1-c1.y), 1-(1-c0.z)*(1-c1.z), 1);
} else if (func == 4) { // Overlay
color.set(c0.x*(c0.x + 2*(c1.x)*(1-c0.x)), c0.y*(c0.y + 2*(c1.y)*(1-c0.y)), c0.z*(c0.z + 2*(c1.z)*(1-c0.z)), 1);
} else if (func == 5) { // Dodge
color.set(c0.x/((1-c1.x)+1), c0.y/((1-c1.y)+1), c0.z/((1-c1.z)+1),1);
} else if (func == 6) { // Burn
color.set(1-((1-c0.x)/(c1.x+1)), 1-((1-c0.y)/(c1.y+1)), 1-((1-c0.z)/(c1.z+1)), 1);
} else if (func == 7) { // Difference
color.set(c0).sub_ip(c1).abs_ip();
} else if (func == 8) { // Addition
color.add_ip(c0);
} else if (func == 9) { // Subtract
color.set(c0).sub_ip(c1);
}
color.clamp(0.0f, 1.0f);
float origW = c0.w; // keep alpha ???
c0.mult_ip(1.0f - alpha);
c0.mult_add_ip(alpha, color);
c0.w = origW;