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.

Fragment Shader (GLSL) · Open in new tab ↗ · Motion begins only when you press Run.

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);
})();

Open the demo source ↗

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

Lineage

Related
Raymarching with SDFs, Domain Warping, Audio-Reactive

Frequently combined with

Works using this algorithm (162)

24 Heures
alexis-andre
3:19
santiago
444(4)
shvembldr
720 Minutes
alexis-andre
923 EMPTY ROOMS
casey-reas
A Snap in Time
qubibi
Act of Emotion
kelly-milligan
Anticyclone
william-mapan
APEX
phenomena
Arcadia
zachariah-watson
Assemblage
sab-k2xl
Assorted Positivity
steganon
Aurora IV
ge1doot
Autoscope
erik-swahn
Bakhoor Assandal
melissa-wiederrecht
Balance
kelly-milligan-x-amber-vittoria
Beatboxes
zeblocks
Beauty of Skateboarding
jeanvascript
Blaschke Ballet
numbersinmotion
Blind Spots
shaderism
Bloom
blockchance
Bokeh (lamps)
mpkoz
Bokeh
mpkoz
Box Light Studies (sculpture)
zach-lieberman
Box Light Studies
zach-lieberman
Bubble Blobby
jason-ting
Calian
eric-de-giuli
Cargo
kim-asendorf
Cattleya
ben-snell
Cerebellum
laya-mathikshara-santiago
Chimera
mpkoz
Chroma Theory
pawe-dudko
Click
ivan-dianov
Collapsed Sequence
toiminto
Contractions
loie-hollowell
Contrast Agent
tim-richardson-sean-zellmer
Cosmodesias
santiago
Cytographia
golan-levin
Departed
alexis-andre
Divergence
loren-bednar
Drift
paolo-ceric
Drifting
simon-de-mai
Ego Death
electralina
EnergySculpture
beervangeer
entretiempos
marcelo-soria-rodriguez
Erratic
owen-moore
Escherly Seeds
martijn-cohen
Exstasis
grant-oesterling
Facets
conundrumer
Fell-Cloud
travess-smalley
Floating World Genesis
a-a-murakami
Flourish
sterling-crispin
Flows
ryley-o-eth
Flux
owen-moore
Friendship Bracelets
alexis-andre
Fushi No Reality - フシノゲンジツ
samsy
Gas Wars
jack-butcher
Gels
jason-brown-shawn-douglas
GHOST IN THE CODE
kazuhiro-tanimoto
Glow
jason-ting

Last updated 2026-07-16