From 8fe04fd5722edbedfc07772e2123783128600f2e Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Thu, 22 Jan 2026 22:21:35 -0500 Subject: Version 4.0 beta Signed-off-by: Andrew Opalach --- Config.cs | 142 +++-- Plugin.cs | 1826 ++++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 1310 insertions(+), 658 deletions(-) diff --git a/Config.cs b/Config.cs index b8c1943..db17a07 100755 --- a/Config.cs +++ b/Config.cs @@ -7,37 +7,63 @@ namespace MHWNewCamera { internal class Config : IConfig { + public String Name => "MHWNewCamera"; + public String Version => "4.0"; + public struct Settings { - public const float DEFAULT_SPEED = 5.25f; + public const float DEFAULT_SPEED = 5.35f; public const float DEFAULT_SPEED_MODIFIER = 0.40f; - public const float DEFAULT_SENSITIVITY = 0.045f; + public const float DEFAULT_SENSITIVITY = 0.0425f; public const float DEFAULT_ZOOM_SPEED = 0.02f; public const double DEFAULT_PITCH_LIMIT = -1.0; public const double MAX_PITCH_LIMIT = 89.95; public const int DEFAULT_DEADZONE = 4750; + public const float DEFAULT_ALT_NEAR_CLIP = 0.3f; public Settings() { - CameraSpeed = DEFAULT_SPEED; - CameraSpeedModifier = DEFAULT_SPEED_MODIFIER; - CameraSensitivity = DEFAULT_SENSITIVITY; - CameraZoomSpeed = DEFAULT_ZOOM_SPEED; - CameraPitchLimit = DEFAULT_PITCH_LIMIT; + Speed = DEFAULT_SPEED; + SpeedModifier = DEFAULT_SPEED_MODIFIER; + Sensitivity = DEFAULT_SENSITIVITY; + ZoomSpeed = DEFAULT_ZOOM_SPEED; + PitchLimit = DEFAULT_PITCH_LIMIT; StickDeadzone = DEFAULT_DEADZONE; + AlternateNearClip = DEFAULT_ALT_NEAR_CLIP; } - public float CameraSpeed { get; set; } - public float CameraSpeedModifier { get; set; } - public float CameraSensitivity { get; set; } - public float CameraZoomSpeed { get; set; } - public double CameraPitchLimit { get; set; } + public float Speed { get; set; } + public float SpeedModifier { get; set; } + public float Sensitivity { get; set; } + public float ZoomSpeed { get; set; } + public double PitchLimit { get; set; } public int StickDeadzone { get; set; } + public float AlternateNearClip { get; set; } + + public struct Binds + { + public Binds() + { + EnableCombo = true; + FreeCameraCombo = "RStick,LT"; + DisableComboButton1UnlessButton2Held = false; + EnableKeyboard = true; + KeyboardLookSensitivity = 19750; + } + + public bool EnableCombo { get; set; } + public String FreeCameraCombo { get; set; } + public bool DisableComboButton1UnlessButton2Held { get; set; } +#if SIMPLE_KEYBOARD_LAYER + public bool EnableKeyboard { get; set; } + public int KeyboardLookSensitivity { get; set; } +#endif + } } public struct Preset { - public double FOV { get; set; } + public double FieldOfView { get; set; } public float Forward { get; set; } public float Right { get; set; } public float Up { get; set; } @@ -45,8 +71,57 @@ namespace MHWNewCamera public bool DisableFading { get; set; } } - public struct SavedPosition + public struct GraphicalTweaks { + public GraphicalTweaks() + { + TripleShadowResolution = false; + SlightlyHigherShadowValues = true; + ShadowRangeOffset = 0.7f; + ApplyShadowRange = false; + ShadowRadiusOffset = -0.0001f; + ApplyShadowRadius = false; + HigherShadowDetailInHoarfrost = false; + SSAOAdjustments = false; + SSRAdjustments = false; + EnableHQMode = false; + DisableLODLimits = false; + FoliageLODBias = 3.0f; + TerrainLODBias = 16.0f; + FoliageLODFactor = 0.0f; + TerrainLODFactor = 0.0f; + SnowLODBias = 32.0f; + ApplyLODFactors = false; + LargerFoliageSwayRange = false; + DisableReducedRateAnimations = false; + DisableVolumetricDownsample = false; + } + + public bool TripleShadowResolution { get; set; } + public bool SlightlyHigherShadowValues { get; set; } + public float ShadowRangeOffset { get; set; } + public bool ApplyShadowRange { get; set; } + public float ShadowRadiusOffset { get; set; } + public bool ApplyShadowRadius { get; set; } + public bool HigherShadowDetailInHoarfrost { get; set; } + public bool SSAOAdjustments { get; set; } + public bool SSRAdjustments { get; set; } + public bool EnableHQMode { get; set; } + public bool DisableLODLimits { get; set; } + public float FoliageLODBias { get; set; } + public float TerrainLODBias { get; set; } + public float FoliageLODFactor { get; set; } + public float TerrainLODFactor { get; set; } + public float SnowLODBias { get; set; } + public bool ApplyLODFactors { get; set; } + public bool LargerFoliageSwayRange { get; set; } + public bool DisableReducedRateAnimations { get; set; } + public bool DisableVolumetricDownsample { get; set; } + } + + public struct Position + { + public float FieldOfView { get; set; } public float PosX { get; set; } public float PosY { get; set; } public float PosZ { get; set; } @@ -56,9 +131,6 @@ namespace MHWNewCamera public double Roll { get; set; } } - public String Name => "MHWNewCamera"; - public String Version => "4.0"; - private static Dictionary buttonMap = new Dictionary { { "r1", Button.R1 }, { "rb", Button.R1 }, @@ -96,41 +168,17 @@ namespace MHWNewCamera public bool DisableMod { get; set; } = false; -#if SIMPLE_KEYBOARD_LAYER - public bool EnableKeyboard { get; set; } = true; - public int KeyboardLookSensitivity { get; set; } = 19750; -#endif + public bool OverrideViewMode { get; set; } = false; - public bool EnableCombo { get; set; } = true; - public String FreeCameraCombo { get; set; } = "RStick,LT"; - public bool DisableComboButton1UnlessButton2Held { get; set; } = false; + public Settings Camera { get; set; } = new Settings(); + public Settings.Binds Binds { get; set; } = new Settings.Binds(); - public Settings CameraSettings { get; set; } = new Settings(); public bool PerspectiveCameraEnabled { get; set; } = false; public Dictionary Presets { get; set; } = new Dictionary(); public String Selected { get; set; } = ""; - public Dictionary Positions { get; set; } = new Dictionary(); - - public bool TripleShadowResolution { get; set; } = false; - public float ShadowRangeOffset { get; set; } = 0.7f; - public bool ApplyShadowRange { get; set; } = false; - public float ShadowRadiusOffset { get; set; } = -0.0001f; - public bool ApplyShadowRadius { get; set; } = false; - public bool HigherShadowDetailInHoarfrost { get; set; } = false; - public bool SSAOAdjustments { get; set; } = false; - public bool SSRAdjustments { get; set; } = false; - public bool EnableHQMode { get; set; } = false; - public bool DisableLODLimits { get; set; } = false; - public float FoliageLODBias { get; set; } = 3.0f; - public float TerrainLODBias { get; set; } = 16.0f; - public float FoliageLODFactor { get; set; } = 0.0f; - public float TerrainLODFactor { get; set; } = 0.0f; - public float SnowLODBias { get; set; } = 32.0f; - public bool ApplyLODFactors { get; set; } = false; - public bool LargerFoliageSwayRange { get; set; } = false; - public bool DisableReducedRateAnimations { get; set; } = false; - public bool DisableVolumetricDownsample { get; set; } = false; - public bool OverrideViewMode { get; set; } = false; + public GraphicalTweaks Graphics { get; set; } = new GraphicalTweaks(); + + public Dictionary Positions { get; set; } = new Dictionary(); } } diff --git a/Plugin.cs b/Plugin.cs index c181513..b0e0c65 100755 --- a/Plugin.cs +++ b/Plugin.cs @@ -2,10 +2,10 @@ //#define HOOK_ORDER_ASSERTS //#define LOG_DEBUG_MESSAGES #define SIMPLE_KEYBOARD_LAYER +//#define QUARANTINED_FEATURES using ImGuiNET; using System.Numerics; -using System.Globalization; using System.Runtime.InteropServices; #if ADDR_ASSERTS || HOOK_ORDER_ASSERTS using System.Diagnostics; @@ -21,7 +21,6 @@ using SharpPluginLoader.Core.Configuration; // Tentative List of Actions: // - Toggle Free Camera -// - Exit Free Camera // - Unlock Player Movement // - Lock Camera Vertical Movement // - Apply Speed Modifier @@ -41,25 +40,24 @@ using SharpPluginLoader.Core.Configuration; // - Sit in Hot Springs // - Adjust SSAO/General A/B Graphical Tweaks // - Freeze Game +// - Exit Free Camera // @TODO: -// - Analyze SSAO between character select, character creator, and gameplay. +// - Camera "Gear Shift". +// - Option to ignore camera change (update position, test open book and close). +// - Better calculation for positioning camera behind the player. // - Underwater camera crashes in The Rotten Vale. -// - Crash related possibly to shadow change? dx11? -// - Crash leaving gallery? -// - Better name for unknownPtr. -// - Read lod bias setting from in-game value. -// - List out all binds and try to work out better mappings. -// - Layers concept? -// - Attempt to reduce noise in binds table. +// - Adjust SSAO in cutscenes. +// - Test for crash on Windows relating to shadow res changes. +// - Read LOD bias setting from in-game setting (Low, Medium or High). // - Make left stick input a curve like Wilds. // - Ability to lock camera to a the player/a joint. -// - 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). // - More multiple controller testing (3 controllers, steam input, windows). // - Thoroughly test "Disable Mod". // - Improve AOB scans. +// - Better name for unknownPtr. // - Some objects still fade. // - Glass objects in research base and on the botanical research center table. // - Decals on floor near Astera lift. @@ -124,39 +122,39 @@ using SharpPluginLoader.Core.Configuration; 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 float depthBias; // +0xB4B0 + public float slopedDepthBias; // +0xB4B4 + public float maxDepthBias; // +0xB4B8 + public float dispersion; // +0xB4BC + public float effect; // +0xB430 + public float effectGI; // +0xB434 + public float depthDifference; // +0xB4C0 + public float samplesPerPixel; // +0xB4C4 + public int maxSampleNum; // +0xB4C8 + public int maxSampleNumHQ; // +0xB4D0 + public float radius; // +0xB4D4 + public float bias; // +0xB4D8 + public float intensity; // +0xB4E0 + public bool useHiZ; // +0xB4E5 + public float edgeAttenRate; // +0xB4DC }; public struct SSLRParameters { - public int 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 bool sslrDitherResolve; // +0xB43F - public float sslrEdgeAttenRate; // +0xB428 - public int sslrMip0CountThreshold; // +0xB438 - public float sslrDepthEliminateRate; // +0xB42C - public bool sslrUseMipmap; // +0xE650 - public bool sslrGBufferJitter; // +0xB440 + public int loopCount; // +0xE628 + public float loopCountFactorForCBR; // +0xE62C + public float eliminateDepth; // +0xE630 + public float accurateThreshold; // +0xE644 + public float accurateThresholdHQ; // +0xE64C + public float ditherRadius; // +0xE634 + public float importanceBias; // +0xE638 + public float mipScale; // +0xE63C + public float mipBias; // +0xE640 + public bool ditherResolve; // +0xB43F + public float edgeAttenRate; // +0xB428 + public int mip0CountThreshold; // +0xB438 + public float depthEliminateRate; // +0xB42C + public bool useMipmap; // +0xE650 + public bool gBufferJitter; // +0xB440 }; public unsafe class Plugin : IPlugin @@ -170,12 +168,6 @@ namespace MHWNewCamera private bool disableMod = false; private static readonly MtObject sMain = SingletonManager.GetSingleton("sMhMain")!; - private static readonly MtObject sTime = SingletonManager.GetSingleton("sTime")!; - -#if SIMPLE_KEYBOARD_LAYER - private bool keyboardEnabled = false; - private int keyboardLookValue; -#endif private float cameraSpeed; private float cameraSpeedModifier; @@ -183,6 +175,7 @@ namespace MHWNewCamera private float cameraZoomSpeed; private double cameraPitchLimit; private int stickDeadzone; + private float alternateNearClip; private double cameraFov = DEFAULT_FOV; private float cameraForward = 0.0f; @@ -196,8 +189,10 @@ namespace MHWNewCamera private bool disableFading = false; private int cameraWrapState = 0; - private bool freeCamera = false; private bool enableFreeCamera = false; + private bool freeCamera = false; + private bool freeCameraFromViewMode = false; + private bool freeCameraFallback = false; private Camera? vCamera = null; private int vCameraViewportIndex = -1; private double cameraFrameX; @@ -205,17 +200,17 @@ namespace MHWNewCamera private double cameraFrameZ; private Vector3 cameraPosition; private Vector3 cameraTarget; - private bool freeCameraFallback = false; - private bool lastFreeCameraFallback = false; - private double? preDetachFov = null; - private double? preDetachRoll = null; + private double? restoreFov = null; + private double? restoreRoll = null; + private float? restoreNearClip = null; private bool unlockMovementHeld = false; private bool unlockMovementToggled = false; private bool unlockMovementPause = false; private bool lockVerticalToggled = false; + private bool freezeGame = false; - private bool offsetPerspective = false; private bool enableOffsetPerspective = false; + private bool offsetPerspective = false; private Player? lastPlayer = null; private Camera? pCamera = null; private int pCameraViewportIndex = -1; @@ -228,6 +223,10 @@ namespace MHWNewCamera private Button[]? freeCameraCombo = null; private bool disableComboButton1 = false; private bool comboButton1Down = false; +#if SIMPLE_KEYBOARD_LAYER + private bool keyboardEnabled = false; + private int keyboardLookValue; +#endif private static readonly MtObject sMhSteamController = SingletonManager.GetSingleton("sMhSteamController")!; private nint controllerAddr() => sMhSteamController.Instance; @@ -298,9 +297,18 @@ namespace MHWNewCamera private delegate void CollisionCheckDelegate(nint unknownPtr, nint unknownPtr2); private Hook? collisionCheckHook; + private bool motionBlurDisabled = false; + private bool motionBlurWasDisabled; + private delegate void MotionBlurDelegate(nint unknownPtr, nint unknownPtr2); + private Hook? motionBlurHook; + private delegate void CameraEffectDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); private Hook? cameraEffectHook; + private nint fxaaPointer = 0x0; + private delegate void FXAADelegate(nint unknownPtr, nint unknownPtr2); + private Hook? fxaaHook; + private Patch swapMinimapFollowsCamera; private bool uiToggled = false; @@ -309,20 +317,22 @@ namespace MHWNewCamera private bool dofDisabled = false; private Patch jmpOverDof; - private float alternateNearClip = 2.0f; - private bool disableCharacterFade = false; private Patch noopCharacterFade; private bool tripleShadowRes = false; + private bool slightlyHigherShadowValues = false; private bool lowShadowDetailOverride = false; private Patch shadowRes1_3x; private Patch shadowRes1_1; private Patch shadowRes1_2; private Patch shadowRes1_3; private Patch shadowRes2; + //private Patch shadowRes2_Upper; private Patch shadowRes3; + //private Patch shadowRes3_Upper; private Patch shadowRes4_3x; + private Patch shadowRes4_Limit; /* private Patch ssrRes1; @@ -350,7 +360,16 @@ namespace MHWNewCamera shadowRes1_3.Enable(); shadowRes2.Enable(); shadowRes3.Enable(); - shadowRes4_3x.Enable(); + if (slightlyHigherShadowValues) + { + //shadowRes2_Upper.Enable(); + //shadowRes3_Upper.Enable(); + shadowRes4_Limit.Enable(); + } + else + { + shadowRes4_3x.Enable(); + } } private void tripleShadowResDisable() @@ -361,14 +380,26 @@ namespace MHWNewCamera shadowRes1_3.Disable(); shadowRes2.Disable(); shadowRes3.Disable(); - shadowRes4_3x.Disable(); + if (slightlyHigherShadowValues) + { + //shadowRes2_Upper.Disable(); + //shadowRes3_Upper.Disable(); + shadowRes4_Limit.Disable(); + } + else + { + shadowRes4_3x.Disable(); + } } private int internalShadowSampleNumHQ; // +0xE5CC //private int shadowSampleNumHQ = 32; private bool ssaoAdjustments = false; + private bool ssaoB = false; private SSAOParameters internalSSAOParams; + //private SSAOParameters aSSAOParams; + //private SSAOParameters bSSAOParams; private bool ssrAdjustments = false; private SSLRParameters internalSSRParams; @@ -381,7 +412,7 @@ namespace MHWNewCamera private float prevTerrainLODBias = 0.0f; private float foliageLODFactor; private float terrainLODFactor; - private float internalSnowField4GlobalLODParam; // +0x5718 + private float internalSnowField4GlobalLODParam = 0.0f; // +0x5718 private float snowField4GlobalLODParam = 8.0f; //private float snowField4AllowTesselationHQ; // +0x5741 //private float snowField4LODBiasHQ; // +0x5748 @@ -406,6 +437,18 @@ namespace MHWNewCamera defaultViewModeLODLimit_2.Disable(); } + /* + private NativeAction setCharacterCreatorParams; + private NativeAction setSaveSelectParams; + private delegate void LODLimitDelegate(nint unknownPtr); + private Hook? setLODLimitsHook; + private bool characterCreatorRendering = false; + private bool saveSelectRendering = false; + private nint psuedoCharacterCreatorObject; + */ + //private Patch defaultCharacterCreatorParam; + //private bool characterCreatorFace = false; + private bool largerFoliageSwayRange = false; private Patch addressHigherValueForFoliageSway; @@ -443,6 +486,8 @@ namespace MHWNewCamera private bool disableVolumeDownsample = false; private Patch zeroVolumetricDownsample; + private bool hideWeapon = false; + private bool disableCollision = false; private bool disableExtraCollision = false; private bool disableGravity = false; @@ -517,6 +562,10 @@ namespace MHWNewCamera private nint psuedoObject1; private nint psuedoObject2; + private bool applyCharacterWetness = false; + private Patch noopCharacterWetnessUpdate; + private float wholeBodyWetness = 0.0f; + private static readonly MtObject sOtomo = SingletonManager.GetSingleton("sOtomo")!; // Gui strings. @@ -543,33 +592,36 @@ namespace MHWNewCamera disableMod = config.DisableMod; + overrideViewMode = config.OverrideViewMode; + + Config.Settings.Binds binds = config.Binds; + enableCombo = binds.EnableCombo; + freeCameraCombo = Config.ParseCombo(binds.FreeCameraCombo); + typedCombo = binds.FreeCameraCombo.Replace(",", "+"); + disableComboButton1 = binds.DisableComboButton1UnlessButton2Held; #if SIMPLE_KEYBOARD_LAYER - keyboardEnabled = config.EnableKeyboard; - keyboardLookValue = config.KeyboardLookSensitivity; + keyboardEnabled = binds.EnableKeyboard; + keyboardLookValue = binds.KeyboardLookSensitivity; #endif - enableCombo = config.EnableCombo; - freeCameraCombo = Config.ParseCombo(config.FreeCameraCombo); - typedCombo = config.FreeCameraCombo.Replace(",", "+"); - disableComboButton1 = config.DisableComboButton1UnlessButton2Held; - - Config.Settings settings = config.CameraSettings; - cameraSpeed = settings.CameraSpeed; - cameraSpeedModifier = settings.CameraSpeedModifier; - cameraSensitivity = settings.CameraSensitivity; - cameraZoomSpeed = settings.CameraZoomSpeed; - cameraPitchLimit = settings.CameraPitchLimit; + Config.Settings camera = config.Camera; + cameraSpeed = camera.Speed; + cameraSpeedModifier = camera.SpeedModifier; + cameraSensitivity = camera.Sensitivity; + cameraZoomSpeed = camera.ZoomSpeed; + cameraPitchLimit = camera.PitchLimit; if (cameraPitchLimit != -1.0) { cameraPitchLimit = Math.Clamp(cameraPitchLimit, 0.0, Config.Settings.MAX_PITCH_LIMIT); } - stickDeadzone = settings.StickDeadzone; + stickDeadzone = camera.StickDeadzone; + alternateNearClip = camera.AlternateNearClip; enableOffsetPerspective = config.PerspectiveCameraEnabled; if (config.Selected != "") { Config.Preset preset = config.Presets[config.Selected]; - cameraFov = preset.FOV; + cameraFov = preset.FieldOfView; cameraForward = preset.Forward; cameraRight = preset.Right; cameraYOffset = preset.Up; @@ -577,20 +629,21 @@ namespace MHWNewCamera disableFading = preset.DisableFading; } - tripleShadowRes = config.TripleShadowResolution; - shadowBiasOffset = config.ShadowRangeOffset; - shadowRadiusOffset = config.ShadowRadiusOffset; - applyShadowBias = config.ApplyShadowRange; - applyShadowRadius = config.ApplyShadowRadius; - lowShadowDetailOverride = config.HigherShadowDetailInHoarfrost; - ssaoAdjustments = config.SSAOAdjustments; - ssrAdjustments = config.SSRAdjustments; - enableHQMode = config.EnableHQMode; - disableLODLimits = config.DisableLODLimits; - largerFoliageSwayRange = config.LargerFoliageSwayRange; - disableReducedRateAnimations = config.DisableReducedRateAnimations; - disableVolumeDownsample = config.DisableVolumetricDownsample; - overrideViewMode = config.OverrideViewMode; + Config.GraphicalTweaks graphics = config.Graphics; + tripleShadowRes = graphics.TripleShadowResolution; + slightlyHigherShadowValues = graphics.SlightlyHigherShadowValues; + shadowBiasOffset = graphics.ShadowRangeOffset; + shadowRadiusOffset = graphics.ShadowRadiusOffset; + applyShadowBias = graphics.ApplyShadowRange; + applyShadowRadius = graphics.ApplyShadowRadius; + lowShadowDetailOverride = graphics.HigherShadowDetailInHoarfrost; + ssaoAdjustments = graphics.SSAOAdjustments; + ssrAdjustments = graphics.SSRAdjustments; + enableHQMode = graphics.EnableHQMode; + disableLODLimits = graphics.DisableLODLimits; + largerFoliageSwayRange = graphics.LargerFoliageSwayRange; + disableReducedRateAnimations = graphics.DisableReducedRateAnimations; + disableVolumeDownsample = graphics.DisableVolumetricDownsample; ConfigManager.SaveConfig(this); @@ -717,8 +770,11 @@ namespace MHWNewCamera collisionCheckHook = Hook.Create(0x1411C4E50, CollisionCheckHook); - //cameraEffectHook = Hook.Create(0x1416D4890, CameraEffectHook); // Wiggle directly. - cameraEffectHook = Hook.Create(0x141AB6AE0, CameraEffectHook); // Upper function. + motionBlurHook = Hook.Create(0x1424CADF0, MotionBlurHook); + + cameraEffectHook = Hook.Create(0x141AB6AE0, CameraEffectHook); + + fxaaHook = Hook.Create(0x1423939D0, FXAAHook); unchecked { @@ -762,24 +818,42 @@ namespace MHWNewCamera Trace.Assert(addr == 0x142287A50); #endif shadowRes2 = new Patch(addr + 0x3F, [ + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, // Value the game picks. + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 + ]); + /* + shadowRes2_Upper = new Patch(addr + 0x3F, [ + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, // Value the game picks. 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 ]); + */ addr = PatternScanner.FindFirst(Pattern.FromString("89 91 30 55 00 00 83 FA FF 7F 06 8B 91 1C 55 00 00 85 D2 74 4B 83 EA 01 74 3B 83 EA 01 74 2B 83 EA 01 74 1B 83 FA 01 74 0B C7 81 20 55 00 00 01 00 00 00 C3 C7 81 20 55 00 00 00 10 00 00")); #if ADDR_ASSERTS Trace.Assert(addr == 0x142287AD0); #endif shadowRes3 = new Patch(addr + 0x34, [ + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, + 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 + ]); + /* + shadowRes3_Upper = new Patch(addr + 0x34, [ 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 ]); + */ addr = PatternScanner.FindFirst(Pattern.FromString("89 91 00 55 00 00 83 FA 05 77 41 48 63 C2 4C 8D 05 ?? ?? ?? ?? 41 8B 94 80 84 8B 28 02 49 03 D0 FF E2 B8 00 08 00 00")); #if ADDR_ASSERTS @@ -792,7 +866,10 @@ namespace MHWNewCamera // Shadow Quality: High the result will be 15360. Going past some number around 16384 will crash // the game. I think it's related to N/64 >= 256. shadowRes4_3x = new Patch(addr + 0x29, [ - 0xB8, 0x40, 0x15, 0x00, 0x00, 0xEB, 0x21 // This case is used for Low, Medium and High in-game. + 0xB8, 0x00, 0x14, 0x00, 0x00, 0xEB, 0x21 // This case is used for Low, Medium and High in-game. + ]); + shadowRes4_Limit = new Patch(addr + 0x29, [ // N/64 = 255, fractional values closer to 256 not tested. + 0xB8, 0x40, 0x15, 0x00, 0x00, 0xEB, 0x21 ]); if (tripleShadowRes && !disableMod) { @@ -842,6 +919,15 @@ namespace MHWNewCamera disableLODLimitsEnable(); } + /* + setCharacterCreatorParams = new NativeAction(0x1402457C0); + setSaveSelectParams = new NativeAction(0x1402623A0); + setLODLimitsHook = Hook.Create(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); @@ -870,7 +956,7 @@ namespace MHWNewCamera zeroVolumetricDownsample2 = new Patch((nint)0x1424CE53F, [0xE9, 0x6B, 0x0C, 0x00, 0x00, 0x90]); zeroVolumetricDownsample3 = new Patch((nint)0x1424CF0D1, [0x90, 0x90, 0x90, 0x90, 0x90]); */ - if (disableVolumeDownsample) + if (disableVolumeDownsample && !disableMod) { zeroVolumetricDownsample.Enable(); } @@ -924,6 +1010,8 @@ namespace MHWNewCamera jmpOverHotSpringsEval = new Patch((nint)0x1417C1B03, [0xEB]); jmpOverHotSpringsSteam = new Patch((nint)0x14203A494, [0xE9, 0x8D, 0x00, 0x00, 0x00, 0x90]); + + noopCharacterWetnessUpdate = new Patch((nint)0x14203E893, [0x90, 0x90, 0x90, 0x90, 0x90]); } } @@ -955,7 +1043,9 @@ namespace MHWNewCamera private bool areLODFactorsDefault() { - return foliageLODBias == 3.0f && terrainLODBias == 3.0f && foliageLODFactor == 1.0f && terrainLODFactor == 1.0f && snowField4GlobalLODParam == 8.0f; + return foliageLODBias == 3.0f && terrainLODBias == 3.0f && + foliageLODFactor == 1.0f && terrainLODFactor == 1.0f && + snowField4GlobalLODParam == 8.0f; } private bool areLODFactorsSet() @@ -976,6 +1066,7 @@ namespace MHWNewCamera nint baseAddr = MemoryUtil.Read(0x1451C4368); if (toggleOn) { + // Assume in-game setting is "High". if (prevFoliageLODBias <= 0.0f) { prevFoliageLODBias = MemoryUtil.Read(baseAddr + 0x21C); @@ -1005,12 +1096,13 @@ namespace MHWNewCamera public void OnLoad() { Config config = ConfigManager.GetConfig(this); - foliageLODBias = config.FoliageLODBias; - terrainLODBias = config.TerrainLODBias; - foliageLODFactor = config.FoliageLODFactor; - terrainLODFactor = config.TerrainLODFactor; - snowField4GlobalLODParam = config.SnowLODBias; - applyLODFactors = config.ApplyLODFactors; + Config.GraphicalTweaks graphics = config.Graphics; + foliageLODBias = graphics.FoliageLODBias; + terrainLODBias = graphics.TerrainLODBias; + foliageLODFactor = graphics.FoliageLODFactor; + terrainLODFactor = graphics.TerrainLODFactor; + snowField4GlobalLODParam = graphics.SnowLODBias; + applyLODFactors = graphics.ApplyLODFactors; if (applyLODFactors) { setLODFactors(true); @@ -1019,7 +1111,10 @@ namespace MHWNewCamera public void OnUpdate(float deltaTime) { - if (disableMod) return; + if (disableMod) + { + return; + } #if HOOK_ORDER_ASSERTS Trace.Assert(hookOrder == 0 || hookOrder == 4); @@ -1029,31 +1124,6 @@ namespace MHWNewCamera debugLog($"OnUpdate() @ {frameTick}"); #endif - lastFreeCameraFallback = freeCameraFallback; - if (freeCameraFallback && vCamera != null) - { - if (!freeCamera) - { - Quaternion forward = Quaternion.Normalize(getForward(vCamera.Position, vCamera.Target)); - cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X)); - cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y)); - if (enableFreeCamera) - { - setupFreeCamera(vCamera, vCameraViewportIndex); - } - } - if (freeCamera) - { - updateFreeCamera(vCamera); - setCameraRoll(vCamera); - if (!enableFreeCamera) - { - disableFreeCamera(); - } - } - } - freeCameraFallback = true; - #if SIMPLE_KEYBOARD_LAYER if (keyboardEnabled) { @@ -1088,10 +1158,55 @@ namespace MHWNewCamera } #endif - //nint baseAddr = MemoryUtil.Read(0x1451C4368); - //MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(1.75f)); - primaryPad = 0x0; + + if (freeCameraFallback) + { + Player? player = checkPlayerChange(); + checkCurrentVisibleCamera(player); // Ensure vCamera is valid. + if (vCamera != null) + { + if (!freeCamera) + { + Quaternion forward = Quaternion.Normalize(getForward(vCamera.Position, vCamera.Target)); + cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X)); + cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y)); + if (enableFreeCamera) + { + setupFreeCamera(vCamera, vCameraViewportIndex); + } + } + if (freeCamera) + { + updateFreeCamera(vCamera); + setCameraRoll(vCamera); + if (!enableFreeCamera) + { + disableFreeCamera(); + } + } + } + } + freeCameraFallback = true; + + if (hideWeapon) + { + Player? player = Player.MainPlayer; + if (player != null) + { + nint baseAddr = MemoryUtil.Read(player.Instance + 0x76B0); + MemoryUtil.WriteBytes(baseAddr + 0x1A98, [0x1]); + int weaponParts = MemoryUtil.Read(baseAddr + 0x2250); + for (int i = 0; i < weaponParts; i++) + { + nint partAddr = MemoryUtil.Read(baseAddr + ((i + 0x16B) * 24)); + if (partAddr != 0x0) + { + MemoryUtil.WriteBytes(partAddr + 0x1A98, [0x1]); + } + } + } + } } private static Quaternion getForward(Vector3 pos, Vector3 target) @@ -1138,6 +1253,40 @@ namespace MHWNewCamera } } + private bool guessAltNearClipSet(Camera camera) + { + // Try to guard against persisting an adjusted near clip on the player camera after a free camera target change. + return (camera.NearClip == alternateNearClip) || (camera == pCamera && camera.NearClip != DEFAULT_NEAR_CLIP); + } + + private void setNearClip(Camera camera, bool alt) + { + if (alt) + { + if (restoreNearClip == null) + { + restoreNearClip = camera.NearClip; + } + camera.NearClip = alternateNearClip; + } + else + { + if (restoreNearClip == null) + { + camera.NearClip = DEFAULT_NEAR_CLIP; + } + else + { + if (camera == pCamera && restoreNearClip != DEFAULT_NEAR_CLIP) + { + restoreNearClip = DEFAULT_NEAR_CLIP; + } + camera.NearClip = (float)restoreNearClip; + restoreNearClip = null; + } + } + } + private void setPerspective(Camera camera) { Quaternion forward = getForward(camera.Position, camera.Target); @@ -1161,7 +1310,7 @@ namespace MHWNewCamera private void setTentBasePos(Vector3 pos, Vector3 target) { - // @TODO: This can be picked out of the code. + // @TODO: This could be picked out of the code. nint baseAddr = MemoryUtil.Read(0x145011F58); // Default: MemoryUtil.WriteBytes(baseAddr + 0x3E20, BitConverter.GetBytes(pos.X)); // 0.0 MemoryUtil.WriteBytes(baseAddr + 0x3E24, BitConverter.GetBytes(pos.Y)); // -19850.0 @@ -1176,8 +1325,9 @@ namespace MHWNewCamera freeCamera = true; cameraPosition = camera.Position; cameraTarget = camera.Target; - preDetachFov = cameraFov; - preDetachRoll = cameraRoll; + restoreFov = cameraFov; + restoreRoll = cameraRoll; + restoreNearClip = camera.NearClip; // The value of cameraFov is effectively a new default and scales accordingly // based on the in-game FOV. Take the calculated FOV here because that's what is // actually shown, which avoids a jump when toggling freecam. This is also why @@ -1200,25 +1350,27 @@ namespace MHWNewCamera private void disableFreeCamera() { freeCamera = false; + freeCameraFromViewMode = false; unlockInputToggled = false; - if (preDetachFov != null) + if (restoreFov != null) + { + cameraFov = (double)restoreFov; + restoreFov = null; + } + if (restoreRoll != null) { - cameraFov = (double)preDetachFov; - preDetachFov = null; + cameraRoll = (double)restoreRoll; + restoreRoll = null; } - if (preDetachRoll != null) + if (restoreNearClip != null && vCamera != null) { - cameraRoll = (double)preDetachRoll; - preDetachRoll = null; + vCamera.NearClip = (float)restoreNearClip; + restoreNearClip = null; } cameraWrapState = 0; setTentBasePos(new Vector3(0.0f, -19850.0f, 270.0f), new Vector3(0.0f, -19830.0f, 0.0f)); setDisableFadingObjects(vCameraViewportIndex, (vCameraViewportIndex == pCameraViewportIndex) ? disableFading : false); setDisableCharacterFade(disableFading); - if (vCamera != null) - { - vCamera.NearClip = DEFAULT_NEAR_CLIP; - } swapMinimapFollowsCamera.Disable(); //stopViewMode.Invoke(psuedoViewModeObject); } @@ -1230,9 +1382,16 @@ namespace MHWNewCamera private void updateFreeCamera(Camera camera) { - float deltaTime = camera.DeltaTime; - //float deltaTime = 60.0f / MemoryUtil.Read(sMain.Instance + 0x68); - //float deltaTime = MemoryUtil.Read(sMain.Instance + 0x94); + float deltaTime; + if (freezeGame) + { + deltaTime = 60.0f / MemoryUtil.Read(sMain.Instance + 0x68); + } + else + { + //deltaTime = camera.DeltaTime; + deltaTime = MemoryUtil.Read(sMain.Instance + 0x94); + } bool lockVerticalAndModifySpeed = buttonWasDown(Button.L2) || lockVerticalToggled; double adjustedSpeed = cameraSpeed * deltaTime * (lockVerticalAndModifySpeed ? cameraSpeedModifier : 1.0f); @@ -1305,25 +1464,18 @@ namespace MHWNewCamera { if (buttonWasPressed(Button.Square)) { - if (camera.NearClip != DEFAULT_NEAR_CLIP) - { - camera.NearClip = DEFAULT_NEAR_CLIP; - } - else - { - camera.NearClip = alternateNearClip; - } + setNearClip(camera, !guessAltNearClipSet(camera)); } } if (buttonWasDown(Button.Triangle)) { - if (buttonWasPressed(Button.Left) || buttonWasPressed(Button.Right)) + if (buttonWasPressed(Button.Right)) { - cameraRoll = (preDetachRoll != null) ? (double)preDetachRoll : 0.0f; + cameraRoll = (restoreRoll != null) ? (double)restoreRoll : 0.0f; } if (buttonWasPressed(Button.Up)) { - cameraFov = (preDetachFov != null) ? (double)preDetachFov : DEFAULT_FOV; + cameraFov = (restoreFov != null) ? (double)restoreFov : DEFAULT_FOV; } } else @@ -1360,7 +1512,7 @@ namespace MHWNewCamera } if (Input.IsPressed(Key.NumPadStar)) { - cameraRoll = (preDetachRoll != null) ? (double)preDetachRoll : 0.0f; + cameraRoll = (restoreRoll != null) ? (double)restoreRoll : 0.0f; } if (Input.IsDown(Key.NumPad7)) { @@ -1513,12 +1665,6 @@ namespace MHWNewCamera } if (vCamera != camera) { - // We're assuming vCamera isn't an invalid pointer, but there's no assurance of that. - if (vCamera != null) - { - camera.NearClip = vCamera.NearClip; - vCamera.NearClip = DEFAULT_NEAR_CLIP; - } if (player != null) { // Try to position the camera behind the player. @@ -1770,6 +1916,7 @@ namespace MHWNewCamera if (vCamera != null) { enableFreeCamera = true; + freeCameraFromViewMode = true; } } @@ -1833,7 +1980,10 @@ namespace MHWNewCamera private void CalculateViewHook(nint unknownPtr) { calculateViewHook!.Original(unknownPtr); - if (disableMod) return; + if (disableMod) + { + return; + } if (vCameraViewportIndex >= 0 && cameraRoll != 0.0f) { Viewport vp = CameraSystem.GetViewport(vCameraViewportIndex); @@ -1869,7 +2019,6 @@ namespace MHWNewCamera shadowCascadeValue++; MemoryUtil.WriteBytes(unknownPtr2 + 0x170, BitConverter.GetBytes((shadowCascadeValue << 32) | (rax & 0x00000000FFFFFFFF))); biasOverride += shadowBiasOffset; - //biasOverride *= 2.0f; } if (shadowCascadeValue != 3) @@ -1886,7 +2035,8 @@ namespace MHWNewCamera } } - if (applyLODFactors) // @HACK + // @TODO: Find a better place where we can update snow parameters. + if (applyLODFactors) { nint baseAddr = MemoryUtil.Read(0x1451C4368); MemoryUtil.WriteBytes(baseAddr + 0x5718, BitConverter.GetBytes(snowField4GlobalLODParam)); @@ -1895,29 +2045,35 @@ namespace MHWNewCamera shadowCascadeHook!.Original(unknownPtr, unknownPtr2); } - private void setSSAOAdjustements(bool enable) + private void setSSAOAdjustements(bool enable, bool b) { 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 + 0xB4C8, BitConverter.GetBytes(18)); MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(18)); - MemoryUtil.WriteBytes(baseAddr + 0xB4D8, BitConverter.GetBytes(0.001f)); - MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(105.0f)); + if (b) + { + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(0.0f)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(0.0f)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(0.0f)); + } + else + { + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(internalSSAOParams.effect)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(internalSSAOParams.effectGI)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.intensity)); + } } 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 + 0xB4C8, BitConverter.GetBytes(internalSSAOParams.ssaoMaxSampleNum)); - MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(internalSSAOParams.ssaoMaxSampleNumHQ)); - MemoryUtil.WriteBytes(baseAddr + 0xB4D8, BitConverter.GetBytes(internalSSAOParams.ssaoBias)); - MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.ssaoIntensity)); + MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(internalSSAOParams.dispersion)); + MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(internalSSAOParams.effect)); + MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(internalSSAOParams.effectGI)); + MemoryUtil.WriteBytes(baseAddr + 0xB4C8, BitConverter.GetBytes(internalSSAOParams.maxSampleNum)); + MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(internalSSAOParams.maxSampleNumHQ)); + MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.intensity)); } } @@ -1927,31 +2083,21 @@ namespace MHWNewCamera if (enable) { MemoryUtil.WriteBytes(baseAddr + 0xE628, BitConverter.GetBytes(72)); - MemoryUtil.WriteBytes(baseAddr + 0xE630, BitConverter.GetBytes(40.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(0.215f)); - MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(0.215f)); - MemoryUtil.WriteBytes(baseAddr + 0xE634, BitConverter.GetBytes(3.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xB428, BitConverter.GetBytes(2.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xB42C, BitConverter.GetBytes(140.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xE650, [0x1]); + MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(0.2f)); + MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(0.2f)); } else { - MemoryUtil.WriteBytes(baseAddr + 0xE628, BitConverter.GetBytes(internalSSRParams.sslrLoopCount)); - MemoryUtil.WriteBytes(baseAddr + 0xE630, BitConverter.GetBytes(internalSSRParams.sslrEliminateDepth)); - MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(internalSSRParams.sslrAccurateThreshold)); - MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(internalSSRParams.sslrAccurateThresholdHQ)); - MemoryUtil.WriteBytes(baseAddr + 0xE634, BitConverter.GetBytes(internalSSRParams.sslrDitherRadius)); - MemoryUtil.WriteBytes(baseAddr + 0xB428, BitConverter.GetBytes(internalSSRParams.sslrEdgeAttenRate)); - MemoryUtil.WriteBytes(baseAddr + 0xB42C, BitConverter.GetBytes(internalSSRParams.sslrDepthEliminateRate)); - MemoryUtil.WriteBytes(baseAddr + 0xE650, internalSSRParams.sslrUseMipmap ? [0x1] : [0x0]); + MemoryUtil.WriteBytes(baseAddr + 0xE628, BitConverter.GetBytes(internalSSRParams.loopCount)); + MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(internalSSRParams.accurateThreshold)); + MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(internalSSRParams.accurateThresholdHQ)); } } private void setHQMode(bool enable) { nint baseAddr = MemoryUtil.Read(0x1451C4368); - MemoryUtil.WriteBytes(baseAddr + 0xE9A3, enableHQMode ? [0x1] : [0x0]); + MemoryUtil.WriteBytes(baseAddr + 0xE9A3, enable ? [0x1] : [0x0]); } private void RendererSetHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3) @@ -1963,51 +2109,51 @@ namespace MHWNewCamera } bool doSet = MemoryUtil.Read(unknownPtr + 0x530) == 0x0; rendererSetHook!.Original(unknownPtr, unknownPtr2, unknownPtr3); + nint baseAddr = MemoryUtil.Read(0x1451C4368); + internalShadowSampleNumHQ = MemoryUtil.Read(baseAddr + 0xE5CC); + MemoryUtil.WriteBytes(baseAddr + 0xE5CC, BitConverter.GetBytes(16)); + internalSSAOParams.depthBias = MemoryUtil.Read(baseAddr + 0xB4B0); + internalSSAOParams.slopedDepthBias = MemoryUtil.Read(baseAddr + 0xB4B4); + internalSSAOParams.maxDepthBias = MemoryUtil.Read(baseAddr + 0xB4B8); + internalSSAOParams.dispersion = MemoryUtil.Read(baseAddr + 0xB4BC); + internalSSAOParams.effect = MemoryUtil.Read(baseAddr + 0xB430); + internalSSAOParams.effectGI = MemoryUtil.Read(baseAddr + 0xB434); + internalSSAOParams.depthDifference = MemoryUtil.Read(baseAddr + 0xB4C0); + internalSSAOParams.samplesPerPixel = MemoryUtil.Read(baseAddr + 0xB4C4); + internalSSAOParams.maxSampleNum = MemoryUtil.Read(baseAddr + 0xB4C8); + internalSSAOParams.maxSampleNumHQ = MemoryUtil.Read(baseAddr + 0xB4D0); + internalSSAOParams.radius = MemoryUtil.Read(baseAddr + 0xB4D4); + internalSSAOParams.bias = MemoryUtil.Read(baseAddr + 0xB4D8); + internalSSAOParams.intensity = MemoryUtil.Read(baseAddr + 0xB4E0); + internalSSAOParams.useHiZ = MemoryUtil.Read(baseAddr + 0xB4E5) == 0x1; + internalSSAOParams.edgeAttenRate = MemoryUtil.Read(baseAddr + 0xB4DC); + internalSSRParams.loopCount = MemoryUtil.Read(baseAddr + 0xE628); + internalSSRParams.loopCountFactorForCBR = MemoryUtil.Read(baseAddr + 0xE62C); + internalSSRParams.eliminateDepth = MemoryUtil.Read(baseAddr + 0xE630); + internalSSRParams.accurateThreshold = MemoryUtil.Read(baseAddr + 0xE644); + internalSSRParams.accurateThresholdHQ = MemoryUtil.Read(baseAddr + 0xE64C); + internalSSRParams.ditherRadius = MemoryUtil.Read(baseAddr + 0xE634); + internalSSRParams.importanceBias = MemoryUtil.Read(baseAddr + 0xE638); + internalSSRParams.mipScale = MemoryUtil.Read(baseAddr + 0xE63C); + internalSSRParams.mipBias = MemoryUtil.Read(baseAddr + 0xE640); + internalSSRParams.ditherResolve = MemoryUtil.Read(baseAddr + 0xB43F) == 0x1; + internalSSRParams.edgeAttenRate = MemoryUtil.Read(baseAddr + 0xB428); + internalSSRParams.mip0CountThreshold = MemoryUtil.Read(baseAddr + 0xB438); + internalSSRParams.depthEliminateRate = MemoryUtil.Read(baseAddr + 0xB42C); + internalSSRParams.useMipmap = MemoryUtil.Read(baseAddr + 0xE650) == 0x1; + internalSSRParams.gBufferJitter = MemoryUtil.Read(baseAddr + 0xB440) == 0x1; + internalSnowField4GlobalLODParam = MemoryUtil.Read(baseAddr + 0x5718); if (doSet) { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - internalShadowSampleNumHQ = MemoryUtil.Read(baseAddr + 0xE5CC); - MemoryUtil.WriteBytes(baseAddr + 0xE5CC, BitConverter.GetBytes(16)); - 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) == 0x1; - internalSSAOParams.ssaoEdgeAttenRate = MemoryUtil.Read(baseAddr + 0xB4DC); if (ssaoAdjustments) { - setSSAOAdjustements(true); - } - internalSSRParams.sslrLoopCount = MemoryUtil.Read(baseAddr + 0xE628); - internalSSRParams.sslrLoopCountFactorForCBR = MemoryUtil.Read(baseAddr + 0xE62C); - internalSSRParams.sslrEliminateDepth = MemoryUtil.Read(baseAddr + 0xE630); - internalSSRParams.sslrAccurateThreshold = MemoryUtil.Read(baseAddr + 0xE644); - internalSSRParams.sslrAccurateThresholdHQ = MemoryUtil.Read(baseAddr + 0xE64C); - internalSSRParams.sslrDitherRadius = MemoryUtil.Read(baseAddr + 0xE634); - internalSSRParams.sslrImportanceBias = MemoryUtil.Read(baseAddr + 0xE638); - internalSSRParams.sslrMipScale = MemoryUtil.Read(baseAddr + 0xE63C); - internalSSRParams.sslrMipBias = MemoryUtil.Read(baseAddr + 0xE640); - internalSSRParams.sslrDitherResolve = MemoryUtil.Read(baseAddr + 0xB43F) == 0x1; - internalSSRParams.sslrEdgeAttenRate = MemoryUtil.Read(baseAddr + 0xB428); - internalSSRParams.sslrMip0CountThreshold = MemoryUtil.Read(baseAddr + 0xB438); - internalSSRParams.sslrDepthEliminateRate = MemoryUtil.Read(baseAddr + 0xB42C); - internalSSRParams.sslrUseMipmap = MemoryUtil.Read(baseAddr + 0xE650) == 0x1; - internalSSRParams.sslrGBufferJitter = MemoryUtil.Read(baseAddr + 0xB440) == 0x1; + setSSAOAdjustements(true, ssaoB); + } if (ssrAdjustments) { setSSRAdjustements(true); } setHQMode(enableHQMode); - internalSnowField4GlobalLODParam = MemoryUtil.Read(baseAddr + 0x5718); if (applyLODFactors) { setLODFactors(true); @@ -2017,16 +2163,16 @@ namespace MHWNewCamera private void setPerspectivePreset(Config.Preset preset) { - cameraFov = preset.FOV; + cameraFov = preset.FieldOfView; cameraForward = preset.Forward; cameraRight = preset.Right; cameraXOffset = 0.0f; cameraYOffset = preset.Up; cameraZOffset = 0.0f; cameraRoll = preset.Roll; - if (preDetachRoll != null) + if (restoreRoll != null) { - preDetachRoll = cameraRoll; + restoreRoll = cameraRoll; } disableFading = preset.DisableFading; if (pCameraViewportIndex >= 0) @@ -2063,8 +2209,9 @@ namespace MHWNewCamera b2 = freeCameraCombo[1]; if (disableComboButton1 && comboButton1Down) { + uint b1u = (uint)b1; PadDown = MemoryUtil.Read(controllerAddr() + 0x198); - PadDown |= (uint)b1; + PadDown |= b1u; MemoryUtil.WriteBytes(controllerAddr() + 0x198, BitConverter.GetBytes(PadDown)); } } @@ -2171,7 +2318,10 @@ namespace MHWNewCamera for (selectedIndex = 0; selectedIndex < presetKeys.Count; selectedIndex++) { string presetKey = presetKeys.ElementAt(selectedIndex); - if (presetKey == config.Selected) break; + if (presetKey == config.Selected) + { + break; + } } selectedIndex += presetSelect; if (selectedIndex >= presetKeys.Count) @@ -2305,24 +2455,23 @@ namespace MHWNewCamera player.Position = new Vector3(cameraPosition.X, cameraPosition.Y - 150.0f, cameraPosition.Z); } } + + if (buttonWasPressed(Button.Left)) + { + toggleFreezeGame(); + } } if (buttonWasDown(Button.Share)) { - /* if (buttonWasPressed(Button.Cross)) { - uiToggled = !uiToggled; - if (uiToggled) - { - jmpOverUi.Enable(); - } - else + ssaoB = !ssaoB; + if (ssaoAdjustments) { - jmpOverUi.Disable(); + setSSAOAdjustements(ssaoAdjustments, ssaoB); } } - */ if (buttonWasPressed(Button.Circle)) { @@ -2337,12 +2486,9 @@ namespace MHWNewCamera } } } - else + else if (freeCameraFromViewMode && buttonWasPressed(Button.Circle)) { - if (buttonWasPressed(Button.Circle)) - { - enableFreeCamera = false; - } + enableFreeCamera = false; } } } @@ -2382,26 +2528,104 @@ namespace MHWNewCamera Player? player = Player.MainPlayer; if (enableCrawl && player != null) { - procEnvironmentCollision.Invoke(player.Instance, psuedoObject1); - procEnvironmentCollision.Invoke(player.Instance, psuedoObject2); + nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); + if (controlsAddr != 0x0) + { + bool combatControls = MemoryUtil.Read(controlsAddr + 0xB18) == 0x80; + if (combatControls) + { + procEnvironmentCollision.Invoke(player.Instance, psuedoObject1); + procEnvironmentCollision.Invoke(player.Instance, psuedoObject2); + } + else + { + enableCrawl = false; + } + } } collisionCheckHook!.Original(unknownPtr, unknownPtr2); } + /* + private void SetLODLimitsHook(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); + } + } + */ + + private void toggleFreezeGame() + { + freezeGame = !freezeGame; + if (freezeGame) + { + motionBlurWasDisabled = motionBlurDisabled; + motionBlurDisabled = true; + } + else + { + motionBlurDisabled = motionBlurWasDisabled; + } + MemoryUtil.WriteBytes(sMain.Instance + 0xA4, BitConverter.GetBytes(freezeGame ? 0.0f : 1.0f)); + } + + private void MotionBlurHook(nint unknownPtr, nint unknownPtr2) + { + if (disableMod) + { + motionBlurHook!.Original(unknownPtr, unknownPtr2); + return; + } + +#if HOOK_ORDER_ASSERTS + debugLog($"MotionBlurHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); +#endif + + if (motionBlurDisabled) + { + MemoryUtil.WriteBytes(unknownPtr + 0x184, BitConverter.GetBytes(0.0f)); + } + + motionBlurHook!.Original(unknownPtr, unknownPtr2); + } + private void UnderwaterCheckHook(nint unknownPtr) { underwaterCheckHook!.Original(unknownPtr); - if (disableMod) return; + + if (disableMod || !enableUnderwaterCamera) + { + return; + } + #if HOOK_ORDER_ASSERTS debugLog($"UnderwaterCheckHook({unknownPtr:x}) @ {frameTick}"); #endif + cameraIsUnderwater = MemoryUtil.Read(unknownPtr + 0x1E83) == 0x1; } private void CameraEffectHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3) { - if (disableMod) + if (disableMod || !enableUnderwaterCamera) { cameraEffectHook!.Original(unknownPtr, unknownPtr2, unknownPtr3); return; @@ -2441,6 +2665,23 @@ namespace MHWNewCamera } } + private void FXAAHook(nint unknownPtr, nint unknownPtr2) + { + if (disableMod) + { + fxaaHook!.Original(unknownPtr, unknownPtr2); + return; + } + +#if HOOK_ORDER_ASSERTS + debugLog($"FXAAHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); +#endif + + fxaaPointer = unknownPtr; + + fxaaHook!.Original(unknownPtr, unknownPtr2); + } + private void disableAllCollisionHooks() { if (disableExtraGravity) @@ -2465,17 +2706,32 @@ namespace MHWNewCamera } } - private static void drawRenderParameter(string name, nint baseAddr, nint offset) where T : unmanaged + private static T drawRenderParameter(string name, nint baseAddr = 0x0, nint offset = 0x0, bool zeroToOne = false) where T : unmanaged { nint addr = baseAddr + offset; - T currentValue = MemoryUtil.Read(addr); + T? currentValue = null; + if (currentValue == null) + { + currentValue = MemoryUtil.Read(addr); + } if (typeof(T) == typeof(float)) { float valueF = Convert.ToSingle(currentValue); - if (ImGui.InputFloat(name, ref valueF, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + if (zeroToOne) + { + if (ImGui.DragFloat(name, ref valueF, 0.01f, 0.0f, 1.0f, "%.6f")) + { + MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueF)); + } + } + else { - MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueF)); + if (ImGui.InputFloat(name, ref valueF, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + { + MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueF)); + } } + return (T)Convert.ChangeType(valueF, typeof(T)); } else if (typeof(T) == typeof(int)) { @@ -2484,6 +2740,7 @@ namespace MHWNewCamera { MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueI)); } + return (T)Convert.ChangeType(valueI, typeof(T)); } else if (typeof(T) == typeof(byte)) { @@ -2492,6 +2749,30 @@ namespace MHWNewCamera { MemoryUtil.WriteBytes(addr, valueSwitch ? [0x1] : [0x0]); } + return (T)Convert.ChangeType(valueSwitch, typeof(T)); + } + return (T)currentValue; + } + + private static void inputSSAOParameters(SSAOParameters? parameters, nint baseAddr) + { + if (parameters == null) + { + drawRenderParameter("SSAO Depth Bias", baseAddr, 0xB4B0); + drawRenderParameter("SSAO Sloped Depth Bias", baseAddr, 0xB4B4); + drawRenderParameter("SSAO Max Depth Bias", baseAddr, 0xB4B8); + drawRenderParameter("SSAO Dispersion", baseAddr, 0xB4BC); + drawRenderParameter("SSAO Effect", baseAddr, 0xB430); + drawRenderParameter("SSAO Effect GI", baseAddr, 0xB434); + drawRenderParameter("SSAO Depth Difference", baseAddr, 0xB4C0); + drawRenderParameter("SSAO Samples Per Pixel", baseAddr, 0xB4C4); + drawRenderParameter("SSAO Max Sample Num", baseAddr, 0xB4C8); + drawRenderParameter("SSAO Max Sample Num HQ", baseAddr, 0xB4D0); + drawRenderParameter("SSAO Radius", baseAddr, 0xB4D4); + drawRenderParameter("SSAO Bias", baseAddr, 0xB4D8); + drawRenderParameter("SSAO Intensity", baseAddr, 0xB4E0); + drawRenderParameter("SSAO Use HiZ", baseAddr, 0xB4E5); + drawRenderParameter("SSAO Edge Atten Rate", baseAddr, 0xB4DC); } } @@ -2521,7 +2802,7 @@ namespace MHWNewCamera Camera camera = vp.Camera; bool usedByFreeCamera = freeCamera && enableFreeCamera && camera == vCamera; if (debug) ImGui.Text($"Camera Pointer: {camera.Instance:x}"); - if (ImGui.DragFloat("FOV", ref camera.FieldOfView, 0.1f)) + if (ImGui.DragFloat("Field of View", ref camera.FieldOfView, 0.1f)) { if (usedByFreeCamera) { @@ -2539,15 +2820,8 @@ namespace MHWNewCamera } if (debug) ImGui.InputFloat("Aspect Ratio", ref camera.AspectRatio); ImGui.InputFloat("Near Clip", ref camera.NearClip); - if (ImGui.DragFloat("Alternate Near Clip", ref alternateNearClip, 0.05f)) - { - if (camera.NearClip != DEFAULT_NEAR_CLIP) - { - camera.NearClip = alternateNearClip; - } - } - ImGui.InputFloat("Far Clip", ref camera.FarClip); - if (usedByFreeCamera) + ImGui.InputFloat("Far Clip", ref camera.FarClip); + if (usedByFreeCamera) { ImGui.DragFloat3("Position", ref cameraPosition, 0.425f); } @@ -2565,7 +2839,8 @@ namespace MHWNewCamera string name = typedPositionName; if (name != "") { - Config.SavedPosition pos = new Config.SavedPosition(); + Config.Position pos = new Config.Position(); + pos.FieldOfView = camera.FieldOfView; pos.PosX = camera.Position.X; pos.PosY = camera.Position.Y; pos.PosZ = camera.Position.Z; @@ -2587,7 +2862,7 @@ namespace MHWNewCamera ImGui.SameLine(); if (ImGui.BeginCombo("##Positions", selectedPositionName)) { - Dictionary.KeyCollection positionKeys = config.Positions.Keys; + Dictionary.KeyCollection positionKeys = config.Positions.Keys; for (int j = 0; j < positionKeys.Count + 1; j++) { if (j == 0) @@ -2601,8 +2876,9 @@ namespace MHWNewCamera string positionKey = positionKeys.ElementAt(j - 1); if (ImGui.Selectable(positionKey)) { - Config.SavedPosition pos = config.Positions[positionKey]; + Config.Position pos = config.Positions[positionKey]; selectedPositionName = positionKey; + camera.FieldOfView = pos.FieldOfView; cameraPosition = new Vector3(pos.PosX, pos.PosY, pos.PosZ); cameraTarget = new Vector3(pos.TargetX, pos.TargetY, pos.TargetZ); Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget)); @@ -2740,7 +3016,7 @@ namespace MHWNewCamera } if (ssaoAdjustments) { - setSSAOAdjustements(false); + setSSAOAdjustements(false, ssaoB); } if (ssrAdjustments) { @@ -2800,7 +3076,7 @@ namespace MHWNewCamera } if (ssaoAdjustments) { - setSSAOAdjustements(true); + setSSAOAdjustements(true, ssaoB); } if (ssrAdjustments) { @@ -2887,7 +3163,10 @@ namespace MHWNewCamera ImGui.Text("Try to disable as much as possible."); ImGui.EndTooltip(); } - if (disableMod) return; + if (disableMod) + { + return; + } ImGui.Separator(); @@ -2922,9 +3201,9 @@ namespace MHWNewCamera if (ImGui.DragFloat("Roll", ref roll, 0.25f)) { cameraRoll = roll; - if (preDetachRoll != null) + if (restoreRoll != null) { - preDetachRoll = roll; + restoreRoll = roll; } } if (freeCamera) @@ -2958,9 +3237,9 @@ namespace MHWNewCamera cameraYOffset = 0.0f; cameraZOffset = 0.0f; cameraRoll = 0.0; - if (preDetachRoll != null) + if (restoreRoll != null) { - preDetachRoll = cameraRoll; + restoreRoll = cameraRoll; } disableFading = false; if (pCameraViewportIndex >= 0) @@ -2981,7 +3260,7 @@ namespace MHWNewCamera if (name != "") { Config.Preset preset = new Config.Preset(); - preset.FOV = cameraFov; + preset.FieldOfView = cameraFov; preset.Forward = cameraForward; preset.Right = cameraRight; preset.Up = cameraYOffset; @@ -3032,25 +3311,25 @@ namespace MHWNewCamera ImGui.PushID("Settings"); ImGui.PushItemWidth(width * 0.575f); - ImGui.DragFloat("Camera Speed", ref cameraSpeed, 0.01f, 0.0f); + ImGui.DragFloat("Camera Speed", ref cameraSpeed, 0.01f, 0.0f, 0.0f, "%.4f"); if (ImGui.BeginItemTooltip()) { ImGui.Text("Movement speed in free camera."); ImGui.EndTooltip(); } - ImGui.DragFloat("Speed Modifier", ref cameraSpeedModifier, 0.01f, 0.0f); + ImGui.DragFloat("Speed Modifier", ref cameraSpeedModifier, 0.01f, 0.0f, 0.0f, "%.4f"); if (ImGui.BeginItemTooltip()) { ImGui.Text("Value to multiply speed by when LT is held."); ImGui.EndTooltip(); } - ImGui.DragFloat("Camera Sensitivity", ref cameraSensitivity, 0.001f, 0.0f); + ImGui.DragFloat("Camera Sensitivity", ref cameraSensitivity, 0.001f, 0.0f, 0.0f, "%.4f"); if (ImGui.BeginItemTooltip()) { ImGui.Text("Look sensitivity in free camera."); ImGui.EndTooltip(); } - ImGui.DragFloat("Zoom Speed", ref cameraZoomSpeed, 0.01f, 0.0f); + ImGui.DragFloat("Zoom Speed", ref cameraZoomSpeed, 0.01f, 0.0f, 0.0f, "%.4f"); float pitchLimit = (float)cameraPitchLimit; if (ImGui.InputFloat("Pitch Limit", ref pitchLimit, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) { @@ -3067,6 +3346,7 @@ namespace MHWNewCamera } ImGui.DragInt("Stick Deadzone", ref stickDeadzone, 5, 0); ImGui.PopItemWidth(); + /* if (ImGui.Button("Default")) { cameraSpeed = Config.Settings.DEFAULT_SPEED; @@ -3075,29 +3355,32 @@ namespace MHWNewCamera cameraZoomSpeed = Config.Settings.DEFAULT_ZOOM_SPEED; cameraPitchLimit = Config.Settings.DEFAULT_PITCH_LIMIT; stickDeadzone = Config.Settings.DEFAULT_DEADZONE; + alternateNearClip = Config.Settings.DEFAULT_ALT_NEAR_CLIP; } ImGui.SameLine(); + */ if (ImGui.Button("Reset")) { - Config.Settings settings = config.CameraSettings; - cameraSpeed = settings.CameraSpeed; - cameraSpeedModifier = settings.CameraSpeedModifier; - cameraSensitivity = settings.CameraSensitivity; - cameraZoomSpeed = settings.CameraZoomSpeed; - cameraPitchLimit = settings.CameraPitchLimit; - stickDeadzone = settings.StickDeadzone; + Config.Settings camera = config.Camera; + cameraSpeed = camera.Speed; + cameraSpeedModifier = camera.SpeedModifier; + cameraSensitivity = camera.Sensitivity; + cameraZoomSpeed = camera.ZoomSpeed; + cameraPitchLimit = camera.PitchLimit; + stickDeadzone = camera.StickDeadzone; + alternateNearClip = camera.AlternateNearClip; } ImGui.SameLine(); if (ImGui.Button("Save")) { - Config.Settings settings = config.CameraSettings; - settings.CameraSpeed = cameraSpeed; - settings.CameraSpeedModifier = cameraSpeedModifier; - settings.CameraSensitivity = cameraSensitivity; - settings.CameraZoomSpeed = cameraZoomSpeed; - settings.CameraPitchLimit = cameraPitchLimit; - settings.StickDeadzone = stickDeadzone; - config.CameraSettings = settings; + Config.Settings camera = config.Camera; + camera.Speed = cameraSpeed; + camera.SpeedModifier = cameraSpeedModifier; + camera.Sensitivity = cameraSensitivity; + camera.ZoomSpeed = cameraZoomSpeed; + camera.PitchLimit = cameraPitchLimit; + camera.StickDeadzone = stickDeadzone; + config.Camera = camera; ConfigManager.SaveConfig(this); } ImGui.PopID(); @@ -3106,6 +3389,7 @@ namespace MHWNewCamera ImGui.PushID("Toggles"); ImGui.Text("Toggles"); + if (ImGui.Checkbox("Disable UI", ref uiToggled)) { if (uiToggled) @@ -3119,35 +3403,22 @@ namespace MHWNewCamera } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Hold Select + Press A. The scoutfly marker on menus will still be visible."); + ImGui.Text("The scoutfly marker on menus will still be visible."); ImGui.EndTooltip(); } if (!freeCamera) { ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); } + ImGui.SameLine(); ImGui.Checkbox("Unlock Input", ref unlockInputToggled); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Hold RT + RB, Release Either."); - ImGui.EndTooltip(); - } ImGui.Checkbox("Unlock Player Movement", ref unlockMovementToggled); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Hold RT + Press LB."); - ImGui.EndTooltip(); - } ImGui.Checkbox("Lock Vertical Movement and Apply Speed Modifier", ref lockVerticalToggled); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Hold LT + Press LB."); - ImGui.EndTooltip(); - } if (!freeCamera) { ImGui.PopStyleVar(); } + if (ImGui.Checkbox("Disable Depth of Field", ref dofDisabled)) { if (dofDisabled) @@ -3161,28 +3432,71 @@ namespace MHWNewCamera } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Hold Select + Press B. Works to disable depth of field in cutscenes."); + ImGui.Text("Works to disable depth of field in cutscenes."); + ImGui.EndTooltip(); + } + ImGui.SameLine(); + float alignCursorX = ImGui.GetCursorPosX(); + ImGui.Checkbox("Disable Motion Blur", ref motionBlurDisabled); + if (!ssaoAdjustments) + { + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Checkbox("Disable SSAO", ref ssaoB)) + { + if (ssaoAdjustments) + { + setSSAOAdjustements(ssaoAdjustments, ssaoB); + } + } + if (!ssaoAdjustments) + { + ImGui.PopStyleVar(); + } + if (ImGui.BeginItemTooltip()) + { + if (!ssaoAdjustments) + { + ImGui.Text("Enable SSAO Adjustments under Graphical Tweaks for this to apply."); + } + else + { + ImGui.Text("Currently doesn't work in cutscenes."); + } ImGui.EndTooltip(); } if (vCamera != null) { - bool reducedNearClip = vCamera.NearClip != DEFAULT_NEAR_CLIP; - if (ImGui.Checkbox("Reduce Near Clip", ref reducedNearClip)) + ImGui.SameLine(); + ImGui.SetCursorPosX(alignCursorX); + ImGui.PushItemWidth(width * 0.125f); + bool altNearClipSet = guessAltNearClipSet(vCamera); + if (ImGui.Checkbox("Alternate Near Clip", ref altNearClipSet)) + { + setNearClip(vCamera, altNearClipSet); + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Allows you to get the camera closer to things without clipping but breaks some rendering farther from the camera."); + ImGui.EndTooltip(); + } + ImGui.SameLine(); + if (ImGui.DragFloat("##Alternate Near Clip", ref alternateNearClip, 0.05f, 0.001f, 0.0f)) { - if (reducedNearClip) + if (altNearClipSet) { vCamera.NearClip = alternateNearClip; } - else - { - vCamera.NearClip = DEFAULT_NEAR_CLIP; - } } - if (ImGui.BeginItemTooltip()) + ImGui.SameLine(); + if (ImGui.Button("Save")) { - ImGui.Text("Hold Select + Press X. Allows you to get the camera closer to things without clipping but breaks rendering farther from the camera."); - ImGui.EndTooltip(); + Config.Settings camera = config.Camera; + camera.AlternateNearClip = alternateNearClip; + config.Camera = camera; + ConfigManager.SaveConfig(this); } + ImGui.PopItemWidth(); } ImGui.PopID(); @@ -3191,7 +3505,7 @@ namespace MHWNewCamera ImGui.Text("When Close to the Camera"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("These are temporary to being in free camera. Set \"Disable Fading\" in the camera settings above for them to persist."); + ImGui.Text("Set Disable Fading in the camera preset above for these to persist."); ImGui.EndTooltip(); } if (vCameraViewportIndex >= 0) @@ -3222,12 +3536,14 @@ namespace MHWNewCamera { if (ImGui.Checkbox("Toggle Free Camera", ref enableCombo)) { - config.EnableCombo = enableCombo; + Config.Settings.Binds binds = config.Binds; + binds.EnableCombo = enableCombo; + config.Binds = binds; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Hold the first button and press the second."); + ImGui.Text("Hold the first button (Button1) then press the second (Button2)."); ImGui.EndTooltip(); } ImGui.SameLine(); @@ -3243,7 +3559,7 @@ namespace MHWNewCamera } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Form: \"RT+LB\", \"R3+L2\", \"A+LStick\", \"Up+RT\", \"Cross+Triangle\", etc."); + ImGui.Text("Form: RT+LB, R3+L2, A+LStick, Up+RT, Cross+Triangle, etc."); ImGui.EndTooltip(); } ImGui.PopItemWidth(); @@ -3254,123 +3570,168 @@ namespace MHWNewCamera freeCameraCombo = Config.ParseCombo(comboString); if (freeCameraCombo != null) { - config.FreeCameraCombo = comboString; + Config.Settings.Binds binds = config.Binds; + binds.FreeCameraCombo = comboString; + config.Binds = binds; ConfigManager.SaveConfig(this); } } ImGui.SameLine(); - if (ImGui.Checkbox("Disable Button 1 Unless Button 2 is Held", ref disableComboButton1)) + if (ImGui.Checkbox("Disable Button1 Unless Button2 is Held", ref disableComboButton1)) { comboButton1Down = false; - config.DisableComboButton1UnlessButton2Held = disableComboButton1; + Config.Settings.Binds binds = config.Binds; + binds.DisableComboButton1UnlessButton2Held = disableComboButton1; + config.Binds = binds; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("For example, if bound to \"RStick+LT\", right stick presses will ignored by the game unless you're holding the left trigger.\nIn that case, it can let you avoid switching the targeted monster when toggling free camera."); + ImGui.Text("For example, if bound to RStick+LT, right stick presses will ignored by the game unless you're holding the left trigger.\nIn that case, it can let you avoid switching the targeted monster when toggling free camera."); ImGui.EndTooltip(); } - ImGui.Text("While in Free Camera"); + + ImGui.Text("Global"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("Set Camera Mouse Controls to Off in Options -> Camera for a better experience."); + ImGui.Text("Button1 refers to the first button of the Toggle Free Camera bind."); ImGui.EndTooltip(); } - if (ImGui.BeginTable("Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders)) + if (ImGui.BeginTable("Global Binds", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold RT (+ Press LB; Toggle)"); + ImGui.Text("Hold Button1 + Press LB"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Unlock Player Movement and Freeze Camera Movement"); + ImGui.Text("Toggle UI"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold LT (+ Press LB; Toggle)"); + ImGui.Text("Hold Button1 + Press D-Pad Up/Down"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Lock Vertical Camera Movement and Apply Speed Modifier"); + ImGui.Text("Select Perspective Camera Preset"); + + ImGui.EndTable(); + } + ImGui.Text("While in Free Camera | ( ) = Toggle"); + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Set Camera Mouse Controls to Off in Options -> Camera for a better experience."); + ImGui.EndTooltip(); + } + if (ImGui.BeginTable("Binds", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) + { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold RT + RB, Release Either"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Can effectively be treated as press RT + RB, but you probably want to press RT first in you're on a menu."); - ImGui.EndTooltip(); - } + ImGui.Text("Hold Button1 + Press RB"); ImGui.TableSetColumnIndex(1); ImGui.Text("Toggle Unlock Input"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("Applies to every controller input except left stick player movement."); + ImGui.Text("Attempts to apply to every controller input except left stick player movement."); ImGui.EndTooltip(); } + + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(0); + ImGui.Text("Hold RT (+ Press LB)"); + ImGui.TableSetColumnIndex(1); + ImGui.Text("Unlock Player Movement and Freeze Camera Movement"); + + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(0); + ImGui.Text("Hold LT (+ Press LB)"); + ImGui.TableSetColumnIndex(1); + ImGui.Text("Lock Vertical Camera Movement and Apply Speed Modifier"); + ImGui.EndTable(); } + ImGui.Text("Disabled While Input to the Game is Unlocked"); - if (ImGui.BeginTable("More Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders)) + if (ImGui.BeginTable("More Binds", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Select + Press A"); + ImGui.Text("D-Pad Up/Down"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Toggle UI"); + ImGui.Text("Translate Camera Up/Down"); + + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(0); + ImGui.Text("D-Pad Left/Right"); + ImGui.TableSetColumnIndex(1); + ImGui.Text("Roll Camera"); + + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(0); + ImGui.Text("Hold LT + RT"); + ImGui.TableSetColumnIndex(1); + ImGui.Text("Zoom with Left Stick Up/Down"); + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("If you have Depth of Field enabled in Advanced Graphics Settings, this will also move the focal point."); + ImGui.EndTooltip(); + } + + ImGui.TableNextRow(); + ImGui.TableSetColumnIndex(0); + ImGui.Text("Hold Select"); + ImGui.TableSetColumnIndex(1); + ImGui.Text(""); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Select + Press B"); + ImGui.Text(" + Press B"); ImGui.TableSetColumnIndex(1); ImGui.Text("Toggle Depth of Field"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Select + Press X"); + ImGui.Text(" + Press A"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Toggle Reduced Near Clip (16.0 -> 0.5)"); + ImGui.Text("Toggle SSAO"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("D-Pad Up/Down"); + ImGui.Text(" + Press X"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Translate Camera Up/Down"); + ImGui.Text("Toggle Alternate Near Clip"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("D-Pad Left/Right"); + ImGui.Text("Hold Y"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Roll Camera"); + ImGui.Text(""); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Y + Press D-Pad Left/Right"); + ImGui.Text(" + Press D-Pad Right"); ImGui.TableSetColumnIndex(1); ImGui.Text("Reset Roll"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold LT + RT"); + ImGui.Text(" + Press D-Pad Up"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Zoom with Left Stick Up/Down"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("If you have DOF (Depth of Field) enabled in Advanced Graphics Settings, this will also move the focal point."); - ImGui.EndTooltip(); - } + ImGui.Text("Reset Zoom"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Y + Press D-Pad Up"); + ImGui.Text(" + Press D-Pad Left"); ImGui.TableSetColumnIndex(1); - ImGui.Text("Reset Zoom"); + ImGui.Text("Toggle Freeze Game"); ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); - ImGui.Text("Hold Y + Press D-Pad Down"); + ImGui.Text(" + Press D-Pad Down"); ImGui.TableSetColumnIndex(1); ImGui.Text("Teleport Player to Camera Position"); ImGui.EndTable(); } + + ImGui.Separator(); } ImGui.PopID(); @@ -3380,13 +3741,17 @@ namespace MHWNewCamera { if (ImGui.Checkbox("Enable Keyboard", ref keyboardEnabled)) { - config.EnableKeyboard = keyboardEnabled; + Config.Settings.Binds binds = config.Binds; + binds.EnableKeyboard = keyboardEnabled; + config.Binds = binds; ConfigManager.SaveConfig(this); } - ImGui.PushItemWidth(width * 0.20f); + ImGui.PushItemWidth(width * 0.2f); if (ImGui.DragInt("Keyboard Look Sensitivity", ref keyboardLookValue, 20, 0, Int16.MaxValue)) { - config.KeyboardLookSensitivity = keyboardLookValue; + Config.Settings.Binds binds = config.Binds; + binds.KeyboardLookSensitivity = keyboardLookValue; + config.Binds = binds; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3395,7 +3760,7 @@ namespace MHWNewCamera ImGui.EndTooltip(); } ImGui.PopItemWidth(); - if (ImGui.BeginTable("Keyboard Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders)) + if (ImGui.BeginTable("Keyboard Binds", 2, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); @@ -3453,74 +3818,240 @@ namespace MHWNewCamera ImGui.EndTable(); } + + ImGui.Separator(); } ImGui.PopID(); #endif - ImGui.PushID("World"); - if (ImGui.CollapsingHeader("World")) + ImGui.PushID("Viewport"); + if (ImGui.CollapsingHeader("Viewport") && vCameraViewportIndex >= 0) { - nint timeAddr = MemoryUtil.Read(sMain.Instance + 0xAF878); - float gameTime = MemoryUtil.Read(timeAddr + 0x38); - if (ImGui.SliderFloat("Time of Day", ref gameTime, 0.0f, 24.0f)) + drawViewportInfo(vCameraViewportIndex, width, config, false); + ImGui.Separator(); + } + ImGui.PopID(); + + ImGui.PushID("Player"); + if (ImGui.CollapsingHeader("Player") && player != null) + { + nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); + nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); + bool combatControls = false; + if (controlsAddr != 0x0 || zoneStateAddr == 0x0) { - MemoryUtil.WriteBytes(timeAddr + 0x38, BitConverter.GetBytes(gameTime)); +#if QUARANTINED_FEATURES + 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]); + } +#else + bool passiveMode = MemoryUtil.Read(player.Instance + 0x7626) == 1; + if (ImGui.Checkbox("Passive", ref passiveMode)) + { + MemoryUtil.WriteBytes(player.Instance + 0x7626, passiveMode ? [0x1] : [0x0]); + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Passive: Calm camera and your hunter looks neutral/smiles.\nCombat: Intense camera and your hunter looks angry."); + ImGui.EndTooltip(); + } +#endif + combatControls = MemoryUtil.Read(controlsAddr + 0xB18) == 0x80; +#if QUARANTINED_FEATURES + 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]); + } +#endif } - float gameSpeed = MemoryUtil.Read(sMain.Instance + 0xA4); - if (ImGui.InputFloat("Game Speed", ref gameSpeed, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) + ImGui.Checkbox("Hide Weapon", ref hideWeapon); + + if (!combatControls) { - MemoryUtil.WriteBytes(sMain.Instance + 0xA4, BitConverter.GetBytes(gameSpeed)); + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); } - if (ImGui.Checkbox("Override View Mode", ref overrideViewMode)) + if (ImGui.Checkbox("Force Crawl", ref enableCrawl)) { - config.OverrideViewMode = overrideViewMode; - ConfigManager.SaveConfig(this); + 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)); + } } - if (ImGui.BeginItemTooltip()) + if (!combatControls) { - ImGui.Text("Replace in-game \"View Mode\" with the free camera from this mod."); - ImGui.EndTooltip(); + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); } - if (ImGui.Checkbox("Underwater Camera", ref enableUnderwaterCamera)) + if (ImGui.BeginItemTooltip()) { - if (enableUnderwaterCamera) + if (!combatControls) { - underwaterCameraEnable(); + ImGui.Text("You have to be out in a map to use this."); } else { - underwaterCameraDisable(); + ImGui.Text("Simulate crawling under an object in the direction your character was facing when enabled."); } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Trigger underwater screen filter when the camera goes underwater."); ImGui.EndTooltip(); } - } - ImGui.PopID(); - ImGui.PushID("Player"); - if (ImGui.CollapsingHeader("Player") && player != null) - { - ImGui.DragFloat3("Position", ref player.Position, 0.5f); - Vector3 forward; - forward.X = player.Forward.X; - forward.Y = player.Forward.Y; - forward.Z = player.Forward.Z; - ImGui.DragFloat3("Forward", ref forward, 0.0f); - Vector4 rotation; - rotation.X = player.Rotation.X; - rotation.Y = player.Rotation.Y; - rotation.Z = player.Rotation.Z; - rotation.W = player.Rotation.W; - if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f)) + if (combatControls) { - player.Rotation.X = rotation.X; - player.Rotation.Y = rotation.Y; - player.Rotation.Z = rotation.Z; - player.Rotation.W = rotation.W; - } + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + 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 (combatControls) + { + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("You have to be in a hub area to use this."); + ImGui.EndTooltip(); + } + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + } + + 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(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("It will take a couple of seconds to fade away."); + ImGui.EndTooltip(); + } + + if (ImGui.CollapsingHeader("Wetness")) + { + nint wetnessAddr = player.Instance + 0x13BD0; + ImGui.PushItemWidth(width * 0.3f); + if (ImGui.DragFloat("Whole Body", ref wholeBodyWetness, 0.005f)) + { + if (applyCharacterWetness) + { + MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(wholeBodyWetness)); + } + } + float headWetness = MemoryUtil.Read(wetnessAddr); + if (ImGui.DragFloat("Head", ref headWetness, 0.005f)) + { + MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(headWetness)); + } + float bodyWetness = MemoryUtil.Read(wetnessAddr + 0x28); + if (ImGui.DragFloat("Body", ref bodyWetness, 0.005f)) + { + MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(bodyWetness)); + } + float waistWetness = MemoryUtil.Read(wetnessAddr + 0x50); + if (ImGui.DragFloat("Waist", ref waistWetness, 0.005f)) + { + MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(waistWetness)); + } + float legsWetness = MemoryUtil.Read(wetnessAddr + 0x78); + if (ImGui.DragFloat("Legs", ref legsWetness, 0.005f)) + { + MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(legsWetness)); + } + ImGui.PopItemWidth(); + if (ImGui.Checkbox("Override Player Wetness", ref applyCharacterWetness)) + { + if (applyCharacterWetness) + { + noopCharacterWetnessUpdate.Enable(); + } + else + { + noopCharacterWetnessUpdate.Disable(); + } + MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(wholeBodyWetness)); + MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(wholeBodyWetness)); + } + } + + ImGui.DragFloat3("Position", ref player.Position, 0.5f); + Vector3 forward; + forward.X = player.Forward.X; + forward.Y = player.Forward.Y; + forward.Z = player.Forward.Z; + ImGui.DragFloat3("Forward", ref forward, 0.0f); + Vector4 rotation; + rotation.X = player.Rotation.X; + rotation.Y = player.Rotation.Y; + rotation.Z = player.Rotation.Z; + rotation.W = player.Rotation.W; + if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f)) + { + player.Rotation.X = rotation.X; + player.Rotation.Y = rotation.Y; + player.Rotation.Z = rotation.Z; + player.Rotation.W = rotation.W; + } if (ImGui.Button("Reset")) { player.Rotation.X = 0.0f; @@ -3646,115 +4177,62 @@ namespace MHWNewCamera ImGui.PopStyleVar(); } - nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); - nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); - bool combatControls = false; - 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]); - } - 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)); + ImGui.Separator(); + } + ImGui.PopID(); - 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.PushID("World"); + if (ImGui.CollapsingHeader("World")) + { + nint timeAddr = MemoryUtil.Read(sMain.Instance + 0xAF878); + float gameTime = MemoryUtil.Read(timeAddr + 0x38); + if (ImGui.SliderFloat("Time of Day", ref gameTime, 0.0f, 24.0f)) + { + MemoryUtil.WriteBytes(timeAddr + 0x38, BitConverter.GetBytes(gameTime)); } - if (combatControls) + ImGui.PushItemWidth(width * 0.125f); + float gameSpeed = MemoryUtil.Read(sMain.Instance + 0xA4); + if (ImGui.DragFloat("Game Speed", ref gameSpeed, 0.005f, 0.0f, Single.MaxValue)) { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + MemoryUtil.WriteBytes(sMain.Instance + 0xA4, BitConverter.GetBytes(gameSpeed)); } - if (ImGui.Button("Sit in Hot Springs")) + ImGui.SameLine(); + if (ImGui.Button("Toggle Freeze Game")) { - MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]); - MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]); + toggleFreezeGame(); } - if (combatControls) + ImGui.PopItemWidth(); + + if (ImGui.Checkbox("Override View Mode", ref overrideViewMode)) { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); + config.OverrideViewMode = overrideViewMode; + ConfigManager.SaveConfig(this); } - - if (ImGui.Checkbox("Allow Hot Springs Anywhere", ref allowHotSpringsAnywhere)) + if (ImGui.BeginItemTooltip()) { - if (allowHotSpringsAnywhere) - { - jmpOverHotSpringsEval.Enable(); - } - else - { - jmpOverHotSpringsEval.Disable(); - } + ImGui.Text("Replace in-game View Mode with the free camera from this mod."); + ImGui.EndTooltip(); } - if (ImGui.Checkbox("Disable Hot Springs Steam", ref disableHotSpringsSteam)) + if (ImGui.Checkbox("Underwater Camera", ref enableUnderwaterCamera)) { - if (disableHotSpringsSteam) + if (enableUnderwaterCamera) { - jmpOverHotSpringsSteam.Enable(); + underwaterCameraEnable(); } else { - jmpOverHotSpringsSteam.Disable(); + underwaterCameraDisable(); } } if (ImGui.BeginItemTooltip()) { - ImGui.Text("It will take a couple seconds to fade away."); + ImGui.Text("Trigger the diving screen filter when the camera goes underwater.\nWARNING: This is experimental, unfinished and known to crash in at least The Rotten Vale.\nIf you want to see the effect you can try it in the Seliana Gathering Hub, the Ancient Forest or your Private Suite."); ImGui.EndTooltip(); } - } - ImGui.PopID(); - ImGui.PushID("Viewport"); - if (ImGui.CollapsingHeader("Viewport") && vCameraViewportIndex >= 0) - { - drawViewportInfo(vCameraViewportIndex, width, config, false); + ImGui.Separator(); } ImGui.PopID(); @@ -3771,7 +4249,9 @@ namespace MHWNewCamera { tripleShadowResDisable(); } - config.TripleShadowResolution = tripleShadowRes; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.TripleShadowResolution = tripleShadowRes; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3779,17 +4259,66 @@ namespace MHWNewCamera ImGui.Text("In-Game Settings:\n - High: 1.0 -> 3.0\n - Mid: 0.7 -> 2.1\n - Low: 0.5 -> 1.5\nReload shadows by toggling Shadow Quality in Options -> Display -> Advanced Graphics Settings."); ImGui.EndTooltip(); } + ImGui.SameLine(); + if (!tripleShadowRes) + { + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Checkbox("Slightly Higher Value", ref slightlyHigherShadowValues)) + { + if (tripleShadowRes) + { + if (slightlyHigherShadowValues) + { + //shadowRes2.Disable(); + //shadowRes2_Upper.Enable(); + //shadowRes3.Disable(); + //shadowRes3_Upper.Enable(); + shadowRes4_3x.Disable(); + shadowRes4_Limit.Enable(); + } + else + { + //shadowRes2_Upper.Disable(); + //shadowRes2.Enable(); + //shadowRes3_Upper.Disable(); + //shadowRes3.Enable(); + shadowRes4_Limit.Disable(); + shadowRes4_3x.Enable(); + } + } + Config.GraphicalTweaks graphics = config.Graphics; + graphics.SlightlyHigherShadowValues = slightlyHigherShadowValues; + config.Graphics = graphics; + ConfigManager.SaveConfig(this); + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Set a value that used to be right below it's limit to it's limit.\nIf this doesn't cause crashes, it will become the default."); + ImGui.EndTooltip(); + } + if (!tripleShadowRes) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + } ImGui.PushItemWidth(width * 0.125f); + if (ImGui.Checkbox("##Apply Larger Shadow Range", ref applyShadowBias)) { - config.ApplyShadowRange = applyShadowBias; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.ApplyShadowRange = applyShadowBias; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } ImGui.SameLine(); if (ImGui.InputFloat("Shadow Range", ref shadowBiasOffset, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) { - config.ShadowRangeOffset = shadowBiasOffset; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.ShadowRangeOffset = shadowBiasOffset; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3797,27 +4326,35 @@ namespace MHWNewCamera ImGui.Text("This will inversely reduce the detail of shadows closer to the camera (like the player shadow), so it's a trade-off.\nValue is an offset. Recommended: 0.7."); ImGui.EndTooltip(); } + if (ImGui.Checkbox("##Apply Radius", ref applyShadowRadius)) { - config.ApplyShadowRadius = applyShadowRadius; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.ApplyShadowRadius = applyShadowRadius; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } ImGui.SameLine(); if (ImGui.InputFloat("Shadow Radius", ref shadowRadiusOffset, 0.0f, 0.0f, "%.5f", ImGuiInputTextFlags.EnterReturnsTrue)) { - config.ShadowRadiusOffset = shadowRadiusOffset; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.ShadowRadiusOffset = shadowRadiusOffset; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Size of a shadows border (to be softened if HQ Mode is enabled).\nValue is an offset. Recommended: -0.0001."); + ImGui.Text("Size of a shadows border (to be softened if HQ Mode is enabled).\nValue is an offset. Recommended: -0.0001 (if Shadow Range = 0.7)."); ImGui.EndTooltip(); } + ImGui.PopItemWidth(); if (ImGui.Checkbox("Higher Shadow Detail in Hoarfrost Reach/Seliana Gathering Hub", ref lowShadowDetailOverride)) { - config.HigherShadowDetailInHoarfrost = lowShadowDetailOverride; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.HigherShadowDetailInHoarfrost = lowShadowDetailOverride; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3828,24 +4365,45 @@ namespace MHWNewCamera if (ImGui.Checkbox("SSAO Adjustments", ref ssaoAdjustments)) { - setSSAOAdjustements(ssaoAdjustments); - config.SSAOAdjustments = ssaoAdjustments; + setSSAOAdjustements(ssaoAdjustments, ssaoB); + Config.GraphicalTweaks graphics = config.Graphics; + graphics.SSAOAdjustments = ssaoAdjustments; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Reduce Max Sample Num HQ because it tanks performance and set Dispersion to 1.75 to mitigate grid artifact."); + ImGui.EndTooltip(); + } if (ImGui.Checkbox("SSR Adjustments", ref ssrAdjustments)) { setSSRAdjustements(ssrAdjustments); - config.SSRAdjustments = ssrAdjustments; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.SSRAdjustments = ssrAdjustments; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Revert HQ value for Accurate Threshold because it looks off in many places and slightly increase Loop Count."); + ImGui.EndTooltip(); + } if (ImGui.Checkbox("HQ Mode", ref enableHQMode)) { setHQMode(enableHQMode); - config.EnableHQMode = enableHQMode; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.EnableHQMode = enableHQMode; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Enable built-in HQ Mode which increases a few parameters and enables HQ Shadows, referring to softened shadow edges.\nIt is not recommended to enable this without also enabling SSAO/SSR Adjustments above."); + ImGui.EndTooltip(); + } if (ImGui.Checkbox("Disable Player/Palico/NPC LOD Limit in Gameplay", ref disableLODLimits)) { @@ -3857,16 +4415,35 @@ namespace MHWNewCamera { disableLODLimitsDisable(); } - config.DisableLODLimits = disableLODLimits; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.DisableLODLimits = disableLODLimits; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("This will make the default (gameplay) LOD limits equivalent to View Mode. Disabling the limit on:\n - Player Models & Shadows\n - Palico Models & Shadows\n - NPC Models & Shadows\n - Simple NPC Models & Shadows\nAlso equivalent to the settings applied in your room with the addition of disabled \"Simple NPC\" limits."); + ImGui.Text("This will make the default (gameplay) LOD limits equivalent to View Mode. Disabling the limit on:\n - Player Models & Shadows\n - Palico Models & Shadows\n - NPC Models & Shadows\n - Simple NPC Models & Shadows\nAlso equivalent to the settings applied in your room with the addition of disabled Simple NPC limits."); 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 (characterCreatorFace) + { + defaultCharacterCreatorParam.Enable(); + } + else + { + defaultCharacterCreatorParam.Disable(); + } + } + */ + ImGui.PushItemWidth(width * 0.1f); + ImGui.InputFloat("##Foliage LOD Bias", ref foliageLODBias, 0.0f, 0.0f, "%.2f"); if (ImGui.BeginItemTooltip()) { @@ -3874,12 +4451,15 @@ namespace MHWNewCamera ImGui.EndTooltip(); } ImGui.SameLine(); - ImGui.InputFloat("Foliage LOD Bias", ref foliageLODFactor, 0.0f, 0.0f, "%.2f"); + ImGui.InputFloat("##Foliage LOD Factor", ref foliageLODFactor, 0.0f, 0.0f, "%.2f"); if (ImGui.BeginItemTooltip()) { ImGui.Text("Controls the distance at which the game decides to no longer render some plants.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0."); ImGui.EndTooltip(); } + ImGui.SameLine(); + ImGui.Text("Foliage LOD Bias"); + ImGui.InputFloat("##Terrain/Object LOD Bias", ref terrainLODBias, 0.0f, 0.0f, "%.2f"); if (ImGui.BeginItemTooltip()) { @@ -3887,14 +4467,19 @@ namespace MHWNewCamera ImGui.EndTooltip(); } ImGui.SameLine(); - ImGui.InputFloat("Terrain/Object LOD Bias", ref terrainLODFactor, 0.0f, 0.0f, "%.2f"); + ImGui.InputFloat("##Terrain/Object LOD Factor", ref terrainLODFactor, 0.0f, 0.0f, "%.2f"); if (ImGui.BeginItemTooltip()) { 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.SameLine(); + ImGui.Text("Terrain/Object LOD Bias"); + ImGui.InputFloat("Snow LOD Param", ref snowField4GlobalLODParam, 0.0f, 0.0f, "%.2f", ImGuiInputTextFlags.EnterReturnsTrue); + ImGui.PopItemWidth(); + bool lodsSet = areLODFactorsSet(); bool disableLODButton = lodsSet && areLODFactorsDefault(); if (disableLODButton) @@ -3907,15 +4492,17 @@ namespace MHWNewCamera { setLODFactors(lodsSet); applyLODFactors = lodsSet && !areLODFactorsDefault(); + Config.GraphicalTweaks graphics = config.Graphics; if (lodsSet) { - config.FoliageLODBias = foliageLODBias; - config.TerrainLODBias = terrainLODBias; - config.FoliageLODFactor = foliageLODFactor; - config.TerrainLODFactor = terrainLODFactor; - config.SnowLODBias = snowField4GlobalLODParam; + graphics.FoliageLODBias = foliageLODBias; + graphics.TerrainLODBias = terrainLODBias; + graphics.FoliageLODFactor = foliageLODFactor; + graphics.TerrainLODFactor = terrainLODFactor; + graphics.SnowLODBias = snowField4GlobalLODParam; } - config.ApplyLODFactors = applyLODFactors; + graphics.ApplyLODFactors = applyLODFactors; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (disableLODButton) @@ -3934,7 +4521,9 @@ namespace MHWNewCamera { addressHigherValueForFoliageSway.Disable(); } - config.LargerFoliageSwayRange = largerFoliageSwayRange; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.LargerFoliageSwayRange = largerFoliageSwayRange; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3953,7 +4542,9 @@ namespace MHWNewCamera { zeroFrameSkip.Disable(); } - config.DisableReducedRateAnimations = disableReducedRateAnimations; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.DisableReducedRateAnimations = disableReducedRateAnimations; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) @@ -3972,107 +4563,31 @@ namespace MHWNewCamera { zeroVolumetricDownsample.Disable(); } - config.DisableVolumetricDownsample = disableVolumeDownsample; + Config.GraphicalTweaks graphics = config.Graphics; + graphics.DisableVolumetricDownsample = disableVolumeDownsample; + config.Graphics = graphics; ConfigManager.SaveConfig(this); } if (ImGui.BeginItemTooltip()) { - ImGui.Text("Disabling blur is likely an undesirable compromise but skipping the downsample without skipping blur is a more involved change."); + 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(); } + + ImGui.Separator(); } ImGui.PopID(); ImGui.PushID("Debug"); if (ImGui.CollapsingHeader("DEBUG")) { - ImGui.Text("Graphics:"); - - ImGui.Text($"Fps: {MemoryUtil.Read(sMain.Instance + 0x58)}"); - ImGui.Text($"Max Fps: {MemoryUtil.Read(sMain.Instance + 0x5C)}"); - ImGui.Text($"Actual Fps: {MemoryUtil.Read(sMain.Instance + 0x64)}"); - ImGui.Text($"Real Fps: {MemoryUtil.Read(sMain.Instance + 0x68)}"); - ImGui.Text($"Delta Time Adjust: {MemoryUtil.Read(sMain.Instance + 0x92) == 0x1}"); - ImGui.Text($"Delta Time: {MemoryUtil.Read(sMain.Instance + 0x94)}"); - //ImGui.Text($"Delta Time Border: {MemoryUtil.Read(sMain.Instance + 0x98)}"); - //ImGui.Text($"Delta Time Limit: {MemoryUtil.Read(sMain.Instance + 0x9C)}"); - ImGui.Text($"Delta Sec: {MemoryUtil.Read(sMain.Instance + 0xA0)}"); - - ImGui.Text($"prevFoliageLODBias: {prevFoliageLODBias}"); - ImGui.Text($"prevTerrainLODBias: {prevTerrainLODBias}"); - ImGui.Text($"shadowCascadeValue: {lastShadowCascadeValue}"); - ImGui.Text($"shadowBias: {lastShadowBias}"); - ImGui.Text($"shadowRadius: {lastShadowRadius}"); - - if (ImGui.CollapsingHeader("Renderer Parameters")) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - ImGui.Text($"Address: {baseAddr:x}"); - ImGui.PushItemWidth(width * 0.2f); - drawRenderParameter("Primary Shadow Sample Num", baseAddr, 0xE5C4); - drawRenderParameter("Primary Shadow Sample Num HQ", baseAddr, 0xE5CC); - drawRenderParameter("Primary Shadow HQ", baseAddr, 0xE5C0); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This seems to refer to softening the edges of shadows."); - ImGui.EndTooltip(); - } - drawRenderParameter("Primary Shadow HQ HQ", baseAddr, 0xE5C2); - drawRenderParameter("LOD Length Bias HQ", baseAddr, 0x1FC); - drawRenderParameter("LOD Pixel Size Bias HQ", baseAddr, 0x1FC); - drawRenderParameter("SSAO Depth Bias", baseAddr, 0xB4B0); - drawRenderParameter("SSAO Sloped Depth Bias", baseAddr, 0xB4B4); - drawRenderParameter("SSAO Max Depth Bias", baseAddr, 0xB4B8); - drawRenderParameter("SSAO Dispersion", baseAddr, 0xB4BC); - drawRenderParameter("SSAO Effect", baseAddr, 0xB430); - drawRenderParameter("SSAO Effect GI", baseAddr, 0xB434); - drawRenderParameter("SSAO Depth Difference", baseAddr, 0xB4C0); - drawRenderParameter("SSAO Samples Per Pixel", baseAddr, 0xB4C4); - drawRenderParameter("SSAO Max Sample Num", baseAddr, 0xB4C8); - drawRenderParameter("SSAO Max Sample Num HQ", baseAddr, 0xB4D0); - drawRenderParameter("SSAO Radius", baseAddr, 0xB4D4); - drawRenderParameter("SSAO Bias", baseAddr, 0xB4D8); - drawRenderParameter("SSAO Intensity", baseAddr, 0xB4E0); - drawRenderParameter("SSAO Use HiZ", baseAddr, 0xB4E5); - drawRenderParameter("SSAO Edge Atten Rate", baseAddr, 0xB4DC); - drawRenderParameter("SSLR Loop Count", baseAddr, 0xE628); - drawRenderParameter("SSLR Loop Count Factor For CBR", baseAddr, 0xE62C); - drawRenderParameter("SSLR Eliminate Depth", baseAddr, 0xE630); - drawRenderParameter("SSLR Accurate Threshold", baseAddr, 0xE644); - drawRenderParameter("SSLR Accurate Threshold HQ", baseAddr, 0xE64C); - drawRenderParameter("SSLR Dither Radius", baseAddr, 0xE634); - drawRenderParameter("SSLR Importance Bias", baseAddr, 0xE638); - drawRenderParameter("SSLR Mip Scale", baseAddr, 0xE63C); - drawRenderParameter("SSLR Mip Bias", baseAddr, 0xE640); - drawRenderParameter("SSLR Dither Resolve", baseAddr, 0xB43F); - drawRenderParameter("SSLR Edge Atten Rate", baseAddr, 0xB428); - drawRenderParameter("SSLR Mip 0 Count Threshold", baseAddr, 0xB438); - drawRenderParameter("SSLR Depth Eliminate Rate", baseAddr, 0xB42C); - drawRenderParameter("SSLR Use Mipmap", baseAddr, 0xE650); - drawRenderParameter("SSLR GBuffer Jitter", baseAddr, 0xB440); - /* - drawRenderParameter("Checkerboard Alpha Unroll Near", baseAddr, 0xE964); - drawRenderParameter("Checkerboard Alpha Unroll Far", baseAddr, 0xE968); - drawRenderParameter("Checkerboard History Blend Rate", baseAddr, 0xE96C); - drawRenderParameter("Checkerboard Sanitize Color", baseAddr, 0xE972); - drawRenderParameter("Checkerboard Blend Dither", baseAddr, 0xE973); - drawRenderParameter("Checkerboard BBox Strength", baseAddr, 0xE974); - drawRenderParameter("Checkerboard Dither Passthru Weight", baseAddr, 0xE978); - drawRenderParameter("Checkerboard Dither Filtered Weight", baseAddr, 0xE97C); - drawRenderParameter("Checkerboard Continous History Reset", baseAddr, 0xE971); - */ - ImGui.PopItemWidth(); - } - - ImGui.Separator(); - if (vCamera != null || pCamera != null) { ImGui.Text("Camera:"); if (vCamera != null) { ImGui.Text($"Visible Camera: {vCamera.Instance:x}"); - ImGui.Text($"freeCameraFallback: {lastFreeCameraFallback}"); + ImGui.Text($"freeCameraFallback: {freeCameraFallback}"); //ImGui.Text($"viewModeObject: {psuedoViewModeObject:x}"); } if (pCamera != null) @@ -4196,6 +4711,92 @@ namespace MHWNewCamera } */ + ImGui.Text("Graphics:"); + + ImGui.Text($"Fps: {MemoryUtil.Read(sMain.Instance + 0x58)}"); + ImGui.Text($"Max Fps: {MemoryUtil.Read(sMain.Instance + 0x5C)}"); + ImGui.Text($"Actual Fps: {MemoryUtil.Read(sMain.Instance + 0x64)}"); + ImGui.Text($"Real Fps: {MemoryUtil.Read(sMain.Instance + 0x68)}"); + ImGui.Text($"Delta Time Adjust: {MemoryUtil.Read(sMain.Instance + 0x92) == 0x1}"); + ImGui.Text($"Delta Time: {MemoryUtil.Read(sMain.Instance + 0x94)}"); + //ImGui.Text($"Delta Time Border: {MemoryUtil.Read(sMain.Instance + 0x98)}"); + //ImGui.Text($"Delta Time Limit: {MemoryUtil.Read(sMain.Instance + 0x9C)}"); + ImGui.Text($"Delta Sec: {MemoryUtil.Read(sMain.Instance + 0xA0)}"); + + ImGui.Text($"prevFoliageLODBias: {prevFoliageLODBias}"); + ImGui.Text($"prevTerrainLODBias: {prevTerrainLODBias}"); + ImGui.Text($"shadowCascadeValue: {lastShadowCascadeValue}"); + ImGui.Text($"shadowBias: {lastShadowBias}"); + ImGui.Text($"shadowRadius: {lastShadowRadius}"); + + if (ImGui.CollapsingHeader("Renderer Parameters")) + { + ImGui.Text($"FXAA Address: {fxaaPointer:x}"); + if (fxaaPointer != 0x0) + { + drawRenderParameter("FXAA Subpix", fxaaPointer, 0x178, true); + drawRenderParameter("FXAA Edge Threshold", fxaaPointer, 0x17C, true); + drawRenderParameter("FXAA Edge Threshold Min", fxaaPointer, 0x180, true); + } + ImGui.Separator(); + nint baseAddr = MemoryUtil.Read(0x1451C4368); + ImGui.Text($"Address: {baseAddr:x}"); + ImGui.PushItemWidth(width * 0.2f); + drawRenderParameter("HQ Mode", baseAddr, 0xE9A3); + drawRenderParameter("Primary Shadow Sample Num", baseAddr, 0xE5C4); + drawRenderParameter("Primary Shadow Sample Num HQ", baseAddr, 0xE5CC); + drawRenderParameter("Primary Shadow HQ", baseAddr, 0xE5C0); + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("This seems to refer to softening the edges of shadows."); + ImGui.EndTooltip(); + } + drawRenderParameter("Primary Shadow HQ HQ", baseAddr, 0xE5C2); + drawRenderParameter("LOD Length Bias HQ", baseAddr, 0x1FC); + drawRenderParameter("LOD Pixel Size Bias HQ", baseAddr, 0x1FC); + inputSSAOParameters(null, baseAddr); + drawRenderParameter("SSLR Loop Count", baseAddr, 0xE628); + drawRenderParameter("SSLR Loop Count Factor For CBR", baseAddr, 0xE62C); + drawRenderParameter("SSLR Eliminate Depth", baseAddr, 0xE630); + drawRenderParameter("SSLR Accurate Threshold", baseAddr, 0xE644); + drawRenderParameter("SSLR Accurate Threshold HQ", baseAddr, 0xE64C); + drawRenderParameter("SSLR Dither Radius", baseAddr, 0xE634); + drawRenderParameter("SSLR Importance Bias", baseAddr, 0xE638); + drawRenderParameter("SSLR Mip Scale", baseAddr, 0xE63C); + drawRenderParameter("SSLR Mip Bias", baseAddr, 0xE640); + drawRenderParameter("SSLR Dither Resolve", baseAddr, 0xB43F); + drawRenderParameter("SSLR Edge Atten Rate", baseAddr, 0xB428); + drawRenderParameter("SSLR Mip 0 Count Threshold", baseAddr, 0xB438); + drawRenderParameter("SSLR Depth Eliminate Rate", baseAddr, 0xB42C); + drawRenderParameter("SSLR Use Mipmap", baseAddr, 0xE650); + drawRenderParameter("SSLR GBuffer Jitter", baseAddr, 0xB440); + drawRenderParameter("Contact Shadows Enabled", baseAddr, 0xB4EC); + drawRenderParameter("Force Disable Contact Shadows", baseAddr, 0xB4ED); + drawRenderParameter("Facial Contact Shadows Enabled", baseAddr, 0xB4EE); + drawRenderParameter("Contact Shadows Enable Noise", baseAddr, 0xB500); + drawRenderParameter("Facial Contact Shadows Enable Noise", baseAddr, 0xB501); + drawRenderParameter("Contact Shadow Intensity", baseAddr, 0xB4F0); + drawRenderParameter("Contact Shadow Length", baseAddr, 0xB4F4); + drawRenderParameter("Contact Shadow Accept Maximum Length", baseAddr, 0xB4F8); + drawRenderParameter("Contact Shadow Accept Minimum Length", baseAddr, 0xB4FC); + /* + drawRenderParameter("Capsule AO Enabled", baseAddr, 0xB502); + drawRenderParameter("Force Disable Capsule AO", baseAddr, 0xB503); + drawRenderParameter("Checkerboard Alpha Unroll Near", baseAddr, 0xE964); + drawRenderParameter("Checkerboard Alpha Unroll Far", baseAddr, 0xE968); + drawRenderParameter("Checkerboard History Blend Rate", baseAddr, 0xE96C); + drawRenderParameter("Checkerboard Sanitize Color", baseAddr, 0xE972); + drawRenderParameter("Checkerboard Blend Dither", baseAddr, 0xE973); + drawRenderParameter("Checkerboard BBox Strength", baseAddr, 0xE974); + drawRenderParameter("Checkerboard Dither Passthru Weight", baseAddr, 0xE978); + drawRenderParameter("Checkerboard Dither Filtered Weight", baseAddr, 0xE97C); + drawRenderParameter("Checkerboard Continous History Reset", baseAddr, 0xE971); + */ + ImGui.PopItemWidth(); + } + + ImGui.Separator(); + ImGui.PushID("Pad"); ImGui.Text("Pad:"); ImGui.Text($"Pointer: {controllerAddr():x}"); @@ -4213,17 +4814,20 @@ namespace MHWNewCamera ImGui.Text($" X: {PadRx}"); ImGui.Text($" Y: {PadRy}"); ImGui.Text($" RT: {PadRz}"); - ImGui.DragFloat("+right", ref plusRight, 0.05f); - ImGui.DragFloat("+forward", ref plusForward, 0.05f); + ImGui.DragFloat("+right", ref plusRight, 0.02f); + ImGui.DragFloat("+forward", ref plusForward, 0.02f); ImGui.PopID(); + + ImGui.Separator(); } ImGui.PopID(); ImGui.PushID("Credits"); if (ImGui.CollapsingHeader("Credits")) { - ImGui.Text("SharpPluginLoader Authors: Framework for this mod and reference for various memory locations."); - ImGui.Text("Otis_Inf: Initial LOD and object fading adjustment locations. As well as time of day and game speed."); + ImGui.Text("Fexty/SharpPluginLoader Authors: Framework for this mod and reference for various memory locations."); + ImGui.Text("Otis_Inf: Initial LOD and object fading adjustment locations. Time of day and game speed."); + ImGui.Text("Andoryuuta: MHW-ClassPropDump/MHW-DTI-Dumps."); ImGui.Text("MonsterHunterWorldModding/wiki Authors."); } ImGui.PopID(); -- cgit v1.2.3-101-g0448