You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
In continuation to #138 , After #138 was resolved, in my recent usage of the plugin, have discovered additional issue regarding the sprite blend;
-Opacity Animation Which due to the removal the blend func; it reads as src blend as one which will give off the slight Additive Blend feel during the animation instead of normal fade-in/out,
//Opacity Animation test(0 ~ 255 alpha) Before Modification
Additive Blend Mode Issue , Which resulted in a slightly duller colour;
//Additive Blend Mode test Before Modification
So i have tried to troubleshoot and have did a slight modification of creatorReader to resolve the issue of my above mentioned use case,
It may not be the best or good way;
But i would at least like to highlight possible issue that the community would encounter since i have encounter it myself;
Below is the modified Snippet of the CreatorReader.cpp
void CreatorReader::parseSprite(cocos2d::Sprite* sprite, const buffers::Sprite* spriteBuffer) const
{
/* As Per before*/
// Creator doesn't premultiply alpha, so its blend function can not work in cocos2d-x.
// const auto& srcBlend = spriteBuffer->srcBlend();
// const auto& dstBlend = spriteBuffer->dstBlend();
// cocos2d::BlendFunc blendFunc;
// blendFunc.src = srcBlend;
// blendFunc.dst = dstBlend;
// sprite->setBlendFunc(blendFunc);
const auto& srcBlend = spriteBuffer->srcBlend();
const auto& dstBlend = spriteBuffer->dstBlend();
//MODIFICATION START - If the blend function declared in creator is additive;
//Without setting the blend function, the color would get dull;
if (srcBlend == GL_SRC_ALPHA && dstBlend == GL_ONE)
{
cocos2d::BlendFunc blendFunc;
blendFunc.src = srcBlend;
blendFunc.dst = dstBlend;
sprite->setBlendFunc(blendFunc);
}
//For Animation that plays around with opacity
const AnimationRef *animRef = nodeBuffer->anim();
if (animRef)
{
const auto& animationClips = animRef->clips();
for (const auto& fbAnimationClip : *animationClips)
{
const auto& curveDatas = fbAnimationClip->curveData();
for (const auto& fbCurveData : *curveDatas)
{
if (fbCurveData)
{
const AnimProps* fbAnimProps = fbCurveData->props();
//Retrieve opacity curveData
const auto& opacityValue = fbAnimProps->opacity();
//If there is an opacity data, set the blend mode as per creator;
//As without setting blend from creator,
//the Blend func read would be src = GL_ONE; dst = GL_ONE_MINUS_ALPHA
//It will give off an additive effect instead of normal opacity animation;
if (opacityValue->size() != 0)
{
cocos2d::BlendFunc blendFunc;
blendFunc.src = srcBlend;
blendFunc.dst = dstBlend;
sprite->setBlendFunc(blendFunc);
}
}
}
}
}
//MODIFICATION END
/* As Per before*/
}
End result of the modification
//OpacityAnimation (0 ~ 255 alpha)
//Additive Blend
The text was updated successfully, but these errors were encountered:
Hi all,
In continuation to #138 , After #138 was resolved, in my recent usage of the plugin, have discovered additional issue regarding the sprite blend;
-Opacity Animation Which due to the removal the blend func; it reads as src blend as one which will give off the slight Additive Blend feel during the animation instead of normal fade-in/out,
//Opacity Animation test(0 ~ 255 alpha) Before Modification
Additive Blend Mode Issue , Which resulted in a slightly duller colour;
//Additive Blend Mode test Before Modification
So i have tried to troubleshoot and have did a slight modification of creatorReader to resolve the issue of my above mentioned use case,
It may not be the best or good way;
But i would at least like to highlight possible issue that the community would encounter since i have encounter it myself;
Below is the modified Snippet of the CreatorReader.cpp
End result of the modification
//OpacityAnimation (0 ~ 255 alpha)
//Additive Blend
The text was updated successfully, but these errors were encountered: