shown in other instead.
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.
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
- Underground Pedestal is always 2 meters down from the terrain 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 terrain 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.
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.
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 FloorSolid texture for Ground Floor
For Upper Floors, a single texture for a wall with openings is applied. The texture height is usually a multiple of the Floor Height. It can be a multiple of the two, three, etc. Floor Height, however, it shouldn't exceed the height of the Upper Floors part.Texture with openings for Upper FloorsSolid 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 meters 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 textureDetail albedo texture
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:
1. Adding a Vector Data Source#
Currently, Sandworm allows using only offline vector data source for generation.
In the Sources panel, add a new vector data layer.
Clicking on Vector opens the window for adding slots. Slots are designed to organize data.
- Clicking on + Add Layer provides the toolset for uploading vector data.
In the Parameters panel, define the type of Data Source to be used: Assets or External Files. Currently only *.shp and *.geojson are supported as assets. Therefore, if you have other types of files, you can try to add them as External Files.
- In the window that opens, select the set of files to be used as vector data.
When the vector data is added, its image is displayed atop all the layers in the Preview panel (the order of layers display may be changed), and the Vector layer parameters become available.
2. Specifying Filters for Buildings#
The Filter is in fact a set of rules used to pick the specific data from the list of all available vector data. The rules are created using the Attributes. Only the objects that fit to the requirements of every attribute are generated based on this filter.
Filters are created as follows:
Click the Add button in the Tags window of the Parameters panel.
Double-click on the tag to specify a tag name. To remove a tag use Remove button. You can add as many filters as necessary.
The Share button allows shared use of the filter among vector data layers. Select the vector data layer that will share this filter in the pop-up window. Changes in a shared filter will be applied to it in all vector data layers.
- Select a slot from those created by you (Sources -> Vector). Slots are designed to organize data into different terrain masks.
For each filter, set an attribute (or attributes) to filter certain data from the vector source. The required data is filtered using the attribute values and suitable operator. Autocomplete is available. You can type in attribute names and values.
The available operators are: =, !=, >, <, ANY. ANY generates all the objects that have any value assigned for the selected attribute.
Double-clicking on an value in the table adds it to the attribute value field.
To add more attributes, use the "+" (plus) button. You can add as many attributes for one filter as necessary. It is possible to set AND and OR relations between the atributes in the filter.
To remove a filter, use the button to the right of the attribute expression.
3. Specifying Parameters of Buildings#
In this step, we are going to set the parameters for buildings that will be generated on the terrain according to the filtered data.
On the Sources panel, click + Add Object.
In the drop-down, select the type of object you are going to generate according to the slot data. In our case it is Buildings. Click Import.
Set the following object parameters:
A slot created by you to organize data filters.
|Enabled||When toggled on, the objects of this type will be generated. When toggled off, the objects of this type are not generated and won't exist in the world containing the generated terrain.|
|Floor Number Name||
The name of the column where the number of floors is indicated, from the Attributes table.
|Floor Height (m)||The height of a floor in the generated buildings. The default value is 3 meters.|
|Ground Floor Offset (m)||The height of pedestal. The default value is 1 meter.|
|Split Length (km)||
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 Export 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 Mesh objects, 100x100 km each.
|Floors Per Texture||
The number of Upper Floors for which a single texture is applied:
|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.|
4. Generating Buildings#