diff options
| author | 2026-04-01 11:29:18 -0400 | |
|---|---|---|
| committer | 2026-04-01 11:29:18 -0400 | |
| commit | f6548381b4a104b3b93ec1eed8add8fe23057a48 (patch) | |
| tree | 543f20f92b6248fd9da079508a71bc1ed0515776 | |
| parent | 47ba7138ae1fc3f090905a0a3feee3b5ae36cbf2 (diff) | |
| download | WorldTuningTool-f6548381b4a104b3b93ec1eed8add8fe23057a48.tar.gz WorldTuningTool-f6548381b4a104b3b93ec1eed8add8fe23057a48.tar.bz2 WorldTuningTool-f6548381b4a104b3b93ec1eed8add8fe23057a48.zip | |
Track patch settings in config
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rwxr-xr-x | Config.cs | 21 | ||||
| -rwxr-xr-x | Plugin.cs | 156 | ||||
| -rwxr-xr-x | Scripts/get_dxbc_hash.py | 6 |
3 files changed, 121 insertions, 62 deletions
@@ -86,19 +86,18 @@ namespace WorldTuningTool return "Global (null)";
}
- /*
- public class StageExt
+ public struct PatchConfig
{
- Stage s {
- get
- {
- }
- set
- {
- }
- };
+ public bool TripleShadowResolution { get; set; } = false;
+ public bool FullResolutionVolumeBlur { get; set; } = false;
+ public bool HigherThanHighestVolumeRendering { get; set; } = false;
+ public bool DisableLODLimits { get; set; } = false;
+ public bool LargerFoliageSwayRange { get; set; } = false;
+ public bool DisableReducedRateAnimations { get; set; } = false;
+ public PatchConfig() {}
}
- */
+
+ public PatchConfig Patches { get; set; } = new PatchConfig();
public Dictionary<Stage, List<Plugin.Override>> Overrides { get; set; } = new Dictionary<Stage, List<Plugin.Override>>();
}
@@ -48,10 +48,10 @@ namespace WorldTuningTool private static int ColorVectorToInt(Vector4 v)
{
- return ((int)MathF.Round(v.X*255.0f) |
- ((int)MathF.Round(v.Y*255.0f) << 8) |
- ((int)MathF.Round(v.Z*255.0f) << 16) |
- ((int)MathF.Round(v.W*255.0f) << 24));
+ return ((int)MathF.Round(v.X*255.0f) |
+ ((int)MathF.Round(v.Y*255.0f) << 8) |
+ ((int)MathF.Round(v.Z*255.0f) << 16) |
+ ((int)MathF.Round(v.W*255.0f) << 24));
}
public enum ParameterType
@@ -904,16 +904,13 @@ namespace WorldTuningTool private delegate void OnAreaChange(nint unknownPtr);
private Hook<OnAreaChange>? onAreaChange;
- private static readonly MtObject sMain = SingletonManager.GetSingleton("sMhMain")!;
- private static readonly MtObject sMhRender = SingletonManager.GetSingleton("sMhRender")!;
-
- private static readonly MtObject sMhScene = SingletonManager.GetSingleton("sMhScene")!;
+ private static MtObject? sMhScene = null;
private delegate void UpdateSSAOParams(nint sceneObjectInternal, nint stackOffset);
private Hook<UpdateSSAOParams>? updateSSAOParams;
private static Parameter[] ssaoParameters = {
- new Parameter<float>("SSAO Depth Bias", 0xB4B0, ParameterType.FLOAT, false),
- new Parameter<float>("SSAO Sloped Depth Bias", 0xB4B4, ParameterType.FLOAT, false),
- new Parameter<float>("SSAO Max Depth Bias", 0xB4B8, ParameterType.FLOAT, false),
+ new Parameter<float>("SSAO Depth Bias", 0xB4B0, ParameterType.FLOAT, false, 0.0001f),
+ new Parameter<float>("SSAO Sloped Depth Bias", 0xB4B4, ParameterType.FLOAT, false, 0.0001f),
+ new Parameter<float>("SSAO Max Depth Bias", 0xB4B8, ParameterType.FLOAT, false, 0.0001f),
new Parameter<float>("SSAO Dispersion", 0xB4BC, ParameterType.FLOAT, false),
new Parameter<float>("SSAO Effect", 0xB430, ParameterType.FLOAT, false),
new Parameter<float>("SSAO Effect GI", 0xB434, ParameterType.FLOAT, false),
@@ -1001,11 +998,11 @@ namespace WorldTuningTool new Parameter<byte>("Accurate Cascade 1 Shadow", 0x44F, ParameterType.BOOL, false),
new Parameter<byte>("Broad Area Shadow Enable", 0x5534, ParameterType.BOOL, false),
new Parameter<float>("Broad Area Shadow Center", 0x5540, ParameterType.FLOAT, false),
- //new Parameter<float>("Broad Area Shadow Range", 0x5560, ParameterType.FLOAT, false),
+ new Parameter<float>("Broad Area Shadow Range", 0x5560, ParameterType.FLOAT, false),
new Parameter<float>("Broad Area Shadow Dir", 0x5550, ParameterType.VECTOR4, false),
- //new Parameter<float>("Broad Area Shadow Depth Bias", 0x5570, ParameterType.FLOAT, false),
- //new Parameter<float>("Broad Area Shadow Sloped Depth Bias", 0x5574, ParameterType.FLOAT, false),
- //new Parameter<float>("Broad Area Shadow Max Depth Bias", 0x5578, ParameterType.FLOAT, false),
+ //new Parameter<float>("Broad Area Shadow Depth Bias", 0x5570, ParameterType.FLOAT, false, 0.0001f),
+ //new Parameter<float>("Broad Area Shadow Sloped Depth Bias", 0x5574, ParameterType.FLOAT, false, 0.0001f),
+ //new Parameter<float>("Broad Area Shadow Max Depth Bias", 0x5578, ParameterType.FLOAT, false, 0.0001f),
new Parameter<float>("Broad Area Shadow Max LOD Level", 0x5524, ParameterType.FLOAT, false),
new Parameter<float>("Broad Area Shadow Culling Size", 0x5528, ParameterType.FLOAT, false),
new Parameter<float>("Checkerboard Alpha Unroll Near", 0xE964, ParameterType.FLOAT, false),
@@ -1176,7 +1173,7 @@ namespace WorldTuningTool new Parameter<float>("Shadow Culling Length[0]", 0x184, ParameterType.FLOAT, true),
new Parameter<float>("Shadow Culling Length[1]", 0x18C, ParameterType.FLOAT, true),
new Parameter<float>("Shadow Culling Length[2]", 0x194, ParameterType.FLOAT, true),
- new Parameter<float>("Broad Area Shadow Range", 0x1B0, ParameterType.FLOAT, true, 0.0001f),
+ //new Parameter<float>("Broad Area Shadow Range", 0x1B0, ParameterType.FLOAT, true),
new Parameter<float>("Broad Area Shadow Depth Bias", 0x1C4, ParameterType.FLOAT, true, 0.0001f),
new Parameter<float>("Broad Area Shadow Sloped Depth Bias", 0x1CC, ParameterType.FLOAT, true, 0.0001f),
new Parameter<float>("Broad Area Shadow Max Depth Bias", 0x1D4, ParameterType.FLOAT, true, 0.0001f),
@@ -1230,7 +1227,7 @@ namespace WorldTuningTool //shadowRes4_Limit.Disable();
}
- private bool disableVolumeDownsample = false;
+ private bool fullResVolumeBlur = false;
private Patch volumeSars1;
private Patch volumeSars2;
private Patch volumeSars3;
@@ -1241,7 +1238,7 @@ namespace WorldTuningTool private Patch volumeSars8;
private Patch volumeSars9;
- private void disableVolumeDownsampleEnable()
+ private void fullResVolumeBlurEnable()
{
volumeSars1.Enable();
volumeSars2.Enable();
@@ -1254,7 +1251,7 @@ namespace WorldTuningTool volumeSars9.Enable();
}
- private void disableVolumeDownsampleDisable()
+ private void fullResVolumeBlurDisable()
{
volumeSars1.Disable();
volumeSars2.Disable();
@@ -1342,6 +1339,8 @@ namespace WorldTuningTool private delegate void UpdateLights(nint lightObject);
private Hook<UpdateLights>? updateLights;
+ private static MtObject? sMain = null;
+
public PluginData Initialize()
{
onAreaChange = Hook.Create<OnAreaChange>(0x141AC27D0, OnAreaChangeHook); // nint
@@ -1371,7 +1370,7 @@ namespace WorldTuningTool createLightingObject = Hook.Create<CreateLightingObject>(0x1424CDE20, CreateLightingObjectHook);
destroyLightingObject = Hook.Create<DestroyLightingObject>(0x1424CE380, DestroyLightingObjectHook); // nint, int
- nint addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 55 41 56 41 57 48 8B EC 48 83 EC 30 48 8B FA 48 8B D9 E8 AA B6 C1 FF 48 8B 47 10 48 8D 57 50"));
+ IntPtr addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 55 41 56 41 57 48 8B EC 48 83 EC 30 48 8B FA 48 8B D9 E8 AA B6 C1 FF 48 8B 47 10 48 8D 57 50"));
#if ADDR_ASSERTS
Assert(addr == 0x141AB2260); // nint, nint
#endif
@@ -1426,17 +1425,17 @@ namespace WorldTuningTool 0xB8, 0x40, 0x15, 0x00, 0x00, 0xEB, 0x21 // This case is used for Low, Medium and High in-game.
]);
- volumeSars1 = new Patch((nint)0x1424D0159, [0x90, 0x90]);
- volumeSars2 = new Patch((nint)0x1424D01A0, [0x90, 0x90]);
- volumeSars3 = new Patch((nint)0x1424D01C6, [0x90, 0x90]);
- volumeSars4 = new Patch((nint)0x1424D0219, [0x90, 0x90]);
- volumeSars5 = new Patch((nint)0x1424D0242, [0x90, 0x90]);
- volumeSars6 = new Patch((nint)0x1424D029D, [0x90, 0x90]);
- volumeSars7 = new Patch((nint)0x1424D02C6, [0x90, 0x90]);
- volumeSars8 = new Patch((nint)0x1424D0321, [0x90, 0x90]);
- volumeSars9 = new Patch((nint)0x1424D034A, [0x90, 0x90]);
+ volumeSars1 = new Patch(new IntPtr(0x1424D0159), [0x90, 0x90]);
+ volumeSars2 = new Patch(new IntPtr(0x1424D01A0), [0x90, 0x90]);
+ volumeSars3 = new Patch(new IntPtr(0x1424D01C6), [0x90, 0x90]);
+ volumeSars4 = new Patch(new IntPtr(0x1424D0219), [0x90, 0x90]);
+ volumeSars5 = new Patch(new IntPtr(0x1424D0242), [0x90, 0x90]);
+ volumeSars6 = new Patch(new IntPtr(0x1424D029D), [0x90, 0x90]);
+ volumeSars7 = new Patch(new IntPtr(0x1424D02C6), [0x90, 0x90]);
+ volumeSars8 = new Patch(new IntPtr(0x1424D0321), [0x90, 0x90]);
+ volumeSars9 = new Patch(new IntPtr(0x1424D034A), [0x90, 0x90]);
- value2ForVolumeQuality = new Patch((nint)0x142389652, [0xB8, 0x02, 0x00, 0x00, 0x00, 0x90]);
+ value2ForVolumeQuality = new Patch(new IntPtr(0x142389652), [0xB8, 0x02, 0x00, 0x00, 0x00, 0x90]);
// Gameplay.
addr = PatternScanner.FindFirst(Pattern.FromString("80 BB 34 EC 00 00 00 88 8B 31 EC 00 00 C6 83 30 EC 00 00 00 74 1C C6 83 34 EC 00 00 00 48 8B 0D 68 4B 4F 03 80 B9 58 02 00 00 00 75 05 E8 5A F5 01 00 48 8B CB E8 E2 05 00 00 83 BB DC EB 00 00 06 74 0A C7 83 DC EB 00 00 06 00 00 00"));
@@ -1466,7 +1465,7 @@ namespace WorldTuningTool addressHigherValueForFoliageSway = new Patch(addr + 0x7, [0x04]);
// Found using mFrameSkipNum annotation from MHW-DTI-Dumps.
- zeroFrameSkip = new Patch((nint)0x142246948, [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90]);
+ zeroFrameSkip = new Patch(new IntPtr(0x142246948), [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90]);
// The game will crash when trying to switch to the FULL_RES path for SSR. It's likley because
// it tries to access resources (shader, buffer, texture, etc.) that are not loaded.
@@ -1508,8 +1507,46 @@ namespace WorldTuningTool return new PluginData();
}
+ public void OnPreMain()
+ {
+ Config config = ConfigManager.GetConfig<Config>(this);
+ Config.PatchConfig patches = config.Patches;
+ tripleShadowResolution = patches.TripleShadowResolution;
+ if (tripleShadowResolution)
+ {
+ tripleShadowResEnable();
+ }
+ fullResVolumeBlur = patches.FullResolutionVolumeBlur;
+ if (fullResVolumeBlur)
+ {
+ fullResVolumeBlurEnable();
+ }
+ higherVolumeQuality = patches.HigherThanHighestVolumeRendering;
+ if (higherVolumeQuality)
+ {
+ value2ForVolumeQuality.Enable();
+ }
+ disableLODLimits = patches.DisableLODLimits;
+ if (disableLODLimits)
+ {
+ disableLODLimitsEnable();
+ }
+ largerFoliageSwayRange = patches.LargerFoliageSwayRange;
+ if (largerFoliageSwayRange)
+ {
+ addressHigherValueForFoliageSway.Enable();
+ }
+ disableReducedRateAnimations = patches.DisableReducedRateAnimations;
+ if (disableReducedRateAnimations)
+ {
+ zeroFrameSkip.Enable();
+ }
+ }
+
public void OnLoad()
{
+ sMain = SingletonManager.GetSingleton("sMhMain")!;
+ sMhScene = SingletonManager.GetSingleton("sMhScene")!;
Config config = ConfigManager.GetConfig<Config>(this);
foreach (Stage area in Enum.GetValues(typeof(Stage)))
{
@@ -1578,27 +1615,27 @@ namespace WorldTuningTool }
}
}
- if (sMhScene.Instance != 0x0)
+ if (sMhScene!.Instance != 0x0)
{
foreach (Parameter param in ssaoParameters)
{
if (!param.PerFrame)
{
- param.Update(sMhScene.Instance);
+ param.Update(sMhScene!.Instance);
}
}
foreach (Parameter param in sslrParameters)
{
if (!param.PerFrame)
{
- param.Update(sMhScene.Instance);
+ param.Update(sMhScene!.Instance);
}
}
foreach (Parameter param in sceneParameters)
{
if (!param.PerFrame)
{
- param.Update(sMhScene.Instance);
+ param.Update(sMhScene!.Instance);
}
}
}
@@ -1609,7 +1646,7 @@ namespace WorldTuningTool updateSSAOParams!.Original(sceneObjectInternal, stackOffset);
foreach (Parameter param in ssaoParameters)
{
- param.Update(sMhScene.Instance);
+ param.Update(sMhScene!.Instance);
}
}
@@ -1618,7 +1655,7 @@ namespace WorldTuningTool updateSSLRParams!.Original(stackOffset);
foreach (Parameter param in sslrParameters)
{
- param.Update(sMhScene.Instance);
+ param.Update(sMhScene!.Instance);
}
}
@@ -2059,6 +2096,7 @@ namespace WorldTuningTool if (ImGui.CollapsingHeader("Patches"))
{
+ Config.PatchConfig patches = config.Patches;
if (ImGui.Checkbox("3x Shadow Resolution", ref tripleShadowResolution))
{
if (tripleShadowResolution)
@@ -2069,7 +2107,10 @@ namespace WorldTuningTool {
tripleShadowResDisable();
}
- setShadowQuality.Invoke(MemoryUtil.Read<int>(sMhScene.Instance + 0x5530) + 1);
+ setShadowQuality.Invoke(MemoryUtil.Read<int>(sMhScene!.Instance + 0x5530) + 1);
+ patches.TripleShadowResolution = tripleShadowResolution;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
@@ -2077,20 +2118,23 @@ namespace WorldTuningTool ImGui.EndTooltip();
}
- if (ImGui.Checkbox("Volume Rendering Full Resolution Blur Pass (Requires Area Change)", ref disableVolumeDownsample))
+ if (ImGui.Checkbox("Volume Rendering Full Resolution Blur Pass (Requires Area Change)", ref fullResVolumeBlur))
{
- if (disableVolumeDownsample)
+ if (fullResVolumeBlur)
{
- disableVolumeDownsampleEnable();
+ fullResVolumeBlurEnable();
}
else
{
- disableVolumeDownsampleDisable();
+ fullResVolumeBlurDisable();
}
+ patches.FullResolutionVolumeBlur = fullResVolumeBlur;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("This can get rid of excessive aliasing when something is in front of a volumetric effect.\nMove to a different area one time for this to apply, it will stay applied after that.");
+ ImGui.Text("This can get rid of excessive aliasing when something is in front of a volumetric effect.\nMove to a different area for this to apply, it will stay applied after that.");
ImGui.EndTooltip();
}
@@ -2104,6 +2148,9 @@ namespace WorldTuningTool {
value2ForVolumeQuality.Disable();
}
+ patches.HigherThanHighestVolumeRendering = higherVolumeQuality;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
@@ -2121,6 +2168,9 @@ namespace WorldTuningTool {
disableLODLimitsDisable();
}
+ patches.DisableLODLimits = disableLODLimits;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
@@ -2138,6 +2188,9 @@ namespace WorldTuningTool {
addressHigherValueForFoliageSway.Disable();
}
+ patches.LargerFoliageSwayRange = largerFoliageSwayRange;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
@@ -2155,6 +2208,9 @@ namespace WorldTuningTool {
zeroFrameSkip.Disable();
}
+ patches.DisableReducedRateAnimations = disableReducedRateAnimations;
+ config.Patches = patches;
+ ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
@@ -2269,7 +2325,7 @@ namespace WorldTuningTool if (ImGui.CollapsingHeader("SSAO Parameters"))
{
ImGui.PushID("SSAO");
- ImGui.Text($"Address: {sMhScene.Instance:X}");
+ ImGui.Text($"Address: {sMhScene!.Instance:X}");
foreach (Parameter param in ssaoParameters)
{
param.Draw(width);
@@ -2280,7 +2336,7 @@ namespace WorldTuningTool if (ImGui.CollapsingHeader("SSLR Parameters"))
{
ImGui.PushID("SSLR");
- ImGui.Text($"Address: {sMhScene.Instance:X}");
+ ImGui.Text($"Address: {sMhScene!.Instance:X}");
foreach (Parameter param in sslrParameters)
{
param.Draw(width);
@@ -2291,7 +2347,7 @@ namespace WorldTuningTool if (ImGui.CollapsingHeader("Scene Parameters"))
{
ImGui.PushID("Scene");
- ImGui.Text($"Address: {sMhScene.Instance:X}");
+ ImGui.Text($"Address: {sMhScene!.Instance:X}");
foreach (Parameter param in sceneParameters)
{
param.Draw(width);
@@ -2303,16 +2359,16 @@ namespace WorldTuningTool if (ImGui.CollapsingHeader("DEBUG"))
{
ImGui.PushItemWidth(width * 0.15f);
- ImGui.Text($"FPS: {MemoryUtil.GetRef<float>(sMain.Instance + 0x68)}");
- ImGui.Text($"Delta Time: {MemoryUtil.GetRef<float>(sMain.Instance + 0x94)}");
+ ImGui.Text($"FPS: {MemoryUtil.GetRef<float>(sMain!.Instance + 0x68)}");
+ ImGui.Text($"Delta Time: {MemoryUtil.GetRef<float>(sMain!.Instance + 0x94)}");
// Locations taken from MHW-DTI-Dumps/wip_dump_15_20_00.h.
- ImGui.InputFloat("Simulation FPS", ref MemoryUtil.GetRef<float>(sMain.Instance + 0x58));
+ ImGui.InputFloat("Simulation FPS", ref MemoryUtil.GetRef<float>(sMain!.Instance + 0x58));
if (ImGui.BeginItemTooltip())
{
ImGui.Text("This does not apply to jiggle physics.");
ImGui.EndTooltip();
}
- ImGui.InputFloat("Max FPS", ref MemoryUtil.GetRef<float>(sMain.Instance + 0x5C));
+ ImGui.InputFloat("Max FPS", ref MemoryUtil.GetRef<float>(sMain!.Instance + 0x5C));
ImGui.PopItemWidth();
}
}
diff --git a/Scripts/get_dxbc_hash.py b/Scripts/get_dxbc_hash.py index 0c53107..dabcc42 100755 --- a/Scripts/get_dxbc_hash.py +++ b/Scripts/get_dxbc_hash.py @@ -12,6 +12,10 @@ for path in sys.argv[1:]: print(path + ':') with open(path, 'rb') as f: if f.read(4).decode('ASCII') == 'DXBC': - print(' %08x-%08x-%08x-%08x' % (struct.unpack('<I', f.read(4))[0], struct.unpack('<I', f.read(4))[0], struct.unpack('<I', f.read(4))[0], struct.unpack('<I', f.read(4))[0])) + print(' %08x-%08x-%08x-%08x' % ( + struct.unpack('<I', f.read(4))[0], + struct.unpack('<I', f.read(4))[0], + struct.unpack('<I', f.read(4))[0], + struct.unpack('<I', f.read(4))[0])) else: print(' Invalid DXBC file.') |