Skip to content

Commit d40e6a9

Browse files
committed
Add Asset Compiler tab
Add Loose Texture Compiler Core Submodule changes Correct text Add custom path function. Refactor name to asset compiler Right align buttons. Store project files outside of the folder of the currently selected mod. Add Simple Mode Fix issue with simple mode not clearing itself. Update constructors Add modifier keys to filepicker clearing buttons. Submodule changes Minor cleanup Adjust event names Fix project persistence. Add a cap to how many texture sets can exist. Only save project if asset compiler tab is actually used. Submodule updates Remove incomplete class. Add Drag And Drop, add bulk name replacement. Attempt to fix some texture errors. Get penumbra to compile again. # This is a combination of 105 commits. Add support for the DalamudSubstitutionProvider for textures. # The commit message #9 will be skipped: # Attempt to fix some texture errors. # The commit message #10 will be skipped: # Get penumbra to compile again. # The commit message #11 will be skipped: # Submodule update # The commit message #12 will be skipped: # Disable UI for textures when converting. # The commit message #13 will be skipped: # Update DirectXTex/OtterTex # The commit message #14 will be skipped: # Keep the texture alive during write. # The commit message #15 will be skipped: # [CI] Updating repo.json for 0.7.3.2 # The commit message #16 will be skipped: # Explain comment. # The commit message #17 will be skipped: # Add some unnamed mounts to actor identification. # The commit message #18 will be skipped: # Material editor: improve color accuracy # The commit message #19 will be skipped: # Material editor: live-preview changes # The commit message #20 will be skipped: # Material editor 2099 # The commit message #21 will be skipped: # Material editor: better color constants # The commit message #22 will be skipped: # Update GameData # The commit message #23 will be skipped: # Material editor: Allow negatives again with R²G²B² # # There seems to be people using it. # The commit message #24 will be skipped: # Material editor: tweak colorset highlighting # # Make the frequency framerate-independent, set it to 1 Hz, and decrease the dynamic range. # # Thanks @StoiaCode for feedback! # The commit message #25 will be skipped: # Material editor: tear down previewers bound to a CharacterBase that goes away # The commit message #26 will be skipped: # Add a few texture manipulation tools. # The commit message #27 will be skipped: # Small cleanup, auto-formatting. # The commit message #28 will be skipped: # Textures: Un-merge save buttons, make ignore unselectable # The commit message #29 will be skipped: # Textures: Renumber CombineOps. # # Positive values in this enum also double as indices into the labels and tooltip arrays. # # (confirmed skill issue moment) # The commit message #30 will be skipped: # Textures: Automatic resizing # The commit message #31 will be skipped: # Textures: Add a matrix preset that drops alpha # The commit message #32 will be skipped: # Textures: PR #327 feedback # The commit message #33 will be skipped: # Textures: PR #327 feedback # The commit message #34 will be skipped: # Textures: Refactor resizing code # The commit message #35 will be skipped: # Textures: Simplify away _targetPixels # The commit message #36 will be skipped: # Slight restructuring. # The commit message #37 will be skipped: # Skin Fixer (fixes modding of skin.shpk) # The commit message #38 will be skipped: # Skin Fixer: Make resolving skin.shpk for new draw objects async # The commit message #39 will be skipped: # Skin Fixer: Fix potential ref leak + add SRH # # `SafeResourceHandle` wraps a `ResourceHandle*` with auto `IncRef` / `DecRef`, to further help prevent leaks. # The commit message #40 will be skipped: # Use better event in SkinFixer and some cleanup. # The commit message #41 will be skipped: # Remove Finalize from FileEditor. # The commit message #42 will be skipped: # Some formatting in Materials.Shpk. # The commit message #43 will be skipped: # Small cleanup in ResolveContext. # The commit message #44 will be skipped: # Auto-formatting and some cleanup. # The commit message #45 will be skipped: # Restructure Live Preview. # The commit message #46 will be skipped: # Fix slash direction in material path. # The commit message #47 will be skipped: # [CI] Updating repo.json for testing_0.7.3.3 # The commit message #48 will be skipped: # Fix newtonsoft not playing well with records with strings. # The commit message #49 will be skipped: # Cleanup # The commit message #50 will be skipped: # Check for drawObject != null before invoking draw object created event. # The commit message #51 will be skipped: # Fix variant gamepath. # The commit message #52 will be skipped: # Material editor: use a SafeHandle for texture swapping # The commit message #53 will be skipped: # Material editor: Customizable highlight color # The commit message #54 will be skipped: # Material editor: Vector field spacing # The commit message #55 will be skipped: # Fix compiler warning # The commit message #56 will be skipped: # [CI] Updating repo.json for testing_0.7.3.4 # The commit message #57 will be skipped: # Resource Tree: Improve mtrl and sklb support # The commit message #58 will be skipped: # Resource Tree: Deduplicate nodes, add skp # The commit message #59 will be skipped: # Resource Tree: Add ChangedItem-like icons, make UI prettier # The commit message #60 will be skipped: # Resource Tree: Make skp child of sklb # The commit message #61 will be skipped: # Resource Tree: Fix shared model fold state # The commit message #62 will be skipped: # Some auto-formatting and ROS iteration for lookups. # The commit message #63 will be skipped: # Resource Tree: Use `/`s for game actual paths # The commit message #64 will be skipped: # Skin Fixer: Switch to a passive approach. # # Do not load skin.shpk for ourselves as it causes a race condition. # Instead, inspect the materials' ShPk names. # The commit message #65 will be skipped: # Some formatting, use ConcurrentSet explicitly for clarity. # The commit message #66 will be skipped: # [CI] Updating repo.json for testing_0.7.3.5 # The commit message #67 will be skipped: # Add Emotes to Changed Items. # The commit message #68 will be skipped: # [CI] Updating repo.json for testing_0.7.3.6 # The commit message #69 will be skipped: # Fix changed item flags for emotes. # The commit message #70 will be skipped: # Update GameData for new parsing. # The commit message #71 will be skipped: # Fix CS update creating ambiguous reference. # The commit message #72 will be skipped: # Add Player and Interface to quick select collections and rework their tooltips and names slightly. # The commit message #73 will be skipped: # [CI] Updating repo.json for testing_0.7.3.7 # The commit message #74 will be skipped: # Allow drag & drop of multiple mods or folders with Control. # The commit message #75 will be skipped: # [CI] Updating repo.json for testing_0.7.3.8 # The commit message #76 will be skipped: # Fix click check for selectables. # The commit message #77 will be skipped: # [CI] Updating repo.json for testing_0.7.3.9 # The commit message #78 will be skipped: # Add Filesystem Compression as a toggle and button. Also some auto-formatting. # The commit message #79 will be skipped: # [CI] Updating repo.json for testing_0.7.3.10 # The commit message #80 will be skipped: # Add Compacting to API AddMod. # The commit message #81 will be skipped: # Add key checks to restoring from backup or deleting backups. # The commit message #82 will be skipped: # Material Editor: Split ColorTable apart from ColorSet # The commit message #83 will be skipped: # GameData Commit. # The commit message #84 will be skipped: # Auto Formatting. # The commit message #85 will be skipped: # Use System global usings. # The commit message #86 will be skipped: # Make line endings explicit in editorconfig and share in sub projects, also apply editorconfig everywhere and move some namespaces. # The commit message #87 will be skipped: # ResourceTree improvements + IPC # # - Moves ResourceType enum out of GameData as discussed on Discord ; # - Adds new color coding for local player and non-networked objects on On-Screen ; # - Adds ResourceTree-related IPC ; # - Fixes #342. # The commit message #88 will be skipped: # ResourceTree IPC: Remove mergeSameCollection. # The commit message #89 will be skipped: # ResourceTree: Avoid enumerating the whole object table in some cases # The commit message #90 will be skipped: # Move IPC Arguments around. # The commit message #91 will be skipped: # Rename ResourceType file. # The commit message #92 will be skipped: # Remove enums folder from csproj?! # The commit message #93 will be skipped: # Fix params bug. # The commit message #94 will be skipped: # Api nuget version. # The commit message #95 will be skipped: # Add load state to resource watcher. # The commit message #96 will be skipped: # [CI] Updating repo.json for testing_0.7.3.11 # The commit message #97 will be skipped: # Add CalculateHeight Hook # The commit message #98 will be skipped: # ResourceTree: Reverse-resolve in bulk # The commit message #99 will be skipped: # Remove some allocations from resource tree. # The commit message #100 will be skipped: # Update OtterGui. # The commit message #101 will be skipped: # Fix ambiguous reference for no fucking reason. # The commit message #102 will be skipped: # [CI] Updating repo.json for testing_0.7.3.12 # The commit message #103 will be skipped: # Add automatic restore from backup for sort_order and active_collections for now. # The commit message #104 will be skipped: # Material Editor: Extend live preview. # The commit message #105 will be skipped: # Optimize ResourceTree somewhat.
1 parent 529788d commit d40e6a9

13 files changed

+2611
-15
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
path = Penumbra.String
1111
url = https://github.com/Ottermandias/Penumbra.String.git
1212
branch = main
13+
[submodule "LooseTextureCompilerCore"]
14+
path = LooseTextureCompilerCore
15+
url = https://github.com/Sebane1/LooseTextureCompilerCore.git
1316
[submodule "Penumbra.GameData"]
1417
path = Penumbra.GameData
1518
url = https://github.com/Ottermandias/Penumbra.GameData.git

LooseTextureCompilerCore

Penumbra.sln

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.Api", "Penumbra.Ap
1818
EndProject
1919
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "Penumbra.String\Penumbra.String.csproj", "{5549BAFD-6357-4B1A-800C-75AC36E5B76D}"
2020
EndProject
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LooseTextureCompilerCore", "LooseTextureCompilerCore\LooseTextureCompilerCore.csproj", "{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}"
22+
EndProject
2123
Global
2224
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2325
Debug|Any CPU = Debug|Any CPU
@@ -44,6 +46,10 @@ Global
4446
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|Any CPU.Build.0 = Debug|Any CPU
4547
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.ActiveCfg = Release|Any CPU
4648
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Release|Any CPU.Build.0 = Release|Any CPU
4753
EndGlobalSection
4854
GlobalSection(SolutionProperties) = preSolution
4955
HideSolutionNode = FALSE

Penumbra/Api/PenumbraIpcProviders.cs

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
using Dalamud.Game.ClientState.Objects.Types;
2-
using Dalamud.Plugin;
32
using Penumbra.GameData.Enums;
43
using Penumbra.Api.Enums;
54
using Penumbra.Api.Helpers;
65
using Penumbra.Collections.Manager;
76
using Penumbra.Mods.Manager;
87
using Penumbra.Services;
9-
using Penumbra.Util;
108

119
namespace Penumbra.Api;
1210

Penumbra/Import/Textures/BaseImage.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Lumina.Data.Files;
22
using OtterTex;
3+
using Penumbra.Api.Enums;
34
using SixLabors.ImageSharp;
45
using SixLabors.ImageSharp.PixelFormats;
56

@@ -103,7 +104,7 @@ public int MipMaps
103104
{
104105
null => 0,
105106
ScratchImage s => s.Meta.MipLevels,
106-
TexFile t => t.Header.MipLevelsCount,
107+
TexFile t => t.Header.MipLevels,
107108
_ => 1,
108109
};
109110
}

Penumbra/Import/Textures/CombinedTexture.cs

+65-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
using FFXIVLooseTextureCompiler.ImageProcessing;
2+
using SixLabors.ImageSharp;
3+
using SixLabors.ImageSharp.Formats.Png;
4+
using SixLabors.ImageSharp.PixelFormats;
5+
16
namespace Penumbra.Import.Textures;
27

38
public partial class CombinedTexture : IDisposable
@@ -138,8 +143,67 @@ public void Update()
138143
break;
139144
}
140145
}
146+
public void ImageToEyeMaps(string path, string textureCompilerDLC)
147+
{
148+
if (!IsLoaded || _current == null)
149+
{
150+
return;
151+
}
152+
153+
try
154+
{
155+
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
156+
_current.TextureWrap!.Height);
157+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
158+
ImageManipulation.ConvertToEyeMaps(path, textureCompilerDLC);
159+
}
160+
catch (Exception e)
161+
{
141162

142-
private void Clean()
163+
}
164+
}
165+
internal void EyeMultiToGrayscale(string path)
166+
{
167+
if (!IsLoaded || _current == null)
168+
{
169+
return;
170+
}
171+
172+
try
173+
{
174+
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
175+
_current.TextureWrap!.Height);
176+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
177+
System.Drawing.Bitmap multi = TexLoader.ResolveBitmap(path);
178+
ImageManipulation.ExtractRed(multi).Save(ImageManipulation.AddSuffix(path, "_grayscale"));
179+
}
180+
catch (Exception e)
181+
{
182+
183+
}
184+
}
185+
186+
public void AtramentumLuminisDiffuseToGlowMap(string path)
187+
{
188+
if (!IsLoaded || _current == null)
189+
{
190+
return;
191+
}
192+
193+
try
194+
{
195+
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
196+
_current.TextureWrap!.Height);
197+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
198+
System.Drawing.Bitmap diffuse = TexLoader.ResolveBitmap(path);
199+
AtramentumLuminisGlow.ExtractGlowMapFromDiffuse(diffuse).Save(path, System.Drawing.Imaging.ImageFormat.Png);
200+
}
201+
catch (Exception e)
202+
{
203+
204+
}
205+
}
206+
private void Clean()
143207
{
144208
_centerStorage.Dispose();
145209
_current = null;

Penumbra/Import/Textures/TexFileParser.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static void Write(this TexFile.TexHeader header, BinaryWriter w)
7979
w.Write(header.Width);
8080
w.Write(header.Height);
8181
w.Write(header.Depth);
82-
w.Write(header.MipLevelsCount);
82+
w.Write(header.MipLevels);
8383
w.Write((byte)0); // TODO Lumina Update
8484
unsafe
8585
{
@@ -99,7 +99,7 @@ public static TexFile.TexHeader ToTexHeader(this ScratchImage scratch)
9999
Height = (ushort)meta.Height,
100100
Width = (ushort)meta.Width,
101101
Depth = (ushort)Math.Max(meta.Depth, 1),
102-
MipLevelsCount = (byte)Math.Min(meta.MipLevels, 13),
102+
MipLevels = (byte)Math.Min(meta.MipLevels, 13),
103103
Format = meta.Format.ToTexFormat(),
104104
Type = meta.Dimension switch
105105
{
@@ -143,7 +143,7 @@ public static TexMeta ToTexMeta(this TexFile.TexHeader header)
143143
Height = header.Height,
144144
Width = header.Width,
145145
Depth = Math.Max(header.Depth, (ushort)1),
146-
MipLevels = header.MipLevelsCount,
146+
MipLevels = header.MipLevels,
147147
ArraySize = 1,
148148
Format = header.Format.ToDXGI(),
149149
Dimension = header.Type.ToDimension(),

Penumbra/Import/Textures/Texture.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using OtterTex;
33

44
namespace Penumbra.Import.Textures;
5-
65
public enum TextureType
76
{
87
Unknown,
@@ -11,9 +10,9 @@ public enum TextureType
1110
Png,
1211
Bitmap,
1312
}
14-
1513
public sealed class Texture : IDisposable
1614
{
15+
1716
// Path to the file we tried to load.
1817
public string Path = string.Empty;
1918

Penumbra/Import/Textures/TextureDrawer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static void DrawData(Texture texture)
105105
ImGuiUtil.DrawTableColumn("Format");
106106
ImGuiUtil.DrawTableColumn(t.Header.Format.ToString());
107107
ImGuiUtil.DrawTableColumn("Mip Levels");
108-
ImGuiUtil.DrawTableColumn(t.Header.MipLevelsCount.ToString());
108+
ImGuiUtil.DrawTableColumn(t.Header.MipLevels.ToString());
109109
ImGuiUtil.DrawTableColumn("Data Size");
110110
ImGuiUtil.DrawTableColumn($"{Functions.HumanReadableSize(t.ImageData.Length)} ({t.ImageData.Length} Bytes)");
111111
break;

Penumbra/Services/ServiceManagerA.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ private static ServiceManager AddInterface(this ServiceManager services)
165165
.AddSingleton<ModPanelEditTab>()
166166
.AddSingleton<ModPanelChangedItemsTab>()
167167
.AddSingleton<ModPanelConflictsTab>()
168-
.AddSingleton<ModPanelCollectionsTab>()
168+
.AddSingleton<ModPanelCollectionsTab>()
169+
.AddSingleton<ModPanelLooseAssetCompilerTab>()
169170
.AddSingleton<ModPanelTabBar>()
170171
.AddSingleton<ModFileSystemSelector>()
171172
.AddSingleton<CollectionsTab>()

Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs

+34
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,40 @@ private void DrawOutputChild(Vector2 size, Vector2 imageSize)
143143
_center.SaveAsTex(_textures, _left.Path, CombinedTexture.TextureSaveType.BC7, _left.MipMaps > 1);
144144
AddReloadTask(_left.Path, false);
145145
}
146+
string eyeMapResources = _config.ModDirectory + @"\LooseTextureCompilerDLC\";
147+
if (Directory.Exists(eyeMapResources))
148+
{
149+
if (ImGui.Button("Image To Eye Maps", -Vector2.UnitX))
150+
{
151+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
152+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
153+
{
154+
if (a)
155+
_center.ImageToEyeMaps(b, eyeMapResources);
156+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
157+
_forceTextureStartPath = false;
158+
}
159+
if (ImGui.Button("Eye Multi To Grayscale", -Vector2.UnitX))
160+
{
161+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
162+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
163+
{
164+
if (a)
165+
_center.EyeMultiToGrayscale(b);
166+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
167+
_forceTextureStartPath = false;
168+
}
169+
}
170+
if (ImGui.Button("Seperate Glow Information From Diffuse", -Vector2.UnitX))
171+
{
172+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
173+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
174+
{
175+
if (a)
176+
_center.AtramentumLuminisDiffuseToGlowMap(b);
177+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
178+
_forceTextureStartPath = false;
179+
}
146180

147181
ImGui.SameLine();
148182
if (ImGuiUtil.DrawDisabledButton("Convert to BC3", buttonSize3,

0 commit comments

Comments
 (0)