VisualShaderNodeCustom

package
v0.0.0-...-e10d1cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

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:

package main

import "graphics.gd/classdb/VisualShaderNodeCustom"

type MyVisualShaderNodeCustom struct {
	VisualShaderNodeCustom.Extension[MyVisualShaderNodeCustom]
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsVisualShaderNodeCustom() Instance
}

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsVisualShaderNode

func (self *Extension[T]) AsVisualShaderNode() VisualShaderNode.Instance

func (*Extension[T]) AsVisualShaderNodeCustom

func (self *Extension[T]) AsVisualShaderNodeCustom() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.VisualShaderNodeCustom

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsVisualShaderNode

func (self Instance) AsVisualShaderNode() VisualShaderNode.Instance

func (Instance) AsVisualShaderNodeCustom

func (self Instance) AsVisualShaderNodeCustom() Instance

func (Instance) GetOptionIndex

func (self Instance) GetOptionIndex(option int) int

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 or GetGlobalCode.

func (Instance) ID

func (self Instance) ID() ID

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Interface

type Interface interface {
	// Override this method to define the name of the associated custom node in the Visual Shader Editor's members dialog and graph.
	//
	// Defining this method is optional, but recommended. If not overridden, the node will be named as "Unnamed".
	GetName() string
	// Override this method to define the description of the associated custom node in the Visual Shader Editor's members dialog.
	//
	// Defining this method is optional.
	GetDescription() 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".
	//
	// Defining this method is optional. If not overridden, the node will be filed under the "Addons" category.
	GetCategory() string
	// Override this method to define the return icon of the associated custom node in the Visual Shader Editor's members dialog.
	//
	// Defining this method is optional. If not overridden, no return icon is shown.
	GetReturnIconType() VisualShaderNode.PortType
	// Override this method to define the number of input ports of the associated custom node.
	//
	// Defining this method is required. If not overridden, the node has no input ports.
	GetInputPortCount() int
	// Override this method to define the returned type of each input port of the associated custom node.
	//
	// Defining this method is optional, but recommended. If not overridden, input ports will return the [Visualshadernode.PortTypeScalar] type.
	GetInputPortType(port int) VisualShaderNode.PortType
	// 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].
	//
	// Defining this method is optional, but recommended. If not overridden, input ports are named as "in" + str(port).
	//
	// [GetCode]: https://pkg.go.dev/graphics.gd/classdb/VisualShaderNodeCustom#Interface
	GetInputPortName(port int) string
	// Override this method to define the default value for the specified input port. Prefer use this over [VisualShaderNode.SetInputPortDefaultValue].
	//
	// Defining this method is required. If not overridden, the node has no default values for their input ports.
	//
	// [VisualShaderNode.SetInputPortDefaultValue]: https://pkg.go.dev/graphics.gd/classdb/VisualShaderNode#Instance.SetInputPortDefaultValue
	GetInputPortDefaultValue(port int) any
	// 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.
	//
	// Defining this method is optional. If not overridden, the connection will be created to the first valid port.
	GetDefaultInputPort(atype VisualShaderNode.PortType) int
	// Override this method to define the number of output ports of the associated custom node.
	//
	// Defining this method is required. If not overridden, the node has no output ports.
	GetOutputPortCount() int
	// Override this method to define the returned type of each output port of the associated custom node.
	//
	// Defining this method is optional, but recommended. If not overridden, output ports will return the [Visualshadernode.PortTypeScalar] type.
	GetOutputPortType(port int) VisualShaderNode.PortType
	// 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].
	//
	// Defining this method is optional, but recommended. If not overridden, output ports are named as "out" + str(port).
	//
	// [GetCode]: https://pkg.go.dev/graphics.gd/classdb/VisualShaderNodeCustom#Interface
	GetOutputPortName(port int) string
	// Override this method to define the number of the properties.
	//
	// Defining this method is optional.
	GetPropertyCount() int
	// Override this method to define the names of the property of the associated custom node.
	//
	// Defining this method is optional.
	GetPropertyName(index int) string
	// Override this method to define the default index of the property of the associated custom node.
	//
	// Defining this method is optional.
	GetPropertyDefaultIndex(index int) int
	// Override this method to define the options inside the drop-down list property of the associated custom node.
	//
	// Defining this method is optional.
	GetPropertyOptions(index int) []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).
	//
	// The 'input_vars' and 'output_vars' arrays contain the string names of the various input and output variables, as defined by _get_input_* and _get_output_* virtual methods in this class.
	//
	// The output ports can be assigned values in the shader code. For example, return output_vars[0] + " = " + input_vars[0] + ";".
	//
	// You can customize the generated code based on the shader 'mode' and/or 'type'.
	//
	// Defining this method is required.
	GetCode(input_vars []string, output_vars []string, mode Shader.Mode, atype VisualShader.Type) 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).
	//
	// If there are multiple custom nodes of different types which use this feature the order of each insertion is undefined.
	//
	// You can customize the generated code based on the shader 'mode' and/or 'type'.
	//
	// Defining this method is optional.
	GetFuncCode(mode Shader.Mode, atype VisualShader.Type) 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).
	//
	// Be careful with this functionality as it can cause name conflicts with other custom nodes, so be sure to give the defined entities unique names.
	//
	// You can customize the generated code based on the shader 'mode'.
	//
	// Defining this method is optional.
	GetGlobalCode(mode Shader.Mode) string
	// Override this method to enable high-end mark in the Visual Shader Editor's members dialog.
	//
	// Defining this method is optional. If not overridden, it's false.
	IsHighend() bool
	// Override this method to prevent the node to be visible in the member dialog for the certain 'mode' and/or 'type'.
	//
	// Defining this method is optional. If not overridden, it's true.
	IsAvailable(mode Shader.Mode, atype VisualShader.Type) bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL