tweaking lights

This commit is contained in:
Dmitri K 2016-12-06 21:50:10 -05:00
parent 3d79976c4e
commit e557a80336

View File

@ -48,7 +48,7 @@ vec4 calcDirLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn) {
// Compute ambient component // Compute ambient component
float amb = 0.2; float amb = 0.2;
float mult = 2; float mult = 1;
float luminance = (diff + amb + spec); float luminance = (diff + amb + spec);
@ -75,7 +75,7 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
// Attenuation // Attenuation
float distance = length(nviewDirection - pointLight[i] - fPos) / 3; float distance = length(nviewDirection - pointLight[i] - fPos) / 3;
float attenuation = 0.5 + 1 / max(0.25, distance * distance); float attenuation = 1 / max(0.25, distance * distance);
// Compute diffuse component // Compute diffuse component
float diff = .2 * max(0.0, dot(nfNormal, LightDirection)); float diff = .2 * max(0.0, dot(nfNormal, LightDirection));
@ -91,6 +91,7 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
if(useToon){ if(useToon){
luminance = floor(luminance * lightLevels) / lightLevels; luminance = floor(luminance * lightLevels) / lightLevels;
attenuation = 1;
} }
return vec4(pointLightCol[i].xyz * luminance * attenuation * tex.xyz, pointLightCol[i].w); return vec4(pointLightCol[i].xyz * luminance * attenuation * tex.xyz, pointLightCol[i].w);
} }
@ -131,31 +132,31 @@ main()
mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords); mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords);
if(isPickingMode){ if(isPickingMode){
fColor = ifColor; fColor = ifColor;
}else{ }else{
if(drawTextures) { if(drawTextures) {
texColor = texture(texCol, texCoords); texColor = texture(texCol, texCoords);
} else { } else {
texColor = ifColor; texColor = ifColor;
} }
if(isLightSource) { if(isLightSource) {
fColor = texColor; fColor = texColor;
} else if(isSky) { } else if(isSky) {
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2; fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
} else if(isPhong) { } else if(isPhong) {
// Get lighting vectors // Get lighting vectors
vec3 LightDirection = normalize(lDirection); vec3 LightDirection = normalize(lDirection);
vec3 nfNormal = normalize(fNormal); vec3 nfNormal = normalize(fNormal);
vec3 nviewDirection = normalize(fPosition); vec3 nviewDirection = normalize(fPosition);
mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords); mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords);
fColor = calcDirLight(texColor, fPosition, fNormal, tbn) fColor = calcDirLight(texColor, fPosition, fNormal, tbn) * 2
+ calcPointLight(texColor, fPosition, fNormal, tbn, 0)/4 + calcPointLight(texColor, fPosition, fNormal, tbn, 0)
+ calcPointLight(texColor, fPosition, fNormal, tbn, 1)/4 + calcPointLight(texColor, fPosition, fNormal, tbn, 1)
+ calcPointLight(texColor, fPosition, fNormal, tbn, 2)/4; + calcPointLight(texColor, fPosition, fNormal, tbn, 2);
} else { } else {
fColor = texColor + ifColor; fColor = texColor + ifColor;
} }
} }
} }