From 2923bd15bc4ff0a2eeec0ce687be6901d6d98b1e Mon Sep 17 00:00:00 2001
From: ehofman <ehofman>
Date: Thu, 9 Apr 2009 10:42:32 +0000
Subject: [PATCH] Also adjust diffuse based on visibility although probably
 nobody will notice the difference

---
 src/Time/light.cxx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/Time/light.cxx b/src/Time/light.cxx
index 4e2398061..046fd8bdd 100644
--- a/src/Time/light.cxx
+++ b/src/Time/light.cxx
@@ -245,9 +245,11 @@ void FGLight::update_sky_color () {
     gamma_correct_rgb( _scene_ambient.data() );
 
     SGVec4f sun_color = thesky->get_sun_color();
-    _scene_diffuse[0] = (sun_color[0]*0.4 + _fog_color[0]*0.6) * diffuse;
-    _scene_diffuse[1] = (sun_color[1]*0.4 + _fog_color[1]*0.6) * diffuse;
-    _scene_diffuse[2] = (sun_color[2]*0.4 + _fog_color[2]*0.6) * diffuse;
+    float ndiff = (ambient + specular) / 2;
+    float idiff = 1.0 - ndiff;
+    _scene_diffuse[0] = (sun_color[0]*ndiff + _fog_color[0]*idiff) * diffuse;
+    _scene_diffuse[1] = (sun_color[1]*ndiff + _fog_color[1]*idiff) * diffuse;
+    _scene_diffuse[2] = (sun_color[2]*ndiff + _fog_color[2]*idiff) * diffuse;
     _scene_diffuse[3] = 1.0;
     gamma_correct_rgb( _scene_diffuse.data() );