The first step is to get your Assets into a format suitable for what you want to do. It’s very important to set up a proper workflow from your 3D modeling application, such as Autodesk® 3ds Max®, Autodesk® Maya®, Blender, and Houdini, into Unity. When exporting assets from 3D modeling applications for import into Unity, you need to consider:
项目缩放比例和您偏好的测量单位在制作可信场景时起着非常重要的作用。在许多“真实世界”设置中,我们建议您假设 1 个 Unity 单位 = 1 米(100 厘米),因为许多物理系统都采用此单位大小。有关更多建议,请参阅艺术资源最佳实践指南。
To maintain consistency between your 3D modeling application and Unity, always validate the imported GameObject scale and size. 3D modeling applications have units and scale settings in the FBX export configuration (see the documentation for your 3D modelling software for configuration advice). Generally, the best way to match the scale when importing to Unity is to set these tools to work in centimeters, and export FBX at automatic scale. However, you should always check that the unit and scale settings match when starting a new project.
To quickly validate your export settings, In your 3D modeling application, create a simple 1x1x1m cube and import it into Unity. In Unity, create a default Cube (GameObject > 3D Object > Cube). This is 1x1x1m. Use this as a scale reference to compare with your imported model. These cubes should look identical when the Transform component’s Scale property is set to 1,1,1 in the Inspector:
注意:
通过占位体或草绘几何体阻挡场景时,使用参考点比例模型可能会有所帮助。请选择适合正在制作的场景的参考点比例模型。在 Spotlight Tunnel 示例场景案例中,我们使用了公园长椅:
场景不必使用与现实生活完全相同的比例。使用参考点比例模型可以在游戏对象之间确保相对的比例一致性,即使场景试图使用夸大的比例也没有关系。
纹理内部的信息需要包含正确的信息,以便在添加到材质时提供正确的结果。纹理创作软件(如 Photoshop 和 Substance Painter)在经过正确配置后可输出一致且可预测的纹理。
以下是 Substance Painter 预设配置的示例,此示例将输出与 Unity 标准不透明材质结合使用的纹理:
Unity 标准材质中的纹理分配为:
用于导出的输出映射 | Unity 标准着色器材质中的分配 |
---|---|
$textureSet_Albedo | 分配给 Albedo。 |
$textureSet_MetallicAOGloss | 分配给 Metallic 且 Occlusion.Smoothness Source 设置为 Metallic Alpha。 |
$textureSet_Normal | 分配给 Normal Map 字段。 |
注意:与将环境光遮挡 (AO) 导出为单独的纹理相比,将多个通道打包到单个纹理(例如 MetallicAOGloss)可节省纹理内存。这是使用 Unity 标准材质的最佳方式。
创建纹理时,不得混淆 Alpha 通道。下面的示例显示了因为 Photoshop 处理 PNG Alpha 通道的方式问题(不使用外部插件),PNG 文件中的透明度如何在 Photoshop 中让创作者感到困惑。在这种情况下,具有专用 Alpha 通道的未压缩 32 位 TGA 可能是更好的选择(假设源纹理文件大小不是问题):
上面显示的透明 PNG 文件是在 Photoshop 中创建的,其 Alpha 通道显示为黑色值。具有专用 Alpha 通道的 TGA 显示了预期值。如上所示,当分配给标准着色器材质的每个纹理从 Alpha 通道读取平滑度数据时,具有 PNG 纹理的材质的平滑度意外反转,而具有 TGA 纹理的材质的平滑度是正常的。
Unity 读取切线空间法线贴图时采用以下解释:
For example, a Autodesk® 3ds Max® Render to Texture normal map outputs the Green Channel Y+ as Down by default. This causes an inverted surface direction along the Y axis and creates invalid results when lit. To validate the normal map direction, create a simple plane with concave bevel (middle picture on the example below) and bake it to a flat plane. Then assign the baked normal map into a plane in Unity with identifiable light direction and see if any of the axes are inverted.
有关轴设置的建议,请参阅 3D 建模应用程序的文档。