RUST · LIBRARY + CLI

Make game assets small.

smasher packs sprites into atlases, turns textures into KTX2, compresses models with Draco or meshopt and cuts each one to what a phone, a desktop or a big screen can draw. The codecs are compiled in: no Node, no external tools to install.

$cargo install --git https://github.com/joydle/smasher smasher-cli
INOUT
4.1 MB rigged character, 35 animation clips
1.6 MB → 162 KB
a static scene, KTX2 textures and Draco geometry
4× less VRAM
KTX2 stays compressed on the GPU; a PNG decodes to raw RGBA
9–15% smaller
than gltfpack at the same texture quality
No surprises
an image or model that does not shrink is not written; inputs are never touched

See it

The original from Khronos against what smasher mesh wrote. Loaded live, measured in your browser.

Drag to turn, scroll or pinch to zoom, right-drag to pan, double-click to reset.

loading…
file–
GPU texture memory–
load + decode–
textures–

Damaged Helmet by ctxwing (CC BY 4.0), after theblueturtle_ (CC BY-NC 4.0). Lantern by sbtron and Frank Galligan, BoomBox by Microsoft (CC0). All from the Khronos glTF Sample Assets; licenses in site/models. The smashed files cap textures at 1024 px as well as keeping them compressed, and the GPU figure counts both: an uncompressed texture is RGBA8 with its mip chain.

Numbers

Against the two open-source tools people reach for: same models, same 1024 px texture cap.

modeloriginalsmashergltfpack, UASTC datagltfpack defaultgltf-transform
DamagedHelmet3.77 MB2.26 MB 39.6 dB2.65 MB 39.7 dB0.81 MB 27.1 dB0.87 MB 34.6 dB
Lantern9.56 MB1.18 MB 41.2 dB1.29 MB 41.2 dB0.42 MB 28.4 dB2.96 MB 58.4 dB
BoomBox10.6 MB0.97 MB 41.7 dB1.11 MB 41.5 dB0.26 MB 21.9 dB2.14 MB 52.3 dB
rigged character, 35 clips, Draco4.08 MB2.65 MBcannot read Draco2.74 MB

Textures capped at 1024 px everywhere. dB is the worst data map (normal, roughness, occlusion): PSNR against the source map resized without compression; higher is closer. smasher and the first gltfpack column both write UASTC for data maps and ETC1S for colour (gltfpack -c -tc -tu normal -tu attrib -tl 1024); at the same quality smasher's files are 9–15% smaller, in the same range of time. gltfpack's default (-c -tc -tl 1024) puts every map in ETC1S: the smallest files, at 22–28 dB. gltf-transform (optimize --compress meshopt --texture-size 1024) keeps JPEG: sharp, but every texture is full RGBA on the GPU, and its KTX2 needs KTX-Software. gltf-transform 4.4, gltfpack 1.3. The first three are Khronos sample models; the last is in crates/smasher-glb/tests/fixtures.

what it doessmashergltf-transformgltfpack
Runs asRust library + CLINode.js library + CLIC++ CLI, also on npm
meshopt geometryyesyesyes
Draco geometryyesyesno, and refuses Draco input
Picks the codec per modelDraco static, meshopt animatedyou choosemeshopt only
KTX2 / Basis texturesbuilt inneeds KTX-Softwarenative builds
Levels per device and asset classphone · desktop · higha simplify ratioa simplify ratio
Sprite atlases and stripsyes, TexturePacker JSONnono

When bytes are all that count and softer maps are fine, gltfpack's defaults go smallest. smasher keeps data maps sharp and also does the sprites, atlases and images a game ships.

What it does

Built while shipping our own games.

Sprite atlases
MaxRects packing with trim, padding and power-of-two, a TexturePacker JSON-hash manifest that loads straight into Pixi, animations named, and unpack to get the frames back. Fixed-grid strips too.
Images
Cap the longest edge with Lanczos3, re-encode as PNG (a lossless palette when it has 256 colours or fewer, quantized on request) or JPEG. A result is written only if it is smaller.
Geometry
meshopt for animated models, Draco for static ones, chosen per file. Quantize, deduplicate, join meshes, prune constant animation channels. Draco input passes through untouched.
Textures
KTX2 with Basis Universal: UASTC for normal, metallic-roughness and occlusion maps, ETC1S for colour, full mip chain, colour resized in linear light. Fills UV gutters so mips do not bleed dark seams.
Levels
One source model cut once per device class, to a triangle budget for what it is: a pickup, a prop, a set piece, a character. A manifest names every level.
Fail-open
An error or a panic returns your original bytes. A heavier asset that works beats a missing one. Inputs are never overwritten.

Levels

How hard to smash. Phone is the most aggressive; high keeps the detail a big screen shows.

PHONE
×1
textures ≤ 1024 px · surface error ≤ 2%
DESKTOP
×4
textures ≤ 2048 px · error ≤ 1%
HIGH
×16
textures ≤ 4096 px · error ≤ 0.5%
asset classphonedesktophigh
food, pickups1,5006,00024,000
props2,50010,00040,000
characters (rigged)6,00024,00096,000
thin-walled: cups, bowls, rims7,00028,000112,000
set pieces, buildings, backdrops9,00036,000144,000

Triangles for the whole model. The phone column is the top of what our games shipped on an iPhone 11-class phone; desktop and high step ×4 each, with texture detail rising alongside. The simplifier stops at the error bound even if the budget is not met.

Use

From the shell, from Rust, or from any tool over JSON.

shell — results go to ./smashed, inputs untouched

$ smasher mesh hero.glb --levels phone,desktop,high
optimize_mesh  372 KB source → 3 level(s)
  smashed/hero.phone.glb  106 KB
  smashed/hero.desktop.glb  116 KB
  smashed/hero.high.glb  116 KB
  smashed/hero.levels.json  525 B
  phone    5998 triangles (of 7185), textures ≤ 1024 px
  desktop  7185 triangles (of 7185), textures ≤ 2048 px
  high     7185 triangles (of 7185), textures ≤ 4096 px

$ smasher atlas sprites/coin_*.png --max-size 2048
$ smasher compress art/*.png --max-size 1024 --format png --quantize
$ smasher gutters hero.glb   # audit UV gutters; `dilate` fills them

Rust — crates/smasher/examples/quickstart.rs

use smasher_glb::{optimize, Options, TextureMode};

let glb = std::fs::read("hero.glb")?;
let (small, report) = optimize(&glb, Options {
    textures: TextureMode::Clamp(1024),
    ktx2: true,
    ..Options::default()
})?;
std::fs::write("hero.small.glb", small)?;

JSON — one request on stdin, one answer on stdout

$ echo '{"root":".","op":"pack_atlas","paths":["a.png","b.png"],"out_dir":"out"}' | smasher
{"protocol":1,"op":"pack_atlas","adopted":true,"before_bytes":8735,"after_bytes":4642,…}

Three crates: smasher (images, atlases, the GLB front end, levels), smasher-glb (the in-process GLB optimizer with Draco, meshoptimizer and Basis Universal compiled in) and smasher-cli. Building needs a C++ compiler for the codecs; smasher-glb also builds without them (--no-default-features), keeping textures PNG/JPEG and static meshes on meshopt.