Source

gltut / Tut 18 Bumpy Textures / data / litBump.frag

Diff from to

Tut 18 Bumpy Textures/data/litBump.frag

 
 in vec2 normalCoord;
 in vec3 cameraSpacePosition;
-in vec3 cameraSpaceNormal;
-in vec3 cameraSpaceTangent;
-in vec3 cameraSpaceBitangent;
+in vec3 cameraToTangentX;
+in vec3 cameraToTangentY;
+in vec3 cameraToTangentZ;
 
 out vec4 outputColor;
 
 
 vec3 CalcLightDir(in vec3 lightDir)
 {
-	vec3 ret = normalize(cameraSpaceTangent) * lightDir.x;
-	ret += normalize(cameraSpaceBitangent) * lightDir.y;
-	ret += normalize(cameraSpaceNormal) * lightDir.z;
+	vec3 ret = normalize(cameraToTangentX) * lightDir.x;
+	ret += normalize(cameraToTangentY) * lightDir.y;
+	ret += normalize(cameraToTangentZ) * lightDir.z;
 	return ret;
 }
 
 	
 	vec3 normal = texture(normalTex, normalCoord).xyz;
 	normal = (normal * 2.0) - 1.0;
+	normal = normalize(normal); 
 
 	vec4 accumLighting = diffuseColor * Lgt.ambientIntensity;
 	for(int light = 0; light < numberOfLights; light++)