@paper-design/shaders 0.0.28 → 0.0.30-backbuffer-experiment.0
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/dist/index.d.ts +2 -2
- package/dist/shader-mount.d.ts +5 -1
- package/dist/shader-sizing.d.ts +1 -1
- package/dist/shaders/dithering.d.ts +21 -7
- package/dist/shaders/grain-gradient.d.ts +12 -2
- package/package.json +2 -2
- package/dist/get-shader-color-from-string.js +0 -93
- package/dist/get-shader-color-from-string.js.map +0 -7
- package/dist/get-shader-noise-texture.js +0 -23
- package/dist/get-shader-noise-texture.js.map +0 -7
- package/dist/index.js +0 -97
- package/dist/index.js.map +0 -7
- package/dist/shader-color-spaces.js +0 -96
- package/dist/shader-color-spaces.js.map +0 -7
- package/dist/shader-mount.js +0 -568
- package/dist/shader-mount.js.map +0 -7
- package/dist/shader-sizing.js +0 -196
- package/dist/shader-sizing.js.map +0 -7
- package/dist/shader-utils.js +0 -59
- package/dist/shader-utils.js.map +0 -7
- package/dist/shaders/dithering.js +0 -197
- package/dist/shaders/dithering.js.map +0 -7
- package/dist/shaders/dot-grid.js +0 -100
- package/dist/shaders/dot-grid.js.map +0 -7
- package/dist/shaders/dot-orbit.js +0 -120
- package/dist/shaders/dot-orbit.js.map +0 -7
- package/dist/shaders/god-rays.js +0 -134
- package/dist/shaders/god-rays.js.map +0 -7
- package/dist/shaders/grain-gradient.js +0 -219
- package/dist/shaders/grain-gradient.js.map +0 -7
- package/dist/shaders/liquid-metal.js +0 -224
- package/dist/shaders/liquid-metal.js.map +0 -7
- package/dist/shaders/mesh-gradient.js +0 -97
- package/dist/shaders/mesh-gradient.js.map +0 -7
- package/dist/shaders/metaballs.js +0 -109
- package/dist/shaders/metaballs.js.map +0 -7
- package/dist/shaders/neuro-noise.js +0 -66
- package/dist/shaders/neuro-noise.js.map +0 -7
- package/dist/shaders/perlin-noise.js +0 -193
- package/dist/shaders/perlin-noise.js.map +0 -7
- package/dist/shaders/pulsing-border.js +0 -218
- package/dist/shaders/pulsing-border.js.map +0 -7
- package/dist/shaders/simplex-noise.js +0 -103
- package/dist/shaders/simplex-noise.js.map +0 -7
- package/dist/shaders/smoke-ring.js +0 -141
- package/dist/shaders/smoke-ring.js.map +0 -7
- package/dist/shaders/spiral.js +0 -75
- package/dist/shaders/spiral.js.map +0 -7
- package/dist/shaders/swirl.js +0 -80
- package/dist/shaders/swirl.js.map +0 -7
- package/dist/shaders/voronoi.js +0 -143
- package/dist/shaders/voronoi.js.map +0 -7
- package/dist/shaders/warp.js +0 -124
- package/dist/shaders/warp.js.map +0 -7
- package/dist/shaders/waves.js +0 -60
- package/dist/shaders/waves.js.map +0 -7
- package/dist/types.js +0 -6
- package/dist/types.js.map +0 -7
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
-
* Paper Shaders *
|
|
3
|
-
* https://github.com/paper-design/shaders *
|
|
4
|
-
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
-
|
|
6
|
-
import { sizingVariablesDeclaration } from "../shader-sizing";
|
|
7
|
-
import { declarePI, declareRandom, declareRotate } from "../shader-utils";
|
|
8
|
-
const dotOrbitMeta = {
|
|
9
|
-
maxColorCount: 10
|
|
10
|
-
};
|
|
11
|
-
const dotOrbitFragmentShader = `#version 300 es
|
|
12
|
-
precision highp float;
|
|
13
|
-
|
|
14
|
-
uniform float u_time;
|
|
15
|
-
|
|
16
|
-
uniform vec4 u_colors[${dotOrbitMeta.maxColorCount}];
|
|
17
|
-
uniform float u_colorsCount;
|
|
18
|
-
uniform float u_stepsPerColor;
|
|
19
|
-
uniform float u_size;
|
|
20
|
-
uniform float u_sizeRange;
|
|
21
|
-
uniform float u_spreading;
|
|
22
|
-
|
|
23
|
-
${sizingVariablesDeclaration}
|
|
24
|
-
|
|
25
|
-
out vec4 fragColor;
|
|
26
|
-
|
|
27
|
-
${declarePI}
|
|
28
|
-
${declareRandom}
|
|
29
|
-
${declareRotate}
|
|
30
|
-
|
|
31
|
-
vec2 random2(vec2 p) {
|
|
32
|
-
return vec2(random(p), random(200. * p));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
vec3 voronoiShape(vec2 uv, float time) {
|
|
36
|
-
vec2 i_uv = floor(uv);
|
|
37
|
-
vec2 f_uv = fract(uv);
|
|
38
|
-
|
|
39
|
-
float spreading = .25 * clamp(u_spreading, 0., 1.);
|
|
40
|
-
|
|
41
|
-
float minDist = 1.;
|
|
42
|
-
vec2 randomizer = vec2(0.);
|
|
43
|
-
for (int y = -1; y <= 1; y++) {
|
|
44
|
-
for (int x = -1; x <= 1; x++) {
|
|
45
|
-
vec2 tileOffset = vec2(float(x), float(y));
|
|
46
|
-
vec2 rand = random2(i_uv + tileOffset);
|
|
47
|
-
vec2 cellCenter = vec2(.5 + 1e-4);
|
|
48
|
-
cellCenter += spreading * cos(time + TWO_PI * rand);
|
|
49
|
-
cellCenter -= .5;
|
|
50
|
-
cellCenter = rotate(cellCenter, random(vec2(rand.x, rand.y)) + .1 * time);
|
|
51
|
-
cellCenter += .5;
|
|
52
|
-
float dist = length(tileOffset + cellCenter - f_uv);
|
|
53
|
-
if (dist < minDist) {
|
|
54
|
-
minDist = dist;
|
|
55
|
-
randomizer = rand;
|
|
56
|
-
}
|
|
57
|
-
minDist = min(minDist, dist);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return vec3(minDist, randomizer);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
void main() {
|
|
65
|
-
|
|
66
|
-
vec2 shape_uv = v_patternUV;
|
|
67
|
-
shape_uv += .5;
|
|
68
|
-
shape_uv *= .015;
|
|
69
|
-
|
|
70
|
-
float t = u_time;
|
|
71
|
-
|
|
72
|
-
vec3 voronoi = voronoiShape(shape_uv, t) + 1e-4;
|
|
73
|
-
|
|
74
|
-
float radius = .25 * clamp(u_size, 0., 1.) - .5 * clamp(u_sizeRange, 0., 1.) * voronoi[2];
|
|
75
|
-
float dist = voronoi[0];
|
|
76
|
-
float edgeWidth = fwidth(dist);
|
|
77
|
-
float dots = smoothstep(radius + edgeWidth, radius - edgeWidth, dist);
|
|
78
|
-
|
|
79
|
-
float shape = voronoi[1];
|
|
80
|
-
|
|
81
|
-
float mixer = shape * (u_colorsCount - 1.);
|
|
82
|
-
mixer = (shape - .5 / u_colorsCount) * u_colorsCount;
|
|
83
|
-
float steps = max(1., u_stepsPerColor);
|
|
84
|
-
|
|
85
|
-
vec4 gradient = u_colors[0];
|
|
86
|
-
gradient.rgb *= gradient.a;
|
|
87
|
-
for (int i = 1; i < ${dotOrbitMeta.maxColorCount}; i++) {
|
|
88
|
-
if (i >= int(u_colorsCount)) break;
|
|
89
|
-
float localT = clamp(mixer - float(i - 1), 0.0, 1.0);
|
|
90
|
-
localT = round(localT * steps) / steps;
|
|
91
|
-
vec4 c = u_colors[i];
|
|
92
|
-
c.rgb *= c.a;
|
|
93
|
-
gradient = mix(gradient, c, localT);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if ((mixer < 0.) || (mixer > (u_colorsCount - 1.))) {
|
|
97
|
-
float localT = mixer + 1.;
|
|
98
|
-
if (mixer > (u_colorsCount - 1.)) {
|
|
99
|
-
localT = mixer - (u_colorsCount - 1.);
|
|
100
|
-
}
|
|
101
|
-
localT = round(localT * steps) / steps;
|
|
102
|
-
vec4 cFst = u_colors[0];
|
|
103
|
-
cFst.rgb *= cFst.a;
|
|
104
|
-
vec4 cLast = u_colors[int(u_colorsCount - 1.)];
|
|
105
|
-
cLast.rgb *= cLast.a;
|
|
106
|
-
gradient = mix(cLast, cFst, localT);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
gradient *= dots;
|
|
110
|
-
vec3 color = gradient.rgb;
|
|
111
|
-
float opacity = gradient.a;
|
|
112
|
-
|
|
113
|
-
fragColor = vec4(color, opacity);
|
|
114
|
-
}
|
|
115
|
-
`;
|
|
116
|
-
export {
|
|
117
|
-
dotOrbitFragmentShader,
|
|
118
|
-
dotOrbitMeta
|
|
119
|
-
};
|
|
120
|
-
//# sourceMappingURL=dot-orbit.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/shaders/dot-orbit.ts"],
|
|
4
|
-
"sourcesContent": ["import type { vec4 } from '../types';\nimport type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declarePI, declareRandom, declareRotate } from '../shader-utils';\n\nexport const dotOrbitMeta = {\n maxColorCount: 10,\n} as const;\n\n/**\n * Dot Pattern with dot moving around their grid position\n * The artwork by Ksenia Kondrashova\n * Renders a dot pattern with dot placed in the center of each cell of animated Voronoi diagram\n *\n * Uniforms include:\n * - u_colors (vec4[]): Input RGBA colors\n * - u_colorsCount (float): Number of active colors (`u_colors` length)\n * - u_stepsPerColor (float): Discretization of the color transition\n * - u_size (float, 0 .. 1): Base dot radius (relative to cell size)\n * - u_sizeRange (float, 0 .. 1): Dot radius to vary between the cells\n * - u_spreading (float, 0 .. 1): the distance each dot can move around the regular grid\n */\nexport const dotOrbitFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\n\nuniform vec4 u_colors[${dotOrbitMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform float u_stepsPerColor;\nuniform float u_size;\nuniform float u_sizeRange;\nuniform float u_spreading;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${declareRandom}\n${declareRotate}\n\nvec2 random2(vec2 p) {\n return vec2(random(p), random(200. * p));\n}\n\nvec3 voronoiShape(vec2 uv, float time) {\n vec2 i_uv = floor(uv);\n vec2 f_uv = fract(uv);\n \n float spreading = .25 * clamp(u_spreading, 0., 1.);\n\n float minDist = 1.;\n vec2 randomizer = vec2(0.);\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec2 tileOffset = vec2(float(x), float(y));\n vec2 rand = random2(i_uv + tileOffset);\n vec2 cellCenter = vec2(.5 + 1e-4);\n cellCenter += spreading * cos(time + TWO_PI * rand);\n cellCenter -= .5;\n cellCenter = rotate(cellCenter, random(vec2(rand.x, rand.y)) + .1 * time);\n cellCenter += .5;\n float dist = length(tileOffset + cellCenter - f_uv);\n if (dist < minDist) {\n minDist = dist;\n randomizer = rand;\n }\n minDist = min(minDist, dist);\n }\n }\n\n return vec3(minDist, randomizer);\n}\n\nvoid main() {\n \n vec2 shape_uv = v_patternUV;\n shape_uv += .5;\n shape_uv *= .015;\n \n float t = u_time;\n\n vec3 voronoi = voronoiShape(shape_uv, t) + 1e-4;\n\n float radius = .25 * clamp(u_size, 0., 1.) - .5 * clamp(u_sizeRange, 0., 1.) * voronoi[2];\n float dist = voronoi[0];\n float edgeWidth = fwidth(dist);\n float dots = smoothstep(radius + edgeWidth, radius - edgeWidth, dist);\n\n float shape = voronoi[1];\n \n float mixer = shape * (u_colorsCount - 1.);\n mixer = (shape - .5 / u_colorsCount) * u_colorsCount;\n float steps = max(1., u_stepsPerColor);\n \n vec4 gradient = u_colors[0];\n gradient.rgb *= gradient.a;\n for (int i = 1; i < ${dotOrbitMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n float localT = clamp(mixer - float(i - 1), 0.0, 1.0);\n localT = round(localT * steps) / steps;\n vec4 c = u_colors[i];\n c.rgb *= c.a;\n gradient = mix(gradient, c, localT);\n }\n\n if ((mixer < 0.) || (mixer > (u_colorsCount - 1.))) {\n float localT = mixer + 1.;\n if (mixer > (u_colorsCount - 1.)) {\n localT = mixer - (u_colorsCount - 1.);\n }\n localT = round(localT * steps) / steps;\n vec4 cFst = u_colors[0];\n cFst.rgb *= cFst.a;\n vec4 cLast = u_colors[int(u_colorsCount - 1.)];\n cLast.rgb *= cLast.a;\n gradient = mix(cLast, cFst, localT);\n }\n\n gradient *= dots;\n vec3 color = gradient.rgb;\n float opacity = gradient.a;\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface DotOrbitUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_size: number;\n u_sizeRange: number;\n u_spreading: number;\n u_stepsPerColor: number;\n}\n\nexport interface DotOrbitParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n size?: number;\n sizeRange?: number;\n spreading?: number;\n stepsPerColor?: number;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,eAAe,qBAAqB;AAEjD,MAAM,eAAe;AAAA,EAC1B,eAAe;AACjB;AAeO,MAAM,yBAAiC;AAAA;AAAA;AAAA;AAAA;AAAA,wBAKtB,aAAa,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,aAAa;AAAA,EACb,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBA0DS,aAAa,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/shaders/god-rays.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
-
* Paper Shaders *
|
|
3
|
-
* https://github.com/paper-design/shaders *
|
|
4
|
-
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
-
|
|
6
|
-
import { sizingVariablesDeclaration } from "../shader-sizing";
|
|
7
|
-
import { declarePI, declareRandom, declareRotate, colorBandingFix } from "../shader-utils";
|
|
8
|
-
const godRaysMeta = {
|
|
9
|
-
maxColorCount: 5
|
|
10
|
-
};
|
|
11
|
-
const godRaysFragmentShader = `#version 300 es
|
|
12
|
-
precision mediump float;
|
|
13
|
-
|
|
14
|
-
uniform float u_time;
|
|
15
|
-
|
|
16
|
-
uniform vec4 u_colorBack;
|
|
17
|
-
uniform vec4 u_colors[${godRaysMeta.maxColorCount}];
|
|
18
|
-
uniform float u_colorsCount;
|
|
19
|
-
|
|
20
|
-
uniform float u_frequency;
|
|
21
|
-
uniform float u_spotty;
|
|
22
|
-
uniform float u_midSize;
|
|
23
|
-
uniform float u_midIntensity;
|
|
24
|
-
uniform float u_density;
|
|
25
|
-
uniform float u_blending;
|
|
26
|
-
|
|
27
|
-
${sizingVariablesDeclaration}
|
|
28
|
-
|
|
29
|
-
out vec4 fragColor;
|
|
30
|
-
|
|
31
|
-
${declarePI}
|
|
32
|
-
${declareRandom}
|
|
33
|
-
${declareRotate}
|
|
34
|
-
|
|
35
|
-
float hash(float n) {
|
|
36
|
-
return fract(sin(n * 43758.5453123) * 43758.5453123);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
float valueNoise(vec2 uv) {
|
|
40
|
-
vec2 i = floor(uv);
|
|
41
|
-
vec2 f = fract(uv);
|
|
42
|
-
|
|
43
|
-
float a = random(i);
|
|
44
|
-
float b = random(i + vec2(1.0, 0.0));
|
|
45
|
-
float c = random(i + vec2(0.0, 1.0));
|
|
46
|
-
float d = random(i + vec2(1.0, 1.0));
|
|
47
|
-
|
|
48
|
-
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
49
|
-
|
|
50
|
-
float x1 = mix(a, b, u.x);
|
|
51
|
-
float x2 = mix(c, d, u.x);
|
|
52
|
-
return mix(x1, x2, u.y);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
float raysShape(vec2 uv, float r, float freq, float density, float radius) {
|
|
56
|
-
float a = atan(uv.y, uv.x);
|
|
57
|
-
vec2 left = vec2(a * freq, r);
|
|
58
|
-
vec2 right = vec2(mod(a, TWO_PI) * freq, r);
|
|
59
|
-
float n_left = pow(valueNoise(left), density);
|
|
60
|
-
float n_right = pow(valueNoise(right), density);
|
|
61
|
-
float shape = mix(n_right, n_left, smoothstep(-.15, .15, uv.x));
|
|
62
|
-
return shape;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
void main() {
|
|
66
|
-
vec2 shape_uv = v_objectUV;
|
|
67
|
-
|
|
68
|
-
float t = .2 * u_time;
|
|
69
|
-
|
|
70
|
-
float radius = length(shape_uv);
|
|
71
|
-
float spots = 5. * abs(u_spotty);
|
|
72
|
-
|
|
73
|
-
float density = 4. - 3. * clamp(u_density, 0., 1.);
|
|
74
|
-
|
|
75
|
-
float delta = 1. - smoothstep(0., 1., radius);
|
|
76
|
-
|
|
77
|
-
float middleShape = pow(u_midIntensity, .3) * smoothstep(abs(u_midSize), 0.02 * abs(u_midSize), 3.0 * radius);
|
|
78
|
-
middleShape = pow(middleShape, 5.0);
|
|
79
|
-
|
|
80
|
-
vec3 accumColor = vec3(0.0);
|
|
81
|
-
float accumAlpha = 0.0;
|
|
82
|
-
|
|
83
|
-
for (int i = 0; i < ${godRaysMeta.maxColorCount}; i++) {
|
|
84
|
-
if (i >= int(u_colorsCount)) break;
|
|
85
|
-
|
|
86
|
-
vec2 rotatedUV = rotate(shape_uv, float(i) + 1.0);
|
|
87
|
-
|
|
88
|
-
float r1 = radius * (1.0 + 0.4 * float(i)) - 3.0 * t;
|
|
89
|
-
float r2 = 0.5 * radius * (1.0 + spots) - 2.0 * t;
|
|
90
|
-
float f = mix(1.0, 3.0 + 0.5 * float(i), hash(float(i) + 10.0)) * u_frequency;
|
|
91
|
-
|
|
92
|
-
float ray = raysShape(rotatedUV, r1, 5.0 * f, density, radius);
|
|
93
|
-
ray *= raysShape(rotatedUV, r2, 4.0 * f, density, radius);
|
|
94
|
-
ray += (1. + 4. * ray) * middleShape;
|
|
95
|
-
ray = clamp(ray, 0.0, 1.0);
|
|
96
|
-
|
|
97
|
-
float srcAlpha = u_colors[i].a * ray;
|
|
98
|
-
vec3 srcColor = u_colors[i].rgb * srcAlpha;
|
|
99
|
-
|
|
100
|
-
vec3 alphaBlendColor = accumColor + (1.0 - accumAlpha) * srcColor;
|
|
101
|
-
float alphaBlendAlpha = accumAlpha + (1.0 - accumAlpha) * srcAlpha;
|
|
102
|
-
|
|
103
|
-
vec3 addBlendColor = accumColor + srcColor;
|
|
104
|
-
float addBlendAlpha = accumAlpha + srcAlpha;
|
|
105
|
-
|
|
106
|
-
accumColor = mix(alphaBlendColor, addBlendColor, u_blending);
|
|
107
|
-
accumAlpha = mix(alphaBlendAlpha, addBlendAlpha, u_blending);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
vec3 bgColor = u_colorBack.rgb * u_colorBack.a;
|
|
111
|
-
|
|
112
|
-
vec3 alphaBlendColor = accumColor + (1.0 - accumAlpha) * bgColor;
|
|
113
|
-
float alphaBlendAlpha = accumAlpha + (1.0 - accumAlpha) * u_colorBack.a;
|
|
114
|
-
|
|
115
|
-
vec3 addBlendColor = accumColor + bgColor;
|
|
116
|
-
float addBlendAlpha = accumAlpha + u_colorBack.a;
|
|
117
|
-
|
|
118
|
-
accumColor = mix(alphaBlendColor, addBlendColor, u_blending);
|
|
119
|
-
accumAlpha = mix(alphaBlendAlpha, addBlendAlpha, u_blending);
|
|
120
|
-
|
|
121
|
-
vec3 color = clamp(accumColor, 0.0, 1.0);
|
|
122
|
-
float opacity = clamp(accumAlpha, 0.0, 1.0);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
${colorBandingFix}
|
|
126
|
-
|
|
127
|
-
fragColor = vec4(color, opacity);
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
130
|
-
export {
|
|
131
|
-
godRaysFragmentShader,
|
|
132
|
-
godRaysMeta
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=god-rays.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/shaders/god-rays.ts"],
|
|
4
|
-
"sourcesContent": ["import type { vec4 } from '../types';\nimport type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declarePI, declareRandom, declareRotate, colorBandingFix } from '../shader-utils';\n\nexport const godRaysMeta = {\n maxColorCount: 5,\n} as const;\n\n/**\n * GodRays pattern\n * The artwork by Ksenia Kondrashova\n * Renders a number of circular shapes with gooey effect applied\n *\n * Uniforms include:\n *\n * - u_colorBack: background RGBA color\n * - uColors (vec4[]): Input RGBA colors\n * - u_frequency: the frequency of rays (the number of sectors)\n * - u_spotty: the density of spots in the rings (higher = more spots)\n * - u_midSize: the size of the central shape within the rings\n * - u_midIntensity: the influence of the central shape on the rings\n * - u_density (0 .. 1): the number of visible rays\n * - u_blending (0 .. 1): normal / additive blending\n */\nexport const godRaysFragmentShader: string = `#version 300 es\nprecision mediump float;\n\nuniform float u_time;\n\nuniform vec4 u_colorBack;\nuniform vec4 u_colors[${godRaysMeta.maxColorCount}];\nuniform float u_colorsCount;\n\nuniform float u_frequency;\nuniform float u_spotty;\nuniform float u_midSize;\nuniform float u_midIntensity;\nuniform float u_density;\nuniform float u_blending;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${declareRandom}\n${declareRotate}\n\nfloat hash(float n) {\n return fract(sin(n * 43758.5453123) * 43758.5453123);\n}\n\nfloat valueNoise(vec2 uv) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n float x1 = mix(a, b, u.x);\n float x2 = mix(c, d, u.x);\n return mix(x1, x2, u.y);\n}\n\nfloat raysShape(vec2 uv, float r, float freq, float density, float radius) {\n float a = atan(uv.y, uv.x);\n vec2 left = vec2(a * freq, r);\n vec2 right = vec2(mod(a, TWO_PI) * freq, r);\n float n_left = pow(valueNoise(left), density);\n float n_right = pow(valueNoise(right), density);\n float shape = mix(n_right, n_left, smoothstep(-.15, .15, uv.x));\n return shape;\n}\n\nvoid main() {\n vec2 shape_uv = v_objectUV;\n\n float t = .2 * u_time;\n\n float radius = length(shape_uv);\n float spots = 5. * abs(u_spotty);\n\n float density = 4. - 3. * clamp(u_density, 0., 1.);\n\n float delta = 1. - smoothstep(0., 1., radius);\n\n float middleShape = pow(u_midIntensity, .3) * smoothstep(abs(u_midSize), 0.02 * abs(u_midSize), 3.0 * radius);\n middleShape = pow(middleShape, 5.0);\n\n vec3 accumColor = vec3(0.0);\n float accumAlpha = 0.0;\n\n for (int i = 0; i < ${godRaysMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n\n vec2 rotatedUV = rotate(shape_uv, float(i) + 1.0);\n\n float r1 = radius * (1.0 + 0.4 * float(i)) - 3.0 * t;\n float r2 = 0.5 * radius * (1.0 + spots) - 2.0 * t;\n float f = mix(1.0, 3.0 + 0.5 * float(i), hash(float(i) + 10.0)) * u_frequency;\n\n float ray = raysShape(rotatedUV, r1, 5.0 * f, density, radius);\n ray *= raysShape(rotatedUV, r2, 4.0 * f, density, radius);\n ray += (1. + 4. * ray) * middleShape;\n ray = clamp(ray, 0.0, 1.0);\n\n float srcAlpha = u_colors[i].a * ray;\n vec3 srcColor = u_colors[i].rgb * srcAlpha;\n\n vec3 alphaBlendColor = accumColor + (1.0 - accumAlpha) * srcColor;\n float alphaBlendAlpha = accumAlpha + (1.0 - accumAlpha) * srcAlpha;\n\n vec3 addBlendColor = accumColor + srcColor;\n float addBlendAlpha = accumAlpha + srcAlpha;\n\n accumColor = mix(alphaBlendColor, addBlendColor, u_blending);\n accumAlpha = mix(alphaBlendAlpha, addBlendAlpha, u_blending);\n }\n\n vec3 bgColor = u_colorBack.rgb * u_colorBack.a;\n\n vec3 alphaBlendColor = accumColor + (1.0 - accumAlpha) * bgColor;\n float alphaBlendAlpha = accumAlpha + (1.0 - accumAlpha) * u_colorBack.a;\n\n vec3 addBlendColor = accumColor + bgColor;\n float addBlendAlpha = accumAlpha + u_colorBack.a;\n\n accumColor = mix(alphaBlendColor, addBlendColor, u_blending);\n accumAlpha = mix(alphaBlendAlpha, addBlendAlpha, u_blending);\n\n vec3 color = clamp(accumColor, 0.0, 1.0);\n float opacity = clamp(accumAlpha, 0.0, 1.0);\n\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface GodRaysUniforms extends ShaderSizingUniforms {\n u_colorBack: [number, number, number, number];\n u_colors: vec4[];\n u_colorsCount: number;\n u_spotty: number;\n u_midSize: number;\n u_midIntensity: number;\n u_frequency: number;\n u_density: number;\n u_blending: number;\n}\n\nexport interface GodRaysParams extends ShaderSizingParams, ShaderMotionParams {\n colorBack?: string;\n colors?: string[];\n spotty?: number;\n midSize?: number;\n midIntensity?: number;\n frequency?: number;\n density?: number;\n blending?: number;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,WAAW,eAAe,eAAe,uBAAuB;AAElE,MAAM,cAAc;AAAA,EACzB,eAAe;AACjB;AAkBO,MAAM,wBAAgC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAMrB,YAAY,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAU/C,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,aAAa;AAAA,EACb,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAkDS,YAAY,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA0C7C,eAAe;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
-
* Paper Shaders *
|
|
3
|
-
* https://github.com/paper-design/shaders *
|
|
4
|
-
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
-
|
|
6
|
-
import { sizingVariablesDeclaration } from "../shader-sizing";
|
|
7
|
-
import { declareSimplexNoise, declarePI, declareRandom, colorBandingFix } from "../shader-utils";
|
|
8
|
-
const grainGradientMeta = {
|
|
9
|
-
maxColorCount: 7
|
|
10
|
-
};
|
|
11
|
-
const grainGradientFragmentShader = `#version 300 es
|
|
12
|
-
precision highp float;
|
|
13
|
-
|
|
14
|
-
uniform float u_time;
|
|
15
|
-
uniform vec2 u_resolution;
|
|
16
|
-
uniform float u_pixelRatio;
|
|
17
|
-
|
|
18
|
-
uniform vec4 u_colors[${grainGradientMeta.maxColorCount}];
|
|
19
|
-
uniform float u_colorsCount;
|
|
20
|
-
uniform float u_softness;
|
|
21
|
-
uniform float u_intensity;
|
|
22
|
-
uniform float u_noise;
|
|
23
|
-
uniform float u_shape;
|
|
24
|
-
|
|
25
|
-
${sizingVariablesDeclaration}
|
|
26
|
-
|
|
27
|
-
out vec4 fragColor;
|
|
28
|
-
|
|
29
|
-
${declarePI}
|
|
30
|
-
${declareSimplexNoise}
|
|
31
|
-
${declareRandom}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
float noisenoise(vec2 st) {
|
|
35
|
-
vec2 i = floor(st);
|
|
36
|
-
vec2 f = fract(st);
|
|
37
|
-
float a = random(i);
|
|
38
|
-
float b = random(i + vec2(1.0, 0.0));
|
|
39
|
-
float c = random(i + vec2(0.0, 1.0));
|
|
40
|
-
float d = random(i + vec2(1.0, 1.0));
|
|
41
|
-
|
|
42
|
-
// Smoothstep for interpolation
|
|
43
|
-
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
44
|
-
|
|
45
|
-
// Do the interpolation as two nested mix operations
|
|
46
|
-
// If you try to do this in one big operation, there's enough precision loss to be off by 1px at cell boundaries
|
|
47
|
-
float x1 = mix(a, b, u.x);
|
|
48
|
-
float x2 = mix(c, d, u.x);
|
|
49
|
-
return mix(x1, x2, u.y);
|
|
50
|
-
}
|
|
51
|
-
|
|
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_4(vec2 n) {
|
|
61
|
-
float total = 0.0, amplitude = .2;
|
|
62
|
-
for (int i = 0; i < 4; i++) {
|
|
63
|
-
total += noise(n) * amplitude;
|
|
64
|
-
n += n;
|
|
65
|
-
amplitude *= 0.6;
|
|
66
|
-
}
|
|
67
|
-
return total;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
vec2 truchet(vec2 uv, float idx){
|
|
72
|
-
idx = fract(((idx - .5) * 2.));
|
|
73
|
-
if (idx > 0.75) {
|
|
74
|
-
uv = vec2(1.0) - uv;
|
|
75
|
-
} else if (idx > 0.5) {
|
|
76
|
-
uv = vec2(1.0 - uv.x, uv.y);
|
|
77
|
-
} else if (idx > 0.25) {
|
|
78
|
-
uv = 1.0 - vec2(1.0 - uv.x, uv.y);
|
|
79
|
-
}
|
|
80
|
-
return uv;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
void main() {
|
|
84
|
-
|
|
85
|
-
float t = .1 * u_time;
|
|
86
|
-
|
|
87
|
-
vec2 grain_uv = (gl_FragCoord.xy - .5 * u_resolution) / u_pixelRatio;
|
|
88
|
-
vec2 shape_uv = v_objectUV;
|
|
89
|
-
if (u_shape < 3.5) {
|
|
90
|
-
shape_uv = v_patternUV * .005;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
float shape = 0.;
|
|
95
|
-
|
|
96
|
-
if (u_shape < 1.5) {
|
|
97
|
-
// Sine wave
|
|
98
|
-
|
|
99
|
-
float wave = cos(.5 * shape_uv.x - 2. * t) * sin(1.5 * shape_uv.x + t) * (.75 + .25 * cos(3. * t));
|
|
100
|
-
shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);
|
|
101
|
-
|
|
102
|
-
} else if (u_shape < 2.5) {
|
|
103
|
-
// Grid (dots)
|
|
104
|
-
|
|
105
|
-
float stripeIdx = floor(2. * shape_uv.x / TWO_PI);
|
|
106
|
-
float rand = fract(sin(stripeIdx * 12.9898) * 43758.5453);
|
|
107
|
-
|
|
108
|
-
float speed = sign(rand - .5) * ceil(2. + rand);
|
|
109
|
-
shape = sin(shape_uv.x) * cos(shape_uv.y + speed * t);
|
|
110
|
-
shape = pow(shape, 4.);
|
|
111
|
-
|
|
112
|
-
} else if (u_shape < 3.5) {
|
|
113
|
-
// Truchet pattern
|
|
114
|
-
|
|
115
|
-
float n2 = noisenoise(shape_uv * .4 - 2.5 * t);
|
|
116
|
-
shape_uv.x += 10.;
|
|
117
|
-
shape_uv *= .6;
|
|
118
|
-
|
|
119
|
-
vec2 tile = truchet(fract(shape_uv), random(floor(shape_uv)));
|
|
120
|
-
|
|
121
|
-
float distance1 = length(tile);
|
|
122
|
-
float distance2 = length(tile - vec2(1.));
|
|
123
|
-
|
|
124
|
-
n2 -= .5;
|
|
125
|
-
n2 *= .1;
|
|
126
|
-
shape = smoothstep(.2, .55, distance1 + n2) * smoothstep(.8, .45, distance1 - n2);
|
|
127
|
-
shape += smoothstep(.2, .55, distance2 + n2) * smoothstep(.8, .45, distance2 - n2);
|
|
128
|
-
|
|
129
|
-
shape = pow(shape, 1.5);
|
|
130
|
-
|
|
131
|
-
} else if (u_shape < 4.5) {
|
|
132
|
-
// Corners
|
|
133
|
-
|
|
134
|
-
shape_uv *= .6;
|
|
135
|
-
vec2 outer = vec2(.5);
|
|
136
|
-
|
|
137
|
-
vec2 bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(2. * t), .2 - .1 * sin(3. * t)));
|
|
138
|
-
vec2 tr = smoothstep(vec2(0.), outer, 1. - shape_uv);
|
|
139
|
-
shape = 1. - bl.x * bl.y * tr.x * tr.y;
|
|
140
|
-
|
|
141
|
-
shape_uv = -shape_uv;
|
|
142
|
-
bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(2. * t), .2 - .1 * cos(3. * t)));
|
|
143
|
-
tr = smoothstep(vec2(0.), outer, 1. - shape_uv);
|
|
144
|
-
shape -= bl.x * bl.y * tr.x * tr.y;
|
|
145
|
-
|
|
146
|
-
shape = 1. - smoothstep(0., 1., shape);
|
|
147
|
-
|
|
148
|
-
} else if (u_shape < 5.5) {
|
|
149
|
-
// Ripple
|
|
150
|
-
|
|
151
|
-
shape_uv *= 2.;
|
|
152
|
-
float dist = length(.4 * shape_uv);
|
|
153
|
-
float waves = sin(pow(dist, 1.2) * 5. - 3. * t) * .5 + .5;
|
|
154
|
-
shape = waves;
|
|
155
|
-
|
|
156
|
-
} else if (u_shape < 6.5) {
|
|
157
|
-
// Blob
|
|
158
|
-
|
|
159
|
-
t *= 2.;
|
|
160
|
-
|
|
161
|
-
vec2 f1_traj = .25 * vec2(1.3 * sin(t), .2 + 1.3 * cos(.6 * t + 4.));
|
|
162
|
-
vec2 f2_traj = .2 * vec2(1.2 * sin(-t), 1.3 * sin(1.6 * t));
|
|
163
|
-
vec2 f3_traj = .25 * vec2(1.7 * cos(-.6 * t), cos(-1.6 * t));
|
|
164
|
-
vec2 f4_traj = .3 * vec2(1.4 * cos(.8 * t), 1.2 * sin(-.6 * t - 3.));
|
|
165
|
-
|
|
166
|
-
shape = .5 * pow(1. - clamp(0., 1., length(shape_uv + f1_traj)), 5.);
|
|
167
|
-
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f2_traj)), 5.);
|
|
168
|
-
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f3_traj)), 5.);
|
|
169
|
-
shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f4_traj)), 5.);
|
|
170
|
-
|
|
171
|
-
shape = smoothstep(.0, .9, shape);
|
|
172
|
-
float edge = smoothstep(.25, .3, shape);
|
|
173
|
-
shape = mix(.0, shape, edge);
|
|
174
|
-
|
|
175
|
-
} else {
|
|
176
|
-
// Sphere
|
|
177
|
-
|
|
178
|
-
shape_uv *= 2.;
|
|
179
|
-
float d = length(shape_uv);
|
|
180
|
-
float z = sqrt(1.0 - clamp(pow(d, 2.0), 0.0, 1.0));
|
|
181
|
-
vec3 pos = vec3(shape_uv, z);
|
|
182
|
-
vec3 lightPos = normalize(vec3(cos(3. * t), 0.8, sin(2.5 * t)));
|
|
183
|
-
float lighting = dot(lightPos, pos);
|
|
184
|
-
float edge = smoothstep(1., .97, d);
|
|
185
|
-
shape = mix(.1, .5 + .5 * lighting, edge);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
float snoise05 = snoise(grain_uv * .5);
|
|
189
|
-
float grainDist = snoise(grain_uv * .2) * snoise05 - fbm_4(.002 * grain_uv + 10.) - fbm_4(.003 * grain_uv);
|
|
190
|
-
float noise = clamp(.6 * snoise05 - fbm_4(.4 * grain_uv) - fbm_4(.001 * grain_uv), 0., 1.);
|
|
191
|
-
|
|
192
|
-
shape += u_intensity * 2. / u_colorsCount * (grainDist + .5);
|
|
193
|
-
shape += u_noise * 10. / u_colorsCount * noise;
|
|
194
|
-
|
|
195
|
-
float edge_w = fwidth(shape);
|
|
196
|
-
|
|
197
|
-
float mixer = shape;
|
|
198
|
-
vec3 gradient = u_colors[0].rgb;
|
|
199
|
-
for (int i = 1; i < ${grainGradientMeta.maxColorCount}; i++) {
|
|
200
|
-
if (i >= int(u_colorsCount)) break;
|
|
201
|
-
|
|
202
|
-
vec2 borders = vec2(float(i) - u_softness, float(i) + u_softness + edge_w) / u_colorsCount;
|
|
203
|
-
float localT = smoothstep(borders[0], borders[1], mixer);
|
|
204
|
-
gradient = mix(gradient, u_colors[i].rgb, localT);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
vec3 color = gradient;
|
|
208
|
-
float opacity = 1.;
|
|
209
|
-
|
|
210
|
-
${colorBandingFix}
|
|
211
|
-
|
|
212
|
-
fragColor = vec4(color, opacity);
|
|
213
|
-
}
|
|
214
|
-
`;
|
|
215
|
-
export {
|
|
216
|
-
grainGradientFragmentShader,
|
|
217
|
-
grainGradientMeta
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=grain-gradient.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/shaders/grain-gradient.ts"],
|
|
4
|
-
"sourcesContent": ["import type { vec4 } from '../types';\nimport type { ShaderMotionParams } from '../shader-mount';\nimport { sizingVariablesDeclaration, type ShaderSizingParams, type ShaderSizingUniforms } from '../shader-sizing';\nimport { declareSimplexNoise, declarePI, declareRandom, colorBandingFix } from '../shader-utils';\n\nexport const grainGradientMeta = {\n maxColorCount: 7,\n} as const;\n\n/**\n * Grainy Gradient Ksenia Kondrashova\n */\nexport const grainGradientFragmentShader: string = `#version 300 es\nprecision highp float;\n\nuniform float u_time;\nuniform vec2 u_resolution;\nuniform float u_pixelRatio;\n\nuniform vec4 u_colors[${grainGradientMeta.maxColorCount}];\nuniform float u_colorsCount;\nuniform float u_softness;\nuniform float u_intensity;\nuniform float u_noise;\nuniform float u_shape;\n\n${sizingVariablesDeclaration}\n\nout vec4 fragColor;\n\n${declarePI}\n${declareSimplexNoise}\n${declareRandom}\n\n\nfloat noisenoise(vec2 st) {\n vec2 i = floor(st);\n vec2 f = fract(st);\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n // Smoothstep for interpolation\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n // Do the interpolation as two nested mix operations\n // If you try to do this in one big operation, there's enough precision loss to be off by 1px at cell boundaries\n float x1 = mix(a, b, u.x);\n float x2 = mix(c, d, u.x);\n return mix(x1, x2, u.y);\n}\n\nfloat rand(vec2 n) {\n return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);\n}\nfloat noise(vec2 n) {\n const vec2 d = vec2(0.0, 1.0);\n vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));\n return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);\n}\nfloat fbm_4(vec2 n) {\n float total = 0.0, amplitude = .2;\n for (int i = 0; i < 4; i++) {\n total += noise(n) * amplitude;\n n += n;\n amplitude *= 0.6;\n }\n return total;\n}\n\n\nvec2 truchet(vec2 uv, float idx){\n idx = fract(((idx - .5) * 2.));\n if (idx > 0.75) {\n uv = vec2(1.0) - uv;\n } else if (idx > 0.5) {\n uv = vec2(1.0 - uv.x, uv.y);\n } else if (idx > 0.25) {\n uv = 1.0 - vec2(1.0 - uv.x, uv.y);\n }\n return uv;\n}\n\nvoid main() {\n \n float t = .1 * u_time;\n \n vec2 grain_uv = (gl_FragCoord.xy - .5 * u_resolution) / u_pixelRatio;\n vec2 shape_uv = v_objectUV;\n if (u_shape < 3.5) {\n shape_uv = v_patternUV * .005;\n }\n \n \n float shape = 0.;\n \n if (u_shape < 1.5) {\n // Sine wave\n \n float wave = cos(.5 * shape_uv.x - 2. * t) * sin(1.5 * shape_uv.x + t) * (.75 + .25 * cos(3. * t));\n shape = 1. - smoothstep(-1., 1., shape_uv.y + wave);\n \n } else if (u_shape < 2.5) {\n // Grid (dots)\n\n float stripeIdx = floor(2. * shape_uv.x / TWO_PI);\n float rand = fract(sin(stripeIdx * 12.9898) * 43758.5453);\n\n float speed = sign(rand - .5) * ceil(2. + rand);\n shape = sin(shape_uv.x) * cos(shape_uv.y + speed * t); \n shape = pow(shape, 4.);\n \n } else if (u_shape < 3.5) {\n // Truchet pattern\n \n float n2 = noisenoise(shape_uv * .4 - 2.5 * t);\n shape_uv.x += 10.;\n shape_uv *= .6;\n\n vec2 tile = truchet(fract(shape_uv), random(floor(shape_uv)));\n\n float distance1 = length(tile);\n float distance2 = length(tile - vec2(1.));\n\n n2 -= .5;\n n2 *= .1;\n shape = smoothstep(.2, .55, distance1 + n2) * smoothstep(.8, .45, distance1 - n2);\n shape += smoothstep(.2, .55, distance2 + n2) * smoothstep(.8, .45, distance2 - n2);\n \n shape = pow(shape, 1.5);\n \n } else if (u_shape < 4.5) { \n // Corners\n\n shape_uv *= .6;\n vec2 outer = vec2(.5);\n \n vec2 bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(2. * t), .2 - .1 * sin(3. * t)));\n vec2 tr = smoothstep(vec2(0.), outer, 1. - shape_uv);\n shape = 1. - bl.x * bl.y * tr.x * tr.y;\n \n shape_uv = -shape_uv;\n bl = smoothstep(vec2(0.), outer, shape_uv + vec2(.1 + .1 * sin(2. * t), .2 - .1 * cos(3. * t)));\n tr = smoothstep(vec2(0.), outer, 1. - shape_uv);\n shape -= bl.x * bl.y * tr.x * tr.y; \n \n shape = 1. - smoothstep(0., 1., shape);\n \n } else if (u_shape < 5.5) { \n // Ripple\n \n shape_uv *= 2.;\n float dist = length(.4 * shape_uv);\n float waves = sin(pow(dist, 1.2) * 5. - 3. * t) * .5 + .5;\n shape = waves;\n\n } else if (u_shape < 6.5) {\n // Blob\n\n t *= 2.;\n \n vec2 f1_traj = .25 * vec2(1.3 * sin(t), .2 + 1.3 * cos(.6 * t + 4.));\n vec2 f2_traj = .2 * vec2(1.2 * sin(-t), 1.3 * sin(1.6 * t));\n vec2 f3_traj = .25 * vec2(1.7 * cos(-.6 * t), cos(-1.6 * t));\n vec2 f4_traj = .3 * vec2(1.4 * cos(.8 * t), 1.2 * sin(-.6 * t - 3.));\n \n shape = .5 * pow(1. - clamp(0., 1., length(shape_uv + f1_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f2_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f3_traj)), 5.);\n shape += .5 * pow(1. - clamp(0., 1., length(shape_uv + f4_traj)), 5.);\n \n shape = smoothstep(.0, .9, shape);\n float edge = smoothstep(.25, .3, shape);\n shape = mix(.0, shape, edge);\n \n } else {\n // Sphere\n\n shape_uv *= 2.;\n float d = length(shape_uv);\n float z = sqrt(1.0 - clamp(pow(d, 2.0), 0.0, 1.0));\n vec3 pos = vec3(shape_uv, z);\n vec3 lightPos = normalize(vec3(cos(3. * t), 0.8, sin(2.5 * t)));\n float lighting = dot(lightPos, pos);\n float edge = smoothstep(1., .97, d);\n shape = mix(.1, .5 + .5 * lighting, edge);\n }\n \n float snoise05 = snoise(grain_uv * .5);\n float grainDist = snoise(grain_uv * .2) * snoise05 - fbm_4(.002 * grain_uv + 10.) - fbm_4(.003 * grain_uv);\n float noise = clamp(.6 * snoise05 - fbm_4(.4 * grain_uv) - fbm_4(.001 * grain_uv), 0., 1.);\n\n shape += u_intensity * 2. / u_colorsCount * (grainDist + .5);\n shape += u_noise * 10. / u_colorsCount * noise; \n\n float edge_w = fwidth(shape);\n \n float mixer = shape;\n vec3 gradient = u_colors[0].rgb;\n for (int i = 1; i < ${grainGradientMeta.maxColorCount}; i++) {\n if (i >= int(u_colorsCount)) break;\n\n vec2 borders = vec2(float(i) - u_softness, float(i) + u_softness + edge_w) / u_colorsCount;\n float localT = smoothstep(borders[0], borders[1], mixer);\n gradient = mix(gradient, u_colors[i].rgb, localT);\n }\n\n vec3 color = gradient;\n float opacity = 1.;\n\n ${colorBandingFix}\n\n fragColor = vec4(color, opacity);\n}\n`;\n\nexport interface GrainGradientUniforms extends ShaderSizingUniforms {\n u_colors: vec4[];\n u_colorsCount: number;\n u_softness: number;\n u_intensity: number;\n u_noise: number;\n u_shape: number;\n}\n\nexport interface GrainGradientParams extends ShaderSizingParams, ShaderMotionParams {\n colors?: string[];\n softness?: number;\n intensity?: number;\n noise?: number;\n shape?: number;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAEA,SAAS,kCAAsF;AAC/F,SAAS,qBAAqB,WAAW,eAAe,uBAAuB;AAExE,MAAM,oBAAoB;AAAA,EAC/B,eAAe;AACjB;AAKO,MAAM,8BAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAO3B,kBAAkB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOrD,0BAA0B;AAAA;AAAA;AAAA;AAAA,EAI1B,SAAS;AAAA,EACT,mBAAmB;AAAA,EACnB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAwKS,kBAAkB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWnD,eAAe;AAAA;AAAA;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|