我最近接手了一个项目,该项目停滞不前,一名团队成员几个月前退出了。在试图让自己加快速度时,我遇到了这个顶点着色器,我很难理解它在做什么:
uniform int axes;
varying vec4 passcolor;
void main()
{
// transform the vertex
vec4 point;
if (axes == 0) {
point = gl_Vertex;
} else if (axes == 1) {
point = gl_Vertex.xzyw;
} else if (axes == 2) {
point = gl_Vertex.xwzy;
} else if (axes == 3) {
point = gl_Vertex.yzxw;
} else if (axes == 4) {
point = gl_Vertex.ywxz;
} else if (axes == 5) {
point = gl_Vertex.zwxy;
}
point.z = 0.0;
point.w = 1.0;
// eliminate w point
gl_Position = gl_ModelViewProjectionMatrix * point;
passcolor = gl_Color;
}
我想更好地理解的行是这样的行:
point = gl_Vertex.xwzy;
我似乎找不到解释这一点的文档。
有人可以快速解释一下这个着色器在做什么吗?