My problem is that I cannot get any place in the form when I have other places without problems.
For example, I have a VS form called MVP and Model, and I have a “MVP” location without problems, but I don't have a “model” that I use symmetrically. Similarly, I cannot get the location of the fields from the Light structure in FS.
Its code passes the data to the shader:
bool Shader::SetShaderParameters(mat4 MVPMatrix,mat4 Model,GLint textureUnit)
{
GLuint matrixLocation = glGetUniformLocation(programID,"MVP");
if(matrixLocation==-1)
return false;
glUniformMatrix4fv(matrixLocation,1,GL_FALSE,&MVPMatrix[0][0]);
GLuint modelLocation = glGetUniformLocation(programID,"Model");
if(modelLocation==-1)
return false;
glUniformMatrix4fv(modelLocation,1,GL_FALSE,&Model[0][0]);
return true;
}
bool Shader::SetShaderLights(vec3 lightColor,vec3 ambientIntensity,vec3 direction,vec3 diffuseIntensity)
{
GLuint lightColorLocation = glGetUniformLocation(programID,"light.lightColor");
if(lightColorLocation==-1)
return false;
glUniform3fv(lightColorLocation,1,&lightColor[0]);
GLuint ambientIntensityLocation = glGetUniformLocation(programID,"light.ambientIntensity");
if(ambientIntensityLocation==-1)
return false;
glUniform3fv(ambientIntensityLocation,1,&ambientIntensity[0]);
GLuint directionLocation = glGetUniformLocation(programID,"light.direction");
if(directionLocation==-1)
return false;
glUniform3fv(directionLocation,1,&direction[0]);
GLuint diffuseIntensityLocation = glGetUniformLocation(programID,"light.diffuseIntensity");
if(diffuseIntensityLocation==-1)
return false;
glUniform3fv(diffuseIntensityLocation,1,&diffuseIntensity[0]);
return true;
}
This shader code:
VS:
layout(location=0) in vec3 vertexPosition;
layout(location=1) in vec2 vertexUV;
layout(location=2) in vec3 normal;
out vec2 uv;
out vec3 norm;
uniform mat4 Model;
uniform mat4 MVP;
void main()
{
gl_Position = MVP*vec4(vertexPosition,1.0);
uv = vertexUV;
norm = (Model*vec4(normal,0.0)).xyz;
}
FS:
struct Light
{
vec3 lightColor;
vec3 ambientIntensity;
vec3 direction;
vec3 diffuseIntensity;
};
in vec2 uv;
in vec3 norm;
out vec3 color;
uniform sampler2D texSamp;
uniform Light light;
void main()
{
color = texture(texSamp,uv).rgb*light.ambientIntensity;
}
What can be a problem with various forms of behavior when getting a place in a form? Maybe I'm using a bad version of the shaders or is it somehow optimizing the data in the shaders. I debugged my decision, and I am sure that the identifiers of the shader programs are correct.
[EDIT]:
FS, , glGetUniformLocation(), , .