aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-03-26 19:16:01 +0100
committermetamuffin <metamuffin@disroot.org>2025-03-26 19:16:01 +0100
commitab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a (patch)
tree863aef760d6a347b11811d2fb06edeaf43a63562
parent11f492a942b3a052017be5d4fe2c76f9e7685ee6 (diff)
downloadunity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar
unity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar.bz2
unity-tools-ab8ecf890fc51fcaf8b85ae594bf41db8aa6bc8a.tar.zst
dxt1 decompression failure
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml2
-rw-r--r--src/classes/texture2d.rs12
3 files changed, 11 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index a5b1bca..0838741 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1288,6 +1288,7 @@ dependencies = [
"log",
"lz4_flex",
"lzma",
+ "rayon",
"serde",
"serde_json",
"texpresso",
diff --git a/Cargo.toml b/Cargo.toml
index ebde4a3..e045519 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,4 +21,6 @@ glam = { version = "0.30.0", features = ["serde"] }
texpresso = "2.0.1"
image = "0.25.5"
texture2ddecoder = { git = "https://github.com/UniversalGameExtraction/texture2ddecoder", rev = "d2b4653fda298f1da39917da86bc509b17879808" }
+# texture2ddecoder = { path = "../ext/texture2ddecoder" }
lewton = "0.10.2"
+rayon = "1.10.0"
diff --git a/src/classes/texture2d.rs b/src/classes/texture2d.rs
index 6b96b17..d1e6e30 100644
--- a/src/classes/texture2d.rs
+++ b/src/classes/texture2d.rs
@@ -133,20 +133,24 @@ impl Texture2D {
_ => unreachable!(),
}
);
- let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_unity_crunch(&self.image_data, w, h, &mut buf).unwrap();
+ let mut buf = vec![0u32; w * h * self.image_count as usize];
+ // TODO decode multi-face textures
+ texture2ddecoder::decode_unity_crunch(&self.image_data, w, h, &mut buf)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
BC7 => {
info!("decompressing {w}x{h} BC7 texture",);
let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_bc7(&self.image_data, w, h, &mut buf).unwrap();
+ texture2ddecoder::decode_bc7(&self.image_data, w, h, &mut buf)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
BC6H => {
info!("decompressing {w}x{h} BC6H texture",);
let mut buf = vec![0u32; w * h];
- texture2ddecoder::decode_bc6(&self.image_data, w, h, &mut buf, false).unwrap();
+ texture2ddecoder::decode_bc6(&self.image_data, w, h, &mut buf, false)
+ .map_err(|e| anyhow!("{e}"))?;
Ok(u32_argb_buf_to_images(buf))
}
RGB24 => {