bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle,
double vis )
{
- double diff;
+ double diff, prev_sun_angle = 999.0;
sgVec3 outer_param, outer_amt, outer_diff;
sgVec3 middle_param, middle_amt, middle_diff;
int i, j;
+ if (prev_sun_angle == sun_angle)
+ return true;
+
+ prev_sun_angle = sun_angle;
+
// Check for sunrise/sunset condition
- if ( (sun_angle > 80.0) && (sun_angle < 100.0) ) {
+ if (sun_angle > 80.0) // && (sun_angle < 100.0) )
+ {
// 0.0 - 0.4
sgSetVec3( outer_param,
(10.0 - fabs(90.0 - sun_angle)) / 20.0,
# include <plib/ssgaLensFlare.h>
#endif
+#include <simgear/screen/colors.hxx>
+
#include "sphere.hxx"
#include "oursun.hxx"
// 90 degrees = sun rise/set
// 180 degrees = darkest midnight
bool SGSun::repaint( double sun_angle ) {
- if ( sun_angle * SGD_RADIANS_TO_DEGREES < 100 ) {
- // else sun is well below horizon (so no point in repainting it)
+ static float prev_sun_angle = 9999.0;
+
+ // else sun is well below horizon (so no point in repainting it)
+#if 0
+ if ( (sun_angle * SGD_RADIANS_TO_DEGREES < 100 )
+ && (prev_sun_angle != sun_angle))
+ {
+ prev_sun_angle = sun_angle;
// x_10 = sun_angle^10
double x_10 = sun_angle * sun_angle * sun_angle * sun_angle * sun_angle
sgVec4 color;
sgSetVec4( color,
(ambient * 6.0) - 1.0, // minimum value = 0.8
- (ambient * 11.0) - 2.8, // minimum value = 0.5
+ (ambient * 11.0) - 2.7, // minimum value = 0.6
(ambient * 12.0) - 3.6, // minimum value = 0.0
1.0 );
if (color[1] > 1.0) color[1] = 1.0;
if (color[2] > 1.0) color[2] = 1.0;
- // cout << "color = " << color[0] << " " << color[1] << " "
- // << color[2] << endl;
+#else
+
+ if (prev_sun_angle != sun_angle)
+ {
+
+ prev_sun_angle = sun_angle;
+
+ float sun_factor = 4*cos(sun_angle);
+
+ if (sun_factor > 1) sun_factor = 1.0;
+ if (sun_factor < -1) sun_factor = -1.0;
+ sun_factor = sun_factor/2 + 0.5;
+
+ sgVec4 color;
+ color[0] = pow(sun_factor, 0.25);
+ color[1] = pow(sun_factor, 0.50);
+ color[2] = pow(sun_factor, 4.0);
+ color[3] = 1.0;
+
+#endif
+ gamma_correct_rgb( color );
+
+ // cout << "color = " << color[0] << " " << color[1] << " "
+ // << color[2] << endl;
- float *ptr;
- ptr = cl->get( 0 );
- sgCopyVec4( ptr, color );
+ float *ptr;
+ ptr = cl->get( 0 );
+ sgCopyVec4( ptr, color );
}
return true;
// simple architecture independant gamma correction function.
-inline void gamma_correct(float *color,
+inline void gamma_correct_rgb(float *color,
float reff = 2.5, float system = system_gamma)
{
color[0] = pow(color[0], reff/system);
color[2] = pow(color[2], reff/system);
};
+inline void gamma_correct_c(float *color,
+ float reff = 2.5, float system = system_gamma)
+{
+ *color = pow(*color, reff/system);
+};
+
+inline void gamma_restore_rgb(float *color,
+ float reff = 2.5, float system = system_gamma)
+{
+ color[0] = pow(color[0], system/reff);
+ color[1] = pow(color[1], system/reff);
+ color[2] = pow(color[2], system/reff);
+};
+
+inline void gamma_restore_c(float *color,
+ float reff = 2.5, float system = system_gamma)
+{
+ *color = pow(*color, system/reff);
+};
+
+
#endif // _SG_COLORS_HXX