@remotion/transitions 4.0.465 → 4.0.467
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/book-flip.js +2 -0
- package/cross-zoom.js +2 -0
- package/crosswarp.js +2 -0
- package/dist/TransitionSeries.js +16 -6
- package/dist/esm/book-flip.mjs +434 -0
- package/dist/esm/cross-zoom.mjs +377 -0
- package/dist/esm/crosswarp.mjs +331 -0
- package/dist/esm/dissolve.mjs +4 -3
- package/dist/esm/dreamy-zoom.mjs +348 -0
- package/dist/esm/film-burn.mjs +443 -0
- package/dist/esm/index.mjs +1020 -209
- package/dist/esm/linear-blur.mjs +343 -0
- package/dist/esm/ripple.mjs +342 -0
- package/dist/esm/swap.mjs +394 -0
- package/dist/esm/zoom-blur.mjs +4 -3
- package/dist/esm/zoom-in-out.mjs +4 -3
- package/dist/html-in-canvas-presentation.js +4 -5
- package/dist/index.d.ts +13 -3
- package/dist/index.js +9 -1
- package/dist/presentations/book-flip.d.ts +14 -0
- package/dist/presentations/book-flip.js +255 -0
- package/dist/presentations/cross-zoom.d.ts +13 -0
- package/dist/presentations/cross-zoom.js +199 -0
- package/dist/presentations/crosswarp.d.ts +11 -0
- package/dist/presentations/crosswarp.js +154 -0
- package/dist/presentations/dreamy-zoom.d.ts +14 -0
- package/dist/presentations/dreamy-zoom.js +169 -0
- package/dist/presentations/film-burn.d.ts +13 -0
- package/dist/presentations/film-burn.js +265 -0
- package/dist/presentations/linear-blur.d.ts +13 -0
- package/dist/presentations/linear-blur.js +164 -0
- package/dist/presentations/ripple.d.ts +14 -0
- package/dist/presentations/ripple.js +164 -0
- package/dist/presentations/swap.d.ts +15 -0
- package/dist/presentations/swap.js +212 -0
- package/dist/types.d.ts +1 -1
- package/dreamy-zoom.js +2 -0
- package/film-burn.js +2 -0
- package/linear-blur.js +2 -0
- package/package.json +80 -8
- package/ripple.js +2 -0
- package/swap.js +2 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
// src/html-in-canvas-presentation.tsx
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import {
|
|
4
|
+
AbsoluteFill,
|
|
5
|
+
HTML_IN_CANVAS_UNSUPPORTED_MESSAGE,
|
|
6
|
+
HtmlInCanvas,
|
|
7
|
+
Internals,
|
|
8
|
+
useDelayRender
|
|
9
|
+
} from "remotion";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
var HtmlInCanvasPresentation = ({
|
|
12
|
+
children,
|
|
13
|
+
onElementImage,
|
|
14
|
+
onUnmount,
|
|
15
|
+
presentationProgress,
|
|
16
|
+
presentationDirection,
|
|
17
|
+
shader,
|
|
18
|
+
effects,
|
|
19
|
+
passedProps,
|
|
20
|
+
bothEnteringAndExiting
|
|
21
|
+
}) => {
|
|
22
|
+
if (!HtmlInCanvas.isSupported()) {
|
|
23
|
+
throw new Error(HTML_IN_CANVAS_UNSUPPORTED_MESSAGE);
|
|
24
|
+
}
|
|
25
|
+
const canvasRef = useRef(null);
|
|
26
|
+
const canvasSubtreeStyle = useMemo(() => {
|
|
27
|
+
return {
|
|
28
|
+
width: "100%",
|
|
29
|
+
height: "100%",
|
|
30
|
+
position: "absolute",
|
|
31
|
+
top: 0,
|
|
32
|
+
left: 0,
|
|
33
|
+
right: 0,
|
|
34
|
+
bottom: 0
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const [offscreenCanvas] = useState(() => new OffscreenCanvas(1, 1));
|
|
38
|
+
const passedPropsRef = useRef(passedProps);
|
|
39
|
+
passedPropsRef.current = passedProps;
|
|
40
|
+
const memoizedEffects = Internals.useMemoizedEffects({
|
|
41
|
+
effects: effects ?? [],
|
|
42
|
+
overrideId: null
|
|
43
|
+
});
|
|
44
|
+
const effectsRef = useRef(memoizedEffects);
|
|
45
|
+
effectsRef.current = memoizedEffects;
|
|
46
|
+
const [instance] = useState(() => shader(offscreenCanvas));
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
return () => {
|
|
49
|
+
instance.cleanup();
|
|
50
|
+
};
|
|
51
|
+
}, [offscreenCanvas, instance]);
|
|
52
|
+
const chainState = Internals.useEffectChainState();
|
|
53
|
+
const { delayRender, continueRender } = useDelayRender();
|
|
54
|
+
const draw = useCallback(async (prevImage, nextImage, progress) => {
|
|
55
|
+
if (!canvasRef.current) {
|
|
56
|
+
throw new Error("Canvas not found");
|
|
57
|
+
}
|
|
58
|
+
const handle = delayRender("onPaint");
|
|
59
|
+
if (!prevImage && !nextImage) {
|
|
60
|
+
continueRender(handle);
|
|
61
|
+
instance.clear();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const width = prevImage?.width ?? nextImage?.width ?? 0;
|
|
65
|
+
const height = prevImage?.height ?? nextImage?.height ?? 0;
|
|
66
|
+
if (width === 0 || height === 0) {
|
|
67
|
+
continueRender(handle);
|
|
68
|
+
instance.clear();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
offscreenCanvas.width = width;
|
|
72
|
+
offscreenCanvas.height = height;
|
|
73
|
+
instance.draw({
|
|
74
|
+
prevImage,
|
|
75
|
+
nextImage,
|
|
76
|
+
width,
|
|
77
|
+
height,
|
|
78
|
+
time: progress,
|
|
79
|
+
passedProps: passedPropsRef.current
|
|
80
|
+
});
|
|
81
|
+
await Internals.runEffectChain({
|
|
82
|
+
state: chainState.get(width, height),
|
|
83
|
+
source: offscreenCanvas,
|
|
84
|
+
effects: effectsRef.current ?? [],
|
|
85
|
+
width,
|
|
86
|
+
height,
|
|
87
|
+
output: canvasRef.current
|
|
88
|
+
});
|
|
89
|
+
continueRender(handle);
|
|
90
|
+
}, [chainState, instance, offscreenCanvas, continueRender, delayRender]);
|
|
91
|
+
const passThrough = bothEnteringAndExiting && presentationDirection === "exiting";
|
|
92
|
+
useLayoutEffect(() => {
|
|
93
|
+
if (passThrough) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const canvas = canvasRef.current;
|
|
97
|
+
if (!canvas) {
|
|
98
|
+
throw new Error("Canvas not found");
|
|
99
|
+
}
|
|
100
|
+
canvas.layoutSubtree = true;
|
|
101
|
+
const onPaint = () => {
|
|
102
|
+
const firstChild = canvas.firstChild;
|
|
103
|
+
if (!firstChild) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const elementImage = canvas.captureElementImage(firstChild);
|
|
107
|
+
onElementImage(elementImage, draw);
|
|
108
|
+
};
|
|
109
|
+
canvas.addEventListener("paint", onPaint);
|
|
110
|
+
return () => {
|
|
111
|
+
canvas.removeEventListener("paint", onPaint);
|
|
112
|
+
};
|
|
113
|
+
}, [onElementImage, presentationDirection, draw, passThrough]);
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
if (passThrough) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const canvas = canvasRef.current;
|
|
119
|
+
if (!canvas) {
|
|
120
|
+
throw new Error("Canvas not found");
|
|
121
|
+
}
|
|
122
|
+
canvas.requestPaint?.();
|
|
123
|
+
}, [presentationProgress, passThrough, memoizedEffects]);
|
|
124
|
+
useLayoutEffect(() => {
|
|
125
|
+
if (passThrough) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
return () => {
|
|
129
|
+
onUnmount();
|
|
130
|
+
};
|
|
131
|
+
}, [onUnmount, passThrough]);
|
|
132
|
+
useLayoutEffect(() => {
|
|
133
|
+
if (passThrough) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const canvas = canvasRef.current;
|
|
137
|
+
if (!canvas) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
141
|
+
canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
|
|
142
|
+
canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
|
|
143
|
+
});
|
|
144
|
+
observer.observe(canvas, { box: "device-pixel-content-box" });
|
|
145
|
+
}, [passThrough]);
|
|
146
|
+
if (passThrough) {
|
|
147
|
+
return children;
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ jsx(AbsoluteFill, {
|
|
150
|
+
children: /* @__PURE__ */ jsx("canvas", {
|
|
151
|
+
ref: canvasRef,
|
|
152
|
+
style: canvasSubtreeStyle,
|
|
153
|
+
children
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
var makeHtmlInCanvasPresentation = (shader) => {
|
|
158
|
+
const CompWithShader = (props) => {
|
|
159
|
+
const { passedProps, ...otherProps } = props;
|
|
160
|
+
const { effects, ...restPassedProps } = props.passedProps;
|
|
161
|
+
return /* @__PURE__ */ jsx(HtmlInCanvasPresentation, {
|
|
162
|
+
shader,
|
|
163
|
+
passedProps: restPassedProps,
|
|
164
|
+
effects,
|
|
165
|
+
...otherProps
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
return (props) => {
|
|
169
|
+
return {
|
|
170
|
+
component: CompWithShader,
|
|
171
|
+
props
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/presentations/film-burn.tsx
|
|
177
|
+
var DEFAULT_SEED = 2.31;
|
|
178
|
+
var VERTEX_SHADER = `#version 300 es
|
|
179
|
+
in vec2 a_pos;
|
|
180
|
+
out vec2 v_uv;
|
|
181
|
+
void main() {
|
|
182
|
+
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
183
|
+
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
184
|
+
}`;
|
|
185
|
+
var FRAGMENT_SHADER = `#version 300 es
|
|
186
|
+
precision highp float;
|
|
187
|
+
|
|
188
|
+
uniform sampler2D u_prev;
|
|
189
|
+
uniform sampler2D u_next;
|
|
190
|
+
uniform float u_time;
|
|
191
|
+
uniform float u_seed;
|
|
192
|
+
|
|
193
|
+
in vec2 v_uv;
|
|
194
|
+
out vec4 outColor;
|
|
195
|
+
|
|
196
|
+
#define PI 3.14159265358979323
|
|
197
|
+
#define CLAMPS(x) clamp(x, 0.0, 1.0)
|
|
198
|
+
#define REPEATS 50.0
|
|
199
|
+
|
|
200
|
+
float sigmoid(float x, float a) {
|
|
201
|
+
float b = pow(x * 2.0, a) / 2.0;
|
|
202
|
+
if (x > 0.5) {
|
|
203
|
+
b = 1.0 - pow(2.0 - (x * 2.0), a) / 2.0;
|
|
204
|
+
}
|
|
205
|
+
return b;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
float rand(float co) {
|
|
209
|
+
return fract(sin((co * 24.9898) + u_seed) * 43758.5453);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
float rand(vec2 co) {
|
|
213
|
+
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
float apow(float a, float b) {
|
|
217
|
+
return pow(abs(a), b) * sign(b);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
vec3 pow3(vec3 a, vec3 b) {
|
|
221
|
+
return vec3(apow(a.r, b.r), apow(a.g, b.g), apow(a.b, b.b));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
float smoothMix(float a, float b, float c) {
|
|
225
|
+
return mix(a, b, sigmoid(c, 2.0));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
float random(vec2 co, float shft) {
|
|
229
|
+
co += 10.0;
|
|
230
|
+
return smoothMix(
|
|
231
|
+
fract(
|
|
232
|
+
sin(
|
|
233
|
+
dot(
|
|
234
|
+
co.xy,
|
|
235
|
+
vec2(12.9898 + (floor(shft) * 0.5), 78.233 + u_seed)
|
|
236
|
+
)
|
|
237
|
+
) * 43758.5453
|
|
238
|
+
),
|
|
239
|
+
fract(
|
|
240
|
+
sin(
|
|
241
|
+
dot(
|
|
242
|
+
co.xy,
|
|
243
|
+
vec2(12.9898 + (floor(shft + 1.0) * 0.5), 78.233 + u_seed)
|
|
244
|
+
)
|
|
245
|
+
) * 43758.5453
|
|
246
|
+
),
|
|
247
|
+
fract(shft)
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
float smoothRandom(vec2 co, float shft) {
|
|
252
|
+
return smoothMix(
|
|
253
|
+
smoothMix(
|
|
254
|
+
random(floor(co), shft),
|
|
255
|
+
random(floor(co + vec2(1.0, 0.0)), shft),
|
|
256
|
+
fract(co.x)
|
|
257
|
+
),
|
|
258
|
+
smoothMix(
|
|
259
|
+
random(floor(co + vec2(0.0, 1.0)), shft),
|
|
260
|
+
random(floor(co + vec2(1.0, 1.0)), shft),
|
|
261
|
+
fract(co.x)
|
|
262
|
+
),
|
|
263
|
+
fract(co.y)
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
vec4 sampleTexture(vec2 p, float progress) {
|
|
268
|
+
return mix(texture(u_prev, p), texture(u_next, p), sigmoid(progress, 10.0));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
vec4 transition(vec2 p, float progress) {
|
|
272
|
+
vec3 f = vec3(0.0);
|
|
273
|
+
for (float i = 0.0; i < 13.0; i++) {
|
|
274
|
+
f += sin(((p.x * rand(i) * 6.0) + (progress * 8.0)) + rand(i + 1.43)) *
|
|
275
|
+
sin(
|
|
276
|
+
((p.y * rand(i + 4.4) * 6.0) + (progress * 6.0)) +
|
|
277
|
+
rand(i + 2.4)
|
|
278
|
+
);
|
|
279
|
+
f += 1.0 - CLAMPS(
|
|
280
|
+
length(
|
|
281
|
+
p -
|
|
282
|
+
vec2(
|
|
283
|
+
smoothRandom(vec2(progress * 1.3), i + 1.0),
|
|
284
|
+
smoothRandom(vec2(progress * 0.5), i + 6.25)
|
|
285
|
+
)
|
|
286
|
+
) * mix(20.0, 70.0, rand(i))
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
f += 4.0;
|
|
291
|
+
f /= 11.0;
|
|
292
|
+
f = pow3(
|
|
293
|
+
f * vec3(1.0, 0.7, 0.6),
|
|
294
|
+
vec3(1.0, 2.0 - sin(progress * PI), 1.3)
|
|
295
|
+
);
|
|
296
|
+
f *= sin(progress * PI);
|
|
297
|
+
|
|
298
|
+
p -= 0.5;
|
|
299
|
+
p *= 1.0 + (smoothRandom(vec2(progress * 5.0), 6.3) * sin(progress * PI) * 0.05);
|
|
300
|
+
p += 0.5;
|
|
301
|
+
|
|
302
|
+
vec4 blurredImage = vec4(0.0);
|
|
303
|
+
float blurAmount = sin(progress * PI) * 0.03;
|
|
304
|
+
for (float i = 0.0; i < REPEATS; i++) {
|
|
305
|
+
vec2 q = vec2(
|
|
306
|
+
cos(degrees((i / REPEATS) * 360.0)),
|
|
307
|
+
sin(degrees((i / REPEATS) * 360.0))
|
|
308
|
+
) * (rand(vec2(i, p.x + p.y)) + blurAmount);
|
|
309
|
+
vec2 uv2 = p + (q * blurAmount);
|
|
310
|
+
blurredImage += sampleTexture(uv2, progress);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
blurredImage /= REPEATS;
|
|
314
|
+
return blurredImage + vec4(f, 0.0);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
void main() {
|
|
318
|
+
float progress = 1.0 - u_time;
|
|
319
|
+
outColor = transition(v_uv, progress);
|
|
320
|
+
}`;
|
|
321
|
+
var compileShader = (gl, source, type) => {
|
|
322
|
+
const shader = gl.createShader(type);
|
|
323
|
+
if (!shader) {
|
|
324
|
+
throw new Error("Failed to create shader");
|
|
325
|
+
}
|
|
326
|
+
gl.shaderSource(shader, source);
|
|
327
|
+
gl.compileShader(shader);
|
|
328
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
329
|
+
const log = gl.getShaderInfoLog(shader);
|
|
330
|
+
gl.deleteShader(shader);
|
|
331
|
+
throw new Error(`Failed to compile shader: ${log}`);
|
|
332
|
+
}
|
|
333
|
+
return shader;
|
|
334
|
+
};
|
|
335
|
+
var createProgram = (gl) => {
|
|
336
|
+
const program = gl.createProgram();
|
|
337
|
+
if (!program) {
|
|
338
|
+
throw new Error("Failed to create WebGL program");
|
|
339
|
+
}
|
|
340
|
+
const vs = compileShader(gl, VERTEX_SHADER, gl.VERTEX_SHADER);
|
|
341
|
+
const fs = compileShader(gl, FRAGMENT_SHADER, gl.FRAGMENT_SHADER);
|
|
342
|
+
gl.attachShader(program, vs);
|
|
343
|
+
gl.attachShader(program, fs);
|
|
344
|
+
gl.linkProgram(program);
|
|
345
|
+
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
346
|
+
const log = gl.getProgramInfoLog(program);
|
|
347
|
+
gl.deleteProgram(program);
|
|
348
|
+
throw new Error(`Failed to link program: ${log}`);
|
|
349
|
+
}
|
|
350
|
+
return program;
|
|
351
|
+
};
|
|
352
|
+
var createTexture = (gl) => {
|
|
353
|
+
const tex = gl.createTexture();
|
|
354
|
+
if (!tex) {
|
|
355
|
+
throw new Error("Failed to create texture");
|
|
356
|
+
}
|
|
357
|
+
gl.bindTexture(gl.TEXTURE_2D, tex);
|
|
358
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
359
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
360
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
361
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
362
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, new Uint8Array([0, 0, 0, 0]));
|
|
363
|
+
return tex;
|
|
364
|
+
};
|
|
365
|
+
var filmBurnShader = (canvas) => {
|
|
366
|
+
const gl = canvas.getContext("webgl2", { premultipliedAlpha: true });
|
|
367
|
+
if (!gl) {
|
|
368
|
+
throw new Error("Failed to create WebGL2 context");
|
|
369
|
+
}
|
|
370
|
+
const program = createProgram(gl);
|
|
371
|
+
const prevTex = createTexture(gl);
|
|
372
|
+
const nextTex = createTexture(gl);
|
|
373
|
+
const vao = gl.createVertexArray();
|
|
374
|
+
gl.bindVertexArray(vao);
|
|
375
|
+
const buffer = gl.createBuffer();
|
|
376
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
377
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
|
|
378
|
+
const aPos = gl.getAttribLocation(program, "a_pos");
|
|
379
|
+
gl.enableVertexAttribArray(aPos);
|
|
380
|
+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
|
|
381
|
+
const uTime = gl.getUniformLocation(program, "u_time");
|
|
382
|
+
const uPrev = gl.getUniformLocation(program, "u_prev");
|
|
383
|
+
const uNext = gl.getUniformLocation(program, "u_next");
|
|
384
|
+
const uSeed = gl.getUniformLocation(program, "u_seed");
|
|
385
|
+
const cleanup = () => {
|
|
386
|
+
gl.deleteProgram(program);
|
|
387
|
+
gl.deleteTexture(prevTex);
|
|
388
|
+
gl.deleteTexture(nextTex);
|
|
389
|
+
};
|
|
390
|
+
const clear = () => {
|
|
391
|
+
gl.clearColor(0, 0, 0, 0);
|
|
392
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
393
|
+
};
|
|
394
|
+
const draw = ({
|
|
395
|
+
prevImage,
|
|
396
|
+
nextImage,
|
|
397
|
+
width,
|
|
398
|
+
height,
|
|
399
|
+
time,
|
|
400
|
+
passedProps
|
|
401
|
+
}) => {
|
|
402
|
+
const { seed = DEFAULT_SEED } = passedProps;
|
|
403
|
+
if (!prevImage && !nextImage) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (prevImage && (prevImage.width === 0 || prevImage.height === 0)) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (nextImage && (nextImage.width === 0 || nextImage.height === 0)) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
const effectiveTime = !prevImage ? 0 : !nextImage ? 1 : time;
|
|
413
|
+
gl.viewport(0, 0, width, height);
|
|
414
|
+
gl.clearColor(0, 0, 0, 0);
|
|
415
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
416
|
+
gl.useProgram(program);
|
|
417
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
418
|
+
gl.bindTexture(gl.TEXTURE_2D, prevTex);
|
|
419
|
+
if (prevImage) {
|
|
420
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, prevImage);
|
|
421
|
+
}
|
|
422
|
+
gl.uniform1i(uPrev, 0);
|
|
423
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
424
|
+
gl.bindTexture(gl.TEXTURE_2D, nextTex);
|
|
425
|
+
if (nextImage) {
|
|
426
|
+
gl.texElementImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, nextImage);
|
|
427
|
+
}
|
|
428
|
+
gl.uniform1i(uNext, 1);
|
|
429
|
+
gl.uniform1f(uTime, effectiveTime);
|
|
430
|
+
gl.uniform1f(uSeed, seed);
|
|
431
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
432
|
+
};
|
|
433
|
+
return {
|
|
434
|
+
clear,
|
|
435
|
+
cleanup,
|
|
436
|
+
draw
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
var filmBurn = makeHtmlInCanvasPresentation(filmBurnShader);
|
|
440
|
+
export {
|
|
441
|
+
filmBurnShader,
|
|
442
|
+
filmBurn
|
|
443
|
+
};
|