Performance model
shadekit’s defaults are tuned so a page full of shaders stays cheap. Most of it requires no code at all.
What you get for free
Section titled “What you get for free”- One device, one loop — a shared
GPUDeviceand a singlerequestAnimationFrameticker serve every canvas on the page. - Frame-rate independence — shaders get absolute
performance.now()seconds and a clampeddt; pointer damping uses1 - exp(-10·dt), identical at 60/120/144Hz. - Off-screen pause — a shared
IntersectionObserverstops rendering canvases that leave the viewport and resumes them on return. - Single upload per frame — all uniforms pack into one
vec4slot per field: onewriteBuffer/uniform4fvper frame per instance.
Resolution budget
Section titled “Resolution budget”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.
Reduced motion
Section titled “Reduced motion”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.
Pause control
Section titled “Pause control”paused: truemounts the shader and renders exactly one frame — useful for thumbnails or pre-hydration SSR placeholders.- At runtime call
instance.pause()/instance.play()(React: thepausedprop drives the same calls reactively).
If a shader still stutters
Section titled “If a shader still stutters”- Check that the canvas isn’t being re-mounted (
shaderidentity changes recreate the instance). - Lower
maxDprbefore simplifying the fragment — fill rate is almost always the cost, not the math. - Keep per-frame
updateUniformscalls small; each call rewrites only the fields you pass.