About this tool
The GLSL Playground is a live fragment-shader laboratory built on WebGL2. Every keystroke recompiles your shader; compiler errors are parsed and mapped back from the injected uniform header to your line numbers, then highlighted directly in the CodeMirror editor (lazy-loaded, so it never bloats the page). A live FPS counter sits next to the render so performance regressions — one loop too many, one branch too deep — show up the moment you type them.
The Shadertoy uniform contract is honored in full: iResolution, iTime, iTimeDelta, iFrame, iMouse (drag the canvas to feed it) and four sampler channels iChannel0..3. Write the familiar `void mainImage(out vec4, in vec2)` signature and the playground wraps it into a real fragment shader; write a raw `void main()` and it passes through untouched.
The gallery covers the genres the PRD names: raymarched primitives (sphere with soft checker floor, rotating torus, a six-iteration Mandelbulb), procedural noise (animated Voronoi cells with glowing borders, five-octave FBM fog), and visual FX (synthwave cyberpunk grid, the classic plasma, matrix rain with per-column speeds, and a neon audio visualizer that reads an FFT strip from iChannel0 — feed it from the synth studio in another tab, or let it idle on a gentle wave).
When you're happy with a look, take it anywhere: export as a Three.js ShaderMaterial setup, a React Three Fiber component (fully typed, useFrame-driven), a standalone single-file WebGL2 HTML page that runs anywhere with zero dependencies, or just the raw GLSL. The canvas also records straight to WebM video via MediaRecorder — perfect for landing-page backgrounds you want to preview in motion.
Where WebGL2 is unavailable (old browsers, locked-down GPUs, headless tests), a Canvas2D plasma fallback keeps the page alive and the source still gets validated, so broken shaders surface errors even without a GPU. All rendering is local; nothing is uploaded.
How to use
Pick a preset
Start from the gallery — Raymarching, Procedural Noise, Visual FX or Classic — or paste your own Shadertoy code.
Edit live
Type in the editor; every change recompiles instantly. Errors appear under the canvas with line numbers, highlighted in the editor.
Drive it with input
Drag on the canvas to feed iMouse; time flows automatically through iTime, iTimeDelta and iFrame.
Check performance
Watch the FPS counter as you edit — it's your free performance profiler.
Record or export
Record the canvas as WebM, or export Three.js, R3F, standalone HTML or plain GLSL from the export panel.
Use cases
Prototyping site visuals
Iterate hero backgrounds and section effects with instant feedback, then export the exact code your stack needs — Three.js, R3F or vanilla.
Learning shader programming
The gallery presets progress from plasma to raymarching; live errors and the FPS counter teach both correctness and cost.
Creative coding practice
Daily-shader exercise in a tab: no toolchain, no build step, Shadertoy muscle memory fully transferable.
Producing motion assets
Record the canvas to WebM for mockups, demos and social clips without any screen-recording software.
Common mistakes
Mistake:Declaring uniforms the header already declares
Fix:iResolution/iTime/etc. are injected above your code — redeclaring them is a redefinition error; just use them.
Mistake:Testing performance at the wrong resolution
Fix:The canvas respects devicePixelRatio (capped at 2); a 4K monitor renders 4× the pixels of 1080p, so compare FPS at the same window size.
Mistake:Unbounded raymarch loops
Fix:Always cap step count and total distance (`if (d < eps || t > maxT) break;`) — an unbounded loop compiles but freezes the tab.
Mistake:Expecting identical float results everywhere
Fix:GLSL precision varies by GPU/driver (highp is requested but mobile may differ); guard against NaN with max()/clamp() on critical paths.
Frequently asked questions
Related guides
Your Font Has Axes: A Field Guide to Variable Fonts and OpenType Features
One font file, infinite weights. How the fvar and gvar tables actually work, why a font inspector can show you the axes but not animate between them, and the metric-override trick that kills fallback-font layout shift.
Symmetry, Dithering and the Sprite Sheet: A Pixel Artist's Toolkit
Why PICO-8 has exactly 16 colors, how a Bayer matrix fakes a gradient with none, and what actually happens when you export a walk cycle to Pixi, Phaser or Godot.
Stable Fluids: Why Smoke Simulators Never Blow Up
Semi-Lagrangian advection, pressure projection and vorticity confinement — the three tricks from Jos Stam's 1999 paper that made real-time fluid simulation unconditionally stable, explained by playing with them.
One Pixel at a Time: Thinking in Fragment Shaders
Fragment shaders invert everything procedural programmers know: no objects, no loops over data — just one function evaluated half a million times per frame. The mental models that make GLSL finally click, from plasma to raymarching.
References & standards
Related tools
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML
Apache Config Generator
Build an Apache 2.4 VirtualHost — ServerName, DocumentRoot, Directory, aliases, and optional SSL
AWS Architecture Diagram
Drag-and-drop AWS service blocks, connect edges and export architecture diagrams as SVG