gl-transitions 1.44.0 → 1.46.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-transitions",
3
- "version": "1.44.0",
3
+ "version": "1.46.0",
4
4
  "description": "The open collection of GL Transitions",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,18 @@
1
+ // Author: Sergey Kosarevsky
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/corporateshark/21d2fdd24c706952dc8c
4
+
5
+ uniform float pixelSize; // = 50.0
6
+
7
+ vec4 transition(vec2 uv) {
8
+ float T = progress;
9
+ float half_ = 0.5;
10
+ float size = (T < half_) ? mix(1.0, pixelSize, T / half_) : mix(pixelSize, 1.0, (T - half_) / half_);
11
+ float D = size * 0.005;
12
+ // Remap UV to center the mosaic pattern
13
+ vec2 UV = (uv - 0.5) / D;
14
+ vec2 coord = clamp(D * (ceil(UV - 0.5)) + 0.5, 0.0, 1.0);
15
+ vec4 C0 = getFromColor(coord);
16
+ vec4 C1 = getToColor(coord);
17
+ return mix(C0, C1, T);
18
+ }
@@ -0,0 +1,13 @@
1
+ // Author: nwoeanhinnogaehr
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/nwoeanhinnogaehr/b93818de23d4511fde10
4
+
5
+ uniform float blocksize; // = 0.02
6
+
7
+ float rand(vec2 co) {
8
+ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
9
+ }
10
+
11
+ vec4 transition(vec2 uv) {
12
+ return mix(getFromColor(uv), getToColor(uv), step(rand(floor(uv / blocksize)), progress));
13
+ }
@@ -33,8 +33,8 @@ float rand (vec2 co) {
33
33
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
34
34
  }
35
35
 
36
- vec3 crossFade(in vec2 uv, in float dissolve) {
37
- return mix(getFromColor(uv).rgb, getToColor(uv).rgb, dissolve);
36
+ vec4 crossFade(in vec2 uv, in float dissolve) {
37
+ return mix(getFromColor(uv), getToColor(uv), dissolve);
38
38
  }
39
39
 
40
40
  vec4 transition(vec2 uv) {
@@ -47,7 +47,7 @@ vec4 transition(vec2 uv) {
47
47
  // Mirrored sinusoidal loop. 0->strength then strength->0
48
48
  float strength = Sinusoidal_easeInOut(0.0, strength, 0.5, progress);
49
49
 
50
- vec3 color = vec3(0.0);
50
+ vec4 color = vec4(0.0);
51
51
  float total = 0.0;
52
52
  vec2 toCenter = center - texCoord;
53
53
 
@@ -60,5 +60,5 @@ vec4 transition(vec2 uv) {
60
60
  color += crossFade(texCoord + toCenter * percent * strength, dissolve) * weight;
61
61
  total += weight;
62
62
  }
63
- return vec4(color / total, 1.0);
63
+ return color / total;
64
64
  }
@@ -0,0 +1,43 @@
1
+ // Author: Sergey Kosarevsky
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/corporateshark/b9f8e5675c647e615419
4
+
5
+ uniform float blurSize; // = 0.02
6
+
7
+ // 12-tap Poisson disk
8
+ // https://github.com/spite/Wagner/blob/master/fragment-shaders/poisson-disc-blur-fs.glsl
9
+
10
+ vec4 transition(vec2 uv) {
11
+ float T = progress;
12
+ float half_ = 0.5;
13
+ float D = (T < half_) ? mix(0.0, blurSize, T / half_) : mix(blurSize, 0.0, (T - half_) / half_);
14
+ vec4 C0 = getFromColor(uv);
15
+ vec4 C1 = getToColor(uv);
16
+ C0 += getFromColor(vec2(-0.326, -0.406) * D + uv);
17
+ C1 += getToColor(vec2(-0.326, -0.406) * D + uv);
18
+ C0 += getFromColor(vec2(-0.840, -0.074) * D + uv);
19
+ C1 += getToColor(vec2(-0.840, -0.074) * D + uv);
20
+ C0 += getFromColor(vec2(-0.696, 0.457) * D + uv);
21
+ C1 += getToColor(vec2(-0.696, 0.457) * D + uv);
22
+ C0 += getFromColor(vec2(-0.203, 0.621) * D + uv);
23
+ C1 += getToColor(vec2(-0.203, 0.621) * D + uv);
24
+ C0 += getFromColor(vec2( 0.962, -0.195) * D + uv);
25
+ C1 += getToColor(vec2( 0.962, -0.195) * D + uv);
26
+ C0 += getFromColor(vec2( 0.473, -0.480) * D + uv);
27
+ C1 += getToColor(vec2( 0.473, -0.480) * D + uv);
28
+ C0 += getFromColor(vec2( 0.519, 0.767) * D + uv);
29
+ C1 += getToColor(vec2( 0.519, 0.767) * D + uv);
30
+ C0 += getFromColor(vec2( 0.185, -0.893) * D + uv);
31
+ C1 += getToColor(vec2( 0.185, -0.893) * D + uv);
32
+ C0 += getFromColor(vec2( 0.507, 0.064) * D + uv);
33
+ C1 += getToColor(vec2( 0.507, 0.064) * D + uv);
34
+ C0 += getFromColor(vec2( 0.896, 0.412) * D + uv);
35
+ C1 += getToColor(vec2( 0.896, 0.412) * D + uv);
36
+ C0 += getFromColor(vec2(-0.322, -0.933) * D + uv);
37
+ C1 += getToColor(vec2(-0.322, -0.933) * D + uv);
38
+ C0 += getFromColor(vec2(-0.792, -0.598) * D + uv);
39
+ C1 += getToColor(vec2(-0.792, -0.598) * D + uv);
40
+ C0 /= 13.0;
41
+ C1 /= 13.0;
42
+ return mix(C0, C1, T);
43
+ }
@@ -0,0 +1,9 @@
1
+ // Author: nwoeanhinnogaehr
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/nwoeanhinnogaehr/f6fc39f4cfcbb97f96a6
4
+
5
+ vec4 transition(vec2 uv) {
6
+ vec4 a = getFromColor((uv - vec2(progress, 0.0)) / vec2(1.0 - progress, 1.0));
7
+ vec4 b = getToColor(uv / vec2(progress, 1.0));
8
+ return mix(a, b, step(uv.x, progress));
9
+ }
@@ -0,0 +1,26 @@
1
+ // Author: nwoeanhinnogaehr
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/nwoeanhinnogaehr/b185145363d65751009b
4
+
5
+ // HSV functions from http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
6
+
7
+ vec3 hsv2rgb(vec3 c) {
8
+ const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
9
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
10
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
11
+ }
12
+
13
+ vec3 rgb2hsv(vec3 c) {
14
+ const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
15
+ vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
16
+ vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
17
+ float d = q.x - min(q.w, q.y);
18
+ return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + 0.001)), d / (q.x + 0.001), q.x);
19
+ }
20
+
21
+ vec4 transition(vec2 uv) {
22
+ vec3 a = rgb2hsv(getFromColor(uv).rgb);
23
+ vec3 b = rgb2hsv(getToColor(uv).rgb);
24
+ vec3 m = mix(a, b, progress);
25
+ return vec4(hsv2rgb(m), 1.0);
26
+ }
@@ -0,0 +1,54 @@
1
+ // Author: JustKirillS
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/JustKirillS/714f095318834f4d2375de872c53af1e
4
+
5
+ uniform ivec2 size; // = ivec2(4, 4)
6
+ uniform float pause; // = 0.1
7
+ uniform float dividerWidth; // = 0.005
8
+
9
+ float rand(vec2 co) {
10
+ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
11
+ }
12
+
13
+ float getDelta(vec2 p) {
14
+ vec2 rectangleSize = 1.0 / vec2(size);
15
+ vec2 rectanglePos = floor(vec2(size) * p);
16
+ float top = rectangleSize.y * (rectanglePos.y + 1.0);
17
+ float bottom = rectangleSize.y * rectanglePos.y;
18
+ float left = rectangleSize.x * rectanglePos.x;
19
+ float right = rectangleSize.x * (rectanglePos.x + 1.0);
20
+ float minX = min(abs(p.x - left), abs(p.x - right));
21
+ float minY = min(abs(p.y - top), abs(p.y - bottom));
22
+ return min(minX, minY);
23
+ }
24
+
25
+ vec4 transition(vec2 uv) {
26
+ if (progress < pause) {
27
+ float currentProg = progress / pause;
28
+ float a = 1.0;
29
+ if (getDelta(uv) < dividerWidth) { a = 1.0 - currentProg; }
30
+ return mix(vec4(0.0, 0.0, 0.0, 1.0), getFromColor(uv), a);
31
+ } else if (progress < 1.0 - pause) {
32
+ if (getDelta(uv) < dividerWidth) {
33
+ return vec4(0.0, 0.0, 0.0, 1.0);
34
+ }
35
+ float currentProg = (progress - pause) / (1.0 - pause * 2.0);
36
+ vec2 rectanglePos = floor(vec2(size) * uv);
37
+ float r = rand(rectanglePos) - 0.1;
38
+ float cp = smoothstep(0.0, 1.0 - r, currentProg);
39
+ float rectangleSize = 1.0 / float(size.x);
40
+ float delta = rectanglePos.x * rectangleSize;
41
+ float offset = rectangleSize / 2.0 + delta;
42
+ vec2 p = uv;
43
+ p.x = (p.x - offset) / abs(cp - 0.5) * 0.5 + offset;
44
+ vec4 a = getFromColor(p);
45
+ vec4 b = getToColor(p);
46
+ float s = step(abs(float(size.x) * (uv.x - delta) - 0.5), abs(cp - 0.5));
47
+ return vec4(mix(b, a, step(cp, 0.5)).rgb * s, 1.0);
48
+ } else {
49
+ float currentProg = (progress - 1.0 + pause) / pause;
50
+ float a = 1.0;
51
+ if (getDelta(uv) < dividerWidth) { a = currentProg; }
52
+ return mix(vec4(0.0, 0.0, 0.0, 1.0), getToColor(uv), a);
53
+ }
54
+ }
@@ -0,0 +1,11 @@
1
+ // Author: nwoeanhinnogaehr
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/nwoeanhinnogaehr/408045772d255df97520
4
+
5
+ vec4 transition(vec2 uv) {
6
+ vec2 q = uv;
7
+ uv.x = (uv.x - 0.5) / abs(progress - 0.5) * 0.5 + 0.5;
8
+ vec4 a = getFromColor(uv);
9
+ vec4 b = getToColor(uv);
10
+ return vec4(mix(a, b, step(0.5, progress)).rgb * step(abs(q.x - 0.5), abs(progress - 0.5)), 1.0);
11
+ }
@@ -0,0 +1,59 @@
1
+ // Author: numb3r23
2
+ // License: MIT
3
+ // Ported from https://gist.github.com/numb3r23/169781bb76f310e2bfde
4
+
5
+ uniform ivec2 tileCount; // = ivec2(8, 8)
6
+ uniform bool flipX; // = true
7
+ uniform bool flipY; // = false
8
+
9
+ vec4 transition(vec2 uv) {
10
+ vec2 tileSize = 1.0 / vec2(tileCount);
11
+ vec2 posInTile = fract(uv * vec2(tileCount));
12
+ vec2 tileNum = floor(uv * vec2(tileCount));
13
+ float countTiles = float(tileCount.x * tileCount.y);
14
+
15
+ // Diagonal wave from bottom-left to top-right
16
+ float offset = (tileNum.y + tileNum.x * float(tileCount.y)) / (sqrt(countTiles) * 2.0);
17
+ float timeOffset = clamp((progress - offset) * countTiles, 0.0, 0.5);
18
+ float sinTime = 1.0 - abs(cos(fract(timeOffset) * 3.1415926));
19
+
20
+ vec2 texC = posInTile;
21
+
22
+ if (sinTime <= 0.5) {
23
+ if (flipX) {
24
+ if (texC.x < sinTime || texC.x > 1.0 - sinTime)
25
+ return getFromColor(uv);
26
+ texC.x = texC.x < 0.5
27
+ ? (texC.x - sinTime) * 0.5 / (0.5 - sinTime)
28
+ : (texC.x - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
29
+ }
30
+ if (flipY) {
31
+ if (texC.y < sinTime || texC.y > 1.0 - sinTime)
32
+ return getFromColor(uv);
33
+ texC.y = texC.y < 0.5
34
+ ? (texC.y - sinTime) * 0.5 / (0.5 - sinTime)
35
+ : (texC.y - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
36
+ }
37
+ vec2 globalUV = tileNum * tileSize + texC * tileSize;
38
+ return getFromColor(globalUV);
39
+ } else {
40
+ if (flipX) {
41
+ if (texC.x > sinTime || texC.x < 1.0 - sinTime)
42
+ return getToColor(uv);
43
+ texC.x = texC.x < 0.5
44
+ ? (texC.x - sinTime) * 0.5 / (0.5 - sinTime)
45
+ : (texC.x - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
46
+ texC.x = 1.0 - texC.x;
47
+ }
48
+ if (flipY) {
49
+ if (texC.y > sinTime || texC.y < 1.0 - sinTime)
50
+ return getToColor(uv);
51
+ texC.y = texC.y < 0.5
52
+ ? (texC.y - sinTime) * 0.5 / (0.5 - sinTime)
53
+ : (texC.y - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
54
+ texC.y = 1.0 - texC.y;
55
+ }
56
+ vec2 globalUV = tileNum * tileSize + texC * tileSize;
57
+ return getToColor(globalUV);
58
+ }
59
+ }