Skip to content
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

动态合并材质相同的mesh #389

Open
kevinypcao opened this issue Jan 29, 2019 · 5 comments
Open

动态合并材质相同的mesh #389

kevinypcao opened this issue Jan 29, 2019 · 5 comments
Assignees

Comments

@kevinypcao
Copy link

材质相同的mesh在渲染时需要做动态合并,减少DrawCall。

@kevinypcao
Copy link
Author

具体做法可以参考Unity,Unity中有静态批处理与动态批处理,目前我们可以考虑先实现静态批处理。
Unity静态批处理与动态批处理介绍如下:
https://www.jianshu.com/p/46c9b6296f9c
我们可以考虑在CBaseObject中添加一个状态,设置了这个状态的对象在渲染之前推到一个特殊的队列,然后这个特殊队列中的对象在渲染时会根据其使用的材质球(也就是贴图)对pass进行分类,同一个分类下的pass使用一个DrawCall去绘制(可以考虑将pass数据复制到一个新的顶点缓存)。

Unity中使用静态批处理与不使用静态批处理DrawCall对比如下:
不使用静态批处理
qq 20190218163353
使用静态批处理
qq 20190218163412

@LiXizhi
Copy link
Owner

LiXizhi commented Feb 20, 2019

search CGlobals::GetScene()->IsInstancingEnabled(),
enable it, currently only supported in DirectX. But it will not increase FPS very much.

this is why I disabled it by default, but you can enable it from script. Only works with static mesh.

@kevinypcao
Copy link
Author

qq 20190221105104
我们这边使用的是ParaXEntity和BMaxObject,只是创建了对象和设置了位置,而且也并不能保证引擎在经过一系列处理之后需要批处理的对象在渲染队列中是相邻的。

@kevinypcao
Copy link
Author

再者,我们需要在移动端也能使用。

@LiXizhi
Copy link
Owner

LiXizhi commented Feb 26, 2019

BMaxObject add a property "SortByTexture". Add all triangle lists to a buffer and render together in a post rendering process.

  • support two buffers: one for transparent, one for opaque
  • precalculate all ParaXmodel by matrix to memory vector3d in tile coordinate.
  • post buffer can be just reference to the instance's vector array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants