From: ehofman Date: Thu, 14 Aug 2003 09:58:48 +0000 (+0000) Subject: Adjust the fog punch through effect for oursun X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e5e1e165b9cb79f8cb81fb208cc8a9805cfca981;p=simgear.git Adjust the fog punch through effect for oursun --- diff --git a/simgear/scene/sky/oursun.cxx b/simgear/scene/sky/oursun.cxx index 03d2a251..d8d8a9ed 100644 --- a/simgear/scene/sky/oursun.cxx +++ b/simgear/scene/sky/oursun.cxx @@ -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) { diff --git a/simgear/scene/sky/oursun.hxx b/simgear/scene/sky/oursun.hxx index 343a4edb..212acdc8 100644 --- a/simgear/scene/sky/oursun.hxx +++ b/simgear/scene/sky/oursun.hxx @@ -34,6 +34,7 @@ #include +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 diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 833b3df8..12c14f41 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -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 );