summaryrefslogtreecommitdiff
path: root/LUT.cs
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-10-09 13:03:46 -0400
committerAndrew Opalach <andrew@akon.city> 2026-10-09 13:05:03 -0400
commitaeb22677767008e995dd2f8390433b918a2cf301 (patch)
treea73be802011f8e9e0462d1f3178689119e51b5f3 /LUT.cs
parentf06c2496b80bf0dd26b8790318eaf194f362b8e2 (diff)
downloadWorldTuningTool-aeb22677767008e995dd2f8390433b918a2cf301.tar.gz
WorldTuningTool-aeb22677767008e995dd2f8390433b918a2cf301.tar.bz2
WorldTuningTool-aeb22677767008e995dd2f8390433b918a2cf301.zip
Add patches, exposure parameters and cleanup
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'LUT.cs')
-rw-r--r--LUT.cs106
1 files changed, 66 insertions, 40 deletions
diff --git a/LUT.cs b/LUT.cs
index a8db19d..1018745 100644
--- a/LUT.cs
+++ b/LUT.cs
@@ -6,47 +6,57 @@ using System.Runtime.InteropServices;
using ImGuiNET;
using SharpPluginLoader.Core.Memory;
+using SharpPluginLoader.Core.IO;
#if TEXTURE_FEATURE
using SharpPluginLoader.Core.Resources;
-using SharpPluginLoader.Core.IO;
#endif
namespace WorldTuningTool
{
using static Plugin;
- public class LUT
+ public static class WorldLUTs
{
private const string addPath = "nativePC/plugins/CSharp/LUT";
- public LUT() { }
+ private static string[] builtinList = {
+ "native:\\light\\LUT\\CC_effect_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_A_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_B_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_darkB_type10_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_darkG_type10_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_darkR_type10_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_dark_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_dark_type10_LUTM.tex",
+ "native:\\light\\LUT\\CC_event_evc0001_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_globalbase_LUTM.tex",
+ "native:\\light\\LUT\\CC_globalbaseSATU_LUTM.tex",
+ "native:\\light\\LUT\\CC_globalbase_stage_LUTM.tex",
+ "native:\\light\\LUT\\CC_st101day_global_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_st101day_global_type10_LUTM.tex",
+ "native:\\light\\LUT\\CC_st104day_global_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_st105day_global_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_title_st101d_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_title_st102d_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_title_st103d_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_title_st104d_type00_LUTM.tex",
+ "native:\\light\\LUT\\CC_title_st105d_type00_LUTM.tex"
+ };
// https://github.com/AsteriskAmpersand/CrappyLUTStudio--CLUTS-/blob/5af10daaa5f295b106cc5db09530a6fe5a4320d4/LUT.py#L35
- private byte[]? parseWorldLUT(BinaryReader reader)
+ private static byte[]? parseWorldLUT(BinaryReader reader)
{
byte[] signature = reader.ReadBytes(4);
- if (!(signature[0] == 0x54 && signature[1] == 0x45 &&
- (signature[2] == 0x58 && signature[3] == 0x0)))
+ if (!(signature[0] == 0x54 && signature[1] == 0x45 && signature[2] == 0x58 && signature[3] == 0x0))
{
return null;
}
- ulong version = reader.ReadUInt64();
- uint datablock = reader.ReadUInt32();
- uint format = reader.ReadUInt32();
- uint mipCount = reader.ReadUInt32();
+ byte[] skip = reader.ReadBytes(20);
uint width = reader.ReadUInt32();
uint height = reader.ReadUInt32();
- uint mipListCount = reader.ReadUInt32();
- uint typeData = reader.ReadUInt32();
+ skip = reader.ReadBytes(8);
uint depth = reader.ReadUInt32();
- byte[] NULL0 = reader.ReadBytes(12);
- int NEG0 = reader.ReadInt32();
- byte[] NULL1 = reader.ReadBytes(8);
- int Special = reader.ReadInt32();
- byte[] NULL2 = reader.ReadBytes(16);
- byte[] NEG1 = reader.ReadBytes(32);
- byte[] flags = reader.ReadBytes(32);
- byte[] NULLX = reader.ReadBytes(32);
+ skip = reader.ReadBytes(140);
reader.BaseStream.Position = (long)reader.ReadUInt64();
if (!(width == 32 && height == 32 && depth == 32))
{
@@ -57,7 +67,7 @@ namespace WorldTuningTool
// https://drive.google.com/file/d/143Eh08ZYncCAMwJ1q4gWxVOqR_OSWYvs/view
// When does DOMAIN_MIN/MAX apply?
- private byte[]? parseCubeLUT(StreamReader reader)
+ private static byte[]? parseCubeLUT(StreamReader reader)
{
string? line;
Vector3[]? parsed = null;
@@ -118,7 +128,7 @@ namespace WorldTuningTool
return data;
}
- private unsafe bool overwriteFromStream(nint texture, Stream stream, bool cube = false)
+ private static unsafe bool overwriteFromStream(nint texture, Stream stream, bool cube = false)
{
byte[]? data = null;
if (cube)
@@ -150,7 +160,7 @@ namespace WorldTuningTool
#endif
}
- private unsafe bool overwriteFromFile(nint texture, string path)
+ private static unsafe bool overwriteFromFile(nint texture, string path)
{
string ext = path.Split('.').Last().ToLower();
using (FileStream stream = File.Open(path, FileMode.Open))
@@ -159,17 +169,29 @@ namespace WorldTuningTool
}
}
- private void reloadBlendLUT(nint lightingObject)
+ private static unsafe 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;
+ }
+
+ private static void reloadBlendLUT(nint lightingObject)
{
MemoryUtil.GetRef<float>(lightingObject + 0x1D4) = MemoryUtil.GetRef<float>(lightingObject + 0x1D0) + 1.0f;
}
- private string[] fileList = [];
+ private static string[] fileList = [];
private static string[] selectedFile = [ "", "" ];
private static bool[] selectionStarted = [ false, false ];
private static bool[] selectedInvalid = [ false, false ];
- public void DrawUI(nint texture, nint lightingObject, int i, float width)
+ public static void DrawUI(nint texture, nint lightingObject, int i, float width)
{
ImGui.PushID(i);
string lutPath = Marshal.PtrToStringAnsi(texture + 0xC)!;
@@ -177,14 +199,9 @@ namespace WorldTuningTool
#if TEXTURE_FEATURE
if (ImGui.Button("Reset"))
{
- MtFileStream? file = MtFileStream.FromPath($"native:\\{lutPath}.tex", OpenMode.Read, false);
- if (file != null)
+ if (overwriteFromMtFile(texture, $"native:\\{lutPath}.tex"))
{
- if (overwriteFromStream(texture, new MemoryStream(file.Read(file.Length))))
- {
- reloadBlendLUT(lightingObject);
- }
- file.Close();
+ reloadBlendLUT(lightingObject);
}
selectedFile[i] = "";
selectedInvalid[i] = false;
@@ -196,11 +213,24 @@ namespace WorldTuningTool
{
ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF);
}
- if (ImGui.BeginCombo("##LUT Files", selectedFile[i], ImGuiComboFlags.HeightLarge))
+ bool beginCombo = ImGui.BeginCombo("##LUT Files", selectedFile[i], ImGuiComboFlags.HeightLarge);
+ if (prevWasInvalid)
{
- if (prevWasInvalid)
+ ImGui.PopStyleColor();
+ }
+ if (beginCombo)
+ {
+ foreach (string nativePath in builtinList)
{
- ImGui.PopStyleColor();
+ bool isSelected = selectedFile[i] == nativePath;
+ if (ImGui.Selectable(nativePath, isSelected))
+ {
+ selectedFile[i] = nativePath;
+ if (overwriteFromMtFile(texture, nativePath))
+ {
+ reloadBlendLUT(lightingObject);
+ }
+ }
}
if (!selectionStarted[i])
{
@@ -224,10 +254,6 @@ namespace WorldTuningTool
}
else
{
- if (prevWasInvalid)
- {
- ImGui.PopStyleColor();
- }
selectionStarted[i] = false;
}
#endif