Textures: untile single-mip 2/4-byte textures as SW_4KB_S #257

Manually merged
github merged 1 commit from gh-pr/257/head into gh-pr/257/base 2026-11-26 20:22:07 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 11:49 UTC · original
holdmysocks:six-deswizzle → master · +23 −13 · 3 files · 1 commits · merged 2026-11-25 12:11 UTC

Single-mip textures with 2- or 4-byte elements are stored in Gfx10 SW_4KB_S blocks. mip0_linear untiled them as 16×16-element tiles, so they decoded with stripes and scrambled blocks in PNG export, DDS export and the viewer. Affected textures include R16 height maps, RGBA8 tint palettes and shore profiles, and BGRA8 tiles.

Change

  • mip0_linear untiles single-mip, uncompressed, 2/4-byte textures with gfx10::Layout (SW_4KB_S).
  • Textures with a mip chain, 1-byte textures and block-compressed formats are unchanged. So are the linear one-row palettes.
  • The water export drops its local workaround and uses the generic path.
  • README: a note in the unusual-formats row.

Checks on the install

  • Neighbour smoothness of mip 0 was compared under the old tiling, SW_4KB_S, SW_64KB_D and linear. This covered every 2/4-byte single-mip texture of 32×32 or more in textures, levels, common and the packs. SW_4KB_S is smoothest on 1,051 of 1,064. The others are noise textures (blue noise, Gaussian, curl noise), 32×32 volumes and flat tiles.
  • Examples: the 1536×1748 R16 terrain height map goes from 8.86 to 0.82 mean neighbour difference, and the tint palettes drop by about half.
  • After the change the generic path gives the SW_4KB_S result for all of them. Multi-mip and 1-byte results are identical to before.
  • The water export is byte-identical: 279 image files and all JSON.
  • cargo check --workspace --all-targets and cargo test -p sixng-core -p sixng-gui --release pass.

The 13 textures where SW_4KB_S is not the smoothest layout

Each was compared side by side as decoded before this change (16×16 tiles) and after (SW_4KB_S).

Texture Format, size With this change
lightanimintensity0000 R16_FLOAT 512×512 Near tie (81.8 vs 81.6). SW_4KB_S is clearly right: clean horizontal curves, one per row. The old decode broke them into 16-px column blocks.
blue_noise_64 R16_UNORM 64×64 Even, high-frequency blue noise. The old decode had visible clumps and 16-px structure, and smoothness penalises real blue noise. Looks right.
rope_anim_deg_twinkle_02 R8G8B8A8_UNORM 32×32 Regular per-column on/off patterns. The old decode repeated a scrambled block. Looks right.
rope_anim_twinkle_01 R8G8B8A8_UNORM 32×32 A one-texel checkerboard. The old decode gave vertical stripes. Both are regular, so it can't be judged by eye; plausible for a twinkle pattern.
iriscausticsdir R16G16_FLOAT 64×64 Blocky shape with some 32-px blocks offset. SW_64KB_D is smoothest here (23.6 vs 26.6), and the old decode wasn't right either (broken columns). Uncertain: this texture may use another tile mode.
windnoisevolume R8G8B8A8_UNORM 32×32 Blocky colour noise either way (61.7 vs 55.6); no visible structure to judge.
curlnoise, curlnoisecpu R10G10B10A2_UNORM 32×32 Colour noise either way (98.4 vs 97.1); indistinguishable.
ocean_sim_gaussian_noise R32_FLOAT 256×256 Gaussian noise either way (315.9 vs 314.9); indistinguishable.
shore_wave_placement_set1 ×2 (levels, minigame pack) B8G8R8A8_UNORM 256×256 Constant tiles. Every layout gives the same image, and the old decode only won the tie.
watersystemheightmap ×2 (levels, minigame pack) R16_UNORM 512×512 Constant tiles, as above.

In short, 4 are constant tiles, 4 are pure noise where no layout looks better, and 3 look correct with this change. rope_anim_twinkle_01 is regular either way. iriscausticsdir is the only one that looks off, and it was off before too.

**@⁠holdmysocks** on GitHub · 2026-11-25 11:49 UTC · [original](https://github.com/holdmysocks/SixNG/pull/257) `holdmysocks:six-deswizzle` → `master` · +23 −13 · 3 files · 1 commits · merged 2026-11-25 12:11 UTC Single-mip textures with 2- or 4-byte elements are stored in Gfx10 SW_4KB_S blocks. `mip0_linear` untiled them as 16×16-element tiles, so they decoded with stripes and scrambled blocks in PNG export, DDS export and the viewer. Affected textures include R16 height maps, RGBA8 tint palettes and shore profiles, and BGRA8 tiles. **Change** - `mip0_linear` untiles single-mip, uncompressed, 2/4-byte textures with `gfx10::Layout` (SW_4KB_S). - Textures with a mip chain, 1-byte textures and block-compressed formats are unchanged. So are the linear one-row palettes. - The water export drops its local workaround and uses the generic path. - README: a note in the unusual-formats row. **Checks on the install** - Neighbour smoothness of mip 0 was compared under the old tiling, SW_4KB_S, SW_64KB_D and linear. This covered every 2/4-byte single-mip texture of 32×32 or more in textures, levels, common and the packs. SW_4KB_S is smoothest on 1,051 of 1,064. The others are noise textures (blue noise, Gaussian, curl noise), 32×32 volumes and flat tiles. - Examples: the 1536×1748 R16 terrain height map goes from 8.86 to 0.82 mean neighbour difference, and the tint palettes drop by about half. - After the change the generic path gives the SW_4KB_S result for all of them. Multi-mip and 1-byte results are identical to before. - The water export is byte-identical: 279 image files and all JSON. - `cargo check --workspace --all-targets` and `cargo test -p sixng-core -p sixng-gui --release` pass. **The 13 textures where SW_4KB_S is not the smoothest layout** Each was compared side by side as decoded before this change (16×16 tiles) and after (SW_4KB_S). | Texture | Format, size | With this change | |---|---|---| | `lightanimintensity0000` | R16_FLOAT 512×512 | Near tie (81.8 vs 81.6). SW_4KB_S is clearly right: clean horizontal curves, one per row. The old decode broke them into 16-px column blocks. | | `blue_noise_64` | R16_UNORM 64×64 | Even, high-frequency blue noise. The old decode had visible clumps and 16-px structure, and smoothness penalises real blue noise. Looks right. | | `rope_anim_deg_twinkle_02` | R8G8B8A8_UNORM 32×32 | Regular per-column on/off patterns. The old decode repeated a scrambled block. Looks right. | | `rope_anim_twinkle_01` | R8G8B8A8_UNORM 32×32 | A one-texel checkerboard. The old decode gave vertical stripes. Both are regular, so it can't be judged by eye; plausible for a twinkle pattern. | | `iriscausticsdir` | R16G16_FLOAT 64×64 | Blocky shape with some 32-px blocks offset. SW_64KB_D is smoothest here (23.6 vs 26.6), and the old decode wasn't right either (broken columns). **Uncertain**: this texture may use another tile mode. | | `windnoisevolume` | R8G8B8A8_UNORM 32×32 | Blocky colour noise either way (61.7 vs 55.6); no visible structure to judge. | | `curlnoise`, `curlnoisecpu` | R10G10B10A2_UNORM 32×32 | Colour noise either way (98.4 vs 97.1); indistinguishable. | | `ocean_sim_gaussian_noise` | R32_FLOAT 256×256 | Gaussian noise either way (315.9 vs 314.9); indistinguishable. | | `shore_wave_placement_set1` ×2 (levels, minigame pack) | B8G8R8A8_UNORM 256×256 | Constant tiles. Every layout gives the same image, and the old decode only won the tie. | | `watersystemheightmap` ×2 (levels, minigame pack) | R16_UNORM 512×512 | Constant tiles, as above. | In short, 4 are constant tiles, 4 are pure noise where no layout looks better, and 3 look correct with this change. `rope_anim_twinkle_01` is regular either way. `iriscausticsdir` is the only one that looks off, and it was off before too.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:22:05 +00:00
github manually merged commit 84e20f867b into gh-pr/257/base 2026-11-26 20:22:07 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.