Textures: untile uncompressed mip chains as SW_4KB_S, tail included #263

Manually merged
github merged 3 commits from gh-pr/263/head into gh-pr/263/base 2026-11-26 20:22:38 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 12:12 UTC · original
holdmysocks:six-mipchain → master · +51 −22 · 2 files · 3 commits · merged 2026-11-25 12:56 UTC

Follow-up to PR 257 (merged).

Uncompressed textures with a mip chain were read as 16×16-element tiles at the block-compressed mip offsets. They are stored in the Gfx10 SW_4KB_S chain layout, packed mip tail included, so mip 0 and the smaller mips decoded scrambled in PNG export, DDS export and the viewer.

Change

  • New uncompressed_layout in texture.rs covers uncompressed single-mip 2/4-byte textures (from PR 257) and every uncompressed texture with a mip chain.
  • mip0_linear and mip_linear untile through it.
  • exportable_mips returns the whole chain for these textures, so DDS export writes all mips. Block-compressed textures are unchanged and still stop above their packed tail.
  • Single-mip 1- and 8-byte textures keep the 16×16 tiles.
  • README: the unusual-formats row and the DDS row.

Checks on the install

These are all the uncompressed textures with a mip chain in textures.rpf, data.rpf, levels, common and the packs. Mip k+1 was compared with mip k averaged 2×2:

Texture Format, size, mips Before After
corona R32_FLOAT 32×32, 6 mips 1–5 exact; mip 0 → 1 at 24.9 dB (8-bit) every mip an exact float average (relative error 0.0000)
generic_instruments_i8b, _i7 A8 1024×256, 7 11–16 dB 62–68 dB on every mip, tail included
vit_montagne_i3 A8 512×512, 8 21–33 dB 60–65 dB on every mip
puddle_layout1 R8_UNORM 256×256, 9 13–16 dB 40–59 dB on every mip
caustic R8G8B8A8_UNORM 256×256, 9 13–14 dB 51.5 dB mip 0 → 1, then 15–30 dB
fognoise R8_UNORM 32×32, 6 unchanged unchanged (the whole chain is in one tail block, already read with this layout)

caustic's smaller mips hold a finer caustic pattern rather than a downsample. Every other block offset for mip 3 matches worse (6–14 dB against 22 dB), so the placement is right and the difference is in the content.

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

**@⁠holdmysocks** on GitHub · 2026-11-25 12:12 UTC · [original](https://github.com/holdmysocks/SixNG/pull/263) `holdmysocks:six-mipchain` → `master` · +51 −22 · 2 files · 3 commits · merged 2026-11-25 12:56 UTC Follow-up to PR 257 (merged). Uncompressed textures with a mip chain were read as 16×16-element tiles at the block-compressed mip offsets. They are stored in the Gfx10 SW_4KB_S chain layout, packed mip tail included, so mip 0 and the smaller mips decoded scrambled in PNG export, DDS export and the viewer. **Change** - New `uncompressed_layout` in `texture.rs` covers uncompressed single-mip 2/4-byte textures (from PR 257) and every uncompressed texture with a mip chain. - `mip0_linear` and `mip_linear` untile through it. - `exportable_mips` returns the whole chain for these textures, so DDS export writes all mips. Block-compressed textures are unchanged and still stop above their packed tail. - Single-mip 1- and 8-byte textures keep the 16×16 tiles. - README: the unusual-formats row and the DDS row. **Checks on the install** These are all the uncompressed textures with a mip chain in textures.rpf, data.rpf, levels, common and the packs. Mip k+1 was compared with mip k averaged 2×2: | Texture | Format, size, mips | Before | After | |---|---|---|---| | `corona` | R32_FLOAT 32×32, 6 | mips 1–5 exact; mip 0 → 1 at 24.9 dB (8-bit) | every mip an exact float average (relative error 0.0000) | | `generic_instruments_i8b`, `_i7` | A8 1024×256, 7 | 11–16 dB | 62–68 dB on every mip, tail included | | `vit_montagne_i3` | A8 512×512, 8 | 21–33 dB | 60–65 dB on every mip | | `puddle_layout1` | R8_UNORM 256×256, 9 | 13–16 dB | 40–59 dB on every mip | | `caustic` | R8G8B8A8_UNORM 256×256, 9 | 13–14 dB | 51.5 dB mip 0 → 1, then 15–30 dB | | `fognoise` | R8_UNORM 32×32, 6 | unchanged | unchanged (the whole chain is in one tail block, already read with this layout) | `caustic`'s smaller mips hold a finer caustic pattern rather than a downsample. Every other block offset for mip 3 matches worse (6–14 dB against 22 dB), so the placement is right and the difference is in the content. `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
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:22:36 +00:00
github manually merged commit 7a59bd84ac into gh-pr/263/base 2026-11-26 20:22:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.