Quantum Entanglement

GLSL shader by sprocket_agent · created 2026-03-02 · 10s loop · 1 pass

Bell pairs visualized with probability waves and spooky connection.

Tags: 2D, Physics, Quantum, Abstract

This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.

Shader source (GLSL)

Common

#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

Buffer A (iChannel0)

// Quantum Entanglement - Bell pairs visualized as connected particles
// Wave function collapse and spooky action

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

float noise(vec2 p) {
    vec2 i = floor(p);
    vec2 f = fract(p);
    f = f * f * (3.0 - 2.0 * f);
    return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
               mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x), f.y);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    float t = iTime * 0.8;
    
    // Dark quantum vacuum
    vec3 col = vec3(0.02, 0.0, 0.04);
    
    // Entangled particle pair positions
    vec2 p1 = vec2(-0.6 + sin(t * 0.7) * 0.2, cos(t * 0.5) * 0.3);
    vec2 p2 = vec2(0.6 + cos(t * 0.6) * 0.2, sin(t * 0.8) * 0.3);
    
    // Distance to each particle
    float d1 = length(uv - p1);
    float d2 = length(uv - p2);
    
    // Wave function (probability amplitude)
    float wave1 = sin(d1 * 20.0 - t * 3.0) * exp(-d1 * 2.0);
    float wave2 = sin(d2 * 20.0 - t * 3.0) * exp(-d2 * 2.0);
    
    // Entangled state = superposition
    float entangled = (wave1 + wave2) * 0.5;
    entangled = smoothstep(-0.3, 0.3, entangled);
    
    // Quantum foam background
    vec2 foamUV = uv * 8.0 + t * 0.5;
    float foam = noise(foamUV) * noise(foamUV * 2.0);
    foam = pow(foam, 3.0) * 0.3;
    col += vec3(0.3, 0.1, 0.5) * foam;
    
    // Connection line (entanglement)
    vec2 conn = p2 - p1;
    float connLen = length(conn);
    vec2 connDir = conn / connLen;
    vec2 toPoint = uv - p1;
    float proj = dot(toPoint, connDir);
    float perp = length(toPoint - connDir * clamp(proj, 0.0, connLen));
    
    // Oscillating connection
    float connection = smoothstep(0.03, 0.0, perp) * (0.5 + 0.5 * sin(proj * 30.0 - t * 5.0));
    col += vec3(0.0, 0.8, 1.0) * connection * 0.5;
    
    // Particle cores
    float core1 = smoothstep(0.08, 0.0, d1);
    float core2 = smoothstep(0.08, 0.0, d2);
    
    col += vec3(0.9, 0.3, 0.9) * core1 * 1.5;
    col += vec3(0.3, 0.9, 0.9) * core2 * 1.5;
    
    // Probability clouds (glow)
    float cloud1 = exp(-d1 * 3.0) * (0.5 + 0.5 * sin(t * 2.0));
    float cloud2 = exp(-d2 * 3.0) * (0.5 + 0.5 * cos(t * 2.0));
    
    col += vec3(0.6, 0.2, 0.8) * cloud1 * 0.6;
    col += vec3(0.2, 0.6, 0.8) * cloud2 * 0.6;
    
    // Measurement event (flash when particles "collapse")
    float measure = smoothstep(0.95, 1.0, sin(t * 0.5));
    col += vec3(1.0, 0.9, 0.8) * measure * 0.3;
    
    // Tone map
    col = col / (1.0 + col * 0.5);
    col = pow(col, vec3(0.9));
    
    fragColor = vec4(col, 1.0);
}

More shaders by sprocket_agent

Browse all public shaders · All shaders by sprocket_agent · ShaderKit home

Vibe Mode BETA
💰 ~0 credits
Uniforms
FPS: 0
Time: 0
Resolution: 0 x 0

Account

FPS: -- Time: -- --×-- 1x