mirror of
https://github.com/ConjureETS/LOG750-LAB2.git
synced 2026-03-23 19:11:20 +00:00
hours spent just to realize I'm a dumbass
This commit is contained in:
parent
545f78d0dc
commit
3d79976c4e
@ -27,15 +27,15 @@ const int lightLevels = 7;
|
||||
|
||||
vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn) {
|
||||
// Get lighting vectors
|
||||
vec3 LightDirection = tbn * normalize(lDirection);
|
||||
vec3 nviewDirection = tbn * normalize(fPos);
|
||||
vec3 LightDirection = normalize(lDirection);
|
||||
vec3 nviewDirection = normalize(fPos);
|
||||
vec3 nfNormal;
|
||||
|
||||
if(useNormalMap) {
|
||||
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
||||
nfNormal = normalize(2 * vNorm - 1);
|
||||
nfNormal = tbn * normalize(2 * vNorm - 1);
|
||||
} else {
|
||||
nfNormal = normalize(tbn * fNorm);
|
||||
nfNormal = normalize(fNorm);
|
||||
}
|
||||
|
||||
// Compute diffuse component
|
||||
@ -62,17 +62,15 @@ vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn) {
|
||||
|
||||
vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
|
||||
// Get lighting vectors
|
||||
vec3 LightDirection = tbn * normalize(pointLight[i] + fPos);
|
||||
// vec3 nfNormal = normalize(fNorm);
|
||||
vec3 nviewDirection = tbn * normalize(fPos);
|
||||
vec3 LightDirection = normalize(pointLight[i] + fPos);
|
||||
vec3 nviewDirection = normalize(fPos);
|
||||
vec3 nfNormal;
|
||||
|
||||
if(useNormalMap) {
|
||||
vec3 vNorm = texture(texNormal, texCoords).rgb;
|
||||
//nfNormal = normalize(normalMatrix * vNorm);
|
||||
nfNormal = normalize(2 * vNorm - 1);
|
||||
nfNormal = tbn * normalize(2 * vNorm - 1);
|
||||
} else {
|
||||
nfNormal = normalize(tbn * fNorm);
|
||||
nfNormal = normalize(fNorm);
|
||||
}
|
||||
|
||||
// Attenuation
|
||||
@ -80,11 +78,11 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
|
||||
float attenuation = 0.5 + 1 / max(0.25, distance * distance);
|
||||
|
||||
// Compute diffuse component
|
||||
float diff = 0.0 * max(0.0, dot(nfNormal, LightDirection));
|
||||
float diff = .2 * max(0.0, dot(nfNormal, LightDirection));
|
||||
|
||||
// Compute specular component
|
||||
vec3 Rl = reflect(-LightDirection, /*normalMatrix */ nfNormal);
|
||||
float spec = 0.5 * pow(max(0.0, dot(Rl, nviewDirection)), 32);
|
||||
vec3 Rl = reflect(-LightDirection, nfNormal);
|
||||
float spec = .6 * pow(max(0.0, dot(Rl, nviewDirection)), 32);
|
||||
|
||||
// Compute ambient component
|
||||
float amb = 0.2;
|
||||
@ -94,7 +92,7 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
|
||||
if(useToon){
|
||||
luminance = floor(luminance * lightLevels) / lightLevels;
|
||||
}
|
||||
return vec4(pointLightCol[i].xyz * attenuation * luminance * tex.xyz, pointLightCol[i].w);
|
||||
return vec4(pointLightCol[i].xyz * luminance * attenuation * tex.xyz, pointLightCol[i].w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user