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 xivdev#9 will be skipped:

# Attempt to fix some texture errors.

# The commit message xivdev#10 will be skipped:

# Get penumbra to compile again.

# The commit message xivdev#11 will be skipped:

# Submodule update

# The commit message xivdev#12 will be skipped:

# Disable UI for textures when converting.

# The commit message xivdev#13 will be skipped:

# Update DirectXTex/OtterTex

# The commit message xivdev#14 will be skipped:

# Keep the texture alive during write.

# The commit message xivdev#15 will be skipped:

# [CI] Updating repo.json for 0.7.3.2

# The commit message xivdev#16 will be skipped:

# Explain comment.

# The commit message xivdev#17 will be skipped:

# Add some unnamed mounts to actor identification.

# The commit message xivdev#18 will be skipped:

# Material editor: improve color accuracy

# The commit message xivdev#19 will be skipped:

# Material editor: live-preview changes

# The commit message xivdev#20 will be skipped:

# Material editor 2099

# The commit message xivdev#21 will be skipped:

# Material editor: better color constants

# The commit message xivdev#22 will be skipped:

# Update GameData

# The commit message xivdev#23 will be skipped:

# Material editor: Allow negatives again with R²G²B²
#
# There seems to be people using it.

# The commit message xivdev#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 xivdev#25 will be skipped:

# Material editor: tear down previewers bound to a CharacterBase that goes away

# The commit message xivdev#26 will be skipped:

# Add a few texture manipulation tools.

# The commit message xivdev#27 will be skipped:

# Small cleanup, auto-formatting.

# The commit message xivdev#28 will be skipped:

# Textures: Un-merge save buttons, make ignore unselectable

# The commit message xivdev#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 xivdev#30 will be skipped:

# Textures: Automatic resizing

# The commit message xivdev#31 will be skipped:

# Textures: Add a matrix preset that drops alpha

# The commit message xivdev#32 will be skipped:

# Textures: PR xivdev#327 feedback

# The commit message xivdev#33 will be skipped:

# Textures: PR xivdev#327 feedback

# The commit message xivdev#34 will be skipped:

# Textures: Refactor resizing code

# The commit message xivdev#35 will be skipped:

# Textures: Simplify away _targetPixels

# The commit message xivdev#36 will be skipped:

# Slight restructuring.

# The commit message xivdev#37 will be skipped:

#  Skin Fixer (fixes modding of skin.shpk)

# The commit message xivdev#38 will be skipped:

# Skin Fixer: Make resolving skin.shpk for new draw objects async

# The commit message xivdev#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 xivdev#40 will be skipped:

# Use better event in SkinFixer and some cleanup.

# The commit message xivdev#41 will be skipped:

# Remove Finalize from FileEditor.

# The commit message xivdev#42 will be skipped:

# Some formatting in Materials.Shpk.

# The commit message xivdev#43 will be skipped:

# Small cleanup in ResolveContext.

# The commit message xivdev#44 will be skipped:

# Auto-formatting and some cleanup.

# The commit message xivdev#45 will be skipped:

# Restructure Live Preview.

# The commit message xivdev#46 will be skipped:

# Fix slash direction in material path.

# The commit message xivdev#47 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.3

# The commit message xivdev#48 will be skipped:

# Fix newtonsoft not playing well with records with strings.

# The commit message xivdev#49 will be skipped:

# Cleanup

# The commit message xivdev#50 will be skipped:

# Check for drawObject != null before invoking draw object created event.

# The commit message xivdev#51 will be skipped:

# Fix variant gamepath.

# The commit message xivdev#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 xivdev#54 will be skipped:

# Material editor: Vector field spacing

# The commit message xivdev#55 will be skipped:

# Fix compiler warning

# The commit message xivdev#56 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.4

# The commit message xivdev#57 will be skipped:

# Resource Tree: Improve mtrl and sklb support

# The commit message xivdev#58 will be skipped:

# Resource Tree: Deduplicate nodes, add skp

# The commit message xivdev#59 will be skipped:

# Resource Tree: Add ChangedItem-like icons, make UI prettier

# The commit message xivdev#60 will be skipped:

# Resource Tree: Make skp child of sklb

# The commit message xivdev#61 will be skipped:

# Resource Tree: Fix shared model fold state

# The commit message xivdev#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 xivdev#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 xivdev#65 will be skipped:

# Some formatting, use ConcurrentSet explicitly for clarity.

# The commit message xivdev#66 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.5

# The commit message xivdev#67 will be skipped:

# Add Emotes to Changed Items.

# The commit message xivdev#68 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.6

# The commit message xivdev#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 xivdev#71 will be skipped:

# Fix CS update creating ambiguous reference.

# The commit message xivdev#72 will be skipped:

# Add Player and Interface to quick select collections and rework their tooltips and names slightly.

# The commit message xivdev#73 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.7

# The commit message xivdev#74 will be skipped:

# Allow drag & drop of multiple mods or folders with Control.

# The commit message xivdev#75 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.8

# The commit message xivdev#76 will be skipped:

# Fix click check for selectables.

# The commit message xivdev#77 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.9

# The commit message xivdev#78 will be skipped:

# Add Filesystem Compression as a toggle and button. Also some auto-formatting.

# The commit message xivdev#79 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.10

# The commit message xivdev#80 will be skipped:

# Add Compacting to API AddMod.

# The commit message xivdev#81 will be skipped:

# Add key checks to restoring from backup or deleting backups.

# The commit message xivdev#82 will be skipped:

# Material Editor: Split ColorTable apart from ColorSet

# The commit message xivdev#83 will be skipped:

# GameData Commit.

# The commit message xivdev#84 will be skipped:

# Auto Formatting.

# The commit message xivdev#85 will be skipped:

# Use System global usings.

# The commit message xivdev#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 xivdev#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 xivdev#342.

# The commit message xivdev#88 will be skipped:

# ResourceTree IPC: Remove mergeSameCollection.

# The commit message xivdev#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 xivdev#91 will be skipped:

# Rename ResourceType file.

# The commit message xivdev#92 will be skipped:

# Remove enums folder from csproj?!

# The commit message xivdev#93 will be skipped:

# Fix params bug.

# The commit message #94 will be skipped:

# Api nuget version.

# The commit message xivdev#95 will be skipped:

# Add load state to resource watcher.

# The commit message xivdev#96 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.11

# The commit message xivdev#97 will be skipped:

# Add CalculateHeight Hook

# The commit message xivdev#98 will be skipped:

# ResourceTree: Reverse-resolve in bulk

# The commit message xivdev#99 will be skipped:

# Remove some allocations from resource tree.

# The commit message xivdev#100 will be skipped:

# Update OtterGui.

# The commit message xivdev#101 will be skipped:

# Fix ambiguous reference for no fucking reason.

# The commit message xivdev#102 will be skipped:

# [CI] Updating repo.json for testing_0.7.3.12

# The commit message xivdev#103 will be skipped:

# Add automatic restore from backup for sort_order and active_collections for now.

# The commit message xivdev#104 will be skipped:

# Material Editor: Extend live preview.

# The commit message xivdev#105 will be skipped:

# Optimize ResourceTree somewhat.
  • Loading branch information
Sebane1 committed Sep 23, 2023
1 parent 4c73453 commit 50f703b
Show file tree
Hide file tree
Showing 13 changed files with 2,636 additions and 28 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 = [email protected]:Ottermandias/Penumbra.String.git
branch = main
[submodule "LooseTextureCompilerCore"]
path = LooseTextureCompilerCore
url = https://github.com/Sebane1/LooseTextureCompilerCore.git
[submodule "Penumbra.GameData"]
path = Penumbra.GameData
url = [email protected]: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
2 changes: 0 additions & 2 deletions Penumbra/Api/PenumbraIpcProviders.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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;

namespace Penumbra.Api;

Expand Down
1 change: 1 addition & 0 deletions 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
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
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
4 changes: 3 additions & 1 deletion Penumbra/Penumbra.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@

<ItemGroup>
<PackageReference Include="EmbedIO" Version="3.4.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="SharpCompress" Version="0.33.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
</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" />
<ProjectReference Include="..\Penumbra.String\Penumbra.String.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Penumbra/Services/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ private static IServiceCollection AddInterface(this IServiceCollection 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 @@ -140,6 +140,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 50f703b

Please sign in to comment.