diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2013-06-30 18:17:14 +0300 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2013-12-15 14:28:50 +0100 |
commit | 848f80b2e53155c76f598c2f7e0ebaff1faea8dc (patch) | |
tree | 80a82ec413866bd73bca1f0cefa93b065d60a9f2 /src/sky.h | |
parent | e9e9fd7c3f12bc5119b567ad37527d777859dbc0 (diff) | |
download | minetest-848f80b2e53155c76f598c2f7e0ebaff1faea8dc.tar.gz minetest-848f80b2e53155c76f598c2f7e0ebaff1faea8dc.tar.bz2 minetest-848f80b2e53155c76f598c2f7e0ebaff1faea8dc.zip |
Directional fog + horizon colors, based on sun & moon positions at sunrise / sunset
Diffstat (limited to 'src/sky.h')
-rw-r--r-- | src/sky.h | 41 |
1 files changed, 39 insertions, 2 deletions
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include <ISceneNode.h> +#include "localplayer.h" #ifndef SKY_HEADER #define SKY_HEADER @@ -31,7 +32,7 @@ class Sky : public scene::ISceneNode { public: //! constructor - Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id); + Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, LocalPlayer* player); virtual void OnRegisterSceneNode(); @@ -61,7 +62,42 @@ public: private: core::aabbox3d<f32> Box; video::SMaterial m_materials[SKY_MATERIAL_COUNT]; - + + // 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_first_update; float m_time_of_day; float m_time_brightness; @@ -78,6 +114,7 @@ private: v3f m_stars[SKY_STAR_COUNT]; u16 m_star_indices[SKY_STAR_COUNT*4]; video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4]; + LocalPlayer* m_player; }; #endif |