weather: added sky rotation

This commit is contained in:
Turánszki János
2023-03-03 16:27:42 +01:00
parent c3e8d2dfbf
commit 1440e0b8fd
9 changed files with 34 additions and 4 deletions
+11
View File
@@ -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;
+1
View File
@@ -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;
+2 -2
View File
@@ -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;
+7
View File
@@ -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;
+2
View File
@@ -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;
+1 -1
View File
@@ -44,7 +44,7 @@ namespace wi::scene
wi::ecs::ComponentManager<AnimationDataComponent>& animation_datas = componentLibrary.Register<AnimationDataComponent>("wi::scene::Scene::animation_datas");
wi::ecs::ComponentManager<EmittedParticleSystem>& emitters = componentLibrary.Register<EmittedParticleSystem>("wi::scene::Scene::emitters");
wi::ecs::ComponentManager<HairParticleSystem>& hairs = componentLibrary.Register<HairParticleSystem>("wi::scene::Scene::hairs");
wi::ecs::ComponentManager<WeatherComponent>& weathers = componentLibrary.Register<WeatherComponent>("wi::scene::Scene::weathers", 3); // version = 3
wi::ecs::ComponentManager<WeatherComponent>& weathers = componentLibrary.Register<WeatherComponent>("wi::scene::Scene::weathers", 4); // version = 4
wi::ecs::ComponentManager<SoundComponent>& sounds = componentLibrary.Register<SoundComponent>("wi::scene::Scene::sounds");
wi::ecs::ComponentManager<InverseKinematicsComponent>& inverse_kinematics = componentLibrary.Register<InverseKinematicsComponent>("wi::scene::Scene::inverse_kinematics");
wi::ecs::ComponentManager<SpringComponent>& springs = componentLibrary.Register<SpringComponent>("wi::scene::Scene::springs", 1); // version = 1
+1
View File
@@ -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;
+8
View File
@@ -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)
+1 -1
View File
@@ -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);