VoxelGraphFunction
Graph for generating or processing series of 3D values.
Graph for generating or processing series of 3D values.
Contains a graph that can be used to process series of values, such as voxel positions (when used as main function of a generator), or to be re-used into other graphs (like a sub-graph).
Currently this class only stores a graph, it cannot run actual processing on its own. It is usually embedded into another resource which then makes use of the graph in a specific way.
To generate voxels with it, see VoxelGeneratorGraph.
Nodes can be connected together from their outputs to the inputs of next nodes. Unconnected inputs can have default values or default implicit connections.
Nodes can also have "parameters" which are constants setup per node.
Nodes come in 3 main families: inputs (only have outputs), outputs (only have inputs), and others (which have both inputs and output to do some calculation).
Entity types are identified with the enum VoxelGraphFunction.NodeTypeId. This enum shouldn't be used in persistent contexts (such as save files) as its values may change between versions.
Graphs can only process 32-bit floating point values.
Description of node types is present in the graph editor node dialog, or at [url]https://voxel-tools.readthedocs.io/en/latest/graph_nodes[/url].
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
VoxelGraphFunctionConstructor
public VoxelGraphFunction();Properties3
GraphDataProperty
public Reckfell.Collections.Dictionary GraphData { get; set; }InputDefinitionsProperty
public Reckfell.Collections.Array InputDefinitions { get; set; }OutputDefinitionsProperty
public Reckfell.Collections.Array OutputDefinitions { get; set; }Methods34
AddConnectionvoid
public void AddConnection(uint srcNodeId, uint srcPortIndex, uint dstNodeId, uint dstPortIndex);Connects the outputs of a node to the input of another node. Connecting a node to itself, or in a way that can lead it back to itself, is not supported.
| Name | Type | Default |
|---|---|---|
srcNodeId | uint | — |
srcPortIndex | uint | — |
dstNodeId | uint | — |
dstPortIndex | uint | — |
CanConnectbool
public bool CanConnect(uint srcNodeId, uint srcPortIndex, uint dstNodeId, uint dstPortIndex);Tests if two ports can be connected together.
| Name | Type | Default |
|---|---|---|
srcNodeId | uint | — |
srcPortIndex | uint | — |
dstNodeId | uint | — |
dstPortIndex | uint | — |
boolClearvoid
public void Clear();Removes all nodes from the graph. Input and output definitions will not be cleared.
CreateFunctionNodeuint
public uint CreateFunctionNode(VoxelGraphFunction function, Vector2 position, uint id = 0);Creates a node based on an existing graph (creates a "sub-graph instance").
| Name | Type | Default |
|---|---|---|
function | VoxelGraphFunction | — |
position | Vector2 | — |
id | uint | 0 |
uintCreateNodeuint
public uint CreateNode(VoxelGraphFunction.NodeTypeId typeId, Vector2 position, uint id = 0);Creates a graph node of a given type at a specific visual position.
The position parameter does not affect how the graph will perform, however it helps organizing nodes.
An optional ID can be specified. If left to 0, the ID will be generated.
This function then returns the ID of the node, which may be useful to modify other properties of the node later.
| Name | Type | Default |
|---|---|---|
typeId | VoxelGraphFunction.NodeTypeId | — |
position | Vector2 | — |
id | uint | 0 |
uintFindNodeByNameuint
public uint FindNodeByName(StringName name);Finds a node with the specified name and returns its ID. If the node is not found, returns 0.
| Name | Type | Default |
|---|---|---|
name | StringName | — |
uintGetConnectionsReckfell.Collections.Array
public Reckfell.Collections.Array GetConnections();Gets an array describing all connections between nodes. The array has the following format:
[
{
"src_node_id": int,
"src_port_index": int,
"dst_node_id": int,
"dst_port_index": int
},
...
]Reckfell.Collections.ArrayGetNodeDefaultInputVariant
public Variant GetNodeDefaultInput(uint nodeId, int inputIndex);| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
inputIndex | int | — |
VariantGetNodeDefaultInputsAutoconnectbool
public bool GetNodeDefaultInputsAutoconnect(uint nodeId);| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
boolGetNodeGuiPositionVector2
public Vector2 GetNodeGuiPosition(uint nodeId);Get the position of the node in the graph editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
Vector2GetNodeGuiSizeVector2
public Vector2 GetNodeGuiSize(uint nodeId);Get the size of the node in the graph editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
Vector2GetNodeIdsint[]
public int[] GetNodeIds();Get a list of IDs of all the nodes in the graph. Note: the order in which IDs are returned is not guaranteed to be the same after nodes are added or removed.
int[]GetNodeInputIndexint
public int GetNodeInputIndex(uint nodeId, string inputName);Gets the input index of a node from the input's name.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
inputName | string | — |
intGetNodeNameStringName
public StringName GetNodeName(uint nodeId);| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
StringNameGetNodeOutputIndexint
public int GetNodeOutputIndex(uint nodeId, string outputName);Gets the output index of a node from the output's name.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
outputName | string | — |
intGetNodeParamVariant
public Variant GetNodeParam(uint nodeId, int paramIndex);Get a parameter of a node. The parameter index corresponds to the position that parameter comes in when seen in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
paramIndex | int | — |
VariantGetNodeTypeCountint
public int GetNodeTypeCount();intGetNodeTypeIdVoxelGraphFunction.NodeTypeId
public VoxelGraphFunction.NodeTypeId GetNodeTypeId(uint nodeId);Get the ID of the type of a node in the graph.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
VoxelGraphFunction.NodeTypeIdGetNodeTypeInfoReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary GetNodeTypeInfo(int typeId);| Name | Type | Default |
|---|---|---|
typeId | int | — |
Reckfell.Collections.DictionaryPasteGraphWithPreGeneratedIds2 overloads
public void PasteGraphWithPreGeneratedIds(VoxelGraphFunction graph, int[] nodeIds, Vector2 guiOffset);Copies nodes into another graph, and connections between them only.
Resources in node parameters will be duplicated if they don't have a file path.
If node_ids is provided with non-zero size, defines the IDs copied nodes will have in the destination graph, in the same order as VoxelGraphFunction.GetNodeIds from the source graph. The array must have the same size as the number of copied nodes and IDs must not already exist in the destination graph. If the array is empty, they will be generated instead.
| Name | Type | Default |
|---|---|---|
graph | VoxelGraphFunction | — |
nodeIds | int[] | — |
guiOffset | Vector2 | — |
public void PasteGraphWithPreGeneratedIds(VoxelGraphFunction graph, ReadOnlySpan<int> nodeIds, Vector2 guiOffset);Copies nodes into another graph, and connections between them only.
Resources in node parameters will be duplicated if they don't have a file path.
If node_ids is provided with non-zero size, defines the IDs copied nodes will have in the destination graph, in the same order as VoxelGraphFunction.GetNodeIds from the source graph. The array must have the same size as the number of copied nodes and IDs must not already exist in the destination graph. If the array is empty, they will be generated instead.
| Name | Type | Default |
|---|---|---|
graph | VoxelGraphFunction | — |
nodeIds | ReadOnlySpan<int> | — |
guiOffset | Vector2 | — |
RemoveConnectionvoid
public void RemoveConnection(uint srcNodeId, uint srcPortIndex, uint dstNodeId, uint dstPortIndex);Removes an existing connection between two nodes of the graph.
| Name | Type | Default |
|---|---|---|
srcNodeId | uint | — |
srcPortIndex | uint | — |
dstNodeId | uint | — |
dstPortIndex | uint | — |
RemoveNodevoid
public void RemoveNode(uint nodeId);Removes a node from the graph.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
SetExpressionNodeInputs2 overloads
public void SetExpressionNodeInputs(uint nodeId, ReadOnlySpan<string> names);Configures inputs for an Expression node. names is the list of input names used in the expression.
If you create an Expression node from code, you should call this method afterwards.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
names | ReadOnlySpan<string> | — |
public void SetExpressionNodeInputs(uint nodeId, string[] names);Configures inputs for an Expression node. names is the list of input names used in the expression.
If you create an Expression node from code, you should call this method afterwards.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
names | string[] | — |
SetNodeDefaultInputvoid
public void SetNodeDefaultInput(uint nodeId, int inputIndex, Variant value);Sets the value an input of a node will have when it is left unconnected.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
inputIndex | int | — |
value | Variant | — |
SetNodeDefaultInputByNamevoid
public void SetNodeDefaultInputByName(uint nodeId, string inputName, Variant value);Sets the value an input of a node will have when it is left unconnected. The input is specified by its name as seen in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
inputName | string | — |
value | Variant | — |
SetNodeDefaultInputsAutoconnectvoid
public void SetNodeDefaultInputsAutoconnect(uint nodeId, bool enabled);Sets wether a node input with no inbound connection will automatically create a default connection when the graph is compiled. This is only available on specific nodes (for example, 2D or 3D noise defaults to XYZ inputs). On other nodes, it has no effect.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
enabled | bool | — |
SetNodeGuiPositionvoid
public void SetNodeGuiPosition(uint nodeId, Vector2 position);Sets the visual position of a node of the graph, as it will appear in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
position | Vector2 | — |
SetNodeGuiSizevoid
public void SetNodeGuiSize(uint nodeId, Vector2 size);Sets the visual size of a node of the graph, as it will appear in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
size | Vector2 | — |
SetNodeNamevoid
public void SetNodeName(uint nodeId, StringName name);Sets a custom name for a node.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
name | StringName | — |
SetNodeParamvoid
public void SetNodeParam(uint nodeId, int paramIndex, Variant value);Set a parameter of a node. The parameter index corresponds to the position that parameter comes in when seen in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
paramIndex | int | — |
value | Variant | — |
SetNodeParamByNamevoid
public void SetNodeParamByName(uint nodeId, string paramName, Variant value);Set a parameter of a node, using its name as it appears in the editor.
| Name | Type | Default |
|---|---|---|
nodeId | uint | — |
paramName | string | — |
value | Variant | — |
SetNodeParamNullvoid
public void SetNodeParamNull(int nodeId, int paramIndex);Set a parameter of a node to null. This method only exists to workaround an issue with Reckfell's UndoRedo system. Prefer using VoxelGraphFunction.SetNodeParam.
| Name | Type | Default |
|---|---|---|
nodeId | int | — |
paramIndex | int | — |
Signals and events2
CompiledEvent
public event Action Compiled;Emitted after the graph finished compiling, even if compiling failed.
NodeNameChangedEvent
public event VoxelGraphFunction.NodeNameChangedEventHandler NodeNameChanged;| Name | Type | Default |
|---|---|---|
nodeId | long | — |