I'm trying to turn a float array into a vector2 array since a float array is the only array I can pass over from Java code to the shader. I'm turning for example float 3.8 into vec2(3,8). But that's pretty irrelevant. The real problem is that the shader stops working when adding a certain line in the for loop. Here's my code:
attribute vec4 a_color;
attribute vec3 a_position;
attribute vec2 a_texCoord0;
uniform float a_tileCoords[144];
uniform mat4 u_projTrans;
varying vec4 v_color;
varying vec2 v_texCoord0;
varying vec2 v_tileCoords[144];
int length = 144;
void main(){
v_color = a_color;
v_texCoord0 = a_texCoord0;
for(int i = 0; i < length; i++){
int x = int(a_tileCoords[i]);
int y = int((a_tileCoords[i] - int(a_tileCoords[i])) * 10);
v_tileCoords[i] = vec2(x,y);
}
gl_Position = u_projTrans * vec4(a_position + vec3(0, 1, 0), 1.);
}
It's about this line:
v_tileCoords[i] = vec2(x,y);
When I remove that line from the for loop the shader works again (the texture gets drawn.) But I want this line to work of course. So the question for you is: What could I have done wrong, or is this even possible what I want to achieve?