@margoengine/dof 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/dist/index.d.ts CHANGED
@@ -19,8 +19,17 @@ export interface DOFOptions {
19
19
  sensorFit?: 'auto' | 'horizontal' | 'vertical';
20
20
  /** Lens f-number, default 2.8. */
21
21
  aperture?: number;
22
- /** Maximum disk radius in pixels, 1-32. Default 16. */
22
+ /**
23
+ * Maximum disk radius in pixels of a view `referenceHeight` pixels tall, 1-32. Default 16. The cap scales with the
24
+ * view's height, so it is the same share of the frame on any canvas: 16 px at 1080, 32 px on a 2160 px canvas (a 2x
25
+ * supersampled 1080p shot), 8 px at 540; at most 128 px.
26
+ */
23
27
  maxRadius?: number;
28
+ /**
29
+ * The view height in pixels at which `maxRadius` holds (KB-DOF-CAPSCALE1). Default 1080, so a 1080 px view caps as
30
+ * before. Set it to a page's own height to cap in that page's pixels. Read every frame.
31
+ */
32
+ referenceHeight?: number;
24
33
  /** False skips the blur and presents the scene sharp. Default true; also settable as `dof.enabled`. */
25
34
  enabled?: boolean;
26
35
  /** Tilt-shift and polygon bokeh, from `@margoengine/dof/lens`. Read when the effect attaches. Default: none. */
@@ -63,6 +72,7 @@ export declare class DOF implements EnginePlugin {
63
72
  private tilesPipeline?;
64
73
  private tilesGroup?;
65
74
  private waiting;
75
+ private routeReady;
66
76
  private presentPipeline?;
67
77
  private scene?;
68
78
  private depth?;
@@ -87,6 +97,13 @@ export declare class DOF implements EnginePlugin {
87
97
  private halfTiles?;
88
98
  private blurred?;
89
99
  private turn;
100
+ private alpha;
101
+ private kernels?;
102
+ private compatPipelines?;
103
+ private coarseAlpha?;
104
+ private blurredAlpha?;
105
+ private coarseAlphaView?;
106
+ private blurredAlphaView?;
90
107
  private readonly shaders;
91
108
  private readonly attachment;
92
109
  private readonly presentation;
@@ -115,6 +132,24 @@ export declare class DOF implements EnginePlugin {
115
132
  private joinStack;
116
133
  private validate;
117
134
  setup(engine: Engine): void;
135
+ /** The pipelines for an opaque canvas, or with `alpha` for a premultiplied one (./alpha.ts). */
136
+ private build;
137
+ /** Swaps in the WebGL2 route's pipelines once it has loaded. */
138
+ private useCompat;
139
+ /**
140
+ * Settles once every frame draws the blur as it will from then on. On the WebGL2 compatibility layer DOF loads its
141
+ * route (a dynamic import) when it attaches, and DOF used alone shows the captured scene sharp until it has loaded.
142
+ * Resolved at once on WebGPU. Read it after attaching, and await it before a frame that must be exact: a film frame,
143
+ * a pixel comparison (KB-COMPAT-READY1).
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const dof = DOF.attach(engine, { focalDistance: 5 });
148
+ * await dof.ready;
149
+ * engine.render();
150
+ * ```
151
+ */
152
+ get ready(): Promise<void>;
118
153
  /** True while DOF, used alone, waits for its WebGL2 route (it presents the captured scene unblurred then). */
119
154
  private get paused();
120
155
  registerPasses(graph: FrameGraph): void;