Sprites with alpha look darker when being animated

We found an issue when updating to cocos2d-x version 3.13.1

We noticed that in our game sprites with alpha looked darker and ended up finding out that it was an issue with premultiplied alpha.

cocos2d-x will by default premultiply every RGBA8888 texture, in our case we saw that the darker sprites problem appeared only on sprites that were being animated with the Animate action.

In the issue blend mode does not work with animated sprite · Issue #9367 · cocos2d/cocos2d-x · GitHub was added two lines to CCAnimate

 auto blend = static_cast<Sprite*>(_target)->getBlendFunc(); //THIS LINE
 _currFrameIndex = i;
 AnimationFrame* frame = frames.at(_currFrameIndex);
 frameToDisplay = frame->getSpriteFrame();
 static_cast<Sprite*>(_target)->setSpriteFrame(frameToDisplay);
 static_cast<Sprite*>(_target)->setBlendFunc(blend);  //THIS LINE

what those lines do is force the blendfunc to the one configured in the sprite ignoring the proper blendfunc determined by the current sprite frame texture.

In the test project you can see one case where the effect is rendered correctly, and one when the effect is rendered darker.

The difference between those two cases is that in the one that renders correctly the sprite is initialised with the first frame of the animation, so the blend func is consistent while the animation is running.

In the case that renders incorrectly the sprite is first created empty without referencing the animation sprites, and after that an Animate action is executed. In this case the sprite has ALPHA_NON_PREMULTIPLIED but the texture needs ALPHA_PREMULTIPLIED to be rendered correctly, and the Animate action will force ALPHA_NON_PREMULTIPLIED to be used.

We think this change is a big change in how cocos2d-x used to work and in our case, we almost always create an empty sprite and afterwards we set it up with an animation if needed.
If this remains we will need to either disable premultiplication, comment the lines in CCAnimate or change everywhere we create sprites to use the first sprite which is a worse match for how our engine works.

We created a small test project with this so you can test.

Thanks,
Guillermo

No one? this is really important for us.