Skip to content

Commit

Permalink
dark phone fix (#621)
Browse files Browse the repository at this point in the history
Co-authored-by: RaphaelK12 <38438130+RaphaelK12@users.noreply.github.com>
  • Loading branch information
sTc2201 and RaphaelK12 authored Sep 24, 2024
1 parent 8d4d5aa commit e4e34b1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 69 deletions.
76 changes: 38 additions & 38 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -452,44 +452,44 @@ public:
}
}

// Skybox Black Bottom Fix
{
auto PatchVertices = [](float* ptr)
{
for (auto i = 0; i < ((6156 / 4) / 3); i++)
{
auto pVertex = (ptr + i * 3);
if (i < 32)
{
if (pVertex[1] < 0.0f)
{
injector::WriteMemory<float>(pVertex, 0.0f, true);
injector::WriteMemory<float>(pVertex + 2, 0.0f, true);
}
}
else
{
injector::WriteMemory<float>(pVertex + 1, (pVertex[1] - 0.16037700f) * 1.78f - 1.0f, true);
}
}
};

auto pattern = hook::pattern("C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? E8 ? ? ? ? 8B 44 24 44");
if (!pattern.empty())
{
auto addr = pattern.get_first<float*>(4);
PatchVertices(*addr);
}
else
{
pattern = hook::pattern("C7 46 ? ? ? ? ? C7 46 ? ? ? ? ? 5E 59 C3");
if (!pattern.empty())
{
auto addr = pattern.get_first<float*>(3);
PatchVertices(*addr);
}
}
}
// Skybox Black Bottom Fix -- causes holes in the map to be more visible.
// {
// auto PatchVertices = [](float* ptr)
// {
// for (auto i = 0; i < ((6156 / 4) / 3); i++)
// {
// auto pVertex = (ptr + i * 3);
// if (i < 32)
// {
// if (pVertex[1] < 0.0f)
// {
// injector::WriteMemory<float>(pVertex, 0.0f, true);
// injector::WriteMemory<float>(pVertex + 2, 0.0f, true);
// }
// }
// else
// {
// injector::WriteMemory<float>(pVertex + 1, (pVertex[1] - 0.16037700f) * 1.78f - 1.0f, true);
// }
// }
// };

// auto pattern = hook::pattern("C7 44 24 ? ? ? ? ? C7 44 24 ? ? ? ? ? E8 ? ? ? ? 8B 44 24 44");
// if (!pattern.empty())
// {
// auto addr = pattern.get_first<float*>(4);
// PatchVertices(*addr);
// }
// else
// {
// pattern = hook::pattern("C7 46 ? ? ? ? ? C7 46 ? ? ? ? ? 5E 59 C3");
// if (!pattern.empty())
// {
// auto addr = pattern.get_first<float*>(3);
// PatchVertices(*addr);
// }
// }
// }
};
}
} Fixes;
62 changes: 31 additions & 31 deletions source/postfx.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -1056,30 +1056,6 @@ private:
}
}

// game postfx
{
for(int i = 0; i < 4; i++) {
pDevice->SetTexture(i, PostFxResources.prePostFx[i]);
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, PostFxResources.Samplers[i]);
}

if(UsePostFxAA->get() > FusionFixSettings.AntialiasingText.eMO_OFF)
pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
else
pDevice->SetRenderTarget(0, PostFxResources.backBuffer);
pDevice->SetTexture(9, PostFxResources.blueNoiseVolume);
pDevice->SetTexture(2, PostFxResources.textureRead);
pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 0, 0);

pDevice->SetPixelShader(pShader);
pDevice->SetVertexShader(vShader);
//hr = pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
hbDrawPrimitivePostFX.fun();
if(UsePostFxAA->get() > FusionFixSettings.AntialiasingText.eMO_OFF)
PostFxResources.swapbuffers();

pDevice->SetTexture(9, 0);
}
// This implementation has some problems with cuts in some
// places (when smoothing some diagonal lines there are pixels that break the smoothing),
// I didn't find the reason, but using antialiasing.ixx it works almost perfectly despite being
Expand All @@ -1090,13 +1066,13 @@ private:
pDevice->GetRenderState(D3DRS_SRGBWRITEENABLE, &OldSRGB); // save srgb state
pDevice->SetPixelShader(PostFxResources.FxaaPS);

//pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
pDevice->SetRenderTarget(0, PostFxResources.backBuffer);
pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
// pDevice->SetRenderTarget(0, PostFxResources.backBuffer);

pDevice->SetTexture(2, PostFxResources.textureRead);
hr = pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
pDevice->SetTexture(2, PostFxResources.renderTargetTex);
//PostFxResources.swapbuffers();
// pDevice->SetTexture(2, PostFxResources.renderTargetTex);
PostFxResources.swapbuffers();
pDevice->SetSamplerState(2, D3DSAMP_SRGBTEXTURE, 0);
//pDevice->SetTexture(2, 0);
pDevice->SetPixelShader(pShader);
Expand Down Expand Up @@ -1152,8 +1128,8 @@ private:
vec4[3] = 4.0f;
pDevice->SetPixelShaderConstantF(5, vec4, 1);

//pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
pDevice->SetRenderTarget(0, PostFxResources.backBuffer);
pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
// pDevice->SetRenderTarget(0, PostFxResources.backBuffer);
pDevice->SetSamplerState(2, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

//pDevice->SetTexture(2, textureRead);
Expand All @@ -1162,7 +1138,7 @@ private:
pDevice->SetTexture(4, PostFxResources.blendTex->mD3DTexture);
pDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, 0);
pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
//PostFxResources.swapbuffers();
PostFxResources.swapbuffers();
pDevice->SetTexture(0, PostFxResources.prePostFx[0]);
pDevice->SetTexture(1, PostFxResources.prePostFx[1]);
pDevice->SetTexture(2, PostFxResources.textureRead);
Expand All @@ -1174,6 +1150,30 @@ private:
}
}

// game postfx
{
for(int i = 0; i < 4; i++) {
pDevice->SetTexture(i, PostFxResources.prePostFx[i]);
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, PostFxResources.Samplers[i]);
}

// if(UsePostFxAA->get() > FusionFixSettings.AntialiasingText.eMO_OFF)
// pDevice->SetRenderTarget(0, PostFxResources.renderTargetSurf);
// else
pDevice->SetRenderTarget(0, PostFxResources.backBuffer);
pDevice->SetTexture(9, PostFxResources.blueNoiseVolume);
pDevice->SetTexture(2, PostFxResources.textureRead);
pDevice->Clear(0, 0, D3DCLEAR_TARGET, 0, 0, 0);

pDevice->SetPixelShader(pShader);
pDevice->SetVertexShader(vShader);
//hr = pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
hbDrawPrimitivePostFX.fun();
// if(UsePostFxAA->get() > FusionFixSettings.AntialiasingText.eMO_OFF)
// PostFxResources.swapbuffers();

pDevice->SetTexture(9, 0);
}
for(int i = 0; i < PostfxTextureCount; i++) {
pDevice->SetTexture(i, PostFxResources.prePostFx[i]);
pDevice->SetSamplerState(i, D3DSAMP_MAGFILTER, PostFxResources.Samplers[i]);
Expand Down

0 comments on commit e4e34b1

Please sign in to comment.