diff --git a/src/Features/DistantTreeLighting.cpp b/src/Features/DistantTreeLighting.cpp index d51fc1a53..7d2cef8d3 100644 --- a/src/Features/DistantTreeLighting.cpp +++ b/src/Features/DistantTreeLighting.cpp @@ -3,10 +3,16 @@ #include "State.h" #include "Util.h" +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( + DistantTreeLighting::Settings, + EnableComplexTreeLOD, + EnableDirLightFix, + SubsurfaceScatteringAmount, + FogDimmerAmount) + void DistantTreeLighting::DrawSettings() { if (ImGui::BeginTabItem("Tree LOD Lighting")) { - if (ImGui::TreeNodeEx("Complex Tree LOD", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Text("Enables advanced lighting simulation on tree LOD."); ImGui::Text("Requires DynDOLOD."); @@ -37,7 +43,6 @@ void DistantTreeLighting::DrawSettings() ImGui::SliderFloat("Fog Dimmer Amount", &settings.FogDimmerAmount, 0.0f, 1.0f); ImGui::TreePop(); - } ImGui::EndTabItem(); @@ -52,12 +57,9 @@ enum class DistantTreeShaderTechniques void DistantTreeLighting::ModifyDistantTree(const RE::BSShader*, const uint32_t descriptor) { - if (auto player = RE::PlayerCharacter::GetSingleton()) - { - if (auto worldSpace = player->GetWorldspace()) - { - if (lastWorldSpace != worldSpace) - { + if (auto player = RE::PlayerCharacter::GetSingleton()) { + if (auto worldSpace = player->GetWorldspace()) { + if (lastWorldSpace != worldSpace) { lastWorldSpace = worldSpace; if (auto name = worldSpace->GetFormEditorID()) { CSimpleIniA ini; @@ -74,7 +76,6 @@ void DistantTreeLighting::ModifyDistantTree(const RE::BSShader*, const uint32_t const auto technique = descriptor & 1; if (technique != static_cast(DistantTreeShaderTechniques::Depth)) { - PerPass perPassData{}; ZeroMemory(&perPassData, sizeof(perPassData)); @@ -147,17 +148,8 @@ void DistantTreeLighting::Draw(const RE::BSShader* shader, const uint32_t descri void DistantTreeLighting::Load(json& o_json) { - if (o_json["Tree LOD Lighting"].is_object()) { - json& distantTreeLighting = o_json["Distant Tree Lighting"]; - if (distantTreeLighting["EnableComplexTreeLOD"].is_boolean()) - settings.EnableComplexTreeLOD = distantTreeLighting["EnableComplexTreeLOD"]; - if (distantTreeLighting["EnableDirLightFix"].is_boolean()) - settings.EnableDirLightFix = distantTreeLighting["EnableDirLightFix"]; - if (distantTreeLighting["SubsurfaceScatteringAmount"].is_number()) - settings.SubsurfaceScatteringAmount = distantTreeLighting["SubsurfaceScatteringAmount"]; - if (distantTreeLighting["FogDimmerAmount"].is_number()) - settings.FogDimmerAmount = distantTreeLighting["FogDimmerAmount"]; - } + settings = o_json["Distant Tree Lighting"]; + CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(L"Data\\Shaders\\Features\\TreeLODLighting.ini"); @@ -173,12 +165,7 @@ void DistantTreeLighting::Load(json& o_json) void DistantTreeLighting::Save(json& o_json) { - json distantTreeLighting; - distantTreeLighting["EnableComplexTreeLOD"] = (bool)settings.EnableComplexTreeLOD; - distantTreeLighting["EnableDirLightFix"] = (bool)settings.EnableDirLightFix; - distantTreeLighting["SubsurfaceScatteringAmount"] = settings.SubsurfaceScatteringAmount; - distantTreeLighting["FogDimmerAmount"] = settings.FogDimmerAmount; - o_json["Tree LOD Lighting"] = distantTreeLighting; + o_json["Tree LOD Lighting"] = settings; } void DistantTreeLighting::SetupResources() diff --git a/src/Features/GrassCollision.cpp b/src/Features/GrassCollision.cpp index 69e980414..9a94eb496 100644 --- a/src/Features/GrassCollision.cpp +++ b/src/Features/GrassCollision.cpp @@ -5,6 +5,12 @@ #include "Features/Clustered.h" +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( + GrassCollision::Settings, + EnableGrassCollision, + RadiusMultiplier, + DisplacementMultiplier) + enum class GrassShaderTechniques { RenderDepth = 8, @@ -15,14 +21,14 @@ void GrassCollision::DrawSettings() if (ImGui::BeginTabItem("Grass Collision")) { if (ImGui::TreeNodeEx("Grass Collision", ImGuiTreeNodeFlags_DefaultOpen)) { ImGui::Text("Allows player collision to modify grass position."); - + ImGui::Checkbox("Enable Grass Collision", (bool*)&settings.EnableGrassCollision); ImGui::Text("Distance from collision centres to apply collision"); ImGui::SliderFloat("Radius Multiplier", &settings.RadiusMultiplier, 0.0f, 8.0f); - + ImGui::Text("Strength of each collision on grass position."); ImGui::SliderFloat("Displacement Multiplier", &settings.DisplacementMultiplier, 0.0f, 32.0f); - + ImGui::TreePop(); } @@ -242,15 +248,8 @@ void GrassCollision::Draw(const RE::BSShader* shader, const uint32_t descriptor) void GrassCollision::Load(json& o_json) { - if (o_json["Grass Collision"].is_object()) { - json& grassCollision = o_json["Grass Collision"]; - if (grassCollision["EnableGrassCollision"].is_boolean()) - settings.EnableGrassCollision = grassCollision["EnableGrassCollision"]; - if (grassCollision["RadiusMultiplier"].is_number()) - settings.RadiusMultiplier = grassCollision["RadiusMultiplier"]; - if (grassCollision["DisplacementMultiplier"].is_number()) - settings.DisplacementMultiplier = grassCollision["DisplacementMultiplier"]; - } + settings = o_json["Grass Collision"]; + CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(L"Data\\Shaders\\Features\\GrassCollision.ini"); @@ -266,11 +265,7 @@ void GrassCollision::Load(json& o_json) void GrassCollision::Save(json& o_json) { - json grassCollision; - grassCollision["EnableGrassCollision"] = (bool)settings.EnableGrassCollision; - grassCollision["RadiusMultiplier"] = settings.RadiusMultiplier; - grassCollision["DisplacementMultiplier"] = settings.DisplacementMultiplier; - o_json["Grass Collision"] = grassCollision; + o_json["Grass Collision"] = settings; } void GrassCollision::SetupResources() diff --git a/src/Features/GrassLighting.cpp b/src/Features/GrassLighting.cpp index bb6d28c91..83e129dac 100644 --- a/src/Features/GrassLighting.cpp +++ b/src/Features/GrassLighting.cpp @@ -5,6 +5,14 @@ #include "Features/Clustered.h" +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( + GrassLighting::Settings, + Glossiness, + SpecularStrength, + SubsurfaceScatteringAmount, + EnableDirLightFix, + EnablePointLights) + enum class GrassShaderTechniques { RenderDepth = 8, @@ -104,19 +112,8 @@ void GrassLighting::Draw(const RE::BSShader* shader, const uint32_t descriptor) void GrassLighting::Load(json& o_json) { - if (o_json["Grass Lighting"].is_object()) { - json& grassLighting = o_json["Grass Lighting"]; - if (grassLighting["Glossiness"].is_number()) - settings.Glossiness = grassLighting["Glossiness"]; - if (grassLighting["SpecularStrength"].is_number()) - settings.SpecularStrength = grassLighting["SpecularStrength"]; - if (grassLighting["SubsurfaceScatteringAmount"].is_number()) - settings.SubsurfaceScatteringAmount = grassLighting["SubsurfaceScatteringAmount"]; - if (grassLighting["EnableDirLightFix"].is_boolean()) - settings.EnableDirLightFix = grassLighting["EnableDirLightFix"]; - if (grassLighting["EnablePointLights"].is_boolean()) - settings.EnablePointLights = grassLighting["EnablePointLights"]; - } + settings = o_json["Grass Lighting"]; + CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(L"Data\\Shaders\\Features\\GrassLighting.ini"); @@ -132,16 +129,9 @@ void GrassLighting::Load(json& o_json) void GrassLighting::Save(json& o_json) { - json grassLighting; - grassLighting["Glossiness"] = settings.Glossiness; - grassLighting["SpecularStrength"] = settings.SpecularStrength; - grassLighting["SubsurfaceScatteringAmount"] = settings.SubsurfaceScatteringAmount; - grassLighting["EnableDirLightFix"] = (bool)settings.EnableDirLightFix; - grassLighting["EnablePointLights"] = (bool)settings.EnablePointLights; - o_json["Grass Lighting"] = grassLighting; + o_json["Grass Lighting"] = settings; } - void GrassLighting::SetupResources() { perFrame = new ConstantBuffer(ConstantBufferDesc()); diff --git a/src/Features/ScreenSpaceShadows.cpp b/src/Features/ScreenSpaceShadows.cpp index 032e8688f..06bbee667 100644 --- a/src/Features/ScreenSpaceShadows.cpp +++ b/src/Features/ScreenSpaceShadows.cpp @@ -5,6 +5,18 @@ using RE::RENDER_TARGETS; +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( + ScreenSpaceShadows::Settings, + MaxSamples, + FarDistanceScale, + FarThicknessScale, + FarHardness, + NearDistance, + NearThickness, + NearHardness, + BlurRadius, + BlurDropoff) + void ScreenSpaceShadows::DrawSettings() { if (ImGui::BeginTabItem("Screen-Space Shadows")) { @@ -153,9 +165,9 @@ void ScreenSpaceShadows::ModifyLighting(const RE::BSShader*, const uint32_t) auto accumulator = RE::BSGraphics::BSShaderAccumulator::GetCurrentAccumulator(); auto dirLight = skyrim_cast(accumulator->GetRuntimeData().activeShadowSceneNode->GetRuntimeData().sunLight->light.get()); - + bool skyLight = true; - if (auto sky = RE::Sky::GetSingleton()) + if (auto sky = RE::Sky::GetSingleton()) skyLight = sky->mode.get() == RE::Sky::Mode::kFull; if (dirLight && skyLight) { @@ -403,29 +415,8 @@ void ScreenSpaceShadows::Draw(const RE::BSShader* shader, const uint32_t descrip void ScreenSpaceShadows::Load(json& o_json) { - if (o_json["Screen-Space Shadows"].is_object()) { - json& ssShadows = o_json["Screen-Space Shadows"]; - if (ssShadows["EnableScreenSpaceShadows"].is_boolean()) - enabled = ssShadows["EnableScreenSpaceShadows"]; - if (ssShadows["MaxSamples"].is_number()) - settings.MaxSamples = ssShadows["MaxSamples"]; - if (ssShadows["FarDistanceScale"].is_number()) - settings.FarDistanceScale = ssShadows["FarDistanceScale"]; - if (ssShadows["FarThicknessScale"].is_number()) - settings.FarThicknessScale = ssShadows["FarThicknessScale"]; - if (ssShadows["FarHardness"].is_number()) - settings.FarHardness = ssShadows["FarHardness"]; - if (ssShadows["NearDistance"].is_number()) - settings.NearDistance = ssShadows["NearDistance"]; - if (ssShadows["NearThickness"].is_number()) - settings.NearThickness = ssShadows["NearThickness"]; - if (ssShadows["NearHardness"].is_number()) - settings.NearHardness = ssShadows["NearHardness"]; - if (ssShadows["BlurRadius"].is_number()) - settings.BlurRadius = ssShadows["BlurRadius"]; - if (ssShadows["BlurDropoff"].is_number()) - settings.BlurDropoff = ssShadows["BlurDropoff"]; - } + settings = o_json["Screen-Space Shadows"]; + CSimpleIniA ini; ini.SetUnicode(); ini.LoadFile(L"Data\\Shaders\\Features\\ScreenSpaceShadows.ini"); @@ -441,18 +432,7 @@ void ScreenSpaceShadows::Load(json& o_json) void ScreenSpaceShadows::Save(json& o_json) { - json ssShadows; - ssShadows["EnableScreenSpaceShadows"] = enabled; - ssShadows["MaxSamples"] = settings.MaxSamples; - ssShadows["FarDistanceScale"] = settings.FarDistanceScale; - ssShadows["FarThicknessScale"] = settings.FarThicknessScale; - ssShadows["FarHardness"] = settings.FarHardness; - ssShadows["NearDistance"] = settings.NearDistance; - ssShadows["NearThickness"] = settings.NearThickness; - ssShadows["NearHardness"] = settings.NearHardness; - ssShadows["BlurRadius"] = settings.BlurRadius; - ssShadows["BlurDropoff"] = settings.BlurDropoff; - o_json["Screen-Space Shadows"] = ssShadows; + o_json["Screen-Space Shadows"] = settings; } void ScreenSpaceShadows::SetupResources()