Skip to main content

GLITCH

Constant GLITCH 

Source
pub const GLITCH: &str = "// Rows of the picture jump sideways with their color channels split, strongest mid-way;\n// each row switches from the outgoing picture to the incoming one at its own moment.\n\nfn transition(uv: vec2f) -> vec4f {\n    let seed = u32(clamp(round(params.seed), 0.0, 16777215.0));\n    let strength = sin(3.14159265 * progress()) * params.amount;\n    let row = builtin_cell(uv.y / params.block_size);\n    // New offsets 24 times over the transition.\n    let stage = u32(floor(progress() * 24.0));\n    let h = builtin_hash3(row, stage, seed);\n    let jumping = select(0.0, 1.0, builtin_unit(builtin_hash(h)) < strength);\n    let shift = vec2f((builtin_unit(h) - 0.5) * 0.25 * strength * jumping, 0.0);\n    let split = vec2f(0.015 * strength * jumping, 0.0);\n    let switched = builtin_unit(builtin_hash3(row, 4096u, seed)) < progress();\n    let p = uv + shift;\n    let base = select(from_color(p), to_color(p), switched);\n    let red = select(from_color(p + split), to_color(p + split), switched);\n    let blue = select(from_color(p - split), to_color(p - split), switched);\n    return vec4f(red.r, base.g, blue.b, max(base.a, max(red.a, blue.a)));\n}\n";
Expand description

Row jumps and channel splits transition body.