Skip to content

Commit

Permalink
Improve support of Texture2DArray assets
Browse files Browse the repository at this point in the history
  • Loading branch information
aelurum committed Jan 12, 2025
1 parent 341612b commit 188ee08
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
10 changes: 7 additions & 3 deletions AssetStudio/Classes/GLTextureSettings.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
namespace AssetStudio
using System.Text.Json.Serialization;

namespace AssetStudio
{
public class GLTextureSettings
{
public int m_FilterMode;
public int m_Aniso;
public float m_MipBias;
public int m_WrapMode;
[JsonInclude]
private int m_WrapU { set => m_WrapMode = value; }

public GLTextureSettings() { }

Expand All @@ -19,8 +23,8 @@ public GLTextureSettings(ObjectReader reader)
if (version >= 2017)//2017.x and up
{
m_WrapMode = reader.ReadInt32(); //m_WrapU
int m_WrapV = reader.ReadInt32();
int m_WrapW = reader.ReadInt32();
var m_WrapV = reader.ReadInt32();
var m_WrapW = reader.ReadInt32();
}
else
{
Expand Down
33 changes: 28 additions & 5 deletions AssetStudio/Classes/Texture2DArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,46 @@ public Texture2DArray() { }

public Texture2DArray(ObjectReader reader) : base(reader)
{
m_ColorSpace = reader.ReadInt32();
m_Format = (GraphicsFormat)reader.ReadInt32();
if (version >= 2019) //2019 and up
{
m_ColorSpace = reader.ReadInt32();
m_Format = (GraphicsFormat)reader.ReadInt32();
}
m_Width = reader.ReadInt32();
m_Height = reader.ReadInt32();
m_Depth = reader.ReadInt32();
if (version < 2019) //2019 down
{
m_Format = (GraphicsFormat)reader.ReadInt32();
}
m_MipCount = reader.ReadInt32();
if (version >= (2023, 2)) //2023.2 and up
{
var m_MipsStripped = reader.ReadInt32();
}
m_DataSize = reader.ReadUInt32();
m_TextureSettings = new GLTextureSettings(reader);
if (version < 2019) //2019 down
{
m_ColorSpace = reader.ReadInt32();
}
if (version >= (2020, 2)) //2020.2 and up
{
var m_UsageMode = reader.ReadInt32();
}
var m_IsReadable = reader.ReadBoolean();
reader.AlignStream();

if (version > (2023, 2)) //2023.2 and up
{
var m_IgnoreMipmapLimit = reader.ReadBoolean();
reader.AlignStream();
var m_MipmapLimitGroupName = reader.ReadAlignedString();
}
else
{
reader.AlignStream();
}
var image_data_size = reader.ReadInt32();
if (image_data_size == 0)
if (image_data_size == 0 && version >= (5, 6)) //5.6 and up
{
m_StreamData = new StreamingInfo(reader);
}
Expand Down

0 comments on commit 188ee08

Please sign in to comment.