@hyperframes/core 0.8.63 → 0.8.65
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/generated/position-edits-render-inline.js +1 -1
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/generated/runtime-inline.js.map +1 -1
- package/dist/hyperframe.runtime.iife.js +191 -28
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/domRealm.d.ts +2 -0
- package/dist/runtime/domRealm.d.ts.map +1 -1
- package/dist/runtime/domRealm.js +4 -0
- package/dist/runtime/domRealm.js.map +1 -1
- package/dist/vfx/displacementMap.frag.d.ts +41 -0
- package/dist/vfx/displacementMap.frag.d.ts.map +1 -0
- package/dist/vfx/displacementMap.frag.js +85 -0
- package/dist/vfx/displacementMap.frag.js.map +1 -0
- package/dist/vfx/fractalNoise.frag.d.ts +45 -0
- package/dist/vfx/fractalNoise.frag.d.ts.map +1 -0
- package/dist/vfx/fractalNoise.frag.js +126 -0
- package/dist/vfx/fractalNoise.frag.js.map +1 -0
- package/dist/vfx/refs/displacementMap.d.ts +34 -0
- package/dist/vfx/refs/displacementMap.d.ts.map +1 -0
- package/dist/vfx/refs/displacementMap.js +53 -0
- package/dist/vfx/refs/displacementMap.js.map +1 -0
- package/dist/vfx/refs/fractalNoise.d.ts +33 -0
- package/dist/vfx/refs/fractalNoise.d.ts.map +1 -0
- package/dist/vfx/refs/fractalNoise.js +94 -0
- package/dist/vfx/refs/fractalNoise.js.map +1 -0
- package/dist/vfx/refs/waveWarp.d.ts +19 -0
- package/dist/vfx/refs/waveWarp.d.ts.map +1 -0
- package/dist/vfx/refs/waveWarp.js +25 -0
- package/dist/vfx/refs/waveWarp.js.map +1 -0
- package/dist/vfx/waveWarp.frag.d.ts +38 -0
- package/dist/vfx/waveWarp.frag.d.ts.map +1 -0
- package/dist/vfx/waveWarp.frag.js +74 -0
- package/dist/vfx/waveWarp.frag.js.map +1 -0
- package/dist/vfx.d.ts +121 -0
- package/dist/vfx.d.ts.map +1 -0
- package/dist/vfx.js +488 -0
- package/dist/vfx.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPU reference for the `fractal-noise` kernel — a pure function of the same
|
|
3
|
+
* inputs the GLSL gets, built from the same `HASH_CONSTANTS`. The determinism
|
|
4
|
+
* contract's cross-backend bar (PSNR ≥ 32 dB, K = 4 sample frames) is measured
|
|
5
|
+
* against this, so it must stay a line-for-line mirror of the shader rather
|
|
6
|
+
* than an independent idea of what the effect should look like.
|
|
7
|
+
*
|
|
8
|
+
* Coordinates are **device pixels with y measured from the bottom** — the
|
|
9
|
+
* shader's `v_uv * u_size`, and the order `gl.readPixels` returns rows in. The
|
|
10
|
+
* shader samples fragment centres, so a caller comparing against pixel
|
|
11
|
+
* `(i, j)` should pass `(i + 0.5, j + 0.5)`.
|
|
12
|
+
*/
|
|
13
|
+
import { normalizeVfxParams } from "../../vfx.js";
|
|
14
|
+
import { HASH_CONSTANTS } from "../fractalNoise.frag.js";
|
|
15
|
+
const { mulX, mulY, mulMix, offset, shift1, shift2, divisor } = HASH_CONSTANTS;
|
|
16
|
+
/**
|
|
17
|
+
* The shader's `hfHashUnit`. `Math.imul` + `>>> 0` reproduce GLSL's 32-bit
|
|
18
|
+
* `uint` wrap-around exactly; without them JS would carry the products into
|
|
19
|
+
* doubles and drift from the GPU immediately.
|
|
20
|
+
*/
|
|
21
|
+
export function fractalNoiseHashUnit(ix, iy, seed) {
|
|
22
|
+
let h = ((Math.imul(ix, mulX) ^ Math.imul(iy, mulY) ^ Math.imul(seed, mulMix)) >>> 0) + offset;
|
|
23
|
+
h = h >>> 0;
|
|
24
|
+
h = (h ^ (h >>> shift1)) >>> 0;
|
|
25
|
+
h = Math.imul(h, mulMix) >>> 0;
|
|
26
|
+
h = (h ^ (h >>> shift2)) >>> 0;
|
|
27
|
+
return h / divisor;
|
|
28
|
+
}
|
|
29
|
+
/** Noise Type picks the interpolation curve: Block, Linear, Soft Linear, Spline. */
|
|
30
|
+
function fade(f, noiseType) {
|
|
31
|
+
if (noiseType < 1.5)
|
|
32
|
+
return 0;
|
|
33
|
+
if (noiseType < 2.5)
|
|
34
|
+
return f;
|
|
35
|
+
if (noiseType < 3.5)
|
|
36
|
+
return f * f * (3 - 2 * f);
|
|
37
|
+
return f * f * f * (f * (f * 6 - 15) + 10);
|
|
38
|
+
}
|
|
39
|
+
function mix(a, b, w) {
|
|
40
|
+
return a + (b - a) * w;
|
|
41
|
+
}
|
|
42
|
+
function valueNoise(px, py, seed, noiseType) {
|
|
43
|
+
const cx = Math.floor(px);
|
|
44
|
+
const cy = Math.floor(py);
|
|
45
|
+
const sx = fade(px - cx, noiseType);
|
|
46
|
+
const sy = fade(py - cy, noiseType);
|
|
47
|
+
const bottom = mix(fractalNoiseHashUnit(cx, cy, seed), fractalNoiseHashUnit(cx + 1, cy, seed), sx);
|
|
48
|
+
const top = mix(fractalNoiseHashUnit(cx, cy + 1, seed), fractalNoiseHashUnit(cx + 1, cy + 1, seed), sx);
|
|
49
|
+
return mix(bottom, top, sy);
|
|
50
|
+
}
|
|
51
|
+
function fbm(px, py, s) {
|
|
52
|
+
const lacunarity = 100 / Math.max(s.subScaling, 1);
|
|
53
|
+
const gain = s.subInfluence / 100;
|
|
54
|
+
let amp = 1;
|
|
55
|
+
let freq = 1;
|
|
56
|
+
let sum = 0;
|
|
57
|
+
let norm = 0;
|
|
58
|
+
for (let i = 0; i < s.complexity; i++) {
|
|
59
|
+
sum += amp * valueNoise(px * freq, py * freq, s.randomSeed + i, s.noiseType);
|
|
60
|
+
norm += amp;
|
|
61
|
+
amp *= gain;
|
|
62
|
+
freq *= lacunarity;
|
|
63
|
+
}
|
|
64
|
+
return norm > 0 ? sum / norm : 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The grey level the kernel writes at `(x, y)`, in [0, 1]. The shader then
|
|
68
|
+
* premultiplies it by `opacity/100` and writes that as alpha; this returns the
|
|
69
|
+
* unpremultiplied value so a caller can check either.
|
|
70
|
+
*
|
|
71
|
+
* `t` is part of the call shape every kernel reference shares. Fractal Noise
|
|
72
|
+
* is time-invariant — its animation arrives as a tweened `evolution` — so it
|
|
73
|
+
* is deliberately unread here.
|
|
74
|
+
*/
|
|
75
|
+
export function fractalNoiseRef(p, t, params) {
|
|
76
|
+
void t;
|
|
77
|
+
const n = normalizeVfxParams("fractal-noise", params);
|
|
78
|
+
const scale = Math.max(n["scale"], 1);
|
|
79
|
+
const evolution = n["evolution"];
|
|
80
|
+
const px = p.x / scale + evolution;
|
|
81
|
+
const py = p.y / scale + evolution * 0.5;
|
|
82
|
+
let v = fbm(px, py, {
|
|
83
|
+
complexity: n["complexity"],
|
|
84
|
+
subInfluence: n["subInfluence"],
|
|
85
|
+
subScaling: n["subScaling"],
|
|
86
|
+
randomSeed: Math.trunc(n["randomSeed"]),
|
|
87
|
+
noiseType: n["noiseType"],
|
|
88
|
+
});
|
|
89
|
+
v = (v - 0.5) * (n["contrast"] / 100) + 0.5 + n["brightness"] / 100;
|
|
90
|
+
if (n["invert"] === true)
|
|
91
|
+
v = 1 - v;
|
|
92
|
+
return Math.min(1, Math.max(0, v));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=fractalNoise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fractalNoise.js","sourceRoot":"","sources":["../../../src/vfx/refs/fractalNoise.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAAC;AA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,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAE,CAAC,CAAC,UAAU,CAAY,GAAG,GAAG,CAAC,GAAG,GAAG,GAAI,CAAC,CAAC,YAAY,CAAY,GAAG,GAAG,CAAC;IAC5F,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI;QAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPU reference for the `wave-warp` kernel. It returns the *source coordinate*
|
|
3
|
+
* the kernel samples rather than a colour: the displacement is the whole of
|
|
4
|
+
* what the kernel decides, and a caller with the source image can look the
|
|
5
|
+
* colour up itself.
|
|
6
|
+
*
|
|
7
|
+
* Coordinates are device pixels with y measured from the bottom — the shader's
|
|
8
|
+
* `v_uv * u_size`, and the order `gl.readPixels` returns rows in.
|
|
9
|
+
*/
|
|
10
|
+
import { type HfVfxParamValues } from "../../vfx";
|
|
11
|
+
/** Where the kernel reads from to paint `(x, y)`, in the same pixel space. */
|
|
12
|
+
export declare function waveWarpSampleRef(p: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}, t: number, params: HfVfxParamValues): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=waveWarp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveWarp.d.ts","sourceRoot":"","sources":["../../../src/vfx/refs/waveWarp.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAKtE,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAC/B,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3B,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,gBAAgB,GACvB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAU1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPU reference for the `wave-warp` kernel. It returns the *source coordinate*
|
|
3
|
+
* the kernel samples rather than a colour: the displacement is the whole of
|
|
4
|
+
* what the kernel decides, and a caller with the source image can look the
|
|
5
|
+
* colour up itself.
|
|
6
|
+
*
|
|
7
|
+
* Coordinates are device pixels with y measured from the bottom — the shader's
|
|
8
|
+
* `v_uv * u_size`, and the order `gl.readPixels` returns rows in.
|
|
9
|
+
*/
|
|
10
|
+
import { normalizeVfxParams } from "../../vfx.js";
|
|
11
|
+
import { WAVE_WARP_CONSTANTS } from "../waveWarp.frag.js";
|
|
12
|
+
const { tau, degreesPerTurn } = WAVE_WARP_CONSTANTS;
|
|
13
|
+
/** Where the kernel reads from to paint `(x, y)`, in the same pixel space. */
|
|
14
|
+
export function waveWarpSampleRef(p, t, params) {
|
|
15
|
+
const n = normalizeVfxParams("wave-warp", params);
|
|
16
|
+
const dir = (n["direction"] * Math.PI) / 180;
|
|
17
|
+
const travelX = Math.sin(dir);
|
|
18
|
+
const travelY = -Math.cos(dir);
|
|
19
|
+
const proj = (p.x + 1) * travelX + p.y * travelY;
|
|
20
|
+
const turns = proj / Math.max(n["width"], 1) + n["phase"] / degreesPerTurn + n["speed"] * t;
|
|
21
|
+
const disp = n["height"] * Math.sin(tau * turns);
|
|
22
|
+
// The displacement swings perpendicular to the direction of travel.
|
|
23
|
+
return { x: p.x - travelY * disp, y: p.y + travelX * disp };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=waveWarp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveWarp.js","sourceRoot":"","sources":["../../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0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wave-warp` kernel — GLSL ES 3.00, capture `self`.
|
|
3
|
+
*
|
|
4
|
+
* **Scope (v1, recorded rather than implied):** After Effects builds a
|
|
5
|
+
* 2048-entry displacement table per Wave Type on the CPU and reads it as
|
|
6
|
+
* `disp = table[round(proj/65536 + phase) & 2047]`, where
|
|
7
|
+
* `proj = (x + 1)·dirX + y·dirY`. The corpus needs **Wave Type 1 (Sine)** only
|
|
8
|
+
* (Direction 0, Speed 1, Pinning 1, Phase 0, Height/Width animated), and Sine
|
|
9
|
+
* ports analytically:
|
|
10
|
+
*
|
|
11
|
+
* disp = height · sin(2π · (proj/width + phase/360 + speed·t))
|
|
12
|
+
*
|
|
13
|
+
* applied perpendicular to the direction of travel, sampling `u_src` at the
|
|
14
|
+
* displaced coordinate with **clamp-to-transparent** edges. The other wave
|
|
15
|
+
* types are not defs in v1 — the exporter marks them cosmetic — and a
|
|
16
|
+
* 2048-wide strip probe is the upgrade path if the gate fails on Sine.
|
|
17
|
+
*
|
|
18
|
+
* **Pinning is not implemented (v1 = 1, "none").** The def's `pinning` option
|
|
19
|
+
* list carries only that value, so `normalizeVfxParams` folds anything else
|
|
20
|
+
* back to it, matching how `fractal-noise` handles Fractal Type.
|
|
21
|
+
*
|
|
22
|
+
* **Open question for the corpus gate:** `direction` is treated here as the
|
|
23
|
+
* direction of *travel*, with the displacement perpendicular to it — the
|
|
24
|
+
* reading the deep dive's `proj` formula supports. If After Effects' UI angle
|
|
25
|
+
* instead names the *displacement* axis, every direction is 90° out and the
|
|
26
|
+
* exporter's handler gains that offset. Corpus retro-wave uses Direction 0, so
|
|
27
|
+
* the two readings differ only by which axis moves.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Angles arrive in degrees (AE's unit) and `phase` is degrees of one wave;
|
|
31
|
+
* both meet `2π` here, so the constant is shared rather than spelled twice.
|
|
32
|
+
*/
|
|
33
|
+
export declare const WAVE_WARP_CONSTANTS: {
|
|
34
|
+
readonly tau: 6.283185307179586;
|
|
35
|
+
readonly degreesPerTurn: 360;
|
|
36
|
+
};
|
|
37
|
+
export declare const WAVE_WARP_FRAG: string;
|
|
38
|
+
//# sourceMappingURL=waveWarp.frag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveWarp.frag.d.ts","sourceRoot":"","sources":["../../src/vfx/waveWarp.frag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAIX,eAAO,MAAM,cAAc,QAmC1B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `wave-warp` kernel — GLSL ES 3.00, capture `self`.
|
|
3
|
+
*
|
|
4
|
+
* **Scope (v1, recorded rather than implied):** After Effects builds a
|
|
5
|
+
* 2048-entry displacement table per Wave Type on the CPU and reads it as
|
|
6
|
+
* `disp = table[round(proj/65536 + phase) & 2047]`, where
|
|
7
|
+
* `proj = (x + 1)·dirX + y·dirY`. The corpus needs **Wave Type 1 (Sine)** only
|
|
8
|
+
* (Direction 0, Speed 1, Pinning 1, Phase 0, Height/Width animated), and Sine
|
|
9
|
+
* ports analytically:
|
|
10
|
+
*
|
|
11
|
+
* disp = height · sin(2π · (proj/width + phase/360 + speed·t))
|
|
12
|
+
*
|
|
13
|
+
* applied perpendicular to the direction of travel, sampling `u_src` at the
|
|
14
|
+
* displaced coordinate with **clamp-to-transparent** edges. The other wave
|
|
15
|
+
* types are not defs in v1 — the exporter marks them cosmetic — and a
|
|
16
|
+
* 2048-wide strip probe is the upgrade path if the gate fails on Sine.
|
|
17
|
+
*
|
|
18
|
+
* **Pinning is not implemented (v1 = 1, "none").** The def's `pinning` option
|
|
19
|
+
* list carries only that value, so `normalizeVfxParams` folds anything else
|
|
20
|
+
* back to it, matching how `fractal-noise` handles Fractal Type.
|
|
21
|
+
*
|
|
22
|
+
* **Open question for the corpus gate:** `direction` is treated here as the
|
|
23
|
+
* direction of *travel*, with the displacement perpendicular to it — the
|
|
24
|
+
* reading the deep dive's `proj` formula supports. If After Effects' UI angle
|
|
25
|
+
* instead names the *displacement* axis, every direction is 90° out and the
|
|
26
|
+
* exporter's handler gains that offset. Corpus retro-wave uses Direction 0, so
|
|
27
|
+
* the two readings differ only by which axis moves.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Angles arrive in degrees (AE's unit) and `phase` is degrees of one wave;
|
|
31
|
+
* both meet `2π` here, so the constant is shared rather than spelled twice.
|
|
32
|
+
*/
|
|
33
|
+
export const WAVE_WARP_CONSTANTS = {
|
|
34
|
+
tau: 6.283185307179586,
|
|
35
|
+
degreesPerTurn: 360,
|
|
36
|
+
};
|
|
37
|
+
const { tau, degreesPerTurn } = WAVE_WARP_CONSTANTS;
|
|
38
|
+
export const WAVE_WARP_FRAG = `#version 300 es
|
|
39
|
+
precision highp float;
|
|
40
|
+
|
|
41
|
+
in vec2 v_uv;
|
|
42
|
+
out vec4 fragColor;
|
|
43
|
+
|
|
44
|
+
uniform vec2 u_size;
|
|
45
|
+
uniform float u_t;
|
|
46
|
+
uniform float u_fps;
|
|
47
|
+
uniform sampler2D u_src;
|
|
48
|
+
uniform float u_waveType;
|
|
49
|
+
uniform float u_height;
|
|
50
|
+
uniform float u_width;
|
|
51
|
+
uniform float u_direction;
|
|
52
|
+
uniform float u_speed;
|
|
53
|
+
uniform float u_pinning;
|
|
54
|
+
uniform float u_phase;
|
|
55
|
+
|
|
56
|
+
// Outside the layer's own box there is nothing to warp in from, so the wave
|
|
57
|
+
// carries transparency rather than a smeared edge pixel.
|
|
58
|
+
vec4 hfSampleSrc(vec2 uv) {
|
|
59
|
+
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) return vec4(0.0);
|
|
60
|
+
return texture(u_src, uv);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void main() {
|
|
64
|
+
vec2 px = v_uv * u_size;
|
|
65
|
+
float dir = radians(u_direction);
|
|
66
|
+
vec2 travel = vec2(sin(dir), -cos(dir));
|
|
67
|
+
vec2 swing = vec2(-travel.y, travel.x);
|
|
68
|
+
float proj = (px.x + 1.0) * travel.x + px.y * travel.y;
|
|
69
|
+
float turns = proj / max(u_width, 1.0) + u_phase / ${degreesPerTurn}.0 + u_speed * u_t;
|
|
70
|
+
float disp = u_height * sin(${tau} * turns);
|
|
71
|
+
fragColor = hfSampleSrc((px + swing * disp) / u_size);
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
//# sourceMappingURL=waveWarp.frag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waveWarp.frag.js","sourceRoot":"","sources":["../../src/vfx/waveWarp.frag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,EAAE,iBAAiB;IACtB,cAAc,EAAE,GAAG;CACX,CAAC;AAEX,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,mBAAmB,CAAC;AAEpD,MAAM,CAAC,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDA+ByB,cAAc;gCACrC,GAAG;;;CAGlC,CAAC"}
|
package/dist/vfx.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VFX chain: the one description of every per-pixel effect that can be
|
|
3
|
+
* applied to a layer's own pixels through the WebGL2 runtime.
|
|
4
|
+
*
|
|
5
|
+
* Mirrors `audioFx.ts` (`data-fx-chain`) in shape: a versioned JSON chain
|
|
6
|
+
* attribute, a def registry with typed params, and parse/serialize/normalize
|
|
7
|
+
* helpers so the exporter and the runtime agree on one description of each
|
|
8
|
+
* effect.
|
|
9
|
+
*/
|
|
10
|
+
export declare const HF_VFX_ATTR = "data-vfx-chain";
|
|
11
|
+
/**
|
|
12
|
+
* Chain files are versioned; a reader must refuse a version it doesn't know.
|
|
13
|
+
* Exported for the exporter (hyperframes-ae-mcp), which stamps the version it
|
|
14
|
+
* emits; inside this repo only parse/serialize below read it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const HF_VFX_CHAIN_VERSION = 1;
|
|
17
|
+
/**
|
|
18
|
+
* What a def's kernel must read besides `(x, y, t, params)`:
|
|
19
|
+
* - `none` — the kernel is a generator/replacement; no captured texture.
|
|
20
|
+
* - `self` — the kernel reads the host's own pixels through a `layoutsubtree`
|
|
21
|
+
* capture canvas.
|
|
22
|
+
* - `backdrop` — the kernel reads everything below the host (adjustment-layer
|
|
23
|
+
* style effects).
|
|
24
|
+
*/
|
|
25
|
+
export type HfVfxCapture = "none" | "self" | "backdrop";
|
|
26
|
+
export interface HfVfxNumberParam {
|
|
27
|
+
kind: "number";
|
|
28
|
+
key: string;
|
|
29
|
+
label: string;
|
|
30
|
+
unit: string;
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
step: number;
|
|
34
|
+
default: number;
|
|
35
|
+
/** May be driven by a `--vfx-<nodeId>-<key>` CSS var instead of `params`. */
|
|
36
|
+
animatable?: boolean;
|
|
37
|
+
hint?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface HfVfxEnumParam {
|
|
40
|
+
kind: "enum";
|
|
41
|
+
key: string;
|
|
42
|
+
label: string;
|
|
43
|
+
options: readonly {
|
|
44
|
+
value: number;
|
|
45
|
+
label: string;
|
|
46
|
+
}[];
|
|
47
|
+
default: number;
|
|
48
|
+
hint?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface HfVfxBoolParam {
|
|
51
|
+
kind: "bool";
|
|
52
|
+
key: string;
|
|
53
|
+
label: string;
|
|
54
|
+
default: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** A second-source param (v1.1): its value is the id of another element. */
|
|
57
|
+
export interface HfVfxRefParam {
|
|
58
|
+
kind: "ref";
|
|
59
|
+
key: string;
|
|
60
|
+
label: string;
|
|
61
|
+
}
|
|
62
|
+
export type HfVfxParam = HfVfxNumberParam | HfVfxEnumParam | HfVfxBoolParam | HfVfxRefParam;
|
|
63
|
+
/** `string` values only occur for `ref` params (element ids). */
|
|
64
|
+
export type HfVfxParamValues = Record<string, number | boolean | string>;
|
|
65
|
+
export interface HfVfxDef {
|
|
66
|
+
id: string;
|
|
67
|
+
label: string;
|
|
68
|
+
/** What the kernel must read besides (x, y, t, params). */
|
|
69
|
+
capture: HfVfxCapture;
|
|
70
|
+
params: readonly HfVfxParam[];
|
|
71
|
+
/** GLSL ES 3.00 fragment source; uniforms are u_size/u_t/u_fps/u_src(2)/u_<key>. */
|
|
72
|
+
frag: string;
|
|
73
|
+
/** AE match name this def ports, for docs — e.g. "ADBE Fractal Noise". */
|
|
74
|
+
ae?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The def registry. Params come from the AE deep dives and retro-wave's
|
|
78
|
+
* observed values; each kernel's own `frag` module states the v1 scope
|
|
79
|
+
* decision — which of the effect's modes it actually implements and why.
|
|
80
|
+
*
|
|
81
|
+
* Exported as the whole registry for the exporter and Studio's effect picker;
|
|
82
|
+
* inside the runtime, defs are reached through `getVfxDef`.
|
|
83
|
+
*/
|
|
84
|
+
export declare const HF_VFX: readonly HfVfxDef[];
|
|
85
|
+
export declare function getVfxDef(id: string): HfVfxDef | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Clamp and fill a parameter set so it is always renderable: unknown keys are
|
|
88
|
+
* dropped, missing keys take their default, numbers are clamped into their
|
|
89
|
+
* declared range, an unrecognised enum value falls back to its default, and a
|
|
90
|
+
* non-boolean bool value falls back to its default. Mirrors
|
|
91
|
+
* `normalizeAudioFxParams`.
|
|
92
|
+
*/
|
|
93
|
+
export declare function normalizeVfxParams(id: string, values: Readonly<HfVfxParamValues> | undefined): HfVfxParamValues;
|
|
94
|
+
export interface HfVfxNode {
|
|
95
|
+
type: string;
|
|
96
|
+
id: string;
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
params: HfVfxParamValues;
|
|
99
|
+
}
|
|
100
|
+
export interface HfVfxChain {
|
|
101
|
+
version: 1;
|
|
102
|
+
nodes: HfVfxNode[];
|
|
103
|
+
}
|
|
104
|
+
export declare class VfxChainError extends Error {
|
|
105
|
+
constructor(message: string);
|
|
106
|
+
}
|
|
107
|
+
/** The nodes that should paint, in order. */
|
|
108
|
+
export declare function enabledVfxNodes(chain: HfVfxChain): HfVfxNode[];
|
|
109
|
+
/** A chain's capture requirement is the strongest of its enabled nodes'. */
|
|
110
|
+
export declare function chainCapture(chain: HfVfxChain): HfVfxCapture;
|
|
111
|
+
/**
|
|
112
|
+
* Parse a chain file. Unknown effect ids are rejected rather than skipped: a
|
|
113
|
+
* chain that silently loses a node would render differently from the
|
|
114
|
+
* composition the author saved, which is worse than refusing to render at
|
|
115
|
+
* all. Params are kept as given (not normalized) so a chain round-trips
|
|
116
|
+
* exactly; call `normalizeVfxParams` at paint time.
|
|
117
|
+
*/
|
|
118
|
+
export declare function parseVfxChain(json: string): HfVfxChain;
|
|
119
|
+
/** Serialise a chain for the `data-vfx-chain` attribute. */
|
|
120
|
+
export declare function serializeVfxChain(chain: HfVfxChain): string;
|
|
121
|
+
//# sourceMappingURL=vfx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vfx.d.ts","sourceRoot":"","sources":["../src/vfx.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C;;;;GAIG;AAEH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,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