From b1dfe847f742aa7079a819090ba36d606e7af4db Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Thu, 29 Oct 2026 23:01:05 -0400 Subject: LUT tweaks Signed-off-by: Andrew Opalach --- LUT.cs | 16 ++++++---------- Plugin.cs | 15 +++++++++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/LUT.cs b/LUT.cs index 941e4a6..a037618 100644 --- a/LUT.cs +++ b/LUT.cs @@ -157,11 +157,10 @@ namespace WorldTuningTool fixed (byte *dataPointer = (byte[])data) { // DXGI_FORMAT_R16G16B16A16_FLOAT = 10 - return new Texture(texture).Replace(dataPointer, 10, 32, 32, 32); + new Texture(texture).Replace(dataPointer, 10, 32, 32, 32); } -#else - return true; #endif + return true; } private static bool overwriteFromFile(nint texture, string path) @@ -176,13 +175,10 @@ namespace WorldTuningTool private static bool overwriteFromMtFile(nint texture, string path) { MtFileStream? file = MtFileStream.FromPath(path, OpenMode.Read, false); - bool success = false; - if (file != null) - { - success = overwriteFromStream(texture, new MemoryStream(file.Read(file.Length))); - file.Close(); - } - return success; + if (file == null) return false; + MemoryStream stream = new MemoryStream(file.Read(file.Length)); + file.Close(); + return overwriteFromStream(texture, stream); } private static void reloadBlendLut(nint lightingObject) diff --git a/Plugin.cs b/Plugin.cs index 7ae5c2e..a2d0f19 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -613,7 +613,6 @@ namespace WorldTuningTool } // Start of Parameter Definitions. - private delegate void OnAreaChange(nint sMhArea); private Hook? onAreaChange; @@ -931,10 +930,11 @@ namespace WorldTuningTool private Hook? destroyBloomObject; private nint bloomObject = 0x0; private static Parameter[] bloomParameters = { - // Disabling 'Draw' is a bad way to disable bloom. It breaks the filter on initial load which - // can be seen when returning to title or opening a guild card for the first time. Setting 'Bloom Renormalize' - // to 0.0 or 'Bloom Reduction Resolution' to -1 can both effectively disable bloom without that issue. - //newFlag("Bloom Enabled", 0x14, ParameterType.FLAG, (1 << 1)), // Draw + // Disabling "Draw" is a bad way to disable bloom as it breaks the filter on initialization. + // It can be seen when returning to title or opening a guild card for the first time. + // Setting "Bloom Renormalize" to 0.0 or "Bloom Reduction Resolution" to -1 can both + // effectively disable bloom without that issue. + //M("Bloom Enabled", 0x14, ParameterType.FLAG, (1 << 1)), // Draw P("Bloom Threshold", 0x204, ParameterType.FLOAT, pStep(0.001f)), P("Bloom Renormalize", 0x208, ParameterType.FLOAT, pMin(0.0f)), P("Bloom Color", 0x200, ParameterType.COLOR), @@ -2283,6 +2283,9 @@ namespace WorldTuningTool sslrEnvMapIntensity.Update(sMhScene!.Instance, true); } + // Any CreateObject() can be called many times consecutively before it's associated DestroyObject(). + // For this to be correct, the most recent CreateObject() needs to be the object that is used. + // This is why we cannot, for example, Assert(toneMapObject == 0x0) in CreateToneMapObjectHook(). private nint CreateToneMapObjectHook() { toneMapObject = createToneMapObject!.Original(); @@ -2290,6 +2293,7 @@ namespace WorldTuningTool { param.Update(toneMapObject); } + Lut.clearState(); return toneMapObject; } @@ -2303,7 +2307,6 @@ namespace WorldTuningTool { param.Update(toneMapObject); } - Lut.clearState(); } return destroyToneMapObject!.Original(toneMapObjectInternal, unknownInt); } -- cgit v1.2.3-101-g0448