Skip to content

Commit abcc178

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.
1 parent cf3810a commit abcc178

11 files changed

+2605
-25
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
path = Penumbra.String
1111
url = [email protected]: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 = [email protected]: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/Import/Textures/CombinedTexture.cs

+65-1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,70 @@ private void Clean()
135135
_centerStorage.Dispose();
136136
_current = null;
137137
SaveTask = Task.CompletedTask;
138-
_mode = Mode.Empty;
138+
_mode = Mode.Empty;
139+
}
140+
141+
public void ImageToEyeMaps(string path, string textureCompilerDLC)
142+
{
143+
if (!IsLoaded || _current == null)
144+
{
145+
return;
146+
}
147+
148+
try
149+
{
150+
var image = Image.LoadPixelData<Rgba32>(_current.RGBAPixels, _current.TextureWrap!.Width,
151+
_current.TextureWrap!.Height);
152+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
153+
ImageManipulation.ConvertToEyeMaps(path, textureCompilerDLC);
154+
SaveException = null;
155+
}
156+
catch (Exception e)
157+
{
158+
SaveException = e;
159+
}
160+
}
161+
internal void EyeMultiToGrayscale(string path)
162+
{
163+
if (!IsLoaded || _current == null)
164+
{
165+
return;
166+
}
167+
168+
try
169+
{
170+
var image = Image.LoadPixelData<Rgba32>(_current.RGBAPixels, _current.TextureWrap!.Width,
171+
_current.TextureWrap!.Height);
172+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
173+
Bitmap multi = TexLoader.ResolveBitmap(path);
174+
ImageManipulation.ExtractRed(multi).Save(ImageManipulation.AddSuffix(path, "_grayscale"));
175+
SaveException = null;
176+
}
177+
catch (Exception e)
178+
{
179+
SaveException = e;
180+
}
181+
}
182+
183+
public void AtramentumLuminisDiffuseToGlowMap(string path)
184+
{
185+
if (!IsLoaded || _current == null)
186+
{
187+
return;
188+
}
189+
190+
try
191+
{
192+
var image = Image.LoadPixelData<Rgba32>(_current.RGBAPixels, _current.TextureWrap!.Width,
193+
_current.TextureWrap!.Height);
194+
image.Save(path, new PngEncoder() { CompressionLevel = PngCompressionLevel.NoCompression });
195+
Bitmap diffuse = TexLoader.ResolveBitmap(path);
196+
AtramentumLuminisGlow.ExtractGlowMapFromDiffuse(diffuse).Save(path, ImageFormat.Png);
197+
SaveException = null;
198+
}
199+
catch (Exception e)
200+
{
201+
SaveException = e;
202+
}
139203
}
140204
}

Penumbra/Services/ServiceManager.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ private static IServiceCollection AddInterface(this IServiceCollection services)
150150
.AddSingleton<ModPanelEditTab>()
151151
.AddSingleton<ModPanelChangedItemsTab>()
152152
.AddSingleton<ModPanelConflictsTab>()
153-
.AddSingleton<ModPanelCollectionsTab>()
153+
.AddSingleton<ModPanelCollectionsTab>()
154+
.AddSingleton<ModPanelLooseAssetCompilerTab>()
154155
.AddSingleton<ModPanelTabBar>()
155156
.AddSingleton<ModFileSystemSelector>()
156157
.AddSingleton<CollectionsTab>()

Penumbra/UI/AdvancedWindow/ModEditWindow.Textures.cs

+34
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,40 @@ private void DrawOutputChild(Vector2 size, Vector2 imageSize)
135135
}, _mod!.ModPath.FullName, _forceTextureStartPath);
136136
_forceTextureStartPath = false;
137137
}
138+
string eyeMapResources = _config.ModDirectory + @"\LooseTextureCompilerDLC\";
139+
if (Directory.Exists(eyeMapResources))
140+
{
141+
if (ImGui.Button("Image To Eye Maps", -Vector2.UnitX))
142+
{
143+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
144+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
145+
{
146+
if (a)
147+
_center.ImageToEyeMaps(b, eyeMapResources);
148+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
149+
_forceTextureStartPath = false;
150+
}
151+
if (ImGui.Button("Eye Multi To Grayscale", -Vector2.UnitX))
152+
{
153+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
154+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
155+
{
156+
if (a)
157+
_center.EyeMultiToGrayscale(b);
158+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
159+
_forceTextureStartPath = false;
160+
}
161+
}
162+
if (ImGui.Button("Seperate Glow Information From Diffuse", -Vector2.UnitX))
163+
{
164+
var fileName = Path.GetFileNameWithoutExtension(_right.Path.Length > 0 ? _right.Path : _left.Path);
165+
_fileDialog.OpenSavePicker("Save Texture as PNG...", ".png", fileName, ".png", (a, b) =>
166+
{
167+
if (a)
168+
_center.AtramentumLuminisDiffuseToGlowMap(b);
169+
}, _mod!.ModPath.FullName, _forceTextureStartPath);
170+
_forceTextureStartPath = false;
171+
}
138172

139173
if (_left.Type is TextureType.Tex && _center.IsLeftCopy)
140174
{

0 commit comments

Comments
 (0)