I'm working on a deferred renderer and need a bit of help getting normal maps working. What I've been doing with them so far is just multiplying the normal texture with the object normals (gl_NormalMatrix * gl_Normal). That appears to be wrong.
I just need someone to explain how I can add the normal map the the normal gbuffer.
The offending line:
vec3 normal = Normal * texture2D(normalTexture, gl_TexCoord).rgb;
Edit: I managed to get it working :)
vec3 Normal = normalize(gl_NormalMatrix * gl_Normal); vec3 Tangent = normalize(gl_NormalMatrix); vec3 Binormal = normalize(gl_NormalMatrix); mat3 tangentToWorld = mat3(Tangent.x, Binormal.x, Normal.x, Tangent.y, Binormal.y, Normal.y, Tangent.z, Binormal.z, Normal.z);
vec3 normal = (texture2D(normalTexture, gl_TexCoord).rgb * 2.0 - 1.0) * tangentToWorld;