]> git.mxchange.org Git - flightgear.git/blobdiff - src/Time/light.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Time / light.cxx
index ba1bfd294d61b8d753ebd81e304ab15bae8e370f..a6021b17480206367ff866dd01ee21c290313ad9 100644 (file)
@@ -52,6 +52,7 @@ SG_USING_STD(string);
 #include <simgear/math/interpolater.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/misc/sg_path.hxx>
+#include <simgear/sky/sky.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Main/globals.hxx>
@@ -60,6 +61,7 @@ SG_USING_STD(string);
 #include "light.hxx"
 #include "sunpos.hxx"
 
+extern SGSky *thesky;           // FIXME: from main.cxx
 
 fgLIGHT cur_light_params;
 
@@ -110,7 +112,6 @@ void fgLIGHT::Update( void ) {
 #else // default
     GLfloat base_sky_color[4] = { 0.336, 0.406, 0.574, 1.0 };
 #endif
-    // base fog color
     GLfloat base_fog_color[4] = { 0.80, 0.83, 1.0, 1.0 };
     double deg, ambient, diffuse, specular, sky_brightness;
 
@@ -121,6 +122,14 @@ void fgLIGHT::Update( void ) {
     // calculate lighting parameters based on sun's relative angle to
     // local up
 
+    // base fog color
+    float *sun_color = thesky->get_sun_color();
+
+    base_fog_color[0] *= (1.25 - sun_color[0]/4.0);    // 100% red
+    base_fog_color[1] *= (0.48 + sun_color[1]/1.923);  //  40% green
+    base_fog_color[2] *= sun_color[2];                 //   0% blue
+
+
     deg = sun_angle * SGD_RADIANS_TO_DEGREES;
     SG_LOG( SG_EVENT, SG_INFO, "  Sun angle = " << deg );