Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set bLandSpecular to support Terrain Parallax #88

Merged
merged 2 commits into from
Sep 11, 2023
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
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