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
21 changes: 15 additions & 6 deletions src/TruePBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ void TruePBR::SetupGlintsTexture()

void TruePBR::SetupFrame()
{
SetupDefaultPBRLandTextureSet();
}

void TruePBR::SetupTextureSetData()
Expand Down Expand Up @@ -1089,8 +1090,8 @@ void SetupLandscapeTexture(BSLightingShaderMaterialPBRLandscape& material, RE::T

RE::TESLandTexture* GetDefaultLandTexture()
{
static RE::TESLandTexture* const defaultLandTexture = *REL::Relocation<RE::TESLandTexture**>(RELOCATION_ID(514783, 400936));
return defaultLandTexture;
static const auto defaultLandTextureAddress = REL::Relocation<RE::TESLandTexture**>(RELOCATION_ID(514783, 400936));
return *defaultLandTextureAddress;
}

struct TESObjectLAND_SetupMaterial
Expand Down Expand Up @@ -1132,7 +1133,7 @@ struct TESObjectLAND_SetupMaterial
if (land->loadedData != nullptr && land->loadedData->mesh[0] != nullptr) {
land->data.flags.set(static_cast<RE::OBJ_LAND::Flag>(8));
for (uint32_t quadIndex = 0; quadIndex < 4; ++quadIndex) {
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(RE::MemoryManager::GetSingleton()->Allocate(sizeof(RE::BSLightingShaderProperty), 0, false));
auto shaderProperty = static_cast<RE::BSLightingShaderProperty*>(RE::MemoryManager::GetSingleton()->Allocate(REL::Module::IsVR() ? 0x178 : sizeof(RE::BSLightingShaderProperty), 0, false));
shaderProperty->Ctor();

{
Expand Down Expand Up @@ -1601,9 +1602,17 @@ void TruePBR::PostPostLoad()
void TruePBR::DataLoaded()
{
defaultPbrLandTextureSet = RE::TESForm::LookupByEditorID<RE::BGSTextureSet>("DefaultPBRLand");
if (defaultPbrLandTextureSet != nullptr) {
logger::info("[TruePBR] replacing default land texture set record with {}", defaultPbrLandTextureSet->GetFormEditorID());
GetDefaultLandTexture()->textureSet = defaultPbrLandTextureSet;
SetupDefaultPBRLandTextureSet();
}

void TruePBR::SetupDefaultPBRLandTextureSet()
{
if (!defaultLandTextureSetReplaced && defaultPbrLandTextureSet != nullptr) {
if (auto* defaultLandTexture = GetDefaultLandTexture()) {
logger::info("[TruePBR] replacing default land texture set record with {}", defaultPbrLandTextureSet->GetFormEditorID());
defaultLandTexture->textureSet = defaultPbrLandTextureSet;
defaultLandTextureSetReplaced = true;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/TruePBR.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ struct TruePBR
PBRTextureSetData* GetPBRTextureSetData(const RE::TESForm* textureSet);
bool IsPBRTextureSet(const RE::TESForm* textureSet);

void SetupDefaultPBRLandTextureSet();

std::unordered_map<std::string, PBRTextureSetData> pbrTextureSets;
RE::BGSTextureSet* defaultPbrLandTextureSet = nullptr;
bool defaultLandTextureSetReplaced = false;
std::string selectedPbrTextureSetName;
PBRTextureSetData* selectedPbrTextureSet = nullptr;

Expand Down