Godot Version
4.0.2 stable
Question
I have a shader script and i would like to gradually lesser a variable in it but when i tried to make it i got an error “Assignment to uniform”. How do i fix it? And if there’s no way to do it, what alternative can i resort to?
You cannot modify uniform parameters. Assign hit to a new variable inside the fragment function.
1 Like
You cannot edit uniform variables within a shader. You must consider the massively parallel nature of shaders. There are potentially more than 1920x1080 (2,073,600) fragment() calls being run in a single frame, if you could reduce a variable for each fragment call it would be disasterous.
You can use an AnimationPlayer or Tween node to create smooth effects by shader parameter values though.
2 Likes
Got it. Thanks for solving my problem