https://github.com/cocos2d/cocos2d-x/blob/develop/docs/RELEASE_NOTES.md#misc-information
说白了就是可以放node了
New Renderer
Feature added in v3.0-beta and improved in v3.0-beta2
The way currently cocos2d-x v2.2 does rendering is OK but it is difficult to optimize, difficult to add new functionality and difficult to port to new platforms. So cocos2d-x v3.0 has a new renderer that is more performing, elegant, scalable, flexible but still simple to use and to understand. Also existing cocos2d-x users will find the new API familiar and they will feel immediately comfortable with, without having to bother about what’s changed or what's new under the hood.
Features of the new renderer:
- It has been decoupled from the Scene Graph. The
draw()method, instead of "drawing" it sends aRenderCommandto theRenderer, andRendereris responsible for drawing the queuedRenderCommandcommands. QuadCommands(used bySpriteandParticleSystemobjects) will be automatically batched.CustomCommandobjects allow the user to use custom OpenGL code, using a API similar to v2.2GroupCommandobjects allow to have "stacks" in the Renderer with different OpenGL values.- Auto-culling for
Spriteobjects (although, technically, Auto-culling is not performed inRenderercode, but in theSpritecode) - Global Z ordering (local Z ordering is still supported)
For detailed information, please read the following doc: Renderer Specification document
Renderer features
Auto-batching
Auto-batching means that the Renderer will package "multiple draw calls" in just one "big draw call" (AKA batch). In order to group "draw calls" certain conditions are needed:
- It only works with
QuadCommandcommands (used by Sprite and ParticleSystem objects) - The
QuadCommandsmust share the same Material ID: same Texture ID, same GLProgram and same blending function - The
QuadCommandsmust consecutive
If those conditions are met, the Renderer will create create a batch (one draw call) with all thoseQuadCommand objects.
In case you are unfamiliar with the OpenGL best practices, batching is very important to have decent speed in your games. The less batches (draw calls) the more performance your game is going to be.
Auto-culling
For the moment auto-culling is only implemented on Sprite objects.
When the method Sprite::draw() is called, it will check if the Sprite is outside the screen. If so, it won't send the QuadCommand command to theRenderer, and thus, it will gain some performance.
In v2.2 the recommended way to have good performance was to parent Sprite objects to aSpriteBatchNode object. Although the performance was (is still) very good by usingSpriteBatchNode objects, they had (still have) some limitations like:
Spriteobjects can only haveSpriteobjects as children (if not, cocos2d-x will raise an Assert)- You cannot add a
ParticleSystemas a child ofSprite, when theSpriteis parented to aSpriteBatchNode - As a consequence of that, you cannot use
ParallaxNodewithSpritesparented toSpriteBatchNode
- You cannot add a
- All
Spriteobjects must share the same TextureId (if not, cocos2d-x will raise an Assert) Spriteobjects use theSpriteBatchNode's blending function and shader.
And although v3.0 still supports SpriteBatchNode (with the same features and limitations), we no longer encourage its usage. Instead, we recommend to useSprite objects without parenting them to a SpriteBatchNode.
But in order to have a very good performance in v3.0, you have to make sure that yourSprite objects:
- Share the same TextureId (place them in a spritesheet, like if you were using a
SpriteBatchNode) - Make sure all of them use the same shader and blending function (like if you were using a
SpriteBatchNode)
If you do so, the Sprites will perform almost as fast as to usingSpriteBatchNode... (about 10% slower on old devices. On newer devices the difference is almost imperceptible)
The big differences between v2.2 and v3.0 are:
Spriteobjects can have different Texture IDs.Spriteobjects can have any kind ofNodeas children, includingParticleSystem.Spriteobjects can have different blending functions and use different shaders.
But if you do that, the Renderer might not be able to batch all its children (less performant). But the game will keep running, without raising any Assert.
To summarize:
- Keep putting all your sprites in a big spritesheet
- Use the same Blending Function (just use the default one)
- Use the same Shader (just use the default one)
- And don't parent your sprites to a
SpriteBatchNode
Only use SpriteBatchNode as the last resort, when you really need an extra (although minor) boost in performance (and you are OK with its limitations).
这个是渲染的文档。
https://docs.google.com/document/d/17zjC55vbP_PYTftTZEuvqXuMb9PbYNxRFu0EGTULPK8/edit#
本文深入解析Cocos2d-X v3.0版本中渲染器的改进,包括新API、性能优化、功能扩展等关键特性。着重介绍了自动批处理、自动裁剪等功能,以及与旧版SpriteBatchNode的对比,旨在提高游戏性能。

1774

被折叠的 条评论
为什么被折叠?



