]> git.mxchange.org Git - flightgear.git/commitdiff
Take the visibility in account for the sky color
authorehofman <ehofman>
Sun, 15 Jun 2003 11:30:25 +0000 (11:30 +0000)
committerehofman <ehofman>
Sun, 15 Jun 2003 11:30:25 +0000 (11:30 +0000)
src/Time/light.cxx

index 83d2edfff5361970fd95d533c36275f50ed97fea..a55127ca0a1935f361585fc0110ca325da26b24a 100644 (file)
@@ -56,6 +56,7 @@ SG_USING_STD(string);
 #include <simgear/screen/colors.hxx>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Main/viewer.hxx>
 
 #include "light.hxx"
@@ -229,12 +230,19 @@ void fgLIGHT::UpdateAdjFog( void ) {
     float s_blue =  (fog_color[2] + 2 * sun_color[2]) / 3;
 
     // interpolate beween the sunrise/sunset color and the color
-    // at the opposite direction of this effect.
+    // at the opposite direction of this effect. Take in account
+    // the current visibility.
     //
+    float av = thesky->get_visibility();
+    if (av > 45000)
+       av = 45000;
+
+    float avf = 0.87 - (45000 - av) / 83333.33;
     float sif = 0.5 - cos(sun_angle*2)/2;
+
     float rf1 = fabs((rotation - SGD_PI) / SGD_PI);             // 0.0 .. 1.0
-    float rf2 = 0.87 * pow(rf1 * rf1, 1/sif);
-    float rf3 = 1.0 - rf2;
+    float rf2 = avf * pow(rf1 * rf1, 1/sif);
+    float rf3 = 0.94 - rf2;
 
     adj_fog_color[0] = rf3 * fog_color[0] + rf2 * s_red;
     adj_fog_color[1] = rf3 * fog_color[1] + rf2 * s_green;