Docs

Documentation

ultra-fast-texture turns WebP, AVIF, PNG and JPEG into GPU textures (BC7, ASTC, ETC2, …) on the GPU, while they load. Start with the agent skill; the rest of this page is a short reference.

Pre-release 0.0.0 v0.1 API frozen three 0.186.x MIT

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.

TerminalClaude Code, Codex, Cursor, …
npx skills add Makio64/ultra-fast-texture
.mcp.json / .cursor/mcp.jsonStdio MCP server
{
	"mcpServers": {
		"ultra-fast-texture": {
			"command": "npx",
			"args": [ "-y", "ultra-fast-texture", "mcp" ]
		}
	}
}
MCP toolWhat it does
uft_audit_assetsScans a project or folder for oversized maps, solid constant textures, duplicated GLB images and unpackable AO + MR slots.
uft_optimize_assetsRuns the closed-loop optimizer (GLB dedupe, ORM pack, PSNR-guarded resize & AVIF/WebP/RCD1 transcode) with a never-inflate guarantee.
uft_detect_semanticInspects a filename and texel statistics to classify color, data, normal or r accurately.
uft_setup_projectConfigures Vite (uftVitePlugin()), npm scripts and workspace agent rules cleanly.

Then ask

  • Audit and optimize all textures and .glb models in my three.js project without losing visual quality.
  • Wire UltraFastTextureLoader, registerUltraFastTexture and uftVitePlugin() 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

TerminalInstall & one-command setup
pnpm add ultra-fast-texture three@0.186.1
npx uft init   # wires Vite plugin, audit/optimize scripts & agent skill
ImportFor
ultra-fast-texture/threethree.js: UltraFastTextureLoader
ultra-fast-texture/gltfglTF: registerUltraFastTexture
ultra-fast-textureAny GPUDevice: createTextureEncoder
ultra-fast-texture/viteZero-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.

TerminalZero-flag CLI
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
PassZero-drawback rule
Semantic detectionReads glTF slots, filenames (_normal, _orm, _ao) and pixel statistics ([128,128,255] normals, grayscale, unused opaque alpha).
Lossless .glb packDeduplicates identical embedded images, merges matching separate AO + MetallicRoughness into ORM, and upgrades legacy spec-gloss materials.
Detail-aware right-sizingShrinks 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-inflateSteps 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

JavaScriptWebGPURenderer
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

JavaScriptGLTFLoader
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

JavaScriptany WebGPU renderer
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

JavaScriptcreateTextureEncoder options
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.

FormatWhat it isNeeds
auto (default)Hybrid fast-decode avif-fast / webp-fast with PSNR floor + never-inflate guardBuilt-in
avif-fastAVIF tuned for fast decoding. Start here for smallest transfers.avifenc / built-in
webp-fastWebP tuned for fastest CPU decodecwebp / built-in
rcd1GPU-native .rcd: decoded on the GPU, 0 ms CPU image decodenothing
JavaScriptvite.config.js (zero-config default)
import { uftVitePlugin } from 'ultra-fast-texture/vite'

export default {
	plugins: [ uftVitePlugin() ], // defaults: format 'auto', autoGlb + safe image optimizer
}
Terminaluft & uft-convert
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

TextureSemanticTip
Albedo, emissive, UIcolorLossy WebP or AVIF; lossless files decode slower.
Roughness, metalness, ORMdataPack O, R and M into one image. Not r: three.js reads roughness from G and metalness from B.
Normal mapnormalStored as XY. For DirectX normals, pass normalConvention: 'directx'.
AO, bump, alpha maskrOne channel at 4 bpp.

03Reference

Semantics and formats

SemanticBC GPUse.g. PCs, Macs, iPhone 15 Pro and newer, M3+ iPads, Snapdragon with Adreno 7xx / 8xxASTC GPUs without BCe.g. iPhones before the 15 Pro, most Mali, PowerVR and older AdrenoETC2-only GPUsrare: some Android GPUs in WebGPU compatibility mode
colorBC7 sRGBASTC 4×4 sRGBETC2 RGB / RGBA sRGB
dataBC7ASTC 4×4ETC2 RGB / RGBA
normalBC5 (XY)EAC RG11 (XY)EAC RG11 (XY)
normal-rgbBC7ASTC 4×4ETC2 RGB
rBC4 (4 bpp)EAC R11 (4 bpp)EAC R11 (4 bpp)
rgBC5EAC RG11EAC 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

OptionValues (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:

HTTP headerContent-Security-Policy
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.
  • /three and /gltf target three 0.186.x; the core works with any GPUDevice.
  • 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

Download sizeQuality on the GPU in dB (PSNR)
  • 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
Time to GPU on 4G8 Mbps, from request to GPU texture
  • UltraTexture + AVIF-Fast362 ms
  • UltraTexture + WebP430 ms
  • spark.js + WebP430 ms
  • TextureLoader + WebP430 ms
  • KTX2Loader + Basis UASTC1,701 ms
Time to GPU on fibre1 Gbps, from request to GPU texture
  • UltraTexture + AVIF-Fast11 ms
  • UltraTexture + WebP22 ms
  • spark.js + WebP21 ms
  • TextureLoader + WebP34 ms
  • KTX2Loader + Basis UASTC49 ms
GPU memoryThe four textures with full mipmaps
  • 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:

TrackBitrate / VRAMMeasured Quality & Speed (Apple M3 Max)
Hardware BC6H_UF16 (bc6h.js)8.00 bpp · 8.00× vs rgba16floatModes 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 BC7Packs 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.

Try it before you install it.

Drop a .glb or an image into the Playground. It runs in your browser, on your GPU.