Why GLSL "optimizing" this shader?
I have simple shader where I trying to apply scaling and rotation onto
model's coordinates
#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;
}
but for some reason glGetUniformLocation for mdlRotMatrix and
mdlScaleMatrix returns -1. I can see values 4-6 for other uniforms. Why it
happens? I checked names and copy-pasted several times, made error in code
to check and got compilation error (shader works with exact file), so
names and shader are intact.
No comments:
Post a Comment