Skip to content

Commit

Permalink
FXAA and SMAA Fixes
Browse files Browse the repository at this point in the history
Fixes the phone's menu and camera when using anti-aliasing methods
  • Loading branch information
RaphaelK12 committed Dec 31, 2023
1 parent d0ae336 commit f3cc62c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions source/antialiasing.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ public:
IDirect3DSurface9* blendSurf = nullptr;
DWORD OldSRGB = 0;
DWORD OldSampler = 0;
DWORD Samplers[5] = { D3DTEXF_LINEAR };
pDevice->GetPixelShader(&pShader);
#define PostfxTextureCount 6
IDirect3DBaseTexture9* prePostFx[PostfxTextureCount] = { 0 };
DWORD Samplers[PostfxTextureCount] = { D3DTEXF_LINEAR };

if (doPostFxAA)
{
Expand All @@ -220,6 +221,12 @@ public:
pDevice->GetRenderTarget(0, &backBuffer);
if (backBuffer && ShadersAA::pHDRTex2)
{
// save sampler state
for(int i = 0; i < PostfxTextureCount; i++) {
pDevice->GetTexture(i, &prePostFx[i]);
pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]);
}

ShadersAA::pHDRTex2->GetSurfaceLevel(0, &pHDRSurface2);

static auto prefAA = FusionFixSettings.GetRef("PREF_ANTIALIASING");
Expand Down Expand Up @@ -257,10 +264,6 @@ public:
ShadersAA::edgesTex->GetSurfaceLevel(0, &edgesSurf);
ShadersAA::blendTex->GetSurfaceLevel(0, &blendSurf);

// save sampler state
for(int i = 0; i < 5; i++)
pDevice->GetSamplerState(i, D3DSAMP_MAGFILTER, &Samplers[i]);

// game postfx
pDevice->SetRenderTarget(0, pHDRSurface2);
pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 0, 0);
Expand Down Expand Up @@ -332,15 +335,18 @@ public:
pDevice->SetPixelShader(pShader);
pDevice->SetFVF(OldFVF);

// restore sampler state
for (auto i = 0; i < 5; i++)
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]);

SAFE_RELEASE(edgesSurf);
SAFE_RELEASE(blendSurf);
}
}

// restore sampler state
for(int i = 0; i < PostfxTextureCount; i++) {
pDevice->SetTexture(i, prePostFx[i]);
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, Samplers[i]);
SAFE_RELEASE(prePostFx[i]);
}

SAFE_RELEASE(backBuffer);
SAFE_RELEASE(pHDRSurface2);
if (bUseSSAA) {
Expand Down

0 comments on commit f3cc62c

Please sign in to comment.