1
0
Fork 0

Expose the color of the sun (which is not the scene specular color anymore)

This commit is contained in:
ehofman 2009-08-16 19:35:24 +00:00 committed by Tim Moore
parent 282ec8ddec
commit 25a99a2417
2 changed files with 26 additions and 2 deletions

View file

@ -71,6 +71,7 @@ FGLight::FGLight ()
_scene_ambient(0, 0, 0, 0), _scene_ambient(0, 0, 0, 0),
_scene_diffuse(0, 0, 0, 0), _scene_diffuse(0, 0, 0, 0),
_scene_specular(0, 0, 0, 0), _scene_specular(0, 0, 0, 0),
_sun_color(1, 1, 1, 1),
_sky_color(0, 0, 0, 0), _sky_color(0, 0, 0, 0),
_fog_color(0, 0, 0, 0), _fog_color(0, 0, 0, 0),
_cloud_color(0, 0, 0, 0), _cloud_color(0, 0, 0, 0),
@ -147,6 +148,15 @@ void FGLight::bind () {
prop->tie("/rendering/scene/specular/red",SGRawValuePointer<float>(&_scene_specular[0])); prop->tie("/rendering/scene/specular/red",SGRawValuePointer<float>(&_scene_specular[0]));
prop->tie("/rendering/scene/specular/green",SGRawValuePointer<float>(&_scene_specular[1])); prop->tie("/rendering/scene/specular/green",SGRawValuePointer<float>(&_scene_specular[1]));
prop->tie("/rendering/scene/specular/blue",SGRawValuePointer<float>(&_scene_specular[2])); prop->tie("/rendering/scene/specular/blue",SGRawValuePointer<float>(&_scene_specular[2]));
prop->tie("/rendering/dome/sun/red",SGRawValuePointer<float>(&_sun_color[0]));
prop->tie("/rendering/dome/sun/green",SGRawValuePointer<float>(&_sun_color[1]));
prop->tie("/rendering/dome/sun/blue",SGRawValuePointer<float>(&_sun_color[2]));
prop->tie("/rendering/dome/sky/red",SGRawValuePointer<float>(&_sky_color[0]));
prop->tie("/rendering/dome/sky/green",SGRawValuePointer<float>(&_sky_color[1]));
prop->tie("/rendering/dome/sky/blue",SGRawValuePointer<float>(&_sky_color[2]));
prop->tie("/rendering/dome/fog/red",SGRawValuePointer<float>(&_fog_color[0]));
prop->tie("/rendering/dome/fog/green",SGRawValuePointer<float>(&_fog_color[1]));
prop->tie("/rendering/dome/fog/blue",SGRawValuePointer<float>(&_fog_color[1]));
} }
void FGLight::unbind () { void FGLight::unbind () {
@ -161,6 +171,12 @@ void FGLight::unbind () {
prop->untie("/rendering/scene/specular/red"); prop->untie("/rendering/scene/specular/red");
prop->untie("/rendering/scene/specular/green"); prop->untie("/rendering/scene/specular/green");
prop->untie("/rendering/scene/specular/blue"); prop->untie("/rendering/scene/specular/blue");
prop->untie("/rendering/dome/sun/red");
prop->untie("/rendering/dome/sun/green");
prop->untie("/rendering/dome/sun/blue");
prop->untie("/rendering/dome/skyred");
prop->untie("/rendering/dome/sky/green");
prop->untie("/rendering/dome/sky/blue");
} }
@ -245,7 +261,7 @@ void FGLight::update_sky_color () {
_scene_ambient[3] = 1.0; _scene_ambient[3] = 1.0;
gamma_correct_rgb( _scene_ambient.data() ); gamma_correct_rgb( _scene_ambient.data() );
SGVec4f sun_color = thesky->get_sun_color(); SGVec4f sun_color = thesky->get_scene_color();
float ndiff = (ambient + specular) / 2; float ndiff = (ambient + specular) / 2;
float idiff = 1.0 - ndiff; float idiff = 1.0 - ndiff;
_scene_diffuse[0] = (sun_color[0]*ndiff + _fog_color[0]*idiff) * diffuse; _scene_diffuse[0] = (sun_color[0]*ndiff + _fog_color[0]*idiff) * diffuse;
@ -259,6 +275,13 @@ void FGLight::update_sky_color () {
_scene_specular[2] = sun_color[2] * specular; _scene_specular[2] = sun_color[2] * specular;
_scene_specular[3] = 1.0; _scene_specular[3] = 1.0;
gamma_correct_rgb( _scene_specular.data() ); gamma_correct_rgb( _scene_specular.data() );
sun_color = thesky->get_sun_color();
_sun_color[0] = sun_color[0];
_sun_color[1] = sun_color[1];
_sun_color[2] = sun_color[2];
_sun_color[3] = sun_color[3];
gamma_correct_rgb( _sun_color.data() );
} }
@ -308,7 +331,7 @@ void FGLight::update_adj_fog_color () {
// revert to unmodified values before usign them. // revert to unmodified values before usign them.
// //
SGVec4f sun_color = thesky->get_sun_color(); SGVec4f sun_color = thesky->get_scene_color();
gamma_restore_rgb( _fog_color.data() ); gamma_restore_rgb( _fog_color.data() );
gamma_restore_rgb( _sky_color.data() ); gamma_restore_rgb( _sky_color.data() );

View file

@ -90,6 +90,7 @@ private:
SGVec4f _scene_specular; SGVec4f _scene_specular;
// clear sky, fog and cloud color // clear sky, fog and cloud color
SGVec4f _sun_color;
SGVec4f _sky_color; SGVec4f _sky_color;
SGVec4f _fog_color; SGVec4f _fog_color;
SGVec4f _cloud_color; SGVec4f _cloud_color;