What's the correct "final step" in a premultiplied alpha blending shader to respect vertex colours?

I’m having an issue with a premultiplied alpha blending shader for the UI I’m tinkering with that won’t respect the CanvasGroup’s alpha.

Normally the “final step” would be:

half4 final = results * IN.color;

I’m guessing I need to do something a little different because of the premultiplied alpha blending but I’m not sure what.

Thanks.

Premultiplied alpha blending assumes the color has been premultiplied by the alpha, hence “premultiplied alpha”. If you want the vertex alpha to act like alpha blending, then:

half4 final = results * IN.color;
final.rgb *= final.a;

2 Likes

Brilliant. Thanks mate.