diff options
| author | 2026-06-25 21:36:21 -0400 | |
|---|---|---|
| committer | 2026-06-25 21:36:21 -0400 | |
| commit | d3a64c89a7b5dd9878a46ab6bceeab6362526be4 (patch) | |
| tree | c5d7b98257ef44bd15dba779a3125a1c611b057e /Plugin.cs | |
| parent | c6900a75360d31a2eb4a494c4c6438610c92ae37 (diff) | |
| download | WorldTuningTool-d3a64c89a7b5dd9878a46ab6bceeab6362526be4.tar.gz WorldTuningTool-d3a64c89a7b5dd9878a46ab6bceeab6362526be4.tar.bz2 WorldTuningTool-d3a64c89a7b5dd9878a46ab6bceeab6362526be4.zip | |
LUTs wip
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'Plugin.cs')
| -rwxr-xr-x | Plugin.cs | 62 |
1 files changed, 56 insertions, 6 deletions
@@ -104,13 +104,13 @@ namespace WorldTuningTool private static string BooleanToString(bool b) { return b.ToString(CultureInfo.InvariantCulture); }
private static string Int32ToString(int i, string? format = null) { return i.ToString(format, CultureInfo.InvariantCulture); }
- private static Vector3 StringToVector3(string s)
+ public static Vector3 StringToVector3(string s, char delim = ',')
{
if (String.IsNullOrEmpty(s))
{
throw new FormatException();
}
- string[] vs = s.Split(',').Select(v => v.Trim()).ToArray();
+ string[] vs = s.Split(delim).Select(v => v.Trim()).ToArray();
if (vs.Length != 3)
{
throw new FormatException();
@@ -1645,9 +1645,14 @@ namespace WorldTuningTool private Hook<CreateLightingObject>? createLightingObject;
private Hook<DestroyLightingObject>? destroyLightingObject;
private nint lightingObject = 0x0;
+ private delegate void SetLightingParameters(nint lightingObjectInternal);
+ private Hook<SetLightingParameters>? setLightingParams;
private delegate void UpdateLightingParameters(nint stackOffset, nint lightingObjectInternal);
private Hook<UpdateLightingParameters>? updateLightingParams;
private Hook<UpdateLightingParameters>? updateLutBlend;
+ private static WorldLUT lut = new WorldLUT();
+ private static string selectedLut = "";
+ private static bool selectedLutInavlid = false;
private static Parameter[] lightingParameters = {
newParameter<int>("Light Tone Map Type", 0x16C, ParameterType.INT, pMinMaxStep(1, 6, 1)),
newParameter<bool>("Light Compute Luminance", 0x170, ParameterType.BOOL),
@@ -2157,6 +2162,7 @@ namespace WorldTuningTool createLightingObject = Hook.Create<CreateLightingObject>(0x1424CDE20, CreateLightingObjectHook);
destroyLightingObject = Hook.Create<DestroyLightingObject>(0x1424CE380, DestroyLightingObjectHook); // nint, int
+ setLightingParams = Hook.Create<SetLightingParameters>(0x1424CF1C0, SetLightingParametersHook); // nint
updateLutBlend = Hook.Create<UpdateLightingParameters>(0x1416D8DF0, UpdateLutBlendHook); // nint, nint
createBloomObject = Hook.Create<CreateBloomObject>(0x1424CB3C0, CreateBloomObjectHook);
@@ -2563,10 +2569,7 @@ namespace WorldTuningTool {
foreach (Parameter param in lightingParameters)
{
- if (!param.PerFrame)
- {
- param.Update(lightingObject);
- }
+ param.Update(lightingObject);
}
}
foreach (Parameter param in lightProbesParameters)
@@ -2855,6 +2858,16 @@ namespace WorldTuningTool return destroyLightingObject!.Original(lightingObjectInternal, unknownInt);
}
+ private void SetLightingParametersHook(nint lightingObjectInternal)
+ {
+ setLightingParams!.Original(lightingObjectInternal);
+ if (lightingObject == lightingObjectInternal)
+ {
+ // LUT texture should be set at this point.
+ selectedLut = "";
+ }
+ }
+
private void UpdateLutBlendHook(nint stackOffset, nint lightingObjectInternal)
{
updateLutBlend!.Original(stackOffset, lightingObjectInternal);
@@ -3789,6 +3802,43 @@ namespace WorldTuningTool {
if (lightingObject != 0x0)
{
+ nint lutTexture = MemoryUtil.Read<nint>(lightingObject + 0x1C0);
+ nint d3d12Resource = 0x0;
+ if (lutTexture != 0x0)
+ {
+ d3d12Resource = MemoryUtil.Read<nint>(lutTexture + 0x10);
+ }
+ if (d3d12Resource != 0x0)
+ {
+ ImGui.SetNextItemWidth(width * 0.65f);
+ bool prevLutWasInvalid = selectedLutInavlid;
+ if (prevLutWasInvalid)
+ {
+ ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF);
+ }
+ if (ImGui.BeginCombo("LUT", selectedLut, ImGuiComboFlags.HeightLarge))
+ {
+ if (prevLutWasInvalid)
+ {
+ ImGui.PopStyleColor();
+ }
+ foreach (string lutPath in lut.GetLUTs())
+ {
+ string lutFile = Path.GetFileName(lutPath);
+ bool isSelected = selectedLut == lutFile;
+ if (ImGui.Selectable(lutFile, isSelected))
+ {
+ selectedLutInavlid = !lut.OverwriteFromFile(d3d12Resource, lutPath);
+ selectedLut = lutFile;
+ }
+ }
+ ImGui.EndCombo();
+ }
+ else if (prevLutWasInvalid)
+ {
+ ImGui.PopStyleColor();
+ }
+ }
ImGui.Text($"Address: 0x{lightingObject:X}");
foreach (Parameter param in lightingParameters)
{
|