Modeling Characters for Optimal Performance
为获得最佳性能的角色建模
Below are some tips for designing character models to give optimal rendering speed.
下面是一些提示,主要是如何设计角色模型来达到更好的渲染速度。
Use a Single Skinned Mesh Renderer
使用一个单一的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.
您应该对于每个角色仅使用一个skinned mesh renderer。Unity使用可见性裁剪和包围体更新的方法来优化角色的运动,并且这些优化只有在您使用一个运动组件和一个skinned mesh renderer时才会被激活。如果您在一个网格的位置使用了两个蒙皮网格,那么该模型的渲染时间将变成原来的两倍。这样,这种做法与使用多个网格相比几乎没有任何实际的优势。
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.
您应该在每个网格上使用尽可能少的材质。您在一个角色上使用多个材质的唯一理由应该是你需要在不同的部分使用不同的着色器(比如在眼睛上使用特殊的着色器)。但是,在大多数情况下,一个角色2-3个材质就已经足够了。
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 can have lots of characters onscreen at any given time. As an example, Half Life 2 used 2500-5000 triangles per character. Current AAA games running on the PS3 or Xbox 360 usually have characters with 5000-7000 triangles.
您应该使用的多边形的数量取决于您所需要的质量和您的目标平台。对于移动设备,每个mesh拥有300-1500个多边形的话江湖达到比较好的效果,而对于桌面平台,这个理论范围大约为1500-4000。当然,如果游戏中任意时刻内屏幕上出现了大量的角色,那么您应该降低每个网格的面片数。比如,半条命2对于每个角色使用2500-5000个三角形面片。目前PS3或者Xbox360上的AAA级游戏中,每个角色大概拥有5000-7000个三角形面片。
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)结点会被烘焙到前向运动(FK)结点中,但实际上,Unity根本就不需要逆向运动结点。因此,如果它们保存在模型中,那么即使它们对运动没有任何影响也会占有一定的CPU开销。您可以根据您的需求在Unity或其他建模工具中删除多余的IK结点。理想情况下,您应该在建模时将IK和FK结点分离,这样在需要的时候就比较容易删除IK结点。
备注:最近一直在研究Unity3D的性能优化问题,这段时间可能会多翻译这方面的文章,如有翻译不当之处还请多多指出。
原文地址:http://unity3d.com/support/documentation/Manual/Modeling%20Optimized%20Characters.html