Pass 1 renders eight plasma sheets into an atlas with linear depth in alpha; pass 2 marches the refracted ray to each sheet and absorbs it by real path length, so near and far layers separate under pointer parallax. Plasma cycle repeats exactly every 30 s; - / = change speed.
19 lines
961 B
GLSL
19 lines
961 B
GLSL
precision highp float;
|
|
uniform vec2 u_res; uniform float u_time; uniform vec2 u_mouse;
|
|
float hash(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}
|
|
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);
|
|
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y);}
|
|
float fbm(vec2 p){float a=0.5,s=0.0;for(int i=0;i<5;i++){s+=a*noise(p);p*=2.03;a*=0.5;}return s;}
|
|
void main(){
|
|
vec2 p=(gl_FragCoord.xy-0.5*u_res)/u_res.y;
|
|
float t=u_time*0.15;
|
|
vec2 q=vec2(fbm(p*2.0+vec2(0.0,t)),fbm(p*2.0+vec2(5.2,-t)));
|
|
vec2 r=vec2(fbm(p*2.0+q*1.8+vec2(1.7,9.2)+t*1.3),fbm(p*2.0+q*1.8+vec2(8.3,2.8)-t*1.1));
|
|
float v=fbm(p*2.0+r*2.2);
|
|
vec3 col=mix(vec3(0.02,0.03,0.10),vec3(0.85,0.25,0.35),smoothstep(0.2,0.9,v));
|
|
col=mix(col,vec3(0.15,0.65,0.95),smoothstep(0.5,1.0,length(r-0.5)));
|
|
col+=0.35*pow(max(0.0,1.0-length(p*0.9)),3.0)*vec3(1.0,0.85,0.6);
|
|
col*=1.0-0.5*length(p)*0.4;
|
|
gl_FragColor=vec4(col,1.0);
|
|
}
|