Index: osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp
===================================================================
--- osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp	(revision 31)
+++ osgVisual/src/sky_Silverlining/skySilverLining_skyDrawable.cpp	(revision 53)
@@ -43,5 +43,5 @@
 }
 
-skySilverLining_skyDrawable::skySilverLining_skyDrawable(osgViewer::Viewer* view)
+skySilverLining_skyDrawable::skySilverLining_skyDrawable(osgViewer::Viewer* view,  osg::CoordinateSystemNode* csn_)
         : osg::Drawable()
         , _view(view)
@@ -53,4 +53,5 @@
 	cloudLayerSlots.clear();
 	newCloudLayersToAdd = false;
+	sceneRoot = csn_;
 }
 
@@ -86,6 +87,62 @@
 void skySilverLining_skyDrawable::setSceneFog(SilverLining::Atmosphere *atmosphere) const
 {    
-	glEnable(GL_FOG);
-    glFogi(GL_FOG_MODE, GL_EXP);
+	//glEnable(GL_FOG);
+ //   glFogi(GL_FOG_MODE, GL_EXP);
+
+	////float hazeR, hazeG, hazeB;
+	////double hazeDepth, hazeDensity;
+	////atmosphere->GetHaze(hazeR, hazeG, hazeB, hazeDepth, hazeDensity);
+
+ //   //hazeDensity = 1.0 / 40000;
+	////hazeDensity = 0;
+	//float hazeDensity = 1.0 / atmosphere->GetConditions()->GetVisibility();
+
+ //   // Decrease fog density with altitude, to avoid fog effects through the vacuum of space.
+ //   static const double H = 8435.0; // Pressure scale height of Earth's atmosphere
+ //   double isothermalEffect = exp(-(atmosphere->GetConditions()->GetLocation().GetAltitude() / H));     
+ //   if (isothermalEffect <= 0) isothermalEffect = 1E-9;
+ //   if (isothermalEffect > 1.0) isothermalEffect = 1.0;
+ //   hazeDensity *= isothermalEffect;
+
+ //   bool silverLiningHandledTheFog = false;
+
+ //   if (atmosphere->GetFogEnabled())
+ //   {
+ //           float density, r, g, b;
+ //           // Note, the fog color returned is already lit
+ //           atmosphere->GetFogSettings(&density, &r, &g, &b);
+
+ //           if (density > hazeDensity)
+ //           {
+ //                   glFogf(GL_FOG_DENSITY, density);
+
+ //                   GLfloat fogColor[4] = {r, g, b, 1.0};
+ //                   glFogfv(GL_FOG_COLOR, fogColor);
+
+ //                   silverLiningHandledTheFog = true;
+ //           }
+ //   }
+ //   
+ //   if (!silverLiningHandledTheFog)
+ //   {
+ //           GLfloat fogColor[4];
+ //           //atmosphere->GetHorizonColor(yaw, &fogColor[0], &fogColor[1], &fogColor[2]);	// New version of this call: SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */
+	//		atmosphere->GetHorizonColor( 0, &fogColor[0], &fogColor[1], &fogColor[2]);
+ //           glFogfv(GL_FOG_COLOR, fogColor);
+
+ //           glFogf(GL_FOG_DENSITY, hazeDensity);
+ //   }
+
+
+
+
+
+	
+	osg::ref_ptr<osg::Fog> fog = new osg::Fog;
+    fog->setMode(osg::Fog::EXP);
+	//fog->setUseRadialFog( true );
+
+	//_objectsNode  = erde oder object, das mit nebel bedacht werden soll	
+	sceneRoot->getOrCreateStateSet()->setAttributeAndModes(fog.get());
 
 	//float hazeR, hazeG, hazeB;
@@ -114,10 +171,8 @@
             if (density > hazeDensity)
             {
-                    glFogf(GL_FOG_DENSITY, density);
-
-                    GLfloat fogColor[4] = {r, g, b, 1.0};
-                    glFogfv(GL_FOG_COLOR, fogColor);
-
-                    silverLiningHandledTheFog = true;
+				fog->setDensity(density);
+				fog->setColor(osg::Vec4(r, g, b, 1.0));
+
+				silverLiningHandledTheFog = true;
             }
     }
@@ -125,44 +180,11 @@
     if (!silverLiningHandledTheFog)
     {
-            GLfloat fogColor[4];
-            //atmosphere->GetHorizonColor(yaw, &fogColor[0], &fogColor[1], &fogColor[2]);	// New version of this call: SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */
-			atmosphere->GetHorizonColor( 0, &fogColor[0], &fogColor[1], &fogColor[2]);
-            glFogfv(GL_FOG_COLOR, fogColor);
-
-            glFogf(GL_FOG_DENSITY, hazeDensity);
+		float r, g, b;
+		atmosphere->GetHorizonColor(0, &r, &g, &b);// New version of this call: since SL_1.94 /** \todo transmit the yaw value of the center channel to all slaves for consistent fog color. */
+
+		fog->setDensity(hazeDensity);
+		fog->setColor(osg::Vec4(r, g, b, 1.0));
     }
 
-
- //   _fog = new osg::Fog;
-	//_objectsNode  = erde oder object, das mit nebel bedacht werden soll	
-	//_objectsNode->getOrCreateStateSet()->setAttributeAndModes(_fog.get());
-
-	//fog->setMode(osg::Fog::EXP);
-
- //   float hazeDensity = 0;//1.0 / 10000.0; //0.000075f
- //   bool silverLiningHandledTheFog = false;
-
- //   if (atmosphere->GetFogEnabled())
- //   {
- //       float density, r, g, b;
- //       atmosphere->GetFogSettings(&density, &r, &g, &b);
-
- //       if (density > hazeDensity)
- //       {
- //           fog->setDensity(density);
- //           fog->setColor(osg::Vec4(r, g, b, 1.0));
-
- //           silverLiningHandledTheFog = true;
- //       }
- //   }
-
- //   if (!silverLiningHandledTheFog)
- //   {
- //       float r, g, b;
- //       atmosphere->GetHorizonColor(0, &r, &g, &b);
-
- //       fog->setDensity(hazeDensity);
- //       fog->setColor(osg::Vec4(r, g, b, 1.0));
- //   }
 }
 
@@ -278,2 +300,7 @@
 	}
 }
+
+void skySilverLining_skyDrawable::shutdown()
+{
+	sceneRoot = NULL;
+}
