Skip to content

Performance model

shadekit’s defaults are tuned so a page full of shaders stays cheap. Most of it requires no code at all.

  • One device, one loop — a shared GPUDevice and a single requestAnimationFrame ticker serve every canvas on the page.
  • Frame-rate independence — shaders get absolute performance.now() seconds and a clamped dt; pointer damping uses 1 - exp(-10·dt), identical at 60/120/144Hz.
  • Off-screen pause — a shared IntersectionObserver stops rendering canvases that leave the viewport and resumes them on return.
  • Single upload per frame — all uniforms pack into one vec4 slot per field: one writeBuffer/uniform4fv per frame per instance.

maxDpr (default 2) caps devicePixelRatio. When a frame exceeds frameBudget milliseconds (default 17), the engine automatically steps the DPR down until frames fit again — and steps back up when the budget allows.

new ShaderInstance(aurora, { maxDpr: 1.5, frameBudget: 12 });

Lower frameBudget on pages with many shaders; raise maxDpr for fullscreen hero canvases on capable hardware.

respectReducedMotion (default true) renders one static frame and pauses when the user prefers reduced motion. Set it to false only for content where motion is the point and you provide your own opt-out.

  • paused: true mounts the shader and renders exactly one frame — useful for thumbnails or pre-hydration SSR placeholders.
  • At runtime call instance.pause() / instance.play() (React: the paused prop drives the same calls reactively).
  1. Check that the canvas isn’t being re-mounted (shader identity changes recreate the instance).
  2. Lower maxDpr before simplifying the fragment — fill rate is almost always the cost, not the math.
  3. Keep per-frame updateUniforms calls small; each call rewrites only the fields you pass.