Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 58 additions & 5 deletions src/Features/IBL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "DynamicCubemaps.h"
#include "Shadercache.h"
#include "State.h"
#include "WeatherVariableRegistry.h"

#include <DDSTextureLoader.h>
#include <DirectXTex.h>
Expand All @@ -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);
}

Expand All @@ -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<WeatherVariables::WeatherVariable<bool>>(
"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<WeatherVariables::FloatVariable>(
"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<WeatherVariables::FloatVariable>(
"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<WeatherVariables::FloatVariable>(
"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<WeatherVariables::FloatVariable>(
"FogAmount",
"Fog Mix",
"Amount of fog mixed into IBL",
&settings.FogAmount,
0.0f,
0.0f, 1.0f));
}

void IBL::EarlyPrepass()
{
if (loaded) {
Expand Down
1 change: 1 addition & 0 deletions src/Features/IBL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down