fixing weird normals bug

This commit is contained in:
Dmitri K 2016-12-02 17:49:43 -05:00
parent 2c06d4374d
commit f09cda0927

View File

@ -30,16 +30,16 @@ vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm) {
if(useNormalMap) {
vec3 vNorm = texture(texNormal, texCoords).rgb;
nfNormal = normalize(normalMatrix * vNorm);
nfNormal = normalMatrix * normalize(2 * vNorm - 1);
} else {
nfNormal = normalize(fNorm);
}
// Compute diffuse component
float diff = 0.2*max(0.0, dot(nfNormal, -LightDirection));
float diff = 0.2*max(0.0, dot(nfNormal, -LightDirection));
// Compute specular component
vec3 Rl = reflect(LightDirection, nfNormal);
vec3 Rl = reflect(-LightDirection, nfNormal);
float spec = 0.2*pow(max(0.0, dot(/*normalMatrix */ Rl, nviewDirection)), 64);
// Compute ambient component
@ -60,7 +60,8 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, int i) {
if(useNormalMap) {
vec3 vNorm = texture(texNormal, texCoords).rgb;
nfNormal = normalize(normalMatrix * vNorm);
//nfNormal = normalize(normalMatrix * vNorm);
nfNormal = normalMatrix * normalize(2 * vNorm - 1);
} else {
nfNormal = normalize(fNorm);
}