I'm currently trying to implement some diffuse lighting in a shader and i've been looking at some examples around the web. I understand the view, model and projection matrix and how they work to move from model to view to projection but i've been seeing this Normal Matrix and i have no idea what its for? The top of the shader has a basic setup like this
uniform mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 MVP;
Apparently the NormalMatrix is a 3x3 matrix of the top left of the model view matrix
x x x x
x x x x
x x x x
x x x x
MVP = Projection * view * model ModelView = view * model NormalMatrix = matrix3 (vector3(ModelView[0]), vector3(ModelView[1]), vector3(ModelView[2]));
and later on it does
vec3 norm = normalize (NormalMatrix * VertexNormal)
I don't know why its multiplying the normal matrix by the current normal in the vertex shader. I suspect it has something to do with getting the interpolated normals over each face though.
Thanks for any help







