runnable fragment

8bit

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform int   u_palette;   // 0=CGA1, 1=CGA2, 2=EGA, 3=GameBoy
uniform float u_pixelate;  // block size (1-16)

vec3 pal(float l, int p) {
  if (p == 0) {
    if (l < 0.33) return vec3(0, 0, 0);
    if (l < 0.66) return vec3(0, 1, 1);
    return vec3(1, 0, 1);
  }
  if (p == 1) {
runnable fragment

Channel Invert

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform int u_channel; // 0=all, 1=red only, 2=green only, 3=blue only

void main() {
  vec4 c = texture2D(u_texture, v_texCoord);

  if (u_channel == 0) {
    c.rgb = 1.0 - c.rgb;
  } else if (u_channel == 1) {
    c.r = 1.0 - c.r;
  } else if (u_channel == 2) {
runnable fragment

Crt

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_gap;         // pixel gap (1-8)
uniform float u_curve;       // curvature (0-0.3)
uniform float u_vignette;    // vignette intensity (0-1)
uniform float u_dispersion;  // chromatic dispersion (0-0.2)

void main() {
  vec2 uv = v_texCoord;
  vec2 d = uv - 0.5;
  float r = length(d);
  float safeCurve = min(u_curve, 0.25);
runnable fragment

Data Glitch

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_intensity; // 0-1
uniform float u_block;     // 4-64
uniform int   u_seed;      // 1-999

float hash(vec2 p) {
  return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453 + float(u_seed) * 123.456);
}

void main() {
  vec2 uv = v_texCoord;
runnable fragment

Edge Detect

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_intensity; // 0-3
uniform int   u_mode;      // 0=sobel line art, 1=overlay, 2=edges only

float lum(vec3 c) {
  return dot(c, vec3(0.299, 0.587, 0.114));
}

void main() {
  vec2 ps = 1.0 / u_resolution;
runnable fragment

Grain

glitch-core material glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_intensity; // 0-1
uniform float u_size;      // grain size (0.5-10)
uniform int   u_color;     // 0=color, 1=grayscale

float hash(vec2 p) {
  return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
}

void main() {
  vec4 c = texture2D(u_texture, v_texCoord);
runnable fragment

Halftone

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_size;      // dot size (2-30)
uniform float u_angle;     // degrees (0-90)
uniform int   u_type;      // 0=dots, 1=lines

float lum(vec3 c) {
  return dot(c, vec3(0.299, 0.587, 0.114));
}

void main() {
  vec2 uv = v_texCoord * u_resolution;
runnable fragment

Kaleidoscope

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_sides;     // number of sides (2-16)
uniform float u_angle;     // rotation angle (0-6.28)
uniform vec2 u_center;     // center point (0-1)

void main() {
  vec2 uv = v_texCoord - u_center;
  float a = atan(uv.y, uv.x) + u_angle;
  float r = length(uv);
  float seg = 3.14159 * 2.0 / u_sides;
  a = mod(a, seg);
runnable fragment

Pixelate

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_block; // pixel block size (2-64)

void main() {
  vec2 uv = v_texCoord;
  uv = floor(uv * u_resolution / u_block) * u_block / u_resolution + u_block / u_resolution * 0.5;
  gl_FragColor = texture2D(u_texture, uv);
}
runnable fragment

Pixel Sort

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_intensity;   // 0.0-1.0
uniform float u_threshold;   // 0.0-1.0 brightness threshold
uniform float u_direction;   // 0=horizontal, 1=vertical

float luminance(vec3 c) {
  return dot(c, vec3(0.299, 0.587, 0.114));
}

void main() {
  vec2 uv = v_texCoord;
runnable fragment

Rgb Shift

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform vec2 u_rOffset;  // red channel offset (px)
uniform vec2 u_bOffset;  // blue channel offset (px)

void main() {
  vec2 pixelSize = 1.0 / u_resolution;

  float r = texture2D(u_texture, v_texCoord + u_rOffset * pixelSize).r;
  float g = texture2D(u_texture, v_texCoord).g;
  float b = texture2D(u_texture, v_texCoord + u_bOffset * pixelSize).b;
  float a = texture2D(u_texture, v_texCoord).a;
runnable fragment

Scanlines

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_density;    // scanline spacing (px)
uniform float u_opacity;    // 0.0-1.0
uniform vec3 u_color;       // scanline color

void main() {
  vec4 texColor = texture2D(u_texture, v_texCoord);
  float lineY = v_texCoord.y * u_resolution.y;

  float line = step(0.5, mod(lineY, u_density) / u_density);
  vec3 blended = mix(texColor.rgb, u_color * texColor.rgb, line * u_opacity);
runnable fragment

Stretch

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_intensity; // 0-1
uniform int   u_direction; // 0=horizontal, 1=vertical

void main() {
  vec2 uv = v_texCoord;

  if (u_direction == 0) {
    float band = floor(uv.y * u_resolution.y / 8.0);
    float off = (fract(sin(band * 127.1) * 43758.54) - 0.5) * u_intensity * 0.05;
    uv.x += off;
runnable fragment

Vhs

glitch-core generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_track;     // tracking noise (0-1)
uniform float u_noise;     // noise level (0-0.5)
uniform float u_bleed;     // color bleed (0-1)

float hash(vec2 p) {
  return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
}

void main() {
  vec2 uv = v_texCoord;
runnable fragment

Wave

glitch-core pattern glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec2 u_resolution;
uniform float u_amplitude; // px
uniform float u_frequency; // waves across image
uniform int   u_direction; // 0=horizontal, 1=vertical, 2=radial

void main() {
  vec2 uv = v_texCoord;
  float amp = u_amplitude / u_resolution.x;
  float freq = u_frequency * 6.28318;
  float offset = 0.0;