gl-transitions 1.67.0 → 1.69.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.67.0",
3
+ "version": "1.69.0",
4
4
  "description": "The open collection of GL Transitions",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -0,0 +1,156 @@
1
+ // Author: bread
2
+ // License: MIT
3
+ // Drop_Zone_Flicker.glsl
4
+ // gl-transitions compatible: progress, ratio, getFromColor, getToColor
5
+ uniform float frameRate; // = 24.0
6
+ uniform float rgbOffset; // = 0.014
7
+ uniform float blockAmount; // = 0.72
8
+ uniform float ghostAmount; // = 0.62
9
+ uniform float redCyan; // = 0.58
10
+ uniform float scanline; // = 0.075
11
+
12
+ float sat(float x) {
13
+ return clamp(x, 0.0, 1.0);
14
+ }
15
+
16
+ float hash12(vec2 p) {
17
+ p = fract(p * vec2(443.8975, 397.2973));
18
+ p += dot(p, p.yx + 19.19);
19
+ return fract(p.x * p.y);
20
+ }
21
+
22
+ vec2 safeUv(vec2 uv) {
23
+ return clamp(uv, vec2(0.001), vec2(0.999));
24
+ }
25
+
26
+ // 24fps reference-matched reveal curve.
27
+ // Non-monotonic on purpose: the reference flashes back to the old clip.
28
+ float frameReveal(float f) {
29
+ if (f < 0.5) return 0.00;
30
+ if (f < 1.5) return 0.28;
31
+ if (f < 2.5) return 0.43;
32
+ if (f < 3.5) return 0.46;
33
+ if (f < 4.5) return 0.38;
34
+ if (f < 5.5) return 0.48;
35
+ if (f < 6.5) return 0.26;
36
+ if (f < 7.5) return 0.10;
37
+ if (f < 8.5) return 0.00;
38
+ if (f < 9.5) return 0.00;
39
+ if (f < 10.5) return 0.30;
40
+ if (f < 11.5) return 0.58;
41
+ if (f < 12.5) return 1.00;
42
+ if (f < 13.5) return 0.70;
43
+ if (f < 14.5) return 0.42;
44
+ if (f < 15.5) return 0.55;
45
+ if (f < 16.5) return 0.72;
46
+ if (f < 17.5) return 0.88;
47
+ if (f < 18.5) return 0.34;
48
+ if (f < 19.5) return 0.48;
49
+ if (f < 20.5) return 0.56;
50
+ if (f < 21.5) return 0.76;
51
+ if (f < 22.5) return 0.93;
52
+ return 1.00;
53
+ }
54
+
55
+ float frameGlitch(float f) {
56
+ if (f < 0.5) return 0.00;
57
+ if (f < 6.5) return 0.92;
58
+ if (f < 10.5) return 0.38;
59
+ if (f < 11.5) return 0.78;
60
+ if (f < 12.5) return 0.12;
61
+ if (f < 17.5) return 0.74;
62
+ if (f < 22.5) return 0.88;
63
+ if (f < 23.5) return 0.28;
64
+ return 0.00;
65
+ }
66
+
67
+ vec4 chromaFrom(vec2 uv, float amt) {
68
+ vec2 o = vec2(amt, 0.0);
69
+ return vec4(
70
+ getFromColor(safeUv(uv + o)).r,
71
+ getFromColor(safeUv(uv)).g,
72
+ getFromColor(safeUv(uv - o)).b,
73
+ 1.0
74
+ );
75
+ }
76
+
77
+ vec4 chromaTo(vec2 uv, float amt) {
78
+ vec2 o = vec2(amt, 0.0);
79
+ return vec4(
80
+ getToColor(safeUv(uv - o)).r,
81
+ getToColor(safeUv(uv)).g,
82
+ getToColor(safeUv(uv + o)).b,
83
+ 1.0
84
+ );
85
+ }
86
+
87
+ float blockMask(vec2 uv, float f) {
88
+ vec2 big = floor(uv * vec2(4.0, 2.0));
89
+ vec2 small = floor(uv * vec2(8.0, 4.0));
90
+
91
+ float wide = step(0.48, hash12(vec2(big.x, f * 1.37)));
92
+ float chunks = step(0.56, hash12(small + vec2(f * 2.11, f * 0.73)));
93
+
94
+ float verticalCut = smoothstep(
95
+ -0.035,
96
+ 0.035,
97
+ uv.x - mix(0.18, 0.78, hash12(vec2(f, 4.7)))
98
+ );
99
+
100
+ return sat(mix(wide, chunks, 0.38) * 0.72 + verticalCut * 0.28);
101
+ }
102
+
103
+ vec4 transition(vec2 uv) {
104
+ if (progress <= 0.0) return getFromColor(uv);
105
+ if (progress >= 1.0) return getToColor(uv);
106
+
107
+ float f = floor(progress * frameRate);
108
+ float reveal = frameReveal(f);
109
+ float glitch = frameGlitch(f);
110
+
111
+ float rnd = hash12(vec2(f, 9.13));
112
+ vec2 jitter = vec2(
113
+ (rnd - 0.5) * 0.042,
114
+ (hash12(vec2(f, 2.71)) - 0.5) * 0.010
115
+ ) * glitch;
116
+
117
+ vec2 fromUv = safeUv(uv + jitter);
118
+ vec2 toUv = safeUv(uv - jitter * 0.55);
119
+
120
+ float block = blockMask(uv, f);
121
+ float localReveal = sat(
122
+ reveal +
123
+ (block - 0.5) * blockAmount * glitch +
124
+ (hash12(vec2(f, floor(uv.y * 9.0))) - 0.5) * 0.18 * glitch
125
+ );
126
+
127
+ localReveal = smoothstep(0.22, 0.78, localReveal);
128
+
129
+ vec4 oldClip = chromaFrom(fromUv, rgbOffset * glitch);
130
+ vec4 newClip = chromaTo(toUv, rgbOffset * glitch);
131
+
132
+ vec4 color = mix(oldClip, newClip, localReveal);
133
+
134
+ float leftWash = (1.0 - smoothstep(0.10, 0.78, uv.x)) * glitch;
135
+ float cyanWash = smoothstep(0.08, 0.62, uv.x) * (1.0 - smoothstep(0.86, 1.0, uv.x)) * glitch;
136
+
137
+ vec3 redGhost = oldClip.rgb * vec3(1.34, 0.42, 0.38);
138
+ vec3 cyanGhost = newClip.rgb * vec3(0.48, 1.12, 1.24);
139
+
140
+ color.rgb = mix(color.rgb, redGhost, leftWash * redCyan * 0.42);
141
+ color.rgb = mix(color.rgb, cyanGhost, cyanWash * redCyan * 0.30);
142
+
143
+ // Keeps the old circular "drop zone" visible as a translucent flash,
144
+ // especially after the first full new-frame hit.
145
+ float oldReturn = glitch * (1.0 - smoothstep(0.94, 1.0, reveal));
146
+ oldReturn *= 0.18 + 0.52 * (1.0 - abs(localReveal - 0.5) * 2.0);
147
+ color.rgb = mix(color.rgb, oldClip.rgb, oldReturn * ghostAmount);
148
+
149
+ float lines = sin((uv.y + f * 0.017) * 1080.0);
150
+ color.rgb += lines * scanline * glitch;
151
+
152
+ float exposurePulse = (hash12(vec2(f, 12.4)) - 0.35) * 0.10 * glitch;
153
+ color.rgb += exposurePulse;
154
+
155
+ return vec4(sat(color.r), sat(color.g), sat(color.b), 1.0);
156
+ }
@@ -0,0 +1,94 @@
1
+ // Author: bread
2
+ // License: MIT
3
+ // gl-transitions v1 compatible
4
+
5
+ uniform vec2 center; // = vec2(0.46, 0.52)
6
+ uniform float direction; // = -1.0
7
+ uniform float maxRotation; // = 1.95
8
+ uniform float peakZoom; // = 2.22
9
+ uniform float swirl; // = 2.85
10
+ uniform float barrel; // = 0.38
11
+ uniform float motionBlur; // = 1.0
12
+ uniform float switchStart; // = 0.30
13
+ uniform float switchEnd; // = 0.50
14
+ uniform float shadow; // = 0.16
15
+
16
+ float sat(float x) {
17
+ return clamp(x, 0.0, 1.0);
18
+ }
19
+
20
+ float ease(float x) {
21
+ x = sat(x);
22
+ return x * x * (3.0 - 2.0 * x);
23
+ }
24
+
25
+ float revolveEnvelope(float t) {
26
+ float rise = ease((t - 0.10) / 0.33);
27
+ float fall = 1.0 - ease((t - 0.43) / 0.29);
28
+ return rise * fall;
29
+ }
30
+
31
+ vec2 rotate2(vec2 p, float a) {
32
+ float s = sin(a);
33
+ float c = cos(a);
34
+ return vec2(c * p.x - s * p.y, s * p.x + c * p.y);
35
+ }
36
+
37
+ vec2 warpUv(vec2 uv, float t) {
38
+ float e = revolveEnvelope(t);
39
+
40
+ vec2 p = uv - center;
41
+ p.x *= ratio;
42
+
43
+ float r = length(p);
44
+ float edgeSpin = maxRotation * e;
45
+ float coreSpin = swirl * e * pow(1.0 - sat(r / 0.96), 1.55);
46
+ float visibleAngle = direction * (edgeSpin + coreSpin);
47
+
48
+ p = rotate2(p, -visibleAngle);
49
+
50
+ float sc = 1.0 + (peakZoom - 1.0) * pow(e, 0.85);
51
+ p /= sc;
52
+
53
+ float rr = length(p);
54
+ p *= 1.0 + barrel * e * rr * rr * 2.8;
55
+
56
+ p.x /= ratio;
57
+ return clamp(p + center, vec2(0.001), vec2(0.999));
58
+ }
59
+
60
+ vec4 sampleRevolve(vec2 uv, float t) {
61
+ vec2 p = warpUv(uv, t);
62
+ float reveal = smoothstep(switchStart, switchEnd, t);
63
+ return mix(getFromColor(p), getToColor(p), reveal);
64
+ }
65
+
66
+ vec4 transition(vec2 uv) {
67
+ if (progress <= 0.0) return getFromColor(uv);
68
+ if (progress >= 1.0) return getToColor(uv);
69
+
70
+ float e = revolveEnvelope(progress);
71
+ float span = 0.060 * motionBlur * e;
72
+
73
+ vec4 color = vec4(0.0);
74
+ float total = 0.0;
75
+
76
+ for (int i = -8; i <= 8; i++) {
77
+ float x = float(i) / 8.0;
78
+ float w = 1.0 - abs(x);
79
+ w = w * w + 0.01;
80
+
81
+ float t = sat(progress + x * span);
82
+ color += sampleRevolve(uv, t) * w;
83
+ total += w;
84
+ }
85
+
86
+ color /= total;
87
+
88
+ vec2 q = uv - vec2(0.5);
89
+ q.x *= ratio;
90
+ float vignette = 1.0 - shadow * e * smoothstep(0.35, 0.95, length(q));
91
+ color.rgb *= vignette;
92
+
93
+ return color;
94
+ }