Corrupt file
glint · Examples · Tutorials · Gallery
A clean test card run through slipped bytes, broken blocks, JPEG errors and crushed bits. Every knob is in Parameters, so MIDI and modulators work on the glitches.
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
2 passes, drawn in this order each frame, in GLSL.
Scene: fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
uniform float beat;
uniform vec3 spectrum;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec2 uv = gl_FragCoord.xy / resolution;
// Colour bars over a greyscale ramp, with a moving circle: a test card to break.
vec3 bars[7] = vec3[](vec3(0.75), vec3(0.75, 0.75, 0.0), vec3(0.0, 0.75, 0.75), vec3(0.0, 0.75, 0.0), vec3(0.75, 0.0, 0.75), vec3(0.75, 0.0, 0.0), vec3(0.0, 0.0, 0.75));
vec3 col = uv.y > 0.25 ? bars[int(min(6.0, floor(uv.x * 7.0)))] : vec3(floor(uv.x * 12.0) / 11.0);
vec2 p = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
vec2 c = vec2(0.35 * sin(time * 0.7), 0.12 * cos(time * 1.1) + 0.1);
float d = length(p - c);
col = mix(col, vec3(1.0), smoothstep(0.012, 0.0, abs(d - 0.18)));
col = mix(col, vec3(0.05), step(d, 0.03 + 0.03 * beat));
fragColor = vec4(col, 1.0);
}Glitch: fragment shader (generated from a stack of glitch effects)
#version 300 es
precision highp float;
// Generated by glint's glitch stack (Pass settings: the effects are toggled there, the knobs are parameters).
uniform vec2 resolution;
uniform float time;
uniform int frame;
uniform float beat;
uniform int beatCount;
uniform sampler2D prevPass;
uniform sampler2D feedback;
uniform float glitchBeat;
uniform float glitchSpeed;
uniform float sliceAmount;
uniform float sliceCount;
uniform float blockAmount;
uniform float blockSize;
uniform float jpegCrush;
uniform float jpegErrors;
uniform int bitDepth;
uniform float bitSwap;
out vec4 fragColor;
float seed;
float kick;
// An integer hash of the floats' bits. Not fract(sin(x) * 43758.5): seeds grow with time, and real GPUs' sin (Direct3D
// via ANGLE, phones) loses precision on big arguments, so it returned ~0 everywhere: every JPEG row "corrupt" the
// same way, and the whole picture went green.
float hash(vec2 p) {
uvec2 q = floatBitsToUint(p);
uint n = q.x * 0x27d4eb2du ^ (q.y + 0x9e3779b9u) * 0x165667b1u;
n ^= n >> 15; n *= 0x2c1b3c6du; n ^= n >> 12; n *= 0x297a2d39u; n ^= n >> 15;
return float(n >> 8) / 16777216.0;
}
float luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
vec3 toYcc(vec3 c) { return vec3(luma(c), (c.b - luma(c)) * 0.564 + 0.5, (c.r - luma(c)) * 0.713 + 0.5); }
vec3 fromYcc(vec3 y) { return vec3(y.x + 1.403 * (y.z - 0.5), y.x - 0.344 * (y.y - 0.5) - 0.714 * (y.z - 0.5), y.x + 1.773 * (y.y - 0.5)); }
vec3 src(vec2 uv) { return texture(prevPass, uv).rgb; }
// Where each pixel reads from.
vec2 warp(vec2 uv) {
// Slice shift: some rows move sideways and wrap.
float band = floor(uv.y * sliceCount);
if (hash(vec2(band, seed)) < 0.35 * kick) uv.x = fract(uv.x + (hash(vec2(band, seed + 1.0)) - 0.5) * sliceAmount * kick);
// Broken blocks: some cells read from another cell, some repeat the row above.
vec2 bs = vec2(blockSize) / resolution;
vec2 cell = floor(uv / bs);
float hb = hash(cell + seed * 0.37);
if (hb < blockAmount * 0.25 * kick) uv = (floor(vec2(hash(cell + 1.3), hash(cell + 2.7)) / bs) + fract(uv / bs)) * bs;
else if (hb > 1.0 - blockAmount * 0.12 * kick) uv.y = (cell.y + 0.999) * bs.y;
return uv;
}
// The input through the warp.
vec3 base(vec2 uv) {
vec2 w = warp(uv);
return src(w);
}
// Before the per-pixel effects: the base.
vec3 pre(vec2 q) {
vec3 c = base(q);
return c;
}
void main() {
vec2 uv = gl_FragCoord.xy / resolution;
kick = 1.0 + glitchBeat * beat * 2.0;
seed = floor(time * glitchSpeed) + float(beatCount) * 17.0;
vec3 col = pre(uv);
// JPEG crush: 8x8 luma blocks, 16x16 chroma, and corrupt rows (errors run on to the end of the line).
vec2 px = gl_FragCoord.xy;
vec2 b8 = floor(px / 8.0) * 8.0;
float ya = 0.25 * (luma(pre((b8 + vec2(2.0)) / resolution)) + luma(pre((b8 + vec2(6.0, 2.0)) / resolution)) + luma(pre((b8 + vec2(2.0, 6.0)) / resolution)) + luma(pre((b8 + vec2(6.0)) / resolution)));
vec3 cc = pre((floor(px / 16.0) * 16.0 + 8.0) / resolution);
vec3 ycc = toYcc(col);
float levels = mix(64.0, 4.0, jpegCrush);
ycc.x = floor(mix(ycc.x, ya, jpegCrush * 0.8) * levels + 0.5) / levels;
ycc.yz = mix(ycc.yz, toYcc(cc).yz, jpegCrush);
float row = floor(px.y / 8.0);
float hr = hash(vec2(row, seed * 1.7));
if (hr < jpegErrors * 0.25 * kick && px.x / resolution.x > hash(vec2(row, seed + 3.0))) {
ycc.yz += (vec2(hash(vec2(row, 5.0 + seed)), hash(vec2(row, 9.0 + seed))) - 0.5) * 0.8;
ycc.x += (hash(vec2(row, 11.0 + seed)) - 0.5) * 0.4;
}
col = clamp(fromYcc(ycc), 0.0, 1.0);
// Bit crush, and bands whose bytes are read wrong (channels rotated, or inverted as if XORed).
float steps = exp2(float(bitDepth)) - 1.0;
col = floor(col * steps + 0.5) / steps;
float bandB = floor(gl_FragCoord.y / 6.0);
float hbit = hash(vec2(bandB, seed * 2.3));
if (hbit < bitSwap * 0.3 * kick) col = col.gbr;
else if (hbit > 1.0 - bitSwap * 0.1 * kick) col = 1.0 - col;
fragColor = vec4(col, 1.0);
}More Nodes & glitch examples
Nodes: Crystal · Nodes: Spectrum bars · Nodes: Lava · Mosh pit