]> git.mxchange.org Git - simgear.git/commitdiff
Adjust the fog punch through effect for oursun
authorehofman <ehofman>
Thu, 14 Aug 2003 09:58:48 +0000 (09:58 +0000)
committerehofman <ehofman>
Thu, 14 Aug 2003 09:58:48 +0000 (09:58 +0000)
simgear/scene/sky/oursun.cxx
simgear/scene/sky/oursun.hxx
simgear/scene/sky/sky.cxx

index 03d2a251e1f89779321d17ccebea9106e2d853d6..d8d8a9edc9f9a48ca6698eae52506a09e9adf951 100644 (file)
@@ -91,7 +91,8 @@ static int sgSunHaloPreDraw( ssgEntity *e ) {
     // cout << "push error = " << glGetError() << endl;
 
     glDisable( GL_DEPTH_TEST );
-//    glDisable( GL_FOG );
+    // glDisable( GL_FOG );
+    glFogf (GL_FOG_DENSITY, sun_exp2_punch_through);
     glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
 
     return true;
@@ -259,7 +260,7 @@ ssgBranch * SGSun::build( SGPath path, double sun_size ) {
                                    sgSunOrbPreDraw, sgSunOrbPostDraw );
 
     // force a repaint of the sun colors with arbitrary defaults
-    repaint( 0.0 );
+    repaint( 0.0, 1.0 );
 
     // build the halo
     // sun_texbuf = new GLubyte[64*64*3];
@@ -334,9 +335,19 @@ ssgBranch * SGSun::build( SGPath path, double sun_size ) {
 // 0 degrees = high noon
 // 90 degrees = sun rise/set
 // 180 degrees = darkest midnight
-bool SGSun::repaint( double sun_angle ) {
+bool SGSun::repaint( double sun_angle, double new_visibility ) {
     static float prev_sun_angle = 9999.0;
 
+    if ( visibility != new_visibility ) {
+        static double sqrt_m_log01 = sqrt( -log( 0.01 ) );
+        visibility = new_visibility;
+        if ( visibility < 8000 ) {
+            sun_exp2_punch_through = sqrt_m_log01 / (visibility * 10);
+        } else {
+            sun_exp2_punch_through = sqrt_m_log01 / (8000 * 10);
+        }
+    }
+
     if (prev_sun_angle != sun_angle)
     {
 
index 343a4edb27551243f507b14b976acfbbfb2f8e5a..212acdc8c11cade1dd2021f2f42191a23fb4eb69 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <simgear/misc/sg_path.hxx>
 
+static double sun_exp2_punch_through;
 
 class SGSun {
 
@@ -49,6 +50,8 @@ class SGSun {
     GLuint sun_texid;
     GLubyte *sun_texbuf;
 
+    double visibility;
+
 public:
 
     // Constructor
@@ -65,7 +68,7 @@ public:
     // 0 degrees = high noon
     // 90 degrees = sun rise/set
     // 180 degrees = darkest midnight
-    bool repaint( double sun_angle );
+    bool repaint( double sun_angle, double new_visibility );
 
     // reposition the sun at the specified right ascension and
     // declination, offset by our current position (p) so that it
index 833b3df8d9bf00349ef83e88e4f498ffb102a3aa..12c14f419965a50626ccdbd865bb01d9fb3a680d 100644 (file)
@@ -110,7 +110,7 @@ bool SGSky::repaint( const SGSkyColor &sc )
        dome->repaint( sc.sky_color, sc.fog_color, sc.sun_angle,
                        effective_visibility );
 
-       oursun->repaint( sc.sun_angle );
+       oursun->repaint( sc.sun_angle, effective_visibility );
 
        moon->repaint( sc.moon_angle );