着色器乘法矩阵
我有一个问题我不明白。
我有一个着色器,
String[] vsSource = new String[] {
"attribute vec3 aVertex;",
"attribute vec3 aColor;",
"uniform mat4 uMVMatrix;",
"uniform mat4 uPMatrix;",
"varying vec3 vColor;",
"void main(void) {",
" vColor = aColor;",
" gl_Position = uMVMatrix * uPMatrix * vec4(aVertex, 1.0);",
"}" };
我设置了两个矩阵 uMVMatrix
和 uPMatrix
,我想在着色器中将它们相乘。当我尝试这样做时,我的屏幕保持黑屏。
当我在 Java 中将其相乘并将其传递给一个 mat4 变量时,我看到了我的三角形。
String[] vsSource = new String[] {
"attribute vec3 aVertex;",
"attribute vec3 aColor;",
"uniform mat4 mvpMatrix;",
"varying vec3 vColor;",
"void main(void) {",
" vColor = aColor;",
" gl_Position = mvpMatrix * vec4(aVertex, 1.0);",
"}" };
有人可以告诉我为什么我不能在着色器中将它们相乘吗?
I have an issue I don't understand.
I have a shader
String[] vsSource = new String[] {
"attribute vec3 aVertex;",
"attribute vec3 aColor;",
"uniform mat4 uMVMatrix;",
"uniform mat4 uPMatrix;",
"varying vec3 vColor;",
"void main(void) {",
" vColor = aColor;",
" gl_Position = uMVMatrix * uPMatrix * vec4(aVertex, 1.0);",
"}" };
I set both matrices uMVMatrix
and uPMatrix
and I want to multiply them in the shader. When I try that, my screen stay black.
When I multiply it in Java and pass it to one mat4 variable, I see my triangle.
String[] vsSource = new String[] {
"attribute vec3 aVertex;",
"attribute vec3 aColor;",
"uniform mat4 mvpMatrix;",
"varying vec3 vColor;",
"void main(void) {",
" vColor = aColor;",
" gl_Position = mvpMatrix * vec4(aVertex, 1.0);",
"}" };
Can someone tell me why I can't multiply them in the shader?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试反转着色器中矩阵的顺序,即
Try inverting the order of the matrices in the shader, i.e.