Original Post
Hey guys, I have recently been experimenting with normal mapping and have had a moderate degree of success. So far I can get my model mapped, and the lighting equation to look 'right', at least to a degree. The problem I am having is that it doesn't seem the shader I am using is correctly interpolating the vertex normal values across the face of the polygon.
I am pretty sure the problem would be the result of the vertex shader I am using and not the fragment shader. This is based off a tutorial I found online. I am sure that the normal values I am using are correct as if I use a standard per pixel shader the objects look 'smooth'. The t,b,n vectors are all the average of the faces connected to that vertex. Any help in smoothing this baby out would be much appreciated.
I am pretty sure the problem would be the result of the vertex shader I am using and not the fragment shader. This is based off a tutorial I found online. I am sure that the normal values I am using are correct as if I use a standard per pixel shader the objects look 'smooth'.
varying vec3 lightDir;
varying vec3 viewDir;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
vec3 vertexPos = vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 t = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz);
vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
mat3 tbnMatrix = mat3(t, b, n);
lightDir = gl_LightSource[0].position.xyz - vertexPos;
lightDir *= tbnMatrix;
viewDir = -vertexPos;
viewDir *= tbnMatrix;
}