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: fix VR tAA detection #111

Merged
merged 1 commit into from
Sep 25, 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
4 changes: 3 additions & 1 deletion src/Features/DistantTreeLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ void DistantTreeLighting::ModifyDistantTree(const RE::BSShader*, const uint32_t
auto sunLight = skyrim_cast<RE::NiDirectionalLight*>(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;
Expand Down
8 changes: 3 additions & 5 deletions src/Features/GrassLighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
7 changes: 6 additions & 1 deletion src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
33 changes: 0 additions & 33 deletions src/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<UnkOuterStruct*&> 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);
Expand Down