// 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;
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];
// 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)
{
#include <simgear/misc/sg_path.hxx>
+static double sun_exp2_punch_through;
class SGSun {
GLuint sun_texid;
GLubyte *sun_texbuf;
+ double visibility;
+
public:
// Constructor
// 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
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 );