diff --git a/.vs/Switch_Toolbox/v15/.suo b/.vs/Switch_Toolbox/v15/.suo index a77e1446..65ba4fb8 100644 Binary files a/.vs/Switch_Toolbox/v15/.suo and b/.vs/Switch_Toolbox/v15/.suo differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide index 01410f83..833f5b6f 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal index c4856378..813ab1b4 100644 Binary files a/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal and b/.vs/Switch_Toolbox/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs index 607742ef..72ef3938 100644 --- a/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs +++ b/Switch_FileFormatsMain/FileFormats/BFRES/Bfres Structs/SubFiles/FTEX.cs @@ -134,9 +134,10 @@ namespace Bfres.Structs GTXImporterSettings setting = SetImporterSettings(image, FileName); setting.MipSwizzle = Tex2Swizzle; - GTXTextureImporter importer = new GTXTextureImporter(); + if (Tex2Swizzle != 0) + setting.Swizzle = Tex2SwizzleValue; - setting.MipSwizzle = Tex2Swizzle; + GTXTextureImporter importer = new GTXTextureImporter(); importer.LoadSetting(setting); if (importer.ShowDialog() == DialogResult.OK) @@ -200,6 +201,9 @@ namespace Bfres.Structs importer.ReadOnlySwizzle = IsSwizzleReadOnly; importer.ReadOnlyTileMode = IsSwizzleReadOnly; + if (Tex2Swizzle != 0) + setting.Swizzle = Tex2Swizzle; + if (MipMapCount != 0) { setting.MipCount = MipMapCount; diff --git a/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs b/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs index 2d52922f..e6bdd520 100644 --- a/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs +++ b/Switch_FileFormatsMain/FileFormats/Texture/BFLIM.cs @@ -150,7 +150,7 @@ namespace FirstPlugin if (ofd.ShowDialog() == DialogResult.OK) { FTEX ftex = new FTEX(); - ftex.ReplaceTexture(ofd.FileName, 1, SupportedFormats, true, true); + ftex.ReplaceTexture(ofd.FileName, 1, SupportedFormats); if (ftex.texture != null) { image.Swizzle = (byte)ftex.texture.Swizzle; diff --git a/Switch_FileFormatsMain/GUI/TextureUI/Importers/CreateGx2Texture.cs b/Switch_FileFormatsMain/GUI/TextureUI/Importers/CreateGx2Texture.cs index 39746baa..e7e233a2 100644 --- a/Switch_FileFormatsMain/GUI/TextureUI/Importers/CreateGx2Texture.cs +++ b/Switch_FileFormatsMain/GUI/TextureUI/Importers/CreateGx2Texture.cs @@ -20,8 +20,7 @@ namespace FirstPlugin setting.TexHeight, setting.Depth, (uint)setting.Format, - setting.SwizzlePattern, - setting.MipSwizzle, + setting.Swizzle, (uint)setting.SurfaceDim, setting.MipCount); } diff --git a/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXImporterSettings.cs b/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXImporterSettings.cs index 4ede6cf5..5789c791 100644 --- a/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXImporterSettings.cs +++ b/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXImporterSettings.cs @@ -27,6 +27,7 @@ namespace FirstPlugin public uint tileMode = 4; public uint SwizzlePattern = 0; + public uint Swizzle = 0; public uint MipSwizzle = 0; public GX2CompSel[] compSel = new GX2CompSel[4]; diff --git a/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXTextureImporter.cs b/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXTextureImporter.cs index 91cca6ff..68d52b37 100644 --- a/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXTextureImporter.cs +++ b/Switch_FileFormatsMain/GUI/TextureUI/Importers/GTXTextureImporter.cs @@ -205,12 +205,13 @@ namespace FirstPlugin MipmapNum.Value = SelectedTexSettings.MipCount; - SwizzleNum.Value = SelectedTexSettings.SwizzlePattern; + SwizzleNum.Value = (SelectedTexSettings.Swizzle >> 8) & 7; } } private void SwizzleNum_ValueChanged(object sender, EventArgs e) { - SelectedTexSettings.SwizzlePattern = (uint)SwizzleNum.Value; + SelectedTexSettings.Swizzle &= GX2.SwizzleMask; + SelectedTexSettings.Swizzle |= (uint)SwizzleNum.Value << 8; } /// diff --git a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache index 54f71a19..514623c1 100644 Binary files a/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache and b/Switch_FileFormatsMain/obj/Release/DesignTimeResolveAssemblyReferences.cache differ diff --git a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache index 96ff8a12..2f95d37e 100644 Binary files a/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache and b/Switch_FileFormatsMain/obj/Release/Switch_FileFormatsMain.csprojAssemblyReference.cache differ diff --git a/Switch_Toolbox_Library/Swizzling/GX2.cs b/Switch_Toolbox_Library/Swizzling/GX2.cs index 2e0bc007..7ce0782c 100644 --- a/Switch_Toolbox_Library/Swizzling/GX2.cs +++ b/Switch_Toolbox_Library/Swizzling/GX2.cs @@ -432,7 +432,7 @@ namespace Switch_Toolbox.Library static bool DebugSurface = false; public static GX2Surface CreateGx2Texture(byte[] imageData, string Name, uint TileMode, uint AAMode, - uint Width, uint Height, uint Depth, uint Format, uint swizzle, uint mipSwizzle, uint SurfaceDim, uint MipCount) + uint Width, uint Height, uint Depth, uint Format, uint swizzle, uint SurfaceDim, uint MipCount) { var surfOut = getSurfaceInfo((GX2SurfaceFormat)Format, Width, Height, 1, 1, TileMode, 0, 0); uint imageSize = (uint)surfOut.surfSize; @@ -474,8 +474,6 @@ namespace Switch_Toolbox.Library for (int mipLevel = 0; mipLevel < MipCount; mipLevel++) { - uint swizzleValue = s; - var result = TextureHelper.GetCurrentMipSize(Width, Height, blkWidth, blkHeight, bpp, mipLevel); uint offset = result.Item1; @@ -489,9 +487,6 @@ namespace Switch_Toolbox.Library if (mipLevel != 0) { - if (mipSwizzle != 0) - swizzleValue = mipSwizzle; - surfOut = GX2.getSurfaceInfo((GX2SurfaceFormat)Format, Width, Height, 1, 1, TileMode, 0, mipLevel); if (mipLevel == 1) @@ -506,7 +501,7 @@ namespace Switch_Toolbox.Library if (mipLevel != 0) mipSize += (uint)(surfOut.surfSize + dataAlignBytes.Length); - byte[] SwizzledData = GX2.swizzle(width_, height_, surfOut.depth, surfOut.height, (uint)Format, surfOut.tileMode, swizzleValue, + byte[] SwizzledData = GX2.swizzle(width_, height_, surfOut.depth, surfOut.height, (uint)Format, surfOut.tileMode, s, surfOut.pitch, surfOut.bpp, data_, DepthLevel); Swizzled.Add(dataAlignBytes.Concat(SwizzledData).ToArray());