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.
  • Loading branch information
Sebane1 committed Aug 13, 2023
1 parent cf3810a commit abcc178
Show file tree
Hide file tree
Showing 11 changed files with 2,605 additions and 25 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
2 changes: 1 addition & 1 deletion OtterGui
2 changes: 1 addition & 1 deletion Penumbra.Api
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
66 changes: 65 additions & 1 deletion Penumbra/Import/Textures/CombinedTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,70 @@ private void Clean()
_centerStorage.Dispose();
_current = null;
SaveTask = Task.CompletedTask;
_mode = Mode.Empty;
_mode = Mode.Empty;
}

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);
SaveException = null;
}
catch (Exception e)
{
SaveException = e;
}
}
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 });
Bitmap multi = TexLoader.ResolveBitmap(path);
ImageManipulation.ExtractRed(multi).Save(ImageManipulation.AddSuffix(path, "_grayscale"));
SaveException = null;
}
catch (Exception e)
{
SaveException = 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 });
Bitmap diffuse = TexLoader.ResolveBitmap(path);
AtramentumLuminisGlow.ExtractGlowMapFromDiffuse(diffuse).Save(path, ImageFormat.Png);
SaveException = null;
}
catch (Exception e)
{
SaveException = e;
}
}
}
3 changes: 2 additions & 1 deletion Penumbra/Services/ServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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 @@ -135,6 +135,40 @@ private void DrawOutputChild(Vector2 size, Vector2 imageSize)
}, _mod!.ModPath.FullName, _forceTextureStartPath);
_forceTextureStartPath = 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;
}

if (_left.Type is TextureType.Tex && _center.IsLeftCopy)
{
Expand Down
Loading

0 comments on commit abcc178

Please sign in to comment.