cocos2d-x lua 添加etc2支持

mark下

对,所以要确认你的用户是否是全部支持opengl 3.0。 并且是非模拟器用户。
又或者,你的用户用opengl2.0的非常少,可以默认抛弃的。
都2020年了,不支持3.0的手机都没了。

我集成过程中加入了Google Angle的软解,所以不会黑屏
详见: https://github.com/c4games/engine-x/blob/master/cocos/base/etc2.h#L81

1赞

你的这个引擎改的不错,有商用案例了吗?

c4 games 不知道?

mark下

按照二次元游戏公司的尿性,应该叫 cocos2d-x-re

叫什么无所谓

请问一下:
透明部分为什么显示为白色的,
正常应该是:

改用etc2后,引擎C++还有一些得修改,不然那个setBlendFunc混合模式会导致图片显示异常的,如粒子动画,骨骼动画,还有老编辑器CocosStudio加载代码等(若代码直接创建一张图片加载并显示的则正常)
参考添加核心代码:

if (tex && !tex->hasPremultipliedAlpha()) {
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
setOpacityModifyRGB(false);
}
else
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
}

另外使用etc2的得注意,不建议给粒子配套的图片转etc2,pvr等格式,转了etc2之后,setBlendFunc都是得使用BlendFunc::ALPHA_NON_PREMULTIPLIED,这时候再去叠加粒子本身混合模式,效果会有差异,所以在批量转换的时候,最好得忽略粒子图片不转换,以及其它一些你有用到了setBlendFunc函数功能的图片。

请问,如果是CocosStudio导出的UI,还要修改那个文件。

文件:cocos/editor-support/cocostudio/WidgetReader/SpriteReader/SpriteReader.cpp
方法:

void SpriteReader::setPropsWithFlatBuffers(cocos2d::Node node,
const flatbuffers::Table
spriteOptions)

原代码:

auto f_blendFunc = options->blendFunc();
if (f_blendFunc)
{
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
blendFunc.src = f_blendFunc->src();
blendFunc.dst = f_blendFunc->dst();
sprite->setBlendFunc(blendFunc);
}

修改后代码:

auto f_blendFunc = options->blendFunc();
if (f_blendFunc)
{
if (sprite->getTexture() && sprite->getTexture()->hasPremultipliedAlpha()) {
cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED;
blendFunc.src = f_blendFunc->src();
blendFunc.dst = f_blendFunc->dst();
sprite->setBlendFunc(blendFunc);
}
}

谢了,我试一下!!!

大佬,可以了,非常感谢!

大佬,这个修改是哪个C++文件?

论坛好像有点BUG,有回复貌似不会有通知,个人信息里边也看不到回复的…

改用etc2后,spine骨骼动画需修改的文件:cocos/editor-support/spine/SkeletonRenderer.cpp
原代码:

void SkeletonRenderer::initialize () {
_worldVertices = new float[1000]; // Max number of vertices per mesh.

_clipper = spSkeletonClipping_create();

_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);

setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
}

参考修改代码:

void SkeletonRenderer::initialize () {
_worldVertices = new float[1000]; // Max number of vertices per mesh.

_clipper = spSkeletonClipping_create();

Texture2D* tex = ((Texture2D*)this->_atlas->pages->rendererObject);
if (tex && !tex->hasPremultipliedAlpha()) {
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
setOpacityModifyRGB(false);
}
else
{
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
setOpacityModifyRGB(true);
}

setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
}

应该叫re:cocos,才有那味

关于spine使用ETC2渲染混合模式问题, 我这里做了更详细的总结,仅供参考: https://blog.csdn.net/xseekerj/article/details/109493823

1赞

大佬,请问下,如果spine导出的是选择mipmap,在android真机上显示的是“黑影”:
image ,win32模拟器上没问题,这怎么解决呢?