Godot Version
v4.4.1.stable.official [49a5bc7b6]
Question
Ok, if I understood this correctly, it is impossible to create a global array that has modifiable elements? Since it either has to be a uniform or a const? I mean, I can technically use the color of each pixel for storing information, but that limits the information density a little, especially since I want pixel colors to be the output.
Additionally, I want to define a constant variable that is related to another constant variable, but even though both are constants, it seems that is not possible either? I mean something along these lines:
const int a = 2;
const int b = a + 1;
ok, i was stupid about the second one, ignore it lol, should have found the uint rules sooner
To be clear, a constant is immutable in any language. It is pre-compiled to never change. This has the benefits of taking up less room in memory and of being always quickly available in memory because it is always guaranteed to be there and the memory address doesn’t change (and there are no re-directs through pointers/references).
Also, it looks like you are talking about writing a shader. Shader code is very different from GDScript so it would behoove you in future posts to mention that. Because in GDScript it is very easy to create a global array with modifiable elements.
Shader code is much closer to C++, in which an array is always immutable in size, but not content. Either, way the solution is just to make a new array and copy updated values and/or size into the new array.