I've been having trouble with my lighting.

Everything on the screen appears dark unless I go in and manually set the color, in which case I can see that the cube does draw to the screen. I played around with different variables to figure out where the problem is, and it seems like it has something to do with my normal vector.

Is there anything that immediately stands out as wrong about this code?:

- Code: Select all
`//GLSL`

vec3 normalVector=normalize(modelviewInverseTranspose*vertexNormal);

vec3 lightVector= normalize(vec3(mainLight.position));

vec3 lighting=vec3(mainLight.color) * vec3(objectColor) * max(0.0, dot(normalVector, lightVector) );

fragmentColor=vec4(lighting, 1.0); //Move final lighting to fragment shader.

I also thought perhaps my problem was specifically with the modelview matrix, (as the vertex normals all read correctly when I print them.)

the modelviewInverseTranspose matrix is defined this way;

- Code: Select all
`model=glm::translate(glm::mat4(1.0f) , glm::vec3(0.0, 0.0, -4.0) );`

view= glm::lookAt(glm::vec3(0.0, 2.0, 0.0), glm::vec3(0.0, 0.0, -4.0), glm::vec3(0.0, 1.0, 0.0));

modelviewMatrix=model*view;

glm::mat3 modelviewInverseTranspose=glm::transpose(glm::inverse(glm::mat3(modelviewMatrix)));

Maybe this is a bigger problem with my program, in which case I will have to spend some more time. But I was just wondering if anything stands out as obviously wrong with these sections. I compare these to other examples online and I don't see much of a difference. Perhaps it is something simple that I am overlooking, but I don't see where the problem is.