mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
parent
d3a8bfb71c
commit
2255e82c0c
@ -50,11 +50,17 @@ public static class TextureConverter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryGetTextureFormat((GraphicsFormat)texture.Format, out TextureFormat format))
|
||||
{
|
||||
bitmap = DirectBitmap.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryConvertToBitmap(
|
||||
texture.GetTextureFormat(),
|
||||
format,
|
||||
texture.Width,
|
||||
texture.Height,
|
||||
texture.ImageCount,
|
||||
texture.Depth,
|
||||
texture.GetCompleteImageSize(),
|
||||
texture.Collection.Version,
|
||||
buffer,
|
||||
@ -83,7 +89,7 @@ public static class TextureConverter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryGetTextureFormat(texture, out TextureFormat format))
|
||||
if (!TryGetTextureFormat((GraphicsFormat)texture.Format, out TextureFormat format))
|
||||
{
|
||||
bitmap = DirectBitmap.Empty;
|
||||
return false;
|
||||
@ -105,26 +111,6 @@ public static class TextureConverter
|
||||
bitmap.FlipY();
|
||||
|
||||
return true;
|
||||
|
||||
static bool TryGetTextureFormat(ITexture2DArray texture, out TextureFormat format)
|
||||
{
|
||||
try
|
||||
{
|
||||
format = ((GraphicsFormat)texture.Format).ToTextureFormat();
|
||||
return true;
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
format = default;
|
||||
return false;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
Logger.Log(LogType.Error, LogCategory.Export, $"Unknown GraphicsFormat '{texture.Format}'");
|
||||
format = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryConvertToBitmap(ICubemapArray texture, out DirectBitmap bitmap)
|
||||
@ -136,8 +122,14 @@ public static class TextureConverter
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryGetTextureFormat((GraphicsFormat)texture.Format, out TextureFormat format))
|
||||
{
|
||||
bitmap = DirectBitmap.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryConvertToBitmap(
|
||||
texture.FormatE,
|
||||
format,
|
||||
texture.Width,
|
||||
texture.GetHeight(),
|
||||
texture.GetDepth(),
|
||||
@ -584,6 +576,26 @@ public static class TextureConverter
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TryGetTextureFormat(GraphicsFormat graphicsFormat, out TextureFormat format)
|
||||
{
|
||||
try
|
||||
{
|
||||
format = graphicsFormat.ToTextureFormat();
|
||||
return true;
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
format = default;
|
||||
return false;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
Logger.Log(LogType.Error, LogCategory.Export, $"Unknown GraphicsFormat '{(int)graphicsFormat}'");
|
||||
format = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void UnpackNormal(Span<byte> data)
|
||||
{
|
||||
for (int i = 0; i < data.Length; i += 4)
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AssetRipper.Checksum" Version="1.1.0" />
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.3.1" />
|
||||
<PackageReference Include="AssetRipper.SourceGenerated" Version="1.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -37,15 +37,44 @@ public static class Texture3DExtensions
|
||||
}
|
||||
}
|
||||
|
||||
extension (ITexture3D texture)
|
||||
{
|
||||
public int Format
|
||||
{
|
||||
get
|
||||
{
|
||||
if (texture.Has_Format_Int32())
|
||||
{
|
||||
return texture.Format_Int32;
|
||||
}
|
||||
else
|
||||
{
|
||||
return unchecked((int)texture.Format_UInt32);
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (texture.Has_Format_Int32())
|
||||
{
|
||||
texture.Format_Int32 = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture.Format_UInt32 = unchecked((uint)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TextureFormat GetTextureFormat(this ITexture3D texture)
|
||||
{
|
||||
if (texture.Has_Format_Int32())
|
||||
{
|
||||
return texture.Format_Int32E;
|
||||
return ((GraphicsFormat)texture.Format_Int32).ToTextureFormat();
|
||||
}
|
||||
else
|
||||
{
|
||||
return texture.Format_UInt32E;
|
||||
return ((GraphicsFormat)texture.Format_UInt32).ToTextureFormat();
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,13 +92,13 @@ public static class Texture3DExtensions
|
||||
|
||||
public static int GetCompleteImageSize(this ITexture3D texture)
|
||||
{
|
||||
if (texture.Has_DataSize())
|
||||
if (texture.Has_CompleteImageSize_UInt32())
|
||||
{
|
||||
return (int)texture.DataSize;
|
||||
return (int)texture.CompleteImageSize_UInt32;
|
||||
}
|
||||
else
|
||||
{
|
||||
return texture.CompleteImageSize;
|
||||
return texture.CompleteImageSize_Int32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user