mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-24 03:21:19 +00:00
fixing weird normals bug
This commit is contained in:
parent
2c06d4374d
commit
f09cda0927
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user