Load 3ds emitters and some fixes
This commit is contained in:
parent
e3284f0a84
commit
9005b9ee0f
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -252,7 +252,7 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.Seek(pos + 1616, SeekOrigin.Begin);
|
||||
reader.Seek(pos + 1072, SeekOrigin.Begin);
|
||||
ColorPosition = reader.Position;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -235,8 +235,11 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
uint TextureAmount = 3;
|
||||
if (header.IsSPBD)
|
||||
TextureAmount = 2;
|
||||
|
||||
for (int i = 0; i < 3; i++) //Max of 3 textures. Seems to fill in texture info even if unused
|
||||
for (int i = 0; i < TextureAmount; i++) //Max of 3 or 2 textures depending on version. Seems to fill in texture info even if unused
|
||||
{
|
||||
TextureInfo textureInfo = new TextureInfo();
|
||||
textureInfo.Read(reader, header, Text);
|
||||
@ -252,7 +255,10 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
reader.Seek(pos + 1616, SeekOrigin.Begin);
|
||||
if (header.IsSPBD)
|
||||
reader.Seek(pos + 1072, SeekOrigin.Begin);
|
||||
else
|
||||
reader.Seek(pos + 1616, SeekOrigin.Begin);
|
||||
ColorPosition = reader.Position;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@ -437,7 +443,7 @@ namespace FirstPlugin
|
||||
public uint TileMode;
|
||||
public uint Swizzle;
|
||||
public byte WrapMode;
|
||||
public uint CompSel;
|
||||
public byte[] CompSel;
|
||||
public uint ImageSize;
|
||||
public uint ImageOffset;
|
||||
public SurfaceFormat SurfFormat;
|
||||
@ -472,7 +478,7 @@ namespace FirstPlugin
|
||||
byte unk2 = reader.ReadByte();
|
||||
byte unk3 = reader.ReadByte();
|
||||
uint mipCount = reader.ReadUInt32();
|
||||
CompSel = reader.ReadUInt32();
|
||||
CompSel = reader.ReadBytes(4);
|
||||
uint[] MipOffsets = reader.ReadUInt32s(13);
|
||||
uint enableMipLevel = reader.ReadUInt32();
|
||||
uint mipBias = reader.ReadUInt32();
|
||||
@ -493,7 +499,7 @@ namespace FirstPlugin
|
||||
if (mipCount < 14)
|
||||
MipCount = mipCount;
|
||||
|
||||
CompSel = reader.ReadUInt32();
|
||||
CompSel = reader.ReadBytes(4);
|
||||
uint enableMipLevel = reader.ReadUInt32();
|
||||
uint mipBias = reader.ReadUInt32();
|
||||
uint originalDataFormat = reader.ReadUInt32();
|
||||
@ -503,6 +509,12 @@ namespace FirstPlugin
|
||||
ImageSize = reader.ReadUInt32();
|
||||
DataPos = reader.ReadUInt32();
|
||||
}
|
||||
|
||||
RedChannel = SetChannel(CompSel[0]);
|
||||
GreenChannel = SetChannel(CompSel[1]);
|
||||
BlueChannel = SetChannel(CompSel[2]);
|
||||
AlphaChannel = SetChannel(CompSel[3]);
|
||||
|
||||
ArrayCount = 1;
|
||||
Depth = 1;
|
||||
|
||||
@ -522,6 +534,16 @@ namespace FirstPlugin
|
||||
reader.Seek(164, SeekOrigin.Current);
|
||||
}
|
||||
|
||||
private STChannelType SetChannel(int comp)
|
||||
{
|
||||
if (comp == 0) return STChannelType.Red;
|
||||
else if (comp == 1) return STChannelType.Green;
|
||||
else if (comp == 2) return STChannelType.Blue;
|
||||
else if (comp == 3) return STChannelType.Alpha;
|
||||
else if (comp == 4) return STChannelType.Zero;
|
||||
else return STChannelType.One;
|
||||
}
|
||||
|
||||
public void Write(FileWriter writer, Header header)
|
||||
{
|
||||
if (data != null && data.Length > 0)
|
||||
|
@ -254,6 +254,8 @@ namespace FirstPlugin
|
||||
Width = image.Width;
|
||||
Height = image.Height;
|
||||
|
||||
LoadComponents(Format);
|
||||
|
||||
reader.Position = 0;
|
||||
ImageData = reader.ReadBytes((int)image.ImageSize);
|
||||
|
||||
@ -261,6 +263,26 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadComponents(TEX_FORMAT Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case TEX_FORMAT.BC5_SNORM:
|
||||
case TEX_FORMAT.BC5_UNORM:
|
||||
RedChannel = STChannelType.Red;
|
||||
GreenChannel = STChannelType.Red;
|
||||
BlueChannel = STChannelType.Red;
|
||||
AlphaChannel = STChannelType.Green;
|
||||
break;
|
||||
case TEX_FORMAT.BC4_SNORM:
|
||||
case TEX_FORMAT.BC4_UNORM:
|
||||
RedChannel = STChannelType.Red;
|
||||
GreenChannel = STChannelType.Red;
|
||||
BlueChannel = STChannelType.Red;
|
||||
AlphaChannel = STChannelType.Red;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private TEX_FORMAT GetFormat(BCLIMFormat format)
|
||||
{
|
||||
|
@ -265,6 +265,8 @@ namespace FirstPlugin
|
||||
Width = image.Width;
|
||||
Height = image.Height;
|
||||
|
||||
LoadComponents(Format);
|
||||
|
||||
uint ImageSize = reader.ReadUInt32();
|
||||
Console.WriteLine(ImageSize);
|
||||
|
||||
@ -276,6 +278,26 @@ namespace FirstPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadComponents(TEX_FORMAT Format)
|
||||
{
|
||||
switch (Format)
|
||||
{
|
||||
case TEX_FORMAT.BC5_SNORM:
|
||||
case TEX_FORMAT.BC5_UNORM:
|
||||
RedChannel = STChannelType.Red;
|
||||
GreenChannel = STChannelType.Red;
|
||||
BlueChannel = STChannelType.Red;
|
||||
AlphaChannel = STChannelType.Green;
|
||||
break;
|
||||
case TEX_FORMAT.BC4_SNORM:
|
||||
case TEX_FORMAT.BC4_UNORM:
|
||||
RedChannel = STChannelType.Red;
|
||||
GreenChannel = STChannelType.Red;
|
||||
BlueChannel = STChannelType.Red;
|
||||
AlphaChannel = STChannelType.Red;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private TEX_FORMAT GetFormat(BFLIMFormat format)
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
@ -32,6 +32,8 @@ namespace Switch_Toolbox.Library
|
||||
{
|
||||
switch (GenericFormat)
|
||||
{
|
||||
|
||||
case TEX_FORMAT.B5G6R5_UNORM: return PICASurfaceFormat.RGB565;
|
||||
case TEX_FORMAT.R8G8_UNORM: return PICASurfaceFormat.RGB8;
|
||||
case TEX_FORMAT.B5G5R5A1_UNORM: return PICASurfaceFormat.RGBA5551;
|
||||
case TEX_FORMAT.B4G4R4A4_UNORM: return PICASurfaceFormat.RGBA4;
|
||||
@ -48,6 +50,8 @@ namespace Switch_Toolbox.Library
|
||||
}
|
||||
}
|
||||
|
||||
private static int[] FmtBPP = new int[] { 32, 24, 16, 16, 16, 16, 16, 8, 8, 8, 4, 4, 4, 8 };
|
||||
|
||||
public static int[] SwizzleLUT =
|
||||
{
|
||||
0, 1, 8, 9, 2, 3, 10, 11,
|
||||
@ -67,7 +71,10 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
byte[] Output = new byte[Width * Height * 4];
|
||||
|
||||
int Increment = (int)STGenericTexture.GetBytesPerPixel(Format);
|
||||
int Increment = FmtBPP[(int)ConvertToPICAFormat(Format)] / 8;
|
||||
if (Increment == 0) Increment = 1;
|
||||
|
||||
// int Increment = (int)STGenericTexture.GetBytesPerPixel(Format);
|
||||
|
||||
int IOffset = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user