Textures: SW_4KB_S for all uncompressed dictionary textures; volumes untiled in 3D #270

Manually merged
github merged 6 commits from gh-pr/270/head into gh-pr/270/base 2026-11-26 20:23:15 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 13:17 UTC · original
holdmysocks:six-1-8byte → master · +53 −23 · 5 files · 6 commits · merged 2026-11-25 14:23 UTC

Follow-up to PR 263 (merged).

After PRs 257 and 263, the remaining uncompressed texture-dictionary textures were still read as 16×16-element tiles: single-mip 1- and 8-byte textures, and volumes, which were read as plain 2D images.

Change

  • TexInfo.dimension holds the header byte at +0x3E: 1 = 2D or array, 2 = cube, 3 = volume. Its meaning was read off the headers of every array, cube and volume in textures.rpf. It is serde-defaulted for old JSON.
  • uncompressed_layout now covers every uncompressed texture:
    • 2D and arrays use SW_4KB_S with with_slices, so mip 0 is slice 0.
    • Single-mip volumes use the 3D SW_4KB_S pattern, so mip 0 is the z = 0 slice.
    • Volumes with a mip chain, and volumes whose element size has no known 3D pattern, keep the 2D reading.
  • gfx10::equation_3d gains the 4-byte pattern X0 Y0 Z0 Y1 X1 Z1 Y2 X2 Z2 Y3 (8×16×8 bricks). The bulk stores have no 4-byte volumes, so they are unaffected. The ttpf test that rejects unmeasured sizes now uses a 1-byte format.
  • README: the unusual-formats row, plus one line in the bulk-store row.

Checks on the install

  • Identity LUTs (exact). The 33×33×33 RGBA16 float identity LUT decodes through mip0_linear with maximum error 0. Read as a 2D image it was nowhere near the identity. The 256×16 RGBA16 float identity LUT is exact within half-float rounding. For 8-byte textures of up to 16 rows, 16×16 tiles and SW_4KB_S give the same addresses.
  • 1-byte textures. The four 4×4 A8 blanks now read as a single value; before, the decoder read the zero padding between rows. The 4×4 R8 dither offsets read as 16 distinct levels 16 apart. A 512×512 R8 light-animation table shows clean per-row curves, where 16×16 tiles gave scrambled blocks.
  • The 4-byte 3D pattern. I tried every x/y/z bit order of a 4 KiB brick and scored each by neighbour smoothness along all three axes.
    • On the 64×64×32 R16G16 float direction field, the pattern above scores 20.7. The next best order scores 24.7.
    • The RGBA8 and R10G10B10A2 noise volumes pick the same pattern.
    • The same search recovers the known 8-byte pattern from the identity LUT as a clear winner (6.0 against 20.8).
  • 1-byte volumes stay as they were. The one R8 noise cube favours X0 X1 Z0 Y0 Z1 Y1 X2 Z2 Y2 X3 Z3 Y3, but only by 3.5%, and the runners-up are the same order with the axes relabelled. That isn't enough to adopt it.
  • 2D textures with depth 1 go through the same SW_4KB_S path as before.
  • cargo check --workspace --all-targets and cargo test -p sixng-core -p sixng-gui --release pass.
**@⁠holdmysocks** on GitHub · 2026-11-25 13:17 UTC · [original](https://github.com/holdmysocks/SixNG/pull/270) `holdmysocks:six-1-8byte` → `master` · +53 −23 · 5 files · 6 commits · merged 2026-11-25 14:23 UTC Follow-up to PR 263 (merged). After PRs 257 and 263, the remaining uncompressed texture-dictionary textures were still read as 16×16-element tiles: single-mip 1- and 8-byte textures, and volumes, which were read as plain 2D images. **Change** - `TexInfo.dimension` holds the header byte at +0x3E: 1 = 2D or array, 2 = cube, 3 = volume. Its meaning was read off the headers of every array, cube and volume in textures.rpf. It is serde-defaulted for old JSON. - `uncompressed_layout` now covers every uncompressed texture: - 2D and arrays use SW_4KB_S with `with_slices`, so mip 0 is slice 0. - Single-mip volumes use the 3D SW_4KB_S pattern, so mip 0 is the z = 0 slice. - Volumes with a mip chain, and volumes whose element size has no known 3D pattern, keep the 2D reading. - `gfx10::equation_3d` gains the 4-byte pattern X0 Y0 Z0 Y1 X1 Z1 Y2 X2 Z2 Y3 (8×16×8 bricks). The bulk stores have no 4-byte volumes, so they are unaffected. The ttpf test that rejects unmeasured sizes now uses a 1-byte format. - README: the unusual-formats row, plus one line in the bulk-store row. **Checks on the install** - **Identity LUTs (exact).** The 33×33×33 RGBA16 float identity LUT decodes through `mip0_linear` with maximum error 0. Read as a 2D image it was nowhere near the identity. The 256×16 RGBA16 float identity LUT is exact within half-float rounding. For 8-byte textures of up to 16 rows, 16×16 tiles and SW_4KB_S give the same addresses. - **1-byte textures.** The four 4×4 A8 blanks now read as a single value; before, the decoder read the zero padding between rows. The 4×4 R8 dither offsets read as 16 distinct levels 16 apart. A 512×512 R8 light-animation table shows clean per-row curves, where 16×16 tiles gave scrambled blocks. - **The 4-byte 3D pattern.** I tried every x/y/z bit order of a 4 KiB brick and scored each by neighbour smoothness along all three axes. - On the 64×64×32 R16G16 float direction field, the pattern above scores 20.7. The next best order scores 24.7. - The RGBA8 and R10G10B10A2 noise volumes pick the same pattern. - The same search recovers the known 8-byte pattern from the identity LUT as a clear winner (6.0 against 20.8). - **1-byte volumes stay as they were.** The one R8 noise cube favours X0 X1 Z0 Y0 Z1 Y1 X2 Z2 Y2 X3 Z3 Y3, but only by 3.5%, and the runners-up are the same order with the axes relabelled. That isn't enough to adopt it. - **2D textures with depth 1** go through the same SW_4KB_S path as before. - `cargo check --workspace --all-targets` and `cargo test -p sixng-core -p sixng-gui --release` pass.
Single-mip textures with 2- or 4-byte elements (R16 height maps, RGBA8 palettes and profiles, BGRA8 tiles) are stored in Gfx10 SW_4KB_S blocks, not the 16x16-element tiles mip0_linear assumed. SW_4KB_S is smoothest on 1,051 of 1,064 such textures; the others are noise, small volumes and flat tiles. The water export now uses the generic path, with byte-identical output.
Uncompressed textures with a mip chain (RGBA8, R8, A8, R32 float) were read as 16x16-element tiles. They use the Gfx10 SW_4KB_S chain layout: each mip now matches the mip above averaged 2x2 (exactly on the R32 float glow; 40-68 dB elsewhere, against 11-25 dB before). DDS export writes these chains whole.
# Conflicts:
#	README.md
#	crates/sixng-core/src/texture.rs
Single-mip 1- and 8-byte textures use SW_4KB_S like the rest. The texture header's dimension byte (+0x3E) marks volumes, which are untiled with the 3D pattern; the 4-byte 3D pattern is added (found by search, confirmed on a direction field). The 33^3 identity LUT and the 256x16 identity LUT decode exactly.
# Conflicts:
#	README.md
#	crates/sixng-core/src/texture.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:23:11 +00:00
github manually merged commit 914117d7e6 into gh-pr/270/base 2026-11-26 20:23:15 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.