Decode the BC5 cloud volume: 3D layout for 16-byte blocks and its mip chain #372

Manually merged
github merged 1 commit from gh-pr/372/head into gh-pr/372/base 2026-11-26 20:31:23 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-26 15:53 UTC · original
holdmysocks:six-bc-volume → master · +56 −24 · 3 files · 1 commits · merged 2026-11-26 16:01 UTC

The one block-compressed volume in the install, a BC5 128×128×128 cloud volume with 8 mips, now decodes and exports whole: a 3D DDS with all 128 slices and all 8 mips, plus <name>_slices.png. Before, it exported a garbled first slice. This was the last gap left by PRs 289 and 300.

Bricks. BC blocks are the elements: 16 bytes, 32×32 blocks per slice.

  • A 4 KiB brick is 4×8×8 blocks, in bit order Z0 Y0 X0 Z1 Y1 X1 Z2 Y2 (low bit first).
  • It was found by trying every order on the block endpoints. The next-best order scores 20 % rougher.
  • The brick-seam test fixes the axis labels: with this order, neighbours across a seam differ as much as inside a brick on every axis. Every other candidate is 30–37 at the seams.

Mip chain. It uses the same per-layer layout as the R8 fog volume from PR 289. Each 8-deep brick layer holds, at 43 blocks a layer:

  • the tail block;
  • 2 blocks of mip 2;
  • 8 blocks of mip 1;
  • 32 blocks of mip 0.

The empty blocks in later layers sit exactly where the shorter mips run out of depth.

Tail. Mips 3–6 sit at bytes 2048, 768, 512 and 256, the same slots as the fog volume. Mip 7 is at byte 0, the one tail element left over (167 nonzero = 128 + 32 + 4 + 2 + 1). Mip 3 is 16 deep, so it continues in the second layer's tail.

Tail rule. It changes from "at most half a brick wide" to "no wider than a brick, at most half a brick high". That fits both volumes. The fog volume's layout is unchanged, and its unit test still passes.

Checked on the exported DDS with a full BC5 pixel decode:

  • each mip matches the one above averaged 2×2×2 at 38–52 dB;
  • mip 0's brick seams are as smooth as the inside (x 3.7 / 4.0, y 3.8 / 4.5, z 4.0 / 4.0 levels).

Scope. Chains are mapped for 1- and 16-byte elements only. BC volumes are mapped for 16-byte blocks only. No volume uses BC1 or BC4. The store reader is unchanged: it still rejects compressed and mipped volumes.

Checked with cargo check --workspace --all-targets and cargo test -p sixng-core -p sixng-gui --release.

**@⁠holdmysocks** on GitHub · 2026-11-26 15:53 UTC · [original](https://github.com/holdmysocks/SixNG/pull/372) `holdmysocks:six-bc-volume` → `master` · +56 −24 · 3 files · 1 commits · merged 2026-11-26 16:01 UTC The one block-compressed volume in the install, a BC5 128×128×128 cloud volume with 8 mips, now decodes and exports whole: a 3D DDS with all 128 slices and all 8 mips, plus `<name>_slices.png`. Before, it exported a garbled first slice. This was the last gap left by PRs 289 and 300. **Bricks.** BC blocks are the elements: 16 bytes, 32×32 blocks per slice. - A 4 KiB brick is 4×8×8 blocks, in bit order Z0 Y0 X0 Z1 Y1 X1 Z2 Y2 (low bit first). - It was found by trying every order on the block endpoints. The next-best order scores 20 % rougher. - The brick-seam test fixes the axis labels: with this order, neighbours across a seam differ as much as inside a brick on every axis. Every other candidate is 30–37 at the seams. **Mip chain.** It uses the same per-layer layout as the R8 fog volume from PR 289. Each 8-deep brick layer holds, at 43 blocks a layer: - the tail block; - 2 blocks of mip 2; - 8 blocks of mip 1; - 32 blocks of mip 0. The empty blocks in later layers sit exactly where the shorter mips run out of depth. **Tail.** Mips 3–6 sit at bytes 2048, 768, 512 and 256, the same slots as the fog volume. Mip 7 is at byte 0, the one tail element left over (167 nonzero = 128 + 32 + 4 + 2 + 1). Mip 3 is 16 deep, so it continues in the second layer's tail. **Tail rule.** It changes from "at most half a brick wide" to "no wider than a brick, at most half a brick high". That fits both volumes. The fog volume's layout is unchanged, and its unit test still passes. **Checked on the exported DDS** with a full BC5 pixel decode: - each mip matches the one above averaged 2×2×2 at 38–52 dB; - mip 0's brick seams are as smooth as the inside (x 3.7 / 4.0, y 3.8 / 4.5, z 4.0 / 4.0 levels). **Scope.** Chains are mapped for 1- and 16-byte elements only. BC volumes are mapped for 16-byte blocks only. No volume uses BC1 or BC4. The store reader is unchanged: it still rejects compressed and mipped volumes. Checked with `cargo check --workspace --all-targets` and `cargo test -p sixng-core -p sixng-gui --release`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:31:20 +00:00
github manually merged commit aa5a76e35c into gh-pr/372/base 2026-11-26 20:31:23 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.