我正在尝试将此 GLSL 着色器移植到 Stage3D 和 AGAL,但我无法使其工作:
顶点着色器 (GLSL)
attribute vec3 aVertexPosition;
attribute vec4 aVertexColor;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying vec4 vColor;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
vColor = aVertexColor;
}
片段着色器 (GLSL)
precision mediump float;
varying vec4 vColor;
void main(void) {
gl_FragColor = vColor;
}
结果是:
顶点着色器 (AGAL)
mov vt0.w, vc0.x
mov vt0.xyz, va0.xyz
mov vt1.xyzw, vc1
mul vt5.xyzw, vt1, vc5
m44 op.xyzw, vt0.xyzw, vt5
mov v0.xyzw, va1.xyzw
片段着色器 (AGAL)
mov oc.xyzw, v0.xyzw
这是我执行的指令的跟踪:
(setVertexBufferAt) va0 3 0
(setVertexBufferAt) va1 4 3
(identity setProgramConstantsFromMatrix): vc0 1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1
(setProgramConstantsFromMatrix) vc1 1,0,0,0,0,1,0,0,0,0,1,0,0,0,-2,1
(setProgramConstantsFromMatrix) vc5 1.8106601238250732,0,0,0,0,2.4142136573791504,0,0,0,0,-1.0020020008087158,-1,0,0,-0.20020020008087158,0
render drawTriangles + present
但我还是什么都看不到。
更新:显然问题是三角形被剪裁了。相乘数组上的值大于 1.0,这使得它们被剪掉。所以我需要找到一种方法来规范化矩阵或扩展剪裁
有什么建议吗?