优化性能建模角色

时间:2022-10-15 00:23:45

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中您应该每个角色仅使用一个蒙皮网格渲染器(skinned mesh renderer)来绘制。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.

你还应该尽可能地减少网格所用材质的数量。只有一个理由在角色上使用多个材质:那就是你想使用不用的着色器(例如,你想为角色眼睛使用另外一个着色器)。但是,大多数情况下,每个角色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.

中型的PC游戏每个角色一般使用15-60个骨骼。骨骼越少,性能越好。一般用30个骨骼就可以在台式机上(Desktop platforms)获得很好的表现效果,同时在手机平台(Mobile Platforms)上质量也相当不错。理想的情况是,在手机平台(Mobile Platforms)上单角色的骨骼不要超过30个,在台式机( Desktop platforms)上也尽量只用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.

究竟用多少多边形取决于你所要求的质量和游戏运行的目标平台。一般手机平台( Mobile Platforms)上每个网格300-1500个多边形可以出好效果,台式机( Desktop Platforms)理想的范围是大约1500-4000个。如果你想同时在屏幕显示很多个角色,那么就需要再减少每个角色的多边形数量。举个例子:半条命2 每个角色用2500-5000个三角片,在PS3或者Xbox360上运行的AAA游戏一般每个角色5000-7000三角片。

Keep Forward and Inverse Kinematics Separate
将IK和FK分开
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.

当Unity导入动画时,模型的IK节点会被烘焙成FK,Unity根本不需要IK节点。但是,如果他们都留在模型中,即使他们不影响动画,他们都会产生CPU开销。根据自己的喜好,您可以在Unity或在建模工具删除多余的IK节点。理想的情况是:在建模过程中,你应该将IK和FK分成两层,一个是IK的、另一个是FK的。这样就可以在必要时很容易的选择整一个IK层并将他删除。