Fixed Spotlights

Former-commit-id: c802da26d010dcf7df6f234be204690e718634a6
This commit is contained in:
Lynix 2013-09-23 00:23:28 +02:00
parent aa4d5f5ab8
commit cd46555acc
2 changed files with 12 additions and 12 deletions

View File

@ -129,7 +129,7 @@ void main()
vec3 lightDir = -Lights[i].parameters1.xyz;
// Ambient
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x;
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * SceneAmbient.rgb;
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
@ -176,20 +176,20 @@ void main()
float lightDirLength = length(lightDir);
lightDir /= lightDirLength; // Normalisation
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*lightDirLength, 0.0);
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
// Ambient
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x;
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
// Modification de l'atténuation pour gérer le spot
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
float outerAngle = Lights[i].parameters3.y;
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
// Specular
@ -217,7 +217,7 @@ void main()
vec3 lightDir = normalize(-Lights[i].parameters1.xyz);
// Ambient
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x;
lightAmbient += Lights[i].color.rgb * Lights[i].factors.x * SceneAmbient.rgb;
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
@ -250,20 +250,20 @@ void main()
float lightDirLength = length(lightDir);
lightDir /= lightDirLength; // Normalisation
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.x*lightDirLength, 0.0);
float att = max(Lights[i].parameters1.w - Lights[i].parameters2.w*lightDirLength, 0.0);
// Ambient
lightAmbient += att * Lights[i].color.rgb * Lights[i].factors.x;
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
// Modification de l'atténuation pour gérer le spot
float curAngle = dot(Lights[i].parameters2.xyz, -lightDir);
float outerAngle = Lights[i].parameters3.y;
float innerMinusOuterAngle = Lights[i].parameters3.x - outerAngle;
att *= max((curAngle - outerAngle) / innerMinusOuterAngle, 0.0);
// Diffuse
float lambert = max(dot(normal, lightDir), 0.0);
lightDiffuse += att * lambert * Lights[i].color.rgb * Lights[i].factors.y;
}
@ -273,7 +273,7 @@ void main()
}
}
lightAmbient = (lightAmbient + SceneAmbient.rgb)*MaterialAmbient.rgb;
lightAmbient *= MaterialAmbient.rgb;
lightSpecular *= MaterialSpecular.rgb;
#if SPECULAR_MAPPING
lightSpecular *= texture(MaterialSpecularMap, texCoord).rgb; // Utiliser l'alpha de MaterialSpecular n'aurait aucun sens

File diff suppressed because one or more lines are too long