Unity3D - 圖形性能優化:角色建模

Unity官方文檔之“圖形性能優化-角色建模”翻譯,E文鏈接

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.

在每個網格中,你應該儘可能使用最少的材質。在一個角色上使用多於一個材質的唯一原因,可能是對於不同部位你想使用不能的着色器(比如,對眼睛使用一個特殊的着色器)。然而,在差不多所有情況下,對一個角色使用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個骨骼,你可以在PC平臺獲得很好的效果,在移動平臺也可以獲得相當不錯的效果。理想情況下,在移動設備上保持30個以下的骨骼數量,在PC遊戲中不能超過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.

你應該使用的多邊形數量依賴於你想要的表現效果和目標平臺。對於移動設備,一個網格使用300-1500個多邊形可以獲得好的效果,然而對於PC平臺,理想的數量是1500-4000個。如果你的遊戲需要在屏幕上同時顯示很多角色,那麼你需要減少每個網格的多邊形數量。比如,《半條命2》每個角色使用2500-5000個三角形。目前在PS3或Xbox 360上的3A遊戲常常每個角色使用5000-7000個三角形。

Keep Forward and Inverse Kinematics Separate 將FK和IK分開

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不需要IK節點。然而,如果模型中存在IK節點,雖然它們並不影響動畫,但是會消耗CPU。可以根據你的喜好,在Unity或建模工具中刪除多餘的IK節點。理想的,你應該在建模的時候保持IK和FK結構獨立,這樣在需要的情況下,你可以刪除所有IK節點。

發佈了60 篇原創文章 · 獲贊 638 · 訪問量 51萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章