diff --git a/planet/Graphics.ocg/AmbientShader.glsl b/planet/Graphics.ocg/AmbientShader.glsl index d50456ada..3fe12fc1b 100644 --- a/planet/Graphics.ocg/AmbientShader.glsl +++ b/planet/Graphics.ocg/AmbientShader.glsl @@ -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 } diff --git a/planet/Graphics.ocg/LightShader.glsl b/planet/Graphics.ocg/LightShader.glsl index 8d0305fec..b783fa521 100644 --- a/planet/Graphics.ocg/LightShader.glsl +++ b/planet/Graphics.ocg/LightShader.glsl @@ -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 }