@margoengine/headless 0.1.0 → 1.0.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/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +1232 -768
- package/dist/accumulate.js +2 -2
- package/dist/ffmpeg-colour-B_r-2O-e.js +15 -0
- package/dist/ffmpeg-colour.d.ts +2 -0
- package/dist/ffmpeg-files.js +1 -1
- package/dist/ffmpeg.d.ts +6 -1
- package/dist/ffmpeg.js +143 -113
- package/dist/formats.js +2 -2
- package/dist/look-base.d.ts +87 -0
- package/dist/look-motion.d.ts +175 -0
- package/dist/look.d.ts +347 -125
- package/dist/look.js +1253 -567
- package/dist/null.js +2 -2
- package/dist/readback-HJLttuJt.js +2 -2
- package/dist/stage.js +2 -2
- package/dist/tiles.js +2 -2
- package/dist/yuv420-pool.d.ts +26 -0
- package/dist/yuv420-pool.js +73 -0
- package/dist/yuv420.d.ts +33 -0
- package/dist/yuv420.js +186 -0
- package/package.json +130 -122
- package/dist/ffmpeg-colour-Cg00HQ4H.js +0 -15
package/dist/look.d.ts
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export type LookImage = HeadlessPixels;
|
|
4
|
-
/** A mask: one byte per pixel, or RGBA where the first channel counts. 128 and above is inside. */
|
|
5
|
-
export interface LookMask {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
data: Uint8Array;
|
|
9
|
-
}
|
|
10
|
-
/** A float frame, RGBA: `Float32Array`, or `Uint16Array` of half-float bits as an `rgba16float` readback holds them. */
|
|
11
|
-
export interface FloatFrame {
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
data: Float32Array | Uint16Array;
|
|
15
|
-
}
|
|
16
|
-
/** A bound from a shot file's `lookBounds`: a number is the largest value that passes, `[low, high]` a range. */
|
|
17
|
-
export type LookBound = number | readonly [number, number];
|
|
18
|
-
/** The name of a look check, as `lookBounds` names it. */
|
|
19
|
-
export type LookCheckName = 'skyClip' | 'grain' | 'speckle' | 'banding' | 'flat' | 'blocks' | 'horizonSeam' | 'waterSeam' | 'lights' | 'foamEdges' | 'crush' | 'flicker' | 'shimmer' | 'nan' | 'backends' | 'reference' | 'penumbra' | 'stairs' | 'colourEdges' | 'chromaSmear' | 'shimmerMoving' | 'motionBlur' | 'silhouette' | 'silhouetteShape' | 'bounce' | 'shadowTint' | 'nightLuma' | 'nightPeak';
|
|
20
|
-
/** What a check gives back. */
|
|
21
|
-
export interface LookResult {
|
|
22
|
-
/** The check's name. */
|
|
23
|
-
check: LookCheckName | string;
|
|
24
|
-
/** The measured value, in `unit`. NaN when the check could not run (`missing`), which never passes. */
|
|
25
|
-
value: number;
|
|
26
|
-
/** `[low, high]`: the value passes when inside, ends included. */
|
|
27
|
-
bound: [number, number];
|
|
28
|
-
pass: boolean;
|
|
29
|
-
unit: string;
|
|
30
|
-
/** Set when the check could not run: what was missing. */
|
|
31
|
-
missing?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Set when the check ran over a mask with no pixels in it, so it measured nothing: for example `0 sky pixels` for
|
|
34
|
-
* a shot with no sky in view. The row passes, and the report says what it measured, so the pass is never silent.
|
|
35
|
-
*/
|
|
36
|
-
empty?: string;
|
|
37
|
-
/**
|
|
38
|
-
* The mask the check measured inside, by name, when {@link checkProbe} chose one: `sky` (the page's sky mask),
|
|
39
|
-
* `sky-coverage` (the pixels `@margoengine/sky` drew, when there is no `sky` mask) or `frame` (the whole frame).
|
|
40
|
-
* Set on `skyClip`; the report says which.
|
|
41
|
-
*/
|
|
42
|
-
mask?: string;
|
|
43
|
-
/** Further numbers the check measured, for the report. */
|
|
44
|
-
detail: Record<string, number>;
|
|
45
|
-
}
|
|
46
|
-
/** Each check's default bound, its unit and what it measures. A shot's `lookBounds` replaces the bound by name. */
|
|
47
|
-
export declare const LOOK_CHECKS: Readonly<Record<LookCheckName, {
|
|
48
|
-
bound: [number, number];
|
|
49
|
-
unit: string;
|
|
50
|
-
about: string;
|
|
51
|
-
}>>;
|
|
52
|
-
/** The `[low, high]` of a bound: a number is the high end, with no low end. */
|
|
53
|
-
export declare function lookBound(bound: LookBound): [number, number];
|
|
54
|
-
/** A row for a check that could not run, which fails: an asked-for check that did not run is not a pass. */
|
|
55
|
-
export declare function missingResult(check: LookCheckName | string, missing: string, bound?: LookBound): LookResult;
|
|
56
|
-
/** Luma of each pixel on 0 to 255: BT.709 weights on the encoded values. */
|
|
57
|
-
export declare function luma(image: LookImage): Float32Array;
|
|
1
|
+
import { type LookImage, type LookMask, type FloatFrame, type LookBound, type LookResult, type FlickerOptions } from './look-base.js';
|
|
2
|
+
export { LOOK_CHECKS, lookBound, missingResult, luma, type LookImage, type LookMask, type FloatFrame, type LookBound, type LookCheckName, type LookResult, type FlickerOptions, } from './look-base.js';
|
|
58
3
|
/** Options of {@link skyClip}. */
|
|
59
4
|
export interface SkyClipOptions {
|
|
60
5
|
/** The sky mask; the whole frame without one. */
|
|
@@ -76,6 +21,13 @@ export interface RegionOptions {
|
|
|
76
21
|
* [1 -2 1; -2 4 -2; 1 -2 1], which is blind to flat areas, ramps and planes, times sqrt(pi / 2) / 6.
|
|
77
22
|
*/
|
|
78
23
|
export declare function grain(frame: LookImage, { mask, bound }?: RegionOptions): LookResult;
|
|
24
|
+
/** The absolute Laplacian responses {@link grain} sums over the interior of `inside`, and how many. */
|
|
25
|
+
export interface GrainSums {
|
|
26
|
+
readonly sum: number;
|
|
27
|
+
readonly count: number;
|
|
28
|
+
}
|
|
29
|
+
/** {@link GrainSums} of `frame` over the interior pixels of `inside` (one byte a pixel, nonzero inside). */
|
|
30
|
+
export declare function grainSums(frame: LookImage, inside: Uint8Array): GrainSums;
|
|
79
31
|
/** Options of {@link speckle}. */
|
|
80
32
|
export interface SpeckleOptions extends RegionOptions {
|
|
81
33
|
/** A pixel this many codes above the brightest, or below the darkest, of its eight neighbours is a speckle. Default 24. */
|
|
@@ -91,7 +43,18 @@ export interface BandingOptions extends RegionOptions {
|
|
|
91
43
|
minStep?: number;
|
|
92
44
|
/** Steps above this many codes are edges of things, not bands. Default 12. */
|
|
93
45
|
maxStep?: number;
|
|
46
|
+
/** The frame before its dither ({@link PreciseFrame}): banding also runs on its colours rounded to 8-bit codes, and
|
|
47
|
+
* the worse of the two is the value ({@link preDither}). */
|
|
48
|
+
codes?: PreciseFrame;
|
|
94
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* The precise frame rounded to 8-bit codes with no dither, as an RGBA frame (alpha 255): the colours the scene gave
|
|
52
|
+
* the encode. A dither two levels wide (the shot tool's, KB-SHOT-DITHERMOD1) breaks every run of identical pixels on
|
|
53
|
+
* the delivered frame, so a flat or banded area of the scene shows only here. A window of identical pixels after a
|
|
54
|
+
* rectangular dither lies within 1/8192 of one code, so it rounds to one code: flat on these codes counts every window
|
|
55
|
+
* the old encode counted, and more.
|
|
56
|
+
*/
|
|
57
|
+
export declare function preDither(precise: PreciseFrame): LookImage;
|
|
95
58
|
/**
|
|
96
59
|
* Percent of pixels in banded runs: along every row and column, two neighbouring runs of identical pixels, each at
|
|
97
60
|
* least `minRun` long, whose luma differs by more than one code and at most `maxStep`. A smooth 8-bit gradient steps
|
|
@@ -104,12 +67,15 @@ export interface FlatOptions extends RegionOptions {
|
|
|
104
67
|
/** Half the side of the constant window: 32 is a 65 x 65 window, wider than the one-code steps of a slow 8-bit
|
|
105
68
|
* gradient, so a smooth sky is not flat. Default 32. */
|
|
106
69
|
radius?: number;
|
|
70
|
+
/** The frame before its dither ({@link PreciseFrame}): flat also runs on its colours rounded to 8-bit codes, and the
|
|
71
|
+
* worse of the two is the value ({@link preDither}). */
|
|
72
|
+
codes?: PreciseFrame;
|
|
107
73
|
}
|
|
108
74
|
/**
|
|
109
75
|
* Percent of pixels at the centre of a window of identical pixels, leaving out black and white (the crush and clip
|
|
110
76
|
* checks own those): an area with no variation at all, such as a missing texture or a fog that lost its detail.
|
|
111
77
|
*/
|
|
112
|
-
export declare function flat(frame: LookImage, {
|
|
78
|
+
export declare function flat(frame: LookImage, { codes, ...options }?: FlatOptions): LookResult;
|
|
113
79
|
/** Options of {@link blocks}. */
|
|
114
80
|
export interface BlocksOptions {
|
|
115
81
|
/** The block size in pixels, for example the froxel tile of `@margoengine/environment`. Default 8. */
|
|
@@ -219,12 +185,6 @@ export interface CrushOptions {
|
|
|
219
185
|
}
|
|
220
186
|
/** Percent of the pixels outside the declared dark areas that are crushed to black. */
|
|
221
187
|
export declare function crush(frame: LookImage, { dark, level, bound }?: CrushOptions): LookResult;
|
|
222
|
-
/** Options of {@link flicker} and {@link shimmer}. */
|
|
223
|
-
export interface FlickerOptions {
|
|
224
|
-
/** Only pixels inside this mask count. */
|
|
225
|
-
mask?: LookMask;
|
|
226
|
-
bound?: LookBound;
|
|
227
|
-
}
|
|
228
188
|
/**
|
|
229
189
|
* The largest jump of the mean luma off its trend over consecutive frames of a still camera, in codes: the most
|
|
230
190
|
* |m(t) - (m(t-1) + m(t+1)) / 2|. A steady change, a fade or a slow sweep, is a trend and passes.
|
|
@@ -267,6 +227,44 @@ export interface FlipResult {
|
|
|
267
227
|
* found in one image and not the other raise it.
|
|
268
228
|
*/
|
|
269
229
|
export declare function flip(test: LookImage, reference: LookImage, { pixelsPerDegree, map }?: FlipOptions): FlipResult;
|
|
230
|
+
/**
|
|
231
|
+
* A tone curve in the form of HDR-FLIP's Equation 1, y = (k0 x^2 + k1 x + k2) / (k3 x^2 + k4 x + k5), applied to each
|
|
232
|
+
* of R, G and B and clamped to 0..1: `'aces'` (the default, Narkowicz's ACES fit as `acesNarkowicz` in
|
|
233
|
+
* `packages/shared/aces.js` has it, with its 0.6 pre-scale), `'reinhard'` (Reinhard et al. 2002, x / (1 + x)) or the
|
|
234
|
+
* six coefficients of another curve that rises from 0 on [0, infinity).
|
|
235
|
+
*/
|
|
236
|
+
export type ToneCurve = 'aces' | 'reinhard' | readonly [number, number, number, number, number, number];
|
|
237
|
+
/** Options of {@link hdrFlip}. */
|
|
238
|
+
export interface HdrFlipOptions extends FlipOptions {
|
|
239
|
+
/** The tone curve every exposure goes through before LDR-FLIP compares it. Default `'aces'`. */
|
|
240
|
+
toneMapper?: ToneCurve;
|
|
241
|
+
/** Shortest exposure compensation, in stops. Default: the exposure that maps the reference's largest luminance to
|
|
242
|
+
* 0.85 after the tone curve. */
|
|
243
|
+
startExposure?: number;
|
|
244
|
+
/** Longest exposure compensation, in stops. Default: the exposure that maps the reference's median luminance to
|
|
245
|
+
* 0.85 after the tone curve. */
|
|
246
|
+
stopExposure?: number;
|
|
247
|
+
/** Also return, per pixel, the exposure (in stops) whose LDR pair gave the largest error. Default false. */
|
|
248
|
+
exposureMap?: boolean;
|
|
249
|
+
}
|
|
250
|
+
/** What {@link hdrFlip} gives back: the errors pooled as {@link flip}'s, and the exposures they were taken over. */
|
|
251
|
+
export interface HdrFlipResult extends FlipResult {
|
|
252
|
+
startExposure: number;
|
|
253
|
+
stopExposure: number;
|
|
254
|
+
/** How many exposures were compared: max(2, ceil(stop - start)). */
|
|
255
|
+
exposures: number;
|
|
256
|
+
/** With `exposureMap: true`: the exposure in stops that gave each pixel its error, row by row. */
|
|
257
|
+
exposureMap?: Float32Array;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* HDR-FLIP (Andersson, Nilsson, Shirley and Akenine-Moller 2021): the largest LDR-FLIP error a rendered HDR frame shows
|
|
261
|
+
* against its HDR reference over a range of exposures. Both float frames (linear Rec.709 RGBA, Float32 or half floats)
|
|
262
|
+
* are exposure compensated by 2^c for max(2, ceil(stop - start)) exposures c spread evenly from `startExposure` to
|
|
263
|
+
* `stopExposure`, tone mapped and clamped to 0..1, and each pair is compared with {@link flip}'s LDR-FLIP; each pixel
|
|
264
|
+
* keeps its largest error. The default range comes from the reference alone, so every test frame of one reference is
|
|
265
|
+
* judged over the same exposures.
|
|
266
|
+
*/
|
|
267
|
+
export declare function hdrFlip(test: FloatFrame, reference: FloatFrame, { pixelsPerDegree, map, toneMapper, startExposure, stopExposure, exposureMap, }?: HdrFlipOptions): HdrFlipResult;
|
|
270
268
|
/** Mean FLIP of a frame against a reference, as the `reference` (16-sample frame) or `backends` (compat frame) check. */
|
|
271
269
|
export declare function difference(frame: LookImage, other: LookImage, check: 'reference' | 'backends', { bound, ...options }?: FlipOptions & {
|
|
272
270
|
bound?: LookBound;
|
|
@@ -295,6 +293,28 @@ export interface LookProbe {
|
|
|
295
293
|
still?: LookImage[];
|
|
296
294
|
/** The frame after this one and each pixel's motion to it, for `shimmerMoving` and `motionBlur`. */
|
|
297
295
|
moving?: MovingFrames;
|
|
296
|
+
/** The light the frame was shaded with: `bounce` and `shadowTint` take their limits from it ({@link lightBounds}). */
|
|
297
|
+
light?: LookLight;
|
|
298
|
+
/** The frame before its 8 bits, which `bounce` and `shadowTint` read in its place. */
|
|
299
|
+
precise?: PreciseFrame;
|
|
300
|
+
/** The scene's light before its haze and tone map ({@link RadianceFrame}): `bounce` reads the ground's light from it. */
|
|
301
|
+
radiance?: RadianceFrame;
|
|
302
|
+
/**
|
|
303
|
+
* More frames whose ground `bounce` and `shadowTint` pool with this one's: each its precise frame (or frame) and its
|
|
304
|
+
* masks, or its {@link groundSample} made with this probe's choice of albedo (with one only if the probe has one).
|
|
305
|
+
* With the probe's `radiance`, each needs its own.
|
|
306
|
+
*/
|
|
307
|
+
pool?: ({
|
|
308
|
+
frame?: LookImage;
|
|
309
|
+
precise?: PreciseFrame;
|
|
310
|
+
radiance?: RadianceFrame;
|
|
311
|
+
masks: Record<string, LookMask>;
|
|
312
|
+
} | GroundSample)[];
|
|
313
|
+
/**
|
|
314
|
+
* The pooled frames' penumbra ground as {@link penumbraSample}s (what `checkShot` reads of the shot's `probePool`);
|
|
315
|
+
* `penumbra` pools these and every `pool` frame that holds its 8-bit frame and a `penumbra` mask.
|
|
316
|
+
*/
|
|
317
|
+
penumbraPool?: GrainSums[];
|
|
298
318
|
}
|
|
299
319
|
/** Options of {@link checkProbe}. */
|
|
300
320
|
export interface CheckProbeOptions {
|
|
@@ -374,12 +394,41 @@ export interface ShotManifestProbe {
|
|
|
374
394
|
moving?: {
|
|
375
395
|
next: string;
|
|
376
396
|
motion: string;
|
|
397
|
+
back?: string;
|
|
398
|
+
velocity?: string;
|
|
399
|
+
nextVelocity?: string;
|
|
400
|
+
/** Each pixel's distance from the eye, raw little-endian float32, one a pixel (`MovingFrames.distance`). */
|
|
401
|
+
distance?: string;
|
|
402
|
+
/** The same for the next frame (`MovingFrames.nextDistance`). */
|
|
403
|
+
nextDistance?: string;
|
|
404
|
+
/** The next frame's flame mask, a PNG (`MovingFrames.nextFlame`). */
|
|
405
|
+
nextFlame?: string;
|
|
377
406
|
};
|
|
378
407
|
/**
|
|
379
408
|
* This probe's own bounds, check name: bound. They replace the shot's `lookBounds` for the checks they name, on this
|
|
380
409
|
* probe only (for example a lights bound for the probes that face the lamps).
|
|
381
410
|
*/
|
|
382
411
|
lookBounds?: Record<string, LookBound>;
|
|
412
|
+
/** The light the frame was shaded with (the shot tool records it), for the T6 limits ({@link lightBounds}). */
|
|
413
|
+
light?: LookLight;
|
|
414
|
+
/** The frame before its 8 bits, raw little-endian RGB float32 rows, sRGB coded 0 to 1 (`.rgb32f`). */
|
|
415
|
+
precise?: string;
|
|
416
|
+
/**
|
|
417
|
+
* The scene's light before its haze and tone map, one little-endian float32 of linear luminance a pixel at the frame's
|
|
418
|
+
* size (`.radiance.f32`, the shot tool's `radiance` light image), which T6 `bounce` reads the ground's light from.
|
|
419
|
+
*/
|
|
420
|
+
radiance?: string;
|
|
421
|
+
/**
|
|
422
|
+
* More frames whose ground T6 and penumbra pool with this one's (the shot's `probePool`): each its precise frame, its
|
|
423
|
+
* 8-bit frame (`file`, which `penumbra` reads), masks and, with the probe's, its `radiance`.
|
|
424
|
+
*/
|
|
425
|
+
pool?: {
|
|
426
|
+
frame: number;
|
|
427
|
+
precise: string;
|
|
428
|
+
radiance?: string;
|
|
429
|
+
file?: string;
|
|
430
|
+
aovs?: Record<string, string>;
|
|
431
|
+
}[];
|
|
383
432
|
}
|
|
384
433
|
/** What {@link checkShot} reads. */
|
|
385
434
|
export interface CheckShotOptions extends CheckProbeOptions, LookReportOptions {
|
|
@@ -390,18 +439,28 @@ export interface CheckShotOptions extends CheckProbeOptions, LookReportOptions {
|
|
|
390
439
|
lookBounds?: Record<string, LookBound>;
|
|
391
440
|
lookFamily?: string | null;
|
|
392
441
|
};
|
|
442
|
+
/** How the frames were made: a shot drawn with sub-frames over a shutter is judged by `motionBlur` at that angle. */
|
|
443
|
+
render?: {
|
|
444
|
+
subframes?: number;
|
|
445
|
+
shutter?: number;
|
|
446
|
+
};
|
|
393
447
|
probes?: Record<string, ShotManifestProbe>;
|
|
394
448
|
};
|
|
395
449
|
/** Reads a file of the shot folder by its manifest path, for example `(path) => readFile(join(folder, path))`. */
|
|
396
450
|
read: (path: string) => Promise<Uint8Array>;
|
|
397
451
|
/** Stops between probes; the promise rejects with the signal's reason. */
|
|
398
452
|
signal?: AbortSignal;
|
|
453
|
+
/**
|
|
454
|
+
* How `shimmerMoving` warps a moving probe's pixels (`MovingFrames.reproject`): default `'velocity'` where the probe
|
|
455
|
+
* has both velocities, `'camera'` for the camera's motion alone, as before 2026-11-29.
|
|
456
|
+
*/
|
|
457
|
+
reproject?: 'velocity' | 'camera';
|
|
399
458
|
}
|
|
400
459
|
/**
|
|
401
460
|
* Runs the look checks on every probe of a rendered shot, with its `lookBounds` (and each probe's own `lookBounds` in
|
|
402
461
|
* their place for the checks a probe names), and makes the report.
|
|
403
462
|
*/
|
|
404
|
-
export declare function checkShot({ manifest, read, signal, pitch, pixelsPerDegree, ...report }: CheckShotOptions): Promise<LookReport>;
|
|
463
|
+
export declare function checkShot({ manifest, read, signal, pitch, pixelsPerDegree, reproject, ...report }: CheckShotOptions): Promise<LookReport>;
|
|
405
464
|
/** A bound per check for a named look family. `natural` has none: every check keeps its default. */
|
|
406
465
|
export declare const LOOK_FAMILY_BOUNDS: Readonly<Record<string, Readonly<Record<string, LookBound>>>>;
|
|
407
466
|
/**
|
|
@@ -437,73 +496,70 @@ export declare function colourEdges(frame: LookImage, { mask, strong, bound }?:
|
|
|
437
496
|
export interface ChromaSmearOptions extends RegionOptions {
|
|
438
497
|
/** A pixel whose CIE76 colour difference after the 4:2:0 round trip is over this is smeared. Default 6, clearly visible side by side. */
|
|
439
498
|
threshold?: number;
|
|
499
|
+
/** The 4:2:0 conversion modelled: `'sharp'` (default), the one the engine's film encodes ship
|
|
500
|
+
* (`@margoengine/headless/yuv420`, `encodeWithFFmpeg`, the shot tool's master); `'average'`, a plain filter, the
|
|
501
|
+
* one a scaler makes. */
|
|
502
|
+
chroma?: 'sharp' | 'average';
|
|
440
503
|
}
|
|
441
504
|
/**
|
|
442
|
-
* T7: percent of the pixels whose colour moves visibly when the frame is cut to 4:2:0 chroma
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* `threshold`.
|
|
447
|
-
* {@link colourEdges} counts the edges
|
|
505
|
+
* T7: percent of the pixels whose colour moves visibly when the frame is cut to 4:2:0 chroma by the encode that ships
|
|
506
|
+
* it, before any quantisation of the codec. The frame goes through {@link toYuv420} (BT.709, limited range, 8 bits,
|
|
507
|
+
* chroma sited on the left column between rows, the H.264 default the encode states) and back the way a player reads
|
|
508
|
+
* it ({@link fromYuv420}: bilinear chroma, the matrix, the clamp), and each pixel's CIE76 difference from the source
|
|
509
|
+
* is counted over `threshold`. An odd width or height is padded by its last column or row, as the encoder pads it.
|
|
510
|
+
* It needs no encoder, so it runs on any frame; where {@link colourEdges} counts the colour edges one pixel wide, this
|
|
511
|
+
* counts what the encode's chroma does to them.
|
|
448
512
|
*/
|
|
449
|
-
export declare function chromaSmear(frame: LookImage, { mask, threshold, bound }?: ChromaSmearOptions): LookResult;
|
|
513
|
+
export declare function chromaSmear(frame: LookImage, { mask, threshold, bound, chroma }?: ChromaSmearOptions): LookResult;
|
|
450
514
|
/** Options of {@link penumbra}. */
|
|
451
515
|
export interface PenumbraOptions {
|
|
452
516
|
/** The shadow penumbra mask. */
|
|
453
517
|
mask?: LookMask;
|
|
518
|
+
/** Where the plants are (the `plants` page mask): left out, so the grain is read on the ground alone. */
|
|
519
|
+
plants?: LookMask;
|
|
454
520
|
bound?: LookBound;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
521
|
+
/**
|
|
522
|
+
* More frames of the shot whose penumbra ground is pooled with this one's (the shot's `probePool`), each its frame and
|
|
523
|
+
* masks or its {@link penumbraSample}: a far penumbra under a pixel wide leaves too few interior pixels in one frame
|
|
524
|
+
* (KB-LOOK-TV-POOLFAILS1, rail-line mid), as a shadow interior does for `bounce`.
|
|
525
|
+
*/
|
|
526
|
+
pool?: ({
|
|
527
|
+
frame: LookImage;
|
|
528
|
+
penumbra: LookMask;
|
|
529
|
+
plants?: LookMask;
|
|
530
|
+
} | GrainSums)[];
|
|
531
|
+
}
|
|
532
|
+
/** A pooled frame's penumbra ground as {@link penumbra} pools it: its summed responses, so the frame and masks can go. */
|
|
533
|
+
export declare function penumbraSample(frame: LookImage, penumbraMask?: LookMask, plants?: LookMask): GrainSums;
|
|
469
534
|
/**
|
|
470
|
-
*
|
|
471
|
-
*
|
|
472
|
-
* (
|
|
535
|
+
* The fewest interior pixels {@link penumbra} and {@link penumbraPlants} read a grain from: 2,055, where the estimate's
|
|
536
|
+
* relative standard error is 5 percent. Immerkaer's value is a mean of absolute Laplacian responses; for Gaussian noise
|
|
537
|
+
* each one's standard deviation is sqrt(pi / 2 - 1) = 0.756 of its mean, and a response shares pixels with the 8 around
|
|
538
|
+
* it, so about one in 9 is independent: (3 x 0.756 / 0.05)^2 = 2,055.
|
|
473
539
|
*/
|
|
474
|
-
export declare
|
|
475
|
-
threshold?: number;
|
|
476
|
-
}): LookResult;
|
|
540
|
+
export declare const PENUMBRA_MIN_PIXELS: number;
|
|
477
541
|
/**
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}):
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
* than half their travel, where a 180 degree shutter smears it across the whole travel: strobing spray, rain or debris.
|
|
500
|
-
* An edge centre is a pixel whose luma profile along its motion (one travel wide, centred on it, spanning over 24 codes)
|
|
501
|
-
* crosses the middle value within one pixel of the pixel itself; the edge's width is the part of the profile between 10
|
|
502
|
-
* and 90 percent of its range. A hard edge is under a pixel wide, a blurred one as wide as its travel.
|
|
503
|
-
*/
|
|
504
|
-
export declare function motionBlur(frame: LookImage, motion: LookMotion, { mask, bound, minimum }?: FlickerOptions & {
|
|
505
|
-
minimum?: number;
|
|
506
|
-
}): LookResult;
|
|
542
|
+
* T1 in shadow penumbras: the grain of the ground inside the `penumbra` mask, the `plants` mask left out (bound 0.7
|
|
543
|
+
* codes for the family), over at least {@link PENUMBRA_MIN_PIXELS} interior pixels. Plants in the penumbra are held by
|
|
544
|
+
* {@link penumbraPlants}.
|
|
545
|
+
*/
|
|
546
|
+
export declare function penumbra(frame: LookImage, { mask, plants, bound, pool }?: PenumbraOptions): LookResult;
|
|
547
|
+
/** Options of {@link penumbraPlants}. */
|
|
548
|
+
export interface PenumbraPlantsOptions {
|
|
549
|
+
/** The shadow penumbra mask. */
|
|
550
|
+
penumbra: LookMask;
|
|
551
|
+
/** Where the plants are (the `plants` page mask). */
|
|
552
|
+
plants: LookMask;
|
|
553
|
+
bound?: LookBound;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* T1 on plants in shadow penumbras: the grain of the plants inside the `penumbra` mask over the grain of the plants
|
|
557
|
+
* outside it, where no shadow filter runs (fully lit or fully shadowed), in the same frame (bound 1: the penumbra adds
|
|
558
|
+
* no noise to the plants' own detail). Each side reads at least {@link PENUMBRA_MIN_PIXELS} interior pixels.
|
|
559
|
+
*/
|
|
560
|
+
export declare function penumbraPlants(frame: LookImage, { penumbra, plants, bound }: PenumbraPlantsOptions): LookResult;
|
|
561
|
+
import { type MovingFrames } from './look-motion.js';
|
|
562
|
+
export { shimmerMoving, reprojectionMotion, relativeViewProjections, depthFromDistance, motionBlur, PARALLAX_STEP, WATER_GAIN_RADIUS, type LookDistance, type LookMotion, type MovingFrames, } from './look-motion.js';
|
|
507
563
|
/** Options of the subject checks. */
|
|
508
564
|
export interface SilhouetteOptions {
|
|
509
565
|
/** The subject's mask: required. */
|
|
@@ -529,6 +585,31 @@ export interface BounceOptions {
|
|
|
529
585
|
lit: LookMask;
|
|
530
586
|
/** Where the ground is in shadow. */
|
|
531
587
|
shadow: LookMask;
|
|
588
|
+
/**
|
|
589
|
+
* The surface colour of each pixel, RGBA sRGB coded (an albedo AOV): the lit and shadowed ground are then compared
|
|
590
|
+
* within strata of like albedo. Unset, all ground is one stratum.
|
|
591
|
+
*/
|
|
592
|
+
albedo?: LookImage;
|
|
593
|
+
/**
|
|
594
|
+
* What is drawn over the scene's surfaces (an `over` AOV, 0 to 255: a flame's or smoke's coverage, as TAA's
|
|
595
|
+
* `reactiveMask` holds it): ground any of it covers is left out, since its colour is partly the effect's, not the
|
|
596
|
+
* ground's light (KB-LOOK-TV-TINTRES1). Unset, nothing is left out.
|
|
597
|
+
*/
|
|
598
|
+
over?: LookMask;
|
|
599
|
+
/** The frame's colours before its 8 bits, read in its place ({@link PreciseFrame}). */
|
|
600
|
+
precise?: PreciseFrame;
|
|
601
|
+
/**
|
|
602
|
+
* The scene's light before its haze and tone map ({@link RadianceFrame}): each pixel's luminance is read from it in
|
|
603
|
+
* place of the frame's, so the airlight a haze adds alike to the lit and the shadowed ground, and the tone curve, no
|
|
604
|
+
* longer lift the shadowed side's share (KB-LOOK-TV-HAZEBOUNCE1). The frame still gives b* for `shadowTint`. Every
|
|
605
|
+
* pooled frame then needs its own. Unset, the luminance is the frame's.
|
|
606
|
+
*/
|
|
607
|
+
radiance?: RadianceFrame;
|
|
608
|
+
/**
|
|
609
|
+
* More frames of the shot whose ground is pooled with this one's, for shadow interiors too small in one frame; the
|
|
610
|
+
* result's detail then gives `frames`, and `se` follows them ({@link GroundFrame}).
|
|
611
|
+
*/
|
|
612
|
+
pool?: (GroundFrame | GroundSample)[];
|
|
532
613
|
bound?: LookBound;
|
|
533
614
|
}
|
|
534
615
|
/**
|
|
@@ -537,16 +618,157 @@ export interface BounceOptions {
|
|
|
537
618
|
*/
|
|
538
619
|
export declare const GROUND_INSET: number;
|
|
539
620
|
/**
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
|
|
621
|
+
* The albedo of a probe's masks: `albedo-r`, `albedo-g` and `albedo-b` (grey masks of one sRGB coded channel each, as
|
|
622
|
+
* the shot tool writes an AOV) as one RGBA image, or undefined without all three.
|
|
623
|
+
*/
|
|
624
|
+
export declare function albedoOf(frame: {
|
|
625
|
+
width: number;
|
|
626
|
+
height: number;
|
|
627
|
+
}, masks: Record<string, LookMask>): LookImage | undefined;
|
|
628
|
+
/**
|
|
629
|
+
* The fewest interior pixels on each side, lit and shadowed, T6 reads once an `over` mask has left out the ground effects
|
|
630
|
+
* are drawn over: 30, the usual floor for treating a sample mean as normal (R. V. Hogg, E. A. Tanis and D. L.
|
|
631
|
+
* Zimmerman, "Probability and Statistical Inference", 9th ed., Pearson, 2015, section 5.6), which `detail.se` assumes.
|
|
632
|
+
*/
|
|
633
|
+
export declare const GROUND_MIN_PIXELS = 30;
|
|
634
|
+
/** Levels per sRGB channel of the albedo strata {@link bounce} and {@link shadowTint} compare within: 16 (16 codes). */
|
|
635
|
+
export declare const GROUND_ALBEDO_LEVELS = 16;
|
|
636
|
+
/**
|
|
637
|
+
* The side of the frame's blocks T6 compares lit and shadowed ground within, as a share of the frame's shorter side:
|
|
638
|
+
* 1/10, 108 pixels at 1080p. A shadow's ratio is read across its own edge, where the light other than the sun's beam is
|
|
639
|
+
* the same on both sides (G. D. Finlayson, S. D. Hordley, C. Lu and M. S. Drew, "On the removal of shadows from
|
|
640
|
+
* images", IEEE TPAMI 28(1), 59-68, 2006, https://doi.org/10.1109/TPAMI.2006.18; illumination varies slowly across an
|
|
641
|
+
* image, E. H. Land and J. J. McCann, "Lightness and Retinex theory", JOSA 61(1), 1-11, 1971,
|
|
642
|
+
* https://doi.org/10.1364/JOSA.61.000001). Across a whole frame it is not: in the timber-valley rail-line shot the sun
|
|
643
|
+
* is 1.6 percent of the ground's light and the haze the fire lights from below brightens one side of the frame, so 74
|
|
644
|
+
* shadowed pixels a frame beside the fire read 137 percent of the lit road across the frame and 95 percent beside
|
|
645
|
+
* themselves (KB-LOOK-TV-POOLFAILS1).
|
|
646
|
+
*/
|
|
647
|
+
export declare const GROUND_BLOCK: number;
|
|
648
|
+
/**
|
|
649
|
+
* The ground pixels of one albedo stratum, lit side first: counts and sums of Y and b* and of their squares, and of the
|
|
650
|
+
* albedo's luminance A (1 a pixel without an albedo), its square and Y x A.
|
|
651
|
+
*/
|
|
652
|
+
export interface GroundStratum {
|
|
653
|
+
n: [number, number];
|
|
654
|
+
Y: [number, number];
|
|
655
|
+
b: [number, number];
|
|
656
|
+
/** Sums of squares of Y and b*, for the standard error. */
|
|
657
|
+
Y2: [number, number];
|
|
658
|
+
b2: [number, number];
|
|
659
|
+
/** Sums of the albedo's linear luminance, of its square and of Y times it: what each side's light is read over. */
|
|
660
|
+
A: [number, number];
|
|
661
|
+
A2: [number, number];
|
|
662
|
+
YA: [number, number];
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* The frame's colours before its 8 bits (the shot tool's precise frame, `.rgb32f`): RGB floats, sRGB coded 0 to 1,
|
|
666
|
+
* row 0 at the top. T6 reads it in place of the 8-bit frame, whose blue codes are 0.4 b* apart at dark ground.
|
|
667
|
+
*/
|
|
668
|
+
export interface PreciseFrame {
|
|
669
|
+
width: number;
|
|
670
|
+
height: number;
|
|
671
|
+
data: Float32Array;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* The scene's light before its haze and tone map: one float a pixel, its linear luminance at any one scale (the shot
|
|
675
|
+
* tool's `radiance` light image, from the `texture` of a `@margoengine/sky/aov` `fogInputCapture` given as a sky's `fog.keepInput`), row 0 at the top.
|
|
676
|
+
*/
|
|
677
|
+
export interface RadianceFrame {
|
|
678
|
+
width: number;
|
|
679
|
+
height: number;
|
|
680
|
+
data: Float32Array;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* A frame's ground reduced to its albedo strata ({@link groundSample}): what {@link bounce} and {@link shadowTint} read of
|
|
684
|
+
* a pooled frame, a few numbers in place of its frame and masks.
|
|
685
|
+
*/
|
|
686
|
+
export interface GroundSample {
|
|
687
|
+
readonly strata: ReadonlyMap<number, Readonly<GroundStratum>>;
|
|
688
|
+
/** Ground interior pixels its `over` mask left out; undefined without one. */
|
|
689
|
+
readonly covered?: number;
|
|
690
|
+
/** True where its luminance came from a {@link RadianceFrame}. */
|
|
691
|
+
readonly radiance?: boolean;
|
|
692
|
+
}
|
|
693
|
+
/** One more frame of a shot whose ground {@link bounce} and {@link shadowTint} pool with the probe's. */
|
|
694
|
+
export interface GroundFrame {
|
|
695
|
+
/** The frame, 8-bit; unused where `precise` is given. */
|
|
696
|
+
frame?: LookImage;
|
|
697
|
+
precise?: PreciseFrame;
|
|
698
|
+
/** The scene's light before its haze and tone map ({@link BounceOptions.radiance}). */
|
|
699
|
+
radiance?: RadianceFrame;
|
|
700
|
+
lit: LookMask;
|
|
701
|
+
shadow: LookMask;
|
|
702
|
+
albedo?: LookImage;
|
|
703
|
+
/** What is drawn over the surfaces ({@link BounceOptions.over}). */
|
|
704
|
+
over?: LookMask;
|
|
705
|
+
}
|
|
706
|
+
/** A frame's ground as {@link bounce} and {@link shadowTint} pool it: its strata, so the frame and masks can go. */
|
|
707
|
+
export declare function groundSample(frame: GroundFrame): GroundSample;
|
|
708
|
+
/**
|
|
709
|
+
* T6: the light on the shadowed ground as a percent of the lit ground's, in linear light (each side's luminance over its
|
|
710
|
+
* albedo's luminance with `albedo`, its mean luminance without), each averaged over
|
|
711
|
+
* its mask's interior (pixels the mask covers whole, {@link GROUND_INSET} in from the edges, where the frame mixes both
|
|
712
|
+
* sides). Shadow that holds 10 to 35 percent of the sunlit value carries bounce and sky light; under 10 is crushed,
|
|
713
|
+
* over 35 flat. With `albedo` the lit and shadowed ground are compared surface for like surface ({@link GROUND_ALBEDO_LEVELS}).
|
|
543
714
|
*/
|
|
544
715
|
export declare function bounce(frame: LookImage, { lit, shadow, bound }: BounceOptions): LookResult;
|
|
545
716
|
/**
|
|
546
717
|
* T6: how much cooler (lower b*) the shadowed ground is than the lit ground, in CIE b* points (at least 3), over the
|
|
547
|
-
* masks' interiors as {@link bounce}.
|
|
718
|
+
* masks' interiors and, with `albedo`, surface for like surface, as {@link bounce}.
|
|
548
719
|
*/
|
|
549
720
|
export declare function shadowTint(frame: LookImage, { lit, shadow, bound }: BounceOptions): LookResult;
|
|
721
|
+
/**
|
|
722
|
+
* The light a frame was shaded with, as the shot tool records it from the engine: the sun as core holds it and the
|
|
723
|
+
* diffuse light on level ground. Both are in the engine light's units, so level ground of albedo a takes
|
|
724
|
+
* a x `intensity` x `colour` x max(`direction`[1], 0) / pi from the sun and a x `ambient` from the sky.
|
|
725
|
+
*/
|
|
726
|
+
export interface LookLight {
|
|
727
|
+
/** The sun (or moon): `direction` toward it, unit; `intensity`; `colour`, linear RGB. */
|
|
728
|
+
sun: {
|
|
729
|
+
direction: readonly number[];
|
|
730
|
+
intensity: number;
|
|
731
|
+
colour: readonly number[];
|
|
732
|
+
};
|
|
733
|
+
/** The diffuse light on level ground: irradiance over pi, linear RGB (the sky's harmonics, or core's ambient). */
|
|
734
|
+
ambient: readonly number[];
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Erbs, Klein and Duffie's diffuse fraction of global horizontal light for an hourly clearness index `kt` ("Estimation
|
|
738
|
+
* of the diffuse radiation fraction for hourly, daily and monthly-average global radiation", Solar Energy 28(4),
|
|
739
|
+
* 293-302, 1982, https://doi.org/10.1016/0038-092X(82)90302-4).
|
|
740
|
+
*/
|
|
741
|
+
export declare function erbsDiffuseFraction(kt: number): number;
|
|
742
|
+
/**
|
|
743
|
+
* The diffuse fraction up to which a sun counts as clear, where T6 keeps its sunlit limits (10 to 35 percent, 3 b*):
|
|
744
|
+
* {@link erbsDiffuseFraction} at the clearness index 0.65 above which a sky is clear (0 to 0.3 overcast, 0.3 to 0.65
|
|
745
|
+
* intermediate: A. H. Fakra, H. Boyer, F. Miranville, D. Bigot, "A simple evaluation of global and diffuse luminous
|
|
746
|
+
* efficacy for all sky conditions in tropical and humid climate", Renewable Energy 36(1), 298-306, 2011,
|
|
747
|
+
* https://arxiv.org/abs/1212.5259), 0.3336.
|
|
748
|
+
*/
|
|
749
|
+
export declare const CLEAR_SUN_DIFFUSE: number;
|
|
750
|
+
/** What {@link lightBounds} gives: the T6 limits for a light and the diffuse fraction they follow. */
|
|
751
|
+
export interface LightBounds {
|
|
752
|
+
/** The share of level ground's light that is diffuse, 0 to 1: ambient luminance over ambient plus the sun's. */
|
|
753
|
+
diffuse: number;
|
|
754
|
+
bounce: [number, number];
|
|
755
|
+
shadowTint: [number, number];
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* The T6 limits that follow a frame's own light (KB-LOOK-TV-PALL1). Level ground in the open takes the sun's beam and
|
|
759
|
+
* the sky's diffuse light; a cast shadow loses the beam and keeps the sky it still sees plus the light bounced into it,
|
|
760
|
+
* both in proportion to the diffuse light. So the share a shadow holds scales with the diffuse fraction d of the lit
|
|
761
|
+
* ground's light, and the cooling it shows with the beam's share 1 - d. Up to {@link CLEAR_SUN_DIFFUSE} (a clear sun)
|
|
762
|
+
* the limits are `base` unchanged; above it `bounce` is base x d / CLEAR_SUN_DIFFUSE (the high end at most 100) and the
|
|
763
|
+
* low end of `shadowTint` base x (1 - d) / (1 - CLEAR_SUN_DIFFUSE). A smoke pall or an overcast sky, nearly all diffuse
|
|
764
|
+
* light, so asks for shadows near the lit ground and little tint, as measured under one (Garcia et al., Atmos. Meas.
|
|
765
|
+
* Tech. 19, 3151-3167, 2026, https://doi.org/10.5194/amt-19-3151-2026), and never for crushed shadows.
|
|
766
|
+
* `base` defaults to the checks' defaults (10 to 35 percent, 3 to 100 b*).
|
|
767
|
+
*/
|
|
768
|
+
export declare function lightBounds(light: LookLight, base?: {
|
|
769
|
+
bounce?: LookBound;
|
|
770
|
+
shadowTint?: LookBound;
|
|
771
|
+
}): LightBounds;
|
|
550
772
|
/** T7 at night: the mean luma of the frame, in codes (at least 24, a night that still reads on a phone). */
|
|
551
773
|
export declare function nightLuma(frame: LookImage, { mask, bound }?: RegionOptions): LookResult;
|
|
552
774
|
/** T7 at night: the luma the brightest 1 percent of the frame reaches, in codes (over 180: a night has its lights). */
|