fix: sc2 alphatest threshold

This commit is contained in:
GonnaHetzMe committed 2026-04-12 22:17:55 +02:00
1 parent 1920be28d8
commit b950ac1318
1 file changed
+17 -2
@@ -75,6 +75,19 @@ export async function extractModel(vfs: AbstractVFS, path: string) {
.setImage(baseColor), .setImage(baseColor),
); );
if (
node.enabledPresets?.AlphaTest &&
node.properties.alphatestThreshold
) {
const view = new DataView(node.properties.alphatestThreshold);
const alphaCutoff =
view.byteLength < 4
? 0.5
: view.getFloat32(view.byteLength - 4, true);
material.setAlphaMode("MASK").setAlphaCutoff(alphaCutoff);
}
if (node.configCount) { if (node.configCount) {
for ( for (
let configIndex = 0; let configIndex = 0;
@@ -91,8 +104,10 @@ export async function extractModel(vfs: AbstractVFS, path: string) {
} }
const view = new DataView(archive.properties.alphatestThreshold); const view = new DataView(archive.properties.alphatestThreshold);
const _ = view.getUint8(0); // only god knows what these flags are const alphaCutoff =
const alphaCutoff = view.getFloat32(1, true); view.byteLength < 4
? 0.5
: view.getFloat32(view.byteLength - 4, true);
material.setAlphaMode("MASK").setAlphaCutoff(alphaCutoff); material.setAlphaMode("MASK").setAlphaCutoff(alphaCutoff);
} }