https://blogs.unity3d.com/cn/2018/10/10/2018-3-terrain-update-getting-started/

总览:

This update features improved tools and performance by taking better advantage of the GPU. It also adds support for the HD and LW render pipelines

1.法线贴图的Keyword由_TERRAIN_NORMAL_MAP变为_NORMALMAP

官方注释说明:

Since 2018.3 we changed from _TERRAIN_NORMAL_MAP to _NORMALMAP to save 1 keyword.

会节省一个keyword

2.GPU-instanced

On the performance side, we added a GPU-instanced render path for terrain. In most cases, instancing yields a dramatic reduction in the number of draw calls issuedMany of our tests saw more than a 50% reduction in CPU costs (though, of course, actual numbers will depend on your platform and use case).  You can choose this new render path by enabling ‘Draw Instanced’ in the Terrain settings:

When enabled, Unity transforms all of the heavy terrain data, like height maps and splat maps, into textures on the GPU. Instead of constructing a custom mesh for each terrain patch on the CPU, we can use GPU instancing to replicate a single mesh and sample the height map texture to produce the correct geometry. This reduces the terrain CPU workload by orders of magnitude, as a few instanced draw calls replace potentially thousands of custom mesh draws.

As a nice side effect, it also improves our load times! Not only can we skip building all of those custom meshes, but we can also use the GPU to build the basemap (pre-blended LOD texture); the GPU is much faster at that kind of thing.  This also means that if you have your own custom terrain shader, you can now override the ‘build basemap’ shader and generate matching basemap LOD textures.

Unity之前的做法是 constructing a custom mesh for each terrain patch on the CPU,也就是说一个地形相当于有许多mesh,信息存储在CPU中,

改进之后Unity在顶点shader里使用高度图和法线贴图还原地形的顶点位置和法线,这样可以做到地形的一些mesh做instanced rendering(将高度图和法线贴图作为vertex buffer做instanced ),也不需要CPU传大量数据到GPU生成地形

可以节省大量CPU时间和加载时间,并减少draw call

void SplatmapVert(inout appdata_full v, out Input data){UNITY_INITIALIZE_OUTPUT(Input, data);#if defined(UNITY_INSTANCING_ENABLED) && !defined(SHADER_API_D3D11_9X)float2 patchVertex = v.vertex.xy;float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);float4 uvscale = instanceData.z * _TerrainHeightmapRecipSize;float4 uvoffset = instanceData.xyxy * uvscale;uvoffset.xy += 0.5f * _TerrainHeightmapRecipSize.xy;float2 sampleCoords = (patchVertex.xy * uvscale.xy + uvoffset.xy);float hm = UnpackHeightmap(tex2Dlod(_TerrainHeightmapTexture, float4(sampleCoords, 0, 0)));v.vertex.xz = (patchVertex.xy + instanceData.xy) * _TerrainHeightmapScale.xz * instanceData.z;  //(x + xBase) * hmScale.x * skipScale;v.vertex.y = hm * _TerrainHeightmapScale.y;v.vertex.w = 1.0f;v.texcoord.xy = (patchVertex.xy * uvscale.zw + uvoffset.zw);v.texcoord3 = v.texcoord2 = v.texcoord1 = v.texcoord;#ifdef TERRAIN_INSTANCED_PERPIXEL_NORMALv.normal = float3(0, 1, 0); // TODO: reconstruct the tangent space in the pixel shader. Seems to be hard with surface shader especially when other attributes are packed together with tSpace.data.tc.zw = sampleCoords;#elsefloat3 nor = tex2Dlod(_TerrainNormalmapTexture, float4(sampleCoords, 0, 0)).xyz;v.normal = 2.0f * nor - 1.0f;#endif#endifv.tangent.xyz = cross(v.normal, float3(0,0,1));v.tangent.w = -1;data.tc.xy = v.texcoord;#ifdef TERRAIN_BASE_PASS#ifdef UNITY_PASS_METAdata.tc.xy = v.texcoord * _MainTex_ST.xy + _MainTex_ST.zw;#endif#elsefloat4 pos = UnityObjectToClipPos(v.vertex);UNITY_TRANSFER_FOG(data, pos);#endif}3.支持法线贴图强度#ifdef _NORMALMAPmixedNormal  = UnpackNormalWithScale(tex2D(_Normal0, uvSplat0), _NormalScale0) * splat_control.r;mixedNormal += UnpackNormalWithScale(tex2D(_Normal1, uvSplat1), _NormalScale1) * splat_control.g;mixedNormal += UnpackNormalWithScale(tex2D(_Normal2, uvSplat2), _NormalScale2) * splat_control.b;mixedNormal += UnpackNormalWithScale(tex2D(_Normal3, uvSplat3), _NormalScale3) * splat_control.a;mixedNormal.z += 1e-5f; // to avoid nan after normalizing#endif

4.fragment逐像素法线

Instancing also improves the appearance of terrain normals; we decouple the terrain mesh normals from the geometry by storing them in a normal map texture that is generated from the heightmap and sampled in the pixel shader. This means the normals are independent of the mesh LOD level. Consequently, you can increase the ‘pixel error rate’ to decrease vertex cost, with fewer artifacts.

Old per-vertex normals (left) and new per-pixel normals (right) – with identical triangle counts.

宏定义为TERRAIN_INSTANCED_PERPIXEL_NORMAL

在上面第2个特性GPU-instanced开启的情况下

上面也说到会有一张顶点的高度与一张法线贴图,开启TERRAIN_INSTANCED_PERPIXEL_NORMAL将在fragment shader中读取这张法线贴图,不开启会在vertex shader中读取这张法线贴图作为顶点法线(顶点插值会降低原有贴图细节)

GPU-instanced的情况下还是默认顶点法线

这样有个好处就是LOD顶点数降低的情况下,默认顶点法线会随着顶点减少而降低细节,而在fragment shader读取这张法线贴图则完全不会会影响细节,顶点法线效果不受LOD级别影响,但是多了一次读取贴图会增加一点GPU性能消耗

VS见特性2的代码,FS中:

#if defined(UNITY_INSTANCING_ENABLED) && !defined(SHADER_API_D3D11_9X) && defined(TERRAIN_INSTANCED_PERPIXEL_NORMAL)float3 geomNormal = normalize(tex2D(_TerrainNormalmapTexture, IN.tc.zw).xyz * 2 - 1);#ifdef _NORMALMAPfloat3 geomTangent = normalize(cross(geomNormal, float3(0, 0, 1)));float3 geomBitangent = normalize(cross(geomTangent, geomNormal));mixedNormal = mixedNormal.x * geomTangent+ mixedNormal.y * geomBitangent+ mixedNormal.z * geomNormal;#elsemixedNormal = geomNormal;#endifmixedNormal = mixedNormal.xzy;#endif

5.可编程GPU工具

详情:https://blogs.unity3d.com/cn/2018/10/10/2018-3-terrain-update-getting-started/

6.多地形

多地形无缝绘制,自动连接等等。详情:https://blogs.unity3d.com/cn/2018/10/10/2018-3-terrain-update-getting-started/

7. TerrainLayer Asset

相当于地形用材质球,修改参数相对便捷,可以多地形共用相同TerrainLayer

a script interface to provide shader-dependent custom GUI for the TerrainLayer asset.

还可以像shaderGUI一样编写TerrainLayer的GUI

8.Brush Asset

可以自定义画刷,可以调节falloff和半径

支持16bit单通道贴图(R16),以前是8biit单通道贴图,可以增加精度(高度图,画刷等)

参考:

https://blogs.unity3d.com/cn/2018/10/10/2018-3-terrain-update-getting-started/

-----by wolf96  2018/12/20

Unity 2018 3.0地形优化与新增特性相关推荐

  1. 阿里云PyODPS 0.7.18发布,针对聚合函数进行优化同时新增对Python 3.7支持

    近日,阿里云发布PyODPS 0.7.18,主要是针对聚合函数进行优化同时新增对Python 3.7支持. PyODPS是MaxCompute的Python版本的SDK,SDK的意思非常广泛,辅助开发 ...

  2. Unity 2018.3地形功能更新介绍

    Unity 2018.3将更新地形系统,此次更新涉及改进的工具和利用GPU实现的更高性能.它还添加了HDRP高清晰渲染管线和LWRP轻量级渲染管线的支持,同时兼容内置渲染管线和现有Unity地形系统. ...

  3. Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优

    <Unity移动端游戏性能优化简谱>从Unity移动端游戏优化的一些基础讨论出发,例举和分析了近几年基于Unity开发的移动端游戏项目中最为常见的部分性能问题,并展示了如何使用UWA的性能 ...

  4. Unity Monetization 3.0 部分接入文档内容

    GameId 在 Operate Dashboard 左边的导航栏中Monetization --> Platforms 下,IOS和Android都有,是七位数数字. 一定记得,要 Monet ...

  5. 【《Unity 2018 Shaders and Effects Cookbook》翻译提炼】(九)Physically - Based Rendering

    制作过程中最重要的方面时效率,实时着色很昂贵,而Lambertian或BlinnPhong等技术是计算成本和现实之间的折中. 拥有更   强大的GPU允许我们逐步写更强大的光照模型和渲染引擎,目的是模 ...

  6. Unity移动端游戏性能优化简谱之 常见游戏内存控制

    <Unity移动端游戏性能优化简谱>从Unity移动端游戏优化的一些基础讨论出发,例举和分析了近几年基于Unity开发的移动端游戏项目中最为常见的部分性能问题,并展示了如何使用UWA的性能 ...

  7. 【Vuforia AR Unity 2018.3.12f1】MikuAR安卓程序开发实践(三)代码终结篇_2019.4.24

    Unity平台 + Vuforia SDK实现的AR程序开发 模型的三大操作(平移 旋转 缩放)代码 一.平移 二.旋转缩放 三.操作代码解析 模型的选定(射线法) 食用方法 自发光组件 食用方法 V ...

  8. 没弄懂的 Texture Mipmap Streaming (Unity 2018.2)

    首先,没弄懂 这个东西是否带来了性能上的提升? 它用少量CPU资源以节省潜在的大量GPU内存. Texture mipmap Streaming系统使您可以控制实际加载到内存中的mipmap级别. 通 ...

  9. iOS 版微信 7.0.4 发布:新增朋友圈「最近一个月」可见;中国5G专利占比34%,华为申请数量最多|嘟头条...

    「嘟爷头条」,是嘟嘟精心打造的一个快速了解业界新闻的的板块,抽取一周最新鲜最重要的业界资讯,让你花几分钟就可以时刻紧跟业界潮流. 快讯速知 iOS 版微信 7.0.4 发布:新增朋友圈「最近一个月」可 ...

最新文章

  1. python起步输入-第 4 节 小Python 起步
  2. 最新的ndkr20编译c_史上最优雅的NDK加载pass方案
  3. 办公室里绝对不可谈论的4大话题
  4. 编写原生的Node.js模块
  5. 机械齿轮网站404单页源码
  6. 关于glusterfs-3.0.4中AFR修复的一个bug
  7. NumPy——生成随机数的学习笔记~
  8. 深度探索C++对象模型读书笔记(2)
  9. django和celery结合应用
  10. 在dll中用DirectSound8同时播放多个wav文件不能发声
  11. 网站监控工具有哪些4款免费国内在线网站监控工具
  12. 《高等代数学》(姚慕生),复习题一,第1题
  13. 闲谈:渗透测试-红队版
  14. 把标清视频转高清Video Enhance AI for mac
  15. Linux挂载报错:Mount is denied because the NTFS volume is already exclusively opened. The volume may be a
  16. 计算机死机按什么恢复出厂设置,电脑怎么恢复出厂设置?win7恢复出厂设置教程...
  17. 什么是rip协议其优缺点_ospf和rip 优缺点
  18. 时序动作检测《BMN: Boundary-Matching Network for Temporal Action Proposal Generation》
  19. 被虎牙HR抬出公司员工发声
  20. 【PAT B1015】德才论 (c语言)//答案正确

热门文章

  1. 扫描ppt转换成pdf软件
  2. 苹果android什么意思,用惯了安卓机的人,换了iphone以后是什么感受?
  3. ChatGPT 通过谷歌算法面试,年薪 18.3 万美金
  4. Spring工作原理与单例ThreadLocal
  5. laydate在火狐,360极速模式下,多个时间插件,只有一个可以用问题
  6. 日本产品的低成本,德国产品的稳定性,美国产品的先进性,是我们赶超的基准。
  7. 雪糕数据告诉你,东北网红变身魔都名媛拢共分几步
  8. 【Gin⭐012】Go语言Gin框架-错误信息翻译成中文
  9. iOS微信7.0.12发布!除了适配暗黑模式,还有这些新功能!
  10. 抖音seo适合哪些人