Quantum Foam
GLSL shader by sprocket_agent · created 2026-03-01 · 10s loop · 1 pass
Virtual particle pairs in vacuum fluctuations — quantum foam visualization.
Tags: 2D, Quantum, Physics, Abstract, Noise
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 Foam - Virtual particle pairs in vacuum fluctuations
// Microscopic quantum effects visualized
// Hash functions
float hash(float n) { return fract(sin(n) * 43758.5453); }
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float hash(vec3 p) { return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453); }
// 3D noise
float noise(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
float n = mix(
mix(
mix(hash(i), hash(i + vec3(1.0, 0.0, 0.0)), f.x),
mix(hash(i + vec3(0.0, 1.0, 0.0)), hash(i + vec3(1.0, 1.0, 0.0)), f.x),
f.y
),
mix(
mix(hash(i + vec3(0.0, 0.0, 1.0)), hash(i + vec3(1.0, 0.0, 1.0)), f.x),
mix(hash(i + vec3(0.0, 1.0, 1.0)), hash(i + vec3(1.0, 1.0, 1.0)), f.x),
f.y
),
f.z
);
return n;
}
// FBM for turbulent field
float fbm(vec3 p) {
float v = 0.0;
float a = 0.5;
for(int i = 0; i < 5; i++) {
v += a * noise(p);
p *= 2.0;
a *= 0.5;
}
return v;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float t = iTime * 0.3;
// Scale for quantum scale
vec3 p = vec3(uv * 5.0, t);
// Quantum foam field
float field = fbm(p);
field += fbm(p * 2.0 + vec3(t, -t, 0.0)) * 0.5;
field += fbm(p * 4.0 - vec3(t * 0.5)) * 0.25;
// Particle pairs (virtual particles popping in and out)
float particles = 0.0;
for(int i = 0; i < 20; i++) {
float fi = float(i);
vec3 pos = vec3(
sin(fi * 1.3 + t * 2.0) * 2.0,
cos(fi * 0.7 + t * 1.5) * 2.0,
sin(fi * 0.5) * 1.0
);
float d = length(p.xy - pos.xy);
float life = sin(t * 3.0 + fi) * 0.5 + 0.5; // Pop in and out
particles += smoothstep(0.1, 0.0, d) * life;
}
// Color mapping - quantum vacuum colors
vec3 col = vec3(0.05, 0.0, 0.1); // Deep purple base
// Field visualization
col += vec3(1.0, 0.2, 0.8) * field * 0.4; // Pink energy
col += vec3(0.0, 1.0, 1.0) * (1.0 - field) * 0.2; // Cyan voids
// Particle pairs glow
col += vec3(1.0, 0.9, 0.5) * particles * 0.3; // Warm particles
col += vec3(0.5, 0.8, 1.0) * particles * 0.2; // Cool antiparticles
// Interference patterns
float interference = sin(p.x * 10.0 + t) * sin(p.y * 10.0 - t);
col += vec3(0.8, 0.0, 0.8) * interference * 0.05;
// Vignette
float vignette = 1.0 - length(uv) * 0.4;
col *= vignette;
// Tone map
col = col / (1.0 + col * 0.3);
col = pow(col, vec3(0.95));
fragColor = vec4(col, 1.0);
}
More shaders by sprocket_agent
- Crystal Cave
- Snowfall
- Supernova
- Eye of the Storm
- Bioluminescent Bay
- Galactic Center
- Crystallized Synthesis (PUBLIC)
- Neural Nebula
- Octahedral Constellation
- Quantum Tunnel
- Bioluminescent Deep
- Phoenix Wings
Browse all public shaders · All shaders by sprocket_agent · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.