summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xPlugin.cs183
1 files changed, 103 insertions, 80 deletions
diff --git a/Plugin.cs b/Plugin.cs
index ac040ae..e24ae26 100755
--- a/Plugin.cs
+++ b/Plugin.cs
@@ -80,7 +80,7 @@ using SharpPluginLoader.Core.Configuration;
// - Option to override in-game viewmode.
// Known Issues:
-// - Broken shadow areas:
+// - Broken shadow areas due to game bug (more noticeable with increased shadow bias):
// - Exit of central camp in Horfrost Reach.
// - Sporepuff area in The Ancient Forest.
// - Wildspire Waste entrence to enclosed area past the waterfall.
@@ -375,19 +375,6 @@ namespace MHWNewCamera
private Patch shadowRes3;
private Patch shadowRes4_Limit;
- /*
- private Patch ssrRes1;
- private Patch ssrRes1_1;
- private Patch ssrRes2;
- private Patch ssrRes2_1;
- private Patch ssrRes3;
- private Patch ssrRes3_1;
- private Patch ssrRes4;
- private Patch ssrRes10;
- private Patch ssrRes11;
- private Patch ssrRes12;
- */
-
private float shadowBiasOffset = 0.0f;
private float shadowRadiusOffset = 0.0f;
private bool applyShadowBias = false;
@@ -509,8 +496,23 @@ namespace MHWNewCamera
underwaterCamera5.Disable();
}
+ private bool forceOffVolumeDownsampleAndBlur = false;
+ private Patch zeroVolumeDownsample;
+
private bool disableVolumeDownsample = false;
- private Patch zeroVolumetricDownsample;
+ private Patch volumeSars1;
+ private Patch volumeSars2;
+ private Patch volumeSars3;
+ private Patch volumeSars4;
+ private Patch volumeSars5;
+ private Patch volumeSars6;
+ private Patch volumeSars7;
+ private Patch volumeSars8;
+ private Patch volumeSars9;
+
+ private delegate nint CreateLightingObject(nint unknownPtr);
+ private Hook<CreateLightingObject>? createLightingObject;
+ private nint lightingObject = 0x0;
private bool hideWeapon = false;
@@ -624,7 +626,6 @@ namespace MHWNewCamera
private void debugLog(string message)
{
- Log.Info(message);
#if LOG_DEBUG_MESSAGES
Log.Debug(message);
#endif
@@ -918,7 +919,7 @@ namespace MHWNewCamera
ssrRes3_1 = new Patch((nint)0x14259342C, [0xC6, 0x81, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90]);
ssrRes4 = new Patch((nint)0x14259268C, [0x41, 0xC7, 0x86, 0x28, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x34, 0x02, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0xC7, 0x86, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x41, 0xC6, 0x86, 0x3C, 0x02, 0x00, 0x00, 0x01]);
*/
- // Neither of these work either.
+ // None of these work either.
/*
// Don't scale resolution by SSR Factor.
ssrRes10 = new Patch((nint)0x142592DEF, [0x90, 0x90, 0x90, 0x90]);
@@ -927,6 +928,11 @@ namespace MHWNewCamera
// Make SSR Factor 1.0.
ssrRes12 = new Patch((nint)0x1425926B8 + 0x7, [0x00, 0x00, 0x80, 0x3F]);
*/
+ /* Double width and height (3rd and 4th parameter).
+ initSSRHook = Hook.Create<initSSR>(0x1425924D5, InitSSRHook); // nint, nint, int, int
+ increaseSSRMipSize1 = new Patch((nint)0x142592EBA + 0x2, [0x2]);
+ increaseSSRMipSize2 = new Patch((nint)0x142592ED0 + 0x2, [0x2]);
+ */
// 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"));
@@ -953,15 +959,6 @@ namespace MHWNewCamera
disableLODLimitsEnable();
}
- /*
- setCharacterCreatorParams = new NativeAction<nint>(0x1402457C0);
- setSaveSelectParams = new NativeAction<nint>(0x1402623A0);
- setLODLimitsHook = Hook.Create<LODLimitDelegate>(0x141B19E10, SetLODLimitsHook);
- psuedoCharacterCreatorObject = (nint)NativeMemory.AllocZeroed(304);
- MemoryUtil.WriteBytes(psuedoCharacterCreatorObject, [0xF0, 0xFA, 0xE4, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00]);
- */
- //defaultCharacterCreatorParam = new Patch((nint)0x141B1A0C1 + 0x6, [0x1]);
-
addr = PatternScanner.FindFirst(Pattern.FromString("74 4D 33 C0 48 81 C1 00 02 00 00 F3 0F 10 11 0F 2F CA 72 0C FF C0 48 83 C1 04 83 F8 03 72 EC C3"));
#if ADDR_ASSERTS
Trace.Assert(addr == 0x1426D89CA);
@@ -986,15 +983,29 @@ namespace MHWNewCamera
underwaterCamera5 = new Patch((nint)0x141FA5A74, [0x0F, 0x57, 0xF6, 0x31, 0xD2, 0x48, 0x8D, 0x4D, 0x80, 0xE8, 0x9E, 0x41, 0x38, 0xFE, 0xC1, 0xE8, 0x14, 0x66, 0x25, 0xD8, 0x03, 0xFF, 0xC8, 0x66, 0x3D, 0x48, 0x00, 0x77]);
underwaterCheckHook = Hook.Create<UnderwaterCheckDelegate>(0x1412AD500, UnderwaterCheckHook); // nint
- zeroVolumetricDownsample = new Patch((nint)0x1424D09B2, [0x31, 0xDB, 0x90, 0x90, 0x90, 0x90, 0x90]);
- /*
- zeroVolumetricDownsample2 = new Patch((nint)0x1424CE53F, [0xE9, 0x6B, 0x0C, 0x00, 0x00, 0x90]);
- zeroVolumetricDownsample3 = new Patch((nint)0x1424CF0D1, [0x90, 0x90, 0x90, 0x90, 0x90]);
- */
+ zeroVolumeDownsample = new Patch((nint)0x1424D09B2, [0x31, 0xDB, 0x90, 0x90, 0x90, 0x90, 0x90]);
+ 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]);
if (disableVolumeDownsample && !disableMod)
{
- zeroVolumetricDownsample.Enable();
+ volumeSars1.Enable();
+ volumeSars2.Enable();
+ volumeSars3.Enable();
+ volumeSars4.Enable();
+ volumeSars5.Enable();
+ volumeSars6.Enable();
+ volumeSars7.Enable();
+ volumeSars8.Enable();
+ volumeSars9.Enable();
}
+ createLightingObject = Hook.Create<CreateLightingObject>(0x1424CE130, CreateLightingObjectHook);
// Player + ECCC = How far underwater is the player.
jmpOverHotSpringsEval = new Patch((nint)0x1417C1B03, [0xEB]);
@@ -1658,7 +1669,18 @@ namespace MHWNewCamera
Rx += MemoryUtil.GetRef<int>(sMhMouse.Instance + 0xFC) * mouseSensitivity;
Ry -= MemoryUtil.GetRef<int>(sMhMouse.Instance + 0x100) * mouseSensitivity;
ref int scrollY = ref MemoryUtil.GetRef<int>(sMhMouse.Instance + 0x17C);
- cameraFov = Math.Clamp(cameraFov - scrollY * cameraZoomSpeed, 1.0f, 179.0f);
+ if (orbitPlayer)
+ {
+ orbitDistance -= scrollY * cameraZoomSpeed * 2.0f;
+ if (orbitDistance < 0.01f)
+ {
+ orbitDistance = 0.01f;
+ }
+ }
+ else
+ {
+ cameraFov = Math.Clamp(cameraFov - scrollY * cameraZoomSpeed, 1.0f, 179.0f);
+ }
}
#endif
cameraYaw += Rx;
@@ -2795,30 +2817,11 @@ namespace MHWNewCamera
}
}
- /*
- private void SetLODLimitsHook(nint unknownPtr)
+ private nint CreateLightingObjectHook(nint unknownPtr)
{
- setLODLimitsHook!.Original(unknownPtr);
-
- if (disableMod)
- {
- return;
- }
-
-#if HOOK_ORDER_ASSERTS
- debugLog($"SetLODLimitsHook({unknownPtr:x}) @ {frameTick}");
-#endif
-
- if (characterCreatorRendering)
- {
- setCharacterCreatorParams.Invoke(psuedoCharacterCreatorObject);
- }
- else if (saveSelectRendering)
- {
- setSaveSelectParams.Invoke(psuedoCharacterCreatorObject);
- }
+ lightingObject = createLightingObject!.Original(unknownPtr);
+ return lightingObject;
}
- */
private void toggleFreezeGame()
{
@@ -3306,10 +3309,12 @@ namespace MHWNewCamera
{
zeroFrameSkip.Disable();
}
+ /*
if (disableVolumeDownsample)
{
zeroVolumetricDownsample.Disable();
}
+ */
if (disableCharacterFade)
{
noopCharacterFade.Disable();
@@ -3366,10 +3371,12 @@ namespace MHWNewCamera
{
zeroFrameSkip.Enable();
}
+ /*
if (disableVolumeDownsample)
{
zeroVolumetricDownsample.Enable();
}
+ */
if (pCameraViewportIndex >= 0)
{
setDisableFadingObjects(pCameraViewportIndex, disableFading);
@@ -4270,7 +4277,7 @@ namespace MHWNewCamera
}
if (ImGui.Button("Sit in Hot Springs"))
{
- // Function "process sit in hot springs action":
+ // Run sit in hot springs action (top of function):
// MonsterHunterWorld.exe+17601F0 - mov [rsp+08],rbx
MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]);
MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]);
@@ -4684,6 +4691,38 @@ namespace MHWNewCamera
ImGui.EndTooltip();
}
+ if (ImGui.Checkbox("Full Resolution Volume Rendering", ref disableVolumeDownsample))
+ {
+ if (disableVolumeDownsample)
+ {
+ volumeSars1.Enable();
+ volumeSars2.Enable();
+ volumeSars3.Enable();
+ volumeSars4.Enable();
+ volumeSars5.Enable();
+ volumeSars6.Enable();
+ volumeSars7.Enable();
+ volumeSars8.Enable();
+ volumeSars9.Enable();
+ }
+ else
+ {
+ volumeSars1.Disable();
+ volumeSars2.Disable();
+ volumeSars3.Disable();
+ volumeSars4.Disable();
+ volumeSars5.Disable();
+ volumeSars6.Disable();
+ volumeSars7.Disable();
+ volumeSars8.Disable();
+ volumeSars9.Disable();
+ }
+ Config.GraphicalTweaks graphics = config.Graphics;
+ graphics.DisableVolumetricDownsample = disableVolumeDownsample;
+ config.Graphics = graphics;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+
if (ImGui.Checkbox("Disable Player/Palico/NPC LOD Limit in Gameplay", ref disableLODLimits))
{
if (disableLODLimits)
@@ -4916,42 +4955,26 @@ namespace MHWNewCamera
ImGui.Text($"shadowBias: {lastShadowBias}");
ImGui.Text($"shadowRadius: {lastShadowRadius}");
- if (ImGui.Checkbox("Disable Volumetric Downsample and Blur", ref disableVolumeDownsample))
+ if (ImGui.Checkbox("Disable Volume Downsample and Blur", ref forceOffVolumeDownsampleAndBlur))
{
- if (disableVolumeDownsample)
+ if (forceOffVolumeDownsampleAndBlur)
{
- zeroVolumetricDownsample.Enable();
+ zeroVolumeDownsample.Enable();
}
else
{
- zeroVolumetricDownsample.Disable();
+ zeroVolumeDownsample.Disable();
}
- Config.GraphicalTweaks graphics = config.Graphics;
- graphics.DisableVolumetricDownsample = disableVolumeDownsample;
- config.Graphics = graphics;
- ConfigManager.SaveConfig<Config>(this);
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("Disabling blur is an undesirable compromise but skipping the downsample without skipping blur is a more involved change.\nThis will look broken with Volume Rendering Quality set to anything but Highest.");
- ImGui.EndTooltip();
}
- /* I haven't verified how correct this is, it doesn't look quite right and breaks lots of NPCs faces.
- ImGui.Checkbox("Character Creator Rendering Params", ref characterCreatorRendering);
- ImGui.Checkbox("Save Select Rendering Params", ref saveSelectRendering);
- if (ImGui.Checkbox("Character Creator Face Rendering", ref characterCreatorFace))
+ if (ImGui.CollapsingHeader("Lighting Object"))
{
- if (characterCreatorFace)
+ if (lightingObject != 0x0)
{
- defaultCharacterCreatorParam.Enable();
- }
- else
- {
- defaultCharacterCreatorParam.Disable();
+ drawRenderParameter<float>("Dispersion", lightingObject, 0x19C);
+ drawRenderParameter<float>("Edge Sharpness", lightingObject, 0x198);
}
}
- */
if (ImGui.CollapsingHeader("Renderer Parameters"))
{