如何降低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(或者说基本全部图形引擎)生成一帧画面的处理过程大致能够这样简化描写叙述: ...
随机推荐
- mongodb 的一些启动命令
启动命令 nohup /home/sh/local/mongodb-linux-x86_64-rhel62-3.4.0/bin/mongod -dbpath /home/sh/local/mongod ...
- STM32学习笔记之__attribute__ ((at())绝对定位分析
STM32也会遇到这样的绝对定位的问题如下: uint8_t UART_RX_BUF[1024] __attribute__ ((at(0X20001000))); //就是将串口接收的数 ...
- jq 全选
$(".checkall").change(function(){ if($(this).is(":checked")){ $(".checkchil ...
- postman 设置代理
点击右上角 图标(亮着的为录制中) 设置端口 和存放位置 把浏览器设置代理 localhost 8080 即可 filter中可以通过正则表达式来匹配自己关心的url 2018.9 后记: 今 ...
- H3C IRF2的三种配置情况
H3C-IRF2-虚拟交换技术-强列鼻视看我文档不下载的呵呵.看了下面的东西你就会配IRF了. H3C-5120-HI H3C-5120S H3C5800 先到H3C官网上面看那些交换机支持IR ...
- 【学步者日记】C#使用线程
http://note.youdao.com/noteshare?id=2810300cdfa3f4d973792dcf30a31db9 System.Threading.Thread th; th ...
- Velocity基本常用语法
Velocity是一个基于java的模板引擎(template engine),它允许任何人仅仅简单的使用模板语言(template language)来引用由java代码定义的对象.作为一个比较完善 ...
- Angular2 如何使用jquery
网上找了很多版本尝试都不行,最后在stackoverflow上找到一个,尝试完美解决 具体操作步骤如下 1. 安装jquery npm install jquery 2.安装 type for jqu ...
- [linux] ping服务器脚本
#!/bin/bash IP=1.2.3.4 while true; do echo "**********************************************" ...
- oracke创建db link
-- Create database link create public database link test_link connect to 用户名 identified by 密码 using ...