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,7 +30,7 @@ vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm) {
|
|||||||
|
|
||||||
if(useNormalMap) {
|
if(useNormalMap) {
|
||||||
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
||||||
nfNormal = normalize(normalMatrix * vNorm);
|
nfNormal = normalMatrix * normalize(2 * vNorm - 1);
|
||||||
} else {
|
} else {
|
||||||
nfNormal = normalize(fNorm);
|
nfNormal = normalize(fNorm);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm) {
|
|||||||
float diff = 0.2*max(0.0, dot(nfNormal, -LightDirection));
|
float diff = 0.2*max(0.0, dot(nfNormal, -LightDirection));
|
||||||
|
|
||||||
// Compute specular component
|
// 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);
|
float spec = 0.2*pow(max(0.0, dot(/*normalMatrix */ Rl, nviewDirection)), 64);
|
||||||
|
|
||||||
// Compute ambient component
|
// Compute ambient component
|
||||||
@ -60,7 +60,8 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, int i) {
|
|||||||
|
|
||||||
if(useNormalMap) {
|
if(useNormalMap) {
|
||||||
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
||||||
nfNormal = normalize(normalMatrix * vNorm);
|
//nfNormal = normalize(normalMatrix * vNorm);
|
||||||
|
nfNormal = normalMatrix * normalize(2 * vNorm - 1);
|
||||||
} else {
|
} else {
|
||||||
nfNormal = normalize(fNorm);
|
nfNormal = normalize(fNorm);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user