@motion-core/motion-gpu ships a framework-agnostic WebGPU core plus Svelte 5, React 18/19, and Vue 3 adapters for fullscreen WGSL rendering. You get a declarative material system, a reactive frame scheduler, a composable post-processing pipeline, and GPU compute shader support — wired into a single <FragCanvas> component in all three adapters.
This documentation was generated directly from the packages/motion-gpu/src source tree, so every contract, default value, and edge-case behavior described here reflects the actual implementation.
AI documentation access
Motion GPU documentation is also available for AI tools via Context7.
Framework mental model
Understanding the frame-by-frame flow is the single most useful thing you can learn about Motion GPU:
- You create an immutable material with
defineMaterial({ fragment, uniforms, textures, storageBuffers, ... }). FragCanvasresolves that material and derives a pipeline signature (a deterministic string from the compiled shader, uniform layout, texture config/bindings includingfragmentVisible, and storage buffer definitions).- If the signature changes, the WebGPU renderer is rebuilt from scratch. If it stays the same, only uniform buffers and texture bindings are updated — no recompilation.
- Every animation frame:
- Scheduler tasks run in topological order (your
useFramecallbacks). - Runtime uniforms and textures are merged with material defaults.
- Pending storage buffer writes are flushed to the GPU.
- Compute passes dispatch their workgroups through the render graph.
- The base fullscreen pass renders your fragment shader.
- Optional post-process passes execute through the render graph.
- The final result is presented to the canvas.
- Scheduler tasks run in topological order (your
Hard contracts
These are enforced at runtime and will throw immediately if violated:
Defaults worth knowing
Scope and boundaries
- This package targets fullscreen fragment workflows and GPU compute — it is not a general-purpose scene graph or 3D engine.
- Root entrypoints (
@motion-core/motion-gpu,/advanced) are framework-agnostic core APIs. - Framework runtimes must be consumed via adapter entrypoints (
@motion-core/motion-gpu/svelte,@motion-core/motion-gpu/react,@motion-core/motion-gpu/vue). - Adapter runtimes work without advanced entrypoints;
@motion-core/motion-gpu/svelte/advanced,@motion-core/motion-gpu/react/advanced, and@motion-core/motion-gpu/vue/advancedadd namespaced user state and extended scheduler ergonomics. - All documentation references behaviors currently implemented in the repository, including edge cases verified by the test suite.