Anthony Fu drops img-auto-parallax for on-device depth
The MIT-licensed WebComponent swaps in for standard <img> tags, running bundled Depth Anything V2 or FastDepth ONNX models locally via WebGPU and Vercel's vgpu to render interactive parallax and depth-of-field effects. It falls back cleanly to a plain image without WebGPU and supports precompiling grayscale depth maps at build time to skip browser inference altogether.
Client-side ML demos usually die on contact with production bundle budgets, so pairing an on-device WebGPU vision component with a build-time precompiler is the exact engineering trade-off that makes this usable outside a portfolio showcase.
- –Bundles quantized Depth Anything V2 Small (19 MB, Apache-2.0) and FastDepth (5 MB, MIT) via ONNX Runtime Web, with 64 MB MiDaS v2.1 small available on demand, requiring zero backend servers or API keys.
- –Ships a companion `img-auto-parallax-build` package (Vite plugin, CLI, and Node 22+ API) that precomputes small grayscale `.depth.png` maps once at build time—letting production sites drop the entire ONNX and WebAssembly runtime while keeping live shader parallax and defocus.
- –Goes beyond basic hover tilt with pointer-driven depth-of-field (`defocus` and `refocus`), mobile gyroscope controls, and foreground/background `cutoff` layers for Apple lock-screen-style text-behind-subject layouts.
- –Serves as a practical early showcase for Vercel Labs' `vgpu` WebGPU wrapper, demonstrating how quantized vision models and WGSL shaders are collapsing into drop-in HTML primitives—though real-world deployment still inherits WebGPU's HTTPS requirement and iOS Safari's gesture-gated motion permissions.
DISCOVERED
29m ago
2026-12-01
PUBLISHED
57m ago
2026-12-01
RELEVANCE
AUTHOR
pzayap