BC6H BCPack: fix speckles after one-region to two-region mode changes #15

Manually merged
github merged 1 commit from gh-pr/15/head into gh-pr/15/base 2026-11-26 20:03:16 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-22 20:28 UTC · original
holdmysocks:claude/bc6-mode-change → master · +158 −134 · 3 files · 1 commits · merged 2026-11-22 20:43 UTC

Fixes the speckles in BC6H BCPack textures where the reference chain changes BC6H mode.

Cause. When a one-region block (modes 11–14) is followed by a block that predicts from it in a two-region mode, the region-1 first endpoint (y) predicted from the wrong state. The decoder copied w into the y state. For transformed one-region modes the encoder instead leaves w written into the y field's delta width, offset by half its range: y_state = (w << (16 - delta_bits)) ^ 0x8000. Untransformed mode 11 (10-bit) still copies w.

How it was found. Endpoint-only scoring is lenient on y, so earlier analyses could not see it. Fitting each mode-change block's endpoints with its decoded indices against the parent mip showed that the gross errors were y alone. After one-region parents, the implied y prediction matched the new rule in 96 % of cases, against 22 % for the copy. With the fix, y predictions on mode changes into two-region modes match in 98.6 % of clean cases.

Results (preset tables refitted under the new rule; textures with a plain neighbour mip):

  • blocks within 0.15 stops of the parent mip: 81.2 % → 85.9 %; against the child mip 61 % → 70 %
  • tonemapped PSNR 23.4 → 27.2 dB, median per texture 23.5 → 29.0 dB
  • 23 of 36 checked textures better, none worse; prop textures +8 to +26 dB (11.5 → 37.1 dB on one)
  • visual check: a prop poster with text and hair, speckled before, now matches the reference mip
  • unfitted blocks unchanged

Adds a unit test for the new state rule and updates the module doc and README.

**@⁠holdmysocks** on GitHub · 2026-11-22 20:28 UTC · [original](https://github.com/holdmysocks/SixNG/pull/15) `holdmysocks:claude/bc6-mode-change` → `master` · +158 −134 · 3 files · 1 commits · merged 2026-11-22 20:43 UTC Fixes the speckles in BC6H BCPack textures where the reference chain changes BC6H mode. **Cause.** When a one-region block (modes 11–14) is followed by a block that predicts from it in a two-region mode, the region-1 first endpoint (y) predicted from the wrong state. The decoder copied w into the y state. For transformed one-region modes the encoder instead leaves w written into the y field's delta width, offset by half its range: `y_state = (w << (16 - delta_bits)) ^ 0x8000`. Untransformed mode 11 (10-bit) still copies w. **How it was found.** Endpoint-only scoring is lenient on y, so earlier analyses could not see it. Fitting each mode-change block's endpoints with its decoded indices against the parent mip showed that the gross errors were y alone. After one-region parents, the implied y prediction matched the new rule in 96 % of cases, against 22 % for the copy. With the fix, y predictions on mode changes into two-region modes match in 98.6 % of clean cases. **Results** (preset tables refitted under the new rule; textures with a plain neighbour mip): - blocks within 0.15 stops of the parent mip: 81.2 % → 85.9 %; against the child mip 61 % → 70 % - tonemapped PSNR 23.4 → 27.2 dB, median per texture 23.5 → 29.0 dB - 23 of 36 checked textures better, none worse; prop textures +8 to +26 dB (11.5 → 37.1 dB on one) - visual check: a prop poster with text and hair, speckled before, now matches the reference mip - unfitted blocks unchanged Adds a unit test for the new state rule and updates the module doc and README.
A one-region transformed block leaves w, written into the y field's delta
width and offset by half its range, as the region-1 y state (untransformed
modes still copy w). With the old copy rule, blocks after a change from a
one-region to a two-region mode came out speckled.

Preset tables refitted under the new rule. On textures with a plain
neighbour mip: blocks within 0.15 stops 81 % -> 86 %, tonemapped
23.4 -> 27.2 dB, 23 of 36 checked textures better and none worse
(prop textures up to +26 dB).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:03:13 +00:00
github manually merged commit 3df634788a into gh-pr/15/base 2026-11-26 20:03:16 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.