I have a texture position (2d vector), which I multiply by a 4x4 matrix in the shader. Currently I'm passing the vector as a vec2 attribute and then creating a vec4 out of it:
Java:
private static final float[] TEXTURE_COORDINATES = {
0, 1, // bottom left
1, 1, // bottom right
0, 0, // top left
1, 0, // top right
};
Vertex-shader:
attribute vec2 texturePosition;
uniform mat4 textureMatrix;
// more variables
void main() {
vec4 tp = vec4(texturePosition.x, texturePosition.y, 1, 1);
tp = textureMatrix * tp;
// more code
}
Would it be better (in which way?) to directly pass a vec4 attribute and store the two 1s on the java-side?
Java:
private static final float[] TEXTURE_COORDINATES = {
0, 1, 1, 1, // bottom left
1, 1, 1, 1, // bottom right
0, 0, 1, 1, // top left
1, 0, 1, 1, // top right
};
Vertex-shader:
attribute vec4 texturePosition;
uniform mat4 textureMatrix;
// more variables
void main() {
vec4 tp = textureMatrix * tp;
// more code
}