BC6H: spec-correct decoder in place of texture2ddecoder's #23
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!23
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/23/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@holdmysocks on GitHub · 2026-11-23 01:35 UTC · original
holdmysocks:claude/interesting-mcclintock-bff8f2→master· +243 −3 · 3 files · 1 commits · merged 2026-11-23 01:59 UTCWhat
Plain BC6H textures (
Fmt::Bc6u/Fmt::Bc6s, mostly HDR lighting textures) were decoded withtexture2ddecoder::decode_bc6. This replaces that path with a decoder that follows the BC6H specification, for UF16 and SF16.crates/sixng-core/src/bc6h.rs:decode_block(half-float bits) anddecode_image(same signature and0xAARRGGBBoutput astexture2ddecoder::decode_bc6). It reads block fields with the existingbc6pack::unpack.texture.rs: the two BC6 lines into_rgbacall it;f16is nowpub(crate).lib.rs: registers the module.export.rsandbc6pack.rsare not touched. The 8-bit conversion is unchanged (clamp to 0..1, truncate), so only the cases below differ.Why
texture2ddecoder 0.1.2 differs from the specification in three places:
1 << (bits - 1)to 0xFFFF. The specification maps(1 << bits) - 1there, so half-range endpoints came out at full brightness.(1 << 16) - 1in u16. That is 0 in release builds, so the second endpoint decoded as 0.Checks
bc6h::tests: hand-computed values for cases 1 and 2 and for signed endpoints, image size handling, and random unsigned blocks that must equal texture2ddecoder exactly outside its bug cases. All 83sixng-coretests pass.data/ttdb/lighting/lighting.ttpf --all, mip 0, previous release build against this branch:The median changed texture differs in 0.06 % of its pixels, and 243 of the 251 have a pixel that differs by 64 levels or more. Two textures were garbled before and are clean now:
49794f046bee0618(UF16, 1024², 98 % of pixels changed) and60664f594ae618bc(SF16, 512², 94 %).Notes for review
to_rgba, so it changes too. That was not checked separately.162a74fbc9e1c232(SF16, 2048x1024) looks like noisy line art before and after; not looked into.