From fc4a089d103c1cfcb7f82c55cfe0cb659cd232f4 Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 14:28:52 +0100 Subject: [PATCH 1/6] Partially hide mouse cursor when using a controller --- source/fixes.ixx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/fixes.ixx b/source/fixes.ixx index 7adc0b8c..3a723126 100644 --- a/source/fixes.ixx +++ b/source/fixes.ixx @@ -490,6 +490,17 @@ public: // } // } // } + + // HACK: Visually hide the mouse cursor when using a gamepad, doesn't actually disable the cursor so it might still interact with UI, also still shows in the start menu because...?? + { + auto pattern = hook::pattern("75 1B 83 3D ? ? ? ? ? 75 12 6A 00 E8"); + if (!pattern.empty()) + { + injector::WriteMemory(pattern.get_first(0), 0x840F, true); // jnz short -> jz long + injector::WriteMemory(pattern.get_first(2), (uintptr_t)hook::get_pattern("C6 05 ? ? ? ? ? 5F 5E 5D 5B 83 C4 2C C3", 7) - (uintptr_t)pattern.get_first(6), true); + injector::MakeNOP(pattern.get_first(6), 23, true); + } + } }; } } Fixes; \ No newline at end of file From 6d8f3ce8b86ddae9ba5aa8733c538101ce182e9c Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 14:30:57 +0100 Subject: [PATCH 2/6] Enable first person crosshair (annihilator, buzzard) for controllers --- source/fixes.ixx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/fixes.ixx b/source/fixes.ixx index 3a723126..653299d0 100644 --- a/source/fixes.ixx +++ b/source/fixes.ixx @@ -501,6 +501,18 @@ public: injector::MakeNOP(pattern.get_first(6), 23, true); } } + + // Enable the "first person" reticle (Annihilator, Buzzard) on gamepads as well, this used to be a keyboard & mouse feature only. + { + auto pattern = hook::pattern("85 F6 0F 84 ? ? ? ? 80 BE ? ? ? ? ? 0F 84 ? ? ? ? 85 C9 0F 84"); + if (!pattern.empty()) + injector::MakeNOP(pattern.get_first(0), 21, true); + else + { + pattern = hook::pattern("8B 4C 24 24 85 C9 0F 84 ? ? ? ? 80 B9 ? ? ? ? ? 0F 84"); + injector::MakeNOP(pattern.get_first(0), 25, true); + } + } }; } } Fixes; \ No newline at end of file From 7487c1c6c873183c5cab5103d686868c316c7d43 Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 14:40:03 +0100 Subject: [PATCH 3/6] More framerate related "fixes" --- source/frameratevigilante.ixx | 41 ++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/source/frameratevigilante.ixx b/source/frameratevigilante.ixx index ce6f37d6..ad23944c 100644 --- a/source/frameratevigilante.ixx +++ b/source/frameratevigilante.ixx @@ -51,7 +51,7 @@ public: }; injector::MakeInline(pattern.get_first(0), pattern.get_first(6)); } - pattern = hook::pattern("F3 0F 10 05 ? ? ? ? F3 0F 58 C1 F3 0F 11 05 ? ? ? ? EB 36"); + pattern = hook::pattern("F3 0F 10 05 ? ? ? ? F3 0F 58 C1 F3 0F 11 05 ? ? ? ? EB 36", "F3 0F 10 05 ? ? ? ? F3 0F 58 05 ? ? ? ? F3 0F 11 05 ? ? ? ? EB 30"); if (!pattern.empty()) { static auto f1032790 = *pattern.get_first(4); @@ -75,6 +75,17 @@ public: } }; injector::MakeInline(pattern.get_first(0), pattern.get_first(8)); } + else + { + pattern = hook::pattern("F3 0F 59 05 ? ? ? ? F3 0F 59 05 ? ? ? ? F3 0F 58 05 ? ? ? ? F3 0F 11 05"); + struct LoadingTextSpeed2 + { + void operator()(injector::reg_pack& regs) + { + regs.xmm0.f32[0] *= (1000.0f) / 10.0f; + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(8)); + } pattern = hook::pattern("F3 0F 58 0D ? ? ? ? 0F 5B C0 F3 0F 11 0D"); if (!pattern.empty()) @@ -87,6 +98,34 @@ public: } }; injector::MakeInline(pattern.get_first(0), pattern.get_first(8)); } + else + { + pattern = hook::pattern("F3 0F 58 05 ? ? ? ? F3 0F 2A 0D"); + struct LoadingTextSparks + { + void operator()(injector::reg_pack& regs) + { + regs.xmm0.f32[0] += (0.085f) / 5.0f; + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(8)); + } + + // Slow down the "CD/busy spinner" at 60 FPS, will be slower below or faster above this framerate + pattern = find_pattern("F3 0F 58 05 ? ? ? ? 33 C0 A3 ? ? ? ? F3 0F 11 05", "F3 0F 58 15 ? ? ? ? 33 C0 F3 0F 11 15 ? ? ? ? A3 ? ? ? ? 8B 0D"); + if (!pattern.empty()) + { + struct CDSpinnerHook + { + void operator()(injector::reg_pack& regs) + { + regs.xmm2.f32[0] += (0.17453294f) / 3.0f; + } + }; injector::MakeInline(pattern.get_first(0), pattern.get_first(8)); + } + + // Slow down the cop blips at 60 FPS, will be slower below or faster above this framerate + pattern = find_pattern("6B C0 15 53 8B DA B9 ? ? ? ? 33 D2 F7 F1", "6B C0 15 C1 EA 05 53 8B DA 33 D2 B9"); + injector::WriteMemory(pattern.get_first(2), 7, true); }; } } FramerateVigilante; \ No newline at end of file From 68baf59cb78066f62db5eff68bb010b8e9619789 Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 14:59:20 +0100 Subject: [PATCH 4/6] some more shader module changes --- source/shaders.ixx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/shaders.ixx b/source/shaders.ixx index b6cb783c..bb057035 100644 --- a/source/shaders.ixx +++ b/source/shaders.ixx @@ -74,6 +74,7 @@ public: fSHADOWFILTERSOFTShadowBias = iniReader.ReadFloat("SHADOWFILTERSOFT", "ShadowBias", 8.0f); fShadowBlendRange = std::clamp(iniReader.ReadFloat("SHADOWS", "ShadowBlendRange", 0.3f), 0.0f, 1.0f); nForceShadowFilter = std::clamp(iniReader.ReadInteger("SHADOWS", "ForceShadowFilter", 0), 0, 2); + bool bConsoleCarReflectionsAndDirt = iniReader.ReadInteger("MISC", "ConsoleCarReflectionsAndDirt", 1) != 0; // Redirect path to one unified folder auto pattern = hook::pattern("8B 04 8D ? ? ? ? A3 ? ? ? ? 8B 44 24 04"); @@ -102,6 +103,28 @@ public: } }; injector::MakeInline(pattern.get_first(0), pattern.get_first(7)); } + + // Pass the correct value for gAmbientAmount to the rain shader (gta_rmptfx_gpurender). + // The Game reads the rain.* values in visualsettings.dat properly but then overrides them with custom values. + // This makes rain drops more visible, this was done in shader before but moved here instead. + { + auto pattern = find_pattern("F3 0F 10 05 ? ? ? ? 6A 10 8B D9 8B 4F 18 F3 0F 11 44 24 ? F3 0F 10 05", "F3 0F 10 05 ? ? ? ? 68 ? ? ? ? F3 0F 11 44 24 ? F3 0F 10 05 ? ? ? ? 50 F3 0F 11 44 24"); + if (!pattern.empty()) + { + injector::MakeNOP(pattern.get_first(0), 8, true); // rain.ambient (gAmbientAmount): 0.1 -> 0.4 + pattern = find_pattern("F3 0F 11 44 24 ? F3 0F 10 05 ? ? ? ? 68 ? ? ? ? FF 73 14 F3 0F 11 44 24", "F3 0F 11 44 24 ? F3 0F 10 05 ? ? ? ? 50 F3 0F 11 44 24 ? F3 0F 10 05 ? ? ? ? 8D 5F 14 53 F3 0F 11 44 24"); + injector::MakeNOP(pattern.get_first(0), 6, true); + } + } + + // Restore console car reflections and dirt level settings. Any car on console could have dirt when they would spawn while on PC some cars _always_ spawn fully cleaned. + if (bConsoleCarReflectionsAndDirt) + { + auto pattern = find_pattern("75 0C C7 87 ? ? ? ? ? ? ? ? EB 20 66 0F 6E C2 F3 0F E6 C0 C1 EA 1F F2 0F 58 04 D5", "75 0D 0F 57 C0 F3 0F 11 86 ? ? ? ? EB 18 85 D2 89 54 24 10 DB 44 24 10 7D 06 D8 05"); + injector::WriteMemory(pattern.get_first(0), 0xEB, true); + pattern = find_pattern("75 37 C7 47 ? ? ? ? ? C7 87 ? ? ? ? ? ? ? ? C7 87", "75 3A F3 0F 10 05 ? ? ? ? F3 0F 11 46 ? F3 0F 11 86"); + injector::MakeNOP(pattern.get_first(0), 2, true); + } }; FusionFix::onGameInitEvent() += []() From b481c2a82a0f8b8ff1e018f7d4ff76b5573a6d24 Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 15:06:28 +0100 Subject: [PATCH 5/6] More shadows module updates/changes --- data/plugins/GTAIV.EFLC.FusionFix.ini | 2 ++ source/shadows.ixx | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/data/plugins/GTAIV.EFLC.FusionFix.ini b/data/plugins/GTAIV.EFLC.FusionFix.ini index efcb66a9..75e5a67a 100644 --- a/data/plugins/GTAIV.EFLC.FusionFix.ini +++ b/data/plugins/GTAIV.EFLC.FusionFix.ini @@ -11,6 +11,7 @@ ShadowBlendRange = 0.3 // controls the size of the cascad ForceShadowFilter = 0 // 0 : shadow filter tied to definition | 1 : force 4 sample filter | 2 : force 16 sample filter HighResolutionShadows = 0 // doubles cascaded shadowmap resolution, very GPU intensive HighResolutionNightShadows = 0 // increases night shadows resolution, extremely GPU intensive +bOverrideShadowMatrix = 1 // Do not touch this setting, for debug purposes only [SHADOWFILTERSHARP] // CE-like shadows ShadowSoftness = 1.5 // controls shadow blur @@ -43,6 +44,7 @@ FixAutoExposure = 1 // restores auto exposure from con TreeAlphaPC = 0.625 TreeAlphaConsole = 4.0 CoronaReflectionIntensity = 1.0 // controls intensity of coronas in reflections +ConsoleCarReflectionsAndDirt = 1 [BudgetedIV] VehicleBudget = 0 // may cause issues, set to e.g. 260000000 to increase budget limit diff --git a/source/shadows.ixx b/source/shadows.ixx index d5b06b90..f000d087 100644 --- a/source/shadows.ixx +++ b/source/shadows.ixx @@ -142,6 +142,7 @@ public: bool bOverrideCascadeRanges = iniReader.ReadInteger("SHADOWS", "OverrideCascadeRanges", 1) != 0; bool bHighResolutionShadows = iniReader.ReadInteger("SHADOWS", "HighResolutionShadows", 0) != 0; bHighResolutionNightShadows = iniReader.ReadInteger("SHADOWS", "HighResolutionNightShadows", 0) != 0; + bool bOverrideShadowMatrix = iniReader.ReadInteger("SHADOWS", "OverrideShadowMatrix", 1) != 0; if (bExtraDynamicShadows || bDynamicShadowForTrees) { @@ -302,6 +303,32 @@ public: } } } + + // Subtract shadow static bias directly in game code. Should this have an ini option...? + if (bOverrideShadowMatrix) + { + struct ShadowMatrix + { + float ShadowMatrix0; + float ShadowMatrix1; + float ShadowMatrix2; + float ShadowMatrix3; + }; + + auto pattern = find_pattern("F3 0F 10 14 85 ? ? ? ? F3 0F 10 0C 85 ? ? ? ? F3 0F 5C CA F3 0F 59 C8 F3 0F 58 CA F3 0F 11 0C B5", + "F3 0F 10 94 00 ? ? ? ? F3 0F 10 9C 00 ? ? ? ? 03 C0 F3 0F 5C DA F3 0F 5E D9 F3 0F 59 D8 F3 0F 58 DA F3 0F 11 1C BD"); + auto pShadowMatrix = *pattern.get_first(5); + + for (size_t i = 0; i < 4; i++) // low medium high veryhigh + { + injector::scoped_unprotect(&pShadowMatrix[i], sizeof(pShadowMatrix)); + + pShadowMatrix[i].ShadowMatrix0 = 0.0f; + pShadowMatrix[i].ShadowMatrix1 = 0.0f; + pShadowMatrix[i].ShadowMatrix2 = 0.0f; + pShadowMatrix[i].ShadowMatrix3 = 0.0f; + } + } }; } } Shadows; \ No newline at end of file From 31db54da6acb74f7f4402ef9d1619e9edeb2b984 Mon Sep 17 00:00:00 2001 From: sTc2201 Date: Tue, 29 Oct 2024 15:36:57 +0100 Subject: [PATCH 6/6] Fix compiler error --- source/frameratevigilante.ixx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/frameratevigilante.ixx b/source/frameratevigilante.ixx index ad23944c..7fea7969 100644 --- a/source/frameratevigilante.ixx +++ b/source/frameratevigilante.ixx @@ -51,7 +51,7 @@ public: }; injector::MakeInline(pattern.get_first(0), pattern.get_first(6)); } - pattern = hook::pattern("F3 0F 10 05 ? ? ? ? F3 0F 58 C1 F3 0F 11 05 ? ? ? ? EB 36", "F3 0F 10 05 ? ? ? ? F3 0F 58 05 ? ? ? ? F3 0F 11 05 ? ? ? ? EB 30"); + pattern = find_pattern("F3 0F 10 05 ? ? ? ? F3 0F 58 C1 F3 0F 11 05 ? ? ? ? EB 36", "F3 0F 10 05 ? ? ? ? F3 0F 58 05 ? ? ? ? F3 0F 11 05 ? ? ? ? EB 30"); if (!pattern.empty()) { static auto f1032790 = *pattern.get_first(4);