X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient%2Fsky.h;h=e03683f121a40a03c41689e12e3ac1ff50425df1;hb=c7bcebb62856ae5fdb23a13e6fa1052eae700ddf;hp=17654501575ce7e961389e1ebf97fa18f245e036;hpb=3077afc0a2039cd4c8d64d9df62ed9b2ba6463dc;p=minetest.git diff --git a/src/client/sky.h b/src/client/sky.h index 176545015..e03683f12 100644 --- a/src/client/sky.h +++ b/src/client/sky.h @@ -17,15 +17,16 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + +#include "irrlichttypes_extrabloated.h" #include #include #include "camera.h" -#include "irrlichttypes_extrabloated.h" #include "irr_ptr.h" +#include "shader.h" #include "skyparams.h" -#pragma once - #define SKY_MATERIAL_COUNT 12 class ITextureSource; @@ -35,7 +36,7 @@ class Sky : public scene::ISceneNode { public: //! constructor - Sky(s32 id, ITextureSource *tsrc); + Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShaderSource *ssrc); virtual void OnRegisterSceneNode(); @@ -64,19 +65,21 @@ class Sky : public scene::ISceneNode } void setSunVisible(bool sun_visible) { m_sun_params.visible = sun_visible; } - void setSunTexture(std::string sun_texture, - std::string sun_tonemap, ITextureSource *tsrc); + bool getSunVisible() const { return m_sun_params.visible; } + void setSunTexture(const std::string &sun_texture, + const std::string &sun_tonemap, ITextureSource *tsrc); void setSunScale(f32 sun_scale) { m_sun_params.scale = sun_scale; } void setSunriseVisible(bool glow_visible) { m_sun_params.sunrise_visible = glow_visible; } - void setSunriseTexture(std::string sunglow_texture, ITextureSource* tsrc); + void setSunriseTexture(const std::string &sunglow_texture, ITextureSource* tsrc); void setMoonVisible(bool moon_visible) { m_moon_params.visible = moon_visible; } - void setMoonTexture(std::string moon_texture, - std::string moon_tonemap, ITextureSource *tsrc); + bool getMoonVisible() const { return m_moon_params.visible; } + void setMoonTexture(const std::string &moon_texture, + const std::string &moon_tonemap, ITextureSource *tsrc); void setMoonScale(f32 moon_scale) { m_moon_params.scale = moon_scale; } void setStarsVisible(bool stars_visible) { m_star_params.visible = stars_visible; } - void setStarCount(u16 star_count, bool force_update); + void setStarCount(u16 star_count); void setStarColor(video::SColor star_color) { m_star_params.starcolor = star_color; } void setStarScale(f32 star_scale) { m_star_params.scale = star_scale; updateStars(); } @@ -86,22 +89,26 @@ class Sky : public scene::ISceneNode void setVisible(bool visible) { m_visible = visible; } // Set only from set_sky API void setCloudsEnabled(bool clouds_enabled) { m_clouds_enabled = clouds_enabled; } - void setFallbackBgColor(const video::SColor &fallback_bg_color) + void setFallbackBgColor(video::SColor fallback_bg_color) { m_fallback_bg_color = fallback_bg_color; } - void overrideColors(const video::SColor &bgcolor, const video::SColor &skycolor) + void overrideColors(video::SColor bgcolor, video::SColor skycolor) { m_bgcolor = bgcolor; m_skycolor = skycolor; } void setSkyColors(const SkyColor &sky_color); void setHorizonTint(video::SColor sun_tint, video::SColor moon_tint, - std::string use_sun_tint); + const std::string &use_sun_tint); void setInClouds(bool clouds) { m_in_clouds = clouds; } void clearSkyboxTextures() { m_sky_params.textures.clear(); } - void addTextureToSkybox(std::string texture, int material_id, + void addTextureToSkybox(const std::string &texture, int material_id, ITextureSource *tsrc); + const video::SColorf &getCurrentStarColor() const { return m_star_color; } + + float getSkyBodyOrbitTilt() const { return m_sky_body_orbit_tilt; } + private: aabb3f m_box; video::SMaterial m_materials[SKY_MATERIAL_COUNT]; @@ -123,7 +130,7 @@ class Sky : public scene::ISceneNode } // Mix two colors by a given amount - video::SColor m_mix_scolor(video::SColor col1, video::SColor col2, f32 factor) + static 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, @@ -132,7 +139,7 @@ class Sky : public scene::ISceneNode col1.getBlue() * (1 - factor) + col2.getBlue() * factor); return result; } - video::SColorf m_mix_scolorf(video::SColorf col1, video::SColorf col2, f32 factor) + static 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, @@ -145,7 +152,7 @@ class Sky : public scene::ISceneNode bool m_visible = true; // Used when m_visible=false video::SColor m_fallback_bg_color = video::SColor(255, 255, 255, 255); - bool m_first_update = true; + bool m_first_update = true; // Set before the sky is updated for the first time float m_time_of_day; float m_time_brightness; bool m_sunlight_seen; @@ -155,6 +162,8 @@ class Sky : public scene::ISceneNode bool m_clouds_enabled = true; // Initialised to true, reset only by set_sky API bool m_directional_colored_fog; bool m_in_clouds = true; // Prevent duplicating bools to remember old values + bool m_enable_shaders = false; + float m_sky_body_orbit_tilt = 0.0f; video::SColorf m_bgcolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); video::SColorf m_skycolor_bright_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); @@ -179,7 +188,9 @@ class Sky : public scene::ISceneNode bool m_default_tint = true; + u64 m_seed = 0; irr_ptr m_stars; + video::SColorf m_star_color; video::ITexture *m_sun_texture; video::ITexture *m_moon_texture; @@ -187,7 +198,6 @@ class Sky : public scene::ISceneNode video::ITexture *m_moon_tonemap; void updateStars(); - void updateStarsColor(video::SColor color); void draw_sun(video::IVideoDriver *driver, float sunsize, const video::SColor &suncolor, const video::SColor &suncolor2, float wicked_time_of_day); @@ -198,5 +208,8 @@ class Sky : public scene::ISceneNode void draw_stars(video::IVideoDriver *driver, float wicked_time_of_day); void place_sky_body(std::array &vertices, float horizon_position, float day_position); - void setSkyDefaults(); }; + +// calculates value for sky body positions for the given observed time of day +// this is used to draw both Sun/Moon and shadows +float getWickedTimeOfDay(float time_of_day);