Version: 2023.2
Grass and other details
地形设置 (Terrain Settings)

使用高度贴图

影响高度的地形工具(如 Raise or Lower Terrain 和 Set Height)使用称为高度贴图的灰度纹理。Unity 将地形上每个点的高度表示为矩形数组中的值。此数组用灰度高度贴图来表示。高度贴图内置于地形中,并且高度贴图中存储的值用于定义地形上每个点或顶点的高度。

示例高度贴图
示例高度贴图

导入和导出高度贴图

You can import and export heightmaps into the Unity Editor. This is useful when you want to use real world height data to replicate a landmark such as Mount Everest, or work on a heightmap image in an external image editor. You can also use 3D modelling applications, such as Houdini and World Machine, to generate Terrain, then import your Terrain into Unity as a heightmap.

It’s good practice to store heightmaps as RAW files. A RAW file uses a 16-bit grayscale format that’s compatible with most image and landscape editors. The Unity Editor enables you to import and export RAW heightmap files for a Terrain.

要在 Editor 中访问导入和导出设置,请在 Inspector 中选择 Terrain 组件,然后单击 Terrain Settings 按钮(工具栏中的齿轮图标)。

Terrain Settings Inspector 中的 Import Raw 按钮和 Export Raw 按钮
Terrain Settings Inspector 中的 Import Raw 按钮和 Export Raw 按钮

在 Texture Resolutions (On Terrain Data) 下,有两个标记为 Import Raw 和 Export Raw 的按钮。

  • Import Raw 允许 Unity 从 RAW 文件格式读取高度贴图,并在 Editor 中生成此高度贴图。

    Import Heightmap 窗口

  • Export Raw 允许 Unity 将高度贴图从 Editor 写入 RAW 文件格式。

    Export Heightmap 窗口

导入和导出选项

属性 描述
Depth 确定 Unity 在导入或导出的高度贴图中每个像素使用的位数。
• Bit 16:使用 16 位(2 个字节)
• Bit 8:使用 8 位(1 个字节)
Resolution 所导入的高度贴图的纹理分辨率(宽度和高度)。
Byte Order 确定 Unity 如何为导入或导出的高度贴图中的每个像素进行字节排序。这主要适用于 16 位深度高度贴图,与平台有关。
Flip Vertically 确定 Unity 是否沿 x 轴垂直翻转导出的高度贴图。
Terrain Size Unity 将导入高度贴图应用到的地形的大小。

  • 2020–06–30 页面已修订

  • 更新了内容以反映新的 UI 和选项

Grass and other details
地形设置 (Terrain Settings)