Quick answer: Pack data into ImageTexture and sample with texelFetch. Bypasses uniform array cap.
You declare uniform vec4 data[2048]. Compile fails. Driver caps uniform arrays well below 2048 elements.
The Fix
# GDScript: pack values into a 1D texture
var n = 2048
var img = Image.create(n, 1, false, Image.FORMAT_RGBAH)
for i in n:
img.set_pixel(i, 0, Color(values[i].x, values[i].y, values[i].z, 1.0))
var tex = ImageTexture.create_from_image(img)
material.set_shader_parameter("data_tex", tex)
// Shader
uniform sampler2D data_tex;
vec3 get_data(int i) {
return texelFetch(data_tex, ivec2(i, 0), 0).rgb;
}
texelFetch reads the raw pixel without filtering. Index translates directly to texel position. Memory cost is the texture; sampling cost is one tap per read.
Verifying
Shader compiles. Visual matches uniform-array reference. No driver warnings. 2D arrays use 2D texture; index = (i % w, i / w).
“Texture for big arrays. Index is UV. Cap dodged.”
Related Issues
For shader instance uniform, see instance uniform. For shader TIME, see TIME.
Pack to texture. Sample. No cap.