From 79758df9b6c469f11bd45944e2e1e3769853261c Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 30 Nov 2014 15:17:47 +0100 Subject: [PATCH] Merged both dual pass methods and made them selectable via the INI file --- SAFix/SilentPatchSA.cpp | 109 +++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index ece9dd2..7690114 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -372,11 +372,11 @@ RpAtomic* OnePassAlphaRender(RpAtomic* atomic) return atomic; } -RpAtomic* TwoPassAlphaRender(RpAtomic* atomic) +RpAtomic* TwoPassAlphaRender_aap(RpAtomic* atomic) { // For cutscenes, fall back to one-pass render if ( CCutsceneMgr__ms_running && !CanSeeOutSideFromCurrArea() ) - return OnePassAlphaRender(atomic); + return AtomicDefaultRenderCallBack(atomic); int nPushedAlpha, nAlphaFunction; int nZWrite; @@ -412,11 +412,11 @@ RpAtomic* TwoPassAlphaRender(RpAtomic* atomic) return atomic; } -RpAtomic* TwoPassAlphaRenderSilent(RpAtomic* atomic) +RpAtomic* TwoPassAlphaRender_Silent(RpAtomic* atomic) { // For cutscenes, fall back to one-pass render if ( CCutsceneMgr__ms_running && !CanSeeOutSideFromCurrArea() ) - return OnePassAlphaRender(atomic); + return AtomicDefaultRenderCallBack(atomic); int nPushedAlpha, nAlphaFunction; int nZWrite; @@ -465,6 +465,7 @@ RpAtomic* StaticPropellerRender(RpAtomic* pAtomic) return pAtomic; } +template RpAtomic* RenderBigVehicleActomic(RpAtomic* pAtomic, float fComp) { UNREFERENCED_PARAMETER(fComp); @@ -472,7 +473,7 @@ RpAtomic* RenderBigVehicleActomic(RpAtomic* pAtomic, float fComp) const char* pNodeName = GetFrameNodeName(RpAtomicGetFrame(pAtomic)); if ( !strncmp(pNodeName, "moving_prop", 11) ) - return TwoPassAlphaRender(pAtomic); + return renderer(pAtomic); if ( !strncmp(pNodeName, "static_prop", 11) ) return StaticPropellerRender(pAtomic); @@ -497,10 +498,16 @@ void SetRendererForAtomic(RpAtomic* pAtomic) BOOL bHasAlpha = FALSE; RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), AlphaTest, &bHasAlpha); -// if ( bHasAlpha ) + if ( bHasAlpha ) RpAtomicSetRenderCallBack(pAtomic, renderer); } +template +void SetRendererForAtomic_NoTest(RpAtomic* pAtomic) +{ + RpAtomicSetRenderCallBack(pAtomic, renderer); +} + void RenderWeapon(CPed* pPed) { pPed->RenderWeapon(false, false); @@ -549,13 +556,14 @@ void RenderWeaponPedsForPC() RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, reinterpret_cast(nAlphaBlending)); }*/ +template RpAtomic* RenderPedCB(RpAtomic* pAtomic) { BOOL bHasAlpha = FALSE; RpGeometryForAllMaterials(RpAtomicGetGeometry(pAtomic), AlphaTest, &bHasAlpha); if ( bHasAlpha ) - return TwoPassAlphaRender(pAtomic); + return renderer(pAtomic); return AtomicDefaultRenderCallBack(pAtomic); } @@ -1706,22 +1714,40 @@ BOOL InjectDelayedPatches_10() if ( !bSARender ) { // Twopass rendering (experimental) + unsigned int dwTwoPassMethod = GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", 0, wcModulePath); Patch(0x4C441E, 0x57); Patch(0x4C4424, 0x5F04C483); Patch(0x4C4428, 0x0004C25E); - if ( GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", FALSE, wcModulePath) != FALSE ) + if ( dwTwoPassMethod == 1 ) { - InjectHook(0x4C441F, SetRendererForAtomic, PATCH_CALL); + // Silent's twopass + InjectHook(0x4C441F, SetRendererForAtomic, PATCH_CALL); + Patch(0x7341D9, TwoPassAlphaRender_Silent); + Patch(0x734127, TwoPassAlphaRender_Silent); + Patch(0x73445E, RenderBigVehicleActomic); // Twopass for peds - InjectHook(0x733614, RenderPedCB); + InjectHook(0x733614, RenderPedCB); + } + else if ( dwTwoPassMethod == 2 ) + { + // aap's twopass + InjectHook(0x4C441F, SetRendererForAtomic_NoTest, PATCH_CALL); + Patch(0x7341D9, TwoPassAlphaRender_aap); + Patch(0x734127, TwoPassAlphaRender_aap); + Patch(0x73445E, RenderBigVehicleActomic); + // Twopass for peds + InjectHook(0x733614, RenderPedCB); } else { + Patch(0x7341D9, TwoPassAlphaRender_aap); + Patch(0x734127, TwoPassAlphaRender_aap); + Patch(0x73445E, RenderBigVehicleActomic); InjectHook(0x4C441F, SetRendererForAtomic, PATCH_CALL); } - if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", FALSE, wcModulePath) != FALSE ) + if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", TRUE, wcModulePath) != FALSE ) { // Shaders! // plugin-sdk compatibility @@ -1896,22 +1922,40 @@ BOOL InjectDelayedPatches_11() if ( !bSARender ) { // Twopass rendering (experimental) + unsigned int dwTwoPassMethod = GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", 0, wcModulePath); Patch(0x4C449E, 0x57); Patch(0x4C44A4, 0x5F04C483); Patch(0x4C44A8, 0x0004C25E); - if ( GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", FALSE, wcModulePath) != FALSE ) + if ( dwTwoPassMethod == 1 ) { - InjectHook(0x4C449F, SetRendererForAtomic, PATCH_CALL); + // Silent's twopass + InjectHook(0x4C449F, SetRendererForAtomic, PATCH_CALL); + Patch(0x734A09, TwoPassAlphaRender_Silent); + Patch(0x734957, TwoPassAlphaRender_Silent); + Patch(0x734C8E, RenderBigVehicleActomic); // Twopass for peds - InjectHook(0x733E44, RenderPedCB); + InjectHook(0x733E44, RenderPedCB); + } + else if ( dwTwoPassMethod == 2 ) + { + // aap's twopass + InjectHook(0x4C449F, SetRendererForAtomic_NoTest, PATCH_CALL); + Patch(0x734A09, TwoPassAlphaRender_aap); + Patch(0x734957, TwoPassAlphaRender_aap); + Patch(0x734C8E, RenderBigVehicleActomic); + // Twopass for peds + InjectHook(0x733E44, RenderPedCB); } else { InjectHook(0x4C449F, SetRendererForAtomic, PATCH_CALL); + Patch(0x734A09, TwoPassAlphaRender_aap); + Patch(0x734957, TwoPassAlphaRender_aap); + Patch(0x734C8E, RenderBigVehicleActomic); } - if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", FALSE, wcModulePath) != FALSE ) + if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", TRUE, wcModulePath) != FALSE ) { // Shaders! // plugin-sdk compatibility @@ -2094,22 +2138,40 @@ BOOL InjectDelayedPatches_Steam() if ( !bSARender ) { // Twopass rendering (experimental) + unsigned int dwTwoPassMethod = GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", 0, wcModulePath); Patch(0x4CEBF3, 0x57); Patch(0x4CEBF9, 0xC25E5F5F); Patch(0x4CEBFD, 0x0004); - if ( GetPrivateProfileIntW(L"SilentPatch", L"TwoPassRendering", FALSE, wcModulePath) != FALSE ) + if ( dwTwoPassMethod == 1 ) { - InjectHook(0x4CEBF4, SetRendererForAtomic, PATCH_CALL); + // Silent's twopass + InjectHook(0x4CEBF4, SetRendererForAtomic, PATCH_CALL); + Patch(0x76E230, TwoPassAlphaRender_Silent); + Patch(0x76E160, TwoPassAlphaRender_Silent); + Patch(0x76E4F0, RenderBigVehicleActomic); // Twopass for peds - InjectHook(0x76D88E, RenderPedCB); + InjectHook(0x76D88E, RenderPedCB); + } + else if ( dwTwoPassMethod == 2 ) + { + // aap's twopass + InjectHook(0x4CEBF4, SetRendererForAtomic_NoTest, PATCH_CALL); + Patch(0x76E230, TwoPassAlphaRender_aap); + Patch(0x76E160, TwoPassAlphaRender_aap); + Patch(0x76E4F0, RenderBigVehicleActomic); + // Twopass for peds + InjectHook(0x76D88E, RenderPedCB); } else { InjectHook(0x4CEBF4, SetRendererForAtomic, PATCH_CALL); + Patch(0x76E230, TwoPassAlphaRender_aap); + Patch(0x76E160, TwoPassAlphaRender_aap); + Patch(0x76E4F0, RenderBigVehicleActomic); } - if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", FALSE, wcModulePath) != FALSE ) + if ( !bSAMP && GetPrivateProfileIntW(L"SilentPatch", L"NVCShader", TRUE, wcModulePath) != FALSE ) { // Shaders! // plugin-sdk compatibility @@ -2271,9 +2333,6 @@ void Patch_SA_10() InjectHook(0x6CAB70, &CPlane::Render_Stub, PATCH_JUMP); InjectHook(0x6C4400, &CHeli::Render_Stub, PATCH_JUMP); //InjectHook(0x553318, RenderAlphaAtomics); - Patch(0x7341D9, TwoPassAlphaRender); - Patch(0x734127, TwoPassAlphaRender); - Patch(0x73445E, RenderBigVehicleActomic); //Patch(0x73406E, TwoPassAlphaRender); // Boats @@ -2524,9 +2583,6 @@ void Patch_SA_11() // Heli rotors InjectHook(0x6CB390, &CPlane::Render_Stub, PATCH_JUMP); InjectHook(0x6C4C20, &CHeli::Render_Stub, PATCH_JUMP); - Patch(0x734A09, TwoPassAlphaRender); - Patch(0x734957, TwoPassAlphaRender); - Patch(0x734C8E, RenderBigVehicleActomic); // RefFix static const float fRefZVal = 1.0f; @@ -2772,9 +2828,6 @@ void Patch_SA_Steam() // Heli rotors InjectHook(0x700620, &CPlane::Render_Stub, PATCH_JUMP); InjectHook(0x6F9550, &CHeli::Render_Stub, PATCH_JUMP); - Patch(0x76E230, TwoPassAlphaRender); - Patch(0x76E160, TwoPassAlphaRender); - Patch(0x76E4F0, RenderBigVehicleActomic); // RefFix static const float fRefZVal = 1.0f;