Add double-sided lighting also for ambient lights

lights3
Armin Burgmeier 2015-08-03 22:43:07 -04:00
parent 5126e86315
commit edc611f3b1
2 changed files with 5 additions and 3 deletions

View File

@ -7,6 +7,8 @@ uniform sampler2D ambientTex;
uniform mat3x2 ambientTransform;
uniform float ambientBrightness;
#endif
//uniform float cullMode; // 0 if backface culling is enabled, 1 if it is disabled
// Already declared in LightShader.glsl
slice(texture+6)
{
@ -33,6 +35,6 @@ slice(light+1)
#else
// For objects, ambient brightness is coming from the front
vec3 ambientDir = vec3(0.0, 0.0, 1.0);
light = mix(light, max(dot(normal, ambientDir), 0.0), ambient);
light = mix(light, max(max(dot(normal, ambientDir), 0.0), cullMode * max(dot(-normal, ambientDir), 0.0)), ambient);
#endif
}

View File

@ -56,9 +56,9 @@ slice(texture+5)
slice(light)
{
float light = 2.0 * lightBright * max(max(dot(normal, lightDir), 0.0), cullMode * max(dot(vec3(-normal.xy, normal.z), lightDir), 0.0));
float light = 2.0 * lightBright * max(max(dot(normal, lightDir), 0.0), cullMode * max(dot(-normal, lightDir), 0.0));
#ifdef HAVE_2PX
float light2 = 2.0 * lightBright * max(max(dot(normal2, lightDir), 0.0), cullMode * max(dot(vec3(-normal2.xy, normal2.z), lightDir), 0.0));
float light2 = 2.0 * lightBright * max(max(dot(normal2, lightDir), 0.0), cullMode * max(dot(-normal2, lightDir), 0.0));
#endif
}