diff --git a/src/Features/IBL.cpp b/src/Features/IBL.cpp index 9d090d9e27..6006be8ba3 100644 --- a/src/Features/IBL.cpp +++ b/src/Features/IBL.cpp @@ -4,6 +4,7 @@ #include "DynamicCubemaps.h" #include "Shadercache.h" #include "State.h" +#include "WeatherVariableRegistry.h" #include #include @@ -21,16 +22,16 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( void IBL::DrawSettings() { - ImGui::Checkbox("Enable Diffuse IBL", (bool*)&settings.EnableDiffuseIBL); - ImGui::SliderFloat("Diffuse IBL Scale", &settings.DiffuseIBLScale, 0.0f, 10.0f, "%.2f"); - ImGui::SliderFloat("Diffuse IBL Saturation", &settings.IBLSaturation, 0.0f, 2.0f, "%.2f"); - ImGui::SliderFloat("DALC Amount", &settings.DALCAmount, 0.0f, 1.0f, "%.2f"); + Util::WeatherUI::Checkbox("Enable Diffuse IBL", this, "EnableDiffuseIBL", (bool*)&settings.EnableDiffuseIBL); + Util::WeatherUI::SliderFloat("Diffuse IBL Scale", this, "DiffuseIBLScale", &settings.DiffuseIBLScale, 0.0f, 10.0f, "%.2f"); + Util::WeatherUI::SliderFloat("Diffuse IBL Saturation", this, "IBLSaturation", &settings.IBLSaturation, 0.0f, 2.0f, "%.2f"); + Util::WeatherUI::SliderFloat("DALC Amount", this, "DALCAmount", &settings.DALCAmount, 0.0f, 1.0f, "%.2f"); ImGui::Checkbox("Enable Interior", (bool*)&settings.EnableInterior); ImGui::Checkbox("Use Static IBL For Out-of-World Objects", (bool*)&settings.UseStaticIBL); if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::Text("Enables the use of static IBL textures for objects that are not in the world (e.g. inventory items)."); } - ImGui::SliderFloat("Fog Mix", &settings.FogAmount, 0.0f, 1.0f, "%.2f"); + Util::WeatherUI::SliderFloat("Fog Mix", this, "FogAmount", &settings.FogAmount, 0.0f, 1.0f, "%.2f"); ImGui::Checkbox("Preserve Fog Luminance", (bool*)&settings.PreserveFogLuminance); } @@ -49,6 +50,58 @@ void IBL::RestoreDefaultSettings() settings = {}; } +void IBL::RegisterWeatherVariables() +{ + auto* registry = WeatherVariables::GlobalWeatherRegistry::GetSingleton() + ->GetOrCreateFeatureRegistry(GetShortName()); + // Register enable diffuse IBL toggle + registry->RegisterVariable(std::make_shared>( + "EnableDiffuseIBL", + "Enable Diffuse IBL", + "Enable or disable diffuse IBL for this weather", + (bool*)&settings.EnableDiffuseIBL, + true, + [](const bool& from, const bool& to, float factor) { + return factor > 0.5f ? to : from; // Switch at transition midpoint + })); + + // Register diffuse IBL scale - controls the overall intensity of diffuse IBL + registry->RegisterVariable(std::make_shared( + "DiffuseIBLScale", + "Diffuse IBL Scale", + "Controls the overall intensity of diffuse IBL lighting", + &settings.DiffuseIBLScale, + 1.0f, + 0.0f, 10.0f)); + + // Register IBL saturation - controls color saturation of IBL + registry->RegisterVariable(std::make_shared( + "IBLSaturation", + "IBL Saturation", + "Controls the color saturation of IBL lighting", + &settings.IBLSaturation, + 1.0f, + 0.0f, 2.0f)); + + // Register DALC amount - controls mixing with Directional Ambient Light Color + registry->RegisterVariable(std::make_shared( + "DALCAmount", + "DALC Amount", + "Amount of DALC (Directional Ambient Light Color) mixing", + &settings.DALCAmount, + 0.33f, + 0.0f, 1.0f)); + + // Register fog amount - controls fog mixing + registry->RegisterVariable(std::make_shared( + "FogAmount", + "Fog Mix", + "Amount of fog mixed into IBL", + &settings.FogAmount, + 0.0f, + 0.0f, 1.0f)); +} + void IBL::EarlyPrepass() { if (loaded) { diff --git a/src/Features/IBL.h b/src/Features/IBL.h index 7e19f33717..7aa3056927 100644 --- a/src/Features/IBL.h +++ b/src/Features/IBL.h @@ -33,6 +33,7 @@ struct IBL : Feature virtual void LoadSettings(json& o_json) override; virtual void SaveSettings(json& o_json) override; + virtual void RegisterWeatherVariables() override; virtual void EarlyPrepass() override; virtual void Prepass() override;