From 48ac04456faccc0d3e4cb9c1f822c305713a1a8b Mon Sep 17 00:00:00 2001 From: ehofman Date: Sun, 29 Mar 2009 11:41:45 +0000 Subject: [PATCH] Adding ambient support for ac3d aircraft models reveiled a mistake in the scne ambient calculation. Decreasing visibility now increases ambient color giving a nice dark color on bright days and a much more visible color on normal days. --- src/Time/light.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Time/light.cxx b/src/Time/light.cxx index 800ddf687..ea55568ae 100644 --- a/src/Time/light.cxx +++ b/src/Time/light.cxx @@ -234,10 +234,13 @@ void FGLight::update_sky_color () { gamma_correct_rgb( _cloud_color.data() ); SGVec4f sun_color = thesky->get_sun_color(); + float av = thesky->get_visibility(); + if (av > 45000) av = 45000; + float avf = ambient+1.0 - log(av)/11.0; - _scene_ambient[0] = ((sun_color[0]*0.25 + _cloud_color[0]*0.75) + ambient) / 2; - _scene_ambient[1] = ((sun_color[1]*0.25 + _cloud_color[1]*0.75) + ambient) / 2; - _scene_ambient[2] = ((sun_color[2]*0.25 + _cloud_color[2]*0.75) + ambient) / 2; + _scene_ambient[0] = sun_color[0] * avf; + _scene_ambient[1] = sun_color[1] * avf; + _scene_ambient[2] = sun_color[2] * avf; _scene_ambient[3] = 1.0; _scene_diffuse[0] = (sun_color[0]*0.25 + _fog_color[0]*0.75) * diffuse; -- 2.39.5