diff --git a/Editor/WeatherWindow.cpp b/Editor/WeatherWindow.cpp index 8c193206d..4798375b3 100644 --- a/Editor/WeatherWindow.cpp +++ b/Editor/WeatherWindow.cpp @@ -225,6 +225,15 @@ void WeatherWindow::Create(EditorComponent* _editor) }); AddWidget(&starsSlider); + skyRotationSlider.Create(0, 360, 0, 10000, "Sky Texture Rotation: "); + skyRotationSlider.SetTooltip("Rotate the sky texture horizontally. (If using a sky texture)"); + skyRotationSlider.SetSize(XMFLOAT2(wid, hei)); + skyRotationSlider.SetPos(XMFLOAT2(x, y += step)); + skyRotationSlider.OnSlide([&](wi::gui::EventArgs args) { + GetWeather().sky_rotation = wi::math::DegreesToRadians(args.fValue); + }); + AddWidget(&skyRotationSlider); + realisticskyCheckBox.Create("Realistic sky: "); realisticskyCheckBox.SetTooltip("Physically based sky rendering model.\nNote that realistic sky requires a sun (directional light) to be visible."); realisticskyCheckBox.SetSize(XMFLOAT2(hei, hei)); @@ -1079,6 +1088,7 @@ void WeatherWindow::Update() windRandomnessSlider.SetValue(weather.windRandomness); skyExposureSlider.SetValue(weather.skyExposure); starsSlider.SetValue(weather.stars); + skyRotationSlider.SetValue(wi::math::RadiansToDegrees(weather.sky_rotation)); windMagnitudeSlider.SetValue(XMVectorGetX(XMVector3Length(XMLoadFloat3(&weather.windDirection)))); switch (colorComboBox.GetSelected()) @@ -1315,6 +1325,7 @@ void WeatherWindow::ResizeLayout() add(windRandomnessSlider); add(skyExposureSlider); add(starsSlider); + add(skyRotationSlider); y += jump; diff --git a/Editor/WeatherWindow.h b/Editor/WeatherWindow.h index 1096c0d25..505898981 100644 --- a/Editor/WeatherWindow.h +++ b/Editor/WeatherWindow.h @@ -36,6 +36,7 @@ public: wi::gui::Slider windRandomnessSlider; wi::gui::Slider skyExposureSlider; wi::gui::Slider starsSlider; + wi::gui::Slider skyRotationSlider; wi::gui::CheckBox realisticskyCheckBox; wi::gui::CheckBox aerialperspectiveCheckBox; wi::gui::CheckBox realisticskyHighQualityCheckBox; diff --git a/WickedEngine/shaders/ShaderInterop_Weather.h b/WickedEngine/shaders/ShaderInterop_Weather.h index f9cdeac78..68b5cbfda 100644 --- a/WickedEngine/shaders/ShaderInterop_Weather.h +++ b/WickedEngine/shaders/ShaderInterop_Weather.h @@ -359,10 +359,10 @@ struct ShaderWeather float sky_exposure; float3 zenith; - float padding0; + float sky_rotation_sin; float3 ambient; - float padding1; + float sky_rotation_cos; float4x4 stars_rotation; diff --git a/WickedEngine/shaders/skyHF.hlsli b/WickedEngine/shaders/skyHF.hlsli index de50383f8..fa59a38f2 100644 --- a/WickedEngine/shaders/skyHF.hlsli +++ b/WickedEngine/shaders/skyHF.hlsli @@ -154,6 +154,13 @@ float3 GetDynamicSkyColor(in float3 V, bool sun_enabled = true, bool dark_enable float3 GetStaticSkyColor(in float3 V) { + ShaderWeather weather = GetWeather(); + float2x2 rot = float2x2( + weather.sky_rotation_cos, -weather.sky_rotation_sin, + weather.sky_rotation_sin, weather.sky_rotation_cos + ); + V.xz = mul(V.xz, rot); + if (GetFrame().options & OPTION_BIT_STATIC_SKY_SPHEREMAP) { float2 uv = (float2(atan2(V.z, V.x) / PI, -V.y) + 1.0) * 0.5; diff --git a/WickedEngine/wiScene.cpp b/WickedEngine/wiScene.cpp index 763d60259..d7ca185b6 100644 --- a/WickedEngine/wiScene.cpp +++ b/WickedEngine/wiScene.cpp @@ -708,6 +708,8 @@ namespace wi::scene shaderscene.weather.sun_direction = weather.sunDirection; shaderscene.weather.most_important_light_index = weather.most_important_light_index; shaderscene.weather.ambient = weather.ambient; + shaderscene.weather.sky_rotation_sin = std::sin(weather.sky_rotation); + shaderscene.weather.sky_rotation_cos = std::cos(weather.sky_rotation); shaderscene.weather.fog.start = weather.fogStart; shaderscene.weather.fog.density = weather.fogDensity; shaderscene.weather.fog.height_start = weather.fogHeightStart; diff --git a/WickedEngine/wiScene.h b/WickedEngine/wiScene.h index 6edd7538f..4172aa8a0 100644 --- a/WickedEngine/wiScene.h +++ b/WickedEngine/wiScene.h @@ -44,7 +44,7 @@ namespace wi::scene wi::ecs::ComponentManager& animation_datas = componentLibrary.Register("wi::scene::Scene::animation_datas"); wi::ecs::ComponentManager& emitters = componentLibrary.Register("wi::scene::Scene::emitters"); wi::ecs::ComponentManager& hairs = componentLibrary.Register("wi::scene::Scene::hairs"); - wi::ecs::ComponentManager& weathers = componentLibrary.Register("wi::scene::Scene::weathers", 3); // version = 3 + wi::ecs::ComponentManager& weathers = componentLibrary.Register("wi::scene::Scene::weathers", 4); // version = 4 wi::ecs::ComponentManager& sounds = componentLibrary.Register("wi::scene::Scene::sounds"); wi::ecs::ComponentManager& inverse_kinematics = componentLibrary.Register("wi::scene::Scene::inverse_kinematics"); wi::ecs::ComponentManager& springs = componentLibrary.Register("wi::scene::Scene::springs", 1); // version = 1 diff --git a/WickedEngine/wiScene_Components.h b/WickedEngine/wiScene_Components.h index 403e8f202..cdeb0b8a2 100644 --- a/WickedEngine/wiScene_Components.h +++ b/WickedEngine/wiScene_Components.h @@ -1288,6 +1288,7 @@ namespace wi::scene float windSpeed = 1; float stars = 0.5f; XMFLOAT3 gravity = XMFLOAT3(0, -10, 0); + float sky_rotation = 0; // horizontal rotation for skyMap texture (in radians) wi::Ocean::OceanParameters oceanParameters; AtmosphereParameters atmosphereParameters; diff --git a/WickedEngine/wiScene_Serializers.cpp b/WickedEngine/wiScene_Serializers.cpp index 78f74b9c0..24fa3aea9 100644 --- a/WickedEngine/wiScene_Serializers.cpp +++ b/WickedEngine/wiScene_Serializers.cpp @@ -1380,6 +1380,10 @@ namespace wi::scene archive >> atmosphereParameters.distanceSPPMaxInv; archive >> atmosphereParameters.aerialPerspectiveScale; } + if (seri.GetVersion() >= 3) + { + archive >> sky_rotation; + } } else { @@ -1587,6 +1591,10 @@ namespace wi::scene archive << atmosphereParameters.distanceSPPMaxInv; archive << atmosphereParameters.aerialPerspectiveScale; } + if (seri.GetVersion() >= 3) + { + archive << sky_rotation; + } } } void SoundComponent::Serialize(wi::Archive& archive, EntitySerializer& seri) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index d10b9aac7..79db3a00e 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 169; + const int revision = 170; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);