Godot Version
4.7 Stable
Question
I have been following this tutorial (he’s using 4.4.1) and I’m at a part where he is getting no errors whatsoever, but line 15 that says “for (int 1=0; i<tex_size[0]; i++) {” is getting flagged with these errors:
ERROR: res://Scripts/Resources/replace_color.gdshader:15 - Expected an identifier or ‘[’ after type.
ERROR: Shader compilation failed.
ERROR: editor/script/script_editor_plugin.cpp:2274 - Parameter “seb” is null.
I don’t know if it’s the difference in versions, but I’m not sure how to fix it.
shader_type canvas_item;
uniform sampler2D team_palette;
uniform int team_color;
vec2 px_to_uv(ivec2 pos, ivec2 tex_size) {
return vec2(
(float(pos[0]) + 0.5) / float(tex_size[0]),
(float(pos[1]) + 0.5) / float(tex_size[1])
);
}
vec4 get_palette_color(vec4 color, sampler2D palette, int selection) {
ivec2 tex_size = textureSize(palette, 0);
for (int 1=0; i<tex_size[0]; i++) {
vec2 uv_color_ref = px_to_uv(ivec2(i, 0), tex_size);
vec4 color_ref = texture(palette, uv_color_ref);
if(color == color_ref) {
vec2 uv_color_dest = px_to_uv(ivec2(i, selection), tex_size);
return texture(palette, uv_color_dest);
}
}
return color;
}
void fragment() {
COLOR = get_palette_color(COLOR, team_palette, team_color);
}
I went over the video multiple times and I’m certain our code is identical.