mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-23 04:53:09 +00:00
Add original texture swizzle pattern to importer setting to prevent swizzle issues
This commit is contained in:
parent
44dea5fefd
commit
a4fb55b5e7
8 changed files with 18 additions and 7 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -193,7 +193,7 @@ namespace Bfres.Structs
|
|||
if (texture != null && texture.MipCount == 1)
|
||||
ReplaceTexture(FileName, Format, texture.MipCount);
|
||||
else
|
||||
ReplaceTexture(FileName, Format);
|
||||
ReplaceTexture(FileName, Format, 0, null, false, false, false, texture.SwizzlePattern);
|
||||
}
|
||||
|
||||
public void ReplaceTexture(string FileName, TEX_FORMAT DefaultFormat = TEX_FORMAT.UNKNOWN, uint MipMapCount = 0, TEX_FORMAT[] SupportedFormats = null,
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -621,21 +621,22 @@ namespace Switch_Toolbox.Library
|
|||
blkHeight = 1;
|
||||
}
|
||||
|
||||
byte[] data = new byte[tex.data.Length];
|
||||
Array.Copy(tex.data, 0, data, 0, tex.data.Length);
|
||||
|
||||
var surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, 0);
|
||||
uint bpp = DIV_ROUND_UP(surfInfo.bpp, 8);
|
||||
|
||||
if (tex.numArray == 0)
|
||||
tex.numArray = 1;
|
||||
|
||||
byte[] data = new byte[tex.data.Length];
|
||||
byte[] mipdata = new byte[tex.mipData.Length];
|
||||
|
||||
uint mipCount = tex.numMips;
|
||||
if (tex.mipData == null || tex.mipData.Length <= 0)
|
||||
mipCount = 1;
|
||||
|
||||
int dataOffset = 0;
|
||||
int mipDataOffset = 0;
|
||||
int mipSpliceSize = 0;
|
||||
|
||||
for (int arrayLevel = 0; arrayLevel < tex.depth; arrayLevel++)
|
||||
{
|
||||
|
@ -658,17 +659,27 @@ namespace Switch_Toolbox.Library
|
|||
|
||||
mipOffset = (tex.mipOffset[mipLevel - 1]);
|
||||
if (mipLevel == 1)
|
||||
{
|
||||
mipOffset -= (uint)surfInfo.surfSize;
|
||||
mipOffset += (uint)mipDataOffset;
|
||||
mipSpliceSize += (int)mipOffset;
|
||||
}
|
||||
|
||||
Console.WriteLine("mipOffset " + mipOffset);
|
||||
if (GetLevel)
|
||||
{
|
||||
surfInfo = getSurfaceInfo((GX2SurfaceFormat)tex.format, tex.width, tex.height, tex.depth, (uint)tex.dim, (uint)tex.tileMode, (uint)tex.aa, mipLevel);
|
||||
data = new byte[surfInfo.sliceSize];
|
||||
Array.Copy(tex.mipData, (uint)mipDataOffset + mipOffset, data, 0, surfInfo.sliceSize);
|
||||
|
||||
Array.Copy(tex.mipData, 0, mipdata, 0, tex.mipData.Length);
|
||||
Array.Copy(tex.mipData, (int)mipOffset, mipdata, 0, (int)surfInfo.sliceSize);
|
||||
data = mipdata;
|
||||
}
|
||||
}
|
||||
else if (GetLevel)
|
||||
{
|
||||
Array.Copy(tex.data, 0, data, 0, tex.data.Length);
|
||||
Array.Copy(tex.data, (uint)dataOffset, data, 0, size);
|
||||
}
|
||||
|
||||
if (GetLevel)
|
||||
{
|
||||
|
@ -682,7 +693,7 @@ namespace Switch_Toolbox.Library
|
|||
}
|
||||
|
||||
dataOffset += (int)surfInfo.sliceSize;
|
||||
mipDataOffset += (int)surfInfo.sliceSize;
|
||||
mipDataOffset += mipSpliceSize;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue