From 43683023fa06414ffd356cf9b5f8df41d8e5bfe4 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 11 Jan 2026 19:22:40 -0500 Subject: Tons of WIP stuff for the people Signed-off-by: Andrew Opalach --- Config.cs | 4 + Plugin.cs | 1118 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 923 insertions(+), 199 deletions(-) diff --git a/Config.cs b/Config.cs index de29aa4..83635fa 100755 --- a/Config.cs +++ b/Config.cs @@ -117,12 +117,16 @@ namespace MHWNewCamera public float ShadowRadiusOffset { get; set; } = 0.0005f; public bool ApplyShadowRadius { get; set; } = false; public bool HigherShadowDetailInHoarfrost { get; set; } = false; + public bool SSAOAdjustments { get; set; } = false; public bool DisableLodLimits { get; set; } = false; public bool ApplyLodFactors { get; set; } = false; public float FoliageLodBias { get; set; } = 3.0f; public float TerrainLodBias { get; set; } = 6.0f; + public float SnowLodBias { get; set; } = 32.0f; public float FoliageLodFactor { get; set; } = 0.0f; public float TerrainLodFactor { get; set; } = 0.0f; public bool LargerFoliageSwayRange { get; set; } = false; + public bool DisableReducedRateAnimations { get; set; } = false; + public bool HQMode { get; set; } = false; } } diff --git a/Plugin.cs b/Plugin.cs index a32f3fa..d0946e4 100755 --- a/Plugin.cs +++ b/Plugin.cs @@ -5,6 +5,11 @@ using ImGuiNET; using System.Numerics; +using System.Globalization; +using System.Runtime.InteropServices; +#if ADDR_ASSERTS || HOOK_ORDER_ASSERTS +using System.Diagnostics; +#endif using SharpPluginLoader.Core; using SharpPluginLoader.Core.Entities; using SharpPluginLoader.Core.IO; @@ -13,12 +18,12 @@ using SharpPluginLoader.Core.Memory; using SharpPluginLoader.Core.Actions; using SharpPluginLoader.Core.Components; using SharpPluginLoader.Core.Configuration; -#if ADDR_ASSERTS || HOOK_ORDER_ASSERTS -using System.Diagnostics; -#endif // @TODO: -// - Find a way to enable crouching and crawling on command. +// - List out all binds and try to work out better mappings. +// - Attempt to reduce noise in binds table. +// - Overall cleanup +// - Make left stick input a curve like Wilds. // - Option to ignore camera change (update position, test open book and close). // - Simplify and document input handling/blocking logic. // - Find a way to block other inputs while button1 is down (and blocked). @@ -28,8 +33,6 @@ using System.Diagnostics; // - Some objects still fade. // - Glass objects in research base and on the botanical research center table. // - Decals on floor near Astera lift. -// - Snow LOD pop-in. -// - Stop animation rate lowering at distance. // - Manully set freecam viewport index. // - Option to override in-game viewmode. // - +right and +forward to move character. @@ -86,6 +89,42 @@ using System.Diagnostics; namespace MHWNewCamera { + public struct SSAOParameters { + public float ssaoDepthBias; // +0xB4B0 + public float ssaoSlopedDepthBias; // +0xB4B4 + public float ssaoMaxDepthBias; // +0xB4B8 + public float ssaoDispersion; // +0xB4BC + public float ssaoEffect; // +0xB430 + public float ssaoEffectGI; // +0xB434 + public float ssaoDepthDifference; // +0xB4C0 + public float ssaoSamplesPerPixel; // +0xB4C4 + public int ssaoMaxSampleNum; // +0xB4C8 + public int ssaoMaxSampleNumHQ; // +0xB4D0 + public float ssaoRadius; // +0xB4D4 + public float ssaoBias; // +0xB4D8 + public float ssaoIntensity; // +0xB4E0 + public bool ssaoUseHiZ; // +0xB4E5 + public float ssaoEdgeAttenRate; // +0xB4DC + }; + + public struct SSLRParameters { + public float sslrLoopCount; // +0xE628 + public float sslrLoopCountFactorForCBR; // +0xE62C + public float sslrEliminateDepth; // +0xE630 + public float sslrAccurateThreshold; // +0xE644 + public float sslrAccurateThresholdHQ; // +0xE64C + public float sslrDitherRadius; // +0xE634 + public float sslrImportanceBias; // +0xE638 + public float sslrMipScale; // +0xE63C + public float sslrMipBias; // +0xE640 + public float sslrDitherResolve; // +0xB43F + public float sslrEdgeAttenRate; // +0xB428 + public float sslrMip0CountThreshold; // +0xB438 + public float sslrDepthEliminateRate; // +0xB42C + public float sslrUseMipmap; // +0xE650 + public float sslrGBufferJitter; // +0xB440 + }; + public unsafe class Plugin : IPlugin { public string Name => "MHW New Camera"; @@ -158,7 +197,7 @@ namespace MHWNewCamera private uint lastPadDown = 0; private uint? prevPadDown = null; private bool unlockInputToggled = false; - private bool inputBlockedForToggle = false; + //private bool inputBlockedForToggle = false; private bool buttonWasDown(Button button) { return (lastPadDown & (uint)button) == (uint)button; @@ -172,11 +211,23 @@ namespace MHWNewCamera return (lastPadDown & (uint)button) != (uint)button && (prevPadDown & (uint)button) == (uint)button; } + private float alternateNearClip = 2.0f; + private bool skipDofHook = true; private bool forceOffDof = false; private bool? wasDofAllowed = null; private nint dofPointer = 0x0; + private bool HQMode = false; + + private bool ssaoOverrides = false; + private SSAOParameters internalSSAOParams; + private SSAOParameters overrideSSAOParams; + private float snowField4GlobalLODParam = 8.0f; // +0x5718 + //private float snowField4AllowTesselationHQ; // +0x5741 + //private float snowField4LODBiasHQ; // +0x5748 + private bool applyRendererOverrides = false; + private float plusRight = 0.0f; private float plusForward = 0.0f; @@ -192,17 +243,31 @@ namespace MHWNewCamera private delegate void SetCameraCutsceneDelegate(nint unknownPtr); private Hook? setCameraCutsceneHook; + /* + private delegate void CalculateViewDelegate(nint unknownPtr); + private Hook? calculateViewHook; + */ + + private delegate void ShadowCascadeDelegate(nint unknownPtr, nint unknownPtr2); + private Hook? shadowCascadeHook; + + private delegate void EvalDepthOfFieldDelegate(nint unknownPtr, nint unknownPtr2); + private Hook? evalDepthOfFieldHook; + + private delegate void RendererSetDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); + private Hook? rendererSetHook; + private delegate void WritePadInputDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); private Hook? writePadInputHook; private delegate float CheckMovementDelegate(int stickValue); private Hook? checkMovementHook; - private delegate void ShadowCascadeDelegate(nint unknownPtr, nint unknownPtr2); - private Hook? shadowCascadeHook; + private delegate void CollisionCheckDelegate(nint unknownPtr, nint unknownPtr2); + private Hook? collisionCheckHook; - private delegate void EvalDepthOfFieldDelegate(nint unknownPtr, nint unknownPtr2); - private Hook? evalDepthOfFieldHook; + private delegate void CameraEffectDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3, double unknownF); + private Hook? cameraEffectHook; private Patch swapMinimapFollowsCamera; @@ -222,15 +287,12 @@ namespace MHWNewCamera private Patch shadowRes3; private Patch shadowRes4_3x; - private float offsetBiasBy = 0.0f; - private float offsetRadiusBy = 0.0f; - //private float offsetSampleNumBy = 0.0f; + private float shadowBiasOffset = 0.0f; + private float shadowRadiusOffset = 0.0f; private bool applyShadowBias = false; private bool applyShadowRadius = false; - //private bool applyShadowSampleNum = false; private float lastShadowBias = -1.0f; private float lastShadowRadius = -1.0f; - private float lastShadowSampleNum = -1.0f; private nint lastShadowCascadeValue = -1; private void tripleShadowResEnable() @@ -261,6 +323,7 @@ namespace MHWNewCamera private float prevTerrainLodBias = 0.0f; private float foliageLodFactor; private float terrainLodFactor; + private bool applyLodFactors; private bool disableLodLimits = false; private Patch defaultViewModeLodLimit; @@ -284,6 +347,23 @@ namespace MHWNewCamera private bool largerFoliageSwayRange = false; private Patch addressHigherValueForFoliageSway; + private bool disableVolumeDownsample = false; + private Patch zeroVolumetricDownsample; + //private Patch zeroVolumetricDownsample2; + //private Patch zeroVolumetricDownsample3; + + private bool disableReducedRateAnimations = false; + private Patch zeroFrameSkip; + + private bool enableUnderWaterCamera = false; + private Patch underwaterCamera1; + private Patch underwaterCamera2; + private Patch underwaterCamera3; + private Patch underwaterCamera4; + private Patch underwaterCamera5; + private byte[] prevUnderwaterValues = new byte[120]; + private nint prevUnderwaterPointer = 0x0; + private bool disableCollision = false; private bool disableExtraCollision = false; private bool disableGravity = false; @@ -343,6 +423,12 @@ namespace MHWNewCamera disableGravityEval.Disable(); } + private bool allowHotSpringsAnywhere = false; + private Patch jmpOverHotSpringsEval; + + private bool disableHotSpringsSteam = false; + private Patch jmpOverHotSpringsSteam; + private static readonly MtObject sOtomo = SingletonManager.GetSingleton("sOtomo")!; // Gui strings. @@ -356,6 +442,15 @@ namespace MHWNewCamera private int frameTick = 0; #endif + private NativeAction setPassiveMode; + private NativeAction setPlayerController1; + private NativeAction setPlayerController2; + + private bool enableCrawl = false; + private NativeAction procEnvironmentCollision; + private nint psuedoObject1; + private nint psuedoObject2; + private void debugLog(string message) { #if LOG_DEBUG_MESSAGES @@ -404,13 +499,16 @@ namespace MHWNewCamera } tripleShadowRes = config.TripleShadowResolution; - offsetBiasBy = config.ShadowRangeOffset; - offsetRadiusBy = config.ShadowRadiusOffset; + shadowBiasOffset = config.ShadowRangeOffset; + shadowRadiusOffset = config.ShadowRadiusOffset; applyShadowBias = config.ApplyShadowRange; applyShadowRadius = config.ApplyShadowRadius; lowShadowDetailOverride = config.HigherShadowDetailInHoarfrost; + ssaoOverrides = config.SSAOAdjustments; + HQMode = config.HQMode; disableLodLimits = config.DisableLodLimits; largerFoliageSwayRange = config.LargerFoliageSwayRange; + disableReducedRateAnimations = config.DisableReducedRateAnimations; ConfigManager.SaveConfig(this); @@ -421,6 +519,16 @@ namespace MHWNewCamera { Config config = loadConfig(); + setPassiveMode = new NativeAction(0x142035020); + setPlayerController1 = new NativeAction(0x141F73850); + setPlayerController2 = new NativeAction(0x14118DDC0); + + procEnvironmentCollision = new NativeAction(0x141F737D0); + psuedoObject1 = (nint)NativeMemory.AllocZeroed(0x7C); + MemoryUtil.WriteBytes(psuedoObject1 + 0x30, [0x03]); + psuedoObject2 = (nint)NativeMemory.AllocZeroed(0x7C); + MemoryUtil.WriteBytes(psuedoObject2 + 0x30, [0x08]); + // Asserts based on version 15.23.00. // @TODO: Handle addr not found. @@ -451,18 +559,13 @@ namespace MHWNewCamera #endif setCameraCutsceneHook = Hook.Create(addr, SetCameraCutsceneHook); - addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 08 57 44 8B 9A 60 01 00 00 48 8B DA 41 0F BF 40 08 4D 8B D0 89 82 80 01 00 00 BF 00 10 00 00 41 0F BF 40 0A 89 82 84 01 00 00 41 0F BF 40 0C 89 82 78 01 00 00 41 0F BF 40 0E 89 82 7C 01 00 00")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x1422A1280); // nint, nint, nint -#endif - writePadInputHook = Hook.Create(addr, WritePadInputHook); - - // Place where we can change the analog stick value the game uses for player movement. - addr = PatternScanner.FindFirst(Pattern.FromString("66 0F 6E C1 0F 5B C0 85 C9 78 11")); + /* + addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 48 89 7C 24 20 41 54 41 56 41 57 48 81 EC 90 00 00 00 ?? ?? ?? ?? ?? ?? ?? 48 8B F9")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x142107CB0); // int + Trace.Assert(addr == 0x14228eb60); #endif - checkMovementHook = Hook.Create(addr, CheckMovementHook); + calculateViewHook = Hook.Create(addr, CalculateViewHook); + */ 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 @@ -476,6 +579,25 @@ namespace MHWNewCamera #endif evalDepthOfFieldHook = Hook.Create(addr, EvalDepthOfFieldHook); + rendererSetHook = Hook.Create(0x141ABDED0, RendererSetHook); // nint, nint, nint + + addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 08 57 44 8B 9A 60 01 00 00 48 8B DA 41 0F BF 40 08 4D 8B D0 89 82 80 01 00 00 BF 00 10 00 00 41 0F BF 40 0A 89 82 84 01 00 00 41 0F BF 40 0C 89 82 78 01 00 00 41 0F BF 40 0E 89 82 7C 01 00 00")); +#if ADDR_ASSERTS + Trace.Assert(addr == 0x1422A1280); // nint, nint, nint +#endif + writePadInputHook = Hook.Create(addr, WritePadInputHook); + + // Place where we can change the analog stick value the game uses for player movement. + addr = PatternScanner.FindFirst(Pattern.FromString("66 0F 6E C1 0F 5B C0 85 C9 78 11")); +#if ADDR_ASSERTS + Trace.Assert(addr == 0x142107CB0); // int +#endif + checkMovementHook = Hook.Create(addr, CheckMovementHook); + + collisionCheckHook = Hook.Create(0x1411C4E50, CollisionCheckHook); + + cameraEffectHook = Hook.Create(0x1416D4890, CameraEffectHook); + unchecked { addr = PatternScanner.FindFirst(Pattern.FromString("84 C0 0F 84 ?? ?? ?? ?? 48 8B 57 28 45 33 C0 48 8B CE E8 ?? ?? ?? ?? 48 8B 97 E0 01 00 00 41 B0 01 48 8B CE E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B D8")); @@ -587,6 +709,24 @@ namespace MHWNewCamera addressHigherValueForFoliageSway.Enable(); } + zeroFrameSkip = new Patch((nint)0x142246948, [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90]); + if (disableReducedRateAnimations && !disableMod) + { + zeroFrameSkip.Enable(); + } + + underwaterCamera1 = new Patch((nint)0x1412AD54D, [0x90, 0x90, 0x90, 0x90, 0x90, 0x90]); // Nop "Is diving" check. + underwaterCamera2 = new Patch((nint)0x1412AD571, [0xB1, 0x01, 0x28, 0xC1, 0x90, 0x90, 0x90]); // Make cl the inverse of al. + underwaterCamera3 = new Patch((nint)0x141FA5A7E, [0x90, 0x90]); // Nop check. + underwaterCamera4 = new Patch((nint)0x141FA5BA0, [0x40, 0x84, 0xF6, 0x90, 0x74]); // jae -> je. + 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]); + + 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]); + */ + // Noop collision checks. addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 06 F3 0F 10 48 04 F3 0F 58 4E 04 F3 0F 11 4E 04 F3 0F 10 40 08 F3 0F 58 46 08 F3 0F 11 46 08 44 8B AF E0 0B 00 00")); #if ADDR_ASSERTS @@ -632,6 +772,10 @@ namespace MHWNewCamera Trace.Assert(addr + 0x40 == 0x141BFFF75); #endif disableGravityEval = new Patch(addr + 0x40, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+1325810 + + jmpOverHotSpringsEval = new Patch((nint)0x1417C1B03, [0xEB]); + + jmpOverHotSpringsSteam = new Patch((nint)0x14203A494, [0xE9, 0x8D, 0x00, 0x00, 0x00, 0x90]); } } @@ -664,7 +808,7 @@ namespace MHWNewCamera private bool areLodFactorsDefault() { - return foliageLodBias == 3.0f && terrainLodBias == 3.0f && foliageLodFactor == 1.0f && terrainLodFactor == 1.0f; + return foliageLodBias == 3.0f && terrainLodBias == 3.0f && foliageLodFactor == 1.0f && terrainLodFactor == 1.0f && snowField4GlobalLODParam == 8.0f; } private bool areLodFactorsSet() @@ -674,8 +818,10 @@ namespace MHWNewCamera float terrainLod1 = MemoryUtil.Read(baseAddr + 0x220); float foliageLod2 = MemoryUtil.Read(baseAddr + 0x224); float terrainLod2 = MemoryUtil.Read(baseAddr + 0x228); + float snowLod1 = MemoryUtil.Read(baseAddr + 0x5718); return foliageLod1 == foliageLodBias && terrainLod1 == terrainLodBias && - foliageLod2 == foliageLodFactor && terrainLod2 == terrainLodFactor; + foliageLod2 == foliageLodFactor && terrainLod2 == terrainLodFactor && + snowLod1 == snowField4GlobalLODParam; } private void setLodFactors(bool toggleOn) @@ -683,18 +829,21 @@ namespace MHWNewCamera nint baseAddr = MemoryUtil.Read(0x1451C4368); if (toggleOn) { - if (prevFoliageLodBias <= 0.0f) { + if (prevFoliageLodBias <= 0.0f) + { prevFoliageLodBias = MemoryUtil.Read(baseAddr + 0x21C); if (prevFoliageLodBias > 3.0f) prevFoliageLodBias = 3.0f; } MemoryUtil.WriteBytes(baseAddr + 0x21C, BitConverter.GetBytes(foliageLodBias)); - if (prevTerrainLodBias <= 0.0f) { + if (prevTerrainLodBias <= 0.0f) + { prevTerrainLodBias = MemoryUtil.Read(baseAddr + 0x220); if (prevTerrainLodBias > 3.0f) prevTerrainLodBias = 3.0f; } MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(terrainLodBias)); MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(foliageLodFactor)); MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(terrainLodFactor)); + MemoryUtil.WriteBytes(baseAddr + 0x5718, BitConverter.GetBytes(snowField4GlobalLODParam)); } else { @@ -702,6 +851,7 @@ namespace MHWNewCamera MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(prevTerrainLodBias)); MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(1.0f)); MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(1.0f)); + MemoryUtil.WriteBytes(baseAddr + 0x5718, BitConverter.GetBytes(8.0f)); } } @@ -712,7 +862,9 @@ namespace MHWNewCamera terrainLodBias = config.TerrainLodBias; foliageLodFactor = config.FoliageLodFactor; terrainLodFactor = config.TerrainLodFactor; - if (config.ApplyLodFactors) + snowField4GlobalLODParam = config.SnowLodBias; + applyLodFactors = config.ApplyLodFactors; + if (applyLodFactors) { setLodFactors(true); } @@ -769,6 +921,16 @@ namespace MHWNewCamera return q * Quaternion.CreateFromYawPitchRoll((float)Math.PI, 0.0f, 0.0f); } + private static Quaternion getHalfLeft(Quaternion q) + { + return q * Quaternion.CreateFromYawPitchRoll((float)(Math.PI+(Math.PI*0.75f)), 0.0f, 0.0f); + } + + private static Quaternion getReverse(Quaternion q) + { + return q * Quaternion.CreateFromYawPitchRoll((float)Math.PI, 0.0f, 0.0f); + } + private void setCameraRoll(Camera camera) { // Don't test our luck with precision weirdness if we know we can be exact. @@ -925,19 +1087,19 @@ namespace MHWNewCamera } } - if (!unlockInputToggled) + if (!unlockInputToggled && !comboButton1Down) { if (buttonWasDown(Button.Share)) { if (buttonWasPressed(Button.Square)) { - if (camera.NearClip == 0.5f) + if (camera.NearClip != DEFAULT_NEAR_CLIP) { camera.NearClip = DEFAULT_NEAR_CLIP; } else { - camera.NearClip = 0.5f; + camera.NearClip = alternateNearClip; } } } @@ -1187,7 +1349,7 @@ namespace MHWNewCamera if (pCamera != null) { previousCameraAnimState = MemoryUtil.Read(pCamera.Instance + 0x240); - if (previousCameraAnimState == 5) + if (previousCameraAnimState == 5 || previousCameraAnimState == 8) { // 1:314 = Wingdrake landing on area enter. // 1:319 = Disoriented wingdrake landing next to monster. @@ -1292,7 +1454,7 @@ namespace MHWNewCamera applyPerspective = offsetPerspective && !freeCamera && pCamera != null; if (applyPerspective) { - applyPerspective &= (previousCameraAnimState != 5 || ignoreAnimState); + applyPerspective &= ((previousCameraAnimState != 5 && previousCameraAnimState != 8) || ignoreAnimState); applyPerspective &= !assumeInQuestBoard(previousFov); } @@ -1396,6 +1558,179 @@ namespace MHWNewCamera } } + /* + private void CalculateViewHook(nint unknownPtr) + { + calculateViewHook!.Original(unknownPtr); + if (vCameraViewportIndex >= 0 && cameraRoll != 0.0f) + { + Viewport vp = CameraSystem.GetViewport(vCameraViewportIndex); + vp.ViewMatrix *= Matrix4x4.CreateRotationZ((float)Double.DegreesToRadians(cameraRoll)); + } + } + */ + + private void ShadowCascadeHook(nint unknownPtr, nint unknownPtr2) + { + if (disableMod) + { + shadowCascadeHook!.Original(unknownPtr, unknownPtr2); + return; + } +#if HOOK_ORDER_ASSERTS + debugLog($"ShadowCascadeHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); +#endif + nint rax = MemoryUtil.Read(unknownPtr2 + 0x170); + nint shadowCascadeValue = rax >> 32; + // After this function the value is written to the render params then maxss'd with the HQ value before use. + float biasOverride = MemoryUtil.Read(unknownPtr2 + 0x17C); + lastShadowBias = biasOverride; + biasOverride += shadowBiasOffset; + if (lowShadowDetailOverride) + { + if (shadowCascadeValue == 1) + { + biasOverride *= 2.0f; + MemoryUtil.WriteBytes(unknownPtr2 + 0x170, BitConverter.GetBytes((shadowCascadeValue + 1) << 32 | (rax & 0x00000000FFFFFFFF))); + } + } + if (shadowCascadeValue != 3) + { + lastShadowCascadeValue = shadowCascadeValue; + lastShadowBias = MemoryUtil.Read(unknownPtr2 + 0x17C); + if (applyShadowBias) + { + MemoryUtil.WriteBytes(unknownPtr2 + 0x17C, BitConverter.GetBytes(biasOverride)); + } + lastShadowRadius = MemoryUtil.Read(unknownPtr2 + 0x1EC); + if (applyShadowRadius) + { + MemoryUtil.WriteBytes(unknownPtr2 + 0x1EC, BitConverter.GetBytes(lastShadowRadius + shadowRadiusOffset)); + } + } + shadowCascadeHook!.Original(unknownPtr, unknownPtr2); + } + + private void EvalDepthOfFieldHook(nint unknownPtr, nint unknownPtr2) + { + if (disableMod || (skipDofHook = !skipDofHook)) + { + evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2); + return; + } +#if HOOK_ORDER_ASSERTS + debugLog($"EvalDepthOfFieldHook({unknownPtr}, {unknownPtr2}) @ {frameTick}"); +#endif + // Possibly of interest: +0x1DE, +0x1DF. + // We're assuming the previous dofPointer will still be valid, but that might not be true. + if (dofPointer != 0x0 && unknownPtr != dofPointer && wasDofAllowed != null) + { + MemoryUtil.WriteBytes(dofPointer + 0x1DD, ((bool)wasDofAllowed) ? [0x1] : [0x0]); + wasDofAllowed = null; + } + dofPointer = unknownPtr; + if (!forceOffDof) + { + if (wasDofAllowed != null) + { + MemoryUtil.WriteBytes(dofPointer + 0x1DD, ((bool)wasDofAllowed) ? [0x1] : [0x0]); + wasDofAllowed = null; + } + } + else + { + if (wasDofAllowed == null) + { + wasDofAllowed = MemoryUtil.Read(dofPointer + 0x1DD) == 0x1; + } + MemoryUtil.WriteBytes(dofPointer + 0x1DD, [0x0]); + } + evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2); + } + + private void writeSSAOParams(nint baseAddr, SSAOParameters ssaoParams) + { + MemoryUtil.WriteBytes(baseAddr + 0xB4B0, BitConverter.GetBytes(ssaoParams.ssaoDepthBias)); + MemoryUtil.WriteBytes(baseAddr + 0xB4B4, BitConverter.GetBytes(ssaoParams.ssaoSlopedDepthBias)); + MemoryUtil.WriteBytes(baseAddr + 0xB4B8, BitConverter.GetBytes(ssaoParams.ssaoMaxDepthBias)); + MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(ssaoParams.ssaoDispersion)); + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(ssaoParams.ssaoEffect)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(ssaoParams.ssaoEffectGI)); + MemoryUtil.WriteBytes(baseAddr + 0xB4C0, BitConverter.GetBytes(ssaoParams.ssaoDepthDifference)); + MemoryUtil.WriteBytes(baseAddr + 0xB4C4, BitConverter.GetBytes(ssaoParams.ssaoSamplesPerPixel)); + MemoryUtil.WriteBytes(baseAddr + 0xB4C8, BitConverter.GetBytes(ssaoParams.ssaoMaxSampleNum)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(ssaoParams.ssaoMaxSampleNumHQ)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D4, BitConverter.GetBytes(ssaoParams.ssaoRadius)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D8, BitConverter.GetBytes(ssaoParams.ssaoBias)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(ssaoParams.ssaoIntensity)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E5, ssaoParams.ssaoUseHiZ ? [0x1] : [0x0]); + MemoryUtil.WriteBytes(baseAddr + 0xB4DC, BitConverter.GetBytes(ssaoParams.ssaoEdgeAttenRate)); + } + + private void setSSAOAdjustements(bool enable) + { + nint baseAddr = MemoryUtil.Read(0x1451C4368); + if (enable) + { + MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(1.75f)); + // SSAO Effect > 1.0 will never look right with these values. + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(1.0f)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(0.5f)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(24)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D8, BitConverter.GetBytes(0.001f)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(110.0f)); + } + else + { + MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(internalSSAOParams.ssaoDispersion)); + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(internalSSAOParams.ssaoEffect)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(internalSSAOParams.ssaoEffectGI)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(internalSSAOParams.ssaoMaxSampleNumHQ)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D8, BitConverter.GetBytes(internalSSAOParams.ssaoBias)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.ssaoIntensity)); + } + } + + private void setHQMode(bool enable) + { + nint baseAddr = MemoryUtil.Read(0x1451C4368); + MemoryUtil.WriteBytes(baseAddr + 0xE9A3, HQMode ? [0x1] : [0x0]); + } + + private void RendererSetHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3) + { + bool doSet = MemoryUtil.Read(unknownPtr + 0x530) == 0x0; + rendererSetHook!.Original(unknownPtr, unknownPtr2, unknownPtr3); + if (doSet) + { + nint baseAddr = MemoryUtil.Read(0x1451C4368); + internalSSAOParams.ssaoDepthBias = MemoryUtil.Read(baseAddr + 0xB4B0); + internalSSAOParams.ssaoSlopedDepthBias = MemoryUtil.Read(baseAddr + 0xB4B4); + internalSSAOParams.ssaoMaxDepthBias = MemoryUtil.Read(baseAddr + 0xB4B8); + internalSSAOParams.ssaoDispersion = MemoryUtil.Read(baseAddr + 0xB4BC); + internalSSAOParams.ssaoEffect = MemoryUtil.Read(baseAddr + 0xB430); + internalSSAOParams.ssaoEffectGI = MemoryUtil.Read(baseAddr + 0xB434); + internalSSAOParams.ssaoDepthDifference = MemoryUtil.Read(baseAddr + 0xB4C0); + internalSSAOParams.ssaoSamplesPerPixel = MemoryUtil.Read(baseAddr + 0xB4C4); + internalSSAOParams.ssaoMaxSampleNum = MemoryUtil.Read(baseAddr + 0xB4C8); + internalSSAOParams.ssaoMaxSampleNumHQ = MemoryUtil.Read(baseAddr + 0xB4D0); + internalSSAOParams.ssaoRadius = MemoryUtil.Read(baseAddr + 0xB4D4); + internalSSAOParams.ssaoBias = MemoryUtil.Read(baseAddr + 0xB4D8); + internalSSAOParams.ssaoIntensity = MemoryUtil.Read(baseAddr + 0xB4E0); + internalSSAOParams.ssaoUseHiZ = MemoryUtil.Read(baseAddr + 0xB4E5) == 1; + internalSSAOParams.ssaoEdgeAttenRate = MemoryUtil.Read(baseAddr + 0xB4DC); + if (ssaoOverrides) + { + setSSAOAdjustements(true); + } + setHQMode(HQMode); + if (applyLodFactors) + { + setLodFactors(true); + } + } + } + private void setPerspectivePreset(Config.Preset preset) { cameraFov = preset.FOV; @@ -1468,8 +1803,21 @@ namespace MHWNewCamera lastPadDown = PadDown; readInputsPostHook = true; } + // https://github.com/HunterPie/HunterPie/blob/fa73f81ed0cdc921a6cf63f96c0fcff3688d88c2/HunterPie.Integrations/Datasources/MonsterHunterWorld/Entity/Game/MHWGame.cs#L74 + bool playerInMenu = false; + /* + nint inMenuOffset = MemoryUtil.Read(0x1451C4640); + if (inMenuOffset != 0) + { + inMenuOffset = MemoryUtil.Read(inMenuOffset + 0x13FD0); + if (inMenuOffset != 0) + { + playerInMenu = MemoryUtil.Read(inMenuOffset + 0xB734) == 1; + } + } + */ uint b1u = (uint)b1; - if (comboButton1Down || enableFreeCamera || !buttonWasDown(b2)) + if (!playerInMenu && (comboButton1Down || enableFreeCamera || !buttonWasDown(b2))) { if ((PadDown & b1u) == b1u) { @@ -1480,16 +1828,19 @@ namespace MHWNewCamera } if (comboButton1Down) { - if (((PadRel & b1u) == b1u)) + if (((PadRel & b1u) == b1u) || playerInMenu) { comboButton1Down = false; } - PadTrg &= ~b1u; - PadRel &= ~b1u; - PadChg &= ~b1u; - MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadTrg)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1A4, BitConverter.GetBytes(PadRel)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1A8, BitConverter.GetBytes(PadChg)); + if (!playerInMenu) + { + PadTrg &= ~b1u; + PadRel &= ~b1u; + PadChg &= ~b1u; + MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadTrg)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1A4, BitConverter.GetBytes(PadRel)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1A8, BitConverter.GetBytes(PadChg)); + } } } } @@ -1507,6 +1858,22 @@ namespace MHWNewCamera { enableFreeCamera = !enableFreeCamera; } + if (buttonWasPressed(Button.L1)) + { + if (uiToggled) + { + jmpOverUi.Disable(); + } + else + { + jmpOverUi.Enable(); + } + uiToggled = !uiToggled; + } + if (buttonWasPressed(Button.R1)) + { + unlockInputToggled = !unlockInputToggled; + } int presetSelect = (buttonWasPressed(Button.Up) ? -1 : 0) + (buttonWasPressed(Button.Down) ? 1 : 0); if (presetSelect != 0) { @@ -1549,10 +1916,11 @@ namespace MHWNewCamera unlockMovementPause = false; } + bool blockInput = comboButton1Down || (enableFreeCamera && !unlockInputToggled); + + /* if (enableFreeCamera) { - bool blockInput = !unlockInputToggled; - // Hold both buttons and release either. We have to block until // release or it will get annoying to toggle input while on a menu. if (buttonWasDown(Button.R2)) @@ -1575,40 +1943,44 @@ namespace MHWNewCamera inputBlockedForToggle = false; blockInput = true; } + } + */ - if (blockInput) + if (blockInput) + { + if (!readInputsPostHook) { - if (!readInputsPostHook) - { - PadTrg = MemoryUtil.Read(controllerAddr() + 0x1A0); - PadRel = MemoryUtil.Read(controllerAddr() + 0x1A4); - PadChg = MemoryUtil.Read(controllerAddr() + 0x1A8); - readInputsPostHook = true; - } - uint FaceButtonMask = (uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle; - uint DPadMask = (uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right; - uint StartSelectMask = (uint)Button.Options | (uint)Button.Share; - uint BumperMask = (uint)Button.L1 | (uint)Button.R1; - uint StickMask = (uint)Button.LsUp | (uint)Button.LsDown | (uint)Button.LsLeft | (uint)Button.LsRight | - (uint)Button.RsUp | (uint)Button.RsDown | (uint)Button.RsLeft | (uint)Button.RsRight; - uint Mask = FaceButtonMask | DPadMask | StartSelectMask | BumperMask | StickMask; - if (enableCombo && freeCameraCombo != null) - { - Mask &= ~((uint)b1 | (uint)b2); - } - PadDown &= ~Mask; - PadTrg &= ~Mask; - PadRel &= ~Mask; - PadChg &= ~Mask; - MemoryUtil.WriteBytes(controllerAddr() + 0x198, BitConverter.GetBytes(PadDown)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadTrg)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadRel)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1A8, BitConverter.GetBytes(PadChg)); - // Left and right trigger. - MemoryUtil.WriteBytes(controllerAddr() + 0x1C0, BitConverter.GetBytes(0)); - MemoryUtil.WriteBytes(controllerAddr() + 0x1C1, BitConverter.GetBytes(0)); + PadTrg = MemoryUtil.Read(controllerAddr() + 0x1A0); + PadRel = MemoryUtil.Read(controllerAddr() + 0x1A4); + PadChg = MemoryUtil.Read(controllerAddr() + 0x1A8); + readInputsPostHook = true; } + uint FaceButtonMask = (uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle; + uint DPadMask = (uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right; + uint StartSelectMask = (uint)Button.Options | (uint)Button.Share; + uint BumperMask = (uint)Button.L1 | (uint)Button.R1; + uint StickMask = (uint)Button.LsUp | (uint)Button.LsDown | (uint)Button.LsLeft | (uint)Button.LsRight | + (uint)Button.RsUp | (uint)Button.RsDown | (uint)Button.RsLeft | (uint)Button.RsRight; + uint Mask = FaceButtonMask | DPadMask | StartSelectMask | BumperMask | StickMask; + if (enableCombo && freeCameraCombo != null) + { + Mask &= ~((uint)b1 | (uint)b2); + } + PadDown &= ~Mask; + PadTrg &= ~Mask; + PadRel &= ~Mask; + PadChg &= ~Mask; + MemoryUtil.WriteBytes(controllerAddr() + 0x198, BitConverter.GetBytes(PadDown)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadTrg)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadRel)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1A8, BitConverter.GetBytes(PadChg)); + // Left and right trigger. + MemoryUtil.WriteBytes(controllerAddr() + 0x1C0, BitConverter.GetBytes(0)); + MemoryUtil.WriteBytes(controllerAddr() + 0x1C1, BitConverter.GetBytes(0)); + } + if (enableFreeCamera) + { if (!unlockMovementHeld && buttonWasPressed(Button.R2)) { unlockMovementHeld = true; @@ -1651,6 +2023,7 @@ namespace MHWNewCamera } if (buttonWasDown(Button.Share)) { + /* if (buttonWasPressed(Button.Cross)) { if (uiToggled) @@ -1663,6 +2036,7 @@ namespace MHWNewCamera } uiToggled = !uiToggled; } + */ if (buttonWasPressed(Button.Circle)) { @@ -1689,92 +2063,57 @@ namespace MHWNewCamera return checkMovementHook!.Original(stickValue); } - private void ShadowCascadeHook(nint unknownPtr, nint unknownPtr2) + private void CollisionCheckHook(nint unknownPtr, nint unknownPtr2) { - if (disableMod) + Player? player = Player.MainPlayer; + if (enableCrawl && player != null) { - shadowCascadeHook!.Original(unknownPtr, unknownPtr2); - return; + procEnvironmentCollision.Invoke(player.Instance, psuedoObject1); + procEnvironmentCollision.Invoke(player.Instance, psuedoObject2); } -#if HOOK_ORDER_ASSERTS - debugLog($"ShadowCascadeHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); -#endif - nint rax = MemoryUtil.Read(unknownPtr2 + 0x170); - nint shadowCascadeValue = rax >> 32; - float biasOverride = MemoryUtil.Read(unknownPtr2 + 0x17C); - lastShadowBias = biasOverride; - biasOverride += offsetBiasBy; - if (lowShadowDetailOverride) + collisionCheckHook!.Original(unknownPtr, unknownPtr2); + } + + private void CameraEffectHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3, double unknownF) + { + nint baseAddr = MemoryUtil.Read(0x14500E180); + byte[] curUnderwaterValues = MemoryUtil.ReadArray(unknownPtr2 + 0x8, 120); + bool underwater = MemoryUtil.Read(baseAddr + 0x9F8) == 0x1; + // Pretty unsafe seeming. + if (prevUnderwaterPointer != 0x0 && unknownPtr2 != prevUnderwaterPointer) { - if (shadowCascadeValue == 1) - { - biasOverride *= 2.0f; - MemoryUtil.WriteBytes(unknownPtr2 + 0x170, BitConverter.GetBytes((shadowCascadeValue + 1) << 32 | (rax & 0x00000000FFFFFFFF))); - } + MemoryUtil.WriteBytes(prevUnderwaterPointer + 0x8, prevUnderwaterValues); + prevUnderwaterPointer = 0x0; } - if (shadowCascadeValue != 3) + if (underwater) { - lastShadowCascadeValue = shadowCascadeValue; - lastShadowBias = MemoryUtil.Read(unknownPtr2 + 0x17C); - if (applyShadowBias) - { - MemoryUtil.WriteBytes(unknownPtr2 + 0x17C, BitConverter.GetBytes(biasOverride)); - } - lastShadowRadius = MemoryUtil.Read(unknownPtr2 + 0x1EC); - if (applyShadowRadius) + if (prevUnderwaterPointer == 0x0) { - MemoryUtil.WriteBytes(unknownPtr2 + 0x1EC, BitConverter.GetBytes(lastShadowRadius + offsetRadiusBy)); + prevUnderwaterValues = curUnderwaterValues; + prevUnderwaterPointer = unknownPtr2; } - lastShadowSampleNum = MemoryUtil.Read(unknownPtr2 + 0x1E4); + // Straight copy from The Great Forest. + MemoryUtil.WriteBytes(unknownPtr2 + 0x8, [0x01, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6F, 0x12, 0x03, 0x3B, 0x01, 0x00, 0x00, 0x00, 0xCE, 0xCC, 0xCC, 0x3E, 0x01, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x80, 0x3F, 0x8F, 0xC2, 0xF5, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7A, 0x44, 0x01, 0x00, 0x00, 0x00, 0x00, 0x60, 0xEA, 0x46, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8, 0x42]); /* - if (applyShadowSampleNum) - { - MemoryUtil.WriteBytes(unknownPtr2 + 0x1E4, BitConverter.GetBytes(lastShadowSampleNum + offsetSampleNumBy)); - } + MemoryUtil.WriteBytes(unknownPtr2 + 0x8, [0x01, 0x01]); + MemoryUtil.WriteBytes(unknownPtr2 + 0x38, [0x01, 0x00, 0x00, 0x00]); + MemoryUtil.WriteBytes(unknownPtr2 + 0x3C, [0xCE, 0xCC, 0xCC, 0x3E]); // 0.40 with extra bit set. + MemoryUtil.WriteBytes(unknownPtr2 + 0x40, [0x01, 0x00, 0x80, 0x3F]); + MemoryUtil.WriteBytes(unknownPtr2 + 0x48, [0x01, 0x00, 0x80, 0x3F]); + MemoryUtil.WriteBytes(unknownPtr2 + 0x4C, BitConverter.GetBytes(0.03f)); */ } - shadowCascadeHook!.Original(unknownPtr, unknownPtr2); + else if (prevUnderwaterPointer != 0x0) + { + MemoryUtil.WriteBytes(prevUnderwaterPointer + 0x8, prevUnderwaterValues); + prevUnderwaterPointer = 0x0; + } + cameraEffectHook!.Original(unknownPtr, unknownPtr2, unknownPtr3, unknownF); } - private void EvalDepthOfFieldHook(nint unknownPtr, nint unknownPtr2) + private void disableAllCollisionHooks() { - if (disableMod || (skipDofHook = !skipDofHook)) - { - evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2); - return; - } -#if HOOK_ORDER_ASSERTS - debugLog($"EvalDepthOfFieldHook({unknownPtr}, {unknownPtr2}) @ {frameTick}"); -#endif - // Possibly of interest: +0x1DE, +0x1DF. - // We're assuming the previous dofPointer will still be valid, but that might not be true. - if (dofPointer != 0x0 && unknownPtr != dofPointer && wasDofAllowed != null) { - MemoryUtil.WriteBytes(dofPointer + 0x1DD, ((bool)wasDofAllowed) ? [0x1] : [0x0]); - wasDofAllowed = null; - } - dofPointer = unknownPtr; - if (!forceOffDof) - { - if (wasDofAllowed != null) - { - MemoryUtil.WriteBytes(dofPointer + 0x1DD, ((bool)wasDofAllowed) ? [0x1] : [0x0]); - wasDofAllowed = null; - } - } - else - { - if (wasDofAllowed == null) - { - wasDofAllowed = MemoryUtil.Read(dofPointer + 0x1DD) == 0x1; - } - MemoryUtil.WriteBytes(dofPointer + 0x1DD, [0x0]); - } - evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2); - } - - private void disableAllCollisionHooks() - { - if (disableExtraGravity) + if (disableExtraGravity) { disableExtraGravity = false; disableExtraGravityDisable(); @@ -1845,6 +2184,7 @@ namespace MHWNewCamera } if (debug) ImGui.InputFloat("Aspect Ratio", ref camera.AspectRatio); ImGui.InputFloat("Near Clip", ref camera.NearClip); + ImGui.InputFloat("Alternate Near Clip", ref alternateNearClip); ImGui.InputFloat("Far Clip", ref camera.FarClip); if (usedByFreeCamera) { @@ -2071,7 +2411,7 @@ namespace MHWNewCamera } else { - if (config.ApplyLodFactors && !areLodFactorsDefault()) + if (applyLodFactors && !areLodFactorsDefault()) { setLodFactors(true); } @@ -2323,11 +2663,27 @@ namespace MHWNewCamera ImGui.PushID("Toggles"); ImGui.Text("Toggles"); + if (ImGui.Checkbox("Disable UI", ref uiToggled)) + { + if (uiToggled) + { + jmpOverUi.Enable(); + } + else + { + jmpOverUi.Disable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Hold Select + Press A. The scoutfly marker on menus will still be visible."); + ImGui.EndTooltip(); + } if (!freeCamera) { ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); } - ImGui.Checkbox("Unlock Input to the Game", ref unlockInputToggled); + ImGui.Checkbox("Unlock Input", ref unlockInputToggled); if (ImGui.BeginItemTooltip()) { ImGui.Text("Hold RT + RB, Release Either."); @@ -2349,23 +2705,7 @@ namespace MHWNewCamera { ImGui.PopStyleVar(); } - if (ImGui.Checkbox("Disable UI", ref uiToggled)) - { - if (uiToggled) - { - jmpOverUi.Enable(); - } - else - { - jmpOverUi.Disable(); - } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Hold Select + Press A. The scoutfly marker on menus will still be visible."); - ImGui.EndTooltip(); - } - ImGui.Checkbox("Force Depth of Field Off", ref forceOffDof); + ImGui.Checkbox("Disable Depth of Field", ref forceOffDof); if (ImGui.BeginItemTooltip()) { ImGui.Text("Hold Select + Press B. Works to disable depth of field in cutscenes. Credit to Otis_Inf."); @@ -2373,12 +2713,12 @@ namespace MHWNewCamera } if (vCamera != null) { - bool reducedNearClip = vCamera.NearClip == 0.5f; + bool reducedNearClip = vCamera.NearClip != DEFAULT_NEAR_CLIP; if (ImGui.Checkbox("Reduce Near Clip", ref reducedNearClip)) { if (reducedNearClip) { - vCamera.NearClip = 0.5f; + vCamera.NearClip = alternateNearClip; } else { @@ -2501,7 +2841,7 @@ namespace MHWNewCamera ImGui.EndTooltip(); } ImGui.TableSetColumnIndex(1); - ImGui.Text("Toggle Unlock Input to the Game"); + ImGui.Text("Toggle Unlock Input"); if (ImGui.BeginItemTooltip()) { ImGui.Text("Applies to every controller input except left stick player movement."); @@ -2662,6 +3002,62 @@ namespace MHWNewCamera ImGui.PushID("Player"); if (ImGui.CollapsingHeader("Player") && player != null) { + nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); + nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); + if (controlsAddr != 0x0 || zoneStateAddr == 0x0) + { + bool passiveFlag = MemoryUtil.Read(zoneStateAddr + 0xD2EA) == 1; + if (ImGui.Checkbox("Passive", ref passiveFlag)) + { + MemoryUtil.WriteBytes(zoneStateAddr + 0xD2EA, passiveFlag ? [0x1] : [0x0]); + setPassiveMode.Invoke(player.Instance, 0x00010780); + /* + MemoryUtil.WriteBytes(player.Instance + 0x7626, passiveMode ? [0x1] : [0x0]); + setPlayerController1.Invoke(player.Instance); + setPlayerController2.Invoke(controlsAddr); + */ + } + bool passiveMode = MemoryUtil.Read(player.Instance + 0x7626) == 1; + if (ImGui.Checkbox("Passive Mode", ref passiveMode)) + { + MemoryUtil.WriteBytes(player.Instance + 0x7626, passiveMode ? [0x1] : [0x0]); + } + bool combatControls = MemoryUtil.Read(controlsAddr + 0xb18) == 0x80; + if (ImGui.Checkbox("Combat Controls", ref combatControls)) + { + MemoryUtil.WriteBytes(player.Instance + 0x7626, combatControls ? [0x0] : [0x1]); + setPlayerController1.Invoke(player.Instance); + setPlayerController2.Invoke(controlsAddr); + MemoryUtil.WriteBytes(player.Instance + 0x7626, passiveMode ? [0x1] : [0x0]); + } + } + if (ImGui.Checkbox("Force Crawl", ref enableCrawl)) + { + if (enableCrawl) + { + MemoryUtil.WriteBytes(psuedoObject2 + 0x70, BitConverter.GetBytes(player.Position.X + player.Forward.X)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x74, BitConverter.GetBytes(player.Position.Y + player.Forward.Y)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x78, BitConverter.GetBytes(player.Position.Z + player.Forward.Z)); + + Quaternion playerRotation = new Quaternion(player.Forward.X, player.Forward.Y, player.Forward.Z, 0.0f); + Quaternion objectRotation = getReverse(playerRotation); + + MemoryUtil.WriteBytes(psuedoObject2 + 0x40, BitConverter.GetBytes(objectRotation.X)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x44, BitConverter.GetBytes(objectRotation.Y)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x48, BitConverter.GetBytes(objectRotation.Z)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x4C, BitConverter.GetBytes(objectRotation.W)); + + MemoryUtil.WriteBytes(psuedoObject2 + 0x50, BitConverter.GetBytes(0.0f)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x54, BitConverter.GetBytes(1.0f)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x58, BitConverter.GetBytes(0.0f)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x5C, BitConverter.GetBytes(0.0f)); + + MemoryUtil.WriteBytes(psuedoObject2 + 0x60, BitConverter.GetBytes(playerRotation.X)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x64, BitConverter.GetBytes(playerRotation.Y)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x68, BitConverter.GetBytes(playerRotation.Z)); + MemoryUtil.WriteBytes(psuedoObject2 + 0x6C, BitConverter.GetBytes(playerRotation.W)); + } + } ImGui.DragFloat3("Position", ref player.Position, 0.5f); Vector3 forward; forward.X = player.Forward.X; @@ -2804,6 +3200,36 @@ namespace MHWNewCamera ImGui.PopItemFlag(); ImGui.PopStyleVar(); } + + if (ImGui.Button("Sit in Hot Springs")) + { + MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]); + MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]); + } + + if (ImGui.Checkbox("Allow Hot Springs Anywhere", ref allowHotSpringsAnywhere)) + { + if (allowHotSpringsAnywhere) + { + jmpOverHotSpringsEval.Enable(); + } + else + { + jmpOverHotSpringsEval.Disable(); + } + } + + if (ImGui.Checkbox("Disable Hot Springs Steam", ref disableHotSpringsSteam)) + { + if (disableHotSpringsSteam) + { + jmpOverHotSpringsSteam.Enable(); + } + else + { + jmpOverHotSpringsSteam.Disable(); + } + } } ImGui.PopID(); @@ -2843,9 +3269,9 @@ namespace MHWNewCamera ConfigManager.SaveConfig(this); } ImGui.SameLine(); - if (ImGui.InputFloat("Shadow Range", ref offsetBiasBy, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) + if (ImGui.InputFloat("Shadow Range", ref shadowBiasOffset, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) { - config.ShadowRangeOffset = offsetBiasBy; + config.ShadowRangeOffset = shadowBiasOffset; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -2859,9 +3285,9 @@ namespace MHWNewCamera ConfigManager.SaveConfig(this); } ImGui.SameLine(); - if (ImGui.InputFloat("Shadow Radius", ref offsetRadiusBy, 0.0f, 0.0f, "%.5f", ImGuiInputTextFlags.EnterReturnsTrue)) + if (ImGui.InputFloat("Shadow Radius", ref shadowRadiusOffset, 0.0f, 0.0f, "%.5f", ImGuiInputTextFlags.EnterReturnsTrue)) { - config.ShadowRadiusOffset = offsetRadiusBy; + config.ShadowRadiusOffset = shadowRadiusOffset; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -2869,11 +3295,6 @@ namespace MHWNewCamera ImGui.Text("Amount of softening for realtime shadows.\nValue is an offset. Recommended: 0.0005."); ImGui.EndTooltip(); } - /* - ImGui.Checkbox("##Apply SampleNum", ref applyShadowSampleNum); - ImGui.SameLine(); - ImGui.InputFloat("Offset Shadow SampleNum", ref offsetSampleNumBy, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue); - */ ImGui.PopItemWidth(); if (ImGui.Checkbox("Higher Shadow Detail in Hoarfrost Reach/Seliana Gathering Hub", ref lowShadowDetailOverride)) @@ -2887,6 +3308,20 @@ namespace MHWNewCamera ImGui.EndTooltip(); } + if (ImGui.Checkbox("SSAO Adjustments", ref ssaoOverrides)) + { + setSSAOAdjustements(ssaoOverrides); + config.SSAOAdjustments = ssaoOverrides; + ConfigManager.SaveConfig(this); + } + + if (ImGui.Checkbox("HQ Mode", ref HQMode)) + { + setHQMode(HQMode); + config.HQMode = HQMode; + ConfigManager.SaveConfig(this); + } + if (ImGui.Checkbox("Disable Player/Palico/NPC LOD Limit in Gameplay", ref disableLodLimits)) { if (disableLodLimits) @@ -2933,6 +3368,7 @@ namespace MHWNewCamera ImGui.Text("Controls the distance at which the game decides to no longer render some objects.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0."); ImGui.EndTooltip(); } + ImGui.InputFloat("Snow LOD Param", ref snowField4GlobalLODParam, 0.0f, 0.0f, "%.2f", ImGuiInputTextFlags.EnterReturnsTrue); ImGui.PopItemWidth(); bool lodsSet = areLodFactorsSet(); bool disableLodButton = lodsSet && areLodFactorsDefault(); @@ -2945,14 +3381,16 @@ namespace MHWNewCamera if (ImGui.Checkbox("Apply LOD Biases", ref lodsSet)) { setLodFactors(lodsSet); - config.ApplyLodFactors = lodsSet && !areLodFactorsDefault(); + applyLodFactors = lodsSet && !areLodFactorsDefault(); if (lodsSet) { config.FoliageLodBias = foliageLodBias; config.TerrainLodBias = terrainLodBias; config.FoliageLodFactor = foliageLodFactor; config.TerrainLodFactor = terrainLodFactor; + config.SnowLodBias = snowField4GlobalLODParam; } + config.ApplyLodFactors = applyLodFactors; ConfigManager.SaveConfig(this); } if (disableLodButton) @@ -2984,12 +3422,88 @@ namespace MHWNewCamera ImGui.Text("Increase the distance at which Foliage Sway is still applied to lower priority plants."); ImGui.EndTooltip(); } + + if (ImGui.Checkbox("Disable Reduced Rate Animations", ref disableReducedRateAnimations)) + { + if (disableReducedRateAnimations) + { + zeroFrameSkip.Enable(); + } + else + { + zeroFrameSkip.Disable(); + } + config.DisableReducedRateAnimations = disableReducedRateAnimations; + ConfigManager.SaveConfig(this); + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Stop monsters' animation rate from being reduced when far from the camera."); + ImGui.EndTooltip(); + } + + if (ImGui.Checkbox("Underwater Camera", ref enableUnderWaterCamera)) + { + if (enableUnderWaterCamera) + { + underwaterCamera1.Enable(); + underwaterCamera2.Enable(); + underwaterCamera3.Enable(); + underwaterCamera4.Enable(); + underwaterCamera5.Enable(); + } + else + { + underwaterCamera1.Disable(); + underwaterCamera2.Disable(); + underwaterCamera3.Disable(); + underwaterCamera4.Disable(); + underwaterCamera5.Disable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Trigger underwater screen filter when the camera goes underwater."); + ImGui.EndTooltip(); + } + + if (ImGui.Checkbox("Disable Volumetric Downsample", ref disableVolumeDownsample)) + { + if (disableVolumeDownsample) + { + zeroVolumetricDownsample.Enable(); + } + else + { + zeroVolumetricDownsample.Disable(); + } + } } ImGui.PopID(); ImGui.PushID("Debug"); if (ImGui.CollapsingHeader("DEBUG")) { + /* + if (ImGui.InputText("ObjectAddr", ref objectAddrStr, 32, ImGuiInputTextFlags.EnterReturnsTrue)) + { + objectAddr = (nint)Int64.Parse(objectAddrStr, NumberStyles.HexNumber); + } + if (ImGui.InputText("Object2Addr", ref object2AddrStr, 32, ImGuiInputTextFlags.EnterReturnsTrue)) + { + object2Addr = (nint)Int64.Parse(object2AddrStr, NumberStyles.HexNumber); + } + if (ImGui.InputText("Object3Addr", ref object3AddrStr, 32, ImGuiInputTextFlags.EnterReturnsTrue)) + { + object3Addr = (nint)Int64.Parse(object3AddrStr, NumberStyles.HexNumber); + } + if (ImGui.InputText("Object4Addr", ref object4AddrStr, 32, ImGuiInputTextFlags.EnterReturnsTrue)) + { + object4Addr = (nint)Int64.Parse(object4AddrStr, NumberStyles.HexNumber); + } + ImGui.Checkbox("Run Collision Func", ref runFunc); + */ + if (pCamera != null) { ImGui.Text("Perspective Camera"); @@ -3002,11 +3516,49 @@ namespace MHWNewCamera ImGui.Separator(); } + + if (ImGui.CollapsingHeader("Monsters")) + { + Monster[] monsters = Monster.GetAllMonsters(); + foreach (Monster monster in monsters) + { + ImGui.PushID(monster.Instance); + ImGui.Text($"{monster.Name}: Instance: {monster.Instance:x}"); + if (monster.AnimationLayer != null) + { + ImGui.Text($" AnimationLayer: {monster.AnimationLayer.Instance:x}"); + } + ActionInfo currentActionInfo = monster.ActionController.CurrentAction; + SharpPluginLoader.Core.Actions.Action? currentAction = null; + if (currentActionInfo.ActionSet >= 0 && currentActionInfo.ActionSet <= 3) + { + ActionList actionList = monster.ActionController.GetActionList(currentActionInfo.ActionSet); + if (currentActionInfo.ActionId >= 0 && currentActionInfo.ActionId < actionList.Count) + { + currentAction = actionList[currentActionInfo.ActionId]; + } + } + if (currentAction != null) + { + ImGui.Text($" Action: {currentAction.Instance:x}, Flags: {currentAction.Flags:x}"); + ImGui.Text($" Active Time: {currentAction.ActiveTime}"); + ImGui.Text($" Delta Sec: {currentAction.DeltaSec}"); + } + ImGui.DragFloat3("Position", ref monster.Position, 0.5f); + if (player != null) + { + ImGui.DragFloat3("Player Reference", ref player.Position, 0.5f); + } + ImGui.PopID(); + } + } + if (player != null) { ImGui.PushID("Player"); ImGui.Text("Player"); ImGui.Text($"Pointer: {player.Instance:x}"); + ImGui.Text($"ActionController: {player.ActionController.Instance:x}"); ActionInfo currentActionInfo = player.ActionController.CurrentAction; SharpPluginLoader.Core.Actions.Action? currentAction = null; @@ -3033,22 +3585,6 @@ namespace MHWNewCamera // An experiment to test potential animation error could be try to keep deltasec as consistent as possible. ImGui.Text($" Delta Sec: {currentAction.DeltaSec}"); } - /* - // https://github.com/HunterPie/HunterPie/blob/fa73f81ed0cdc921a6cf63f96c0fcff3688d88c2/HunterPie.Integrations/Datasources/MonsterHunterWorld/Entity/Game/MHWGame.cs#L74 - bool playerInMenu = false; - nint offset = MemoryUtil.Read(0x1451C4640); - if (offset != 0) - { - offset += 0x13FD0; - offset = MemoryUtil.Read(offset); - if (offset != 0) - { - offset += 0xB734; - playerInMenu = MemoryUtil.Read(offset) == 1; - } - } - ImGui.Text($"In Menu: {playerInMenu}"); - */ bool move = player.Move; if (ImGui.Checkbox("Move", ref move)) { @@ -3088,13 +3624,197 @@ namespace MHWNewCamera ImGui.Separator(); ImGui.Text("Graphics"); + nint baseAddr = MemoryUtil.Read(0x1451C4368); ImGui.Text($"dofPointer: {dofPointer:x}"); ImGui.Text($"prevFoliageLodBias: {prevFoliageLodBias}"); ImGui.Text($"prevTerrainLodBias: {prevTerrainLodBias}"); ImGui.Text($"shadowCascadeValue: {lastShadowCascadeValue}"); ImGui.Text($"shadowBias: {lastShadowBias}"); ImGui.Text($"shadowRadius: {lastShadowRadius}"); - ImGui.Text($"shadowSampleNum: {lastShadowSampleNum}"); + + ImGui.PushItemWidth(width * 0.2f); + ImGui.Text("SSAO Depth Bias"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Depth Bias", ref overrideSSAOParams.ssaoDepthBias, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoDepthBias}"); + + ImGui.Text("SSAO Sloped Depth Bias"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Sloped Depth Bias", ref overrideSSAOParams.ssaoSlopedDepthBias, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoSlopedDepthBias}"); + + ImGui.Text("SSAO Max Depth Bias"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Max Depth Bias", ref overrideSSAOParams.ssaoMaxDepthBias, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoMaxDepthBias}"); + + ImGui.Text("SSAO Dispersion"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Dispersion", ref overrideSSAOParams.ssaoDispersion, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoDispersion}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB4BC)}"); + + ImGui.Text("SSAO Effect"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Effect", ref overrideSSAOParams.ssaoEffect, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoEffect}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB430)}"); + + ImGui.Text("SSAO Effect GI"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Effect GI", ref overrideSSAOParams.ssaoEffectGI, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoEffectGI}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB434)}"); + + ImGui.Text("SSAO Depth Difference"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Depth Difference", ref overrideSSAOParams.ssaoDepthDifference, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoDepthDifference}"); + + ImGui.Text("SSAO Samples Per Pixel"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Samples Per Pixel", ref overrideSSAOParams.ssaoSamplesPerPixel, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoSamplesPerPixel}"); + + ImGui.Text("SSAO Max Samples"); + ImGui.SameLine(); + ImGui.InputInt("##SSAO Max Samples", ref overrideSSAOParams.ssaoMaxSampleNum, 0, 0, ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoMaxSampleNum}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB4C8)}"); + + ImGui.Text("SSAO Max Samples HQ"); + ImGui.SameLine(); + ImGui.InputInt("##SSAO Max Samples HQ", ref overrideSSAOParams.ssaoMaxSampleNumHQ, 0, 0, ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoMaxSampleNumHQ}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB4D0)}"); + + ImGui.Text("SSAO Radius"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Radius", ref overrideSSAOParams.ssaoRadius, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoRadius}"); + + ImGui.Text("SSAO Intensity"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Intensity", ref overrideSSAOParams.ssaoIntensity, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoIntensity}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB4E0)}"); + + ImGui.Text("SSAO Bias"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Bias", ref overrideSSAOParams.ssaoBias, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoBias}"); + ImGui.SameLine(); + ImGui.Text($"Set: {MemoryUtil.Read(baseAddr + 0xB4D8)}"); + + ImGui.Text("SSAO Use HiZ"); + ImGui.SameLine(); + ImGui.Checkbox("##SSAO Use HiZ", ref overrideSSAOParams.ssaoUseHiZ); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoUseHiZ}"); + + ImGui.Text("SSAO Edge Atten Rate"); + ImGui.SameLine(); + ImGui.InputFloat("##SSAO Edge Atten Rate", ref overrideSSAOParams.ssaoEdgeAttenRate, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.SameLine(); + ImGui.Text($"Internal: {internalSSAOParams.ssaoEdgeAttenRate}"); + ImGui.PopItemWidth(); + + float cbAlphaUnrollNear = MemoryUtil.Read(baseAddr + 0xE964); + if (ImGui.InputFloat("cbAlphaUnrollNear", ref cbAlphaUnrollNear, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE964, BitConverter.GetBytes(cbAlphaUnrollNear)); + } + + float cbAlphaUnrollFar = MemoryUtil.Read(baseAddr + 0xE968); + if (ImGui.InputFloat("cbAlphaUnrollFar", ref cbAlphaUnrollFar, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE968, BitConverter.GetBytes(cbAlphaUnrollNear)); + } + + float cbHistoryBlendRate = MemoryUtil.Read(baseAddr + 0xE96C); + if (ImGui.InputFloat("cbHistoryBlendRate", ref cbHistoryBlendRate, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE96C, BitConverter.GetBytes(cbHistoryBlendRate)); + } + + int cbSanitizeColor = MemoryUtil.Read(baseAddr + 0xE972); + if (ImGui.InputInt("cbSanitizeColor", ref cbSanitizeColor, 0, 0, ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE972, BitConverter.GetBytes(cbSanitizeColor)); + } + + float cbBlendDither = MemoryUtil.Read(baseAddr + 0xE973); + if (ImGui.InputFloat("cbBlendDither", ref cbBlendDither, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE973, BitConverter.GetBytes(cbBlendDither)); + } + + float cbDitherBBoxStrength = MemoryUtil.Read(baseAddr + 0xE974); + if (ImGui.InputFloat("cbDitherBBoxStrength", ref cbDitherBBoxStrength, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE974, BitConverter.GetBytes(cbDitherBBoxStrength)); + } + + float cbDitherPassthruWeight = MemoryUtil.Read(baseAddr + 0xE978); + if (ImGui.InputFloat("cbDitherPassthruWeight", ref cbDitherPassthruWeight, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE978, BitConverter.GetBytes(cbDitherPassthruWeight)); + } + + float cbDitherFilteredWeight = MemoryUtil.Read(baseAddr + 0xE97C); + if (ImGui.InputFloat("cbDitherFilteredWeight", ref cbDitherFilteredWeight, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE97C, BitConverter.GetBytes(cbDitherFilteredWeight)); + } + + bool cbContinuousHistoryReset = MemoryUtil.Read(baseAddr + 0xE971) == 1; + if (ImGui.Checkbox("cbContinuousHistoryReset", ref cbContinuousHistoryReset)) + { + MemoryUtil.WriteBytes(baseAddr + 0xE971, cbContinuousHistoryReset ? [0x1] : [0x0]); + } + + if (ImGui.Checkbox("Renderer Param Overrides", ref applyRendererOverrides)) + { + writeSSAOParams(baseAddr, applyRendererOverrides ? overrideSSAOParams : internalSSAOParams); + } + ImGui.SameLine(); + if (ImGui.Button("Copy from internal")) + { + overrideSSAOParams.ssaoDepthBias = internalSSAOParams.ssaoDepthBias; + overrideSSAOParams.ssaoSlopedDepthBias = internalSSAOParams.ssaoSlopedDepthBias; + overrideSSAOParams.ssaoMaxDepthBias = internalSSAOParams.ssaoMaxDepthBias; + overrideSSAOParams.ssaoDispersion = internalSSAOParams.ssaoDispersion; + overrideSSAOParams.ssaoEffect = internalSSAOParams.ssaoEffect; + overrideSSAOParams.ssaoEffectGI = internalSSAOParams.ssaoEffectGI; + overrideSSAOParams.ssaoDepthDifference = internalSSAOParams.ssaoDepthDifference; + overrideSSAOParams.ssaoSamplesPerPixel = internalSSAOParams.ssaoSamplesPerPixel; + overrideSSAOParams.ssaoMaxSampleNum = internalSSAOParams.ssaoMaxSampleNum; + overrideSSAOParams.ssaoMaxSampleNumHQ = internalSSAOParams.ssaoMaxSampleNumHQ; + overrideSSAOParams.ssaoRadius = internalSSAOParams.ssaoRadius; + overrideSSAOParams.ssaoBias = internalSSAOParams.ssaoBias; + overrideSSAOParams.ssaoIntensity = internalSSAOParams.ssaoIntensity; + overrideSSAOParams.ssaoUseHiZ = internalSSAOParams.ssaoUseHiZ; + overrideSSAOParams.ssaoEdgeAttenRate = internalSSAOParams.ssaoEdgeAttenRate; + } ImGui.Separator(); -- cgit v1.2.3-101-g0448