From abe4c712b5afd1b23ae3a0414da3f4a6c12eac75 Mon Sep 17 00:00:00 2001 From: FordProductions <127124202+1915rising@users.noreply.github.com> Date: Sun, 29 Nov 2026 18:13:29 -0500 Subject: [PATCH 1/3] Pass explicit BC7 params to etcpak compress_bc7 --- UnityPy/export/Texture2DConverter.py | 5 ++++- tests/test_bc7_encode.py | 30 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/test_bc7_encode.py diff --git a/UnityPy/export/Texture2DConverter.py b/UnityPy/export/Texture2DConverter.py index b028a1bd..d114fbaf 100644 --- a/UnityPy/export/Texture2DConverter.py +++ b/UnityPy/export/Texture2DConverter.py @@ -92,7 +92,10 @@ def compress_etcpak(data: bytes, width: int, height: int, target_texture_format: elif target_texture_format == TF.BC5: return etcpak.compress_bc5(data, width, height) elif target_texture_format == TF.BC7: - return etcpak.compress_bc7(data, width, height, None) + # etcpak <= 0.9.14 rejects None here and requires an explicit + # BC7CompressBlockParams instance (default params = etcpak defaults); + # newer etcpak accepts both, so pass the instance for compatibility. + return etcpak.compress_bc7(data, width, height, etcpak.BC7CompressBlockParams()) elif target_texture_format in [TF.ETC_RGB4, TF.ETC_RGB4Crunched, TF.ETC_RGB4_3DS]: return etcpak.compress_etc1_rgb(data, width, height) elif target_texture_format == TF.ETC2_RGB: diff --git a/tests/test_bc7_encode.py b/tests/test_bc7_encode.py new file mode 100644 index 00000000..3d3b87a1 --- /dev/null +++ b/tests/test_bc7_encode.py @@ -0,0 +1,30 @@ +from PIL import Image + +from UnityPy.enums import BuildTarget, TextureFormat +from UnityPy.export.Texture2DConverter import compress_etcpak, image_to_texture2d, parse_image_data + + +def test_compress_etcpak_bc7(): + data = bytes([255, 0, 0, 255] * 16) + enc = compress_etcpak(data, 4, 4, TextureFormat.BC7) + # one 4x4 BC7 block = 16 bytes + assert len(enc) == 16 + + +def test_image_to_texture2d_bc7_roundtrip(): + img = Image.new("RGBA", (8, 8), (255, 0, 0, 255)) + enc, fmt = image_to_texture2d(img, TextureFormat.BC7) + assert fmt == TextureFormat.BC7 + # 8x8 = 2x2 blocks of 16 bytes + assert len(enc) == 64 + dec = parse_image_data( + enc, + 8, + 8, + TextureFormat.BC7, + (2022, 3, 0, 0), + BuildTarget.StandaloneWindows64, + flip=False, + ) + r, g, b, a = dec.getpixel((0, 0)) + assert r > 250 and g < 5 and b < 5 and a > 250 From c727d8441dee55db90345fb5b73ea39c657ced24 Mon Sep 17 00:00:00 2001 From: FordProductions <127124202+1915rising@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:45:48 -0500 Subject: [PATCH 2/3] fix: pin etcpak >= 0.9.15 instead of passing explicit BC7 params --- UnityPy/export/Texture2DConverter.py | 5 +---- pyproject.toml | 5 ++--- tests/test_bc7_encode.py | 30 ---------------------------- 3 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 tests/test_bc7_encode.py diff --git a/UnityPy/export/Texture2DConverter.py b/UnityPy/export/Texture2DConverter.py index d114fbaf..b028a1bd 100644 --- a/UnityPy/export/Texture2DConverter.py +++ b/UnityPy/export/Texture2DConverter.py @@ -92,10 +92,7 @@ def compress_etcpak(data: bytes, width: int, height: int, target_texture_format: elif target_texture_format == TF.BC5: return etcpak.compress_bc5(data, width, height) elif target_texture_format == TF.BC7: - # etcpak <= 0.9.14 rejects None here and requires an explicit - # BC7CompressBlockParams instance (default params = etcpak defaults); - # newer etcpak accepts both, so pass the instance for compatibility. - return etcpak.compress_bc7(data, width, height, etcpak.BC7CompressBlockParams()) + return etcpak.compress_bc7(data, width, height, None) elif target_texture_format in [TF.ETC_RGB4, TF.ETC_RGB4Crunched, TF.ETC_RGB4_3DS]: return etcpak.compress_etc1_rgb(data, width, height) elif target_texture_format == TF.ETC2_RGB: diff --git a/pyproject.toml b/pyproject.toml index ff22003c..ccf48f28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ dependencies = [ # Texture & Sprite handling "Pillow", "texture2ddecoder >= 1.0.5", # texture decompression - "etcpak", # ETC & DXT compression + "etcpak >= 0.9.15", # ETC & DXT compression "astc-encoder-py >= 0.1.12", # ASTC compression # audio extraction "fmod_toolkit", @@ -78,8 +78,7 @@ version = { attr = "UnityPy.__version__" } testpaths = ["tests"] [tool.cibuildwheel.linux] -archs = ["x86_64", "i686"] -# auditwheel issues with fmod on: "aarch64", "armv7l" +archs = ["x86_64", "i686", "aarch64", "armv7l"] [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"] diff --git a/tests/test_bc7_encode.py b/tests/test_bc7_encode.py deleted file mode 100644 index 3d3b87a1..00000000 --- a/tests/test_bc7_encode.py +++ /dev/null @@ -1,30 +0,0 @@ -from PIL import Image - -from UnityPy.enums import BuildTarget, TextureFormat -from UnityPy.export.Texture2DConverter import compress_etcpak, image_to_texture2d, parse_image_data - - -def test_compress_etcpak_bc7(): - data = bytes([255, 0, 0, 255] * 16) - enc = compress_etcpak(data, 4, 4, TextureFormat.BC7) - # one 4x4 BC7 block = 16 bytes - assert len(enc) == 16 - - -def test_image_to_texture2d_bc7_roundtrip(): - img = Image.new("RGBA", (8, 8), (255, 0, 0, 255)) - enc, fmt = image_to_texture2d(img, TextureFormat.BC7) - assert fmt == TextureFormat.BC7 - # 8x8 = 2x2 blocks of 16 bytes - assert len(enc) == 64 - dec = parse_image_data( - enc, - 8, - 8, - TextureFormat.BC7, - (2022, 3, 0, 0), - BuildTarget.StandaloneWindows64, - flip=False, - ) - r, g, b, a = dec.getpixel((0, 0)) - assert r > 250 and g < 5 and b < 5 and a > 250 From 565dc9b0ca792b5aa77a4a67302fc2596f410038 Mon Sep 17 00:00:00 2001 From: FordProductions <127124202+1915rising@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:47:58 -0500 Subject: [PATCH 3/3] fix: keep the etcpak pin as the only pyproject change --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ccf48f28..826d34a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,8 @@ version = { attr = "UnityPy.__version__" } testpaths = ["tests"] [tool.cibuildwheel.linux] -archs = ["x86_64", "i686", "aarch64", "armv7l"] +archs = ["x86_64", "i686"] +# auditwheel issues with fmod on: "aarch64", "armv7l" [tool.cibuildwheel.macos] archs = ["x86_64", "arm64"]