Accname
2D-Graphics enthusiast
- Reaction score
- 1,462
Hi folks, i have problems with a short glsl fragment shader i was trying to write.
I havent used glsl very often, in fact this is the third shader i am writing so the code might not be perfect.
However, i get a very weird parse error which i just cant figure out any solution for. Maybe it is because its too late in the evening. Anyways, if somebody could help me i would be very thankful.
The error is:
ERROR: 0:1: error(#132) Syntax error: "offset_array" parse error
I havent used glsl very often, in fact this is the third shader i am writing so the code might not be perfect.
However, i get a very weird parse error which i just cant figure out any solution for. Maybe it is because its too late in the evening. Anyways, if somebody could help me i would be very thankful.
The error is:
ERROR: 0:1: error(#132) Syntax error: "offset_array" parse error
Code:
uniform sampler2D tex;
uniform int palette;
uniform int offset_array[3];
offset_array[0] = 0;
offset_array[1] = 11;
offset_array[2] = 15;
uniform vec3 color_table[30];
color_table[0] = vec3(24, 24, 24);
color_table[1] = vec3(72, 56, 32);
color_table[2] = vec3(120, 128, 72);
color_table[3] = vec3(192, 192, 152);
color_table[4] = vec3(232, 112, 72);
color_table[5] = vec3(248, 192, 96);
color_table[6] = vec3(248, 248, 248);
color_table[7] = vec3(152, 64, 56);
color_table[8] = vec3(56, 144, 64);
color_table[9] = vec3(32, 90, 34);
color_table[10] = vec3(120, 232, 152);
color_table[11] = vec3(24, 24, 24);
color_table[12] = vec3(120, 80, 48);
color_table[13] = vec3(200, 128, 88);
color_table[14] = vec3(240, 192, 144);
color_table[15] = vec3(24, 24, 24);
color_table[16] = vec3(32, 72, 49);
color_table[17] = vec3(72, 128, 126);
color_table[18] = vec3(152, 192, 185);
color_table[19] = vec3(72, 232, 83);
color_table[20] = vec3(96, 248, 164);
color_table[21] = vec3(248, 248, 248);
color_table[22] = vec3(66, 152, 56);
color_table[23] = vec3(56, 64, 144);
color_table[24] = vec3(32, 42, 90);
color_table[25] = vec3(131, 120, 232);
color_table[26] = vec3(24, 24, 24);
color_table[27] = vec3(82, 54, 32);
color_table[28] = vec3(172, 110, 76);
color_table[29] = vec3(204, 148, 96);
void main(){
vec4 color = texture2D(tex, gl_TexCoord[0].st);
int type = color.r;
int index = color.g;
int offset = offset_array[type];
vec3 final_color = color_table[offset+index+palette*15];
gl_FragColor = vec4(final_color.r, final_color.g, final_color.b, color.a);
}