VisualShaderNodeCustom
Virtual class to define custom VisualShaderNode
s for use in the Visual Shader Editor.
class VisualShaderNodeCustom
By inheriting this class you can create a custom VisualShader
script addon which will be automatically added to the Visual Shader Editor. The VisualShaderNode
’s behavior is defined by overriding the provided virtual methods.
In order for the node to be registered as an editor addon, you must use the @tool
annotation and provide a class_name
for your custom script. For example:
Superclasses
class VisualShaderNode
Base class for
VisualShader
nodes. Not related to scene nodes.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
func getOptionIndex(option: Int32
) -> Int32 Returns the selected index of the drop-down list option within a graph. You may use this function to define the specific behavior in the
_getCode(inputVars:outputVars:mode:type:)
or_getGlobalCode(mode:)
.
Show implementation details (21)
Hide implementation details
func _getCategory(
) -> String Override this method to define the path to the associated custom node in the Visual Shader Editor’s members dialog. The path may look like
"MyGame/MyFunctions/Noise"
.func _getCode(inputVars: VariantCollection<String>, outputVars: VariantCollection<String>, mode: Shader.Mode, type: VisualShader.GType
) -> String Override this method to define the actual shader code of the associated custom node. The shader code should be returned as a string, which can have multiple lines (the
"""
multiline string construct can be used for convenience).func _getDefaultInputPort(type: VisualShaderNode.PortType
) -> Int32 Override this method to define the input port which should be connected by default when this node is created as a result of dragging a connection from an existing node to the empty space on the graph.
func _getDescription(
) -> String Override this method to define the description of the associated custom node in the Visual Shader Editor’s members dialog.
func _getFuncCode(mode: Shader.Mode, type: VisualShader.GType
) -> String Override this method to add a shader code to the beginning of each shader function (once). The shader code should be returned as a string, which can have multiple lines (the
"""
multiline string construct can be used for convenience).func _getGlobalCode(mode: Shader.Mode
) -> String Override this method to add shader code on top of the global shader, to define your own standard library of reusable methods, varyings, constants, uniforms, etc. The shader code should be returned as a string, which can have multiple lines (the
"""
multiline string construct can be used for convenience).func _getInputPortCount(
) -> Int32 Override this method to define the number of input ports of the associated custom node.
func _getInputPortDefaultValue(port: Int32
) -> Variant Override this method to define the default value for the specified input port. Prefer use this over
setInputPortDefaultValue(port:value:prevValue:)
.func _getInputPortName(port: Int32
) -> String Override this method to define the names of input ports of the associated custom node. The names are used both for the input slots in the editor and as identifiers in the shader code, and are passed in the
input_vars
array in_getCode(inputVars:outputVars:mode:type:)
.func _getInputPortType(port: Int32
) -> VisualShaderNode.PortType Override this method to define the returned type of each input port of the associated custom node (see
VisualShaderNode.PortType
for possible types).func _getName(
) -> String Override this method to define the name of the associated custom node in the Visual Shader Editor’s members dialog and graph.
func _getOutputPortCount(
) -> Int32 Override this method to define the number of output ports of the associated custom node.
func _getOutputPortName(port: Int32
) -> String Override this method to define the names of output ports of the associated custom node. The names are used both for the output slots in the editor and as identifiers in the shader code, and are passed in the
output_vars
array in_getCode(inputVars:outputVars:mode:type:)
.func _getOutputPortType(port: Int32
) -> VisualShaderNode.PortType Override this method to define the returned type of each output port of the associated custom node (see
VisualShaderNode.PortType
for possible types).func _getPropertyCount(
) -> Int32 Override this method to define the number of the properties.
func _getPropertyDefaultIndex(Int32
) -> Int32 Override this method to define the default index of the property of the associated custom node.
func _getPropertyName(index: Int32
) -> String Override this method to define the names of the property of the associated custom node.
func _getPropertyOptions(index: Int32
) -> PackedStringArray Override this method to define the options inside the drop-down list property of the associated custom node.
func _getReturnIconType(
) -> VisualShaderNode.PortType Override this method to define the return icon of the associated custom node in the Visual Shader Editor’s members dialog.
func _isAvailable(mode: Shader.Mode, type: VisualShader.GType
) -> Bool Override this method to prevent the node to be visible in the member dialog for the certain
mode
(seeShader.Mode
) and/ortype
(seeVisualShader.GType
).func _isHighend(
) -> Bool Override this method to enable high-end mark in the Visual Shader Editor’s members dialog.