以下是一些能够优化渲染速度的角色建模技巧。
对于每个角色,仅使用单个蒙皮网格渲染器。Unity 使用可见性剔除和包围体更新来优化动画,这些优化仅在您将单个动画组件和单个蒙皮网格渲染器组合使用时才会生效。若使用两个蒙皮网格,模型的渲染时间大概会是单个网格的两倍,并且这样做很少能带来实际的意义。
您同样应该尽可能减少每个网格上的材质数量。只有在需要为角色的不同的部分使用不同着色器(例如,眼睛的特殊着色器)时,您才应该考虑使用多种材质。其余大多数情况下,每个角色有两到三种材质就应该足够了。
典型的桌面游戏中的骨骼层级视图大概拥有 15 到 60 根骨骼。骨骼的数量越少,性能就越好。在使用大约 30 根骨骼的情况下,桌面平台上可以获得极佳质量,移动平台上也能获得比较好的质量。理想情况下,移动设备游戏的骨骼数量应保持在 30 根以下,桌面游戏的骨骼数量也不要超出 30 根太多。
您应该使用的多边形数量取决于您需要达到的质量,以及您的目标平台。对于移动设备而言,每个网格 300 到 1500 个多边形就可以取得良好的效果,而对于桌面平台,理想的数量范围大约为 1500 到 4000。如果游戏经常会同屏内出现大量角色,那么您可能需要减少每个网格的多边形数量。
在导入动画时,模型的反向动力学 (IK) 节点将被烘焙为正向动力学 (FK),因此 Unity 根本不需要 IK 节点。但是,如果它们留在了模型中,那么即使它们不影响动画,也会让 CPU 产生额外开销。您可以根据自己的偏好,删除 Unity 或建模工具中的冗余 IK 节点。理想情况下,应在建模期间保留单独的 IK 和 FK 层级视图,以便在必要时更轻松地删除 IK 节点。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.