Fragment Shader (GLSL)
Fragment-shader (pixel-program) art emerged with programmable GPU shading pipelines in the early 2000s (GLSL, 2004) and was popularized by the online sharing platform Shadertoy (2013). A practice window rather than a single work.
community / folk Name — A descriptive category label, not a coined or eponymous name; no single coiner of the term is attested.
In one line Per-pixel computation on the GPU: a fragment shader (GLSL) runs in parallel for every pixel to compute its colour from coordinates and uniforms — the base layer for procedural textures, raymarching and real-time generative visuals.
The code
The actual sketch behind the demo above — sandboxed and reproducible. This is the whole thing.
shader-fragment/index.html
// Pure fragment-shader art: animated fbm + polar warping in GLSL, all pixels
// computed on the GPU. Seeded per-load.
const SEED = Math.random();
const c = document.getElementById('c');
const dpr = Math.min(devicePixelRatio || 1, 2);
const size = Math.min(innerWidth, innerHeight);
c.width = Math.floor(size*dpr); c.height = Math.floor(size*dpr);
const gl = c.getContext('webgl');
const vs = `attribute vec2 a; void main(){ gl_Position=vec4(a,0.,1.); }`;
const fs = `precision highp float;
uniform vec2 u_res; uniform float u_t; uniform float u_seed;
float hash(vec2 p){ return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453); }
float noise(vec2 p){ vec2 i=floor(p),f=fract(p); f=f*f*(3.-2.*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y); }
float fbm(vec2 p){ float v=0.,a=.5; for(int i=0;i<6;i++){ v+=a*noise(p); p*=2.03; a*=.5; } return v; }
void main(){
vec2 uv=(gl_FragCoord.xy-.5*u_res)/u_res.y;
float r=length(uv), ang=atan(uv.y,uv.x);
vec2 p=vec2(ang*1.6+u_seed*6.28, r*3.-u_t*.15);
float n=fbm(p+fbm(p+u_t*.05)*1.5);
vec3 col=.5+.5*cos(6.2831*(vec3(.0,.33,.66)+n*1.2+u_seed));
col*=smoothstep(1.1,.2,r);
gl_FragColor=vec4(pow(col,vec3(.4545)),1.);
}`;
function sh(t,s){ const o=gl.createShader(t); gl.shaderSource(o,s); gl.compileShader(o);
if(!gl.getShaderParameter(o,gl.COMPILE_STATUS)) console.error(gl.getShaderInfoLog(o)); return o; }
const prog=gl.createProgram();
gl.attachShader(prog,sh(gl.VERTEX_SHADER,vs)); gl.attachShader(prog,sh(gl.FRAGMENT_SHADER,fs));
gl.linkProgram(prog); gl.useProgram(prog);
const buf=gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER,buf);
gl.bufferData(gl.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),gl.STATIC_DRAW);
const loc=gl.getAttribLocation(prog,'a'); gl.enableVertexAttribArray(loc); gl.vertexAttribPointer(loc,2,gl.FLOAT,false,0,0);
const uRes=gl.getUniformLocation(prog,'u_res'), uT=gl.getUniformLocation(prog,'u_t'), uSeed=gl.getUniformLocation(prog,'u_seed');
gl.viewport(0,0,c.width,c.height);
const t0=performance.now();
(function frame(){
gl.uniform2f(uRes,c.width,c.height);
gl.uniform1f(uT,(performance.now()-t0)/1000);
gl.uniform1f(uSeed,SEED);
gl.drawArrays(gl.TRIANGLES,0,6);
requestAnimationFrame(frame);
})();How it works
Draw a single full-screen quad; the GPU then invokes the fragment shader once per covered pixel, all in parallel: 1. Each invocation knows its screen coordinate (gl_FragCoord) and shared "uniform" inputs (time, resolution, mouse, textures). 2. It computes a colour purely from those — e.g. normalise coords to uv, feed them through noise, SDFs, trig and feedback, and return vec4 rgba. 3. There is no memory of other pixels within a pass, which is exactly why it scales to millions of pixels in real time. Multi-pass effects (blur, feedback, simulation) render the shader's output to a texture and read it back next frame. This is the engine behind Shadertoy-style procedural art and GPU raymarching.
Parameters
uniforms: array — Inputs passed to the shader (time, resolution, hash, mouse).precision: string — Float precision qualifier (lowp / mediump / highp).passes: number — Number of render passes (e.g. for blur or feedback chains).
Lineage
Frequently combined with
- Perlin / Simplex Noise · 56 works
- 3D Mesh / Geometry · 25 works
- Raymarching with SDFs · 20 works
- HSL / Hue Cycle · 17 works
- Flow Field / Vector Field · 16 works
- Bezier / Catmull-Rom Splines · 15 works
- Instanced Geometry · 13 works
- Glitch / Datamosh · 10 works
- Audio-Reactive · 8 works
- Plotter-style Hatching · 6 works
- Marching Squares / Contours · 5 works
- Voronoi Diagram · 5 works
Works using this algorithm (162)
Last updated 2026-07-16