Sorry for the delay.
While implementing the blend mode in glsl, I noticed that I had the calculation wrong after all.
So I started from scratch. Here's the important snipped from the final code:
It's unfortunately not 100% pixel perfect like I had hoped for. It is only accurate for ad = 0 and = 255,
the values in between are linearly interpolated but in RMXP they change in a more "square" way.
But that's good enough for my needs I guess.
While implementing the blend mode in glsl, I noticed that I had the calculation wrong after all.
So I started from scratch. Here's the important snipped from the final code:
vec4 resFrag;
float ab = opacity; // blend opacity
const float as = srcFrag.a;
const float ad = dstFrag.a;
const float at = ab*as;
resFrag.a = at + ad - ad*at;
resFrag.rgb = mix(dstFrag.rgb, srcFrag.rgb, ab*as);
resFrag.rgb = mix(srcFrag.rgb, resFrag.rgb, ad*resFrag.a);
gl_FragColor = resFrag;
It's unfortunately not 100% pixel perfect like I had hoped for. It is only accurate for ad = 0 and = 255,
the values in between are linearly interpolated but in RMXP they change in a more "square" way.
But that's good enough for my needs I guess.