Skip to content

Commit

Permalink
fix: set bLandSpecular to support Terrain Parallax (#88)
Browse files Browse the repository at this point in the history
* refactor: remove redundant state load

* fix: set bLandSpecular to support Terrain Parallax

bLandSpecular may be disabled by certain mod lists and is necessary for
terrain parallax. This will force the setting to true when Terrain
Parallax is enabled.
  • Loading branch information
alandtse committed Sep 11, 2023
1 parent 746e301 commit 0b49ae9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
18 changes: 17 additions & 1 deletion src/Features/ExtendedMaterials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
ShadowsStartFade,
ShadowsEndFade)

void ExtendedMaterials::DataLoaded()
{
if (&settings.EnableTerrain) {
if (auto bLandSpecular = RE::INISettingCollection::GetSingleton()->GetSetting("bLandSpecular:Landscape"); bLandSpecular) {
if (!bLandSpecular->data.b) {
logger::info("[CPM] Changing bLandSpecular from {} to {} to support Terrain Parallax", bLandSpecular->data.b, true);
bLandSpecular->data.b = true;
}
}
}
}

void ExtendedMaterials::DrawSettings()
{
if (ImGui::TreeNodeEx("Complex Material", ImGuiTreeNodeFlags_DefaultOpen)) {
Expand Down Expand Up @@ -43,7 +55,11 @@ void ExtendedMaterials::DrawSettings()
ImGui::EndTooltip();
}

ImGui::Checkbox("Enable Terrain", (bool*)&settings.EnableTerrain);
if (ImGui::Checkbox("Enable Terrain", (bool*)&settings.EnableTerrain)) {
if (settings.EnableTerrain) {
DataLoaded();
}
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
Expand Down
2 changes: 2 additions & 0 deletions src/Features/ExtendedMaterials.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct ExtendedMaterials : Feature
virtual void SetupResources();
virtual inline void Reset() {}

void DataLoaded();

virtual void DrawSettings();

void ModifyLighting(const RE::BSShader* shader, const uint32_t descriptor);
Expand Down
5 changes: 2 additions & 3 deletions src/XSEPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ void MessageHandler(SKSE::MessagingInterface::Message* message)
shaderCache.SetAsync(true);
shaderCache.SetDiskCache(true);
shaderCache.SetDump(false);

State::GetSingleton()->Load();

shaderCache.ValidateDiskCache();

if (LightLimitFix::GetSingleton()->loaded) {
Expand Down Expand Up @@ -133,6 +130,8 @@ void MessageHandler(SKSE::MessagingInterface::Message* message)

if (LightLimitFix::GetSingleton()->loaded)
LightLimitFix::GetSingleton()->DataLoaded();
if (ExtendedMaterials::GetSingleton()->loaded)
ExtendedMaterials::GetSingleton()->DataLoaded();
}

break;
Expand Down

0 comments on commit 0b49ae9

Please sign in to comment.