Modeling characters for optimal performance 角色建模的优化性能
本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.3版本
参考链接:https://docs.unity3d.com/Manual/ModelingOptimizedCharacters.html
Below are some tips for designing character models to give optimal rendering speed.
下面是一些为设计角色模型以提供最佳渲染速度的技巧。
Use a single skinned Mesh Renderer
用一个骨骼网格渲染器
You should use only a single skinned Mesh Renderer for each character. Unity optimizes animation using visibility culling and bounding volume updates and these optimizations are only activated if you use one Animation component and one skinned Mesh Renderer in conjunction. The rendering time for a model could roughly double as a result of using two skinned meshes in place of a single mesh and there is seldom any practical advantage in using multiple meshes.
你应该只对每个角色使用一个蒙皮的网格渲染器。Unity使用可见性裁剪和包围体更新优化动画,这些优化只有在你同时使用一个动画组件和一个蒙皮网格渲染器时才会被激活。由于使用两个蒙皮网格代替单个网格,模型的渲染时间可能会增加一倍,而且使用多个网格几乎没有任何实际优势。
Use as few materials as possible
使用尽可能少的材质
You should also keep the number of Materials on each mesh as low as possible. The only reason why you might want to have more than one Material on a character is that you need to use different shaders for different parts (eg, a special shader for the eyes). However, two or three materials per character should be sufficient in almost all cases.
你还应该保持每个网格上的材质数量尽可能低。你可能想在一个角色上有多个材质的唯一原因是你需要在不同的部分使用不同的材质(例如,眼睛的特殊材质)。然而,在几乎所有情况下,每个角色使用两到三种材质就足够了。
Use as few bones as possible
用尽可能少的骨骼
A bone hierarchy in a typical desktop game uses somewhere between fifteen and sixty bones. The fewer bones you use, the better the performance will be. You can achieve very good quality on desktop platforms and fairly good quality on mobile platforms with about thirty bones. Ideally, keep the number below thirty for mobile devices, and don’t go too far above thirty for desktop games.
在典型的桌面游戏中,骨骼层次结构使用的是15到60块骨头。使用的骨骼越少,性能就越好。您可以在桌面平台上获得非常好的质量。在移动平台上获得相当好的质量,大约有30块骨头。理想的情况是,移动设备的数字不要超过30,桌面游戏的数字不要超过30太多。
Polygon count
多边形数量
The number of polygons you should use depends on the quality you require and the platform you are targeting. For mobile devices, somewhere between 300 and 1500 polygons per mesh will give good results, whereas for desktop platforms the ideal range is about 1500 to 4000. You may need to reduce the polygon count per mesh if the game has lots of characters on screen at any given time.
您应该使用的多边形数量取决于您需要的质量和平台。对于移动设备来说,每个网格300到1500个多边形会有很好的效果,而对于桌面平台来说,理想的范围是1500到4000个。如果游戏在任何时候屏幕上都有很多角色,你可能需要减少每个网格的多边形数量。
Keep forward and inverse kinematics separate
保持正反向运动学分离
When animations are imported, a model’s inverse kinematic (IK) nodes are baked into forward kinematics
(FK) and as a result, Unity doesn’t need the IK nodes at all. However, if they are left in the model then they will have a CPU overhead even though they don’t affect the animation. You can delete the redundant IK nodes in Unity or in the modeling tool, according to your preference. Ideally, you should keep separate IK and FK hierarchies during modeling to make it easier to remove the IK nodes when necessary.
当导入动画时,模型的反向运动学(IK)节点被烘焙成正向运动学。因此,Unity根本不需要IK节点。然而,如果它们留在模型中,那么即使它们不影响动画,它们也会有CPU开销。您可以根据自己的喜好在Unity或建模工具中删除冗余的IK节点。理想情况下,您应该在建模期间保持独立的IK和FK层次结构,以便在必要时更容易删除IK节点。