Skip to content

Commit

Permalink
Add Asset Compiler tab
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sebane1 committed Feb 21, 2024
1 parent 529788d commit a327724
Show file tree
Hide file tree
Showing 15 changed files with 2,648 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
path = Penumbra.String
url = https://github.com/Ottermandias/Penumbra.String.git
branch = main
[submodule "LooseTextureCompilerCore"]
path = LooseTextureCompilerCore
url = https://github.com/Sebane1/LooseTextureCompilerCore.git
[submodule "Penumbra.GameData"]
path = Penumbra.GameData
url = https://github.com/Ottermandias/Penumbra.GameData.git
Expand Down
1 change: 1 addition & 0 deletions LooseTextureCompilerCore
6 changes: 6 additions & 0 deletions Penumbra.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.Api", "Penumbra.Ap
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "Penumbra.String\Penumbra.String.csproj", "{5549BAFD-6357-4B1A-800C-75AC36E5B76D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LooseTextureCompilerCore", "LooseTextureCompilerCore\LooseTextureCompilerCore.csproj", "{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,6 +46,10 @@ Global
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5549BAFD-6357-4B1A-800C-75AC36E5B76D}.Release|Any CPU.Build.0 = Release|Any CPU
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39769DC8-E6B7-4C5C-8758-7FB36F6A7FB4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 1 addition & 2 deletions Penumbra/Api/PenumbraIpcProviders.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Plugin;
using Penumbra.GameData.Enums;
using Penumbra.Api.Enums;
using Penumbra.Api.Helpers;
using Penumbra.Collections.Manager;
using Penumbra.Mods.Manager;
using Penumbra.Services;
using Penumbra.Util;
using Dalamud.Plugin;

namespace Penumbra.Api;

Expand Down
3 changes: 2 additions & 1 deletion Penumbra/Import/Textures/BaseImage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Lumina.Data.Files;
using OtterTex;
using Penumbra.Api.Enums;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

Expand Down Expand Up @@ -103,7 +104,7 @@ public int MipMaps
{
null => 0,
ScratchImage s => s.Meta.MipLevels,
TexFile t => t.Header.MipLevelsCount,
TexFile t => t.Header.MipLevels,
_ => 1,
};
}
66 changes: 65 additions & 1 deletion Penumbra/Import/Textures/CombinedTexture.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
using FFXIVLooseTextureCompiler.ImageProcessing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;

namespace Penumbra.Import.Textures;

public partial class CombinedTexture : IDisposable
Expand Down Expand Up @@ -138,8 +143,67 @@ public void Update()
break;
}
}
public void ImageToEyeMaps(string path, string textureCompilerDLC)
{
if (!IsLoaded || _current == null)
{
return;
}

try
{
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
_current.TextureWrap!.Height);
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
ImageManipulation.ConvertToEyeMaps(path, textureCompilerDLC);
}
catch (Exception e)
{

private void Clean()
}
}
internal void EyeMultiToGrayscale(string path)
{
if (!IsLoaded || _current == null)
{
return;
}

try
{
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
_current.TextureWrap!.Height);
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
System.Drawing.Bitmap multi = TexLoader.ResolveBitmap(path);
ImageManipulation.ExtractRed(multi).Save(ImageManipulation.AddSuffix(path, "_grayscale"));
}
catch (Exception e)
{

}
}

public void AtramentumLuminisDiffuseToGlowMap(string path)
{
if (!IsLoaded || _current == null)
{
return;
}

try
{
var image = Image.LoadPixelData<Rgba32>(_current.RgbaPixels, _current.TextureWrap!.Width,
_current.TextureWrap!.Height);
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
System.Drawing.Bitmap diffuse = TexLoader.ResolveBitmap(path);
AtramentumLuminisGlow.ExtractGlowMapFromDiffuse(diffuse).Save(path, System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception e)
{

}
}
private void Clean()
{
_centerStorage.Dispose();
_current = null;
Expand Down
6 changes: 3 additions & 3 deletions Penumbra/Import/Textures/TexFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static void Write(this TexFile.TexHeader header, BinaryWriter w)
w.Write(header.Width);
w.Write(header.Height);
w.Write(header.Depth);
w.Write(header.MipLevelsCount);
w.Write(header.MipLevels);
w.Write((byte)0); // TODO Lumina Update
unsafe
{
Expand All @@ -99,7 +99,7 @@ public static TexFile.TexHeader ToTexHeader(this ScratchImage scratch)
Height = (ushort)meta.Height,
Width = (ushort)meta.Width,
Depth = (ushort)Math.Max(meta.Depth, 1),
MipLevelsCount = (byte)Math.Min(meta.MipLevels, 13),
MipLevels = (byte)Math.Min(meta.MipLevels, 13),
Format = meta.Format.ToTexFormat(),
Type = meta.Dimension switch
{
Expand Down Expand Up @@ -143,7 +143,7 @@ public static TexMeta ToTexMeta(this TexFile.TexHeader header)
Height = header.Height,
Width = header.Width,
Depth = Math.Max(header.Depth, (ushort)1),
MipLevels = header.MipLevelsCount,
MipLevels = header.MipLevels,
ArraySize = 1,
Format = header.Format.ToDXGI(),
Dimension = header.Type.ToDimension(),
Expand Down
3 changes: 1 addition & 2 deletions Penumbra/Import/Textures/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using OtterTex;

namespace Penumbra.Import.Textures;

public enum TextureType
{
Unknown,
Expand All @@ -11,9 +10,9 @@ public enum TextureType
Png,
Bitmap,
}

public sealed class Texture : IDisposable
{

// Path to the file we tried to load.
public string Path = string.Empty;

Expand Down
2 changes: 1 addition & 1 deletion Penumbra/Import/Textures/TextureDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private static void DrawData(Texture texture)
ImGuiUtil.DrawTableColumn("Format");
ImGuiUtil.DrawTableColumn(t.Header.Format.ToString());
ImGuiUtil.DrawTableColumn("Mip Levels");
ImGuiUtil.DrawTableColumn(t.Header.MipLevelsCount.ToString());
ImGuiUtil.DrawTableColumn(t.Header.MipLevels.ToString());
ImGuiUtil.DrawTableColumn("Data Size");
ImGuiUtil.DrawTableColumn($"{Functions.HumanReadableSize(t.ImageData.Length)} ({t.ImageData.Length} Bytes)");
break;
Expand Down
3 changes: 2 additions & 1 deletion Penumbra/Penumbra.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@
<ItemGroup>
<PackageReference Include="EmbedIO" Version="3.4.3" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.8.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="SharpCompress" Version="0.33.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="SharpGLTF.Core" Version="1.0.0-alpha0030" />
<PackageReference Include="SharpGLTF.Toolkit" Version="1.0.0-alpha0030" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LooseTextureCompilerCore\LooseTextureCompilerCore.csproj" />
<ProjectReference Include="..\OtterGui\OtterGui.csproj" />
<ProjectReference Include="..\Penumbra.GameData\Penumbra.GameData.csproj" />
<ProjectReference Include="..\Penumbra.Api\Penumbra.Api.csproj" />
Expand Down
3 changes: 2 additions & 1 deletion Penumbra/Services/ServiceManagerA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ private static ServiceManager AddInterface(this ServiceManager services)
.AddSingleton<ModPanelEditTab>()
.AddSingleton<ModPanelChangedItemsTab>()
.AddSingleton<ModPanelConflictsTab>()
.AddSingleton<ModPanelCollectionsTab>()
.AddSingleton<ModPanelCollectionsTab>()
.AddSingleton<ModPanelLooseAssetCompilerTab>()
.AddSingleton<ModPanelTabBar>()
.AddSingleton<ModFileSystemSelector>()
.AddSingleton<CollectionsTab>()
Expand Down
34 changes: 34 additions & 0 deletions Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,40 @@ private void DrawOutputChild(Vector2 size, Vector2 imageSize)
_center.SaveAsTex(_textures, _left.Path, CombinedTexture.TextureSaveType.BC7, _left.MipMaps > 1);
AddReloadTask(_left.Path, false);
}
string eyeMapResources = _config.ModDirectory + @"\LooseTextureCompilerDLC\";
if (Directory.Exists(eyeMapResources))
{
if (ImGui.Button("Image To Eye Maps", -Vector2.UnitX))
{
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
{
if (a)
_center.ImageToEyeMaps(b, eyeMapResources);
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = false;
}
if (ImGui.Button("Eye Multi To Grayscale", -Vector2.UnitX))
{
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
{
if (a)
_center.EyeMultiToGrayscale(b);
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = false;
}
}
if (ImGui.Button("Seperate Glow Information From Diffuse", -Vector2.UnitX))
{
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
{
if (a)
_center.AtramentumLuminisDiffuseToGlowMap(b);
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = false;
}

ImGui.SameLine();
if (ImGuiUtil.DrawDisabledButton("Convert to BC3", buttonSize3,
Expand Down
Loading

0 comments on commit a327724

Please sign in to comment.