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
float amb = 0.2;
float mult = 2;
float mult = 1;
float luminance = (diff + amb + spec);
@ -75,7 +75,7 @@ vec4 calcPointLight(vec4 tex, vec3 fPos, vec3 fNorm, mat3 tbn, int i) {
// Attenuation
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
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){
luminance = floor(luminance * lightLevels) / lightLevels;
attenuation = 1;
}
return vec4(pointLightCol[i].xyz * luminance * attenuation * tex.xyz, pointLightCol[i].w);
}
@ -131,31 +132,31 @@ main()
mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords);
if(isPickingMode){
fColor = ifColor;
}else{
if(drawTextures) {
texColor = texture(texCol, texCoords);
} else {
texColor = ifColor;
}
fColor = ifColor;
}else{
if(drawTextures) {
texColor = texture(texCol, texCoords);
} else {
texColor = ifColor;
}
if(isLightSource) {
fColor = texColor;
} else if(isSky) {
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
} else if(isPhong) {
// Get lighting vectors
vec3 LightDirection = normalize(lDirection);
vec3 nfNormal = normalize(fNormal);
vec3 nviewDirection = normalize(fPosition);
mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords);
if(isLightSource) {
fColor = texColor;
} else if(isSky) {
fColor = skyMult * normalize(texColor*texColor*texColor*2/1.41)*2;
} else if(isPhong) {
// Get lighting vectors
vec3 LightDirection = normalize(lDirection);
vec3 nfNormal = normalize(fNormal);
vec3 nviewDirection = normalize(fPosition);
mat3 tbn = cotangent_frame(fNormal, fPosition, texCoords);
fColor = calcDirLight(texColor, fPosition, fNormal, tbn)
+ calcPointLight(texColor, fPosition, fNormal, tbn, 0)/4
+ calcPointLight(texColor, fPosition, fNormal, tbn, 1)/4
+ calcPointLight(texColor, fPosition, fNormal, tbn, 2)/4;
} else {
fColor = texColor + ifColor;
}
}
fColor = calcDirLight(texColor, fPosition, fNormal, tbn) * 2
+ calcPointLight(texColor, fPosition, fNormal, tbn, 0)
+ calcPointLight(texColor, fPosition, fNormal, tbn, 1)
+ calcPointLight(texColor, fPosition, fNormal, tbn, 2);
} else {
fColor = texColor + ifColor;
}
}
}