From 0f9afa60d72ab1b15f1e85fbe56312b0426b442f Mon Sep 17 00:00:00 2001 From: VaDiM Date: Tue, 27 Feb 2024 22:17:24 +0300 Subject: [PATCH] Add support for Texture2DArray --- AssetStudio/AssetsManager.cs | 5 + AssetStudio/ClassIDType.cs | 1 + AssetStudio/Classes/EditorExtension.cs | 2 + AssetStudio/Classes/GLTextureSettings.cs | 29 + AssetStudio/Classes/GraphicsFormat.cs | 711 +++++++++++++++++++++++ AssetStudio/Classes/NamedObject.cs | 2 + AssetStudio/Classes/Object.cs | 2 + AssetStudio/Classes/StreamingInfo.cs | 25 + AssetStudio/Classes/Texture.cs | 9 +- AssetStudio/Classes/Texture2D.cs | 222 ++++--- AssetStudio/Classes/Texture2DArray.cs | 54 ++ AssetStudio/Classes/TextureFormat.cs | 282 +++++++++ AssetStudio/ResourceReader.cs | 3 +- AssetStudioCLI/Exporter.cs | 22 + AssetStudioCLI/Options/CLIOptions.cs | 4 + AssetStudioCLI/Studio.cs | 17 + AssetStudioGUI/AssetStudioGUIForm.cs | 16 +- AssetStudioGUI/Exporter.cs | 22 + AssetStudioGUI/Studio.cs | 25 + AssetStudioUtility/Texture2DConverter.cs | 2 +- 20 files changed, 1321 insertions(+), 134 deletions(-) create mode 100644 AssetStudio/Classes/GLTextureSettings.cs create mode 100644 AssetStudio/Classes/GraphicsFormat.cs create mode 100644 AssetStudio/Classes/StreamingInfo.cs create mode 100644 AssetStudio/Classes/Texture2DArray.cs create mode 100644 AssetStudio/Classes/TextureFormat.cs diff --git a/AssetStudio/AssetsManager.cs b/AssetStudio/AssetsManager.cs index 4e4cbe4..c4281a6 100644 --- a/AssetStudio/AssetsManager.cs +++ b/AssetStudio/AssetsManager.cs @@ -569,6 +569,9 @@ namespace AssetStudio case ClassIDType.Texture2D: obj = new Texture2D(objectReader); break; + case ClassIDType.Texture2DArray: + obj = new Texture2DArray(objectReader); + break; case ClassIDType.Transform: obj = new Transform(objectReader); break; @@ -583,7 +586,9 @@ namespace AssetStudio break; } if (obj != null) + { assetsFile.AddObject(obj); + } } catch (Exception e) { diff --git a/AssetStudio/ClassIDType.cs b/AssetStudio/ClassIDType.cs index f827cae..2568be0 100644 --- a/AssetStudio/ClassIDType.cs +++ b/AssetStudio/ClassIDType.cs @@ -145,6 +145,7 @@ namespace AssetStudio ProceduralMaterial = 185, ProceduralTexture = 186, Texture2DArray = 187, + Texture2DArrayImage = -187, //fake type CubemapArray = 188, OffMeshLink = 191, OcclusionArea = 192, diff --git a/AssetStudio/Classes/EditorExtension.cs b/AssetStudio/Classes/EditorExtension.cs index 1605f2c..aacfccc 100644 --- a/AssetStudio/Classes/EditorExtension.cs +++ b/AssetStudio/Classes/EditorExtension.cs @@ -7,6 +7,8 @@ namespace AssetStudio { public abstract class EditorExtension : Object { + protected EditorExtension() { } + protected EditorExtension(ObjectReader reader) : base(reader) { if (platform == BuildTarget.NoTarget) diff --git a/AssetStudio/Classes/GLTextureSettings.cs b/AssetStudio/Classes/GLTextureSettings.cs new file mode 100644 index 0000000..455076c --- /dev/null +++ b/AssetStudio/Classes/GLTextureSettings.cs @@ -0,0 +1,29 @@ +namespace AssetStudio +{ + public class GLTextureSettings + { + public int m_FilterMode; + public int m_Aniso; + public float m_MipBias; + public int m_WrapMode; + + public GLTextureSettings(ObjectReader reader) + { + var version = reader.version; + + m_FilterMode = reader.ReadInt32(); + m_Aniso = reader.ReadInt32(); + m_MipBias = reader.ReadSingle(); + if (version[0] >= 2017)//2017.x and up + { + m_WrapMode = reader.ReadInt32(); //m_WrapU + int m_WrapV = reader.ReadInt32(); + int m_WrapW = reader.ReadInt32(); + } + else + { + m_WrapMode = reader.ReadInt32(); + } + } + } +} diff --git a/AssetStudio/Classes/GraphicsFormat.cs b/AssetStudio/Classes/GraphicsFormat.cs new file mode 100644 index 0000000..64e50ea --- /dev/null +++ b/AssetStudio/Classes/GraphicsFormat.cs @@ -0,0 +1,711 @@ +namespace AssetStudio +{ + public enum GraphicsFormat + { + /// + /// The format is not specified. + /// + None, + /// + /// A one-component, 8-bit unsigned normalized format that has a single 8-bit R component stored with sRGB nonlinear encoding. + /// + R8_SRGB, + /// + /// A two-component, 16-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, and an 8-bit G component stored with sRGB nonlinear encoding in byte 1. + /// + R8G8_SRGB, + /// + /// A three-component, 24-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, and an 8-bit B component stored with sRGB nonlinear encoding in byte 2. + /// + R8G8B8_SRGB, + /// + /// A four-component, 32-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, an 8-bit B component stored with sRGB nonlinear encoding in byte 2, and an 8-bit A component in byte 3. + /// + R8G8B8A8_SRGB, + /// + /// A one-component, 8-bit unsigned normalized format that has a single 8-bit R component. + /// + R8_UNorm, + /// + /// A two-component, 16-bit unsigned normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, and an 8-bit G component stored with sRGB nonlinear encoding in byte 1. + /// + R8G8_UNorm, + /// + /// A three-component, 24-bit unsigned normalized format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, and an 8-bit B component in byte 2. + /// + R8G8B8_UNorm, + /// + /// A four-component, 32-bit unsigned normalized format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, an 8-bit B component in byte 2, and an 8-bit A component in byte 3. + /// + R8G8B8A8_UNorm, + /// + /// A one-component, 8-bit signed normalized format that has a single 8-bit R component. + /// + R8_SNorm, + /// + /// A two-component, 16-bit signed normalized format that has an 8-bit R component stored with sRGB nonlinear encoding in byte 0, and an 8-bit G component stored with sRGB nonlinear encoding in byte 1. + /// + R8G8_SNorm, + /// + /// A three-component, 24-bit signed normalized format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, and an 8-bit B component in byte 2. + /// + R8G8B8_SNorm, + /// + /// A four-component, 32-bit signed normalized format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, an 8-bit B component in byte 2, and an 8-bit A component in byte 3. + /// + R8G8B8A8_SNorm, + /// + /// A one-component, 8-bit unsigned integer format that has a single 8-bit R component. + /// + R8_UInt, + /// + /// A two-component, 16-bit unsigned integer format that has an 8-bit R component in byte 0, and an 8-bit G component in byte 1. + /// + R8G8_UInt, + /// + /// A three-component, 24-bit unsigned integer format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, and an 8-bit B component in byte 2. + /// + R8G8B8_UInt, + /// + /// A four-component, 32-bit unsigned integer format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, an 8-bit B component in byte 2, and an 8-bit A component in byte 3. + /// + R8G8B8A8_UInt, + /// + /// A one-component, 8-bit signed integer format that has a single 8-bit R component. + /// + R8_SInt, + /// + /// A two-component, 16-bit signed integer format that has an 8-bit R component in byte 0, and an 8-bit G component in byte 1. + /// + R8G8_SInt, + /// + /// A three-component, 24-bit signed integer format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, and an 8-bit B component in byte 2. + /// + R8G8B8_SInt, + /// + /// A four-component, 32-bit signed integer format that has an 8-bit R component in byte 0, an 8-bit G component in byte 1, an 8-bit B component in byte 2, and an 8-bit A component in byte 3. + /// + R8G8B8A8_SInt, + /// + /// A one-component, 16-bit unsigned normalized format that has a single 16-bit R component. + /// + R16_UNorm, + /// + /// A two-component, 32-bit unsigned normalized format that has a 16-bit R component in bytes 0..1, and a 16-bit G component in bytes 2..3. + /// + R16G16_UNorm, + /// + /// A three-component, 48-bit unsigned normalized format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, and a 16-bit B component in bytes 4..5. + /// + R16G16B16_UNorm, + /// + /// A four-component, 64-bit unsigned normalized format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, a 16-bit B component in bytes 4..5, and a 16-bit A component in bytes 6..7. + /// + R16G16B16A16_UNorm, + /// + /// A one-component, 16-bit signed normalized format that has a single 16-bit R component. + /// + R16_SNorm, + /// + /// A two-component, 32-bit signed normalized format that has a 16-bit R component in bytes 0..1, and a 16-bit G component in bytes 2..3. + /// + R16G16_SNorm, + /// + /// A three-component, 48-bit signed normalized format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, and a 16-bit B component in bytes 4..5. + /// + R16G16B16_SNorm, + /// + /// A four-component, 64-bit signed normalized format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, a 16-bit B component in bytes 4..5, and a 16-bit A component in bytes 6..7. + /// + R16G16B16A16_SNorm, + /// + /// A one-component, 16-bit unsigned integer format that has a single 16-bit R component. + /// + R16_UInt, + /// + /// A two-component, 32-bit unsigned integer format that has a 16-bit R component in bytes 0..1, and a 16-bit G component in bytes 2..3. + /// + R16G16_UInt, + /// + /// A three-component, 48-bit unsigned integer format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, and a 16-bit B component in bytes 4..5. + /// + R16G16B16_UInt, + /// + /// A four-component, 64-bit unsigned integer format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, a 16-bit B component in bytes 4..5, and a 16-bit A component in bytes 6..7. + /// + R16G16B16A16_UInt, + /// + /// A one-component, 16-bit signed integer format that has a single 16-bit R component. + /// + R16_SInt, + /// + /// A two-component, 32-bit signed integer format that has a 16-bit R component in bytes 0..1, and a 16-bit G component in bytes 2..3. + /// + R16G16_SInt, + /// + /// A three-component, 48-bit signed integer format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, and a 16-bit B component in bytes 4..5. + /// + R16G16B16_SInt, + /// + /// A four-component, 64-bit signed integer format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, a 16-bit B component in bytes 4..5, and a 16-bit A component in bytes 6..7. + /// + R16G16B16A16_SInt, + /// + /// A one-component, 32-bit unsigned integer format that has a single 32-bit R component. + /// + R32_UInt, + /// + /// A two-component, 64-bit unsigned integer format that has a 32-bit R component in bytes 0..3, and a 32-bit G component in bytes 4..7. + /// + R32G32_UInt, + /// + /// A three-component, 96-bit unsigned integer format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, and a 32-bit B component in bytes 8..11. + /// + R32G32B32_UInt, + /// + /// A four-component, 128-bit unsigned integer format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, a 32-bit B component in bytes 8..11, and a 32-bit A component in bytes 12..15. + /// + R32G32B32A32_UInt, + /// + /// A one-component, 32-bit signed integer format that has a single 32-bit R component. + /// + R32_SInt, + /// + /// A two-component, 64-bit signed integer format that has a 32-bit R component in bytes 0..3, and a 32-bit G component in bytes 4..7. + /// + R32G32_SInt, + /// + /// A three-component, 96-bit signed integer format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, and a 32-bit B component in bytes 8..11. + /// + R32G32B32_SInt, + /// + /// A four-component, 128-bit signed integer format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, a 32-bit B component in bytes 8..11, and a 32-bit A component in bytes 12..15. + /// + R32G32B32A32_SInt, + /// + /// A one-component, 16-bit signed floating-point format that has a single 16-bit R component. + /// + R16_SFloat, + /// + /// A two-component, 32-bit signed floating-point format that has a 16-bit R component in bytes 0..1, and a 16-bit G component in bytes 2..3. + /// + R16G16_SFloat, + /// + /// A three-component, 48-bit signed floating-point format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, and a 16-bit B component in bytes 4..5. + /// + R16G16B16_SFloat, + /// + /// A four-component, 64-bit signed floating-point format that has a 16-bit R component in bytes 0..1, a 16-bit G component in bytes 2..3, a 16-bit B component in bytes 4..5, and a 16-bit A component in bytes 6..7. + /// + R16G16B16A16_SFloat, + /// + /// A one-component, 32-bit signed floating-point format that has a single 32-bit R component. + /// + R32_SFloat, + /// + /// A two-component, 64-bit signed floating-point format that has a 32-bit R component in bytes 0..3, and a 32-bit G component in bytes 4..7. + /// + R32G32_SFloat, + /// + /// A three-component, 96-bit signed floating-point format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, and a 32-bit B component in bytes 8..11. + /// + R32G32B32_SFloat, + /// + /// A four-component, 128-bit signed floating-point format that has a 32-bit R component in bytes 0..3, a 32-bit G component in bytes 4..7, a 32-bit B component in bytes 8..11, and a 32-bit A component in bytes 12..15. + /// + R32G32B32A32_SFloat, + /// + /// A three-component, 24-bit unsigned normalized format that has an 8-bit B component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, and an 8-bit R component stored with sRGB nonlinear encoding in byte 2. + /// + B8G8R8_SRGB = 56, + /// + /// A four-component, 32-bit unsigned normalized format that has an 8-bit B component stored with sRGB nonlinear encoding in byte 0, an 8-bit G component stored with sRGB nonlinear encoding in byte 1, an 8-bit R component stored with sRGB nonlinear encoding in byte 2, and an 8-bit A component in byte 3. + /// + B8G8R8A8_SRGB, + /// + /// A three-component, 24-bit unsigned normalized format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, and an 8-bit R component in byte 2. + /// + B8G8R8_UNorm, + /// + /// A four-component, 32-bit unsigned normalized format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, an 8-bit R component in byte 2, and an 8-bit A component in byte 3. + /// + B8G8R8A8_UNorm, + /// + /// A three-component, 24-bit signed normalized format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, and an 8-bit R component in byte 2. + /// + B8G8R8_SNorm, + /// + /// A four-component, 32-bit signed normalized format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, an 8-bit R component in byte 2, and an 8-bit A component in byte 3. + /// + B8G8R8A8_SNorm, + /// + /// A three-component, 24-bit unsigned integer format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, and an 8-bit R component in byte 2 + /// + B8G8R8_UInt, + /// + /// A four-component, 32-bit unsigned integer format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, an 8-bit R component in byte 2, and an 8-bit A component in byte 3. + /// + B8G8R8A8_UInt, + /// + /// A three-component, 24-bit signed integer format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, and an 8-bit R component in byte 2. + /// + B8G8R8_SInt, + /// + /// A four-component, 32-bit signed integer format that has an 8-bit B component in byte 0, an 8-bit G component in byte 1, an 8-bit R component in byte 2, and an 8-bit A component in byte 3. + /// + B8G8R8A8_SInt, + /// + /// A four-component, 16-bit packed unsigned normalized format that has a 4-bit R component in bits 12..15, a 4-bit G component in bits 8..11, a 4-bit B component in bits 4..7, and a 4-bit A component in bits 0..3. + /// + R4G4B4A4_UNormPack16, + /// + /// A four-component, 16-bit packed unsigned normalized format that has a 4-bit B component in bits 12..15, a 4-bit G component in bits 8..11, a 4-bit R component in bits 4..7, and a 4-bit A component in bits 0..3. + /// + B4G4R4A4_UNormPack16, + /// + /// A three-component, 16-bit packed unsigned normalized format that has a 5-bit R component in bits 11..15, a 6-bit G component in bits 5..10, and a 5-bit B component in bits 0..4. + /// + R5G6B5_UNormPack16, + /// + /// A three-component, 16-bit packed unsigned normalized format that has a 5-bit B component in bits 11..15, a 6-bit G component in bits 5..10, and a 5-bit R component in bits 0..4. + /// + B5G6R5_UNormPack16, + /// + /// A four-component, 16-bit packed unsigned normalized format that has a 5-bit R component in bits 11..15, a 5-bit G component in bits 6..10, a 5-bit B component in bits 1..5, and a 1-bit A component in bit 0. + /// + R5G5B5A1_UNormPack16, + /// + /// A four-component, 16-bit packed unsigned normalized format that has a 5-bit B component in bits 11..15, a 5-bit G component in bits 6..10, a 5-bit R component in bits 1..5, and a 1-bit A component in bit 0. + /// + B5G5R5A1_UNormPack16, + /// + /// A four-component, 16-bit packed unsigned normalized format that has a 1-bit A component in bit 15, a 5-bit R component in bits 10..14, a 5-bit G component in bits 5..9, and a 5-bit B component in bits 0..4. + /// + A1R5G5B5_UNormPack16, + /// + /// A three-component, 32-bit packed unsigned floating-point format that has a 5-bit shared exponent in bits 27..31, a 9-bit B component mantissa in bits 18..26, a 9-bit G component mantissa in bits 9..17, and a 9-bit R component mantissa in bits 0..8. + /// + E5B9G9R9_UFloatPack32, + /// + /// A three-component, 32-bit packed unsigned floating-point format that has a 10-bit B component in bits 22..31, an 11-bit G component in bits 11..21, an 11-bit R component in bits 0..10. + /// + B10G11R11_UFloatPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 2-bit A component in bits 30..31, a 10-bit B component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit R component in bits 0..9. + /// + A2B10G10R10_UNormPack32, + /// + /// A four-component, 32-bit packed unsigned integer format that has a 2-bit A component in bits 30..31, a 10-bit B component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit R component in bits 0..9. + /// + A2B10G10R10_UIntPack32, + /// + /// A four-component, 32-bit packed signed integer format that has a 2-bit A component in bits 30..31, a 10-bit B component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit R component in bits 0..9. + /// + A2B10G10R10_SIntPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 2-bit A component in bits 30..31, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. + /// + A2R10G10B10_UNormPack32, + /// + /// A four-component, 32-bit packed unsigned integer format that has a 2-bit A component in bits 30..31, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. + /// + A2R10G10B10_UIntPack32, + /// + /// A four-component, 32-bit packed signed integer format that has a 2-bit A component in bits 30..31, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. + /// + A2R10G10B10_SIntPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 2-bit A component in bits 30..31, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are gamma encoded and their values range from -0.5271 to 1.66894. The alpha component is clamped to either 0.0 or 1.0 on sampling, rendering, and writing operations. + /// + A2R10G10B10_XRSRGBPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 2-bit A component in bits 30..31, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are linearly encoded and their values range from -0.752941 to 1.25098 (pre-expansion). The alpha component is clamped to either 0.0 or 1.0 on sampling, rendering, and writing operations. + /// + A2R10G10B10_XRUNormPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are gamma encoded and their values range from -0.5271 to 1.66894. The alpha component is clamped to either 0.0 or 1.0 on sampling, rendering, and writing operations. + /// + R10G10B10_XRSRGBPack32, + /// + /// A four-component, 32-bit packed unsigned normalized format that has a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are linearly encoded and their values range from -0.752941 to 1.25098 (pre-expansion). + /// + R10G10B10_XRUNormPack32, + /// + /// A four-component, 64-bit packed unsigned normalized format that has a 10-bit A component in bits 30..39, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are gamma encoded and their values range from -0.5271 to 1.66894. The alpha component is clamped to either 0.0 or 1.0 on sampling, rendering, and writing operations. + /// + A10R10G10B10_XRSRGBPack32, + /// + /// A four-component, 64-bit packed unsigned normalized format that has a 10-bit A component in bits 30..39, a 10-bit R component in bits 20..29, a 10-bit G component in bits 10..19, and a 10-bit B component in bits 0..9. The components are linearly encoded and their values range from -0.752941 to 1.25098 (pre-expansion). The alpha component is clamped to either 0.0 or 1.0 on sampling, rendering, and writing operations. + /// + A10R10G10B10_XRUNormPack32, + /// + /// A one-component, 16-bit unsigned normalized format that has a single 16-bit depth component. + /// + D16_UNorm = 90, + /// + /// A two-component, 32-bit format that has 24 unsigned normalized bits in the depth component and, optionally: 8 bits that are unused. + /// + D24_UNorm, + /// + /// A two-component, 32-bit packed format that has 8 unsigned integer bits in the stencil component, and 24 unsigned normalized bits in the depth component. + /// + D24_UNorm_S8_UInt, + /// + /// A one-component, 32-bit signed floating-point format that has 32-bits in the depth component. + /// + D32_SFloat, + /// + /// A two-component format that has 32 signed float bits in the depth component and 8 unsigned integer bits in the stencil component. There are optionally: 24-bits that are unused. + /// + D32_SFloat_S8_UInt, + /// + /// A one-component, 8-bit unsigned integer format that has 8-bits in the stencil component. + /// + S8_UInt, + /// + /// A three-component, block-compressed format (also known as BC1). Each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data with sRGB nonlinear encoding. This format has a 1 bit alpha channel. + /// + RGBA_DXT1_SRGB, + /// + /// A three-component, block-compressed format (also known as BC1). Each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data. This format has a 1 bit alpha channel. + /// + RGBA_DXT1_UNorm, + /// + /// A four-component, block-compressed format (also known as BC2) where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values with sRGB nonlinear encoding. + /// + RGBA_DXT3_SRGB, + /// + /// A four-component, block-compressed format (also known as BC2) where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values. + /// + RGBA_DXT3_UNorm, + /// + /// A four-component, block-compressed format (also known as BC3) where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values with sRGB nonlinear encoding. + /// + RGBA_DXT5_SRGB, + /// + /// A four-component, block-compressed format (also known as BC3) where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values. + /// + RGBA_DXT5_UNorm, + /// + /// A one-component, block-compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized red texel data. + /// + R_BC4_UNorm, + /// + /// A one-component, block-compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of signed normalized red texel data. + /// + R_BC4_SNorm, + /// + /// A two-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RG texel data with the first 64 bits encoding red values followed by 64 bits encoding green values. + /// + RG_BC5_UNorm, + /// + /// A two-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of signed normalized RG texel data with the first 64 bits encoding red values followed by 64 bits encoding green values. + /// + RG_BC5_SNorm, + /// + /// A three-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned floating-point RGB texel data. + /// + RGB_BC6H_UFloat, + /// + /// A three-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of signed floating-point RGB texel data. + /// + RGB_BC6H_SFloat, + /// + /// A four-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_BC7_SRGB, + /// + /// A four-component, block-compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_BC7_UNorm, + /// + /// A three-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 8×4 rectangle of unsigned normalized RGB texel data with sRGB nonlinear encoding. This format has no alpha and is considered opaque. + /// + RGB_PVRTC_2Bpp_SRGB, + /// + /// A three-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 8×4 rectangle of unsigned normalized RGB texel data. This format has no alpha and is considered opaque. + /// + RGB_PVRTC_2Bpp_UNorm, + /// + /// A three-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data with sRGB nonlinear encoding. This format has no alpha and is considered opaque. + /// + RGB_PVRTC_4Bpp_SRGB, + /// + /// A three-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data. This format has no alpha and is considered opaque. + /// + RGB_PVRTC_4Bpp_UNorm, + /// + /// A four-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 8×4 rectangle of unsigned normalized RGBA texel data with the first 32 bits encoding alpha values followed by 32 bits encoding RGB values with sRGB nonlinear encoding applied. + /// + RGBA_PVRTC_2Bpp_SRGB, + /// + /// A four-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 8×4 rectangle of unsigned normalized RGBA texel data with the first 32 bits encoding alpha values followed by 32 bits encoding RGB values. + /// + RGBA_PVRTC_2Bpp_UNorm, + /// + /// A four-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 32 bits encoding alpha values followed by 32 bits encoding RGB values with sRGB nonlinear encoding applied. + /// + RGBA_PVRTC_4Bpp_SRGB, + /// + /// A four-component, PVRTC compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 32 bits encoding alpha values followed by 32 bits encoding RGB values. + /// + RGBA_PVRTC_4Bpp_UNorm, + /// + /// A three-component, ETC compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data. This format has no alpha and is considered opaque. + /// + RGB_ETC_UNorm, + /// + /// A three-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data with sRGB nonlinear encoding. This format has no alpha and is considered opaque. + /// + RGB_ETC2_SRGB, + /// + /// A three-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data. This format has no alpha and is considered opaque. + /// + RGB_ETC2_UNorm, + /// + /// A four-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data with sRGB nonlinear encoding, and provides 1 bit of alpha. + /// + RGB_A1_ETC2_SRGB, + /// + /// A four-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGB texel data, and provides 1 bit of alpha. + /// + RGB_A1_ETC2_UNorm, + /// + /// A four-component, ETC2 compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values with sRGB nonlinear encoding applied. + /// + RGBA_ETC2_SRGB, + /// + /// A four-component, ETC2 compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with the first 64 bits encoding alpha values followed by 64 bits encoding RGB values. + /// + RGBA_ETC2_UNorm, + /// + /// A one-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized red texel data. + /// + R_EAC_UNorm, + /// + /// A one-component, ETC2 compressed format where each 64-bit compressed texel block encodes a 4×4 rectangle of signed normalized red texel data. + /// + R_EAC_SNorm, + /// + /// A two-component, ETC2 compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RG texel data with the first 64 bits encoding red values followed by 64 bits encoding green values. + /// + RG_EAC_UNorm, + /// + /// A two-component, ETC2 compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of signed normalized RG texel data with the first 64 bits encoding red values followed by 64 bits encoding green values. + /// + RG_EAC_SNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC4X4_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC4X4_UNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 5×5 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC5X5_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 5×5 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC5X5_UNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 6×6 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC6X6_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 6×6 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC6X6_UNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes an 8×8 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC8X8_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes an 8×8 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC8X8_UNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 10×10 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC10X10_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 10×10 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC10X10_UNorm, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 12×12 rectangle of unsigned normalized RGBA texel data with sRGB nonlinear encoding applied to the RGB components. + /// + RGBA_ASTC12X12_SRGB, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 12×12 rectangle of unsigned normalized RGBA texel data. + /// + RGBA_ASTC12X12_UNorm, + /// + /// YUV 4:2:2 Video resource format. + /// + YUV2, + /// + /// GraphicsFormat.YUV2. + /// + VideoAuto = 144, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 4×4 rectangle of float RGBA texel data. + /// + RGBA_ASTC4X4_UFloat, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 5×5 rectangle of float RGBA texel data. + /// + RGBA_ASTC5X5_UFloat, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 6×6 rectangle of float RGBA texel data. + /// + RGBA_ASTC6X6_UFloat, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes an 8×8 rectangle of float RGBA texel data. + /// + RGBA_ASTC8X8_UFloat, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 10×10 rectangle of float RGBA texel data. + /// + RGBA_ASTC10X10_UFloat, + /// + /// A four-component, ASTC compressed format where each 128-bit compressed texel block encodes a 12×12 rectangle of float RGBA texel data. + /// + RGBA_ASTC12X12_UFloat, + /// + /// A two-component, 24-bit format that has 16 unsigned normalized bits in the depth component and 8 unsigned integer bits in the stencil component. Most platforms do not support this format. + /// + D16_UNorm_S8_UInt, + } + + public static class GraphicsFormatExtension + { + public static TextureFormat ToTextureFormat(this GraphicsFormat graphicsFormat) + { + switch (graphicsFormat) + { + case GraphicsFormat.R8_SRGB: + case GraphicsFormat.R8_UInt: + case GraphicsFormat.R8_UNorm: + return TextureFormat.R8; + case GraphicsFormat.R8G8_SRGB: + case GraphicsFormat.R8G8_UInt: + case GraphicsFormat.R8G8_UNorm: + return TextureFormat.RG16; + case GraphicsFormat.R8G8B8_SRGB: + case GraphicsFormat.R8G8B8_UInt: + case GraphicsFormat.R8G8B8_UNorm: + return TextureFormat.RGB24; + case GraphicsFormat.R8G8B8A8_SRGB: + case GraphicsFormat.R8G8B8A8_UInt: + case GraphicsFormat.R8G8B8A8_UNorm: + return TextureFormat.RGBA32; + case GraphicsFormat.R16_UInt: + case GraphicsFormat.R16_UNorm: + return TextureFormat.R16; + case GraphicsFormat.R16G16_UInt: + case GraphicsFormat.R16G16_UNorm: + return TextureFormat.RG32; + case GraphicsFormat.R16G16B16_UInt: + case GraphicsFormat.R16G16B16_UNorm: + return TextureFormat.RGB48; + case GraphicsFormat.R16G16B16A16_UInt: + case GraphicsFormat.R16G16B16A16_UNorm: + return TextureFormat.RGBA64; + case GraphicsFormat.R16_SFloat: + return TextureFormat.RHalf; + case GraphicsFormat.R16G16_SFloat: + return TextureFormat.RGHalf; + case GraphicsFormat.R16G16B16_SFloat: //? + case GraphicsFormat.R16G16B16A16_SFloat: + return TextureFormat.RGBAHalf; + case GraphicsFormat.R32_SFloat: + return TextureFormat.RFloat; + case GraphicsFormat.R32G32_SFloat: + return TextureFormat.RGFloat; + case GraphicsFormat.R32G32B32_SFloat: //? + case GraphicsFormat.R32G32B32A32_SFloat: + return TextureFormat.RGBAFloat; + case GraphicsFormat.B8G8R8A8_SRGB: + case GraphicsFormat.B8G8R8A8_UInt: + case GraphicsFormat.B8G8R8A8_UNorm: + return TextureFormat.BGRA32; + case GraphicsFormat.E5B9G9R9_UFloatPack32: + return TextureFormat.RGB9e5Float; + case GraphicsFormat.RGBA_DXT1_SRGB: + case GraphicsFormat.RGBA_DXT1_UNorm: + return TextureFormat.DXT1; + case GraphicsFormat.RGBA_DXT3_SRGB: + case GraphicsFormat.RGBA_DXT3_UNorm: + return TextureFormat.DXT3; + case GraphicsFormat.RGBA_DXT5_SRGB: + case GraphicsFormat.RGBA_DXT5_UNorm: + return TextureFormat.DXT5; + case GraphicsFormat.R_BC4_UNorm: + return TextureFormat.BC4; + case GraphicsFormat.RG_BC5_UNorm: + return TextureFormat.BC5; + case GraphicsFormat.RGB_BC6H_SFloat: + case GraphicsFormat.RGB_BC6H_UFloat: + return TextureFormat.BC6H; + case GraphicsFormat.RGBA_BC7_SRGB: + case GraphicsFormat.RGBA_BC7_UNorm: + return TextureFormat.BC7; + case GraphicsFormat.RGB_PVRTC_2Bpp_SRGB: + case GraphicsFormat.RGB_PVRTC_2Bpp_UNorm: + case GraphicsFormat.RGBA_PVRTC_2Bpp_SRGB: + case GraphicsFormat.RGBA_PVRTC_2Bpp_UNorm: + return TextureFormat.PVRTC_RGBA2; + case GraphicsFormat.RGB_PVRTC_4Bpp_SRGB: + case GraphicsFormat.RGB_PVRTC_4Bpp_UNorm: + case GraphicsFormat.RGBA_PVRTC_4Bpp_SRGB: + case GraphicsFormat.RGBA_PVRTC_4Bpp_UNorm: + return TextureFormat.PVRTC_RGBA4; + case GraphicsFormat.RGB_ETC_UNorm: + return TextureFormat.ETC_RGB4; + case GraphicsFormat.RGB_ETC2_SRGB: + case GraphicsFormat.RGB_ETC2_UNorm: + return TextureFormat.ETC2_RGB; + case GraphicsFormat.RGB_A1_ETC2_SRGB: + case GraphicsFormat.RGB_A1_ETC2_UNorm: + return TextureFormat.ETC2_RGBA1; + case GraphicsFormat.RGBA_ETC2_SRGB: + case GraphicsFormat.RGBA_ETC2_UNorm: + return TextureFormat.ETC2_RGBA8; + case GraphicsFormat.R_EAC_UNorm: + return TextureFormat.EAC_R; + case GraphicsFormat.R_EAC_SNorm: + return TextureFormat.EAC_R_SIGNED; + case GraphicsFormat.RG_EAC_UNorm: + return TextureFormat.EAC_RG; + case GraphicsFormat.RG_EAC_SNorm: + return TextureFormat.EAC_RG_SIGNED; + case GraphicsFormat.RGBA_ASTC4X4_SRGB: + case GraphicsFormat.RGBA_ASTC4X4_UNorm: + return TextureFormat.ASTC_RGBA_4x4; + case GraphicsFormat.RGBA_ASTC5X5_SRGB: + case GraphicsFormat.RGBA_ASTC5X5_UNorm: + return TextureFormat.ASTC_RGBA_5x5; + case GraphicsFormat.RGBA_ASTC6X6_SRGB: + case GraphicsFormat.RGBA_ASTC6X6_UNorm: + return TextureFormat.ASTC_RGBA_6x6; + case GraphicsFormat.RGBA_ASTC8X8_SRGB: + case GraphicsFormat.RGBA_ASTC8X8_UNorm: + return TextureFormat.ASTC_RGBA_8x8; + case GraphicsFormat.RGBA_ASTC10X10_SRGB: + case GraphicsFormat.RGBA_ASTC10X10_UNorm: + return TextureFormat.ASTC_RGBA_10x10; + case GraphicsFormat.RGBA_ASTC12X12_SRGB: + case GraphicsFormat.RGBA_ASTC12X12_UNorm: + return TextureFormat.ASTC_RGBA_12x12; + case GraphicsFormat.YUV2: + case GraphicsFormat.VideoAuto: + return TextureFormat.YUY2; + default: + return 0; + } + } + } +} diff --git a/AssetStudio/Classes/NamedObject.cs b/AssetStudio/Classes/NamedObject.cs index d43db4e..d1ea5fd 100644 --- a/AssetStudio/Classes/NamedObject.cs +++ b/AssetStudio/Classes/NamedObject.cs @@ -9,6 +9,8 @@ namespace AssetStudio { public string m_Name; + protected NamedObject() { } + protected NamedObject(ObjectReader reader) : base(reader) { m_Name = reader.ReadAlignedString(); diff --git a/AssetStudio/Classes/Object.cs b/AssetStudio/Classes/Object.cs index 87ea4fc..1b15db6 100644 --- a/AssetStudio/Classes/Object.cs +++ b/AssetStudio/Classes/Object.cs @@ -18,6 +18,8 @@ namespace AssetStudio public SerializedType serializedType; public uint byteSize; + public Object() { } + public Object(ObjectReader reader) { this.reader = reader; diff --git a/AssetStudio/Classes/StreamingInfo.cs b/AssetStudio/Classes/StreamingInfo.cs new file mode 100644 index 0000000..8221a8e --- /dev/null +++ b/AssetStudio/Classes/StreamingInfo.cs @@ -0,0 +1,25 @@ +namespace AssetStudio +{ + public class StreamingInfo + { + public long offset; //ulong + public uint size; + public string path; + + public StreamingInfo(ObjectReader reader) + { + var version = reader.version; + + if (version[0] >= 2020) //2020.1 and up + { + offset = reader.ReadInt64(); + } + else + { + offset = reader.ReadUInt32(); + } + size = reader.ReadUInt32(); + path = reader.ReadAlignedString(); + } + } +} diff --git a/AssetStudio/Classes/Texture.cs b/AssetStudio/Classes/Texture.cs index 8da11a8..8fc9f3c 100644 --- a/AssetStudio/Classes/Texture.cs +++ b/AssetStudio/Classes/Texture.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AssetStudio +namespace AssetStudio { public abstract class Texture : NamedObject { + protected Texture() { } + protected Texture(ObjectReader reader) : base(reader) { if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 3)) //2017.3 and up diff --git a/AssetStudio/Classes/Texture2D.cs b/AssetStudio/Classes/Texture2D.cs index 84a84d0..200a6ea 100644 --- a/AssetStudio/Classes/Texture2D.cs +++ b/AssetStudio/Classes/Texture2D.cs @@ -2,72 +2,58 @@ namespace AssetStudio { - public class StreamingInfo - { - public long offset; //ulong - public uint size; - public string path; - - public StreamingInfo(ObjectReader reader) - { - var version = reader.version; - - if (version[0] >= 2020) //2020.1 and up - { - offset = reader.ReadInt64(); - } - else - { - offset = reader.ReadUInt32(); - } - size = reader.ReadUInt32(); - path = reader.ReadAlignedString(); - } - } - - public class GLTextureSettings - { - public int m_FilterMode; - public int m_Aniso; - public float m_MipBias; - public int m_WrapMode; - - public GLTextureSettings(ObjectReader reader) - { - var version = reader.version; - - m_FilterMode = reader.ReadInt32(); - m_Aniso = reader.ReadInt32(); - m_MipBias = reader.ReadSingle(); - if (version[0] >= 2017)//2017.x and up - { - m_WrapMode = reader.ReadInt32(); //m_WrapU - int m_WrapV = reader.ReadInt32(); - int m_WrapW = reader.ReadInt32(); - } - else - { - m_WrapMode = reader.ReadInt32(); - } - } - } - public sealed class Texture2D : Texture { public int m_Width; public int m_Height; + public int m_CompleteImageSize; public TextureFormat m_TextureFormat; public bool m_MipMap; public int m_MipCount; public GLTextureSettings m_TextureSettings; + public int m_ImageCount; public ResourceReader image_data; public StreamingInfo m_StreamData; + public Texture2D() { } + + public Texture2D(Texture2DArray m_Texture2DArray, int layer) + { + reader = m_Texture2DArray.reader; + assetsFile = m_Texture2DArray.assetsFile; + version = m_Texture2DArray.version; + platform = m_Texture2DArray.platform; + + m_Name = $"{m_Texture2DArray.m_Name}_{layer + 1}"; + type = ClassIDType.Texture2DArrayImage; + m_PathID = -1; + + m_Width = m_Texture2DArray.m_Width; + m_Height = m_Texture2DArray.m_Height; + m_TextureFormat = m_Texture2DArray.m_Format.ToTextureFormat(); + m_MipCount = m_Texture2DArray.m_MipCount; + m_TextureSettings = m_Texture2DArray.m_TextureSettings; + m_StreamData = m_Texture2DArray.m_StreamData; + m_MipMap = m_MipCount > 1; + m_ImageCount = 1; + + //var imgActualDataSize = GetImageDataSize(m_TextureFormat); + //var mipmapSize = (int)(m_Texture2DArray.m_DataSize / m_Texture2DArray.m_Depth - imgActualDataSize); + m_CompleteImageSize = (int)m_Texture2DArray.m_DataSize / m_Texture2DArray.m_Depth; + var offset = layer * m_CompleteImageSize + m_Texture2DArray.image_data.Offset; + + image_data = !string.IsNullOrEmpty(m_StreamData?.path) + ? new ResourceReader(m_StreamData.path, assetsFile, offset, m_CompleteImageSize) + : new ResourceReader(reader, offset, m_CompleteImageSize); + + byteSize = (uint)(m_Width * m_Height) * 4; + } + public Texture2D(ObjectReader reader) : base(reader) { m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); - var m_CompleteImageSize = reader.ReadInt32(); + m_CompleteImageSize = reader.ReadInt32(); if (version[0] >= 2020) //2020.1 and up { var m_MipsStripped = reader.ReadInt32(); @@ -121,7 +107,7 @@ namespace AssetStudio { var m_StreamingMipmapsPriority = reader.ReadInt32(); } - var m_ImageCount = reader.ReadInt32(); + m_ImageCount = reader.ReadInt32(); var m_TextureDimension = reader.ReadInt32(); m_TextureSettings = new GLTextureSettings(reader); if (version[0] >= 3) //3.0 and up @@ -154,79 +140,65 @@ namespace AssetStudio } image_data = resourceReader; } - } - public enum TextureFormat - { - Alpha8 = 1, - ARGB4444, - RGB24, - RGBA32, - ARGB32, - ARGBFloat, - RGB565, - BGR24, - R16, - DXT1, - DXT3, - DXT5, - RGBA4444, - BGRA32, - RHalf, - RGHalf, - RGBAHalf, - RFloat, - RGFloat, - RGBAFloat, - YUY2, - RGB9e5Float, - RGBFloat, - BC6H, - BC7, - BC4, - BC5, - DXT1Crunched, - DXT5Crunched, - PVRTC_RGB2, - PVRTC_RGBA2, - PVRTC_RGB4, - PVRTC_RGBA4, - ETC_RGB4, - ATC_RGB4, - ATC_RGBA8, - EAC_R = 41, - EAC_R_SIGNED, - EAC_RG, - EAC_RG_SIGNED, - ETC2_RGB, - ETC2_RGBA1, - ETC2_RGBA8, - ASTC_RGB_4x4, - ASTC_RGB_5x5, - ASTC_RGB_6x6, - ASTC_RGB_8x8, - ASTC_RGB_10x10, - ASTC_RGB_12x12, - ASTC_RGBA_4x4, - ASTC_RGBA_5x5, - ASTC_RGBA_6x6, - ASTC_RGBA_8x8, - ASTC_RGBA_10x10, - ASTC_RGBA_12x12, - ETC_RGB4_3DS, - ETC_RGBA8_3DS, - RG16, - R8, - ETC_RGB4Crunched, - ETC2_RGBA8Crunched, - ASTC_HDR_4x4, - ASTC_HDR_5x5, - ASTC_HDR_6x6, - ASTC_HDR_8x8, - ASTC_HDR_10x10, - ASTC_HDR_12x12, - RG32, - RGB48, - RGBA64 + // https://docs.unity3d.com/2023.3/Documentation/Manual/class-TextureImporterOverride.html + private int GetImageDataSize(TextureFormat textureFormat) + { + var imgDataSize = m_Width * m_Height; + switch (textureFormat) + { + case TextureFormat.ASTC_RGBA_5x5: + // https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_astc/ + imgDataSize = (int)(Math.Floor((m_Width + 4) / 5f) * Math.Floor((m_Height + 4) / 5f) * 16); + break; + case TextureFormat.ASTC_RGBA_6x6: + imgDataSize = (int)(Math.Floor((m_Width + 5) / 6f) * Math.Floor((m_Height + 5) / 6f) * 16); + break; + case TextureFormat.ASTC_RGBA_8x8: + imgDataSize = (int)(Math.Floor((m_Width + 7) / 8f) * Math.Floor((m_Height + 7) / 8f) * 16); + break; + case TextureFormat.ASTC_RGBA_10x10: + imgDataSize = (int)(Math.Floor((m_Width + 9) / 10f) * Math.Floor((m_Height + 9) / 10f) * 16); + break; + case TextureFormat.ASTC_RGBA_12x12: + imgDataSize = (int)(Math.Floor((m_Width + 11) / 12f) * Math.Floor((m_Height + 11) / 12f) * 16); + break; + case TextureFormat.DXT1: + case TextureFormat.EAC_R: + case TextureFormat.EAC_R_SIGNED: + case TextureFormat.ATC_RGB4: + case TextureFormat.ETC_RGB4: + case TextureFormat.ETC2_RGB: + case TextureFormat.ETC2_RGBA1: + case TextureFormat.PVRTC_RGBA4: + imgDataSize /= 2; + break; + case TextureFormat.PVRTC_RGBA2: + imgDataSize /= 4; + break; + case TextureFormat.R16: + case TextureFormat.RGB565: + imgDataSize *= 2; + break; + case TextureFormat.RGB24: + imgDataSize *= 3; + break; + case TextureFormat.RG32: + case TextureFormat.RGBA32: + case TextureFormat.ARGB32: + case TextureFormat.BGRA32: + case TextureFormat.RGB9e5Float: + imgDataSize *= 4; + break; + case TextureFormat.RGB48: + imgDataSize *= 6; + break; + case TextureFormat.RGBAHalf: + case TextureFormat.RGBA64: + imgDataSize *= 8; + break; + } + return imgDataSize; + } } } \ No newline at end of file diff --git a/AssetStudio/Classes/Texture2DArray.cs b/AssetStudio/Classes/Texture2DArray.cs new file mode 100644 index 0000000..a1fbf9f --- /dev/null +++ b/AssetStudio/Classes/Texture2DArray.cs @@ -0,0 +1,54 @@ +using System.Collections.Generic; + +namespace AssetStudio +{ + public sealed class Texture2DArray : Texture + { + public int m_Width; + public int m_Height; + public int m_Depth; + public GraphicsFormat m_Format; + public int m_MipCount; + public uint m_DataSize; + public GLTextureSettings m_TextureSettings; + public int m_ColorSpace; + public ResourceReader image_data; + public StreamingInfo m_StreamData; + public List TextureList; + + public Texture2DArray(ObjectReader reader) : base(reader) + { + m_ColorSpace = reader.ReadInt32(); + m_Format = (GraphicsFormat)reader.ReadInt32(); + m_Width = reader.ReadInt32(); + m_Height = reader.ReadInt32(); + m_Depth = reader.ReadInt32(); + m_MipCount = reader.ReadInt32(); + m_DataSize = reader.ReadUInt32(); + m_TextureSettings = new GLTextureSettings(reader); + if (version[0] > 2020 || (version[0] == 2020 && version[1] >= 2)) //2020.2 and up + { + var m_UsageMode = reader.ReadInt32(); + } + var m_IsReadable = reader.ReadBoolean(); + reader.AlignStream(); + + var image_data_size = reader.ReadInt32(); + if (image_data_size == 0) + { + m_StreamData = new StreamingInfo(reader); + } + + if (!string.IsNullOrEmpty(m_StreamData?.path)) + { + image_data = new ResourceReader(m_StreamData.path, assetsFile, m_StreamData.offset, (int)m_StreamData.size); + } + else + { + image_data = new ResourceReader(reader, reader.BaseStream.Position, image_data_size); + } + + TextureList = new List(); + } + } +} diff --git a/AssetStudio/Classes/TextureFormat.cs b/AssetStudio/Classes/TextureFormat.cs new file mode 100644 index 0000000..abf6ffe --- /dev/null +++ b/AssetStudio/Classes/TextureFormat.cs @@ -0,0 +1,282 @@ +namespace AssetStudio +{ + public enum TextureFormat + { + /// + /// Alpha-only texture format, 8 bit integer. + /// + Alpha8 = 1, + /// + /// A 16 bits/pixel texture format. Texture stores color with an alpha channel. + /// + ARGB4444, + /// + /// Three channel (RGB) texture format, 8-bits unsigned integer per channel. + /// + RGB24, + /// + /// Four channel (RGBA) texture format, 8-bits unsigned integer per channel. + /// + RGBA32, + /// + /// Color with alpha texture format, 8-bits per channel. + /// + ARGB32, + /// + /// + ARGBFloat, + /// + /// A 16 bit color texture format. + /// + RGB565, + /// + /// + BGR24, + /// + /// Single channel (R) texture format, 16 bit integer. + /// + R16, + /// + /// Compressed color texture format. + /// + DXT1, + /// + /// + DXT3, + /// + /// Compressed color with alpha channel texture format. + /// + DXT5, + /// + /// Color and alpha texture format, 4 bit per channel. + /// + RGBA4444, + /// + /// Color with alpha texture format, 8-bits per channel. + /// + BGRA32, + /// + /// Scalar (R) texture format, 16 bit floating point. + /// + RHalf, + /// + /// Two color (RG) texture format, 16 bit floating point per channel. + /// + RGHalf, + /// + /// RGB color and alpha texture format, 16 bit floating point per channel. + /// + RGBAHalf, + /// + /// Scalar (R) texture format, 32 bit floating point. + /// + RFloat, + /// + /// Two color (RG) texture format, 32 bit floating point per channel. + /// + RGFloat, + /// + /// RGB color and alpha texture format, 32-bit floats per channel. + /// + RGBAFloat, + /// + /// A format that uses the YUV color space and is often used for video encoding or playback. + /// + YUY2, + /// + /// RGB HDR format, with 9 bit mantissa per channel and a 5 bit shared exponent. + /// + RGB9e5Float, + /// + /// + RGBFloat, + /// + /// HDR compressed color texture format. + /// + BC6H, + /// + /// High quality compressed color texture format. + /// + BC7, + /// + /// Compressed one channel (R) texture format. + /// + BC4, + /// + /// Compressed two-channel (RG) texture format. + /// + BC5, + /// + /// Compressed color texture format with Crunch compression for smaller storage sizes. + /// + DXT1Crunched, + /// + /// Compressed color with alpha channel texture format with Crunch compression for smaller storage sizes. + /// + DXT5Crunched, + /// + /// PowerVR (iOS) 2 bits/pixel compressed color texture format. + /// + PVRTC_RGB2, + /// + /// PowerVR (iOS) 2 bits/pixel compressed with alpha channel texture format. + /// + PVRTC_RGBA2, + /// + /// PowerVR (iOS) 4 bits/pixel compressed color texture format. + /// + PVRTC_RGB4, + /// + /// PowerVR (iOS) 4 bits/pixel compressed with alpha channel texture format. + /// + PVRTC_RGBA4, + /// + /// ETC (GLES2.0) 4 bits/pixel compressed RGB texture format. + /// + ETC_RGB4, + /// + /// ATC (ATITC) 4 bits/pixel compressed RGB texture format. + /// + ATC_RGB4, + /// + /// ATC (ATITC) 8 bits/pixel compressed RGB texture format. + /// + ATC_RGBA8, + /// + /// ETC2 / EAC (GL ES 3.0) 4 bits/pixel compressed unsigned single-channel texture format. + /// + EAC_R = 41, + /// + /// ETC2 / EAC (GL ES 3.0) 4 bits/pixel compressed signed single-channel texture format. + /// + EAC_R_SIGNED, + /// + /// ETC2 / EAC (GL ES 3.0) 8 bits/pixel compressed unsigned dual-channel (RG) texture format. + /// + EAC_RG, + /// + /// ETC2 / EAC (GL ES 3.0) 8 bits/pixel compressed signed dual-channel (RG) texture format. + /// + EAC_RG_SIGNED, + /// + /// ETC2 (GL ES 3.0) 4 bits/pixel compressed RGB texture format. + /// + ETC2_RGB, + /// + /// ETC2 (GL ES 3.0) 4 bits/pixel RGB+1-bit alpha texture format. + /// + ETC2_RGBA1, + /// + /// ETC2 (GL ES 3.0) 8 bits/pixel compressed RGBA texture format. + /// + ETC2_RGBA8, + /// + /// ASTC (4x4 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_4x4, + /// + /// ASTC (5x5 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_5x5, + /// + /// ASTC (6x6 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_6x6, + /// + /// ASTC (8x8 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_8x8, + /// + /// ASTC (10x10 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_10x10, + /// + /// ASTC (12x12 pixel block in 128 bits) compressed RGB texture format. + /// + ASTC_RGB_12x12, + /// + /// ASTC (4x4 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_4x4, + /// + /// ASTC (5x5 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_5x5, + /// + /// ASTC (6x6 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_6x6, + /// + /// ASTC (8x8 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_8x8, + /// + /// ASTC (10x10 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_10x10, + /// + /// ASTC (12x12 pixel block in 128 bits) compressed RGBA texture format. + /// + ASTC_RGBA_12x12, + /// + /// ETC 4 bits/pixel compressed RGB texture format. + /// + ETC_RGB4_3DS, + /// + /// ETC 4 bits/pixel RGB + 4 bits/pixel Alpha compressed texture format. + /// + ETC_RGBA8_3DS, + /// + /// Two color (RG) texture format, 8-bits per channel. + /// + RG16, + /// + /// Single channel (R) texture format, 8 bit integer. + /// + R8, + /// + /// Compressed color texture format with Crunch compression for smaller storage sizes. + /// + ETC_RGB4Crunched, + /// + /// Compressed color with alpha channel texture format using Crunch compression for smaller storage sizes. + /// + ETC2_RGBA8Crunched, + /// + /// ASTC (4x4 pixel block in 128 bits) compressed RGB(A) HDR texture format. + /// + ASTC_HDR_4x4, + /// + /// ASTC (5x5 pixel block in 128 bits) compressed RGB(A) HDR texture format. + /// + ASTC_HDR_5x5, + /// + /// ASTC (6x6 pixel block in 128 bits) compressed RGB(A) HDR texture format. + /// + ASTC_HDR_6x6, + /// + /// ASTC (8x8 pixel block in 128 bits) compressed RGB(A) texture format. + /// + ASTC_HDR_8x8, + /// + /// ASTC (10x10 pixel block in 128 bits) compressed RGB(A) HDR texture format. + /// + ASTC_HDR_10x10, + /// + /// ASTC (12x12 pixel block in 128 bits) compressed RGB(A) HDR texture format. + /// + ASTC_HDR_12x12, + /// + /// Two channel (RG) texture format, 16-bits unsigned integer per channel. + /// + RG32, + /// + /// Three channel (RGB) texture format, 16-bits unsigned integer per channel. + /// + RGB48, + /// + /// Four channel (RGBA) texture format, 16-bits unsigned integer per channel. + /// + RGBA64, + } +} diff --git a/AssetStudio/ResourceReader.cs b/AssetStudio/ResourceReader.cs index a717111..6b705ec 100644 --- a/AssetStudio/ResourceReader.cs +++ b/AssetStudio/ResourceReader.cs @@ -11,7 +11,8 @@ namespace AssetStudio private long size; private BinaryReader reader; - public int Size { get => (int)size; } + public int Size => (int)size; + public int Offset => (int)offset; public ResourceReader(string path, SerializedFile assetsFile, long offset, long size) { diff --git a/AssetStudioCLI/Exporter.cs b/AssetStudioCLI/Exporter.cs index 6b8a9e0..2d9f819 100644 --- a/AssetStudioCLI/Exporter.cs +++ b/AssetStudioCLI/Exporter.cs @@ -68,6 +68,26 @@ namespace AssetStudioCLI } } + public static bool ExportTexture2DArray(AssetItem item, string exportPath) + { + var m_Texture2DArray = (Texture2DArray)item.Asset; + var count = 0; + foreach (var texture in m_Texture2DArray.TextureList) + { + var fakeItem = new AssetItem(texture) + { + Text = texture.m_Name, + Container = item.Container, + }; + if (ExportTexture2D(fakeItem, exportPath)) + { + count++; + } + } + Logger.Debug($"{item.TypeString} \"{item.Text}\" exported to \"{exportPath}\""); + return count > 0; + } + public static bool ExportAudioClip(AssetItem item, string exportPath) { string exportFullPath; @@ -451,6 +471,8 @@ namespace AssetStudioCLI { case ClassIDType.Texture2D: return ExportTexture2D(item, exportPath); + case ClassIDType.Texture2DArray: + return ExportTexture2DArray(item, exportPath); case ClassIDType.AudioClip: return ExportAudioClip(item, exportPath); case ClassIDType.VideoClip: diff --git a/AssetStudioCLI/Options/CLIOptions.cs b/AssetStudioCLI/Options/CLIOptions.cs index 7ccf290..7ab20c8 100644 --- a/AssetStudioCLI/Options/CLIOptions.cs +++ b/AssetStudioCLI/Options/CLIOptions.cs @@ -158,6 +158,7 @@ namespace AssetStudioCLI.Options exportableAssetTypes = new List { ClassIDType.Texture2D, + ClassIDType.Texture2DArray, ClassIDType.Sprite, ClassIDType.TextAsset, ClassIDType.MonoBehaviour, @@ -591,6 +592,9 @@ namespace AssetStudioCLI.Options case "tex2d": o_exportAssetTypes.Value.Add(ClassIDType.Texture2D); break; + case "tex2darray": + o_exportAssetTypes.Value.Add(ClassIDType.Texture2DArray); + break; case "audio": o_exportAssetTypes.Value.Add(ClassIDType.AudioClip); break; diff --git a/AssetStudioCLI/Studio.cs b/AssetStudioCLI/Studio.cs index da56320..ea5a797 100644 --- a/AssetStudioCLI/Studio.cs +++ b/AssetStudioCLI/Studio.cs @@ -56,6 +56,7 @@ namespace AssetStudioCLI Logger.Info("Parse assets..."); var fileAssetsList = new List(); + var tex2dArrayAssetList = new List(); var objectCount = assetsManager.assetsFileList.Sum(x => x.Objects.Count); var objectAssetItemDic = new Dictionary(objectCount); @@ -112,6 +113,12 @@ namespace AssetStudioCLI assetItem.FullSize = asset.byteSize + m_Texture2D.m_StreamData.size; assetItem.Text = m_Texture2D.m_Name; break; + case Texture2DArray m_Texture2DArray: + if (!string.IsNullOrEmpty(m_Texture2DArray.m_StreamData?.path)) + assetItem.FullSize = asset.byteSize + m_Texture2DArray.m_StreamData.size; + assetItem.Text = m_Texture2DArray.m_Name; + tex2dArrayAssetList.Add(assetItem); + break; case AudioClip m_AudioClip: if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size; @@ -170,8 +177,18 @@ namespace AssetStudioCLI asset.Container = container; } } + foreach (var tex2dAssetItem in tex2dArrayAssetList) + { + var m_Texture2DArray = (Texture2DArray)tex2dAssetItem.Asset; + for (var layer = 0; layer < m_Texture2DArray.m_Depth; layer++) + { + var fakeObj = new Texture2D(m_Texture2DArray, layer); + m_Texture2DArray.TextureList.Add(fakeObj); + } + } parsedAssetsList.AddRange(fileAssetsList); fileAssetsList.Clear(); + tex2dArrayAssetList.Clear(); if (CLIOptions.o_workMode.Value != WorkMode.ExportLive2D) { containers.Clear(); diff --git a/AssetStudioGUI/AssetStudioGUIForm.cs b/AssetStudioGUI/AssetStudioGUIForm.cs index 27bb875..41abe8b 100644 --- a/AssetStudioGUI/AssetStudioGUIForm.cs +++ b/AssetStudioGUI/AssetStudioGUIForm.cs @@ -349,7 +349,7 @@ namespace AssetStudioGUI if (e.Control) { var need = false; - if (lastSelectedItem?.Type == ClassIDType.Texture2D) + if (lastSelectedItem?.Type == ClassIDType.Texture2D || lastSelectedItem?.Type == ClassIDType.Texture2DArrayImage) { switch (e.KeyCode) { @@ -810,8 +810,12 @@ namespace AssetStudioGUI switch (assetItem.Type) { case ClassIDType.Texture2D: + case ClassIDType.Texture2DArrayImage: PreviewTexture2D(assetItem, assetItem.Asset as Texture2D); break; + case ClassIDType.Texture2DArray: + PreviewTexture2DArray(assetItem, assetItem.Asset as Texture2DArray); + break; case ClassIDType.AudioClip: PreviewAudioClip(assetItem, assetItem.Asset as AudioClip); break; @@ -870,6 +874,16 @@ namespace AssetStudioGUI } } + private void PreviewTexture2DArray(AssetItem assetItem, Texture2DArray m_Texture2DArray) + { + assetItem.InfoText = + $"Width: {m_Texture2DArray.m_Width}\n" + + $"Height: {m_Texture2DArray.m_Height}\n" + + $"Graphics Format: {m_Texture2DArray.m_Format}\n" + + $"Texture Format: {m_Texture2DArray.m_Format.ToTextureFormat()}\n" + + $"Texture count: {m_Texture2DArray.m_Depth}"; + } + private void PreviewTexture2D(AssetItem assetItem, Texture2D m_Texture2D) { var image = m_Texture2D.ConvertToImage(true); diff --git a/AssetStudioGUI/Exporter.cs b/AssetStudioGUI/Exporter.cs index 9b724bd..ba9c873 100644 --- a/AssetStudioGUI/Exporter.cs +++ b/AssetStudioGUI/Exporter.cs @@ -38,6 +38,25 @@ namespace AssetStudioGUI } } + public static bool ExportTexture2DArray(AssetItem item, string exportPath) + { + var m_Texture2DArray = (Texture2DArray)item.Asset; + var count = 0; + foreach(var texture in m_Texture2DArray.TextureList) + { + var fakeItem = new AssetItem(texture) + { + Text = texture.m_Name, + Container = item.Container, + }; + if (ExportTexture2D(fakeItem, exportPath)) + { + count++; + } + } + return count > 0; + } + public static bool ExportAudioClip(AssetItem item, string exportPath) { var m_AudioClip = (AudioClip)item.Asset; @@ -376,7 +395,10 @@ namespace AssetStudioGUI switch (item.Type) { case ClassIDType.Texture2D: + case ClassIDType.Texture2DArrayImage: return ExportTexture2D(item, exportPath); + case ClassIDType.Texture2DArray: + return ExportTexture2DArray(item, exportPath); case ClassIDType.AudioClip: return ExportAudioClip(item, exportPath); case ClassIDType.Shader: diff --git a/AssetStudioGUI/Studio.cs b/AssetStudioGUI/Studio.cs index 0141a51..78c6fa5 100644 --- a/AssetStudioGUI/Studio.cs +++ b/AssetStudioGUI/Studio.cs @@ -179,6 +179,7 @@ namespace AssetStudioGUI var objectCount = assetsManager.assetsFileList.Sum(x => x.Objects.Count); var objectAssetItemDic = new Dictionary(objectCount); var containers = new List<(PPtr, string)>(); + var tex2dArrayAssetList = new List(); l2dResourceContainers.Clear(); var i = 0; Progress.Reset(); @@ -206,6 +207,13 @@ namespace AssetStudioGUI assetItem.Text = m_Texture2D.m_Name; exportable = true; break; + case Texture2DArray m_Texture2DArray: + if (!string.IsNullOrEmpty(m_Texture2DArray.m_StreamData?.path)) + assetItem.FullSize = asset.byteSize + m_Texture2DArray.m_StreamData.size; + assetItem.Text = m_Texture2DArray.m_Name; + tex2dArrayAssetList.Add(assetItem); + exportable = true; + break; case AudioClip m_AudioClip: if (!string.IsNullOrEmpty(m_AudioClip.m_Source)) assetItem.FullSize = asset.byteSize + m_AudioClip.m_Size; @@ -310,11 +318,28 @@ namespace AssetStudioGUI } } } + foreach (var tex2dAssetItem in tex2dArrayAssetList) + { + var m_Texture2DArray = (Texture2DArray)tex2dAssetItem.Asset; + for (var layer = 0; layer < m_Texture2DArray.m_Depth; layer++) + { + var fakeObj = new Texture2D(m_Texture2DArray, layer); + m_Texture2DArray.TextureList.Add(fakeObj); + + var fakeItem = new AssetItem(fakeObj) + { + Text = fakeObj.m_Name, + Container = tex2dAssetItem.Container + }; + exportableAssets.Add(fakeItem); + } + } foreach (var tmp in exportableAssets) { tmp.SetSubItems(); } containers.Clear(); + tex2dArrayAssetList.Clear(); visibleAssets = exportableAssets; diff --git a/AssetStudioUtility/Texture2DConverter.cs b/AssetStudioUtility/Texture2DConverter.cs index 3d7d7f9..89a6528 100644 --- a/AssetStudioUtility/Texture2DConverter.cs +++ b/AssetStudioUtility/Texture2DConverter.cs @@ -214,7 +214,7 @@ namespace AssetStudio } finally { - BigArrayPool.Shared.Return(buff); + BigArrayPool.Shared.Return(buff, clearArray: true); } return flag; }