0

我有简单的着色器,我试图在模型坐标上应用缩放和旋转

#version 330

layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec3 VertexNormal;
layout(location = 2) in vec2 VertexUV;

out VS_GS_VERTEX
{
    vec3 vs_worldpos;
    vec3 vs_normal;
    vec2 VertexUV;
} vertex_out;

uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
uniform mat4 lookAtMatrix;
uniform mat4 mdlScaleMatrix;
uniform mat4 mdlRotMatrix;

void main(void)
{
    mat4 mdlMat = mdlRotMatrix * mdlScaleMatrix;
    vec4 mdlPos = mdlMat * vec4(VertexPosition, 1.0);

    mat4 MVP = projectionMatrix * lookAtMatrix * modelMatrix;

    gl_Position = MVP * mdlPos;
    gl_Normal = mat3(modelMatrix) * VertexNormal;

    vertex_out.vs_worldpos = gl_Position.xyz;
    vertex_out.vs_normal = gl_Normal;
    vertex_out.VertexUV = VertexUV;
}

但由于某种原因glGetUniformLocation而返回。我可以看到其他制服的值 4-6。为什么会发生?我检查了名称并复制粘贴了几次,在代码中出错以检查并得到编译错误(着色器适用于确切的文件),因此名称和着色器是完整的。mdlRotMatrixmdlScaleMatrix-1

4

0 回答 0