1、根据 纹理 是否alpha预乘,决定混合方式
void Sprite::updateBlendFunc(void) { CCASSERT(! _batchNode, "CCSprite: updateBlendFunc doesn't
work when the sprite is rendered using a SpriteBatchNode"); // it is possible to have an untextured sprite if (! _texture || ! _texture->hasPremultipliedAlpha()) { _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; setOpacityModifyRGB(false); } else { _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setOpacityModifyRGB(true); } }
2、混合方式示例:
const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO}; const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; const BlendFunc BlendFunc::ALPHA_NON_PREMULTIPLIED = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; const BlendFunc BlendFunc::ADDITIVE = {GL_SRC_ALPHA, GL_ONE};
对于 alpha 预乘的纹理,默认选择 {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}
即src以100%混合,dst以(1-src_alpha)混合;
对于未作alpha预乘的纹理,选择 {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}
即src需要乘以src_alpha混合,dst以(1-src_alpha)混合;
3、在使用 ASTC 压缩纹理时,默认未作alpha预乘;
4、png、jpg默认作 alpha预乘;
标签:SRC,BlendFunc,图形学,混合,预乘,alpha,ALPHA,GL From: https://www.cnblogs.com/xingchong/p/17164543.html