Thank you for your message Daniel, it was indeed due to the PMA. I initially tried to use the same technique you used in the ColorMatrixFilter, but I was missing something.
Just realized today after reading your message that the color attribute has also PMA, so when I was doing the multiplication and the offset at the same time, the colors were wrong. I've reverted the PMA from the color attribute, and now the results are much better!
Although there's one strange problem left, with the
max operation to avoid the division by zero when undoing the PMA on the texels color. If I run that operation, fully transparent texels are affected by the alpha offset.
But if I omit this operation, those transparents texels are not affected, and we have the right results most of the time. (it randomly fails to ignore transparent texels and still apply the alpha offset to them sometimes)
So for now, I've decided to skip the
max operation and make sure to apply the alpha offset only to non-transparent texels. Cf. https://github.com/rthery/starling-colortransform/commit/2aae8f5a7121dc5cb9e89e040ea7938dbeae44ef#diff-309fa331e3e6a88384f612cd120d39c6L215
I'm not sure if it's a bug with Stage3D or just a problem with my AGAL code (since I'm no expert, quite possibly the second option!)
In any case, the end result works well now 🙂