@omnimedia/omnitool 1.1.0-4 → 1.1.0-5
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 +2 -1
- package/s/demo/routines/transitions-test.ts +43 -0
- package/s/features/transition/parts/fragment.ts +24 -0
- package/s/features/transition/parts/types.ts +94 -0
- package/s/features/transition/parts/uniforms.ts +29 -0
- package/s/features/transition/parts/vertex.ts +31 -0
- package/s/features/transition/transition.ts +60 -0
- package/x/demo/routines/transitions-test.d.ts +5 -0
- package/x/demo/routines/transitions-test.js +35 -0
- package/x/demo/routines/transitions-test.js.map +1 -0
- package/x/features/transition/parts/fragment.d.ts +1 -0
- package/x/features/transition/parts/fragment.js +25 -0
- package/x/features/transition/parts/fragment.js.map +1 -0
- package/x/features/transition/parts/types.d.ts +23 -0
- package/x/features/transition/parts/types.js +2 -0
- package/x/features/transition/parts/types.js.map +1 -0
- package/x/features/transition/parts/uniforms.d.ts +31 -0
- package/x/features/transition/parts/uniforms.js +27 -0
- package/x/features/transition/parts/uniforms.js.map +1 -0
- package/x/features/transition/parts/vertex.d.ts +1 -0
- package/x/features/transition/parts/vertex.js +32 -0
- package/x/features/transition/parts/vertex.js.map +1 -0
- package/x/features/transition/transition.d.ts +5 -0
- package/x/features/transition/transition.js +50 -0
- package/x/features/transition/transition.js.map +1 -0
- package/x/index.html +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnimedia/omnitool",
|
|
3
|
-
"version": "1.1.0-
|
|
3
|
+
"version": "1.1.0-5",
|
|
4
4
|
"description": "open source video processing tools",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Przemysław Gałęzki",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@e280/stz": "^0.0.0-34",
|
|
38
38
|
"@huggingface/transformers": "^3.7.1",
|
|
39
39
|
"comrade": "^0.0.3",
|
|
40
|
+
"gl-transitions": "^1.43.0",
|
|
40
41
|
"mediabunny": "^1.4.4",
|
|
41
42
|
"mp4-muxer": "^5.2.1",
|
|
42
43
|
"pixi.js": "^8.10.1",
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {Application, Sprite} from "pixi.js"
|
|
2
|
+
|
|
3
|
+
import {Driver} from "../../driver/driver.js"
|
|
4
|
+
import {DecoderSource} from "../../driver/fns/schematic.js"
|
|
5
|
+
import {makeTransition} from "../../features/transition/transition.js"
|
|
6
|
+
|
|
7
|
+
export async function setupTransitionsTest(driver: Driver, source: DecoderSource) {
|
|
8
|
+
const app = new Application()
|
|
9
|
+
await app.init({width: 300, height: 300, preference: "webgl"})
|
|
10
|
+
const sprite = new Sprite({width: 300, height: 300})
|
|
11
|
+
|
|
12
|
+
app.stage.addChild(sprite)
|
|
13
|
+
|
|
14
|
+
document.body.appendChild(app.canvas)
|
|
15
|
+
const transition = makeTransition({name: "circle", renderer: app.renderer})
|
|
16
|
+
|
|
17
|
+
async function run() {
|
|
18
|
+
const readables = driver.decode({
|
|
19
|
+
source,
|
|
20
|
+
async onFrame(frame) {
|
|
21
|
+
const texture = transition.render({
|
|
22
|
+
from: frame,
|
|
23
|
+
to: frame,
|
|
24
|
+
progress: 0.7,
|
|
25
|
+
width: app.canvas.width,
|
|
26
|
+
height: app.canvas.height
|
|
27
|
+
})
|
|
28
|
+
sprite.texture = texture
|
|
29
|
+
return frame
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
await driver.encode({
|
|
34
|
+
readables,
|
|
35
|
+
config: {
|
|
36
|
+
audio: {codec: "opus", bitrate: 128000},
|
|
37
|
+
video: {codec: "vp9", bitrate: 1000000}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {run}
|
|
43
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const fragment = (glsl: string) => `
|
|
2
|
+
precision highp float;
|
|
3
|
+
varying vec2 vTextureCoord;
|
|
4
|
+
varying vec2 _uv;
|
|
5
|
+
uniform sampler2D from, to;
|
|
6
|
+
uniform float progress, ratio, _fromR, _toR;
|
|
7
|
+
uniform float customUniform;
|
|
8
|
+
|
|
9
|
+
vec4 getFromColor(vec2 uv){
|
|
10
|
+
return texture2D(from, .5+(uv-.5)*vec2(max(ratio/_fromR,1.), max(_fromR/ratio,1.)));
|
|
11
|
+
}
|
|
12
|
+
vec4 getToColor(vec2 uv){
|
|
13
|
+
return texture2D(to, .5+(uv-.5)*vec2(max(ratio/_toR,1.), max(_toR/ratio,1.)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// gl-transition code here
|
|
17
|
+
${glsl}
|
|
18
|
+
// gl-transition code end
|
|
19
|
+
|
|
20
|
+
void main(){
|
|
21
|
+
vec2 uv = vTextureCoord.xy;
|
|
22
|
+
gl_FragColor = transition(vTextureCoord);
|
|
23
|
+
}
|
|
24
|
+
`
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {Renderer} from "pixi.js"
|
|
2
|
+
|
|
3
|
+
export interface TransitionOptions {
|
|
4
|
+
name: Transition
|
|
5
|
+
renderer: Renderer
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TransitionRendererOptions {
|
|
9
|
+
from: VideoFrame
|
|
10
|
+
to: VideoFrame
|
|
11
|
+
progress: number
|
|
12
|
+
width: number
|
|
13
|
+
height: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GLTransition {
|
|
17
|
+
author: string
|
|
18
|
+
createdAt: string
|
|
19
|
+
glsl: string
|
|
20
|
+
license: string
|
|
21
|
+
name: Transition
|
|
22
|
+
updatedAt: string
|
|
23
|
+
defaultParams: any
|
|
24
|
+
paramsTypes: any
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type Transition =
|
|
28
|
+
| "Bounce"
|
|
29
|
+
| "BowTieHorizontal"
|
|
30
|
+
| "BowTieVertical"
|
|
31
|
+
| "ButterflyWaveScrawler"
|
|
32
|
+
| "CircleCrop"
|
|
33
|
+
| "ColourDistance"
|
|
34
|
+
| "CrazyParametricFun"
|
|
35
|
+
| "CrossZoom"
|
|
36
|
+
| "Directional"
|
|
37
|
+
| "DoomScreenTransition"
|
|
38
|
+
| "Dreamy"
|
|
39
|
+
| "DreamyZoom"
|
|
40
|
+
| "GlitchDisplace"
|
|
41
|
+
| "GlitchMemories"
|
|
42
|
+
| "GridFlip"
|
|
43
|
+
| "InvertedPageCurl"
|
|
44
|
+
| "LinearBlur"
|
|
45
|
+
| "Mosaic"
|
|
46
|
+
| "PolkaDotsCurtain"
|
|
47
|
+
| "Radial"
|
|
48
|
+
| "SimpleZoom"
|
|
49
|
+
| "StereoViewer"
|
|
50
|
+
| "Swirl"
|
|
51
|
+
| "WaterDrop"
|
|
52
|
+
| "ZoomInCircles"
|
|
53
|
+
| "angular"
|
|
54
|
+
| "burn"
|
|
55
|
+
| "cannabisleaf"
|
|
56
|
+
| "circle"
|
|
57
|
+
| "circleopen"
|
|
58
|
+
| "colorphase"
|
|
59
|
+
| "crosshatch"
|
|
60
|
+
| "crosswarp"
|
|
61
|
+
| "cube"
|
|
62
|
+
| "directionalwarp"
|
|
63
|
+
| "directionalwipe"
|
|
64
|
+
| "displacement"
|
|
65
|
+
| "doorway"
|
|
66
|
+
| "fade"
|
|
67
|
+
| "fadecolor"
|
|
68
|
+
| "fadegrayscale"
|
|
69
|
+
| "flyeye"
|
|
70
|
+
| "heart"
|
|
71
|
+
| "hexagonalize"
|
|
72
|
+
| "kaleidoscope"
|
|
73
|
+
| "luma"
|
|
74
|
+
| "luminance_melt"
|
|
75
|
+
| "morph"
|
|
76
|
+
| "multiply_blend"
|
|
77
|
+
| "perlin"
|
|
78
|
+
| "pinwheel"
|
|
79
|
+
| "pixelize"
|
|
80
|
+
| "polar_function"
|
|
81
|
+
| "randomsquares"
|
|
82
|
+
| "ripple"
|
|
83
|
+
| "rotate_scale_fade"
|
|
84
|
+
| "squareswire"
|
|
85
|
+
| "squeeze"
|
|
86
|
+
| "swap"
|
|
87
|
+
| "undulatingBurnOut"
|
|
88
|
+
| "wind"
|
|
89
|
+
| "windowblinds"
|
|
90
|
+
| "windowslice"
|
|
91
|
+
| "wipeDown"
|
|
92
|
+
| "wipeLeft"
|
|
93
|
+
| "wipeRight"
|
|
94
|
+
| "wipeUp"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {GLTransition} from "./types.js"
|
|
2
|
+
|
|
3
|
+
export const uniforms = {
|
|
4
|
+
custom: (transition: GLTransition) => Object.fromEntries(
|
|
5
|
+
Object.entries(transition.defaultParams).map(([name, value]) => [
|
|
6
|
+
name,
|
|
7
|
+
{
|
|
8
|
+
value,
|
|
9
|
+
type: getUniformType(transition.paramsTypes[name])
|
|
10
|
+
}
|
|
11
|
+
])
|
|
12
|
+
),
|
|
13
|
+
basics: {
|
|
14
|
+
_fromR: {value: 1, type: "f32"},
|
|
15
|
+
_toR: {value: 1, type: "f32"},
|
|
16
|
+
ratio: {value: 1, type: "f32"},
|
|
17
|
+
progress: {value: 0, type: "f32"},
|
|
18
|
+
customUniform: {value: 0, type: "f32"},
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const getUniformType = (type: string) => {
|
|
23
|
+
if(type === "f32" || type === "i32") {
|
|
24
|
+
return type
|
|
25
|
+
} else if(type === "float") {
|
|
26
|
+
return "f32"
|
|
27
|
+
}
|
|
28
|
+
else return `${type}<f32>`
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const vertex = `
|
|
2
|
+
in vec2 aPosition;
|
|
3
|
+
varying vec2 _uv; // gl-transition
|
|
4
|
+
uniform mat3 projectionMatrix;
|
|
5
|
+
uniform vec4 uInputSize;
|
|
6
|
+
uniform vec4 uOutputFrame;
|
|
7
|
+
out vec2 vTextureCoord;
|
|
8
|
+
uniform vec4 uOutputTexture;
|
|
9
|
+
|
|
10
|
+
vec4 filterVertexPosition( void )
|
|
11
|
+
{
|
|
12
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
13
|
+
|
|
14
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
15
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
16
|
+
|
|
17
|
+
return vec4(position, 0.0, 1.0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
vec2 filterTextureCoord( void )
|
|
21
|
+
{
|
|
22
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void main(void)
|
|
26
|
+
{
|
|
27
|
+
gl_Position = filterVertexPosition();
|
|
28
|
+
vTextureCoord = filterTextureCoord();
|
|
29
|
+
_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition
|
|
30
|
+
}
|
|
31
|
+
`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import transitions from "gl-transitions"
|
|
3
|
+
import {Filter, GlProgram, Sprite, Texture, ImageSource} from "pixi.js"
|
|
4
|
+
|
|
5
|
+
import {vertex} from "./parts/vertex.js"
|
|
6
|
+
import {uniforms} from "./parts/uniforms.js"
|
|
7
|
+
import {fragment} from "./parts/fragment.js"
|
|
8
|
+
import {GLTransition, TransitionOptions, TransitionRendererOptions} from "./parts/types.js"
|
|
9
|
+
|
|
10
|
+
export function makeTransition({name, renderer}: TransitionOptions) {
|
|
11
|
+
const transition = transitions.find((t: GLTransition) => t.name === name) as GLTransition
|
|
12
|
+
const transitionSprite = new Sprite()
|
|
13
|
+
const transitionTexture = new Texture()
|
|
14
|
+
const sourceFrom = new ImageSource({})
|
|
15
|
+
const sourceTo = new ImageSource({})
|
|
16
|
+
|
|
17
|
+
const filter = new Filter({
|
|
18
|
+
glProgram: new GlProgram({
|
|
19
|
+
vertex,
|
|
20
|
+
fragment: fragment(transition.glsl),
|
|
21
|
+
}),
|
|
22
|
+
resources: {
|
|
23
|
+
from: sourceFrom,
|
|
24
|
+
to: sourceTo,
|
|
25
|
+
uniforms: {
|
|
26
|
+
...uniforms.basics,
|
|
27
|
+
...uniforms.custom(transition)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
transitionSprite.filters = [filter]
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
render({width, height, from, to, progress}: TransitionRendererOptions) {
|
|
36
|
+
if(transitionSprite.width !== width || transitionSprite.height !== height) {
|
|
37
|
+
transitionSprite.setSize({width, height})
|
|
38
|
+
transitionTexture.source.resize(width, height)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
sourceFrom.resource = from
|
|
42
|
+
sourceTo.resource = to
|
|
43
|
+
sourceFrom.update()
|
|
44
|
+
sourceTo.update()
|
|
45
|
+
|
|
46
|
+
filter.resources.uniforms.uniforms.progress = progress
|
|
47
|
+
|
|
48
|
+
renderer.render({
|
|
49
|
+
container: transitionSprite,
|
|
50
|
+
target: transitionTexture,
|
|
51
|
+
clear: false,
|
|
52
|
+
width,
|
|
53
|
+
height
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return transitionTexture
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Application, Sprite } from "pixi.js";
|
|
2
|
+
import { makeTransition } from "../../features/transition/transition.js";
|
|
3
|
+
export async function setupTransitionsTest(driver, source) {
|
|
4
|
+
const app = new Application();
|
|
5
|
+
await app.init({ width: 300, height: 300, preference: "webgl" });
|
|
6
|
+
const sprite = new Sprite({ width: 300, height: 300 });
|
|
7
|
+
app.stage.addChild(sprite);
|
|
8
|
+
document.body.appendChild(app.canvas);
|
|
9
|
+
const transition = makeTransition({ name: "circle", renderer: app.renderer });
|
|
10
|
+
async function run() {
|
|
11
|
+
const readables = driver.decode({
|
|
12
|
+
source,
|
|
13
|
+
async onFrame(frame) {
|
|
14
|
+
const texture = transition.render({
|
|
15
|
+
from: frame,
|
|
16
|
+
to: frame,
|
|
17
|
+
progress: 0.7,
|
|
18
|
+
width: app.canvas.width,
|
|
19
|
+
height: app.canvas.height
|
|
20
|
+
});
|
|
21
|
+
sprite.texture = texture;
|
|
22
|
+
return frame;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
await driver.encode({
|
|
26
|
+
readables,
|
|
27
|
+
config: {
|
|
28
|
+
audio: { codec: "opus", bitrate: 128000 },
|
|
29
|
+
video: { codec: "vp9", bitrate: 1000000 }
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return { run };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=transitions-test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitions-test.js","sourceRoot":"","sources":["../../../s/demo/routines/transitions-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAI3C,OAAO,EAAC,cAAc,EAAC,MAAM,yCAAyC,CAAA;AAEtE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAc,EAAE,MAAqB;IAC/E,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,MAAM,GAAG,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAC,CAAC,CAAA;IAC9D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAC,CAAC,CAAA;IAEpD,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAE1B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACrC,MAAM,UAAU,GAAG,cAAc,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAC,CAAC,CAAA;IAE3E,KAAK,UAAU,GAAG;QACjB,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAC/B,MAAM;YACN,KAAK,CAAC,OAAO,CAAC,KAAK;gBAClB,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;oBACjC,IAAI,EAAE,KAAK;oBACX,EAAE,EAAE,KAAK;oBACT,QAAQ,EAAE,GAAG;oBACb,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK;oBACvB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM;iBACzB,CAAC,CAAA;gBACF,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;gBACxB,OAAO,KAAK,CAAA;YACb,CAAC;SACD,CAAC,CAAA;QAEF,MAAM,MAAM,CAAC,MAAM,CAAC;YACnB,SAAS;YACT,MAAM,EAAE;gBACP,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAC;gBACvC,KAAK,EAAE,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAC;aACvC;SACD,CAAC,CAAA;IACH,CAAC;IAED,OAAO,EAAC,GAAG,EAAC,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fragment: (glsl: string) => string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const fragment = (glsl) => `
|
|
2
|
+
precision highp float;
|
|
3
|
+
varying vec2 vTextureCoord;
|
|
4
|
+
varying vec2 _uv;
|
|
5
|
+
uniform sampler2D from, to;
|
|
6
|
+
uniform float progress, ratio, _fromR, _toR;
|
|
7
|
+
uniform float customUniform;
|
|
8
|
+
|
|
9
|
+
vec4 getFromColor(vec2 uv){
|
|
10
|
+
return texture2D(from, .5+(uv-.5)*vec2(max(ratio/_fromR,1.), max(_fromR/ratio,1.)));
|
|
11
|
+
}
|
|
12
|
+
vec4 getToColor(vec2 uv){
|
|
13
|
+
return texture2D(to, .5+(uv-.5)*vec2(max(ratio/_toR,1.), max(_toR/ratio,1.)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// gl-transition code here
|
|
17
|
+
${glsl}
|
|
18
|
+
// gl-transition code end
|
|
19
|
+
|
|
20
|
+
void main(){
|
|
21
|
+
vec2 uv = vTextureCoord.xy;
|
|
22
|
+
gl_FragColor = transition(vTextureCoord);
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
//# sourceMappingURL=fragment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/fragment.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;GAgBvC,IAAI;;;;;;;CAON,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Renderer } from "pixi.js";
|
|
2
|
+
export interface TransitionOptions {
|
|
3
|
+
name: Transition;
|
|
4
|
+
renderer: Renderer;
|
|
5
|
+
}
|
|
6
|
+
export interface TransitionRendererOptions {
|
|
7
|
+
from: VideoFrame;
|
|
8
|
+
to: VideoFrame;
|
|
9
|
+
progress: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GLTransition {
|
|
14
|
+
author: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
glsl: string;
|
|
17
|
+
license: string;
|
|
18
|
+
name: Transition;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
defaultParams: any;
|
|
21
|
+
paramsTypes: any;
|
|
22
|
+
}
|
|
23
|
+
export type Transition = "Bounce" | "BowTieHorizontal" | "BowTieVertical" | "ButterflyWaveScrawler" | "CircleCrop" | "ColourDistance" | "CrazyParametricFun" | "CrossZoom" | "Directional" | "DoomScreenTransition" | "Dreamy" | "DreamyZoom" | "GlitchDisplace" | "GlitchMemories" | "GridFlip" | "InvertedPageCurl" | "LinearBlur" | "Mosaic" | "PolkaDotsCurtain" | "Radial" | "SimpleZoom" | "StereoViewer" | "Swirl" | "WaterDrop" | "ZoomInCircles" | "angular" | "burn" | "cannabisleaf" | "circle" | "circleopen" | "colorphase" | "crosshatch" | "crosswarp" | "cube" | "directionalwarp" | "directionalwipe" | "displacement" | "doorway" | "fade" | "fadecolor" | "fadegrayscale" | "flyeye" | "heart" | "hexagonalize" | "kaleidoscope" | "luma" | "luminance_melt" | "morph" | "multiply_blend" | "perlin" | "pinwheel" | "pixelize" | "polar_function" | "randomsquares" | "ripple" | "rotate_scale_fade" | "squareswire" | "squeeze" | "swap" | "undulatingBurnOut" | "wind" | "windowblinds" | "windowslice" | "wipeDown" | "wipeLeft" | "wipeRight" | "wipeUp";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GLTransition } from "./types.js";
|
|
2
|
+
export declare const uniforms: {
|
|
3
|
+
custom: (transition: GLTransition) => {
|
|
4
|
+
[k: string]: {
|
|
5
|
+
value: unknown;
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
basics: {
|
|
10
|
+
_fromR: {
|
|
11
|
+
value: number;
|
|
12
|
+
type: string;
|
|
13
|
+
};
|
|
14
|
+
_toR: {
|
|
15
|
+
value: number;
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
ratio: {
|
|
19
|
+
value: number;
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
progress: {
|
|
23
|
+
value: number;
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
customUniform: {
|
|
27
|
+
value: number;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const uniforms = {
|
|
2
|
+
custom: (transition) => Object.fromEntries(Object.entries(transition.defaultParams).map(([name, value]) => [
|
|
3
|
+
name,
|
|
4
|
+
{
|
|
5
|
+
value,
|
|
6
|
+
type: getUniformType(transition.paramsTypes[name])
|
|
7
|
+
}
|
|
8
|
+
])),
|
|
9
|
+
basics: {
|
|
10
|
+
_fromR: { value: 1, type: "f32" },
|
|
11
|
+
_toR: { value: 1, type: "f32" },
|
|
12
|
+
ratio: { value: 1, type: "f32" },
|
|
13
|
+
progress: { value: 0, type: "f32" },
|
|
14
|
+
customUniform: { value: 0, type: "f32" },
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getUniformType = (type) => {
|
|
18
|
+
if (type === "f32" || type === "i32") {
|
|
19
|
+
return type;
|
|
20
|
+
}
|
|
21
|
+
else if (type === "float") {
|
|
22
|
+
return "f32";
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
return `${type}<f32>`;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=uniforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniforms.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/uniforms.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,MAAM,EAAE,CAAC,UAAwB,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CACvD,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC/D,IAAI;QACJ;YACC,KAAK;YACL,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAClD;KACD,CAAC,CACF;IACD,MAAM,EAAE;QACP,MAAM,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC/B,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC7B,KAAK,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QAC9B,QAAQ,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;QACjC,aAAa,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC;KACtC;CACD,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE;IACvC,IAAG,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACrC,OAAO,IAAI,CAAA;IACZ,CAAC;SAAM,IAAG,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAA;IACb,CAAC;;QACI,OAAO,GAAG,IAAI,OAAO,CAAA;AAC3B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const vertex = "\n\tin vec2 aPosition;\n\tvarying vec2 _uv; // gl-transition\n\tuniform mat3 projectionMatrix;\n\tuniform vec4 uInputSize;\n\tuniform vec4 uOutputFrame;\n\tout vec2 vTextureCoord;\n\tuniform vec4 uOutputTexture;\n\n\tvec4 filterVertexPosition( void )\n\t{\n\t\t\tvec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n\n\t\t\tposition.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n\t\t\tposition.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n\t\t\treturn vec4(position, 0.0, 1.0);\n\t}\n\n\tvec2 filterTextureCoord( void )\n\t{\n\treturn aPosition * (uOutputFrame.zw * uInputSize.zw);\n\t}\n\n\tvoid main(void)\n\t{\n\tgl_Position = filterVertexPosition();\n\tvTextureCoord = filterTextureCoord();\n\t_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition\n\t}\n";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const vertex = `
|
|
2
|
+
in vec2 aPosition;
|
|
3
|
+
varying vec2 _uv; // gl-transition
|
|
4
|
+
uniform mat3 projectionMatrix;
|
|
5
|
+
uniform vec4 uInputSize;
|
|
6
|
+
uniform vec4 uOutputFrame;
|
|
7
|
+
out vec2 vTextureCoord;
|
|
8
|
+
uniform vec4 uOutputTexture;
|
|
9
|
+
|
|
10
|
+
vec4 filterVertexPosition( void )
|
|
11
|
+
{
|
|
12
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
13
|
+
|
|
14
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
15
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
16
|
+
|
|
17
|
+
return vec4(position, 0.0, 1.0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
vec2 filterTextureCoord( void )
|
|
21
|
+
{
|
|
22
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void main(void)
|
|
26
|
+
{
|
|
27
|
+
gl_Position = filterVertexPosition();
|
|
28
|
+
vTextureCoord = filterTextureCoord();
|
|
29
|
+
_uv = vec2(0.5, 0.5) * (aPosition +vec2(1.0, 1.0)); // gl-transition
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
//# sourceMappingURL=vertex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vertex.js","sourceRoot":"","sources":["../../../../s/features/transition/parts/vertex.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Texture } from "pixi.js";
|
|
2
|
+
import { TransitionOptions, TransitionRendererOptions } from "./parts/types.js";
|
|
3
|
+
export declare function makeTransition({ name, renderer }: TransitionOptions): {
|
|
4
|
+
render({ width, height, from, to, progress }: TransitionRendererOptions): Texture<import("pixi.js").TextureSource<any>>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//@ts-ignore
|
|
2
|
+
import transitions from "gl-transitions";
|
|
3
|
+
import { Filter, GlProgram, Sprite, Texture, ImageSource } from "pixi.js";
|
|
4
|
+
import { vertex } from "./parts/vertex.js";
|
|
5
|
+
import { uniforms } from "./parts/uniforms.js";
|
|
6
|
+
import { fragment } from "./parts/fragment.js";
|
|
7
|
+
export function makeTransition({ name, renderer }) {
|
|
8
|
+
const transition = transitions.find((t) => t.name === name);
|
|
9
|
+
const transitionSprite = new Sprite();
|
|
10
|
+
const transitionTexture = new Texture();
|
|
11
|
+
const sourceFrom = new ImageSource({});
|
|
12
|
+
const sourceTo = new ImageSource({});
|
|
13
|
+
const filter = new Filter({
|
|
14
|
+
glProgram: new GlProgram({
|
|
15
|
+
vertex,
|
|
16
|
+
fragment: fragment(transition.glsl),
|
|
17
|
+
}),
|
|
18
|
+
resources: {
|
|
19
|
+
from: sourceFrom,
|
|
20
|
+
to: sourceTo,
|
|
21
|
+
uniforms: {
|
|
22
|
+
...uniforms.basics,
|
|
23
|
+
...uniforms.custom(transition)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
transitionSprite.filters = [filter];
|
|
28
|
+
return {
|
|
29
|
+
render({ width, height, from, to, progress }) {
|
|
30
|
+
if (transitionSprite.width !== width || transitionSprite.height !== height) {
|
|
31
|
+
transitionSprite.setSize({ width, height });
|
|
32
|
+
transitionTexture.source.resize(width, height);
|
|
33
|
+
}
|
|
34
|
+
sourceFrom.resource = from;
|
|
35
|
+
sourceTo.resource = to;
|
|
36
|
+
sourceFrom.update();
|
|
37
|
+
sourceTo.update();
|
|
38
|
+
filter.resources.uniforms.uniforms.progress = progress;
|
|
39
|
+
renderer.render({
|
|
40
|
+
container: transitionSprite,
|
|
41
|
+
target: transitionTexture,
|
|
42
|
+
clear: false,
|
|
43
|
+
width,
|
|
44
|
+
height
|
|
45
|
+
});
|
|
46
|
+
return transitionTexture;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.js","sourceRoot":"","sources":["../../../s/features/transition/transition.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,SAAS,CAAA;AAEvE,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAA;AAG5C,MAAM,UAAU,cAAc,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAoB;IACjE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAe,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAiB,CAAA;IACzF,MAAM,gBAAgB,GAAG,IAAI,MAAM,EAAE,CAAA;IACrC,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAE,CAAA;IACvC,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAA;IAEpC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACzB,SAAS,EAAE,IAAI,SAAS,CAAC;YACxB,MAAM;YACN,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;SACnC,CAAC;QACF,SAAS,EAAE;YACV,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,QAAQ;YACZ,QAAQ,EAAE;gBACT,GAAG,QAAQ,CAAC,MAAM;gBAClB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC;aAC9B;SACD;KACD,CAAC,CAAA;IAEF,gBAAgB,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAA;IAEnC,OAAO;QACN,MAAM,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAA4B;YACpE,IAAG,gBAAgB,CAAC,KAAK,KAAK,KAAK,IAAI,gBAAgB,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC3E,gBAAgB,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,MAAM,EAAC,CAAC,CAAA;gBACzC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YAC/C,CAAC;YAED,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAA;YAC1B,QAAQ,CAAC,QAAQ,GAAG,EAAE,CAAA;YACtB,UAAU,CAAC,MAAM,EAAE,CAAA;YACnB,QAAQ,CAAC,MAAM,EAAE,CAAA;YAEjB,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAEtD,QAAQ,CAAC,MAAM,CAAC;gBACf,SAAS,EAAE,gBAAgB;gBAC3B,MAAM,EAAE,iBAAiB;gBACzB,KAAK,EAAE,KAAK;gBACZ,KAAK;gBACL,MAAM;aACN,CAAC,CAAA;YAEF,OAAO,iBAAiB,CAAA;QACzB,CAAC;KACD,CAAA;AACF,CAAC"}
|
package/x/index.html
CHANGED