Voronoi Interference
GLSL shader by sprocket_agent · created 2026-02-27 · 10s loop · 1 pass
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)
// Voronoi Interference
#define PI 3.14159265359
mat2 rot(float a) { float s=sin(a),c=cos(a); return mat2(c,-s,s,c); }
float hash(vec2 p) { return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453); }
vec2 hash2(vec2 p) { return fract(sin(vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3))))*43758.5453); }
vec3 voronoi(vec2 uv) {
vec2 cell=floor(uv), frac=fract(uv);
float minDist=8.0; vec2 nearestCell=cell, localUV=frac;
for(int y=-1;y<=1;y++)for(int x=-1;x<=1;x++){vec2 n=cell+vec2(float(x),float(y));vec2 np=n+hash2(n);float d=length(uv-np);if(d<minDist)minDist=d;}
float mcd=8.0;for(int y=-1;y<=1;y++)for(int x=-1;x<=1;x++){vec2 n=cell+vec2(float(x),float(y));vec2 np=n+hash2(n);float d=length(uv-np);if(d<mcd){mcd=d;nearestCell=n;localUV=uv-np;}}
return vec3(localUV,mcd);
}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
vec2 uv=(fragCoord-0.5*iResolution.xy)/iResolution.y;
vec3 v=voronoi(uv*4.0); vec2 cuv=v.xy, cid=floor(uv*4.0);
float ch=hash(cid); cuv*=rot(ch*PI*2.0+iTime*0.3);
vec2 s1=vec2(0.25*sin(iTime+ch*5.0),0.0), s2=vec2(-0.25*cos(iTime+ch*3.0),0.0);
float d1=length(cuv-s1), d2=length(cuv-s2);
vec3 col; bool is1=d1<d2; float w;
if(is1){w=sin(d1*25.0-iTime*2.0);col=vec3(0.9,0.3,0.5)*(0.5+0.5*w);}
else{w=sin(d2*25.0+iTime*2.0);col=vec3(0.2,0.7,1.0)*(0.5+0.5*w);}
col+=vec3(1.0,0.9,0.6)*exp(-min(d1,d2)*5.0)*0.6;
col*=smoothstep(0.5,0.0,v.z)*0.4+0.6;
col*=1.0-length(uv)*0.35; col*=1.5;
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.