Why (the vision)
The way currently Cocos2d does rendering is good but it is beginning to feel somehow antiquate and moreover it doesn’t actually leverage modern multi core CPUs so popular nowadays on most modern tablets and mobile phones.
So we want to re design Cocos renderer, for making it more performing, elegant, scalable, flexible but still simple to use and to understand. Also we want to maintain that same familiar API that current Cocos2d users will feel immediately comfortable with, without having to bother about what’s changed or new under the hood.
We will do this maintaining the same key cornerstone concepts Cocos2d users get to know and like as Scenes, Nodes, Layers, Sprites.
What (the goals)
Here is a high level view of the new features and improvements we would like to achieve in Cocos2d v.3.0:
Decouple the scene graph from the renderer
Visiting nodes issues graphics commands and put them on a queue, but doesn’t actually invoke any OpenGL rendering code
Viewing frustum Geometry culling
Sprites (and geometries more in general) not visible from the camera’s point of view be automatically removed from the current frame and not rendered
Rendering on a thread
The execution of all the rendering commands (i.e. OpenGL calls) will be moved to different thread than the main one (this will allow for better parallelism and usage of more than one CPUs cores where possible)
Automatic batching
Efficiently reduces the number of draw calls (automatically) batching them together when possible (i.e. sprites using the same material)
(Node based) Customizable rendering
As in the current version of Cocos, users will still be able (if needed) to customize rendering on a per node basis, calling OpenGL commands directly, disregarding the official renderer (but possibly incurring on worst performances)
How (the plan)
Central to the new design is the notion CommandQueue. While visiting a node, rendering will not call OpenGL commands directly anymore (as currently is the case); it will instead push CocosGraphicsCommands to a queue. Commands In the queue will subsequently be read by the rendering backend, processed as needed and pushed to the actual rendering API (i.e. OpenGL) (see picture)
The rendering backend (running on his own thread) will in turn pop graphics commands from the queue, process them and actually execute them. Any locking or CPU expensive OpenGL commands will be then executed from the back-end thread, letting Cocos’ main thread free continue working on parsing the scene graph or doing other non rendering related tasks. This will help parallelism and will allow for using multi core CPU’s (see picture)
With Cocos2d-x 3.00 we also want to introduce the concept of automatic batching. In fact we believe reducing the number of draw calls and render device state changes will improve drastically rendering speed.
In order to achieve very good batching, we would like to introduce also a new concept of “attributes” for Layers (formally CCLayer). There are going to (at least) 3 new Layer attributes:
-
Unordered
-
Static
-
Batch
Unordered Layer (formally CCLayer)
We want now focus on Unordered Layers, which are going to help achieving auto batching for improving rendering performance.
Rendering order in Cocos2d is dictated by the “order” nodes are arranged in the scene graph (see picture)
This is still going to be true still in V.3.0 unless the Layer is tagged as Unordered.
The Unordered attribute will instruct the Layer to disregard rendering order for all of his children (see picture)
The graphics commands will then be put in the CommandQueue and a special “unordered tag” will be place in the command queue as well for instructing the rendered to disregard the order and re arrange graphics commands so to render all the primitives using the same material in one draw call. Rendering all primitives (that use the same “material”) in one go will make rendering much faster, especially on mobile devices.
Static Layer
Layers tagged as static, will be treated as if all children will not going to be translated/rotated/zoomed (transformed) during the entire lifespan of the layer. This will allow Cocos performing expensive operations as matrices concatenation or computing culling information (i.e. quad-tree) only once (typically before the first rendering pass) improving drastically performance. Note that sprites in a static Layer can still be “animated” as far as they’re not transformed or scaled.
Batch Layer
A batch layers will behave very similarly to how a Batch Node (CCBatchNode) currently works in Cocos2d. All the children of a batch layer will HAVE to use the same “material” thus allowing the front end to combine all the draw calls for that layer in one single one. (Erroneously) Adding children that use a different material to a Batch Layer will trigger an Assert ().
Automatic Culling
To do
Rendering context (RenderBucket, RenderTarget, Camera, viewport)
To do
Rendering and materials system
To do
Customize rendering for nodes
To do
转载:https://docs.google.com/document/d/1nDX131S-k_XwKHkh7CjP4yC4pmywLk8Do3kMtyrRYwI/edit?pli=1
相关推荐
cocos2d-x 3.0 人物行走 . 包里有代码和 图片资源.
Harness the power of Cocos2D to create your own stunning and engaging games for iOS Overview Find practical solutions to many real-world game development problems Create games from start to finish by...
Cocos2d-x3.0正式版 练练看 源码。有注释。
这是我重新弄的cocos2d-x-3.0的类图.之前别人兄台弄的,有些不全面,有些地方错误.我这个可以说是最新的了.每个类添加了中文的详细注解,同时也添加了中文的类名称翻译.这样对cocos2d-x-3.0的框架比较好上手. 有兴趣的...
这是cocos2d-x 3.0 类关系图, 这个制作者是:gamecocos2dx 他做的Xmind,我导出的PNG格式,我推荐还是看Xmind,里面还有一些注释 gamecocos2dx Xmind下载地址:...
兄弟连cocos2d-x3.0 final视频教程 1.Cocos2d-x手机游戏开发C编程基础 2.Cocos2d-x手机游戏开发C++编程基础 3.Cocos2d-x3.0 final手机游戏开发核心技术 4.实例:贪吃蛇 5.实例:微信飞机大战
Cocos2d-x3.0final 自学教程的配套代码http://blog.csdn.net/column/details/cocos2dx2014.html
cocos2d-x 3.0 骨骼动画 demo 以及注意事项
官网中文docs文档的例子下载 创建工程的时候一定要创建一样的文件名 http://www.cocos2d-x.org/docs/tutorial/framework/native/how-to-drag-and-drop-sprites/zh
这是一个cocos2d-x 3.0中文开发文档.
Cocos2d-x3.0游戏实例《别救我》源码。 教程地址:http://blog.csdn.net/musicvs/article/details/24928929
自制的cocos2d-x 3.0alpha1项目创建包,适用于cocos2d-x 3.0alpha1版,用此资源包创建的cocos2d-x 3.0alpha1项目,可以拷贝至任意目录下
cocos2d-x 3.0 rapidjson 读取Json
使用cocos2d-x3.0来给Sprite添加遮罩
本游戏基于cocos2d-x 3.0版本,可能不适用于cocos2d-x 2.x版本,请看清楚,再参考! 使用方法:将Classes中的类全部拷贝到新建cocos项目的Classes项目中,将Resources下的所有文件拷贝到对应的文件下,运行即可!
http://blog.csdn.net/zoyzn/article/details/27251633一文的源码。cocos2d-x 3.0导出自定义类到lua,并导出自定义类的名称空间到lua。
Cocos2d-x 3.0 过渡学习 尊重原创,转载来自:star特530的CSDN博客 :http://blog.csdn.net/star530?viewmode=contents
Cocos2d-x 3.0 开发(九)使用Physicals代替Box2D和chipmunk的3.0 alpha1新版本 对应于Coco2d-x 3.0 alpha1 使用,更新之前3.0 alpha0 的 文件。相关博客地址:...
cocos2d-x 3.0 开发文档英文版(html)
cocos2d-x 3.0正式版 所有类 的结构 图 (思想导图)用 xmind 做的 本人 有的是mac 做的 win用户下载时 有乱码 是正常的 想用这个 必须下载 xmind 软件 (mac win 都有 )目前本人 在这两个平台 都能打开