+
+ // How much sun & moon transition should affect horizon color
+ float m_horizon_blend()
+ {
+ if (!m_sunlight_seen)
+ return 0;
+ float x; m_time_of_day >= 0.5 ? x = (1 - m_time_of_day) * 2 : x = m_time_of_day * 2;
+ if (x <= 0.3)
+ return 0;
+ if (x <= 0.4) // when the sun and moon are aligned
+ return (x - 0.3) * 10;
+ if (x <= 0.5)
+ return (0.5 - x) * 10;
+ return 0;
+ }
+
+ // Mix two colors by a given amount
+ video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor)
+ {
+ video::SColor result = video::SColor(
+ col1.getAlpha() * (1 - factor) + col2.getAlpha() * factor,
+ col1.getRed() * (1 - factor) + col2.getRed() * factor,
+ col1.getGreen() * (1 - factor) + col2.getGreen() * factor,
+ col1.getBlue() * (1 - factor) + col2.getBlue() * factor);
+ return result;
+ }
+ video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor)
+ {
+ video::SColorf result = video::SColorf(
+ col1.r * (1 - factor) + col2.r * factor,
+ col1.g * (1 - factor) + col2.g * factor,
+ col1.b * (1 - factor) + col2.b * factor,
+ col1.a * (1 - factor) + col2.a * factor);
+ return result;
+ }
+
+ bool m_visible;
+ video::SColor m_fallback_bg_color; // Used when m_visible=false