Attention

You are reading the latest (unstable) version of this documentation, which may document features not available or compatible with Godot 3.x.

Work in progress

Godot documentation is being updated to reflect the latest changes in version 4.0. Some documentation pages may still state outdated information. This banner will tell you if you're reading one of such pages.

The contents of this page are up to date. If you can still find outdated information, please open an issue.

VisualShaderNode

Inherits: Resource < RefCounted < Object

Inherited By: VisualShaderNodeBillboard, VisualShaderNodeClamp, VisualShaderNodeColorFunc, VisualShaderNodeColorOp, VisualShaderNodeCompare, VisualShaderNodeConstant, VisualShaderNodeCubemap, VisualShaderNodeCustom, VisualShaderNodeDerivativeFunc, VisualShaderNodeDeterminant, VisualShaderNodeDistanceFade, VisualShaderNodeDotProduct, VisualShaderNodeFloatFunc, VisualShaderNodeFloatOp, VisualShaderNodeFresnel, VisualShaderNodeIf, VisualShaderNodeInput, VisualShaderNodeIntFunc, VisualShaderNodeIntOp, VisualShaderNodeIs, VisualShaderNodeLinearSceneDepth, VisualShaderNodeMix, VisualShaderNodeMultiplyAdd, VisualShaderNodeOuterProduct, VisualShaderNodeOutput, VisualShaderNodeParameter, VisualShaderNodeParameterRef, VisualShaderNodeParticleAccelerator, VisualShaderNodeParticleConeVelocity, VisualShaderNodeParticleEmit, VisualShaderNodeParticleEmitter, VisualShaderNodeParticleMultiplyByAxisAngle, VisualShaderNodeParticleRandomness, VisualShaderNodeProximityFade, VisualShaderNodeRandomRange, VisualShaderNodeRemap, VisualShaderNodeResizableBase, VisualShaderNodeSample3D, VisualShaderNodeScreenUVToSDF, VisualShaderNodeSDFRaymarch, VisualShaderNodeSDFToScreenUV, VisualShaderNodeSmoothStep, VisualShaderNodeStep, VisualShaderNodeSwitch, VisualShaderNodeTexture, VisualShaderNodeTextureSDF, VisualShaderNodeTextureSDFNormal, VisualShaderNodeTransformCompose, VisualShaderNodeTransformDecompose, VisualShaderNodeTransformFunc, VisualShaderNodeTransformOp, VisualShaderNodeTransformVecMult, VisualShaderNodeUIntFunc, VisualShaderNodeUIntOp, VisualShaderNodeUVFunc, VisualShaderNodeUVPolarCoord, VisualShaderNodeVarying, VisualShaderNodeVectorBase

Base class for nodes in a visual shader graph.

Description

Visual shader graphs consist of various nodes. Each node in the graph is a separate object and they are represented as a rectangular boxes with title and a set of properties. Each node has also connection ports that allow to connect it to another nodes and control the flow of the shader.

Tutorials

Properties

int

output_port_for_preview

-1

Methods

void

clear_default_input_values ( )

Array

get_default_input_values ( ) const

Variant

get_input_port_default_value ( int port ) const

void

remove_input_port_default_value ( int port )

void

set_default_input_values ( Array values )

void

set_input_port_default_value ( int port, Variant value, Variant prev_value=null )


Enumerations

enum PortType:

PortType PORT_TYPE_SCALAR = 0

Floating-point scalar. Translated to float type in shader code.

PortType PORT_TYPE_SCALAR_INT = 1

Integer scalar. Translated to int type in shader code.

PortType PORT_TYPE_SCALAR_UINT = 2

Unsigned integer scalar. Translated to uint type in shader code.

PortType PORT_TYPE_VECTOR_2D = 3

2D vector of floating-point values. Translated to vec2 type in shader code.

PortType PORT_TYPE_VECTOR_3D = 4

3D vector of floating-point values. Translated to vec3 type in shader code.

PortType PORT_TYPE_VECTOR_4D = 5

4D vector of floating-point values. Translated to vec4 type in shader code.

PortType PORT_TYPE_BOOLEAN = 6

Boolean type. Translated to bool type in shader code.

PortType PORT_TYPE_TRANSFORM = 7

Transform type. Translated to mat4 type in shader code.

PortType PORT_TYPE_SAMPLER = 8

Sampler type. Translated to reference of sampler uniform in shader code. Can only be used for input ports in non-uniform nodes.

PortType PORT_TYPE_MAX = 9

Represents the size of the PortType enum.


Property Descriptions

int output_port_for_preview = -1

  • void set_output_port_for_preview ( int value )

  • int get_output_port_for_preview ( )

Sets the output port index which will be showed for preview. If set to -1 no port will be open for preview.


Method Descriptions

void clear_default_input_values ( )

Clears the default input ports value.


Array get_default_input_values ( ) const

Returns an Array containing default values for all of the input ports of the node in the form [index0, value0, index1, value1, ...].


Variant get_input_port_default_value ( int port ) const

Returns the default value of the input port.


void remove_input_port_default_value ( int port )

Removes the default value of the input port.


void set_default_input_values ( Array values )

Sets the default input ports values using an Array of the form [index0, value0, index1, value1, ...]. For example: [0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0)].


void set_input_port_default_value ( int port, Variant value, Variant prev_value=null )

Sets the default value for the selected input port.