GPU nodes are custom nodes based on a GPU script used to interact with the data handled by Instant Terra.
The node is displayed in the graph with the default settings (an input terrain, a parameter, and an output terrain).
The node appears as invalid as it is not yet
connected to any input terrain. Connect it to any terrain to view
the default GPU node working.
Right-click the node to show the contextual menu then select Edit custom node.
The custom node's graph window opens.
This is where you will define the inputs, outputs and parameter (including manipulators) nodes, and also enter the GPU script.
The GPU script node is created from a default sample script. This default custom node has one input terrain, one output terrain, and one parameter: Strength.
Select the GPU script node to open its properties and the script editor.
When the node has no input terrain or mask (the node is a generator), specify the size (width, height, quad size); otherwise, these options are disabled and the values are retrieved from the input terrain / mask and the output grids.
Use C++ comments, starting with //, or use Python comments, starting with #.
Any new node, input, output or parameter triggers a new connector on the GPU Script node.
Inputs and outputs are referenced by the node's name.
The script is run for each vertex.
When several input grids are of different sizes, the size of the first grid is used for the output grids and the other input grids are scaled so their sizes match the first input's grid. A different scale may be applied on X and on Y.
Define as many local variables as needed in the script. All local variables are the float type.
The following predefined variables are available in the script:
For example, for a 2048 x 1024 vertices terrain with a 2 meters quad size, the values of the predefined variables are as follows:
The complete list of available functions can be found in the Functions list page.
Select this option if you need to read the values of a vertex that is not the current vertex, inside an input grid.
To read a vertex in an input grid, provide its coordinates as a distance in meters from the current vertex.
If a script compiles with this option unchecked, it
will not compile when the option is checked as you need to replace
Input by Input[0,0].
This option may slow down the performance.
To remain GPU compatible, only vertices located at
a maximum distance of 1023 vertices. are read.
- For a quad size of 1 meter, the maximum distance to read a vertex
is 1023 meters.
- For a quad size of 0.5 meter, the maximum distance to read a
vertex if 1023 x 0.5 = 511.5 meters.
This option is visible only when "Can access other points" is checked.
When this option is checked, it is possible to access ANY
vertex* in an input terrain or mask. This raises the limitation to
the distance of 1023 vertices from the current vertex.
(*currently limited to 8192 x 8192 vertices)
This option may slow down the performances.
Select this option if you need to use the minimum or maximum values of an input grid.
Use the following functions:
Minimum(InputName)
Maximum(InputName)
This option may slow down the performance.
Once your script ready, compile it by clicking the Compile button below the text editor. Instant Terra checks the code syntax then runs the script. While running, a Stop button is shown to let you stop the execution of the script.
In case of any error while compiling or running, a message is displayed under the Compile button, with information about the error.
Copyright © 2022 · All Rights Reserved · Wysilab