Video Tutorials
How To
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Light Sources
World Objects
Sound Objects
Pathfinding Objects
Setting Up Development Environment
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
Double Precision Coordinates
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Art Samples

Generating Buildings

The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Engineering / Sim SDK edition to use it.

Sandworm allows procedural generation of buildings based on shapes stored in the vector data sources. This article reviews the general workflow as well as the main concepts of the buildings composition to give a deeper understanding of how the assets should be prepared.

Main Concepts#

For the sake of generation of buildings, we differentiate between the following two types of buildings:

  • Single-storey buildings, which have only one floor
  • Multi-storey buildings, which have two or more floors

Conceptual representation of single-storey and multi-storey buildings
  • Underground Pedestal is always 2 meters down from the landscape level. This value is hardcoded and cannot be changed.
  • The Pedestal height is defined by the Ground floor offset value and is 1 meter high above landscape by default.
  • The Ground Floor height is defined by the Floor height value and is 3 meters high by default.
  • The height of Upper Floors equals Number of Upper Floors * Floor height.

Buildings Texturing#

UNIGINE provides a set of built-in materials for generated buildings: they are inherited from mesh_base and named according to the rules. You can also create your custom textures and set up materials. However, your textures should meet a set of requirements described below.

There are four types of textures that should be prepared for a building: a texture for the basement, a texture for the wall with openings (doors and windows), a texture for the solid wall, and a texture for the roof. The UV map of each part of the building depends on the size of the wall segment that is shown on the texture.

Textures for walls differ depending on the part of the building they are applied to: if a texture is applied to Basement, it should depict Pedestal and Underground Pedestal.
  • For Underground Pedestal and Pedestal, a single texture for a wall is applied. The texture height should correspond to the height of all these parts (in sum).

    Texture for Underground Pedestal and Pedestal (Basement)
  • For the ground floor, an individual texture is applied. The texture height should correspond to the ground floor height.

    Texture with openings for Ground Floor
    Solid texture for Ground Floor
  • For Upper Floors, a single texture for a wall with openings is applied. The texture height is usually multiple of the floor height. It can be multiple of the two, three, etc. floors height, however, it shouldn't exceed the height of the Upper Floors part.
    Texture with openings for Upper Floors
    Solid texture for Upper Floors
  • If the wall width is less than the floor height, a segment of the texture with openings does not fit into this space properly, and the texture for a solid wall is applied.
  • If the wall width is more than the floor height, the wall surface is split into two parts:
    • The first part is tiled with a texture with openings. Its width is multiple of the floor height.
    • The second part, where the texture with openings does not fit, is tiled with the solid texture.

    For example, we have a two-storey building with the floor height of 3 meters. The sufrace of the second floor wall is 10.5 meters wide and is divided as follows:

    The texture for a wall with openings is applied to each 3*3 m segment (based on the floor height value). For the rest of the wall, the solid texture is applied.

  • For Roof, two textures should be applied: the base and detail albedo textures. Using the detail texture allows you to diversify colors of roofs with the same material: set up details rendering (blending, masking, UV mapping, shading parameters of the texture) for the Roof material to achieve the required result.
    Base albedo texture
    Detail albedo texture

Materials Naming#

For materials to be correctly applied by Sandworm to the generated buildings, follow these rules:

  • Each building category should have a separate base material inherited from mesh_base. This material is used as the material for the Ground Floor wall with doors and windows.
    For this material, a texture depicting the Ground Floor should be used.
    The other materials applied to different parts of the same building are inherited from this one. The base material can have any desired name.
    When specifying parameters of the buildings, only the base material is specified: its child materials are loaded automatically.
  • Materials for the other parts of the building should be inherited from the parent material described in the previous paragraph and use the following name postfixes:
    • _basement — a material for Pedestal and Underground Pedestal.
    • _level_1_blank — a material for Ground Floor wall without doors and windows.
    • _level_2_complex — materials for Upper Floors walls with doors and windows.
    • _level_2_blank — materials for Upper Floors walls without doors and windows.
    • _roof — a material for Roof.

For example, if you have 2 types of buildings that should have different materials, set up the following hierarchy:

Hierarchy of materials for buildings

1. Adding a Vector Data Source#

This step is the same as Adding a Vector Data Source for point objects.

2. Specifying Tags to Filter Buildings#

This step is the same as Specifying Tags to Filter Point Objects.

3. Specifying Parameters of Buildings#

In this step, we are going to set the parameters for buildings that will be generated on the landscape according to the data filtered by the tag.

In the Objects window, click Add to add the object that will be generated on the landscape based on the vector data specified for it. The dialog window will open. Set Type: Buildings to see these settings:

Set the following object parameters:

Name The object's name, which is displayed in the Objects list in Sandworm and in World Nodes when the landscape is generated.
Tag The tag for the selected object from the list of created tags.
Type Type of the vector object to be generated. In this case, we are generating Buildings.
Floor Number Tag The tag that is used to sort out from the vector source the buildings with the required number of floors.
If set to none, all buildings will be generated as single-floor buildings.
Floor Height The height of a floor in the generated buildings. The default value is 3 meters.
Ground Floor Offset The height of pedestal. The default value is 1 meter.
Split Length The size of the grid cell by which the generated geometry will be divided. Geometry of each cell is represented as a separate ObjectMeshStatic object. If the specified value exceeds or equals to the size of the Play Area, a single static mesh will be generated. For example, if you specify 100 and have a 1000x1000 km area, the buildings will be generated as 10 separate static meshes, 100x100 km each.
Floors Per Texture The number of Upper Floors for which a single texture is applied:
  • If the texture height corresponds to the height of a single floor, this value should remain 1. The texture will be applied for each floor.
  • If the texture height corresponds to the height of two/three/etc. floors, this value should be set to 2/3/etc. The texture will be applied for every two/three/etc. floors.
  • If the texture height is equal to the height of the Upper Floors part, this value should be equal to the number of Upper Floors.
Base Material Material applied to the buildings tagged to the basic object. The default material for buildings is already set. If you want to change it to a custom materal, ensure that the materials are named correctly.
Min Visibility Minimum visibility distance from the camera at which generated objects (ObjectMeshStatic) start to appear on the screen. By default, this value is -inf.
Max Visibility Maximum visibility distance at which generated objects (ObjectMeshStatic) are no longer fully visible: they can either disappear completely or start to fade out. By default, this value is inf.
Min Fade Minimum fade distance, over which generated objects (ObjectMeshStatic) fade in until they are completely visible. Along this distance, the engine automatically interpolates the level of detail from alpha of 0.0 (completely invisible) to 1.0 (completely visible). Fading in starts when the camera has reached the minimum visibility distance and is in the full visibility range.
Max Fade Maximum fade distance, over which generated objects (ObjectMeshStatic) fade out until they are completely invisible. Fading out starts when the camera has reached the maximum visibility distance and is out of the full visibility range.

If you introduce any changes into created objects, click Apply to update them immediately.

4. Generating Buildings#

Now you can generate (or regenerate) the landscape that contains these buildings by clicking the Generate button.

Generated buildings
Last update: 2021-02-17