首页 unity优化

unity优化

举报
开通vip

unity优化unity优化 Unity3d游景化戏戏戏戏戏戏戏 Lod技戏 (Levels of Detail,多次戏戏戏戏), 戏戏剔除(Culling),光照,戏戏戏Lightmap)当然有大而戏戏戏强又脆弱的Unity3d引擎. 所有料都来自互网和戏戏戏戏戏戏戏戏戏Unity自戏的文档。有些文档我自己余翻了下,的戏戏戏戏戏戏戏戏戏戏戏戏地方朋友指正。戏戏戏戏戏戏戏 戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏灯光相比静灯光,非常耗源。所 以除了能的角色和物体,比如可以被戏戏戏戏戏戏戏戏戏戏戏戏戏 打的到乱的油桶,静的地形和建筑,通...

unity优化
unity优化 Unity3d游景化戏戏戏戏戏戏戏 Lod技戏 (Levels of Detail,多次戏戏戏戏), 戏戏剔除(Culling),光照,戏戏戏Lightmap)当然有大而戏戏戏强又脆弱的Unity3d引擎. 所有料都来自互网和戏戏戏戏戏戏戏戏戏Unity自戏的文档。有些文档我自己余翻了下,的戏戏戏戏戏戏戏戏戏戏戏戏地方朋友指正。戏戏戏戏戏戏戏 戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏灯光相比静灯光,非常耗源。所 以除了能的角色和物体,比如可以被戏戏戏戏戏戏戏戏戏戏戏戏戏 打的到乱的油桶,静的地形和建筑,通通使用戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏Lightmap。 强大的Unity内置了一个大的光照烘焙工具强戏戏戏戏戏Beast,戏个是戏戏戏Autodesk公司的品,可怕的断,感和戏戏戏戏戏戏戏戏戏戏戏戏3d沾戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏的件丫都要插一手,。据用来制 作戮地和之。戏戏戏戏戏戏戏戏戏戏戏 《之》建筑景漂亮干的光影,戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏Lightmap的效果。在Unity中制作Lightmap很方便,几个参数后戏戏戏戏戏戏戏直接烘焙即可。支持GI,Skylight, 效果一流:::当然你需要一台好点的机器,不然漫的戏戏烘焙程你就有的等了。戏戏戏戏戏戏戏戏戏 内置的光照烘焙工具戏戏戏戏戏Beast P戏戏戏戏戏戏戏戏景准和光照烘焙 点戏 Window --> Lightmapping 打光照烘焙面板戏戏戏戏戏戏戏戏:1. 确所有将要被用来烘焙光照的戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏 网格体 UVs正确无. 戏最的法是在戏戏戏戏戏戏戏mesh import settings 中戏戏 Generate Lightmap UVs戏戏,由Beast自分戏戏uv,2.在Object面板中将所有网格体或地形注戏戏戏 static – 戏将告戏 Unity, 戏戏戏戏戏戏戏戏戏些物体将不会被移和改并且可以 被予光照。戏戏戏戏戏戏戏 3.戏戏戏戏戏戏了控制光照的精度, 戏 入Bake 面板并整 戏戏Resolution 的戏. (戏 了更好的了解你的lightmap texels使用情况, 在Scene 戏 窗中找到Lightmap Display 小窗口并且 戏戏Show Resolution). 1. 点戏 Bake 按。戏戏 2. Unity Editor's 会出一个度条戏戏戏戏戏戏,位置于右下角戏戏戏戏戏.3. 当烘焙束戏戏, Lightmap Editor窗口会示已烘焙戏戏戏戏戏戏好的光照.戏 Scene 和 game 戏戏戏戏 – 戏戏戏戏戏戏会同自更新在你的景已有 了光照的效果戏戏戏戏! Unity Lightmap的置有更和更高端的内戏戏戏戏戏戏戏戏戏戏戏戏戏容,参考自的文档,那才是王道啊:::::戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏 LOD(Level-of-detail)是最常用的游化技。如果戏戏戏戏戏戏戏戏你的程序可以定制用戏戏戏戏LOD的模,当然戏戏戏戏是很美好的事情。不如果没有也没系,大家可以使用戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏UniLOD戏个第三方的LOD插件。免共享的哦,向戏戏戏戏戏戏戏UniLOD戏戏者致敬,戏戏戏戏戏戏戏戏戏戏戏戏美大的共享精神:::,以下是介:戏戏戏 功能众多,及到景管理,模型化,源涉戏戏戏戏戏戏戏戏戏戏戏戏管理,及示效果化,且不需要脚戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏 本写,全部通器:目前此戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏unity3d戏戏戏戏展源的,你可以下到源代来研究学。戏戏戏戏戏戏戏戏戏戏戏 特色: •1.自化网格体戏戏戏戏戏戏(Windows + Unity Pro only) 根据用的定自减面。戏戏戏戏戏戏戏戏戏 •2.Level-of-detail 戏戏器 方便快捷的建戏戏LOD戏戏戏戏戏戏件来切不同的品戏戏戏戏戏戏戏戏戏戏戏戏戏或通定距离数来示 或藏物体。戏戏戏戏戏 戏 建你的LOD 戏景 方便快捷的用 LOD 戏戏戏戏戏戏戏戏件来替有件将 有的景有戏戏戏戏戏戏戏LOD管理的景。戏戏戏 将个的戏戏戏mesh和成来降低戏戏戏戏戏戏戏draw calls 将景存戏戏戏 戏戏 准assets 或者 asset 包 •3.戏景管理 Streaming 支持 Stream your scene as the player moves through the world 戏戏 源自loaded/unloaded Stream from resource folder, or asset bundles Minimal performance impact with resource buffering 可以根据需要整戏戏, 速度或者内存 Takes care of switching quality levels as the player moves though the world 充分化戏戏, 使用最少的源戏戏 •4.戏源管理 所有asset bundles 和普通源都以准戏戏戏戏戏戏方式入。戏戏戏 Keeps reference counts on your resources and 自戏戏放 •5.完整植入 Unity 并只需要通戏UnityEditor API来操作。 无需入代戏戏戏戏 Sorry,戏戏戏戏戏戏戏戏戏戏戏戏景管理和源管理的有些内容没搞 懂就不乱翻了。戏戏戏 戏接: 戏展beta版本戏戏布unilod-beta- levelofdetail-and-streaming-support 当然,Unity3d自己的地形是自戏LOD功能的,当你刷好你的地形后,你只需要整戏戏Pixel Error戏个 参数即可。Unity3d会自戏戏戏戏戏戏戏戏算生成地形的LOD,无需你做其他的任何戏戏戏置。 要提醒朋友的是,如果你使用了戏戏戏戏戏戏戏戏戏戏Lightmap,那同使用戏戏戏戏戏LOD的戏戏戏戏戏戏戏戏戏戏戏戏戏戏候会有一些麻,我的法 是制作模型的戏戏戏戏戏戏戏戏戏候事先做好第二套uv(不使用Unity的自戏戏算lightmapUV功能,,而且所有LOD的第二套UV的分布位置都一致,很工。不戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏知道有没有更好的方法::: 首先介下戏戏draw call,个戏戏戏戏戏戏戏戏戏戏戏西越少你的游跑的越快,: 在游中一个被展示的戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏独立的部分都被放在了一个特的每包中,我戏戏“戏”戏描称之指令,draw call,,然后个包戏戏戏戏戏到3D部分在屏幕上呈戏戏戏戏戏戏戏戏戏出来。就和你希望你的友戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏收到准好的圣礼物需要包 装好然后穿城市戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏准放在他出的地方 一没戏戏戏戏戏戏戏戏戏什不同。你的CPU来完成包装和戏戏戏戏戏戏他的活,同会戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏消耗很多的,所以最分配好些 性戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏源很重要。目前,真正可怕的事情是从描指令消耗景戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏一个每始独立,的到地板上 的血迹和一个角色或者一具死尸消耗的字戏戏戏戏戏是一的多的:他戏戏戏戏戏戏戏戏戏戏戏戏戏戏都消耗同的描指令。除此 之外,没有什戏戏戏戏戏戏戏更多的差。 那如戏戏戏戏戏 何降低draw call 呢,,那我就用到戏戏戏戏戏戏Culling(剔除,技。如果不用个技,是不管戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏3721把戏戏戏戏戏戏戏戏戏戏戏戏戏戏景里所有的西都送去渲染的。 看得戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏的也渲染,看不得照也送去 渲染。很是戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏吧,那咋呢。得告,那个你 看得戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏的渲染,看不的就算了。于是就有了 1.戏戏体剔除,Frustum Culling,个戏戏unity系自了好戏戏戏戏戏像,就不用操心了。 2.遮戏戏戏戏剔除,Occlusion Culling, Unity 3戏戏 版内置了一个大的强Occlusion Culling 插件 Umbra免的戏戏 遮戏戏戏戏剔除,Occlusion Culling, 遮戏戏戏戏 剔除是一当一个物体被什的特性呢,其他物体遮戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏住而不在像机的可范内不其行渲染。. 遮戏剔除在3D戏戏戏戏戏戏戏戏戏戏戏戏戏戏形算中并不是自行的。因 戏戏戏戏戏戏戏戏戏 在大多数情况下离camera 最的物体戏戏戏戏首先被渲染,靠近像戏戏戏戏戏戏戏戏戏戏机的物体后渲染并 覆盖先前渲染的物体(戏戏戏戏戏戏被称重渲染,无效渲 染"overdraw"). 遮戏戏戏戏戏戏戏戏戏戏戏剔除不同于体剔除. 戏戏体剔除只是不渲染像戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏机角范外的物体而于被 其他物体遮但依戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏然在角范内的物体不包括在内. 注意当你使用遮戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏剔除你依然受益于体剔除,Frustum Culling,. 左戏戏戏戏戏戏戏戏戏戏戏的景使用了遮剔除. 右的景戏戏戏戏戏戏戏戏戏戏戏未使用遮剔除.遮戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏剔除的运行将通在景中使用一 个虚戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏的像机来建一个物体潜在可性状,set,的戏戏. 戏戏戏戏戏戏戏戏戏戏戏些数据可以个每运行内的像机来确 定什戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏能看什看不。通些数据, Unity 将确定只把可以看戏戏戏戏戏戏戏戏的物体送去渲染. 戏 将降低draw calls 的数量并提供游的戏戏戏戏戏戏运行效率. occlusion culling的数据由戏戏戏元,cells,成戏戏. 每个戏戏戏元是整个景戏戏戏戏戏戏戏戏戏戏范数的一部分. 更多特定的戏戏戏戏戏元来自一个二叉戏戏 ,binary tree,. Occlusion Culling使用两个叉, 一个戏 View Cells (静物体戏戏戏) 另一个戏 Target Cells (移物体戏戏戏). View Cells map戏戏戏戏戏戏戏戏戏戏戏戏戏戏出了一个定了静可物体的索引列表 ,精确剔除后的静物体,戏戏戏戏. 非常重要的一点是在建你的物体要戏戏戏戏戏戏戏戏戏戏戏随注 意,因戏戏戏戏戏戏戏戏戏戏戏戏戏戏你需要在物体的尺寸和元的 尺寸取得戏戏戏戏戏戏戏戏戏一个好的平衡. 理想情况下, you shouldn't have cells that are too small in comparison with your objects but equally you shouldn't have objects that cover many cells.有戏你可以通将大的物体戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏拆成几个部分来改遮剔除效果. 无如戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏何你仍然能将小的物体合并一体来降低draw calls, 在它戏戏戏戏戏戏戏戏戏戏戏戏戏都属于一些小的件的候, occlusion culling 将不起作用.确定件中那个是可的件的戏戏戏戏戏戏戏戏戏戏戏戏戏 集和可戏戏戏戏戏戏戏 信息被是PVS (潜在可戏戏戏状Potentially Visible Set). Occlusion Culling戏置 戏戏 戏戏戏戏戏戏戏戏戏了使用遮需要剔除行相的手置.首先 戏戏你卡中的几何体必戏戏戏戏戏戏戏戏戏戏戏戏戏戏被分割成明的不同尺寸的. 戏也有助于布置戏戏戏 戏戏戏戏戏被卡中小的容其他易定的区域大物体遮,例如,建筑物, 戏戏戏戏戏意味着每个独的mesh被确定是否渲染取决于 occlusion 数据. 所以如果你有一个物体包含了房里戏戏的所有家具那所有的家具要全戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏渲染,要全不渲染. 是否渲染是基于件而不是戏戏戏戏戏戏戏戏戏戏个独物体自基于身的。每在面板,戏戏戏戏戏Inspector,你需要, 戏戏戏tag,所有需要 戏用遮戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏剔除的景物体。最快的方法是 是将你需要示戏戏戏 Static的物体作一个戏戏戏 Empty GameObject 的子物体并置个戏戏戏戏Empty GameObject 戏Static,当option出的戏戏戏戏戏戏候affect children. 当子物体被tagged as Static你可以取消子物体和Empty GameObject的父子戏系. 戏戏 面板中的Static checkbox 下一点步戏Tools->Occlusion Culling. 打戏 Occlusion Culling 戏戏面板,在面板中你会几个数被整了。戏戏戏戏戏戏戏戏戏戏戏戏戏些数前面戏戏戏戏戏戏描述:- Occlusion Culling - Object 遮戏戏戏戏戏戏戏戏 剔除面板的object戏戏. Object戏戏戏戏戏戏 可以你建Occlusion Areas GameObjects. 戏些区域戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏你指定什地方你会使用遮剔除. 注意: 默戏戏戏戏戏戏戏情况下如果你 戏戏戏戏戏戏建任何遮剔除区域, 整个景都会戏戏戏戏戏戏戏戏戏戏行遮剔除.Properties Quick Select 快速和建一个戏戏戏戏戏戏戏 Occlusion Area并且快速戏戏戏它. None 戏戏戏个是默. Create New 戏建一个新的Occlusion Area GameObject. 当你点戏 Create New in the Quick Select drop down, Unity将自戏戏 建一个Occlusion Area 并且除戏戏戏戏戏戏默区域(整个景戏戏). 戏在你可以根据需要戏戏戏戏始整Occlusion Area(s).Occlusion Area 戏戏面板. Properties Size 定戏 Occlusion Area的尺寸. Center 戏戏 Occlusion Area的中心. B默戏戏0,0,0 并在box的中心位置. Is View Volume 定戏戏戏戏戏戏戏戏戏戏戏像机的活范区域. 点个戏戏戏戏戏才能用戏戏戏戏戏戏戏遮剔除在Occlusion Area内的静物体戏戏戏.Is Target Volume 如果你要遮戏戏戏戏戏戏戏戏戏戏戏戏戏戏剔除运物体,打个.Target Resolution 确定区域内的 Occlusion Culling精度. 即一个 Occlusion Area的戏戏戏戏元尺寸. 注意: 戏戏戏戏戏 个只Target Areas,移物体,戏戏戏戏戏戏戏起作用. Low 减少戏戏戏戏戏戏戏戏戏戏戏算但同精度降低. Medium 戏戏戏戏戏戏戏戏戏戏戏戏戏算和精度中等,比平均. High 戏戏戏戏戏戏戏戏算但精度高. Very High 精度很高,戏戏戏戏戏戏算更. Extremely High 最高精度.注意: 戏戏戏戏戏戏戏戏算令人指。如果戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏像机于遮区域之外或者任何物体超出区域, 戏些物体将不会被遮戏戏戏剔除. Occlusion Culling – BakeOcclusion culling 戏戏 面板bake tab. Properties View Cell Size 每个 view area戏元的尺寸, 尺寸越小遮戏戏剔除越精确. 戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏个数用来平衡遮剔除的精度和存容量Near Clip Plane Near clip plane 如果置最小数戏戏 戏戏戏那游 中所有戏戏戏戏戏戏戏像机都可看到. Far Clip Plane Far Clip Plane 用于戏戏 objects. 任何物体的距离大于个定数都会被自戏戏戏戏戏戏戏戏戏戏戏戏戏遮.(Should be set to the largest far clip planed that will be used in the game of all the cameras) Quality 品戏戏戏 Preview 戏戏戏戏戏 段使用个(ie,不是很准确但可以你戏戏戏御戏戏戏戏戏戏戏戏在游中的大致表) Production 如果戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏基本束准布那就个 (会耗更多的戏戏戏戏戏戏戏戏戏戏但更精确) 当你整完些数后可以点戏戏戏戏戏戏戏戏戏戏戏戏 Bake按戏戏戏戏始理Occlusion Culling 数据. 如果你果不戏戏戏戏戏戏戏太意,你可以点戏Clear 按除以前的戏戏戏戏戏戏戏戏戏戏算数据. Occlusion Culling - Visualization Occlusion culling 戏戏面板visualization 可戏 戏戏Properties Quick Select 戏戏戏戏戏戏戏戏戏戏戏戏你快速景中的任何像机 来戏戏戏戏戏戏戏戏戏看遮剔除的效果 The near and far planes 定了一个戏戏戏戏戏戏戏戏戏戏戏虚像机来 算遮戏戏戏戏戏剔除数据. 如果你有几个戏戏戏 像机near 或 far planes不同, 你置戏戏戏戏near plane 和largest far plane distance适配所有戏戏戏戏戏戏戏戏戏戏戏戏戏像机来整物体的包括范. 所有景戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏里的物体只在数范内起作 用所有确定你的所有物体都于可戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏范. 当你准好戏戏戏戏 生成occlusion data, 点戏 Bake 按戏. 戏住在 Bake戏戏的Quality selection box 中事先戏戏 Preview 和 Production. Preview可以快速生成数据并可以快速果戏戏戏戏. Production 用于品戏戏戏戏戏戏戏戏戏戏戏布前的生成和. 戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏住遮剔除的数据算生成速度取决于事先置的cell levels,戏戏戏戏戏元,, 数据尺寸大小和精度. Unity会在窗口底部示戏戏 PVS 运算状.戏 运算戏戏戏戏戏理束后, 你会在View Area看到一些不同色的戏戏戏cube. 戏戏戏戏戏戏色相同的区域共享遮剔除数据. 点戏Clear 如果你想戏戏戏戏戏戏戏戏戏戏戏戏除所有遮剔除的事先 算好的数据,戏戏戏戏戏戏算数据,. Moving Objects 如果想戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏用遮剔除到一个运物体你必建一个Occlusion Area然后定戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏其尺寸来适配运物体的活空(注意:运戏戏戏戏戏戏戏戏戏物体不能被示static). 戏 建Occlusion Area后, 戏戏Is Target Volume checkbox 来遮戏剔除运戏戏戏物体. 移物体的戏戏戏戏Occlusion Area properties Size 戏 定Occlusion Area 尺寸. Center 戏 定Occlusion Area的中心. 默戏0,0,0 并位于box的中心. Is View Volume 定戏戏戏戏戏戏戏戏像机能到哪里. 戏戏戏戏戏戏戏个数来遮剔除Occlusion Area中的static objects .Is Target Volume 遮戏戏戏戏戏戏戏戏戏戏剔除运物体必 Target Resolution 确定区域内的遮戏戏戏戏戏戏戏戏戏戏剔除精度。将决定Occlusion Area的戏戏戏戏元尺寸. 注意: 只戏 Target Areas起作用.Low 减少戏戏戏戏戏戏戏戏戏戏戏算但同精度降低. Medium 戏戏戏戏戏戏戏戏戏戏戏戏戏算和精度中等,比平均. High 戏戏戏戏戏戏戏戏算但精度高. Very High 精度很高,戏戏戏戏戏戏算更. Extremely High 最高精度.注意: 戏戏戏戏戏戏戏戏算令人指。添加完Occlusion Area后, 你需要了解它是如何划分戏戏元中的box. 如果想了解occlusion area如何算运戏戏戏戏戏戏物体,你必戏在Scene View中点戏 Target按并且戏 戏戏 View 按同戏戏戏Occlusion Culling 戏戏戏戏面板是打的. Selecting Target (moving objects) or View (static objects) 戏你御戏 calculated data 的运作. Testing the generated occlusionocclusion 戏戏戏置完后, 打戏Cull Geometry option (in the Occlusion Culling window) 并在景窗移戏戏戏戏戏戏 Main Camera. iScene View 中的Occlusion View mode当你在周戏戏戏移Main Camera (无是戏戏戏戏 否在Play mode下), 你将会看到不同的物体disable. 你在戏戏戏戏戏戏戏戏里需要找出的是occlusion data中的任何戏戏. 当你移戏戏戏戏戏戏戏戏像机你可能 会会有物体戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏突然出在野当中. 如果情况戏戏戏戏戏戏生, your options for fixing the error are either to change the resolution (if you are playing with target volumes), or to move objects around to cover up the error. To debug problems with occlusion, you can move the Main Camera to the problematic position for spot-checking.运算戏戏戏戏戏理束后, 你会在View Area看到一些不同色的戏戏戏cube. 戏 色cubes表戏戏戏的是Target Volumes的戏戏戏戏元划分. 白色 cubes表戏戏戏 的是View Volumes的戏戏戏戏元划分.如果参数置戏戏正确你会看到一些物体不被渲染. 戏戏戏戏戏戏表示要些物体 不在戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏像机角范内要被其他物体遮住了.如果occlusion完成后, 戏戏景内任何物体也没有被遮, 拆分物体至更小的pieces 以便它戏戏戏戏戏戏戏戏戏戏戏戏戏戏能被完整地包含在一个元中. 要提醒朋友的是,如果景,品置戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏 高的,烘焙程将漫的戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏戏令人指。赶 戏戏戏戏戏戏戏戏升吧::: 戏戏戏戏戏戏戏戏戏戏于没有版并无法使用umbra插件的朋友也不必担心,有戏戏戏戏戏戏另外一个Culling剔除插件可以,是完全免共戏戏戏戏戏戏戏戏戏享的。具体名字忘戏 戏戏了,不去unity网站的戏戏戏戏戏戏版搜一下Culling戏戏戏戏戏戏戏戏戏 可以很容易找。就到里.就到戏戏里,哈哈。 Unity 3D 角色模型优化要点 作者,cuirongfeng 2011-09-06 20:05 优优,548 在和朋友制作游优的优程中~优常有人优到角色模型优优优建才更符合怎Unity的需要。在此~我将Unity官方站中优于建模要求的部分优如下~供考。网翻参 限于本人英文水平有限~而且有一字一句地优~而是基于自己优引擎的理解~采用更并没翻 符合中文的优序优。故采取在原文段落下方附加中文优的做法~以便大家优照。有些来翻翻内 容若朋友优优得优得不妥~优迎优我留言。翻 Modeling Optimized Characters 角色优化建模 Use one Skinned Mesh Renderer 一角色优使用一个个SkinedMeshRenderer;后优 称SMR, Your character should use only a single skinned mesh renderer. There is usually no reason to use multiple meshes for a character. Unity also has optimizations related to visibility culling and bounding volume updating which only kick in if you use one animation component and one skinned mesh renderer in conjunction. If you care about performance, multiple skinned meshes per character is not an option. If you use two skinned mesh renderers for one character instead of one, the time spent on rendering the character will most likely double! 在Unity中优优每角色优使用一您个个SkinedMeshRenderer来来个没优制。一般优优角色优必要 用到或更多的格;优者,此格优理解优两个网网Unity中Render优件所使用的Mesh~优Mesh 可以包含多个sub mesh~各sub mesh有自己的材优~但都用一个Render优制,。而且~ Unity在优化优景裁剪和更新角色包优优~是基于优有一优优件和一优体个个画SMR的假优的。所以~ 如果最求性能~就不优优优一角色使用多你个个SMR。如果用了你两个SMR~优优优消耗可能 是用一个SMR的倍,两 Don't Use Many Materials 不要使用优多的材优 You also want to keep the number of materials on that mesh as low as possible. There is only one reason why you might want to have more than one material on the character: when you need to use a different shader (e.g. if you want to use a special shader for the eyes). However, 2-3 materials per character should be sufficient in almost all cases. If your character is carrying a gun, it might be useful to have the gun a separate object, simply because it might get detached. 你优优优可能地少角色所用材优的量。优优只有一理由使用多材优,那就是优想使用尽减数你个个你 多着色器;例如~想优角色眼睛使用外一着色器,。但是~大多情下~每角个你另个数况个 色2-3个你你材优就优了。如果的角色优有一把优~那优优考优把优作优外一物;而不是角色另个体 的一部分,~因优可以角色身上拿走。;优者,我优优优和武器格点如果要求受到多它从装网个 角色骨的控制~而不是优优作优优骨优~优最好优是作优角色的一部分建模~然后用脚骼体随骼运 本优优优合优优优~优装参3D游优引擎——Unity中格合示例究,网并研 Reduce Amount of Bones 减少骨量骼数 Medium Desktop games use bone hierarchies with 15-60 bones. The fewer bones you use the faster; with 30 bones you can achieve very good quality on Desktop platforms and fairly good quality on Mobile Platforms. Unless you really have to, we strongly recommend you use fewer than 30 bones if you are developing for Mobile Platforms and around 30 bones per character on Desktop platforms. 中型的PC游优每角色一般使用个15-60个骨。骨越少~优算优行速度越快。一般用骼骼30 个骨就可以在骼PC游优中优得好的表优效果~同优在手机平台上也如此。我优建优如果不是很 特优有需要的优~在手机平台上优角色的骨不要超优骼30个~在PC平台上也量只用尽30个 左右的骨。骼 Polygon Count 三角片量数 How many polygons you should use depends on the quality you require and the platform you are targeting. Anything between 300-1500 triangles on Mobile Platforms and 500-6000 triangles on Desktop Platforms is reasonable. If you want lots of characters on screen or want the game to run on old machines, you will have to reduce the polygon count for each character. As an example: Half Life 2 characters used 2500-5000 triangles per character. Next-gen AAA games running on PS3 or Xbox 360 usually have characters with 5000-7000 triangles. 究竟用多少三角片取于所要求的优致程度和游优行的目优平台。一般手机上优角色决你运200- 1500~PC上500-6000个你很个三角片都是合适的。如果想同优优示多角色~或者想在优早 的硬件平台上流优行~那优就需要再削三角片量。优例子,半命运减数个条2 每角色用个 2500-5000个三角片~在PS3或者Xbox360上行的下一代的运AAA;优者,优是优。。。, 游优一般每角色个5000-7000三角片。 Separate Out IK and FK 将IK和FK分优 Separate out inverse kinematics (IK) and forward kinematics (FK). When animations are imported, the IK nodes are baked into FK, thus Unity doesn't need the IK nodes at all. You can either kill the GameObjects in Unity or the nodes in the modelling tool. By removing them, the IK nodes don't need to be animated every frame anymore. For this reason it is a very bad idea to intermix IK and FK hierarchies. Instead, you should create two hierarchies: one strictly for IK and one for FK. This way you can very easily select the whole IK hierarchy and delete it. 将IK和FK分优。当Unity优入模型优作优~IK优点被烘焙成会FK~因优Unity根本不需要IK优 点。可以在你Uniy中将IK优点优优生成的GameObject优除~或者直接在建模工具;如 maya、MAX等,中将IK优点优除后再优入。优优~Unity在优制每优优就不需要再考优IK优点的优作 了~由此提高了性能。所以~建模优将IK和FK混在一起可不是什优好主意。正的做法是确, 你将优优优IK和FK分成优。优优优除的优候就非常方便。;优者,本人优两Max等建模工具完全 不~不妥之优优多指,懂教 Use Reusable Rigs 优建可重用的Rig Create a rig which you can reuse. This allows you to share animations between different characters. 优建使用可重用的并rig。优优~就可以一套优作优用到不同的角色。;优者,基于骨优优优你将骼 作~然后在骨上优优多套骼Mesh~就可以优优不同外貌的角色具有相同的优作。优在游优中提个 供用优自定优角色外貌优有用。,很 Name Bones Correctly 优骨取直优易的名字骼懂 Name the bones correctly (left hip, left ankle, left foot etc.). Especially with characters, naming your bones correctly is very important. For example if you want to turn a character into a Ragdoll you will have to find the right bones for each body part. If they are not named correctly, finding all the body parts will take much longer.优骨取上直优易的名字;例如左臀、左、右腿等等,。优于人物角色~优骨取正骼懂踝骼个确 的名字尤其重要。优例子,如果要优一角色优入优娃娃;优者,一优物理引擎优优的优作模个你个靠 型~常用于模优人优优境相互作用下的优作,优体与真状,你确就需要正定位角色的各段骨。如骼 果名字取得不好;例如 1、2、3之优的,~程序的兄弟起脚本就优优。写来很 这 个脚本由CocoaChina “这” 这这这这这这这这这这这这这版主四角分享,可以将的材,比如有法 的材这这这这,行"烘焙"这这这这这这这这这这这这这 ,一的。可用来将Unity 这这这这这的游移植到移 这这这这这这这这这这这 平台候使用。将脚本放Editor 这这这这这这这这这这文件里,使用一个 Material 这这这这这这这这材,然后在菜"Custom/Bake Material"这这这这这这这这这这这这这这打并整照明和其他参数,点Bake按 这这这这这这这就会生成一个一的。 class BakeMaterialSettings { private static var kEditorPrefsName = "BakeMaterialSettings"; static var kBakingLayerShouldBeUnusedInScene = 30; static var kStandardTexNames = new Array ("_MainTex", "_BumpMap", "_Detail", "_ParallaxMap", "_Parallax"); var bakeAlpha = false; var bakeMainTexAsWhite = false; var minTextureResolution = 8; var maxTextureResolution = 2048; var emptyScene = false; var useCustomLights = false; var ambient = Color.black; static var kLights = 3; var enableLight = new boolean[kLights]; var colorLight = new Color[kLights]; var dirLight = new Vector2[kLights]; function BakeMaterialSettings () { Load (); } function Load () { bakeAlpha = EditorPrefs.GetBool(kEditorPrefsName + ".bakeAlpha"); bakeMainTexAsWhite = EditorPrefs.GetBool(kEditorPrefsName + ".bakeMainTexAsWhite"); minTextureResolution = EditorPrefs.GetInt(kEditorPrefsName + ".minTextureResolution", 8); maxTextureResolution = EditorPrefs.GetInt(kEditorPrefsName + ".maxTextureResolution", 2048); emptyScene = EditorPrefs.GetBool(kEditorPrefsName + ".emptyScene"); useCustomLights = EditorPrefs.GetBool(kEditorPrefsName + ".useCustomLights"); ambient.r = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.r"); ambient.g = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.g"); ambient.b = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.b"); ambient.a = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.a", 1.0f); for (var q = 0; q < kLights; ++q) { enableLight[q] = EditorPrefs.GetBool(kEditorPrefsName + ".enableLight" + q); colorLight[q].r = EditorPrefs.GetFloat(kEditorPrefsName + ".color.r" + q, 0.5f); colorLight[q].g = EditorPrefs.GetFloat(kEditorPrefsName + ".color.g" + q, 0.5f); colorLight[q].b = EditorPrefs.GetFloat(kEditorPrefsName + ".color.b" + q, 0.5f); colorLight[q].a = EditorPrefs.GetFloat(kEditorPrefsName + ".color.a" + q, 1.0f); dirLight[q].x = EditorPrefs.GetFloat(kEditorPrefsName + ".dir.x" + q); dirLight[q].y = EditorPrefs.GetFloat(kEditorPrefsName + ".dir.y" + q); } } function Save () { EditorPrefs.SetBool(kEditorPrefsName + ".bakeAlpha", bakeAlpha); EditorPrefs.SetBool(kEditorPrefsName + ".bakeMainTexAsWhite", bakeMainTexAsWhite); EditorPrefs.SetInt(kEditorPrefsName + ".minTextureResolution", minTextureResolution); EditorPrefs.SetInt(kEditorPrefsName + ".maxTextureResolution", maxTextureResolution); EditorPrefs.GetBool(kEditorPrefsName + ".emptyScene", emptyScene); EditorPrefs.SetBool(kEditorPrefsName + ".useCustomLights", useCustomLights); EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.r", ambient.r); EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.g", ambient.g); EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.b", ambient.b); EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.a", ambient.a); for (var q = 0; q < kLights; ++q) { EditorPrefs.SetBool(kEditorPrefsName + ".enableLight" + q, enableLight[q]); EditorPrefs.SetFloat(kEditorPrefsName + ".color.r" + q, colorLight[q].r); EditorPrefs.SetFloat(kEditorPrefsName + ".color.g" + q, colorLight[q].g); EditorPrefs.SetFloat(kEditorPrefsName + ".color.b" + q, colorLight[q].b); EditorPrefs.SetFloat(kEditorPrefsName + ".color.a" + q, colorLight[q].a); EditorPrefs.SetFloat(kEditorPrefsName + ".dir.x" + q, dirLight[q].x); EditorPrefs.SetFloat(kEditorPrefsName + ".dir.y" + q, dirLight[q].y); } } } class BakeMaterial extends EditorWindow { private static var kMateriBakeNodeName = "__MateriaBakeSetup"; private static var kWindowMinSize = Vector2 (300, 386); private static var settings : BakeMaterialSettings; private static var visible : boolean = false; private var camera : GameObject; private var plane : GameObject; private var previewTexture : Texture; private var lights : GameObject[] = new GameObject[BakeMaterialSettings.kLights]; private var stateChanged = false; private var texViewScrollPosition = Vector2.zero; private var lastMaterial : Material; private var originalScene = ""; private var scheduleBakeOnNextUpdate = false; private function SetupScene () { DestroyScene (); var oldGo = GameObject.Find(kMateriBakeNodeName); if (oldGo) DestroyImmediate (oldGo); camera = new GameObject (kMateriBakeNodeName, Camera); plane = GameObject.CreatePrimitive (PrimitiveType.Plane); var cam = camera; cam.camera.backgroundColor = Color.black; cam.camera.clearFlags = CameraClearFlags.SolidColor; cam.camera.orthographic = true; cam.camera.orthographicSize = 5.0; cam.camera.cullingMask = 1 << settings.kBakingLayerShouldBeUnusedInScene; plane.transform.parent = cam.transform; plane.transform.position = Vector3.forward * 10.0; plane.transform.rotation = Quaternion.Euler (0, 0, 180) * Quaternion.Euler (-90, 0, 0); plane.layer = settings.kBakingLayerShouldBeUnusedInScene; for (var l in lights) { l = new GameObject ("Light", Light); l.light.type = LightType.Directional; l.light.cullingMask = 1 << settings.kBakingLayerShouldBeUnusedInScene; l.transform.parent = cam.transform; l.active = false; } } private function UpdateScene (m : Material) { for (q = 0; q < settings.kLights; ++q) { lights[q].active = settings.useCustomLights & settings.enableLight[q]; lights[q].light.color = settings.colorLight[q]; lights[q].transform.rotation = Quaternion.AngleAxis(settings.dirLight[q].x, Vector3.up) * Quaternion.AngleAxis(settings.dirLight[q].y, Vector3.right); } if (settings.useCustomLights) RenderSettings.ambientLight = settings.ambient; else if (settings.emptyScene) RenderSettings.ambientLight = Color.white; plane.renderer.material = m; } private function DestroyScene () { GameObject.DestroyImmediate (camera); GameObject.DestroyImmediate (plane); GameObject.DestroyImmediate (previewTexture); } function UpdateMaterialPreview (m : Material) : RenderTexture { if (!m) return; var saveAmbientLight = RenderSettings.ambientLight; var saveMainTexture = m.mainTexture; if (settings.bakeMainTexAsWhite) m.mainTexture = null; // setup if (!camera) SetupScene (); camera.SetActiveRecursively(true); UpdateScene (m); var res = FindLargestTextureResolution (plane.renderer.sharedMaterial, settings.minTextureResolution, settings.maxTextureResolution); var rt = RenderCameraToRenderTexture (camera.camera, res.x, res.y); // restore camera.SetActiveRecursively(false); RenderSettings.ambientLight = saveAmbientLight; m.mainTexture = saveMainTexture; previewTexture = rt; return rt; } function CaptureMaterial(m : Material) { var matAssetPath = AssetDatabase.GetAssetPath (m); var assetPath = System.IO.Path.Combine (System.IO.Path.GetDirectoryName (matAssetPath), System.IO.Path.GetFileNameWithoutExtension (matAssetPath)); var rt = UpdateMaterialPreview (m); RenderTextureToPNG (rt, settings.bakeAlpha, assetPath + ".png"); } function OnEnable () { if (!settings) settings = new BakeMaterialSettings (); SetupScene (); visible = true; } function OnDisable () { DestroyScene (); settings.Save (); visible = false; } static function GetTargetMaterial () : Material { return EditorUtility.InstanceIDToObject (Selection.activeInstanceID) as Material; } function OnSelectionChange () { Repaint (); } function Update () { var rebuildScene = false; if (scheduleBakeOnNextUpdate) { Bake (); scheduleBakeOnNextUpdate = false; rebuildScene = true; } if (originalScene == "" && EditorApplication.currentScene == "") settings.emptyScene = true; if (settings.emptyScene && originalScene == "" && EditorApplication.currentScene ! = "") { DestroyScene (); if (EditorApplication.SaveCurrentSceneIfUserWantsTo ()) { originalScene = EditorApplication.currentScene; EditorApplication.NewScene (); } else settings.emptyScene = false; rebuildScene = true; } else if (!settings.emptyScene && originalScene != "") { EditorApplication.OpenScene (originalScene); rebuildScene = true; originalScene = ""; } if (rebuildScene) { SetupScene (); } if (rebuildScene || stateChanged || !settings.emptyScene) { UpdateMaterialPreview (lastMaterial); Repaint (); stateChanged = false; } } function OnGUI () { var material = GetTargetMaterial (); if (lastMaterial != material) UpdateMaterialPreview (material); if (material) lastMaterial = material; EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(GUILayout.MaxWidth(200)); if (!(originalScene == "" && EditorApplication.currentScene == "")) { settings.emptyScene = !EditorGUILayout.BeginToggleGroup("Scene ligthing", !settings.emptyScene); EditorGUILayout.EndToggleGroup(); } settings.useCustomLights = EditorGUILayout.BeginToggleGroup("Custom lighting", settings.useCustomLights); if (settings.useCustomLights) { EditorGUI.indentLevel = 1; settings.ambient = EditorGUILayout.ColorField("Ambient", settings.ambient); for (var q = 0; q < settings.kLights; ++q) { settings.enableLight[q] = EditorGUILayout.BeginToggleGroup("Light", settings.enableLight[q]); EditorGUI.indentLevel = 2; settings.colorLight[q] = EditorGUILayout.ColorField("Color", settings.colorLight[q]); settings.dirLight[q] = EditorGUILayout.Vector2Field("Direction", settings.dirLight[q]); EditorGUILayout.EndToggleGroup(); } } EditorGUI.indentLevel = 0; EditorGUILayout.EndToggleGroup(); settings.bakeAlpha = EditorGUILayout.Toggle("Bake Alpha", settings.bakeAlpha); settings.bakeMainTexAsWhite = !EditorGUILayout.Toggle("MainTex", ! settings.bakeMainTexAsWhite); settings.minTextureResolution = EditorGUILayout.IntField("Min Resolution", settings.minTextureResolution); settings.maxTextureResolution = EditorGUILayout.IntField("Max Resolution", settings.maxTextureResolution); settings.minTextureResolution = Mathf.Max(2, settings.minTextureResolution); settings.maxTextureResolution = Mathf.Max(settings.minTextureResolution, settings.maxTextureResolution); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Bake")) { CaptureMaterial (lastMaterial); } if (GUILayout.Button("Bake Selected")) { scheduleBakeOnNextUpdate = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); texViewScrollPosition = EditorGUILayout.BeginScrollView (texViewScrollPosition); var r = GUILayoutUtility.GetAspectRect(1.0f); if (previewTexture) EditorGUI.DrawPreviewTexture(r, previewTexture); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); if (GUI.changed) { stateChanged = true; } } @MenuItem("Custom/Bake Material ...", false, 5) static function CreateBakeEditor() { var window = EditorWindow.GetWindow(BakeMaterial); window.title = "Bake Material"; window.minSize = kWindowMinSize; window.Show(); } @MenuItem("Custom/Bake Selected Materials", false, 4) static function Bake() { var instanceIDs = Selection.instanceIDs; var currentScene = EditorApplication.currentScene; var wasAlreadyVisible = BakeMaterial.visible; var window = EditorWindow.GetWindow(BakeMaterial); if (window.settings.emptyScene) { if (!EditorApplication.SaveCurrentSceneIfUserWantsTo ()) return; EditorApplication.NewScene (); } window.SetupScene (); for (var i in instanceIDs) { var m : Material = EditorUtility.InstanceIDToObject (i) as Material; if (m) window.CaptureMaterial (m); } window.DestroyScene (); if (window.settings.emptyScene && currentScene) { EditorApplication.OpenScene (currentScene); } if (!wasAlreadyVisible) window.Close (); } static function FindLargestTextureResolution (m : Material, minTexRes : int, maxTexRes : int) : Vector2 { var res = Vector2 (minTexRes, minTexRes); for (var n in BakeMaterialSettings.kStandardTexNames) { if (!m.HasProperty (n)) continue; var t : Texture = m.GetTexture (n); if (!t) continue; res.x = Mathf.Max (res.x, t.width); res.y = Mathf.Max (res.y, t.height); } res.x = Mathf.Min (res.x, maxTexRes); res.y = Mathf.Min (res.y, maxTexRes); return res; } static function RenderCameraToRenderTexture (cam : Camera, width : int, height : int) : RenderTexture { var rt = cam.camera.targetTexture; if (rt && rt.width != width && rt.height != height) DestroyImmediate(rt); if (!rt) rt = new RenderTexture (width, height, 24); cam.camera.targetTexture = rt; cam.camera.Render (); return rt; } static function RenderTextureToPNG (rt : RenderTexture, bakeAlpha : boolean, assetPath : String) { RenderTexture.active = rt; var screenShot = new Texture2D (rt.width, rt.height, bakeAlpha? TextureFormat.ARGB32 : TextureFormat.RGB24, false); screenShot.ReadPixels (Rect (0, 0, rt.width, rt.height), 0, 0); RenderTexture.active = null; var bytes = screenShot.EncodeToPNG (); System.IO.File.WriteAllBytes (assetPath, bytes); AssetDatabase.ImportAsset (assetPath, ImportAssetOptions.ForceUpdate); } }
本文档为【unity优化】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_624976
暂无简介~
格式:doc
大小:109KB
软件:Word
页数:0
分类:生活休闲
上传时间:2018-04-28
浏览量:10