GitHub
Translate

Opens Google Translate in a new tab. Website translation availability varies by region. Details

How FluxFX Works

A simple, clear look at how FluxFX runs effects smoothly — from HTML attribute scanning and a shared animation loop to background GPU workers and automatic FPS protection.

Architecture Pipeline

HTML [data-fx] / FluxFX.apply() / useFX() FluxEngine (Registry + Lifecycle + Error Isolation) Hot-updates options via setOptions() without restarting WebGL DOM Effects (tilt-3d, magnetic) 1 shared rAF loop • Sleeps at 0% CPU when idle WebGL2 Effects (WebGLQuad + Context Budget) Max 6 mobile / 8 desktop • CSS gradient fallback if full OffscreenCanvas Web Worker Main-Thread Fallback (Safari)

1. FluxEngine & CentralizedTicker

2. OffscreenCanvas Worker vs Main-Thread Fallback

WebGLQuad renders every shader onto a single fullscreen triangle ([-1,-1, 3,-1, -1,3]) in WebGL2 (#version 300 es):

3. Ping-Pong FBO Simulation

fluid, ink, and aetheria use two paired offscreen framebuffers (pingPong[0] and pingPong[1]):

  1. Feedback Pass: Renders feedbackShader into the write FBO while sampling the previous frame from uPrevFrame (advecting velocity in RG channels and dye/ink in BA channels).
  2. Swap: Swaps readIdx and writeIdx.
  3. Display Pass: Renders the final shaded frame to screen sampling uFeedback.

FBOs prefer RGBA16F (HALF_FLOAT) when EXT_color_buffer_float or EXT_color_buffer_half_float is available, automatically falling back to RGBA8. FBO dimensions scale with quality (0.35 low, 0.5 medium, 0.65 high) and cap the longest edge (512px / 896px / 1152px).

4. Dual-Axis Efficiency & 30 ↔ 60 FPS Hover Benchmark

FluxFX coordinates work across the main thread and, when supported, an OffscreenCanvas worker. Its scheduler uses lower ambient and higher interaction frame-rate targets, then returns to the ambient target after activity. Actual frame rate and CPU/GPU cost vary by browser, device, effect, and page workload; the targets shown here are not performance guarantees. Settled DOM effects can stop requesting ticker updates until interaction wakes them.

60 FPS 30 FPS Idle Cursor Hover / Scroll Active (1800ms Boost Window) Ambient GPU Cruise (30 FPS) Instant 60 FPS Worker Boost Cool-Down Back to 30 FPS DOM effects sleep while settled; worker support is browser-dependent Pointer Outside Pointer Enter Pointer Leave Settled (Power Save)
Ambient Mode (30 FPS Target) Hover stage to trigger 60 FPS boost

Zero Main-Thread DOM Bottlenecks

WebGL2 shaders execute inside an OffscreenCanvas Web Worker wherever supported, while DOM interactions share one rAF ticker and sleep at 0% CPU once damped.

Thermal & Battery GPU Guardrails

Frame-rate targets, DynamicResolution DPR scaling, viewport pause (IntersectionObserver), and maxActiveContexts help manage rendering cost. They cannot prevent thermal throttling on every device.

5. Frame Pacing, DynamicResolution & PerformanceGuard

Subsystem Behavior
Adaptive FPS Pacing Idles at 30 FPS ambient and boosts to 60 FPS for 1800ms on pointer, touch, scroll, or option updates using exponential dt smoothing.
DynamicResolution Samples a 30-frame ring buffer; drops DPR by 0.15 if average frame time > 20.5ms, and restores by +0.10 after two stable windows < 17.2ms.
PerformanceGuard Escalates across 4 tiers (0: normal, 1: reduced-res, 2: low-fps, 3: survival), progressively lowering DPR, uQuality, FPS (20/30 → 15/30), and FBO size, suspending non-interacted effects in survival mode with a 6s recovery probe.
Context Budget Enforces maxActiveContexts (6 on Safari/mobile, 8 on desktop). Off-viewport or idle canvases are evicted to CSS radial-gradient placeholders and restored on scroll-in or hover.

6. Theme, Surface Adaptation & Accessibility