From e4e34b1161b72e96139563ded78bc7368d5f1507 Mon Sep 17 00:00:00 2001 From: sTc2201 <41953894+sTc2201@users.noreply.github.com> Date: Tue, 24 Sep 2024 05:16:07 +0200 Subject: [PATCH] dark phone fix (#621) Co-authored-by: RaphaelK12 <38438130+RaphaelK12@users.noreply.github.com> --- source/fixes.ixx | 76 +++++++++++++++++++++++------------------------ source/postfx.ixx | 62 +++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/source/fixes.ixx b/source/fixes.ixx index 12d65de5..7adc0b8c 100644 --- a/source/fixes.ixx +++ b/source/fixes.ixx @@ -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(pVertex, 0.0f, true); - injector::WriteMemory(pVertex + 2, 0.0f, true); - } - } - else - { - injector::WriteMemory(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(4); - PatchVertices(*addr); - } - else - { - pattern = hook::pattern("C7 46 ? ? ? ? ? C7 46 ? ? ? ? ? 5E 59 C3"); - if (!pattern.empty()) - { - auto addr = pattern.get_first(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(pVertex, 0.0f, true); + // injector::WriteMemory(pVertex + 2, 0.0f, true); + // } + // } + // else + // { + // injector::WriteMemory(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(4); + // PatchVertices(*addr); + // } + // else + // { + // pattern = hook::pattern("C7 46 ? ? ? ? ? C7 46 ? ? ? ? ? 5E 59 C3"); + // if (!pattern.empty()) + // { + // auto addr = pattern.get_first(3); + // PatchVertices(*addr); + // } + // } + // } }; } } Fixes; \ No newline at end of file diff --git a/source/postfx.ixx b/source/postfx.ixx index 780b3ac9..459e0070 100644 --- a/source/postfx.ixx +++ b/source/postfx.ixx @@ -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 @@ -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); @@ -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); @@ -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); @@ -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]);