Set sun color below horizon

Thorsten Renk:
The following patch sets the sun color to alpha=0 when
the sun is below the local horizon, removing the oddity
that the sun is seen 'through' the terrain when the terrain
at large distance is rendered by the skydome.
This commit is contained in:
Torsten Dreyer 2014-10-08 12:45:01 +02:00
parent 93a63a0678
commit 543f1b7902
2 changed files with 12 additions and 1 deletions

View File

@ -52,7 +52,7 @@ using namespace simgear;
// Constructor // Constructor
SGSun::SGSun( void ) : SGSun::SGSun( void ) :
visibility(-9999.0), prev_sun_angle(-9999.0), path_distance(60000.0), visibility(-9999.0), prev_sun_angle(-9999.0), path_distance(60000.0),
sun_exp2_punch_through(7.0e-06) sun_exp2_punch_through(7.0e-06), horizon_angle(0.0)
{ {
} }
@ -341,6 +341,13 @@ bool SGSun::repaint( double sun_angle, double new_visibility ) {
gamma_correct_rgb( scene_color._v ); gamma_correct_rgb( scene_color._v );
gamma_correct_rgb( sun_color._v ); gamma_correct_rgb( sun_color._v );
if (sun_angle >91.0 * 3.1415/180.0 + horizon_angle)
{
sun_color[3] = 0;
o_halo_color[3]=0;
i_halo_color[3]=0;
}
(*sun_cl)[0] = sun_color; (*sun_cl)[0] = sun_color;
sun_cl->dirty(); sun_cl->dirty();
(*scene_cl)[0] = scene_color; (*scene_cl)[0] = scene_color;
@ -404,6 +411,9 @@ bool SGSun::reposition( double rightAscension, double declination,
if ( alt_half < 0.0 ) alt_half = 0.0; if ( alt_half < 0.0 ) alt_half = 0.0;
//angle at which the sun is visible below the horizon
horizon_angle = acos(r_earth/position_radius);
// Push the data to the property tree, so it can be used in the enviromental code // Push the data to the property tree, so it can be used in the enviromental code
if ( env_node ){ if ( env_node ){
env_node->setDoubleValue( "atmosphere/altitude-troposphere-top", r_tropo - r_earth ); env_node->setDoubleValue( "atmosphere/altitude-troposphere-top", r_tropo - r_earth );

View File

@ -51,6 +51,7 @@ class SGSun : public SGReferenced {
// distance of light traveling through the atmosphere // distance of light traveling through the atmosphere
double path_distance; double path_distance;
double sun_exp2_punch_through; double sun_exp2_punch_through;
double horizon_angle;
SGPropertyNode_ptr env_node; SGPropertyNode_ptr env_node;