]> git.mxchange.org Git - flightgear.git/blobdiff - src/Time/light.cxx
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / Time / light.cxx
index c1d204ac339b4e289a040150951caf5379bc5274..1f24bef4e3f28fb108eff00d95fdf56b66683413 100644 (file)
@@ -57,8 +57,6 @@ FGLight::FGLight ()
       _sun_lat(0),
       _moon_lon(0),
       _moon_gc_lat(0),
-      _sunpos(0, 0, 0),
-      _moonpos(0, 0, 0),
       _sun_vec(0, 0, 0, 0),
       _moon_vec(0, 0, 0, 0),
       _sun_vec_inv(0, 0, 0, 0),
@@ -71,6 +69,7 @@ FGLight::FGLight ()
       _scene_ambient(0, 0, 0, 0),
       _scene_diffuse(0, 0, 0, 0),
       _scene_specular(0, 0, 0, 0),
+      _scene_chrome(0, 0, 0, 0),
       _sky_color(0, 0, 0, 0),
       _fog_color(0, 0, 0, 0),
       _cloud_color(0, 0, 0, 0),
@@ -153,6 +152,15 @@ void FGLight::bind () {
     prop->tie("/rendering/dome/fog/red",SGRawValuePointer<float>(&_fog_color[0]));
     prop->tie("/rendering/dome/fog/green",SGRawValuePointer<float>(&_fog_color[1]));
     prop->tie("/rendering/dome/fog/blue",SGRawValuePointer<float>(&_fog_color[2]));
+    // Properties used directly by effects
+    _chromeProps[0] = prop->getNode("/rendering/scene/chrome-light/red", true);
+    _chromeProps[1] = prop->getNode("/rendering/scene/chrome-light/green",
+                                    true);
+    _chromeProps[2] = prop->getNode("/rendering/scene/chrome-light/blue", true);
+    _chromeProps[3] = prop->getNode("/rendering/scene/chrome-light/alpha",
+                                    true);
+    for (int i = 0; i < 4; ++i)
+        _chromeProps[i]->setValue(0.0);
 }
 
 void FGLight::unbind () {
@@ -170,10 +178,10 @@ void FGLight::unbind () {
     prop->untie("/rendering/dome/sun/red");
     prop->untie("/rendering/dome/sun/green");
     prop->untie("/rendering/dome/sun/blue");
-    prop->untie("/rendering/dome/skyred");
+    prop->untie("/rendering/dome/sky/red");
     prop->untie("/rendering/dome/sky/green");
     prop->untie("/rendering/dome/sky/blue");
-    prop->untie("/rendering/dome/fogred");
+    prop->untie("/rendering/dome/fog/red");
     prop->untie("/rendering/dome/fog/green");
     prop->untie("/rendering/dome/fog/blue");
 }
@@ -200,7 +208,7 @@ void FGLight::update_sky_color () {
     // if the 4th field is 0.0, this specifies a direction ...
     // const GLfloat white[4]          = { 1.0,  1.0,  1.0,  1.0 };
     const GLfloat base_sky_color[4] = { 0.31, 0.43, 0.69, 1.0 };
-    const GLfloat base_fog_color[4] = { 0.84, 0.87, 1.0,  1.0 };
+    const GLfloat base_fog_color[4] = { 0.63, 0.72, 0.88,  1.0 };
 
     SG_LOG( SG_EVENT, SG_DEBUG, "Updating light parameters." );
 
@@ -267,6 +275,14 @@ void FGLight::update_sky_color () {
     _scene_diffuse[3] = 1.0;
     gamma_correct_rgb( _scene_diffuse.data() );
 
+    SGVec4f chrome = _scene_ambient * .4f + _scene_diffuse;
+    chrome[3] = 1.0f;
+    if (chrome != _scene_chrome) {
+        _scene_chrome = chrome;
+        for (int i = 0; i < 4; ++i)
+            _chromeProps[i]->setValue(static_cast<double>(_scene_chrome[i]));
+    }
+
     color = thesky->get_sun_color();
     _scene_specular[0] = color[0] * specular;
     _scene_specular[1] = color[1] * specular;
@@ -330,9 +346,9 @@ void FGLight::update_adj_fog_color () {
     // Calculate the fog color in the direction of the sun for
     // sunrise/sunset effects.
     //
-    float s_red =   color[0]*color[0];
-    float s_green = color[1]*color[1];
-    float s_blue =  color[2];
+    float s_red =   color[0]*color[0]*color[0];
+    float s_green = color[1]*color[1]*color[1];
+    float s_blue =  color[2]*color[2];
 
     // interpolate beween the sunrise/sunset color and the color
     // at the opposite direction of this effect. Take in account