Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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/Services/StaticServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,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
Loading