Adaptive browser graphics with WebGL
The animated background from my old local web server now runs on its own page. It drifts between 19 patterns, ripples where you click, and picks a quality level the visitor's computer can keep smooth.
Results
19patterns it drifts between
3quality tiers, picked by measuring frame rate
8ripples the shader tracks at once
The problem
A full-screen shader can make a laptop with weak graphics stutter. I needed the visualizer to adjust to different graphics hardware without making visitors tune its settings.
What I did
- A feedback loop that renders into a pair of reduced-size framebuffers and swaps them every frame, so each frame is the last one zoomed, turned and faded.
- Layered fractal noise, two octaves normally and four on GPU Max, crossfading to a new pattern every 15 seconds.
- Click ripples and drag trails passed into the shader, with particles and a waveform drawn on a separate 2D canvas.
- Three quality tiers. On Auto the page starts at the top tier, times the first two seconds and steps down until the frame rate holds.
- Shader setup moved to a background worker, so the page and its controls appear at once while the graphics compile and fade in.
What I took from it
I measured the frame rate on the visitor's machine rather than choosing one setting for everyone. Auto mode takes about three seconds to settle on a tier.