Unity Terrain Optimze
来源:互联网 发布:监控 linux 编辑:程序博客网 时间:2024/06/16 16:04
1、Important Fact
Resolution
DETAIL RESOLUTION
Now we’re getting to the grass. In the example, the parameter Detail Resolution is set to 64. This means that in any direction, there will be 64 “patches” of grass. We had 512 quads in any direction on the terrain, but we’ll have only 64 grass patches. That means that each grass path will cover 64 quads. How does this work? Unity will actually store a 64×64 pixel bitmap whose pixels values indicate the quantity of grass in each spot. This means:
Higher detail resolution = higher patch of grass vs. terrain quad density = more draw calls.
DETAIL RESOLUTION PER PATCH
Now there’s yet another parameter that we can set: Detail Resolution per Patch. In previous versions of Unity this was fixed at 8, but you can now increase the value. This parameter controls how blocks in the detail bitmap are grouped to be sent to the graphics card as a single draw call (or actually a couple). If this value were set to 1, then each pixel in the detail map would result in one or more draw calls. For our 64×64 map, this will mean at least 4096 draw calls (and probably double or triple that). The lowest value is 8, and that means (64/8)*(64/8) = (at least) 64 draw calls. So:
Lower detail resolution per path = more draw calls per patch
If you’re not too bothered with the exact placement of your grass, then you can increase the parameter’s value. On the other hand, if you must have fine control on where your plants live, say, on the banks of a river, then you’ll need a higher detail resolution and a lower detail resolution per patch.
According to what I understand, the terrain detail/grass data is represented in a 2D array. So each element of the array represents a small square on the terrain, a chunk of grass/detail. As we know, the bigger the array/resolution, better precision we have positioning the grass. However, it is not feasible to draw chunk by chunk: in a 1024x1024 resolution it would result at least in 1 Million drawcalls (if we draw the whole terrain). So, Unity batchs those chunks based on the "Detail Resolution Per Patch". If you have it set to 8, in a 512x512 detail res map, we would have (512x512) / (8x8) = 4096 batchs (and at least 4096 drawcalls). This way, in order to reduce drawcalls, you should increase "Detail Resolution Per Patch", for instance to 128 (the maximum). In a 512x512, it would be (512x512) / (128x128) = 16 batchs. Since it seems Unity needs a couple of draw calls to draw a single batch (someone correct me if I'm wrong) it would take 32 drawcalls to draw the whole grass in the scene.
The ideal number for "Detail Resolution Per Patch" depends on the density of your detail. You don't want to send a huge amount of triangles (very dense grass) to the GPU. But my guess is that you might be able to set it to 128 in most cases.
Detail Resolution Changer:
Ever had to change the detail resolution texture, and then realized all your work will be erased if you change it from the terrain menu? This script will transfer all detail info to your new resolution of choise. You need to save this in a folder called "Editor" (Script plsase see url below)
参考文档:
http://docs.unity3d.com/460/Documentation/Manual/terrain-OtherSettings.html
http://www.independent-software.com/removing-grass-from-a-terrain-in-unity/
http://answers.unity3d.com/questions/29663/detail-resolution-per-patch.html
http://forum.unity3d.com/threads/small-terrain-scripts.43085/
- Unity Terrain Optimze
- Unity Terrain
- unity地形Terrain浅谈
- unity terrain export to obj
- Unity 获取Terrain大小的方法
- Unity中动态修改Terrain地形
- Unity中动态修改Terrain地形
- Terrain
- terrain
- unity+vuforia(AR)(Smart Terrain/penguin)
- unity中地形Terrain明显闪烁的解决办法
- Vuforia和unity 官方案例Penguin Smart Terrain Sample
- 自学Unity之做一个MOBA游戏1——Terrain(地形)
- 蓝鸥Unity开发教程之课时3 Terrain地形系统
- Unity——地形切割方法(Terrain Slicing插件用法)
- LOD Terrain
- terrain rending
- Terrain类
- Apple Watch三个月开发的一些收获总结
- Linux core dump详解
- 格式化UTC时间为本地时间
- 3*3矩阵进行转置
- navigator浏览器识别
- Unity Terrain Optimze
- yii学习笔记—gii 自动代码生成工具
- 80x86指令系统和寻址方式
- Eclipse注释快捷键
- 查看Android应用包名、Activity的几个方法
- Linux /proc目录
- 数组名与指针,及数组退化
- R语言中的Rwordseg包详细使用教材
- Oracle 锁与session