【发布时间】:2017-03-09 07:43:07
【问题描述】:
我有一个纹理位置(2d 向量),我将它乘以着色器中的 4x4 矩阵。 目前我将向量作为 vec2 属性传递,然后从中创建一个 vec4:
Java:
private static final float[] TEXTURE_COORDINATES = {
0, 1, // bottom left
1, 1, // bottom right
0, 0, // top left
1, 0, // top right
};
顶点着色器:
attribute vec2 texturePosition;
uniform mat4 textureMatrix;
// more variables
void main() {
vec4 tp = vec4(texturePosition.x, texturePosition.y, 1, 1);
tp = textureMatrix * tp;
// more code
}
直接传递一个 vec4 属性并将两个 1 存储在 java 端会更好(以哪种方式?)?
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
};
顶点着色器:
attribute vec4 texturePosition;
uniform mat4 textureMatrix;
// more variables
void main() {
vec4 tp = textureMatrix * tp;
// more code
}
【问题讨论】:
标签: java opengl-es opengl-es-2.0