unity VR游戏帧数优化(二)

这篇主要摘录了unity官网上对于VR项目优化相关的帖子,读罢受益良多,也应用到了自己的项目里。这里记录留作日后学习参考。

由于在目标平台上达到帧率要求是保证玩家获得良好VR体验,同时避免眩晕的重要措施,优化在VR游戏开发中占据着极其重要的地位。和其他平台不同,最好在VR游戏开发早期就着手进行优化,同时优化也应当经常进行,而不是将其放在开发的最后阶段,当然,在目标平台上经常性开展测试也是有益的优化手段

相较于非VR工程,VR是计算消耗很大,这主要是由于每次都要分别为每只眼睛单独进行整个场景的渲染。因此,在创建VR体验时应确保自己熟知该领域中的一些常见问题。如果你能预先对这些问题有所认识,就可以围绕这些问题进行项目的设计,从而避免在项目生命周期后期的繁重工作。

移动VR对于优化的要求更加强烈,不仅在于运行VR应用的大量开销,同时,移动设备的性能只是桌面PC的零头,此时优化就会成为影响项目成败的至关重要的因素。

由于达到目标帧率十分重要,所有的优化方法都需要进行考虑。别忘了尽可能多的优化程序代码,细节可以查看Unity的代码优化指南

Unity Editor optimisation tools(Unity自带的优化工具)

The Profiler(性能分析器)

The profiler will help you understand how much time is spent rendering each frame of your game, and splits this into CPU, Rendering, Memory, Audio, Physics and Network. Understanding how to use the Profiler is critical to examining performance, and identifying areas that need optimisation.

可以让你了解游戏中每帧渲染的时间开销,并通过处理器、渲染、内存、音频、物理和网络进行分项显示。执行性能测试时,了解性能分析器,找到需要优化的方面非常重要

To find out more about using the Profiler, please see these links(扩展链接):

http://docs.unity3d.com/Manual/Profiler.html

https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/profiler-overview

https://unity3d.com/learn/tutorials/modules/intermediate/editor/intro-to-profiler

Geometry(几何体)

Remove any faces from your geometry that will never be seen in VR. We don’t want to render something that will never be seen. For example, if the user will never see the back of a cupboard as it’s against the wall, we don’t want any of those faces on the model.

移除VR场景中永不可见的几何体表面。例如,用户永远看不到靠墙柜子的背面,那么我们就不需要在那个模型中建立背面中任何一个表面。

Simplify your meshes as much as possible. Depending on your target platform, you may want to look into adding detail via textures, and potentially parallax mapping and tessellation, though this can impact performance, and may not be suitable or available for your target platform.

尽可能简化mesh。根据你的目标平台,你可能会想通过纹理增添细节,使用视差贴图、曲面细分技术,但这可能会对性能造成影响,也可能无法适用于你的目标平台。

Overdraw(遮挡绘制)

Overdraw view allows you to see what objects are drawn on top of another, which is a waste of GPU time. Look atreducing overdraw as much as possible. You can view overdraw in the Scene View by using the Scene View Control Bar.

遮挡绘制会让你看到绘制在别的物体上方的物体,这样就造成了GPU时间的浪费。 尽可能减少遮挡绘制的数量。你可以通过Scene View 控制栏中检查遮挡绘制。

Normal shaded view:

Overdraw enabled:

Level of Detail(细节级别)

Level Of Detail (LOD) rendering allows you to reduce the number of triangles rendered for an object as its distance from camera increases. As long as your objects aren’t all close to the camera at the same time, LOD will reduce the load on the hardware and improve rendering performance by adding an LOD component and providing lower detail meshes for distance groups further from the camera.

细节级别渲染可以让你减少距离相机较远物体的三角面的数量。只要游戏物体不是同时出现在摄像机附近,通过添加LOD组件就可以通过为较远物体指定面数较低的网格模型,减少硬件负荷,并提高渲染质量。

Using Simplygon can automate much of the asset preparation process for LOD.

使用Simpolygon 可以自动为大部分游戏资源进行LOD预处理。

Draw Call batching(Draw Call批处理)

Batch Draw Calls wherever possible, using Static Batching and Dynamic Batching. This can greatly increase performance. See the Unity guide to Draw Call Batching.

尽可能使用静态批处理和动态批处理来进行Draw Call 批处理的调用。这个可以极大提高运行性能。(查看Unity指南来进行Draw Call批处理的学习)

Lightmapping(光照贴图)

Eliminate dynamic lighting wherever possible, and bake lighting where you can, and avoid realtime shadows.

尽可能削减动态光照而使用烘焙得到光照效果,避免使用实时阴影

See the Unity guide to Lighting and Rendering for more information.

Light Probes(光线检测)

Light probes allow you to sample the lighting at points in the scene and apply this to dynamic objects. This is relatively fast, and frequently has great visual results.

光线检测对场景中某点的光照进行取样并将其应用于动态物体上,执行速度较快,通常能获得较好的视觉效果。

Reflection Probes(反射检测)

Reflection probes store cubemaps of their surroundings to allow for realistic reflections, and can impact performance. Please be aware that real-time mode reflection probes are too slow to use in VR at this time.

反射检测存储周围环境的立方体贴图来获得真是的反射,并且会显著影响性能。请注意实时的反射检测因过于缓慢而无法应用于VR项目的开发中。

Occlusion Culling(遮挡剔除)

Occlusion Culling stops objects from being rendered if they cannot be seen. For example, we don’t want to render another room if a door is closed and it cannot be seen.

遮挡剔除可以停止不可见的物体渲染。例如,我们没有必要去渲染一个门被关上。并且内部情形不可见的房间。

Depending on your project and target platform, you may be able to implement Occlusion Culling, which can significantly increase performance.

能否使用遮挡剔除视你的工程和目标平台而定,但一旦使用,遮挡剔除将极大提升游戏性能。

An example of frustum culling:

An example of Occlusion Culling:


你可能感兴趣的:(unity)