Repository: godotengine/godot (language: cpp)

Issue:
RandomRange VisualShader Node throws error when connected to Varying Setter
### Tested versions

Reproducible in 4.4 dev 7

### System information

Godot v4.4.dev7 - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Thu, 19 Dec 2024 20:32:41 +0000 on Wayland - X11 display driver, Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3060 (nvidia; 565.77) - AMD Ryzen 9 9900X 12-Core Processor (24 threads)

### Issue description

When the RandomRange node is only connected to a VaryingSetter like so: 
![Image](https://github.com/user-attachments/assets/bfdbaef3-b7cb-4746-8591-86e9e630f030)
The shader code is generated without the function definition as such:
![Image](https://github.com/user-attachments/assets/c248b959-534d-4a8e-9128-ceada7977547)

When connected to the vertex color output as well for example: 
![Image](https://github.com/user-attachments/assets/41b2cdcb-b4b2-43ec-95d8-3bc120a3a2e7)

It now generates correctly:
![Image](https://github.com/user-attachments/assets/83befdde-5901-47bc-9333-49b67d674ab9)


Seems as though the check for how to include the function needs to be aware of the VaryingSetter as well.

Hopefully it's an easy fix :)

### Steps to reproduce

Connect a RandomRange Setter to a VaryingSetter in the Vertex Shader
Connect the VarryingGetter to the Albedo in the Fragment Shader

Check the generated shader code and notice the error from the lack of function definition.

### Minimal reproduction project (MRP)

[random-range.zip](https://github.com/user-attachments/files/18302838/random-range.zip)



Discussion / hints:

Fix patch:
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index fc9da9482705..b29577ed64c9 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2796,7 +2796,7 @@ void VisualShader::_update_shader() const {
 
 		if (varying_setters.has(i)) {
 			for (int &E : varying_setters[i]) {
-				err = _write_node(Type(i), &global_code, nullptr, nullptr, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
+				err = _write_node(Type(i), &global_code, &global_code_per_node, nullptr, func_code, default_tex_params, input_connections, output_connections, E, processed, false, classes);
 				ERR_FAIL_COND(err != OK);
 			}
 		}


Test patch: