Adding a Multi file export terrain node

This node exports several files from a terrain. The images are exported as gray levels, each pixel having a value between 0 and 1. The generated images have the resolution of the terrain as its size, and the gray levels and scale of the heights (vertices with a 0 value will have their height set to the min value, and vertices with a 1 value will have their height set to the max value) determine the height of each point.

The advantage of exporting multiple files is to optimize the rendering times for very large terrains in an external engine where it is more practical to manage parts of the terrain in different files.

To add a node, right click in the Graph Editor and select Create Node  > Export  > Multi file export terrain.

Double click on the node to open its parameters:

Exporting a terrain to multiple files

To export a terrain to multiple files, set the following parameters:

  • File pattern: This is the formula used to name the files to export. The naming convention is important because the node aligns the terrain on a grid and where the first number is the X axis and the second one is the Y axis. Depending on the XY coordinates of the part of the terrain and the number of files to export, each exported file be named according to its XY coordinates, for example the top left part of a 2x2 terrain will have the name Group_0_0.png, the top right part Group_0_1.png, etc.

See Explanation about the formula for a detailed description about the formula.

Browse to the folder where want to save your files and copy the path.

In File pattern in the parameters dialog, paste the path and add a file name, for example here we add "Group" and then _$x_$y, where $x represents the position of the part of the terrain on the X axis and $y represents the Y axis.

  • File format: Choose the file format from the options available.
  • Range: Click User defined to set the Minimum height and Maximum heights or leave the default setting, Automatic.
  • Size of each file: Set the following parameters:
  • Width and height: Set the width and height in number of vertices.
  • Overlapping: Instant Terra displays the number of files to create based on this parameter.
    If overlapping is set to 0 the file is cut into parts, and the parts have nothing in common.



    If overlapping is set to 1, two contiguous parts will have a column or a line in common.



    If overlapping is set to 2, two contiguous parts will have 2 columns or 2 lines in common.



    etc.
  • Number of files: The number of files to export depends on the graph and the value of the overlapping parameter. This parameter is non-editable.
  • Click Export now to export the files.

A pop-up dialog displays the progress of the export.

Another popup-up dialog confirms the export.

The files are exported to the directory entered in the File pattern box.

Explanation about the formula

For the imported files, the node:

  • Replaces $y by 0, and finds the largest value of $x that exists for the files, i.e. input_$x_0.bmp. This determines one dimension of the grid of files, called X.
  • Replaces $x by 0, and finds the largest value of $y that exists for the files, i.e. input_0_$y.bmp. This determines the other dimension of the grid of files, called Y.
  • The node iterates on $y and $x and calculates the image size, i.e. width and height.

Each file is loaded, and forms the corresponding part of the final terrain.

The replacement rules in the file names (or directory) are:

  • $x is replaced by: 0, 1, ..., 10, 11, ...
  • $0x is replaced by: 00, 01, ..., 10, 11, ..., 100, ...
  • $00x is replaced by: 000, 001,..., 010, 011,..., 100,...
  • $000x is replaced by: 0000, 0001,..., 0010, 0011,..., 0100,..., 1000
  • $0000x is replaced by: 00000, 00001,..., 00010, 00011,..., 00100,..., 01000,..., 10000,...
  • $00000x is replaced by: 000000, 000001,..., 000010, 000011,..., 000100,..., 001000,...
  • Ditto for $y, $0y, $00y, $000y, $0000y, and $00000y.
  • The expressions above can be used:
    • In the name of the file and in the directory name.
    • In one or more copies.
    • Mixed (for both $X and $Y).

For example:

Expression Product names
terrain/$0x/$0y/file.bmp terrain/00/00/file.bmp
terrain/01/00/file.bmp
terrain/10/24/file.bmp
terrain/$0x/$0y/file_$x_$y.bmp terrain/00/00/file_0_0.bmp
terrain/01/00/file_1_0.bmp
terrain/10/24/file_10_24.bmp

Parameters

Parameter Use
File pattern Name and directory of the files to export
File format Format of the files to export
Range Sets the minimum and maximum heights of each file to export, either automatically or manually
Width and height Sets the width and height of each file to export
Overlapping Sets the number of rows or columns to overlap
Number of files Non-editable parameter displaying the number of files to export depending on the graph and overlapping

Copyright © 2018 · All Rights Reserved · Wysilab