Skip to content

Commit

Permalink
change default value
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Dec 27, 2023
1 parent 9ffb614 commit 1557378
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
22 changes: 0 additions & 22 deletions source/antialiasing.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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) {
Expand Down
27 changes: 27 additions & 0 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import common;
import comvars;
import settings;
import natives;
import shaders;
import fusiondxhook;

class Fixes
{
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion source/settings.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 1557378

Please sign in to comment.