如何降低Unity程序的Drawcall
【如何降低Unity程序的Drawcall】
Unity can combine a number of objects at runtime and draws them together with a single draw call. This operation is called “batching”
每帧能够有多少batch依赖于cpu。每个drawcall提交多少个三角形,对cpu压力变化不大,但是每帧有多少个drawcall则影响很明显。
Currently, only Mesh Renderers、Trail Renderers、Line Renderers、Particle Systems and Sprite Renderers are batched. This means that skinned Meshes, Cloth, and other types of rendering components are not batched.
Skinned Meshes 不能被合批。
一、Dynamic Batching。
Dynamic Batching会自动进行。有与顶点呈线性相关的overhead。所以只对顶点数小于900的mesh进行batch。
1)如果 Position, Normal and Single UV, then you can batch up to 300 verts
2)Position, Normal, UV0, UV1 and Tangent, then only 180 verts
动态Batching有以下要求:
1、Using different Material instances causes GameObjects not to batch together, even if they are essentially the same. The exception is shadow caster rendering.
使用同一个Material实例。
2、Lightmapped objects s hould point to exactly the same lightmap location to be batched。
想被batching的对象必须有相同的lightindex、及lightmapoffset/lightmapscale。
3、Objects that receive real-time shadows will not be batched。
勾选receive real-time shadow的对象不会被batch。
4、Batching dynamic objects has certain overhead per vertex,If your shader is using Vertex Position, Normal and single UV, then you can batch up to 300 verts; whereas if your shader is using Vertex Position, Normal, UV0, UV1 and Tangent, then only 180 verts.
5、 GameObjects are not batched if they contain mirroring on the transform (for example GameObject A with +1 scale and GameObject B with –1 scale cannot be batched together).
scale正负值相反的,没法动态合批。
6、Almost all Unity Shaders support several Lights in forward rendering, effectively doing additional passes for them. The draw calls for “additional per-pixel lights” are not batched.
前身渲染中的 additional pass不会被合批。
什么时候动态合批才有用?
Because it works by transforming all GameObject vertices into world space on the CPU, it is only an advantage if that work is smaller than doing a draw call. The resource requirements of a draw call depends on many factors, primarily the graphics API used. For example, on consoles or modern APIs like Apple Metal, the draw call overhead is generally much lower, and often dynamic batching cannot be an advantage at all.
合批要把 vertex 转换到 world space。所以只有在 draw-call 时间大于 vertex transformation 时间时,合批才有效。在Apple的Metal上,draw-call 的开销已经非常小了,所以动态合批没有什么价值。
二、Static Batching。
Using static batching will require additional memory for storing the combined geometry. If several objects shared the same geometry before static batching, then a copy of geometry will be created for each object. Sometimes you will have to sacrifice rendering performance by avoiding static batching for some objects to keep a smaller memory footprint.
使用StaticBatching会产生额外内存使用,因为Unity会把多个对象Join成一个对象。
StaticBatchingUtility.Combine()告诉UnityEngine把staticRoot作为static对象来处理。
once combined children can NOT change their Transform
properties, however staticBatchRoot
can be moved.
三、其它降低Drawcall的方法
1、改变表现方法。如流水粒子改为流水动画。
2、高级特性Shader降级为统一的低级特性的Shader。
参考:
2、http://docs.unity3d.com/Manual/DrawCallBatching.html
如何降低Unity程序的Drawcall的更多相关文章
- 关于Unity程序在IOS和Android上显示内嵌网页的方式
近期因为有须要在Unity程序执行在ios或android手机上显示内嵌网页.所以遍从网上搜集了一下相关的资料.整理例如以下: UnityWebCore 从搜索中先看到了这个.下载下来了以后发现这个的 ...
- 【拥抱元宇宙】创建你的第一个Unity程序HelloWorld,并发布
第一个Unity程序--Hello World. 1.需要先下载一个Unity Hub,以及安装Unity编辑器.Unity Hub需要登陆,激活码可以选择个人用户,免费的.免费的无法改变启动画面,其 ...
- Unity性能优化-DrawCall
1. DrawCall是啥?其实就是对底层图形程序(比如:OpenGL ES)接口的调用,以在屏幕上画出东西.所以,是谁去调用这些接口呢?CPU.比如有上千个物体,每一个的渲染都需要去调用一次底层接口 ...
- 面向Unity程序员的Android快速上手教程
作者:Poan,腾讯移动客户端开发 工程师 商业转载请联系腾讯WeTest获得授权,非商业转载请注明出处. WeTest 导读 随着Unity.cocos2dx等优秀跨平台游戏引擎的出现,开发者可以把 ...
- Unity程序们经常用到的网址(方便自己用,一直更新)
浏览器收藏夹不好用,那就整理到这里吧 官方 API查询: https://docs.unity3d.com/ScriptReference/index.html 文档查询:https://docs.u ...
- Unity程序协同问题,传送时屏幕变黑变亮的解决,常规操作的行为集合
在unity中运行某段程序时往往需要运行另外一段不相干但是却对功能上有需求的程序,比如进行场景传送,在传送点处,点击I键,屏幕慢慢变黑,场景传送到另外一个场景,场景又慢慢变亮.这里首先涉及两个物体,一 ...
- unity panel删除drawcall失败导致的残留影像
ngui panel 被隐藏或者删除的时候调用ondisable,清空drawcall,如果这个操作是在ontriggerenter等物理操作中就会删除不掉导致留下残影 解决方式 : 讲这些操转移到协 ...
- 向.Net/Unity 程序员推荐一个十分因吹斯听的网站:sharplab.io
0x00 前言 & 过程 & 结论 今天发现了一个十分有趣的网站: https://sharplab.io/ 网站的页面并不复杂,功能大体上能够在题图中得到概括.发现它的过程也很偶然, ...
- NGUI 降低drawcall
前置说明一: Unity中的drawcall定义: 每次引擎准备数据并通知GPU的过程称为一次Draw Call. Unity(或者说基本全部图形引擎)生成一帧画面的处理过程大致能够这样简化描写叙述: ...
随机推荐
- 服务器上通过FTP共享文件夹
近日,公司某服务器共同操作的人员增多,而我只需访问及替换某些文件,故想到共享文件夹. 在IIS中建立ftp站点,添加虚拟目录(可多个,对应不同文件夹),设置允许访问的用户(添加用户,见在IIS上搭建F ...
- {Notes}{Latex}{multirow}
这个文章写的真的太牛比了! ============================================================ 在latex文件最前面用这个包\usepackag ...
- hessian+spring集成应用
注意事项 ▲JAVA服务器端必须具备以下几点:---->包含Hessian的jar包---->设计一个接口,用来给客户端调用---->实现该接口的功能---->配置web.xm ...
- 异常处理—Exception(三)
最近有点事,把这个系列给落下了,给大家道个歉,这里还要感谢我的老婆,谢谢她一直对我的支持:) 系列回顾: 1.异常处理--Exception(一) 2.异常处理—Exception(二) 上一篇中主要 ...
- jQuery的deferred对象详解(转载)
jQuery的开发速度很快,几乎每半年一个大版本,每两个月一个小版本.(由于无法转载,复制原文 .原文链接——原作者:阮一峰) 每个版本都会引入一些新功能.今天我想介绍的,就是从jQuery 1.5. ...
- Errors running builder 'DeploymentBuilder' on project ' 解决方法
此问题一般发生在Myeclipse 保存文件并自动部署时候. Errors occurred during the build. Errors running builder 'DeploymentB ...
- Apache Kafka 0.9消费者客户端
当Kafka最初创建时,它与Scala生产者和消费者客户端一起运送.随着时间的推移,我们开始意识到这些API的许多限制.例如,我们有一个“高级”消费者API,它支持消费者组并处理故障转移,但不支持许多 ...
- java的时间
先看例子: import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; imp ...
- snmp安装zabbix
zabbix能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题. zabbix由2部分构成,zabbix server与可选组件zabbix ...
- php-PSR
<?php/** * 符合psr-1,2的编程实例 */ namespace Standard; // 顶部命名空间// 空一行use Test\TestClass;//use引入类 /** * ...