Skip to content

Commit

Permalink
some small updates (#644)
Browse files Browse the repository at this point in the history
* Partially hide mouse cursor when using a controller

* Enable first person crosshair (annihilator, buzzard) for controllers

* More framerate related "fixes"

* some more shader module changes

* More shadows module updates/changes

* Fix compiler error
  • Loading branch information
sTc2201 authored Oct 30, 2024
1 parent 2d68e51 commit 2f770d5
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 1 deletion.
2 changes: 2 additions & 0 deletions data/plugins/GTAIV.EFLC.FusionFix.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions source/fixes.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,29 @@ 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<uint16_t>(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);
}
}

// 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;
41 changes: 40 additions & 1 deletion source/frameratevigilante.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public:
}; injector::MakeInline<FramerateVigilanteHook1>(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 = 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<float*>(4);
Expand All @@ -75,6 +75,17 @@ public:
}
}; injector::MakeInline<LoadingTextSpeed2>(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<LoadingTextSpeed2>(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())
Expand All @@ -87,6 +98,34 @@ public:
}
}; injector::MakeInline<LoadingTextSparks>(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<LoadingTextSparks>(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<CDSpinnerHook>(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<uint8_t>(pattern.get_first(2), 7, true);
};
}
} FramerateVigilante;
23 changes: 23 additions & 0 deletions source/shaders.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -102,6 +103,28 @@ public:
}
}; injector::MakeInline<ShaderPathHook>(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<uint8_t>(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() += []()
Expand Down
27 changes: 27 additions & 0 deletions source/shadows.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<ShadowMatrix*>(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;

0 comments on commit 2f770d5

Please sign in to comment.