Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/cooked-asset-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,31 @@ renderer path, buffers, shaders, passes, draws, pixels, or frame-time behavior.

The canonical variant, fallback, deduplication, and Bistro qualification is
recorded in `docs/evidence/issue-136-asset-variants-v2.{md,json}`.

## Compressed textures inside a GLB (`glb-compress`)

`glb-compress` is independent of the store: it rewrites one GLB so every
embedded image is a KTX2 container of ASTC blocks with a full mip chain, and
the ordinary `loadModel` / staged model paths load the result.

```shell
cargo run --release --manifest-path tools/bloom-cook/Cargo.toml -- \
glb-compress hero.glb hero.astc.glb [--astc 4x4] [--normal-astc 4x4|keep] \
[--quality fast|medium|thorough|exhaustive]
```

- On an adapter with `TEXTURE_COMPRESSION_ASTC` (every Apple GPU, most mobile
GPUs) the blocks upload untouched: a 4096² texture occupies 22 MB at 4×4 or
10 MB at 6×6 instead of 85 MB of RGBA8 with mips, and load skips PNG inflate
and mip filtering. Other adapters decode level zero on the CPU and take the
RGBA8 path, so one file loads everywhere. BC7 payloads in KTX2 are read the
same way.
- Mips are the runtime's own: sRGB-aware averaging for colour, plain averaging
for data, renormalised direction plus accumulated variance in alpha for
normal maps.
- Base-colour images of alpha-`MASK` materials are left as they are, because
their coverage mips depend on the material cutoff.
- The command prints the PSNR of each encoded top level. The file on disk is
larger than with PNG or JPEG images (blocks are not entropy-coded).
- The images carry `mimeType: "image/ktx2"`. That is not a ratified glTF
extension for raw ASTC, so keep the source GLB for other tools.
7 changes: 7 additions & 0 deletions native/android/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions native/ios/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions native/linux/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions native/macos/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions native/shared/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions native/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ image-extras = [
"dep:image_dds",
"dep:serde_json",
"dep:sha2",
# KTX2 images with ASTC blocks in glTF: the software decoder for
# adapters without the format.
"dep:astc-decode",
]

[build-dependencies]
Expand All @@ -59,6 +62,7 @@ bytemuck = { version = "1", features = ["derive"] }
half = "2"
image = { version = "0.25", default-features = false, features = ["png"] }
image_dds = { version = "0.7", default-features = false, features = ["ddsfile", "image"], optional = true }
astc-decode = { version = "0.3", optional = true }
gltf = { version = "1", features = [
"extensions",
"extras",
Expand Down
Loading
Loading