1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #ifdef GL_ES precision mediump float; #endif
uniform float u_time; uniform vec2 u_resolution;
float rand( vec2 c ) { return fract( sin( dot( c.xy, vec2( 12.9898, 78.233 ) ) ) * 43758.5453 ); }
vec2 rand2(vec2 st){ st = vec2( dot(st,vec2(127.1,311.7)), dot(st,vec2(269.5,183.3)) ); return -1.0 + 2.0*fract(sin(st)*43758.5453123); }
float noise (in vec2 st) { vec2 i = floor(st); vec2 f = fract(st); vec2 u = f*f*(3.0-2.0*f); return mix( mix( dot( rand2(i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ), dot( rand2(i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x), mix( dot( rand2(i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ), dot( rand2(i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y); }
float circle(vec2 pos, float radius, float glow){ float sdf = length(pos); sdf = smoothstep(radius-0.700,radius,sdf); float circles = 1.0 - smoothstep(0.0,1.0,sdf*10.280); float glows = exp(-sdf*4.496) * glow * (1.0 - circles); return circles+glows; }
void main() { vec2 st = (gl_FragCoord.xy - 0.5 * u_resolution.xy ) / u_resolution.y; st *= 20.0; vec2 uv = st; float noisest = noise(vec2(uv.x - u_time, uv.y - u_time)); uv += noisest*0.13; uv += vec2(noise(vec2(u_time) * 0.2) * 6.0, -u_time * 2.0); vec3 color = vec3(0.); vec2 pos = fract(uv)-0.5; vec2 id = floor(uv); for(int y = -1; y <= 1; y++){ for(int x = -1; x <= 1; x++){ vec2 neighbour = vec2(x,y); vec2 rand2 = rand2(id+neighbour); float a = noise(rand2 + u_time * 2.8); vec2 offset = 0.5*(sin(u_time + rand2*6.28))*2.2; float size = rand(id+neighbour)*0.75 + a*0.15; color += circle(pos-neighbour+offset,size,size*1.400)/9.0 * vec3(rand2.x*7.884,7.2,rand2.y*6.832); } } float xRange = 1.0 - abs(2.0 * st.x)*0.02; vec3 ambient = smoothstep(1.0,0.0,st.y*0.05+0.9) * vec3(0.401,0.570,0.443); color = max(ambient, color) * xRange; gl_FragColor = vec4(color,1.0); }
|