I have a GLSL vertex/fragment shader pair. I'm trying to pass it a combined matrix for transformation, but whenever I try glGetUniformLocation on it, I get -1.
Here's the vertex shader:
#version 300 es
precision mediump float;
uniform mat4 gComboMatrix;
layout (location = 0 ) in vec4 input_mXYZ;
layout (location = 1 ) in uint input_mColor;
layout (location = 2 ) in vec2 input_mUV;
out vec4 output_mXYZ;
out vec4 output_mColor;
out vec2 output_mUV;
void main()
{
output_mXYZ=(input_mXYZ*gComboMatrix);
output_mColor=(vec4(float(((input_mColor)&0x000000FFu))/255.0f,float(((input_mColor)&0x0000FF00u)>>8)/255.0f,float(((input_mColor)&0x00FF0000u)>>16)/255.0f,float(((input_mColor)&0xFF000000u)>>24)/255.0f));
output_mUV=input_mUV;
}
And here's the fragment shader:
#version 300 es
precision mediump float;
uniform sampler2D theTexture;
uniform float theSaturation;
in vec4 input_mXYZ;
in vec2 input_mTex1;
in vec4 input_mColor;
out vec4 output_mColor;
void main()
{
vec4 aReal=texture(theTexture,input_mTex1)*input_mColor;
float aGrey=(aReal.r+aReal.g+aReal.b)/3.0f;
output_mColor.rgb=vec3(aGrey,aGrey,aGrey);
output_mColor.rgb=mix(output_mColor.rgb,aReal.rgb,theSaturation);
output_mColor.a=aReal.a;
}
So this:
glGetUniformLocation(glProgram,"gComboMatrix");
Always returns -1. Any idea why? It compiles and links fine, and I am able to fetch "theSaturation" without any issues. What's wrong with gComboMatrix?
Added note: I've also tried a couple insane things like setting the color's a equal to gComboMatrix[0] to try to confirm to myself that it's not optimized away. Still nothing, always -1. Help!
Odds are good that your compiler recognizes that your VS does not write to gl_Position
, and since you didn't set any transform feedback stuff, there is no way executing it will result in well-defined behavior. Since your shader cannot be used to render anything, the compiler likely optimized it away.
Or it gave a compile error that you didn't check for.