From c5f6656f998457450b036285713f49854249cc13 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 30 Apr 2014 16:38:26 +0300 Subject: Make directional fog colors respect tonemap --- src/sky.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/sky.cpp b/src/sky.cpp index b5706f4e3..00072f17f 100644 --- a/src/sky.cpp +++ b/src/sky.cpp @@ -607,14 +607,31 @@ void Sky::update(float time_of_day, float time_brightness, // invert direction to match where the sun and moon are rising if (m_time_of_day > 0.5) pointcolor_blend = 1 - pointcolor_blend; - // horizon colors of sun and moon f32 pointcolor_light = rangelim(m_time_brightness * 3, 0.2, 1); + video::SColorf pointcolor_sun_f(1, 1, 1, 1); - pointcolor_sun_f.r = pointcolor_light * 1; - pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim(m_time_brightness, 0.25, 0.75) - 0.25) * 2 * 0.75); - pointcolor_sun_f.g = pointcolor_light * (pointcolor_sun_f.b * 0.375 + (rangelim(m_time_brightness, 0.05, 0.15) - 0.05) * 10 * 0.625); + if (m_sun_tonemap) + { + pointcolor_sun_f.r = pointcolor_light * (float)m_materials[3].EmissiveColor.getRed() / 255; + pointcolor_sun_f.b = pointcolor_light * (float)m_materials[3].EmissiveColor.getBlue() / 255; + pointcolor_sun_f.g = pointcolor_light * (float)m_materials[3].EmissiveColor.getGreen() / 255; + } + else + { + pointcolor_sun_f.r = pointcolor_light * 1; + pointcolor_sun_f.b = pointcolor_light * (0.25 + (rangelim(m_time_brightness, 0.25, 0.75) - 0.25) * 2 * 0.75); + pointcolor_sun_f.g = pointcolor_light * (pointcolor_sun_f.b * 0.375 + (rangelim(m_time_brightness, 0.05, 0.15) - 0.05) * 10 * 0.625); + } + video::SColorf pointcolor_moon_f(0.5 * pointcolor_light, 0.6 * pointcolor_light, 0.8 * pointcolor_light, 1); + if (m_moon_tonemap) + { + pointcolor_moon_f.r = pointcolor_light * (float)m_materials[4].EmissiveColor.getRed() / 255; + pointcolor_moon_f.b = pointcolor_light * (float)m_materials[4].EmissiveColor.getBlue() / 255; + pointcolor_moon_f.g = pointcolor_light * (float)m_materials[4].EmissiveColor.getGreen() / 255; + } + video::SColor pointcolor_sun = pointcolor_sun_f.toSColor(); video::SColor pointcolor_moon = pointcolor_moon_f.toSColor(); // calculate the blend color -- cgit v1.2.3