From 5bd78d046b40ff8a1383dd28d5810f671134c979 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Wed, 20 Sep 2023 01:24:50 -0700 Subject: [PATCH] fix: fix VR tAA detection Includes RE fix for ImageSpaceManager in VR. This also allows simplification of GrassLighting.cpp code due to bad RE for sunlightScale --- extern/CommonLibSSE-NG | 2 +- src/Features/DistantTreeLighting.cpp | 4 +++- src/Features/GrassLighting.cpp | 8 +++---- src/Features/LightLimitFix.cpp | 7 +++++- src/Util.h | 33 ---------------------------- 5 files changed, 13 insertions(+), 41 deletions(-) diff --git a/extern/CommonLibSSE-NG b/extern/CommonLibSSE-NG index 0ff396dc6..270bae594 160000 --- a/extern/CommonLibSSE-NG +++ b/extern/CommonLibSSE-NG @@ -1 +1 @@ -Subproject commit 0ff396dc6a662325d92eabc82644d267cf47e246 +Subproject commit 270bae594559600bff011d5897f086b5d1b8b31d diff --git a/src/Features/DistantTreeLighting.cpp b/src/Features/DistantTreeLighting.cpp index 35201f304..4bcdb8b45 100644 --- a/src/Features/DistantTreeLighting.cpp +++ b/src/Features/DistantTreeLighting.cpp @@ -130,8 +130,10 @@ void DistantTreeLighting::ModifyDistantTree(const RE::BSShader*, const uint32_t auto sunLight = skyrim_cast(accumulator->GetRuntimeData().activeShadowSceneNode->GetRuntimeData().sunLight->light.get()); if (sunLight) { auto imageSpaceManager = RE::ImageSpaceManager::GetSingleton(); + auto sunlightScale = !REL::Module::IsVR() ? imageSpaceManager->GetRuntimeData().data.baseData.hdr.sunlightScale : + imageSpaceManager->GetVRRuntimeData().data.baseData.hdr.sunlightScale; - perPassData.DirLightScale = imageSpaceManager->data.baseData.hdr.sunlightScale * sunLight->GetLightRuntimeData().fade; + perPassData.DirLightScale = sunlightScale * sunLight->GetLightRuntimeData().fade; perPassData.DirLightColor.x = sunLight->GetLightRuntimeData().diffuse.red; perPassData.DirLightColor.y = sunLight->GetLightRuntimeData().diffuse.green; diff --git a/src/Features/GrassLighting.cpp b/src/Features/GrassLighting.cpp index b8ed96715..5b4c7c0a1 100644 --- a/src/Features/GrassLighting.cpp +++ b/src/Features/GrassLighting.cpp @@ -110,11 +110,9 @@ void GrassLighting::ModifyGrass(const RE::BSShader*, const uint32_t descriptor) ZeroMemory(&perFrameData, sizeof(perFrameData)); Util::StoreTransform3x4NoScale(perFrameData.DirectionalAmbient, dalcTransform); - if (REL::Module::IsVR()) { - perFrameData.SunlightScale = imageSpaceManager->data.baseData.cinematic.brightness; - } else { - perFrameData.SunlightScale = imageSpaceManager->data.baseData.hdr.sunlightScale; - } + perFrameData.SunlightScale = !REL::Module::IsVR() ? + imageSpaceManager->GetRuntimeData().data.baseData.hdr.sunlightScale : + imageSpaceManager->GetVRRuntimeData().data.baseData.hdr.sunlightScale; perFrameData.Settings = settings; perFrame->Update(perFrameData); diff --git a/src/Features/LightLimitFix.cpp b/src/Features/LightLimitFix.cpp index e9e1320cf..bf272e725 100644 --- a/src/Features/LightLimitFix.cpp +++ b/src/Features/LightLimitFix.cpp @@ -376,7 +376,12 @@ void LightLimitFix::Bind() perPassData.LightsFar = lightsFar; perPassData.BufferDim = { resolutionX, resolutionY }; - perPassData.FrameCount = viewport->uiFrameCount * (Util::UnkOuterStruct::GetSingleton()->GetTAA() || State::GetSingleton()->upscalerLoaded); + + const auto imageSpaceManager = RE::ImageSpaceManager::GetSingleton(); + auto bTAA = !REL::Module::IsVR() ? imageSpaceManager->GetRuntimeData().BSImagespaceShaderISTemporalAA->taaEnabled : + imageSpaceManager->GetVRRuntimeData().BSImagespaceShaderISTemporalAA->taaEnabled; + + perPassData.FrameCount = viewport->uiFrameCount * (bTAA || State::GetSingleton()->upscalerLoaded); perPassData.EnableGlobalLights = true; perPassData.EnableContactShadows = settings.EnableContactShadows; perPassData.EnableLightsVisualisation = settings.EnableLightsVisualisation; diff --git a/src/Util.h b/src/Util.h index 539a62ae2..aa9f7ab18 100644 --- a/src/Util.h +++ b/src/Util.h @@ -2,39 +2,6 @@ namespace Util { - struct UnkOuterStruct - { - struct UnkInnerStruct - { - uint8_t unk00[0x18]; // 00 - bool bTAA; // 18 - }; - - // members - uint8_t unk00[0x1F0]; // 00 - UnkInnerStruct* unkInnerStruct; // 1F0 - - static UnkOuterStruct* GetSingleton() - { - REL::Relocation instance{ REL::VariantID(527731, 414660, 0x34234C0) }; // 31D11A0, 326B280, 34234C0 - return instance.get(); - } - - bool GetTAA() const - { - if (this == nullptr) - return false; - return unkInnerStruct->bTAA; - } - - void SetTAA(bool a_enabled) - { - if (this == nullptr) - return; - unkInnerStruct->bTAA = a_enabled; - } - }; - void StoreTransform3x4NoScale(DirectX::XMFLOAT3X4& Dest, const RE::NiTransform& Source); ID3D11ShaderResourceView* GetSRVFromRTV(ID3D11RenderTargetView* a_rtv); ID3D11RenderTargetView* GetRTVFromSRV(ID3D11ShaderResourceView* a_srv);