This page has been translated automatically.
UNIGINE 基础课程
1. 简介
2. 虚拟世界管理
3. 3D模型准备
4. 材质
5. 摄像机和光照系统
6. 实现应用程序逻辑
7. 制作过场动画与动画序列
8. 准备发布项目
9. 物理系统
10. 优化基础
11. 项目2:第一人称射击游戏
13. 项目4:带有简单交互的 VR 应用程序

创建地形

So far, the car has been moving on the test plane. However, the game needs a vast and variegated open space with various, so let's add a landscape to the scene.到目前为止,汽车一直在测试平面上行驶。但游戏需要一个广阔而多样的开放空间,因此我们将向场景中添加地形。

For this purpose we'll use terrain — a special type of geometry object designed for creating landscapes. The main object for working with landscape in UNIGINE is Landscape Terrain. It is optimized for vast areas and uses the material with specific texture blending to realistically simulate natural and artificial surfaces: soil, rocks, asphalt, paving stones, etc. Typically, it serves as the foundational element for open-world games, providing a basis for static geometry placement and character movement.为此我们将使用terrain(地形),这是一种专门用于创建地貌的几何对象类型。UNIGINE 中用于地形编辑的主要对象是Landscape Terrain。它针对大范围区域进行了优化,并使用支持多纹理混合的材质,能够逼真地模拟自然与人造表面,如:土壤、岩石、沥青、石板路等。它通常作为开放世界游戏中的基础元素,为静态几何体放置和角色移动提供支撑。

The Landscape Terrain system is represented by two types of nodes:Landscape Terrain系统包含两种节点类型:

  • Object Landscape Terrain — a virtual object ensuring the terrain rendering.Object Landscape Terrain用于地形渲染的虚拟对象。
  • One or several Landscape Layer Map objects — layers with the terrain graphic data. The layer system allows you to combine and mix layer data in different order, as well as to place high-detailed layers of small size over large low-detailed layers (the so-called inset).一个或多个Landscape Layer Map对象包含图形地形数据的图层。图层系统支持不同顺序的混合,还可以将高精度小尺寸图层覆盖在大范围低精度图层上(称为嵌入图层)。

To create a terrain, you need a set of the following textures created in third-party software:创建地形需要使用第三方工具生成以下纹理集:

  • Height map — terrain height data高度图(Height map):表示地形高度的数据
  • Albedo — colored terrain surface textureAlbedo:地形表面的颜色纹理
  • Masks — a set of masks that can be used to arrange plants and apply additional detailMasks:可用于布置植被和应用附加细节的遮罩集合
  • Albedo, Roughness, and Height textures for each additional detail每个附加细节所需的Albedo、RoughnessHeight 纹理

You can model a fairly simple terrain by drawing it manually using the UnigineEditor's built-in landscape editor. However, realistic natural terrains are usually created in specialized software such as: Quadspinner Gaea, World Machine, World Creator, SideFX Houdini, etc. Using these tools, you can simulate a suitable landscape and get a set of textures that define the shape and color of the terrain for the game engine.你也可以直接在 UnigineEditor 内置的地形编辑器中手工绘制一个较为简单的地形。但更真实的自然地貌通常在专用软件中创建,例如:Quadspinner Gaea、World Machine、World Creator、SideFX Houdini等。这些工具可以生成拟真的地貌,并导出供游戏引擎使用的纹理数据。

在 Quadspinner Gaea 中创建的地形

Terrain in Quadspinner Gaea在 Quadspinner Gaea 中创建的地形

For this tutorial, you can use the ready-made textures available in the race/terrain folder.本教程中你可以使用race/terrain文件夹中提供的现成纹理。

  1. In the menu, select Create → Landscape → Landscape Terrain and add it to the scene. Two new nodes will appear in the world hierarchy: ObjectLandscapeTerrain — the terrain itself, and LandscapeLayerMap — the layer with data. The standard terrain layer is represented by a colorless plane with the size of 1000×1000 m. The ground_plane test plane can be disabled for convenience.在菜单中选择Create → Landscape → Landscape Terrain并将其添加到场景中。世界层级中会新增两个节点:ObjectLandscapeTerrain(地形对象)和LandscapeLayerMap(图层对象)。默认图层显示为一块无颜色的 1000×1000 米平面。你可以禁用ground_plane测试平面以获得更清晰视图。
  2. Set the Size of this layer to 5000 × 5000 m.将该图层的Size设置为 5000 × 5000 米。
  3. Find the ready-made terrain textures in the race/terrain folder. In the Parameters tab of LandscapeLayerMap, click the + button in the Landscape field to create and apply a new *.lmap asset that will store data of our terrain layer.race/terrain文件夹中找到现成地形纹理。在LandscapeLayerMapParameters标签中,点击Landscape字段旁的 + 按钮,创建并应用一个新的*.lmap资源,该资源将保存图层数据。

  4. In the import settings, for Data Filling select From Tileset and add the source textures for the terrain:在导入设置中,将Data Filling设置为From Tileset,并添加以下地形源纹理:

    1. Height map in the Heightmap field. Here you also need to set the terrain layer height Max: 1000 meters.Heightmap字段中添加Height图,并设置地形高度Max为 1000 米。
    2. Albedo texture in the Albedo Color field.Albedo Color字段中添加Albedo纹理。
    3. Each of the 6 masks from the race/terrain folder is added to an individual slot in the Masks section. For easier customization, we recommend to name each mask accordingly.race/terrain文件夹中的 6 个Mask分别拖入Masks部分的单独槽位中。建议根据用途为每个遮罩命名,方便管理。

    4. Click Reimport Data to load the selected textures.点击Reimport Data以加载所选纹理。

Landscape Terrain has the Collision and Physics Intersections options enabled by default (your can check this by selecting the ObjectLandscapeTerrain node and viewing the Surfaces tab in parameters), so the car will be able to drive on it without any problems.Landscape Terrain默认启用了CollisionPhysics Intersections(你可以通过选择ObjectLandscapeTerrain节点并查看Surfaces标签验证),因此汽车可以直接在其上行驶,无需额外设置。

Details
细节#

No matter how large the textures used for the surface are, the data density still won't be enough for a terrain 5 kilometers on a side. The data density is too low when viewed from the surface.无论地表使用的纹理有多大,对于边长为 5 公里的地形来说,其数据密度仍然不够。从地面视角来看,细节分辨率太低。

One solution is to split the original high-resolution textures into a set of tiles and use them for creating a terrain. However, even with a total resolution of 65536×65536 pixels (8×8 tiles with the size of 8192×8192 each), the density of the texels will barely exceed 13 pixels per meter. This is also not enough.一种解决方案是将原始的高分辨率纹理拆分成若干图块并用于创建地形。但即使总分辨率达到65536×65536像素(即8×8个图块,每块大小为8192×8192),单位面积上的像素密度也仅略高于每米 13 像素,这仍然不够。

For high detailing of the surface we use terrain details — additional materials that can be mixed based on the terrain masks: the grass mask defines where the detailed grass texture will be located, the same is done for rocks, soil, sandstone, etc.为提高地表细节,我们使用地形细节层(details):这些是可以根据地形遮罩进行混合的附加材质。例如草地遮罩控制细节草纹理的分布区域,岩石、泥土、砂岩等也是如此。

注意
To view the terrain masks, go to Helpers → Show Landscape Data.要查看地形遮罩,请前往Helpers → Show Landscape Data

Select the ObjectLandscapeTerrain node and go to the Details parameter section. You can add as many details as you want for each mask:选择ObjectLandscapeTerrain节点并打开其Details参数部分。你可以为每个遮罩添加任意数量的细节层:

  1. After selecting a mask, click "+" on the panel to add a detail layer.选中某个遮罩后,点击面板上的"+"按钮添加一个细节层。

  2. Then click "+" on the detail material panel to add a new editable material.然后在该细节材质面板中再次点击"+"以添加一个可编辑材质。
  3. In the race/terrain/details/textures folder there is a set of textures to recreate different natural surfaces. Use the Albedo, Roughness and Height textures to make each masked area look unique.race/terrain/details/textures文件夹中包含了一组用于模拟各种自然表面的纹理。请使用Albedo、RoughnessHeight纹理,为每个遮罩区域打造独特外观。
  4. Pay specific attention to the following parameters:特别注意以下参数:

    • Size — the size of one tile of the detail. Higher values increase the layer size.Size:单个细节图块的尺寸。值越大,图层覆盖范围越广。
    • Scale — the intensity of the height displacement. Higher Scale values make the geometry irregularities more protruding.Scale:高度扰动的强度。值越大,几何凹凸越明显。

Customizing details is a completely artistic task. Usually at least one detail layer needs to be assigned to each mask in order to cover the entire terrain surface. Detail layers, as well as masks, can be swapped if a different order of layers is required.细节层的定制是一个完全美术导向的任务。通常每个遮罩至少应有一个细节图层,以覆盖整个地形表面。细节层(包括遮罩本身)也可以调整顺序,以适配需求。

For convenience, the project already contains ready-made materials for the details (race/terrain/details) that are to be assigned to the detail layers in the corresponding masks.为方便起见,项目中已经包含了准备好的细节材质(位于race/terrain/details),你只需将其分配到对应遮罩的细节图层中即可。

After customizing the details, the data density is much higher and the terrain looks more natural.完成细节设置后,数据密度显著提升,地形也更加真实自然。

注意
All terrain components, and masks in particular, can be edited using the built-in landscape editor. Switch to Landscape Paint Mode, select a layer to paint on, a terrain component (Albedo, Height, or one of the masks) and a brush, and try editing it manually by painting on the terrain surface. To save changes, simply switch back to Object Mode.所有地形组件,尤其是遮罩,都可以使用内置地形编辑器进行编辑。切换到Landscape Paint Mode(地形绘制模式),选择要绘制的图层和地形通道(Albedo、Height或某个遮罩),再选择画笔工具,在地形表面上进行手动编辑。要保存更改,只需切换回Object Mode即可。

Vegetation
植被#

To diversify the landscape, let's add vegetation. Use the ready-made tree and grass assets from the race/vegetation folder.为了让地形更加多样化,我们来添加植被。使用race/vegetation文件夹中提供的现成树木和草地资源。

Adding trees:添加树木:

  1. Right-click on the trees_clutter.node asset from the trees folder, select Place as Node Content in the context menu and add the asset content to the scene.右键点击trees文件夹中的trees_clutter.node资源,在上下文菜单中选择Place as Node Content,将其内容添加到场景中。
  2. In the World Nodes window, drag the trees_clutter node to ObjectLandscapeTerrain to make the trees children of the terrain, and reset the position to align the trees with the terrain (the terrain itself and the LandscapeLayerMap node are also located in the origin).World Nodes窗口中,将trees_clutter节点拖到ObjectLandscapeTerrain节点下,使其成为地形的子节点,并将位置重置,使树木与地形对齐(地形本身以及LandscapeLayerMap节点也都位于世界原点)。

  3. Trees (the trees_clutter node) are represented by the Mesh Clutter object that arranges polygonal meshes procedurally on a rectangular area according to the the specified parameters. In addition, this node is a child of the terrain object and the Intersection option is enabled in the object settings, so the trees automatically follow the surface of the terrain.树木(即trees_clutter节点)由Mesh Clutter对象表示,该对象可根据设定参数在矩形区域内程序化地分布网格模型。此外,由于该节点是地形对象的子节点,且在对象设置中启用了Intersection选项,因此树木会自动贴合地形表面。
  4. In the object settings, find the Mask Terrain parameter: use it to select the terrain mask that will be used to arrange procedural trees. It can be the Grass mask or any other mask at your choice.在对象设置中找到Mask Terrain参数:使用它选择要用于布置树木的地形遮罩层。可以选择Grass遮罩,或任意其他你希望使用的遮罩。
  5. Rendering multipolygonal trees at a great distance from the camera can significantly impact performance. To address this, the Grass object is added as a child node to the trees to handle rendering of impostors. This object has the same settings as the Mesh Clutter object, ensuring that each tree is replaced by its "photo" when viewed from a distance. In the Mask Terrain parameter of the Grass object's settings, select the same mask in the first of the four lists (since impostors only use one type of texture out of four possible) that was selected in the previous step.当摄像机距离较远时渲染多边形树木会显著影响性能。为了解决这个问题,在树木节点下添加了一个Grass对象,用于处理远距离 impostor(替身)渲染。该对象与Mesh Clutter对象具有相同的设置,确保每棵树在远处被其“照片”所替代。在Grass对象的设置中,Mask Terrain参数的四个遮罩列表中,在第一个位置选择与前一步相同的遮罩(因为 impostor 仅使用一个遮罩纹理)。

Add the contents of the grass/grass_clutter.node asset in the same way to generate grass on the terrain surface. Grass is also represented by Mesh Clutter objects (grass_close, grass_far) that procedurally arrange bunches of polygonal grass.以相同方式添加grass/grass_clutter.node资源的内容,在地形表面生成草地。草地同样由Mesh Clutter对象(grass_close, grass_far)表示,用于程序化分布一簇簇多边形草丛。

本页面上的信息适用于 UNIGINE 2.20 SDK.

最新更新: 2025-06-20
Build: ()