From 15573781c94a3602488d62855be2da954b8fad6c Mon Sep 17 00:00:00 2001 From: ThirteenAG Date: Wed, 27 Dec 2023 21:47:34 +0800 Subject: [PATCH] change default value --- source/antialiasing.ixx | 22 ---------------------- source/fixes.ixx | 27 +++++++++++++++++++++++++++ source/settings.ixx | 2 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/source/antialiasing.ixx b/source/antialiasing.ixx index dfe9ad3c..364c9746 100644 --- a/source/antialiasing.ixx +++ b/source/antialiasing.ixx @@ -34,7 +34,6 @@ public: static inline IDirect3DTexture9* edgesTex = nullptr; static inline IDirect3DTexture9* blendTex = nullptr; static inline IDirect3DPixelShader9* FxaaPS = nullptr; - static inline IDirect3DVertexShader9* CoronaVertexShader = nullptr; static inline IDirect3DPixelShader9* SMAA_EdgeDetectionPS = nullptr; static inline IDirect3DPixelShader9* SMAA_BlendingWeightsCalculationPS = nullptr; static inline IDirect3DPixelShader9* SMAA_NeighborhoodBlendingPS = nullptr; @@ -177,13 +176,6 @@ public: } }; - FusionFix::D3D9::onAfterCreateVertexShader() += [](LPDIRECT3DDEVICE9& pDevice, DWORD*& pFunction, IDirect3DVertexShader9**& ppShader) - { - static constexpr auto CoronaVertexShaderID = 15; - if (GetFusionShaderID(*ppShader) == CoronaVertexShaderID) - ShadersAA::CoronaVertexShader = *ppShader; - }; - FusionFix::D3D9::onAfterCreateTexture() += [](LPDIRECT3DDEVICE9& pDevice, UINT& Width, UINT& Height, UINT& Levels, DWORD& Usage, D3DFORMAT& Format, D3DPOOL& Pool, IDirect3DTexture9**& ppTexture, HANDLE*& pSharedHandle) { if (Format == D3DFMT_A16B16G16R16F && ppTexture && (getWindowWidth() * (bUseSSAA ? 2 : 1)) && Height == (getWindowHeight() * (bUseSSAA ? 2 : 1))) @@ -360,20 +352,6 @@ public: } }; - FusionFix::D3D9::onDrawPrimitive() += [](LPDIRECT3DDEVICE9& pDevice, D3DPRIMITIVETYPE& PrimitiveType, UINT& StartVertex, UINT& PrimitiveCount) - { - DWORD CoronaDepth = 0; - IDirect3DVertexShader9* vShader = 0; - pDevice->GetVertexShader(&vShader); - if (vShader && ShadersAA::CoronaVertexShader && vShader == ShadersAA::CoronaVertexShader) - { - pDevice->GetRenderState(D3DRS_ZENABLE, &CoronaDepth); - pDevice->SetRenderState(D3DRS_ZENABLE, 1); - DrawPrimitiveOriginalPtr(pDevice, PrimitiveType, StartVertex, PrimitiveCount); - pDevice->SetRenderState(D3DRS_ZENABLE, CoronaDepth); - } - }; - FusionFix::D3D9::onSetPixelShaderConstantF() += [](LPDIRECT3DDEVICE9& pDevice, UINT& StartRegister, float*& pConstantData, UINT& Vector4fCount) { if (bUseSSAA && pConstantData[0] == 1.f / getWindowWidth() && pConstantData[1] == 1.f / getWindowHeight() && Vector4fCount == 1) { diff --git a/source/fixes.ixx b/source/fixes.ixx index 75f97655..151e38dd 100644 --- a/source/fixes.ixx +++ b/source/fixes.ixx @@ -8,6 +8,8 @@ import common; import comvars; import settings; import natives; +import shaders; +import fusiondxhook; class Fixes { @@ -305,6 +307,31 @@ public: if (!pattern.empty()) injector::WriteMemory(pattern.get_first(1), 0xFFFFFFFF, true); } + + // Fix for light coronas being rendered through objects in water reflections. + { + static IDirect3DVertexShader9* CoronaVertexShader = nullptr; + FusionFix::D3D9::onAfterCreateVertexShader() += [](LPDIRECT3DDEVICE9& pDevice, DWORD*& pFunction, IDirect3DVertexShader9**& ppShader) + { + static constexpr auto CoronaVertexShaderID = 15; + if (GetFusionShaderID(*ppShader) == CoronaVertexShaderID) + CoronaVertexShader = *ppShader; + }; + + FusionFix::D3D9::onDrawPrimitive() += [](LPDIRECT3DDEVICE9& pDevice, D3DPRIMITIVETYPE& PrimitiveType, UINT& StartVertex, UINT& PrimitiveCount) + { + DWORD CoronaDepth = 0; + IDirect3DVertexShader9* vShader = 0; + pDevice->GetVertexShader(&vShader); + if (vShader && CoronaVertexShader && vShader == CoronaVertexShader) + { + pDevice->GetRenderState(D3DRS_ZENABLE, &CoronaDepth); + pDevice->SetRenderState(D3DRS_ZENABLE, 1); + DrawPrimitiveOriginalPtr(pDevice, PrimitiveType, StartVertex, PrimitiveCount); + pDevice->SetRenderState(D3DRS_ZENABLE, CoronaDepth); + } + }; + } }; } } Fixes; \ No newline at end of file diff --git a/source/settings.ixx b/source/settings.ixx index 2aca6928..173b33d4 100644 --- a/source/settings.ixx +++ b/source/settings.ixx @@ -141,7 +141,7 @@ public: { 0, "PREF_SKIP_MENU", "MAIN", "SkipMenu", "", 1, nullptr, 0, 1 }, { 0, "PREF_BORDERLESS", "MAIN", "BorderlessWindowed", "", 1, nullptr, 0, 1 }, { 0, "PREF_FPS_LIMIT_PRESET", "FRAMELIMIT", "FpsLimitPreset", "MENU_DISPLAY_FRAMELIMIT", 0, nullptr, FpsCaps.eOFF, std::distance(std::begin(FpsCaps.data), std::end(FpsCaps.data)) - 1 }, - { 0, "PREF_SSAA", "MISC", "SSAA", "", 1, nullptr, 0, 1 }, + { 0, "PREF_SSAA", "MISC", "SSAA", "", 0, nullptr, 0, 1 }, { 0, "PREF_CONSOLE_GAMMA", "MISC", "ConsoleGamma", "", 0, nullptr, 0, 1 }, { 0, "PREF_TIMECYC", "MISC", "ScreenFilter", "MENU_DISPLAY_TIMECYC", 5, nullptr, TimecycText.eMO_DEF, std::distance(std::begin(TimecycText.data), std::end(TimecycText.data)) - 1 }, { 0, "PREF_CUTSCENE_DOF", "MISC", "DepthOfField", "", 1, nullptr, 0, 1 },