Visual shader - how to create a pramater in Vertex for use in Fragment

Godot Version

4.5.2

Question

I know how to do this in GLSL in the shader code editor, but how would I transfer data in the visual editor?

For example lets say I take the model matrix data and perform a mathematical operation on it but I then want to use this information in the fragment function, in GLSL its pretty simple:

varying vec4 useful_data;
varying vec4 some_use

void vertex(){
   useful_data = (MODEL_MATRIX * vec4(VERTEX,1.0)).xyz;
}

void fragment(){
   some_use = normalize(useful_data)
}

But how do I pass this information around using the visual shader node system?

I can’t seem to find any output or parameter nodes that take an input to pass on/store data

Add a varying here:

image

and set its value using VaryingSetter node.

1 Like

Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.