01Start
Agent skill & MCP server
Add the skill or plug in the zero-dependency stdio MCP server so Claude Code, Cursor, Codex or Antigravity can audit, wire and optimize your textures automatically.
npx skills add Makio64/ultra-fast-texture
{
"mcpServers": {
"ultra-fast-texture": {
"command": "npx",
"args": [ "-y", "ultra-fast-texture", "mcp" ]
}
}
}
| MCP tool | What it does |
|---|---|
uft_audit_assets | Scans a project or folder for oversized maps, solid constant textures, duplicated GLB images and unpackable AO + MR slots. |
uft_optimize_assets | Runs the closed-loop optimizer (GLB dedupe, ORM pack, PSNR-guarded resize & AVIF/WebP/RCD1 transcode) with a never-inflate guarantee. |
uft_detect_semantic | Inspects a filename and texel statistics to classify color, data, normal or r accurately. |
uft_setup_project | Configures Vite (uftVitePlugin()), npm scripts and workspace agent rules cleanly. |
Then ask
- Audit and optimize all textures and
.glbmodels in my three.js project without losing visual quality. - Wire
UltraFastTextureLoader,registerUltraFastTextureanduftVitePlugin()into my scene. - Use ultra-fast-texture in my own WebGPU renderer.
Read the skill: SKILL.md. It ships inside the npm package (skills/), and in Claude Code /ultra-fast-texture invokes it directly. Other agents: llms.txt.
Install
pnpm add ultra-fast-texture three@0.186.1
npx uft init # wires Vite plugin, audit/optimize scripts & agent skill
| Import | For |
|---|---|
ultra-fast-texture/three | three.js: UltraFastTextureLoader |
ultra-fast-texture/gltf | glTF: registerUltraFastTexture |
ultra-fast-texture | Any GPUDevice: createTextureEncoder |
ultra-fast-texture/vite | Zero-config Vite plugin, uft auto-optimizer & MCP server |
Automatic optimization
Pure performance gain with zero quality or workflow drawback: audit a repo or optimize textures and .glb models in place with one zero-flag command.
npx uft audit --json # non-destructive audit & savings estimate
npx uft optimize --in-place # optimize textures + .glb files safely in place
npx uft optimize ./assets --out ./dist/assets
| Pass | Zero-drawback rule |
|---|---|
| Semantic detection | Reads glTF slots, filenames (_normal, _orm, _ao) and pixel statistics ([128,128,255] normals, grayscale, unused opaque alpha). |
Lossless .glb pack | Deduplicates identical embedded images, merges matching separate AO + MetallicRoughness into ORM, and upgrades legacy spec-gloss materials. |
| Detail-aware right-sizing | Shrinks solid uniform maps (>16²) to 8×8; halves over-authored maps 2× only when global PSNR ≥ 45 dB and worst 16×16 patch ≥ 38 dB. |
| PSNR floor & never-inflate | Steps quality upward until the semantic PSNR target (≥ 38–42 dB) holds; keeps original bytes whenever re-encoding is larger. |
Even if a visitor opens your app on WebGL2 or a device without WebGPU block compression, UltraFastTextureLoader and registerUltraFastTexture fail open to standard Three.js textures automatically.
02Guides
three.js loader
import { UltraFastTextureLoader } from 'ultra-fast-texture/three'
const loader = new UltraFastTextureLoader( renderer )
material.map = await loader.loadAsync( 'albedo.webp' )
material.normalMap = await loader.loadAsync( 'normal.webp', { semantic: 'normal' } )
material.roughnessMap = await loader.loadAsync( 'orm.webp', { semantic: 'data' } )
material.aoMap = await loader.loadAsync( 'ao.webp', { semantic: 'r' } )
load() returns a placeholder at once and swaps in the compressed texture when it is ready (call await loader.init() first). On WebGL you get plain three.js textures; on a GPU without compressed formats, RGBA8 with mipmaps.
glTF plugin
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'
import { registerUltraFastTexture } from 'ultra-fast-texture/gltf'
const gltfLoader = registerUltraFastTexture( new GLTFLoader(), loader )
const gltf = await gltfLoader.loadAsync( 'scene.glb' )
Each texture gets its semantic from its material slot. The summary is in gltf.userData.ultraFastTexture.
Raw GPUDevice / mini3
import { createDevice, createTextureEncoder } from 'ultra-fast-texture'
const device = await createDevice() // or your own GPUDevice
const encoder = await createTextureEncoder( device )
const out = await encoder.encode( 'albedo.webp', { semantic: 'color' } )
out.texture // GPUTexture with every mip level
out.format // 'bc7' | 'astc-4x4' | 'etc2-rgb' | …
out.release()
Worker mode
const encoder = await createTextureEncoder( device, {
worker: 'decode', // 'off' (default) | 'decode' | 'full'
cache: 'persistent', // reuse encoded textures on the next visit
} )
'decode' decodes images off the main thread; 'full' also encodes there. Under a strict CSP, serve dist/worker.js and pass workerURL. With content-hashed URLs, add cacheValidation: 'url'.
Build tools
Optional: standard WebP, AVIF, PNG and JPEG files work with zero build config. Add zero-config uftVitePlugin() to optimize imported .glb/.gltf models, images and public/ assets automatically during dev and build.
| Format | What it is | Needs |
|---|---|---|
auto (default) | Hybrid fast-decode avif-fast / webp-fast with PSNR floor + never-inflate guard | Built-in |
avif-fast | AVIF tuned for fast decoding. Start here for smallest transfers. | avifenc / built-in |
webp-fast | WebP tuned for fastest CPU decode | cwebp / built-in |
rcd1 | GPU-native .rcd: decoded on the GPU, 0 ms CPU image decode | nothing |
import { uftVitePlugin } from 'ultra-fast-texture/vite'
export default {
plugins: [ uftVitePlugin() ], // defaults: format 'auto', autoGlb + safe image optimizer
}
npx uft optimize --in-place
npx uft-convert scene.glb -o scene.avif.glb --format avif-fast
npx uft-convert albedo.png -o albedo.rcd --format rcd1
Authoring guide
| Texture | Semantic | Tip |
|---|---|---|
| Albedo, emissive, UI | color | Lossy WebP or AVIF; lossless files decode slower. |
| Roughness, metalness, ORM | data | Pack O, R and M into one image. Not r: three.js reads roughness from G and metalness from B. |
| Normal map | normal | Stored as XY. For DirectX normals, pass normalConvention: 'directx'. |
| AO, bump, alpha mask | r | One channel at 4 bpp. |
03Reference
Semantics and formats
| Semantic | BC GPUse.g. PCs, Macs, iPhone 15 Pro and newer, M3+ iPads, Snapdragon with Adreno 7xx / 8xx | ASTC GPUs without BCe.g. iPhones before the 15 Pro, most Mali, PowerVR and older Adreno | ETC2-only GPUsrare: some Android GPUs in WebGPU compatibility mode |
|---|---|---|---|
color | BC7 sRGB | ASTC 4×4 sRGB | ETC2 RGB / RGBA sRGB |
data | BC7 | ASTC 4×4 | ETC2 RGB / RGBA |
normal | BC5 (XY) | EAC RG11 (XY) | EAC RG11 (XY) |
normal-rgb | BC7 | ASTC 4×4 | ETC2 RGB |
r | BC4 (4 bpp) | EAC R11 (4 bpp) | EAC R11 (4 bpp) |
rg | BC5 | EAC RG11 | EAC RG11 |
bitrate: 'medium' | 'low' | ASTC 6×6 / 8×8 if the GPU also has ASTC; otherwise BC1 (opaque) or BC7 (alpha) | ASTC 6×6 (3.56 bpp) / 8×8 (2 bpp) | ETC2 RGB (4 bpp, opaque) / ETC2 RGBA (alpha) |
Chosen from the compression features the GPU reports, never from the user agent. Apple GPUs report BC and ASTC, so they use the BC column.
Options
| Option | Values (default first) |
|---|---|
semantic | 'color' · 'data' · 'normal' · 'normal-rgb' · 'r' · 'rg' |
bitrate | 'high' · 'medium' · 'low' (8 bpp down to 2 bpp, per GPU) |
quality | 'default' · 'fast' |
alpha | 'auto' · 'none' · 'keep' |
normalConvention | 'opengl' · 'directx' |
worker | 'off' · 'decode' · 'full' |
cache | 'memory' · 'persistent' · false |
schedule | 'auto' · 'paced' · 'immediate' |
warmup | ['color'] · [] to compile on first use |
Every texture carries a receipt (out, or texture.userData.ultraFastTexture) with its format, GPU bytes, fallback and timings. Errors are UFTError with a code.
CSP
No WASM and no eval, so a strict policy works:
default-src 'self'; script-src 'self'; style-src 'self';
img-src 'self' data: blob:; connect-src 'self' data: blob:; worker-src 'self' blob:;
Limitations
- Needs WebGPU: Chrome and Edge on most platforms, Safari 26, Firefox on Windows and Apple-silicon Macs. Tested on Chrome with an Apple M3 Max.
- 11 core SDR formats in
src/; experimental HDR (BC6H) and TSL variable-bitrate PBR prototypes live in Beyond BC7. /threeand/gltftarget three 0.186.x; the core works with anyGPUDevice.- Sources above 4096² are halved unless you pass
createDevice( { requiredLimits: 'adapter' } ).
04Project
Benchmarks
The same four colour textures (3.1 MP), loaded by each loader and compressed to BC7. Shorter bars are better.
UltraTextureOther loaders
- UltraTexture + AVIF-Fast294 KiB35.9 dB
- UltraTexture + WebP351 KiB35.4 dB
- spark.js + WebP351 KiB34.0 dB
- TextureLoader + WebP351 KiB35.9 dB
- KTX2Loader + Basis UASTC1,575 KiB35.8 dB
- UltraTexture + AVIF-Fast362 ms
- UltraTexture + WebP430 ms
- spark.js + WebP430 ms
- TextureLoader + WebP430 ms
- KTX2Loader + Basis UASTC1,701 ms
- UltraTexture + AVIF-Fast11 ms
- UltraTexture + WebP22 ms
- spark.js + WebP21 ms
- TextureLoader + WebP34 ms
- KTX2Loader + Basis UASTC49 ms
- UltraTexture + AVIF-Fast4.0 MiB
- UltraTexture + WebP4.0 MiB
- spark.js + WebP4.0 MiB
- TextureLoader + WebP16.0 MiB
- KTX2Loader + Basis UASTC4.0 MiB
Apple M3 Max, Chrome 156–157, November 2026: network emulated by Chrome, loader code already loaded, one mip level, median of 3 runs. GPU memory is computed: BC7 against uncompressed RGBA8. Run them on your GPU · All measurements · RCD1 at equal quality
Beyond BC7 (HDR & TSL)
Research tracks in bench/beyond-bc7/ that push past the fixed 8-bpp BC7 ceiling without pre-transcoding or WebAssembly:
| Track | Bitrate / VRAM | Measured Quality & Speed (Apple M3 Max) |
|---|---|---|
Hardware BC6H_UF16 (bc6h.js) | 8.00 bpp · 8.00× vs rgba16float | Modes 11–14 in log2 space: 70.09 dB 9-stop mPSNR (5.2–5.5 ms), 0-ULP hardware parity, PMREMNode IBL ready. |
Joint PBR TSL JMBC1 (jmbc-gpu.js + tsl-material.js) | 2.61–5.85 bpp · 4.27×–5.98× vs 24-bpp BC7 | Packs standard .glb/.avif/.webp PBR tuples into 4 adaptive 8×8 macro-tile tiers; viking_ship.glb drops from 6.03 MB BC7 to 1.27 MB (4.76×) at 43.52 dB render PSNR. |
Open the interactive Beyond BC7 lab and benchmark tables · Read 11-beyond-bc7.md.
Licence
MIT, every WGSL kernel included (third-party notices). The Playground’s sample models are CC BY 4.0: Viking Ship by emelyarules, Retro Cartoon Car by RCC Design, Cat House by Roman_Nilikovskii, Butterfly by Erina eka syaharani, GoldFish by Tasha.Lime.