diff --git a/CodeWalker.Core/GameFiles/Resources/Texture.cs b/CodeWalker.Core/GameFiles/Resources/Texture.cs index 36c558ee9..088acf0b1 100644 --- a/CodeWalker.Core/GameFiles/Resources/Texture.cs +++ b/CodeWalker.Core/GameFiles/Resources/Texture.cs @@ -707,6 +707,7 @@ public int CalcDataSize() len += slicePitch; div *= 2; } + return len * Depth; } public ushort CalculateStride() @@ -1099,6 +1100,13 @@ public override void Read(ResourceDataReader reader, params object[] parameters) int Levels = Convert.ToInt32(parameters[3]); int Stride = Convert.ToInt32(parameters[4]); + bool compressed = DDSIO.DXTex.IsCompressed(DDSIO.GetDXGIFormat((TextureFormat)format)); + + if (compressed && Height % 4 != 0) + { + Height = Math.Max(4, (Height + 3) & ~3); + } + int fullLength = 0; int length = Stride * Height; for (int i = 0; i < Levels; i++)