@paper-design/shaders 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -8
- package/dist/get-shader-color-from-string.d.ts +3 -0
- package/dist/get-shader-color-from-string.test.d.ts +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +981 -117
- package/dist/index.js.map +4 -4
- package/dist/shader-mount.d.ts +11 -9
- package/dist/shaders/dots-grid.d.ts +37 -0
- package/dist/shaders/dots-orbit.d.ts +26 -0
- package/dist/shaders/grain-clouds.d.ts +8 -10
- package/dist/shaders/mesh-gradient.d.ts +5 -7
- package/dist/shaders/metaballs.d.ts +22 -0
- package/dist/shaders/neuro-noise.d.ts +8 -10
- package/dist/shaders/perlin-noise.d.ts +28 -0
- package/dist/shaders/smoke-ring.d.ts +22 -0
- package/dist/shaders/stepped-simplex-noise.d.ts +24 -0
- package/dist/shaders/voronoi.d.ts +36 -0
- package/dist/shaders/waves.d.ts +34 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,138 +1,154 @@
|
|
|
1
1
|
/***** Paper Shaders: https://github.com/paper-design/shaders *****/
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
void main() {
|
|
5
|
-
gl_Position = a_position;
|
|
6
|
-
}
|
|
7
|
-
`;function b(e,r,t){let i=e.createShader(r);return i?(e.shaderSource(i,t),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(i)),e.deleteShader(i),null)):null}function x(e,r,t){let i=b(e,e.VERTEX_SHADER,r),o=b(e,e.FRAGMENT_SHADER,t);if(!i||!o)return null;let n=e.createProgram();return n?(e.attachShader(n,i),e.attachShader(n,o),e.linkProgram(n),e.getProgramParameter(n,e.LINK_STATUS)?(e.detachShader(n,i),e.detachShader(n,o),e.deleteShader(i),e.deleteShader(o),n):(console.error("Unable to initialize the shader program: "+e.getProgramInfoLog(n)),e.deleteProgram(n),e.deleteShader(i),e.deleteShader(o),null)):null}function g(e,r=[0,0,0]){if(Array.isArray(e)&&e.length===3)return e;if(typeof e!="string")return g(r);let t,i,o;if(e.startsWith("#"))[t,i,o]=y(e);else if(e.startsWith("rgb"))[t,i,o]=A(e);else if(e.startsWith("hsl"))[t,i,o]=R(S(e));else return console.error("Unsupported color format",e),g(r);return[t,i,o]}function y(e){e.length===4&&(e=`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`);let r=parseInt(e.slice(1),16),t=(r>>16&255)/255,i=(r>>8&255)/255,o=(r&255)/255;return[t,i,o]}function A(e){let r=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);return r?[parseInt(r[1]??"0")/255,parseInt(r[2]??"0")/255,parseInt(r[3]??"0")/255]:[0,0,0]}function S(e){let r=e.match(/^hsl\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)$/i);return r?[parseInt(r[1]??"0"),parseInt(r[2]??"0"),parseInt(r[3]??"0")]:[0,0,0]}function R(e){let[r,t,i]=e,o=r/360,n=t/100,s=i/100,c,l,h;if(t===0)c=l=h=s;else{let f=(u,p,a)=>(a<0&&(a+=1),a>1&&(a-=1),a<.16666666666666666?u+(p-u)*6*a:a<.5?p:a<.6666666666666666?u+(p-u)*(.6666666666666666-a)*6:u),m=s<.5?s*(1+n):s+n-s*n,d=2*s-m;c=f(d,m,o+1/3),l=f(d,m,o),h=f(d,m,o-1/3)}return[c,l,h]}var F=`
|
|
8
|
-
precision highp float;
|
|
9
|
-
uniform vec2 u_resolution;
|
|
10
|
-
uniform float u_time;
|
|
11
|
-
uniform vec3 u_color1;
|
|
12
|
-
uniform vec3 u_color2;
|
|
13
|
-
uniform float u_noiseScale;
|
|
14
|
-
uniform float u_noiseSpeed;
|
|
15
|
-
uniform float u_grainAmount;
|
|
16
|
-
|
|
17
|
-
// Simplex 2D noise
|
|
18
|
-
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
|
|
2
|
+
var g=class{canvas;gl;program=null;uniformLocations={};fragmentShader;rafId=null;lastFrameTime=0;totalAnimationTime=0;speed=1;providedUniforms;hasBeenDisposed=!1;resolutionChanged=!0;constructor(o,r,t={},a,i=1,s=0){this.canvas=o,this.fragmentShader=r,this.providedUniforms=t,this.totalAnimationTime=s;let n=o.getContext("webgl2",a);if(!n)throw new Error("WebGL not supported");this.gl=n,this.initWebGL(),this.setupResizeObserver(),this.setSpeed(i),this.canvas.setAttribute("data-paper-shaders","true")}initWebGL=()=>{let o=S(this.gl,y,this.fragmentShader);o&&(this.program=o,this.setupPositionAttribute(),this.setupUniforms())};setupPositionAttribute=()=>{let o=this.gl.getAttribLocation(this.program,"a_position"),r=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r);let t=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(t),this.gl.STATIC_DRAW),this.gl.enableVertexAttribArray(o),this.gl.vertexAttribPointer(o,2,this.gl.FLOAT,!1,0,0)};setupUniforms=()=>{this.uniformLocations={u_time:this.gl.getUniformLocation(this.program,"u_time"),u_pixelRatio:this.gl.getUniformLocation(this.program,"u_pixelRatio"),u_resolution:this.gl.getUniformLocation(this.program,"u_resolution"),...Object.fromEntries(Object.keys(this.providedUniforms).map(o=>[o,this.gl.getUniformLocation(this.program,o)]))}};resizeObserver=null;setupResizeObserver=()=>{this.resizeObserver=new ResizeObserver(()=>this.handleResize()),this.resizeObserver.observe(this.canvas),this.handleResize()};handleResize=()=>{let o=window.devicePixelRatio,r=this.canvas.clientWidth*o,t=this.canvas.clientHeight*o;(this.canvas.width!==r||this.canvas.height!==t)&&(this.canvas.width=r,this.canvas.height=t,this.resolutionChanged=!0,this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height),this.render(performance.now()))};render=o=>{if(this.hasBeenDisposed)return;let r=o-this.lastFrameTime;this.lastFrameTime=o,this.speed!==0&&(this.totalAnimationTime+=r*this.speed),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.useProgram(this.program),this.gl.uniform1f(this.uniformLocations.u_time,this.totalAnimationTime*.001),this.resolutionChanged&&(this.gl.uniform2f(this.uniformLocations.u_resolution,this.gl.canvas.width,this.gl.canvas.height),this.gl.uniform1f(this.uniformLocations.u_pixelRatio,window.devicePixelRatio),this.resolutionChanged=!1),this.gl.drawArrays(this.gl.TRIANGLES,0,6),this.speed!==0?this.requestRender():this.rafId=null};requestRender=()=>{this.rafId!==null&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render)};updateProvidedUniforms=()=>{this.gl.useProgram(this.program),Object.entries(this.providedUniforms).forEach(([o,r])=>{let t=this.uniformLocations[o];if(t)if(Array.isArray(r))switch(r.length){case 2:this.gl.uniform2fv(t,r);break;case 3:this.gl.uniform3fv(t,r);break;case 4:this.gl.uniform4fv(t,r);break;default:r.length===9?this.gl.uniformMatrix3fv(t,!1,r):r.length===16?this.gl.uniformMatrix4fv(t,!1,r):console.warn(`Unsupported uniform array length: ${r.length}`)}else typeof r=="number"?this.gl.uniform1f(t,r):typeof r=="boolean"?this.gl.uniform1i(t,r?1:0):console.warn(`Unsupported uniform type for ${o}: ${typeof r}`)})};setSeed=o=>{let r=8.333333333333334;this.totalAnimationTime=o*r,this.lastFrameTime=performance.now(),this.render(performance.now())};setSpeed=(o=1)=>{this.speed=o,this.rafId===null&&o!==0&&(this.lastFrameTime=performance.now(),this.rafId=requestAnimationFrame(this.render)),this.rafId!==null&&o===0&&(cancelAnimationFrame(this.rafId),this.rafId=null)};setUniforms=o=>{this.providedUniforms={...this.providedUniforms,...o},this.updateProvidedUniforms(),this.render(performance.now())};dispose=()=>{this.hasBeenDisposed=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.gl&&this.program&&(this.gl.deleteProgram(this.program),this.program=null,this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.getError()),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.uniformLocations={}}},y=`#version 300 es
|
|
3
|
+
layout(location = 0) in vec4 a_position;
|
|
19
4
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
vec2 i1;
|
|
26
|
-
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
|
27
|
-
vec4 x12 = x0.xyxy + C.xxzz;
|
|
28
|
-
x12.xy -= i1;
|
|
29
|
-
i = mod(i, 289.0);
|
|
30
|
-
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0))
|
|
31
|
-
+ i.x + vec3(0.0, i1.x, 1.0));
|
|
32
|
-
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
|
|
33
|
-
dot(x12.zw,x12.zw)), 0.0);
|
|
34
|
-
m = m*m ;
|
|
35
|
-
m = m*m ;
|
|
36
|
-
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
|
37
|
-
vec3 h = abs(x) - 0.5;
|
|
38
|
-
vec3 ox = floor(x + 0.5);
|
|
39
|
-
vec3 a0 = x - ox;
|
|
40
|
-
m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h);
|
|
41
|
-
vec3 g;
|
|
42
|
-
g.x = a0.x * x0.x + h.x * x0.y;
|
|
43
|
-
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
44
|
-
return 130.0 * dot(m, g);
|
|
45
|
-
}
|
|
5
|
+
void main() {
|
|
6
|
+
gl_Position = a_position;
|
|
7
|
+
}
|
|
8
|
+
`;function x(e,o,r){let t=e.createShader(o);return t?(e.shaderSource(t,r),e.compileShader(t),e.getShaderParameter(t,e.COMPILE_STATUS)?t:(console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(t)),e.deleteShader(t),null)):null}function S(e,o,r){let t=x(e,e.VERTEX_SHADER,o),a=x(e,e.FRAGMENT_SHADER,r);if(!t||!a)return null;let i=e.createProgram();return i?(e.attachShader(i,t),e.attachShader(i,a),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)?(e.detachShader(i,t),e.detachShader(i,a),e.deleteShader(t),e.deleteShader(a),i):(console.error("Unable to initialize the shader program: "+e.getProgramInfoLog(i)),e.deleteProgram(i),e.deleteShader(t),e.deleteShader(a),null)):null}var z=`#version 300 es
|
|
9
|
+
precision highp float;
|
|
46
10
|
|
|
47
|
-
|
|
48
|
-
|
|
11
|
+
uniform vec2 u_resolution;
|
|
12
|
+
uniform float u_pixelRatio;
|
|
13
|
+
uniform float u_time;
|
|
49
14
|
|
|
50
|
-
|
|
51
|
-
|
|
15
|
+
uniform float u_scale;
|
|
16
|
+
uniform vec4 u_color1;
|
|
17
|
+
uniform vec4 u_color2;
|
|
18
|
+
uniform float u_grainAmount;
|
|
52
19
|
|
|
53
|
-
|
|
54
|
-
float contentAspect = 1.0;
|
|
20
|
+
out vec4 fragColor;
|
|
55
21
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
float scale = shaderAspect / contentAspect;
|
|
59
|
-
st.x = (st.x - 0.5) * scale + 0.5;
|
|
60
|
-
} else {
|
|
61
|
-
float scale = contentAspect / shaderAspect;
|
|
62
|
-
st.y = (st.y - 0.5) * scale + 0.5;
|
|
63
|
-
}
|
|
22
|
+
// Simplex 2D noise
|
|
23
|
+
vec3 permute(vec3 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }
|
|
64
24
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
25
|
+
float snoise(vec2 v) {
|
|
26
|
+
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
|
|
27
|
+
-0.577350269189626, 0.024390243902439);
|
|
28
|
+
vec2 i = floor(v + dot(v, C.yy));
|
|
29
|
+
vec2 x0 = v - i + dot(i, C.xx);
|
|
30
|
+
vec2 i1;
|
|
31
|
+
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
|
32
|
+
vec4 x12 = x0.xyxy + C.xxzz;
|
|
33
|
+
x12.xy -= i1;
|
|
34
|
+
i = mod(i, 289.0);
|
|
35
|
+
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))
|
|
36
|
+
+ i.x + vec3(0.0, i1.x, 1.0));
|
|
37
|
+
vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy),
|
|
38
|
+
dot(x12.zw, x12.zw)), 0.0);
|
|
39
|
+
m = m * m;
|
|
40
|
+
m = m * m;
|
|
41
|
+
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
|
42
|
+
vec3 h = abs(x) - 0.5;
|
|
43
|
+
vec3 ox = floor(x + 0.5);
|
|
44
|
+
vec3 a0 = x - ox;
|
|
45
|
+
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
|
|
46
|
+
vec3 g;
|
|
47
|
+
g.x = a0.x * x0.x + h.x * x0.y;
|
|
48
|
+
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
49
|
+
return 130.0 * dot(m, g);
|
|
50
|
+
}
|
|
70
51
|
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
float rand(vec2 n) {
|
|
53
|
+
return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
|
|
54
|
+
}
|
|
55
|
+
float noise(vec2 n) {
|
|
56
|
+
const vec2 d = vec2(0.0, 1.0);
|
|
57
|
+
vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
|
|
58
|
+
return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
|
|
59
|
+
}
|
|
60
|
+
float fbm(vec2 n) {
|
|
61
|
+
float total = 0.0, amplitude = .2;
|
|
62
|
+
for (int i = 0; i < 6; i++) {
|
|
63
|
+
total += noise(n) * amplitude;
|
|
64
|
+
n += n;
|
|
65
|
+
amplitude *= 0.6;
|
|
66
|
+
}
|
|
67
|
+
return total;
|
|
68
|
+
}
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
color += (grain - 0.5) * u_grainAmount;
|
|
70
|
+
void main() {
|
|
71
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
uv -= .5;
|
|
74
|
+
float scale = .5 * u_scale + 1e-4;
|
|
75
|
+
uv *= (.0004 * (1. - step(1. - scale, 1.) / scale));
|
|
76
|
+
uv *= u_resolution;
|
|
77
|
+
uv /= u_pixelRatio;
|
|
78
|
+
uv += .5;
|
|
79
|
+
|
|
80
|
+
// Create blobby texture
|
|
81
|
+
float n = snoise(uv + u_time);
|
|
82
|
+
n += 0.5 * snoise(uv * 2.0 - u_time * 0.5);
|
|
83
|
+
n += 0.25 * snoise(uv * 4.0 + u_time * 0.25);
|
|
84
|
+
n = n * 0.5 + 0.5;
|
|
83
85
|
|
|
86
|
+
// Color interpolation
|
|
87
|
+
vec3 color = mix(u_color1.rgb, u_color2.rgb, n);
|
|
88
|
+
float opacity = mix(u_color1.a, u_color2.a, n);
|
|
89
|
+
|
|
90
|
+
// Add grain
|
|
91
|
+
float grain = fbm(uv * 1000.);
|
|
92
|
+
color.rgb += (grain - 0.5) * u_grainAmount;
|
|
93
|
+
|
|
94
|
+
fragColor = vec4(color * opacity, opacity);
|
|
95
|
+
}
|
|
96
|
+
`;var C=`#version 300 es
|
|
84
97
|
precision highp float;
|
|
85
98
|
|
|
86
|
-
uniform
|
|
87
|
-
uniform vec3 u_color2;
|
|
88
|
-
uniform vec3 u_color3;
|
|
89
|
-
uniform vec3 u_color4;
|
|
99
|
+
uniform float u_pixelRatio;
|
|
90
100
|
uniform vec2 u_resolution;
|
|
91
101
|
uniform float u_time;
|
|
92
|
-
uniform float u_speed;
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
|
|
103
|
+
uniform vec4 u_color1;
|
|
104
|
+
uniform vec4 u_color2;
|
|
105
|
+
uniform vec4 u_color3;
|
|
106
|
+
uniform vec4 u_color4;
|
|
107
|
+
|
|
108
|
+
out vec4 fragColor;
|
|
109
|
+
|
|
110
|
+
#define S(a,b,t) smoothstep(a,b,t)
|
|
111
|
+
|
|
112
|
+
mat2 Rot(float a) {
|
|
96
113
|
float s = sin(a);
|
|
97
114
|
float c = cos(a);
|
|
98
115
|
return mat2(c, -s, s, c);
|
|
99
116
|
}
|
|
100
117
|
|
|
101
|
-
|
|
102
118
|
vec2 hash(vec2 p) {
|
|
103
119
|
vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));
|
|
104
120
|
p3 += dot(p3, p3.yzx + 33.33);
|
|
105
121
|
return fract((p3.xx+p3.yz)*p3.zy);
|
|
106
122
|
}
|
|
107
123
|
|
|
108
|
-
float noise( in vec2 p )
|
|
109
|
-
{
|
|
124
|
+
float noise( in vec2 p ) {
|
|
110
125
|
vec2 i = floor( p );
|
|
111
126
|
vec2 f = fract( p );
|
|
112
|
-
|
|
113
|
-
vec2 u = f*f*(3.0-2.0*f);
|
|
127
|
+
vec2 u = f*f*(3.0-2.0*f);
|
|
114
128
|
|
|
115
129
|
float n = mix( mix( dot( -1.0+2.0*hash( i + vec2(0.0,0.0) ), f - vec2(0.0,0.0) ),
|
|
116
130
|
dot( -1.0+2.0*hash( i + vec2(1.0,0.0) ), f - vec2(1.0,0.0) ), u.x),
|
|
117
131
|
mix( dot( -1.0+2.0*hash( i + vec2(0.0,1.0) ), f - vec2(0.0,1.0) ),
|
|
118
132
|
dot( -1.0+2.0*hash( i + vec2(1.0,1.0) ), f - vec2(1.0,1.0) ), u.x), u.y);
|
|
119
|
-
|
|
133
|
+
return 0.5 + 0.5*n;
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
|
|
123
137
|
void main() {
|
|
124
138
|
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
125
139
|
float ratio = u_resolution.x / u_resolution.y;
|
|
126
|
-
|
|
140
|
+
|
|
141
|
+
uv /= u_pixelRatio;
|
|
142
|
+
|
|
127
143
|
vec2 tuv = uv;
|
|
128
144
|
tuv -= .5;
|
|
129
145
|
|
|
130
146
|
// rotate with Noise
|
|
131
|
-
float degree = noise(vec2(u_time
|
|
147
|
+
float degree = noise(vec2(u_time, tuv.x * tuv.y));
|
|
132
148
|
|
|
133
149
|
tuv.y *= 1./ratio;
|
|
134
150
|
tuv *= Rot(radians((degree-.5)*720.+180.));
|
|
135
|
-
|
|
151
|
+
tuv.y *= ratio;
|
|
136
152
|
|
|
137
153
|
|
|
138
154
|
// Wave warp with sin
|
|
@@ -140,32 +156,139 @@ void main() {
|
|
|
140
156
|
float amplitude = 30.;
|
|
141
157
|
float speed = u_time * 2.;
|
|
142
158
|
tuv.x += sin(tuv.y*frequency+speed)/amplitude;
|
|
143
|
-
|
|
159
|
+
tuv.y += sin(tuv.x*frequency*1.5+speed)/(amplitude*.5);
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
float proportion_1 = S(-.3, .2, (tuv*Rot(radians(-5.))).x);
|
|
163
|
+
vec3 layer1_color = mix(u_color1.rgb * u_color1.a, u_color2.rgb * u_color2.a, proportion_1);
|
|
164
|
+
float layer1_opacity = mix(u_color1.a, u_color2.a, proportion_1);
|
|
165
|
+
vec3 layer2_color = mix(u_color3.rgb * u_color3.a, u_color4.rgb * u_color4.a, proportion_1);
|
|
166
|
+
float layer2_opacity = mix(u_color3.a, u_color4.a, proportion_1);
|
|
167
|
+
|
|
168
|
+
float proportion_2 = S(.5, -.3, tuv.y);
|
|
169
|
+
vec3 color = mix(layer1_color, layer2_color, proportion_2);
|
|
170
|
+
float opacity = mix(layer1_opacity, layer2_opacity, proportion_2);
|
|
171
|
+
|
|
172
|
+
fragColor = vec4(color, opacity);
|
|
173
|
+
}
|
|
174
|
+
`;var R=`#version 300 es
|
|
175
|
+
precision highp float;
|
|
176
|
+
|
|
177
|
+
uniform float u_pixelRatio;
|
|
178
|
+
uniform vec2 u_resolution;
|
|
179
|
+
uniform float u_time;
|
|
144
180
|
|
|
181
|
+
uniform float u_scale;
|
|
145
182
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
183
|
+
uniform vec4 u_colorBack;
|
|
184
|
+
uniform vec4 u_colorInner;
|
|
185
|
+
uniform vec4 u_colorOuter;
|
|
186
|
+
uniform float u_noiseScale;
|
|
187
|
+
uniform float u_thickness;
|
|
149
188
|
|
|
150
|
-
|
|
189
|
+
out vec4 fragColor;
|
|
151
190
|
|
|
152
|
-
|
|
191
|
+
#define TWO_PI 6.28318530718
|
|
192
|
+
#define PI 3.14159265358979323846
|
|
153
193
|
|
|
154
|
-
|
|
194
|
+
float random(in vec2 st) {
|
|
195
|
+
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
|
196
|
+
}
|
|
197
|
+
float noise(in vec2 st) {
|
|
198
|
+
vec2 i = floor(st);
|
|
199
|
+
vec2 f = fract(st);
|
|
200
|
+
float a = random(i);
|
|
201
|
+
float b = random(i + vec2(1.0, 0.0));
|
|
202
|
+
float c = random(i + vec2(0.0, 1.0));
|
|
203
|
+
float d = random(i + vec2(1.0, 1.0));
|
|
204
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
205
|
+
return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
|
|
206
|
+
}
|
|
207
|
+
float fbm(in vec2 n) {
|
|
208
|
+
float total = 0.0, amplitude = .4;
|
|
209
|
+
for (int i = 0; i < 12; i++) {
|
|
210
|
+
total += noise(n) * amplitude;
|
|
211
|
+
n += n;
|
|
212
|
+
amplitude *= 0.6;
|
|
213
|
+
}
|
|
214
|
+
return total;
|
|
155
215
|
}
|
|
156
|
-
`;var C=`
|
|
157
|
-
precision mediump float;
|
|
158
216
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
217
|
+
float get_ring_shape(vec2 uv, float innerRadius, float outerRadius) {
|
|
218
|
+
float distance = length(uv);
|
|
219
|
+
float line_width = outerRadius - innerRadius;
|
|
220
|
+
float ringValue = smoothstep(innerRadius, innerRadius + .8 * line_width, distance);
|
|
221
|
+
ringValue -= smoothstep(outerRadius, outerRadius + 1.2 * line_width, distance);
|
|
222
|
+
return clamp(ringValue, 0., 1.);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
void main() {
|
|
226
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
227
|
+
float ratio = u_resolution.x / u_resolution.y;
|
|
228
|
+
|
|
229
|
+
uv -= .5;
|
|
230
|
+
uv /= u_pixelRatio;
|
|
231
|
+
float scale = .5 * u_scale + 1e-4;
|
|
232
|
+
uv *= (1. - step(1. - scale, 1.) / scale);
|
|
233
|
+
uv *= 3.;
|
|
234
|
+
uv.x *= ratio;
|
|
235
|
+
|
|
236
|
+
float t = u_time;
|
|
237
|
+
|
|
238
|
+
float atg = atan(uv.y, uv.x);
|
|
239
|
+
float angle = (atg + PI) / TWO_PI;
|
|
240
|
+
|
|
241
|
+
vec2 polar_uv = vec2(atg, .1 * t - (.5 * length(uv)) + 1. / pow(length(uv), .5));
|
|
242
|
+
polar_uv *= u_noiseScale;
|
|
243
|
+
|
|
244
|
+
float noise_left = fbm(polar_uv + .05 * t);
|
|
245
|
+
polar_uv.x = mod(polar_uv.x, u_noiseScale * TWO_PI);
|
|
246
|
+
float noise_right = fbm(polar_uv + .05 * t);
|
|
247
|
+
float noise = mix(noise_right, noise_left, smoothstep(-.2, .2, uv.x));
|
|
248
|
+
|
|
249
|
+
float center_shape = 1. - pow(smoothstep(2., .0, length(uv)), 50.);
|
|
250
|
+
|
|
251
|
+
float radius = .4 - .25 * u_thickness;
|
|
252
|
+
float thickness = u_thickness;
|
|
253
|
+
thickness = pow(thickness, 2.);
|
|
254
|
+
|
|
255
|
+
float ring_shape = get_ring_shape(uv * (.5 + .6 * noise), radius - .2 * thickness, radius + .5 * thickness);
|
|
256
|
+
|
|
257
|
+
float ring_shape_outer = 1. - pow(ring_shape, 7.);
|
|
258
|
+
ring_shape_outer *= ring_shape;
|
|
259
|
+
|
|
260
|
+
float ring_shape_inner = ring_shape - ring_shape_outer;
|
|
261
|
+
ring_shape_inner *= ring_shape;
|
|
262
|
+
|
|
263
|
+
float background = u_colorBack.a;
|
|
264
|
+
|
|
265
|
+
float opacity = ring_shape_outer * u_colorOuter.a;
|
|
266
|
+
opacity += ring_shape_inner * u_colorInner.a;
|
|
267
|
+
opacity += background * (1. - ring_shape_inner * u_colorInner.a - ring_shape_outer * u_colorOuter.a);
|
|
268
|
+
|
|
269
|
+
vec3 color = u_colorBack.rgb * (1. - ring_shape) * background;
|
|
270
|
+
color += u_colorOuter.rgb * ring_shape_outer * u_colorOuter.a;
|
|
271
|
+
color += u_colorInner.rgb * ring_shape_inner * u_colorInner.a;
|
|
272
|
+
|
|
273
|
+
color += u_colorBack.rgb * ring_shape_inner * (1. - u_colorInner.a) * background;
|
|
274
|
+
color += u_colorBack.rgb * ring_shape_outer * (1. - u_colorOuter.a) * background;
|
|
275
|
+
|
|
276
|
+
fragColor = vec4(color, opacity);
|
|
277
|
+
}
|
|
278
|
+
`;var w=`#version 300 es
|
|
279
|
+
precision highp float;
|
|
164
280
|
|
|
165
281
|
uniform float u_time;
|
|
166
|
-
uniform float
|
|
282
|
+
uniform float u_pixelRatio;
|
|
167
283
|
uniform vec2 u_resolution;
|
|
168
284
|
|
|
285
|
+
uniform float u_scale;
|
|
286
|
+
uniform vec4 u_colorFront;
|
|
287
|
+
uniform vec4 u_colorBack;
|
|
288
|
+
uniform float u_brightness;
|
|
289
|
+
|
|
290
|
+
out vec4 fragColor;
|
|
291
|
+
|
|
169
292
|
vec2 rotate(vec2 uv, float th) {
|
|
170
293
|
return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv;
|
|
171
294
|
}
|
|
@@ -188,26 +311,767 @@ float neuro_shape(vec2 uv, float t) {
|
|
|
188
311
|
|
|
189
312
|
void main() {
|
|
190
313
|
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
191
|
-
float ratio = u_resolution.x / u_resolution.y;
|
|
192
|
-
vec2 uv_r = uv;
|
|
193
|
-
uv_r -= .5;
|
|
194
|
-
uv_r *= u_scale;
|
|
195
|
-
uv_r += .5;
|
|
196
|
-
uv_r.x *= ratio;
|
|
197
314
|
|
|
198
|
-
|
|
199
|
-
|
|
315
|
+
uv -= .5;
|
|
316
|
+
float scale = .5 * u_scale + 1e-4;
|
|
317
|
+
uv *= (.001 * (1. - step(1. - scale, 1.) / scale));
|
|
318
|
+
uv *= u_resolution;
|
|
319
|
+
uv /= u_pixelRatio;
|
|
320
|
+
uv += .5;
|
|
321
|
+
|
|
322
|
+
float t = u_time;
|
|
200
323
|
|
|
201
|
-
float noise = neuro_shape(
|
|
324
|
+
float noise = neuro_shape(uv, t);
|
|
202
325
|
|
|
203
326
|
noise = u_brightness * pow(noise, 3.);
|
|
204
|
-
noise += pow(noise,
|
|
327
|
+
noise += pow(noise, 12.);
|
|
205
328
|
noise = max(.0, noise - .5);
|
|
206
|
-
noise *= (1. - length(uv - .5));
|
|
207
329
|
|
|
208
|
-
color = mix(u_colorBack, u_colorFront, noise);
|
|
330
|
+
vec3 color = mix(u_colorBack.rgb * u_colorBack.a, u_colorFront.rgb * u_colorFront.a, noise);
|
|
331
|
+
float opacity = mix(u_colorBack.a, u_colorFront.a, noise);
|
|
332
|
+
|
|
333
|
+
fragColor = vec4(color, opacity);
|
|
334
|
+
}
|
|
335
|
+
`;var F=`#version 300 es
|
|
336
|
+
precision highp float;
|
|
337
|
+
|
|
338
|
+
uniform float u_time;
|
|
339
|
+
uniform float u_pixelRatio;
|
|
340
|
+
uniform vec2 u_resolution;
|
|
341
|
+
|
|
342
|
+
uniform float u_scale;
|
|
343
|
+
uniform vec4 u_color1;
|
|
344
|
+
uniform vec4 u_color2;
|
|
345
|
+
uniform vec4 u_color3;
|
|
346
|
+
uniform vec4 u_color4;
|
|
347
|
+
uniform float u_dotSize;
|
|
348
|
+
uniform float u_dotSizeRange;
|
|
349
|
+
uniform float u_spreading;
|
|
350
|
+
|
|
351
|
+
out vec4 fragColor;
|
|
352
|
+
|
|
353
|
+
#define TWO_PI 6.28318530718
|
|
354
|
+
|
|
355
|
+
float random(in vec2 st) {
|
|
356
|
+
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
|
357
|
+
}
|
|
358
|
+
vec2 random2(vec2 p) {
|
|
359
|
+
return vec2(random(p), random(200. * p));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
vec3 get_voronoi_shape(vec2 _uv, float time) {
|
|
363
|
+
vec2 i_uv = floor(_uv);
|
|
364
|
+
vec2 f_uv = fract(_uv);
|
|
365
|
+
|
|
366
|
+
float min_dist = 1.;
|
|
367
|
+
vec2 cell_randomizer = vec2(0.);
|
|
368
|
+
for (int y = -1; y <= 1; y++) {
|
|
369
|
+
for (int x = -1; x <= 1; x++) {
|
|
370
|
+
vec2 tile_offset = vec2(float(x), float(y));
|
|
371
|
+
vec2 rand = random2(i_uv + tile_offset);
|
|
372
|
+
vec2 cell_center = .5 + 1e-4 + .25 * clamp(u_spreading, 0., 1.) * sin(time + TWO_PI * rand);
|
|
373
|
+
float dist = length(tile_offset + cell_center - f_uv);
|
|
374
|
+
if (dist < min_dist) {
|
|
375
|
+
min_dist = dist;
|
|
376
|
+
cell_randomizer = rand;
|
|
377
|
+
}
|
|
378
|
+
min_dist = min(min_dist, dist);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
return vec3(min_dist, cell_randomizer);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
void main() {
|
|
386
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
387
|
+
|
|
388
|
+
uv -= .5;
|
|
389
|
+
float scale = .5 * u_scale + 1e-4;
|
|
390
|
+
uv *= (.02 * (1. - step(1. - scale, 1.) / scale));
|
|
391
|
+
uv *= u_resolution;
|
|
392
|
+
uv /= u_pixelRatio;
|
|
393
|
+
uv += .5;
|
|
394
|
+
|
|
395
|
+
float t = u_time;
|
|
396
|
+
|
|
397
|
+
vec3 voronoi = get_voronoi_shape(uv, t) + 1e-4;
|
|
398
|
+
|
|
399
|
+
float radius = .25 * clamp(u_dotSize, 0., 1.) - .5 * clamp(u_dotSizeRange, 0., 1.) * voronoi[2];
|
|
400
|
+
float dist = voronoi[0];
|
|
401
|
+
float edge_width = fwidth(dist);
|
|
402
|
+
float shape = smoothstep(radius + edge_width, radius - edge_width, dist);
|
|
403
|
+
|
|
404
|
+
float color_randomizer = voronoi[1];
|
|
405
|
+
|
|
406
|
+
float opacity =
|
|
407
|
+
u_color1.a * step(0.0, color_randomizer) * step(color_randomizer, 0.25) +
|
|
408
|
+
u_color2.a * step(0.25, color_randomizer) * step(color_randomizer, 0.5) +
|
|
409
|
+
u_color3.a * step(0.5, color_randomizer) * step(color_randomizer, 0.75) +
|
|
410
|
+
u_color4.a * step(0.75, color_randomizer) * step(color_randomizer, 1.0);
|
|
411
|
+
|
|
412
|
+
opacity *= shape;
|
|
413
|
+
|
|
414
|
+
vec3 color =
|
|
415
|
+
u_color1.rgb * step(0.0, color_randomizer) * step(color_randomizer, 0.25) +
|
|
416
|
+
u_color2.rgb * step(0.25, color_randomizer) * step(color_randomizer, 0.5) +
|
|
417
|
+
u_color3.rgb * step(0.5, color_randomizer) * step(color_randomizer, 0.75) +
|
|
418
|
+
u_color4.rgb * step(0.75, color_randomizer) * step(color_randomizer, 1.0);
|
|
419
|
+
|
|
420
|
+
fragColor = vec4(color * opacity, opacity);
|
|
421
|
+
}
|
|
422
|
+
`;var k={Circle:0,Diamond:1,Square:2,Triangle:3},I=`#version 300 es
|
|
423
|
+
precision highp float;
|
|
424
|
+
|
|
425
|
+
uniform vec2 u_resolution;
|
|
426
|
+
uniform float u_pixelRatio;
|
|
427
|
+
|
|
428
|
+
uniform vec4 u_colorBack;
|
|
429
|
+
uniform vec4 u_colorFill;
|
|
430
|
+
uniform vec4 u_colorStroke;
|
|
431
|
+
uniform float u_dotSize;
|
|
432
|
+
uniform float u_gridSpacingX;
|
|
433
|
+
uniform float u_gridSpacingY;
|
|
434
|
+
uniform float u_strokeWidth;
|
|
435
|
+
uniform float u_sizeRange;
|
|
436
|
+
uniform float u_opacityRange;
|
|
437
|
+
uniform float u_shape;
|
|
438
|
+
|
|
439
|
+
out vec4 fragColor;
|
|
440
|
+
|
|
441
|
+
#define TWO_PI 6.28318530718
|
|
442
|
+
#define PI 3.14159265358979323846
|
|
443
|
+
|
|
444
|
+
float hash(vec2 st) {
|
|
445
|
+
return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
|
|
449
|
+
|
|
450
|
+
float snoise(vec2 v) {
|
|
451
|
+
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
|
|
452
|
+
-0.577350269189626, 0.024390243902439);
|
|
453
|
+
vec2 i = floor(v + dot(v, C.yy));
|
|
454
|
+
vec2 x0 = v - i + dot(i, C.xx);
|
|
455
|
+
vec2 i1;
|
|
456
|
+
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
|
457
|
+
vec4 x12 = x0.xyxy + C.xxzz;
|
|
458
|
+
x12.xy -= i1;
|
|
459
|
+
i = mod(i, 289.0);
|
|
460
|
+
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0))
|
|
461
|
+
+ i.x + vec3(0.0, i1.x, 1.0));
|
|
462
|
+
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
|
|
463
|
+
dot(x12.zw,x12.zw)), 0.0);
|
|
464
|
+
m = m*m ;
|
|
465
|
+
m = m*m ;
|
|
466
|
+
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
|
467
|
+
vec3 h = abs(x) - 0.5;
|
|
468
|
+
vec3 ox = floor(x + 0.5);
|
|
469
|
+
vec3 a0 = x - ox;
|
|
470
|
+
m *= 1.79284291400159 - 0.85373472095314 * (a0*a0 + h*h);
|
|
471
|
+
vec3 g;
|
|
472
|
+
g.x = a0.x * x0.x + h.x * x0.y;
|
|
473
|
+
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
474
|
+
return 130.0 * dot(m, g);
|
|
475
|
+
}
|
|
476
|
+
float polygon(vec2 p, float N, float rot) {
|
|
477
|
+
float a = atan(p.x, p.y) + rot;
|
|
478
|
+
float r = TWO_PI / float(N);
|
|
479
|
+
|
|
480
|
+
return cos(floor(.5 + a/r) * r - a) * length(p);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
void main() {
|
|
484
|
+
vec2 uv = gl_FragCoord.xy;
|
|
485
|
+
uv.y = u_resolution.y - uv.y;
|
|
486
|
+
|
|
487
|
+
uv /= u_pixelRatio;
|
|
488
|
+
|
|
489
|
+
vec2 grid = fract(uv / vec2(u_gridSpacingX, u_gridSpacingY)) + 1e-4;
|
|
490
|
+
vec2 grid_idx = floor(uv / vec2(u_gridSpacingX, u_gridSpacingY));
|
|
491
|
+
float size_randomizer = .5 + .5 * snoise(2. * vec2(grid_idx.x * 100., grid_idx.y));
|
|
492
|
+
float opacity_randomizer = .5 + .5 * snoise(2. * vec2(grid_idx.y, grid_idx.x));
|
|
493
|
+
|
|
494
|
+
vec2 center = vec2(0.5) - 1e-3;
|
|
495
|
+
vec2 p = (grid - center) * vec2(u_gridSpacingX, u_gridSpacingY);
|
|
496
|
+
|
|
497
|
+
float base_size = u_dotSize * (1. - size_randomizer * clamp(u_sizeRange, 0., 1.));
|
|
498
|
+
float stroke_width = u_strokeWidth;
|
|
499
|
+
|
|
500
|
+
float dist;
|
|
501
|
+
if (u_shape < 0.5) {
|
|
502
|
+
// Circle
|
|
503
|
+
dist = length(p);
|
|
504
|
+
} else if (u_shape < 1.5) {
|
|
505
|
+
// Diamond
|
|
506
|
+
dist = polygon(1.5 * p, 4., .25 * PI);
|
|
507
|
+
} else if (u_shape < 2.5) {
|
|
508
|
+
// Square
|
|
509
|
+
dist = polygon(1.5 * p, 4., 1e-3);
|
|
510
|
+
} else {
|
|
511
|
+
// Triangle
|
|
512
|
+
p = p * 2. - 1.;
|
|
513
|
+
p.y -= .75 * base_size;
|
|
514
|
+
stroke_width *= 2.;
|
|
515
|
+
dist = polygon(p, 3., 1e-3);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
float edge_width = fwidth(dist);
|
|
519
|
+
float shape_outer = smoothstep(base_size + edge_width, base_size - edge_width, dist);
|
|
520
|
+
float shape_inner = smoothstep(base_size - u_strokeWidth + edge_width, base_size - u_strokeWidth - edge_width, dist);
|
|
521
|
+
float stroke = clamp(shape_outer - shape_inner, 0., 1.);
|
|
522
|
+
|
|
523
|
+
float dot_opacity = max(0., 1. - opacity_randomizer * clamp(u_opacityRange, 0., 1.));
|
|
524
|
+
|
|
525
|
+
vec3 color = u_colorBack.rgb * u_colorBack.a;
|
|
526
|
+
color = mix(color, u_colorFill.rgb, u_colorFill.a * dot_opacity * shape_inner);
|
|
527
|
+
color = mix(color, u_colorStroke.rgb, u_colorStroke.a * dot_opacity * stroke);
|
|
528
|
+
|
|
529
|
+
float opacity = u_colorBack.a;
|
|
530
|
+
opacity += u_colorFill.a * shape_inner * dot_opacity;
|
|
531
|
+
opacity += u_colorStroke.a * stroke * dot_opacity;
|
|
532
|
+
|
|
533
|
+
fragColor = vec4(color, opacity);
|
|
534
|
+
}
|
|
535
|
+
`;var P=`#version 300 es
|
|
536
|
+
precision highp float;
|
|
537
|
+
|
|
538
|
+
uniform float u_time;
|
|
539
|
+
uniform float u_pixelRatio;
|
|
540
|
+
uniform vec2 u_resolution;
|
|
541
|
+
|
|
542
|
+
uniform float u_scale;
|
|
543
|
+
|
|
544
|
+
uniform vec4 u_color1;
|
|
545
|
+
uniform vec4 u_color2;
|
|
546
|
+
uniform vec4 u_color3;
|
|
547
|
+
uniform vec4 u_color4;
|
|
548
|
+
uniform vec4 u_color5;
|
|
549
|
+
uniform float u_steps_number;
|
|
550
|
+
|
|
551
|
+
out vec4 fragColor;
|
|
552
|
+
|
|
553
|
+
vec3 permute(vec3 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }
|
|
554
|
+
float snoise(vec2 v) {
|
|
555
|
+
const vec4 C = vec4(0.211324865405187, 0.366025403784439,
|
|
556
|
+
-0.577350269189626, 0.024390243902439);
|
|
557
|
+
vec2 i = floor(v + dot(v, C.yy));
|
|
558
|
+
vec2 x0 = v - i + dot(i, C.xx);
|
|
559
|
+
vec2 i1;
|
|
560
|
+
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
|
561
|
+
vec4 x12 = x0.xyxy + C.xxzz;
|
|
562
|
+
x12.xy -= i1;
|
|
563
|
+
i = mod(i, 289.0);
|
|
564
|
+
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0))
|
|
565
|
+
+ i.x + vec3(0.0, i1.x, 1.0));
|
|
566
|
+
vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy),
|
|
567
|
+
dot(x12.zw, x12.zw)), 0.0);
|
|
568
|
+
m = m * m;
|
|
569
|
+
m = m * m;
|
|
570
|
+
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
|
571
|
+
vec3 h = abs(x) - 0.5;
|
|
572
|
+
vec3 ox = floor(x + 0.5);
|
|
573
|
+
vec3 a0 = x - ox;
|
|
574
|
+
m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);
|
|
575
|
+
vec3 g;
|
|
576
|
+
g.x = a0.x * x0.x + h.x * x0.y;
|
|
577
|
+
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
|
578
|
+
return 130.0 * dot(m, g);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
float get_noise(vec2 uv, float t) {
|
|
582
|
+
float noise = .5 * snoise(uv - vec2(0., .3 * t));
|
|
583
|
+
noise += .5 * snoise(2. * uv + vec2(0., .32 * t));
|
|
584
|
+
|
|
585
|
+
return noise;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
vec4 getColor(int index) {
|
|
589
|
+
if (index == 0) return u_color1;
|
|
590
|
+
if (index == 1) return u_color2;
|
|
591
|
+
if (index == 2) return u_color3;
|
|
592
|
+
if (index == 3) return u_color4;
|
|
593
|
+
if (index == 4) return u_color5;
|
|
594
|
+
return u_color1;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
void main() {
|
|
598
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
599
|
+
|
|
600
|
+
uv -= .5;
|
|
601
|
+
float scale = .5 * u_scale + 1e-4;
|
|
602
|
+
uv *= (.0008 * (1. - step(1. - scale, 1.) / scale));
|
|
603
|
+
uv *= u_resolution;
|
|
604
|
+
uv /= u_pixelRatio;
|
|
605
|
+
uv += .5;
|
|
606
|
+
|
|
607
|
+
float t = u_time;
|
|
608
|
+
|
|
609
|
+
float noise = .5 + .5 * get_noise(uv, t);
|
|
610
|
+
noise = floor(noise * u_steps_number) / u_steps_number;
|
|
611
|
+
|
|
612
|
+
vec3 color = u_color1.rgb * u_color1.a;
|
|
613
|
+
float opacity = u_color1.a;
|
|
614
|
+
for (int i = 0; i < 5; i++) {
|
|
615
|
+
vec4 next_c = getColor(i + 1);
|
|
616
|
+
float proportion = smoothstep((float(i) + .5) / 5., (float(i) + 2.) / 5., noise);
|
|
617
|
+
color = mix(color, next_c.rgb * next_c.a, proportion);
|
|
618
|
+
opacity = mix(opacity, next_c.a, proportion);
|
|
619
|
+
}
|
|
620
|
+
fragColor = vec4(color, opacity);
|
|
621
|
+
}
|
|
622
|
+
`;var U=`#version 300 es
|
|
623
|
+
precision highp float;
|
|
624
|
+
|
|
625
|
+
uniform float u_time;
|
|
626
|
+
uniform float u_pixelRatio;
|
|
627
|
+
uniform vec2 u_resolution;
|
|
628
|
+
|
|
629
|
+
uniform float u_scale;
|
|
630
|
+
uniform vec4 u_color1;
|
|
631
|
+
uniform vec4 u_color2;
|
|
632
|
+
uniform vec4 u_color3;
|
|
633
|
+
uniform float u_ballSize;
|
|
634
|
+
uniform float u_visibilityRange;
|
|
635
|
+
|
|
636
|
+
#define TWO_PI 6.28318530718
|
|
637
|
+
|
|
638
|
+
out vec4 fragColor;
|
|
639
|
+
|
|
640
|
+
float hash(float x) {
|
|
641
|
+
return fract(sin(x) * 43758.5453123);
|
|
642
|
+
}
|
|
643
|
+
float lerp(float a, float b, float t) {
|
|
644
|
+
return a + t * (b - a);
|
|
645
|
+
}
|
|
646
|
+
float noise(float x) {
|
|
647
|
+
float i = floor(x);
|
|
648
|
+
float f = fract(x);
|
|
649
|
+
float u = f * f * (3.0 - 2.0 * f); // Smoothstep function for interpolation
|
|
650
|
+
return lerp(hash(i), hash(i + 1.0), u);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
float get_ball_shape(vec2 uv, vec2 c, float p) {
|
|
654
|
+
float s = .5 * length(uv - c);
|
|
655
|
+
s = 1. - clamp(s, 0., 1.);
|
|
656
|
+
s = pow(s, p);
|
|
657
|
+
return s;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
void main() {
|
|
661
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
662
|
+
float ratio = u_resolution.x / u_resolution.y;
|
|
663
|
+
|
|
664
|
+
uv -= .5;
|
|
665
|
+
uv /= u_pixelRatio;
|
|
666
|
+
float scale = .5 * u_scale + 1e-4;
|
|
667
|
+
uv *= (18. * (1. - step(1. - scale, 1.) / scale));
|
|
668
|
+
uv += .5;
|
|
669
|
+
uv.x *= ratio;
|
|
670
|
+
|
|
671
|
+
float t = u_time;
|
|
672
|
+
|
|
673
|
+
vec3 total_color = vec3(0.);
|
|
674
|
+
float total_shape = 0.;
|
|
675
|
+
|
|
676
|
+
const int max_balls_number = 15;
|
|
677
|
+
for (int i = 0; i < max_balls_number; i++) {
|
|
678
|
+
vec2 pos = vec2(.5) + 1e-4;
|
|
679
|
+
float idx_fract = float(i) / float(max_balls_number);
|
|
680
|
+
float angle = TWO_PI * idx_fract;
|
|
681
|
+
|
|
682
|
+
float speed = 1. - .2 * idx_fract;
|
|
683
|
+
float noiseX = noise(angle * 10. + float(i) + t * speed);
|
|
684
|
+
float noiseY = noise(angle * 20. + float(i) - t * speed);
|
|
685
|
+
|
|
686
|
+
pos += 7. * (vec2(noiseX, noiseY) - .5);
|
|
687
|
+
|
|
688
|
+
vec4 ball_color;
|
|
689
|
+
if (i % 3 == 0) {
|
|
690
|
+
ball_color = u_color1;
|
|
691
|
+
} else if (i % 3 == 1) {
|
|
692
|
+
ball_color = u_color2;
|
|
693
|
+
} else {
|
|
694
|
+
ball_color = u_color3;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
float shape = get_ball_shape(uv, pos, 6. - 4. * u_ballSize) * ball_color.a;
|
|
698
|
+
|
|
699
|
+
shape *= smoothstep((float(i) - 1.) / float(max_balls_number), idx_fract, u_visibilityRange);
|
|
700
|
+
|
|
701
|
+
total_color += ball_color.rgb * shape;
|
|
702
|
+
total_shape += shape;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
total_color /= max(total_shape, 1e-4);
|
|
706
|
+
|
|
707
|
+
float edge_width = fwidth(total_shape);
|
|
708
|
+
float final_shape = smoothstep(.4, .4 + edge_width, total_shape);
|
|
709
|
+
|
|
710
|
+
vec3 color = total_color * final_shape;
|
|
711
|
+
float opacity = final_shape;
|
|
712
|
+
|
|
713
|
+
if (opacity < .01) {
|
|
714
|
+
discard;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
fragColor = vec4(color, opacity);
|
|
718
|
+
}
|
|
719
|
+
`;var A=`#version 300 es
|
|
720
|
+
precision highp float;
|
|
721
|
+
|
|
722
|
+
uniform float u_time;
|
|
723
|
+
uniform float u_pixelRatio;
|
|
724
|
+
uniform vec2 u_resolution;
|
|
725
|
+
|
|
726
|
+
uniform float u_scale;
|
|
727
|
+
uniform vec4 u_color1;
|
|
728
|
+
uniform vec4 u_color2;
|
|
729
|
+
uniform float u_proportion;
|
|
730
|
+
uniform float u_contour;
|
|
731
|
+
uniform float u_octaveCount;
|
|
732
|
+
uniform float u_persistence;
|
|
733
|
+
uniform float u_lacunarity;
|
|
734
|
+
|
|
735
|
+
out vec4 fragColor;
|
|
736
|
+
|
|
737
|
+
#define TWO_PI 6.28318530718
|
|
738
|
+
|
|
739
|
+
uint hash(uint x, uint seed) {
|
|
740
|
+
const uint m = 0x5bd1e995U;
|
|
741
|
+
uint hash = seed;
|
|
742
|
+
// process input
|
|
743
|
+
uint k = x;
|
|
744
|
+
k *= m;
|
|
745
|
+
k ^= k >> 24;
|
|
746
|
+
k *= m;
|
|
747
|
+
hash *= m;
|
|
748
|
+
hash ^= k;
|
|
749
|
+
// some final mixing
|
|
750
|
+
hash ^= hash >> 13;
|
|
751
|
+
hash *= m;
|
|
752
|
+
hash ^= hash >> 15;
|
|
753
|
+
return hash;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
uint hash(uvec3 x, uint seed){
|
|
757
|
+
const uint m = 0x5bd1e995U;
|
|
758
|
+
uint hash = seed;
|
|
759
|
+
// process first vector element
|
|
760
|
+
uint k = x.x;
|
|
761
|
+
k *= m;
|
|
762
|
+
k ^= k >> 24;
|
|
763
|
+
k *= m;
|
|
764
|
+
hash *= m;
|
|
765
|
+
hash ^= k;
|
|
766
|
+
// process second vector element
|
|
767
|
+
k = x.y;
|
|
768
|
+
k *= m;
|
|
769
|
+
k ^= k >> 24;
|
|
770
|
+
k *= m;
|
|
771
|
+
hash *= m;
|
|
772
|
+
hash ^= k;
|
|
773
|
+
// process third vector element
|
|
774
|
+
k = x.z;
|
|
775
|
+
k *= m;
|
|
776
|
+
k ^= k >> 24;
|
|
777
|
+
k *= m;
|
|
778
|
+
hash *= m;
|
|
779
|
+
hash ^= k;
|
|
780
|
+
// some final mixing
|
|
781
|
+
hash ^= hash >> 13;
|
|
782
|
+
hash *= m;
|
|
783
|
+
hash ^= hash >> 15;
|
|
784
|
+
return hash;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
vec3 gradientdy(uint hash) {
|
|
789
|
+
switch (int(hash) & 15) { // look at the last four bits to pick a gradient dy
|
|
790
|
+
case 0:
|
|
791
|
+
return vec3(1, 1, 0);
|
|
792
|
+
case 1:
|
|
793
|
+
return vec3(-1, 1, 0);
|
|
794
|
+
case 2:
|
|
795
|
+
return vec3(1, -1, 0);
|
|
796
|
+
case 3:
|
|
797
|
+
return vec3(-1, -1, 0);
|
|
798
|
+
case 4:
|
|
799
|
+
return vec3(1, 0, 1);
|
|
800
|
+
case 5:
|
|
801
|
+
return vec3(-1, 0, 1);
|
|
802
|
+
case 6:
|
|
803
|
+
return vec3(1, 0, -1);
|
|
804
|
+
case 7:
|
|
805
|
+
return vec3(-1, 0, -1);
|
|
806
|
+
case 8:
|
|
807
|
+
return vec3(0, 1, 1);
|
|
808
|
+
case 9:
|
|
809
|
+
return vec3(0, -1, 1);
|
|
810
|
+
case 10:
|
|
811
|
+
return vec3(0, 1, -1);
|
|
812
|
+
case 11:
|
|
813
|
+
return vec3(0, -1, -1);
|
|
814
|
+
case 12:
|
|
815
|
+
return vec3(1, 1, 0);
|
|
816
|
+
case 13:
|
|
817
|
+
return vec3(-1, 1, 0);
|
|
818
|
+
case 14:
|
|
819
|
+
return vec3(0, -1, 1);
|
|
820
|
+
case 15:
|
|
821
|
+
return vec3(0, -1, -1);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
float interpolate(float value1, float value2, float value3, float value4, float value5, float value6, float value7, float value8, vec3 t) {
|
|
826
|
+
return mix(
|
|
827
|
+
mix(mix(value1, value2, t.x), mix(value3, value4, t.x), t.y),
|
|
828
|
+
mix(mix(value5, value6, t.x), mix(value7, value8, t.x), t.y),
|
|
829
|
+
t.z
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
vec3 fade(vec3 t) {
|
|
834
|
+
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
float perlinNoise(vec3 position, uint seed) {
|
|
838
|
+
position += 1e+4;
|
|
839
|
+
vec3 floorPosition = floor(position);
|
|
840
|
+
vec3 fractPosition = fract(position);
|
|
841
|
+
uvec3 cellCoordinates = uvec3(floorPosition);
|
|
842
|
+
float value1 = dot(gradientdy(hash(cellCoordinates, seed)), fractPosition);
|
|
843
|
+
float value2 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 0)), seed)), fractPosition - vec3(1, 0, 0));
|
|
844
|
+
float value3 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 0)), seed)), fractPosition - vec3(0, 1, 0));
|
|
845
|
+
float value4 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 0)), seed)), fractPosition - vec3(1, 1, 0));
|
|
846
|
+
float value5 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 0, 1)), seed)), fractPosition - vec3(0, 0, 1));
|
|
847
|
+
float value6 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 0, 1)), seed)), fractPosition - vec3(1, 0, 1));
|
|
848
|
+
float value7 = dot(gradientdy(hash((cellCoordinates + uvec3(0, 1, 1)), seed)), fractPosition - vec3(0, 1, 1));
|
|
849
|
+
float value8 = dot(gradientdy(hash((cellCoordinates + uvec3(1, 1, 1)), seed)), fractPosition - vec3(1, 1, 1));
|
|
850
|
+
return interpolate(value1, value2, value3, value4, value5, value6, value7, value8, fade(fractPosition));
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
float p_noise(vec3 position, int octaveCount, float persistence, float lacunarity) {
|
|
854
|
+
float value = 0.0;
|
|
855
|
+
float amplitude = 1.0;
|
|
856
|
+
float currentFrequency = 10.;
|
|
857
|
+
uint currentSeed = uint(0);
|
|
858
|
+
for (int i = 0; i < octaveCount; i++) {
|
|
859
|
+
currentSeed = hash(currentSeed, 0x0U);
|
|
860
|
+
value += perlinNoise(position * currentFrequency, currentSeed) * amplitude;
|
|
861
|
+
amplitude *= persistence;
|
|
862
|
+
currentFrequency *= lacunarity;
|
|
863
|
+
}
|
|
864
|
+
return value;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
float get_max_amp(float persistence, float octaveCount) {
|
|
868
|
+
persistence *= .999;
|
|
869
|
+
return (1. - pow(persistence, octaveCount)) / (1. - persistence);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
void main() {
|
|
873
|
+
|
|
874
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
875
|
+
float t = .2 * u_time;
|
|
876
|
+
|
|
877
|
+
uv -= .5;
|
|
878
|
+
uv *= (.004 * u_scale * u_resolution);
|
|
879
|
+
uv /= u_pixelRatio;
|
|
880
|
+
uv += .5;
|
|
881
|
+
|
|
882
|
+
vec3 p = vec3(uv, t);
|
|
883
|
+
|
|
884
|
+
float oct_count = max(0., floor(u_octaveCount));
|
|
885
|
+
float persistence = clamp(u_persistence, 0., 1.);
|
|
886
|
+
float noise = p_noise(p, int(oct_count), persistence, u_lacunarity);
|
|
887
|
+
|
|
888
|
+
float max_amp = get_max_amp(persistence, oct_count);
|
|
889
|
+
float noise_normalized = (noise + max_amp) / (2. * max_amp) + (u_proportion - .5);
|
|
890
|
+
float sharpness = clamp(1. - u_contour, 0., 1.);
|
|
891
|
+
float smooth_w = 0.5 * fwidth(noise_normalized);
|
|
892
|
+
float sharp_noise = smoothstep(
|
|
893
|
+
.5 - .5 * sharpness - smooth_w,
|
|
894
|
+
.5 + .5 * sharpness + smooth_w,
|
|
895
|
+
noise_normalized
|
|
896
|
+
);
|
|
897
|
+
|
|
898
|
+
vec3 color = mix(u_color1.rgb * u_color1.a, u_color2.rgb * u_color2.a, sharp_noise);
|
|
899
|
+
float opacity = mix(u_color1.a, u_color2.a, sharp_noise);
|
|
900
|
+
|
|
901
|
+
fragColor = vec4(color, opacity);
|
|
902
|
+
}
|
|
903
|
+
`;var O=`#version 300 es
|
|
904
|
+
precision highp float;
|
|
905
|
+
|
|
906
|
+
uniform float u_time;
|
|
907
|
+
uniform float u_pixelRatio;
|
|
908
|
+
uniform vec2 u_resolution;
|
|
909
|
+
|
|
910
|
+
uniform float u_scale;
|
|
911
|
+
|
|
912
|
+
uniform vec4 u_colorCell1;
|
|
913
|
+
uniform vec4 u_colorCell2;
|
|
914
|
+
uniform vec4 u_colorCell3;
|
|
915
|
+
uniform vec4 u_colorEdges;
|
|
916
|
+
uniform vec4 u_colorMid;
|
|
917
|
+
|
|
918
|
+
uniform float u_colorGradient;
|
|
919
|
+
uniform float u_distance;
|
|
920
|
+
uniform float u_edgesSize;
|
|
921
|
+
uniform float u_edgesSharpness;
|
|
922
|
+
uniform float u_middleSize;
|
|
923
|
+
uniform float u_middleSharpness;
|
|
924
|
+
|
|
925
|
+
#define TWO_PI 6.28318530718
|
|
926
|
+
|
|
927
|
+
out vec4 fragColor;
|
|
928
|
+
|
|
929
|
+
vec2 hash(vec2 p) {
|
|
930
|
+
p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));
|
|
931
|
+
return fract(sin(p) * 18.5453);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
float smin(float angle, float b, float k) {
|
|
935
|
+
float h = clamp(.5 + .5 * (b - angle) / k, 0., 1.);
|
|
936
|
+
return mix(b, angle, h) - k * h * (1. - h);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
vec4 blend_colors(vec4 c1, vec4 c2, vec4 c3, vec2 randomizer) {
|
|
940
|
+
vec3 color1 = c1.rgb * c1.a;
|
|
941
|
+
vec3 color2 = c2.rgb * c2.a;
|
|
942
|
+
vec3 color3 = c3.rgb * c3.a;
|
|
943
|
+
|
|
944
|
+
float mixer = clamp(u_colorGradient, 0., 1.);
|
|
945
|
+
float r1 = smoothstep(.5 - .5 * mixer, .5 + .5 * mixer, randomizer[0]);
|
|
946
|
+
float r2 = smoothstep(.6 - .6 * mixer, .6 + .4 * mixer, randomizer[1]);
|
|
947
|
+
vec3 blended_color_2 = mix(color1, color2, r1);
|
|
948
|
+
float blended_opacity_2 = mix(c1.a, c2.a, r1);
|
|
949
|
+
vec3 c = mix(blended_color_2, color3, r2);
|
|
950
|
+
float o = mix(blended_opacity_2, c3.a, r2);
|
|
951
|
+
|
|
952
|
+
return vec4(c, o);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
void main() {
|
|
956
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
957
|
+
float t = u_time;
|
|
958
|
+
uv -= .5;
|
|
959
|
+
uv *= (.01 * u_scale * u_resolution);
|
|
960
|
+
uv /= u_pixelRatio;
|
|
961
|
+
uv += .5;
|
|
962
|
+
|
|
963
|
+
vec2 i_uv = floor(uv);
|
|
964
|
+
vec2 f_uv = fract(uv);
|
|
965
|
+
|
|
966
|
+
vec2 randomizer = vec2(0.);
|
|
967
|
+
vec3 distance = vec3(1.);
|
|
968
|
+
|
|
969
|
+
for (int y = -1; y <= 1; y++) {
|
|
970
|
+
for (int x = -1; x <= 1; x++) {
|
|
971
|
+
vec2 tile_offset = vec2(float(x), float(y));
|
|
972
|
+
vec2 o = hash(i_uv + tile_offset);
|
|
973
|
+
tile_offset += (.5 + clamp(u_distance, 0., .5) * sin(t + TWO_PI * o)) - f_uv;
|
|
974
|
+
|
|
975
|
+
float dist = dot(tile_offset, tile_offset);
|
|
976
|
+
float old_min_dist = distance.x;
|
|
977
|
+
|
|
978
|
+
distance.z = max(distance.x, max(distance.y, min(distance.z, dist)));
|
|
979
|
+
distance.y = max(distance.x, min(distance.y, dist));
|
|
980
|
+
distance.x = min(distance.x, dist);
|
|
981
|
+
|
|
982
|
+
if (old_min_dist > distance.x) {
|
|
983
|
+
randomizer = o;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
distance = sqrt(distance);
|
|
989
|
+
|
|
990
|
+
distance = sqrt(distance);
|
|
991
|
+
float cell_shape = min(smin(distance.z, distance.y, .1) - distance.x, 1.);
|
|
992
|
+
|
|
993
|
+
float dot_shape = pow(distance.x, 2.) / (2. * clamp(u_middleSize, 0., 1.) + 1e-4);
|
|
994
|
+
float dot_edge_width = fwidth(dot_shape);
|
|
995
|
+
float dotSharp = clamp(u_middleSharpness, 0., 1.);
|
|
996
|
+
dot_shape = 1. - smoothstep(.5 * dotSharp - dot_edge_width, 1. - .5 * dotSharp, dot_shape);
|
|
997
|
+
|
|
998
|
+
float cell_edge_width = fwidth(distance.x);
|
|
999
|
+
float w = .7 * (clamp(u_edgesSize, 0., 1.) - .1);
|
|
1000
|
+
float edgeSharp = clamp(u_edgesSharpness, 0., 1.);
|
|
1001
|
+
cell_shape = smoothstep(w - cell_edge_width, w + edgeSharp, cell_shape);
|
|
1002
|
+
|
|
1003
|
+
dot_shape *= cell_shape;
|
|
1004
|
+
|
|
1005
|
+
vec4 cell_mix = blend_colors(u_colorCell1, u_colorCell2, u_colorCell3, randomizer);
|
|
1006
|
+
|
|
1007
|
+
vec4 edges = vec4(u_colorEdges.rgb * u_colorEdges.a, u_colorEdges.a);
|
|
1008
|
+
|
|
1009
|
+
vec3 color = mix(edges.rgb, cell_mix.rgb, cell_shape);
|
|
1010
|
+
float opacity = mix(edges.a, cell_mix.a, cell_shape);
|
|
1011
|
+
|
|
1012
|
+
color = mix(color, u_colorMid.rgb * u_colorMid.a, dot_shape);
|
|
1013
|
+
opacity = mix(opacity, u_colorMid.a, dot_shape);
|
|
1014
|
+
|
|
1015
|
+
fragColor = vec4(color, opacity);
|
|
1016
|
+
}
|
|
1017
|
+
`;var T=`#version 300 es
|
|
1018
|
+
precision highp float;
|
|
1019
|
+
|
|
1020
|
+
uniform float u_pixelRatio;
|
|
1021
|
+
uniform vec2 u_resolution;
|
|
1022
|
+
|
|
1023
|
+
uniform float u_scale;
|
|
1024
|
+
uniform float u_rotation;
|
|
1025
|
+
|
|
1026
|
+
uniform vec4 u_color1;
|
|
1027
|
+
uniform vec4 u_color2;
|
|
1028
|
+
uniform float u_shape;
|
|
1029
|
+
uniform float u_frequency;
|
|
1030
|
+
uniform float u_amplitude;
|
|
1031
|
+
uniform float u_spacing;
|
|
1032
|
+
uniform float u_dutyCycle;
|
|
1033
|
+
uniform float u_edgeBlur;
|
|
1034
|
+
|
|
1035
|
+
#define TWO_PI 6.28318530718
|
|
1036
|
+
#define PI 3.14159265358979323846
|
|
1037
|
+
|
|
1038
|
+
out vec4 fragColor;
|
|
1039
|
+
|
|
1040
|
+
vec2 rotate(vec2 uv, float th) {
|
|
1041
|
+
return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
void main() {
|
|
1045
|
+
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
|
1046
|
+
|
|
1047
|
+
uv -= .5;
|
|
1048
|
+
uv *= (.02 * max(0., u_scale) * u_resolution);
|
|
1049
|
+
uv = rotate(uv, u_rotation * .5 * PI);
|
|
1050
|
+
uv /= u_pixelRatio;
|
|
1051
|
+
uv += .5;
|
|
1052
|
+
|
|
1053
|
+
float wave = .5 * cos(uv.x * u_frequency * TWO_PI);
|
|
1054
|
+
float zigzag = 2. * abs(fract(uv.x * u_frequency) - .5);
|
|
1055
|
+
float irregular = sin(uv.x * .25 * u_frequency * TWO_PI) * cos(uv.x * u_frequency * TWO_PI);
|
|
1056
|
+
float irregular2 = .75 * (sin(uv.x * u_frequency * TWO_PI) + .5 * cos(uv.x * .5 * u_frequency * TWO_PI));
|
|
1057
|
+
|
|
1058
|
+
float offset = mix(zigzag, wave, smoothstep(0., 1., u_shape));
|
|
1059
|
+
offset = mix(offset, irregular, smoothstep(1., 2., u_shape));
|
|
1060
|
+
offset = mix(offset, irregular2, smoothstep(2., 3., u_shape));
|
|
1061
|
+
offset *= 2. * u_amplitude;
|
|
1062
|
+
|
|
1063
|
+
float spacing = .02 + .98 * u_spacing;
|
|
1064
|
+
float shape = .5 + .5 * sin((uv.y + offset) * PI / spacing);
|
|
1065
|
+
|
|
1066
|
+
float edge_width = .02 / (1. + abs(shape)) * (.001 + u_scale);
|
|
1067
|
+
edge_width += .5 * max(0., u_edgeBlur);
|
|
1068
|
+
float dc = clamp(u_dutyCycle, 0., 1.);
|
|
1069
|
+
float t = smoothstep(dc - edge_width, dc + edge_width, shape);
|
|
209
1070
|
|
|
210
|
-
|
|
1071
|
+
vec3 color = mix(u_color1.rgb * u_color1.a, u_color2.rgb * u_color2.a, t);
|
|
1072
|
+
float opacity = mix(u_color1.a, u_color2.a, t);
|
|
1073
|
+
|
|
1074
|
+
fragColor = vec4(color, opacity);
|
|
211
1075
|
}
|
|
212
|
-
`;
|
|
1076
|
+
`;function f(e,o=[0,0,0,1]){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:f(o);if(typeof e!="string")return f(o);let r,t,a,i=1;if(e.startsWith("#"))[r,t,a,i]=W(e);else if(e.startsWith("rgb"))[r,t,a,i]=B(e);else if(e.startsWith("hsl"))[r,t,a,i]=G(L(e));else return console.error("Unsupported color format",e),f(o);return[m(r,0,1),m(t,0,1),m(a,0,1),m(i,0,1)]}function W(e){e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(i=>i+i).join("")),e.length===6&&(e=e+"ff");let o=parseInt(e.slice(0,2),16)/255,r=parseInt(e.slice(2,4),16)/255,t=parseInt(e.slice(4,6),16)/255,a=parseInt(e.slice(6,8),16)/255;return[o,r,t,a]}function B(e){let o=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return o?[parseInt(o[1]??"0")/255,parseInt(o[2]??"0")/255,parseInt(o[3]??"0")/255,o[4]===void 0?1:parseFloat(o[4])]:[0,0,0,1]}function L(e){let o=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return o?[parseInt(o[1]??"0"),parseInt(o[2]??"0"),parseInt(o[3]??"0"),o[4]===void 0?1:parseFloat(o[4])]:[0,0,0,1]}function G(e){let[o,r,t,a]=e,i=o/360,s=r/100,n=t/100,_,d,p;if(r===0)_=d=p=n;else{let v=(l,b,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<.16666666666666666?l+(b-l)*6*u:u<.5?b:u<.6666666666666666?l+(b-l)*(.6666666666666666-u)*6:l),c=n<.5?n*(1+s):n+s-n*s,h=2*n-c;_=v(h,c,i+1/3),d=v(h,c,i),p=v(h,c,i-1/3)}return[_,d,p,a]}var m=(e,o,r)=>Math.min(Math.max(e,o),r);export{k as DotsGridShapes,g as ShaderMount,I as dotsGridFragmentShader,F as dotsOrbitFragmentShader,f as getShaderColorFromString,z as grainCloudsFragmentShader,C as meshGradientFragmentShader,U as metaballsFragmentShader,w as neuroNoiseFragmentShader,A as perlinNoiseFragmentShader,R as smokeRingFragmentShader,P as steppedSimplexNoiseFragmentShader,O as voronoiFragmentShader,T as wavesFragmentShader};
|
|
213
1077
|
//# sourceMappingURL=index.js.map
|