在Unity中高效工作(下)
原地址:http://www.unity蛮牛.com/thread-20005-1-1.html
!Use Level of Detail
多细节层次
The level of detail feature inside of Unity is a great tool to use to that allows you take a very detailed asset and switch it out for a lower resolution mesh depending on how close the camera is. As the camera moves further away, it’s going to switch out the mesh with the lower resolution version. This is a great optimization technique to use that can save a lot of processing time, because it only renders out the detail when it’s actually necessary.
Unity的多细节层次是一个很好的工具,它允许你使用多层次的细节,并根据相机的远近程度切换到较低分辨率的级别。这是一个非常重要的优化技术,它仅仅在必要时,将细节进行渲染,因而可以节省大量的时间开销。
There’s no reason to display a high resolution of detail if the player isn’t close enough to actually tell the difference. Of course, this will mean you’ll need to model several versions of the same asset at different detail levels. You also need to keep in mind that this is a Unity Pro only feature. So if you’re using the free version, it won’t be available to you.
当玩家离物体较远,而不足以分辨出差别时,我们完全没有必要呈现出较高的分辨率。当然,这意味着你需要为同一份资源在细节层次上准备多个版本。【注意:LOD是专业版的功能,如果你使用的是免费版,就不用想了。】

Bake Lightmaps
烘焙光照贴图
As you start working with large levels requiring many different lights to create the look and feel you want, it can really start bogging down your game and have an impact on the framerate.
当你建造大型的场景,并且需要使用各种类型的灯光,用来营造理想的效果时,你会发现自己的游戏运行很慢,帧数也急剧下降。
To prevent your lights from impacting your game, you should be creating lightmaps. They allow you to bake all the lighting in your level directly to the actual textures. All of the lighting information stays there, but you don’t need the lights anymore. You can also add things like ambient occlusion to a lightmap to enhance the realism, but keep in mind this will increase the bake time.
为了避免光照效果影响你的游戏性能,你应该创建光照贴图。你可以将你场景中所有的灯光都烘焙到实际的纹理上。所有的照明信息都会留在上面,然后你就可以去掉这些灯光了。你还可以将环境光散射也烘焙进去,从而增加真实感,但要注意,这会增加烘焙时间。
Lightmaps may not be great for everything. Let’s say you want to give the player the ability to shoot out a light. This wouldn’t be achievable with a lightmap. So find places where you can implement lightmaps without hurting the gameplay.
光照贴图并不是万能的。例如,你想让玩家可以发射出一束光,光照贴图是无法办到的。你所要做的是,找到可以用光照贴图实现,又不会影响游戏性的场合。
Use Light Probes
使用灯光探测器
Anytime you create lightmaps for the lighting in your game, you’ll see it’ll look great for all the static objects in the level, but it doesn’t work for any type of dynamic asset in your game. This could be the character, enemies or anything moving. Dynamic objects will not be affected by the lightmaps. So while your level is nice and bright, the character will stay dark.
当你为游戏创建光照贴图时,你会发现它在静态的物体上效果还不错,但它不适用于任何类型的动态物体,例如角色、敌人以及所有会移动的物体。光照贴图无法作用于动态物体,所以你会发现即使你的场景看上去十分的明亮,但是角色却是黑色的。

Lightmapping can’t be calculated for moving objects in real time, but it’s possible to get a similar effect that you would get with dynamic lights by using light probes. By placing light probes in your level, it’ll sample all of the lighting at each probe point. The lighting can then be interpolated between the samples taken from the nearest point. This can be done in real time so it simulates the lighting that would occur in the scene if there were actual dynamic lights set up and not lightmaps.
光照贴图无法为移动中的物体进行实时计算,但是通过为动态光源使用灯光探测器,还是可以达到非常接近的效果。通过在场景中布置灯光探测器,可以为每个探测点的光照进行采样。然后任一点的光照就可以通过附近的点进行插值来得到。所以,在场景中没有光照贴图而存在动态光源的地方,就可以通过插值实时地模拟出光照。
When placing your light probes, you want to do it in areas with a high contrast in light. You’ll also want to put a probe between two bright areas, so you’ll get realistic results as your character moves through the level.
在放置灯光探测器时,你可以把它放置在和光亮有较大对比的一个区域内。同样可以考虑,把灯光探测器放置在两个明亮区域之间,这样当人物在场景中移动时,会产生明显的效果。

Next time you fire up Unity to work on your game project, find places where you can incorporate these tips to speed up your workflow and even cut back on processing time.
下一次,当你用Unity开发你的游戏项目时,好好回顾下我讲授的几点建议,这样能够加快你的工作和增强游戏性能。
译文:蛮牛译馆 - Dusthand & OVATION
转载注明出处!!!
在Unity中高效工作(下)的更多相关文章
- 在Unity中高效工作(上)
原地址:http://www.unity蛮牛.com/thread-19974-1-1.html 编的话:感谢做编程的IT朋友,帮我翻译文章,我又稍稍做了些修改.给点儿掌声哩.欢迎大家多多评论呦. 我 ...
- unity中鼠标按下加速漫游,鼠标抬起减速漫游。
private bool IsMouseUpOrDown=true; //一开始默认是鼠标抬起状态 if (Input.GetMouseButtonDown(1)) //鼠标按下的瞬间状态 { IsM ...
- Unite 2018 | 《崩坏3》:在Unity中实现高品质的卡通渲染(下)
http://forum.china.unity3d.com/thread-32273-1-1.html 今天我们继续分享米哈游技术总监贺甲在Unite Beijing 2018大会上的演讲<在 ...
- C#中的yield return与Unity中的Coroutine(协程)(下)
Unity中的Coroutine(协程) 估计熟悉Unity的人看过或者用过StartCoroutine() 假设我们在场景中有一个UGUI组件, Image: 将以下代码绑定到Image using ...
- 【《Effective C#》提炼总结】提高Unity中C#代码质量的21条准则
作者:Williammao, 腾讯移动客户端开发工程师 商业转载请联系腾讯WeTest获得授权,非商业转载请注明出处. 原文链接:http://wetest.qq.com/lab/view/290.h ...
- 【《Effective C#》提炼总结】提高Unity中C#代码质量的22条准则
引言 原则1尽可能地使用属性而不是可直接访问的数据成员 原则2偏向于使用运行时常量而不是编译时常量 原则3 推荐使用is 或as操作符而不是强制类型转换 原则4 推荐使用条件属性而不是if条件编译 原 ...
- 【转】Effective C#观后感之提高Unity中C#代码质量的21条准则
转自:http://blog.csdn.net/swj524152416/article/details/75418162 我们知道,在C++领域,作为进阶阅读材料,必看的书是<Effectiv ...
- Unity Shader入门精要学习笔记 - 第16章 Unity中的渲染优化技术
转自冯乐乐的 <Unity Shader 入门精要> 移动平台的特点 为了尽可能一处那些隐藏的表面,减少overdraw(即一个像素被绘制多次),PowerVR芯片(通常用于ios设备和某 ...
- Unity中使用WebView
Unity中使用WebView @(设计) 需求,最近游戏中需要引入H5直播页面和更新比较频繁的赛事页面,需求包括:加密传参数.和Unity交互,在Unity框架下其实有几种方案: 内置函数Appli ...
随机推荐
- iis7 php urlrewrite 并隐藏index.php
<rewrite> <rules> <rule name="OrgPage" stopProcessing="true"> ...
- 使用adb devices命令,老是报error:device offline的错误。
刚开始报error:devices not found 重新安装adb 驱动. 解决方法: adb kill-server adb start-server adb remount 再使用adb de ...
- MIME 部分扩展名与类型对应
svg image/svg+xml woff application/x-font-woff woff2 application/x-font-woff eot applicati ...
- sparkSQL1.1入门
http://blog.csdn.net/book_mmicky/article/details/39288715 2014年9月11日,Spark1.1.0忽然之间发布.笔者立即下载.编译.部署了S ...
- 【C#4.0图解教程】笔记(第1章~第8章)
第1章 C#和.NET框架 1..NET框架的组成 .NET框架由三部分组成(严格来说只有CLR和FCL(框架类库)两部分),如图 执行环境称为:CLR(公共语言运行库),它在运行期管理程序的执行. ...
- sqlserver 2012 重启是 ID 自动增长 1000的问题
1. Open "SQL Server Configuration Manager"2. Click "SQL Server Services" on the ...
- Android 百度地图开发之一(Hello BaiDu Map)
之前也接触过百度地图的开发,但那是在网上找的案例或代码,而且是比较老的版本.打算重新学习一下百度地图的开发. 本次使用的百度地图的版本是 Android SDK v3.0.0 本篇文章主要讲述百度地图 ...
- Sql 基于列的Case表达式
Case表达式可以用在 Select,update ,delete ,set,in,where ,order by,having子句之后, 只是case表达式不能控制sql程序的流程,只能作为基于列的 ...
- Hudson的安装配置
Hudson的安装配置 目录 一.正文... 2 1.安装配置jdk. 2 2.安装配置tomcat7. 2 3.安装Hudson. 2 4.启动tomcat. 2 5.初识Hudson. 3 6 ...
- C#基于AE组件二次开发常见问题
由于本人从事的是在.net平台下进行GIS的二次开发,所以第一篇博文就说一下:我最近在项目中出现的常见的问题,如果能够给大家增加一点点便利,也是我的荣幸,如果大家对于这次博文有什么意见和建议,欢迎大家 ...