-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][cocos2dx-v4] Re-enable support for a custom SpineAnimation shader #1763
Conversation
Sync with primary branch
…ion when using SkeletonBatch. This won't have any affect when using SkeletonTwoColorBatch.
To fix the batching with custom shaders, changes to cocos2d-x v4 engine code had to be made, and are now in a pull request cocos2d/cocos2d-x#20584 With the changes to the cocos2d-x engine code in that pull request, multiple spine animations will use a single draw call if the custom shader has the same uniform values. |
This looks great! I'll have to validate the PR, but from a quick look I think we can merge this as is. Thanks! |
It does work as it is. The only issue is that the attachments on the Spine animation, one that is using a custom fragment shader, do not get batched into one draw call, even if they are using the same texture, but that has nothing to do with Spine or the changes in this pull request; it's a Cocos2d-x v4 issue, and if and when the Cocos2d-x devs fix it (such as the Cocos2d-x pull request I linked above), no modifications should be required to Spine in order to batch the draw calls. I'm using it at the moment with the modified Cocos2d-x v4, and every sprite animation with a unique fragment shader uses only a single draw call per shader (which is correct). |
Hm, IIRC, when I tested the v4 spine-cocos2dx runtime, the old way via |
As per @halx99 we are going with his PR, as it avoids a few performance issues. |
I'm not sure about the implementation by @halx99 since I wasn't involved in creating it. If that implementation is more suitable, then go with it that one. The code by @halx99 seems similar, with a few additions like overriding the SkeletonTwoColorBatch shader. We just need the custom shader support re-enabled in the cocos2d-x v4 runtime, and how it's done is entirely up to you. Regarding the UniformLocation of both the MVP and texture, will it always be the same for all program states? If so, then the
|
I'd assume the uniform location might change on some platforms, i.e. if the OpenGL context is lost on older Android versions. |
These changes re-enable support for a custom shader applied to SpineAnimation when using SkeletonBatch with Cocos2d-x v4. This won't have any affect when using SkeletonTwoColorBatch, since that is already applying its own shader for the two color effect.
NOTE: When a custom shader is applied, it breaks batching, because of this code in Cocos2d-x,
CCTrianglesCommand.cpp
:Not sure what to do about that.