@margoengine/shader 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 +1920 -1771
- package/dist/attribute.d.ts +28 -0
- package/dist/black-hole.js +3 -3
- package/dist/clock-BLGNexlt.js +3 -3
- package/dist/{compute-D-BghbXj.js → compute-CXGG9qvI.js} +76 -70
- package/dist/compute-texture.js +3 -3
- package/dist/compute-volume.js +3 -3
- package/dist/compute.d.ts +8 -2
- package/dist/{control-DvjfV7R0.js → control-CFjkGPBk.js} +1 -1
- package/dist/deform.js +2 -2
- package/dist/editor-pass.js +17 -17
- package/dist/effects.js +2 -2
- package/dist/glsl-material.js +2 -2
- package/dist/glsl-pass.js +5 -5
- package/dist/glsl.js +18 -18
- package/dist/gpu-DQJk2xAv.js +55 -0
- package/dist/graph.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +103 -8
- package/dist/{lighting-Dx8_RsBz.js → lighting-JU9yQPfM.js} +2 -2
- package/dist/lighting.js +1 -1
- package/dist/{material-CU7p-Q8u.js → material-C6bpqlnE.js} +1 -1
- package/dist/{material-REzUrXtu.js → material-CZ8V1FeA.js} +95 -71
- package/dist/material.d.ts +9 -4
- package/dist/{node-DzKv9CF2.js → node-B6yoIC9V.js} +126 -126
- package/dist/node.d.ts +7 -1
- package/dist/noise.js +1 -1
- package/dist/pass.d.ts +1 -0
- package/dist/pass.js +24 -21
- package/dist/{post-DC62ZleD.js → post-DLpZ110L.js} +17 -17
- package/dist/{raw-D0W8U3Qa.js → raw-0AYej3Ak.js} +422 -273
- package/dist/raw.d.ts +125 -15
- package/dist/raw.js +1 -1
- package/dist/readback.js +13 -12
- package/dist/serialization.js +12 -12
- package/dist/shadertoy.js +6 -6
- package/dist/shared/caster.d.ts +159 -152
- package/dist/shared/fog.d.ts +33 -33
- package/dist/shared/fractal.d.ts +9 -9
- package/dist/shared/msaa.d.ts +30 -25
- package/dist/shared/stack.d.ts +22 -22
- package/dist/subgroups.js +4 -4
- package/dist/{texture-D6vy0bam.js → texture-BawKO_h9.js} +1 -1
- package/dist/texture-array.js +2 -2
- package/dist/utils.js +32 -32
- package/package.json +151 -151
- package/dist/gpu-DQ5Jmggz.js +0 -31
package/dist/raw.d.ts
CHANGED
|
@@ -18,6 +18,19 @@ export interface RawAttribute {
|
|
|
18
18
|
}
|
|
19
19
|
/** One value of a {@link RawUniform}: a number, a colour string or the numbers of a vector or matrix. */
|
|
20
20
|
export type RawUniformValue = number | string | ArrayLike<number>;
|
|
21
|
+
/** The value of a struct uniform: one entry per field, a nested struct's an object and an array field's a list. */
|
|
22
|
+
export interface RawUniformStructValue {
|
|
23
|
+
readonly [field: string]: RawUniformValue | RawUniformStructValue | readonly RawUniformValue[] | readonly RawUniformStructValue[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A struct field that is not a plain type: `struct` nests another struct, `count` makes an array of `type` (16 bytes
|
|
27
|
+
* apart, as a uniform array) or of the nested struct.
|
|
28
|
+
*/
|
|
29
|
+
export interface RawUniformField {
|
|
30
|
+
readonly type?: RawUniformType;
|
|
31
|
+
readonly count?: number;
|
|
32
|
+
readonly struct?: Readonly<Record<string, RawUniformType | RawUniformField>>;
|
|
33
|
+
}
|
|
21
34
|
/**
|
|
22
35
|
* A live uniform: assign `material.uniforms.name.value` any time. A number is an f32 (or the scalar of
|
|
23
36
|
* `type`), 2/3/4/9/16 numbers a vecNf/mat3x3f/mat4x4f, and `'#rrggbb'`/`0xrrggbb` with a vec3f type an sRGB colour
|
|
@@ -26,15 +39,18 @@ export type RawUniformValue = number | string | ArrayLike<number>;
|
|
|
26
39
|
* construction.
|
|
27
40
|
*/
|
|
28
41
|
export interface RawUniform {
|
|
29
|
-
value: RawUniformValue | readonly RawUniformValue[] |
|
|
42
|
+
value: RawUniformValue | readonly RawUniformValue[] | RawUniformStructValue | readonly RawUniformStructValue[];
|
|
30
43
|
readonly type?: RawUniformType;
|
|
31
44
|
/**
|
|
32
45
|
* Elements of an `array<type, count>`, read as `uniforms.<name>[i]`. A uniform array's stride is a multiple of 16 bytes, so
|
|
33
46
|
* the element is a vec3, a vec4, a matrix or a struct; a storage buffer holds tighter arrays.
|
|
34
47
|
*/
|
|
35
48
|
readonly count?: number;
|
|
36
|
-
/**
|
|
37
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Field names and types of a struct, read as `uniforms.<name>.<field>`. A field is a plain type, or a
|
|
51
|
+
* {@link RawUniformField}: a nested struct (`uniforms.<name>.<field>.<inner>`) or an array (`uniforms.<name>.<field>[i]`).
|
|
52
|
+
*/
|
|
53
|
+
readonly struct?: Readonly<Record<string, RawUniformType | RawUniformField>>;
|
|
38
54
|
}
|
|
39
55
|
/**
|
|
40
56
|
* A storage buffer a raw shader reads, declared `<name>:array<type>`. A `storage()` node of `@margoengine/shader` fits as it
|
|
@@ -114,6 +130,16 @@ export interface RawShaderMaterialOptions {
|
|
|
114
130
|
* depth still occludes and its pixels are not darkened.
|
|
115
131
|
*/
|
|
116
132
|
gbufferEntry?: string;
|
|
133
|
+
/**
|
|
134
|
+
* A `@fragment fn` of the fragment code that returns `margoCapture(MargoMaterial(worldPosition, worldNormal, toEye,
|
|
135
|
+
* baseColor, metallic, roughness, ambient))` as a `MargoCapture`, drawn when the RawShaders is added to screen-space
|
|
136
|
+
* reflections or screen-space global illumination (`ssr.add(raw)`, `ssgi.add(raw)`). SSR reads its normal, base colour,
|
|
137
|
+
* metallic and roughness, so the mesh reflects the screen; SSGI reads its normal and diffuse albedo, so bounced light
|
|
138
|
+
* reaches it. `ambient` is the ambient light the colour fragment added (SSGI replaces it with the bounce); `vec3f(0)`
|
|
139
|
+
* when it added none. Without it the mesh's depth still hides what is behind it, and it neither reflects nor takes
|
|
140
|
+
* bounced light. Default none.
|
|
141
|
+
*/
|
|
142
|
+
captureEntry?: string;
|
|
117
143
|
/**
|
|
118
144
|
* A `@vertex fn` of the vertex code that returns `margoVelocity(position, positionBefore)`: where the vertex is now and
|
|
119
145
|
* where it was last frame, both before `mesh.world`. Drawn when the RawShaders is added to TAA (`taa.add(raw)`), it gives
|
|
@@ -157,11 +183,16 @@ export interface RawShaderMaterialOptions {
|
|
|
157
183
|
/** Debug and error-message name. Default `'raw:<n>'`. */
|
|
158
184
|
name?: string;
|
|
159
185
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
/** What `RawShaders.setCapture` takes: the material capture hook of `@margoengine/post` SSR and SSGI (their `SSRCapture`). */
|
|
187
|
+
export interface RawCapture {
|
|
188
|
+
/** Module-scope WGSL for the capture code: `struct MargoCapture` and `fn margoCapture(m:MargoMaterial)->MargoCapture`. */
|
|
189
|
+
declarations(code: string): string;
|
|
190
|
+
/** Colour targets of the capture pass, in `MargoCapture` location order. */
|
|
191
|
+
readonly targets: readonly GPUColorTargetState[];
|
|
192
|
+
/** This frame's capture pass, begun on the first draw and ended by its owner. */
|
|
193
|
+
begin(): GPURenderPassEncoder;
|
|
164
194
|
}
|
|
195
|
+
/** A uniform block member or a struct field. */
|
|
165
196
|
interface Member {
|
|
166
197
|
name: string;
|
|
167
198
|
/** A uniform type, or the generated struct's name. */
|
|
@@ -170,10 +201,15 @@ interface Member {
|
|
|
170
201
|
/** Elements of an array, and the bytes from one to the next (a struct's size when it is not an array). */
|
|
171
202
|
count?: number;
|
|
172
203
|
stride?: number;
|
|
173
|
-
fields?:
|
|
204
|
+
fields?: Member[];
|
|
205
|
+
}
|
|
206
|
+
/** A generated struct of the prelude. */
|
|
207
|
+
interface RawStruct {
|
|
208
|
+
type: string;
|
|
209
|
+
fields: Member[];
|
|
174
210
|
}
|
|
175
211
|
/** Which pipeline of a material: the colour pass, a shadow cascade, SSAO's G-buffer or a pick. */
|
|
176
|
-
type RawPass = 'color' | 'shadow' | 'gbuffer' | 'pick' | 'velocity';
|
|
212
|
+
type RawPass = 'color' | 'shadow' | 'gbuffer' | 'pick' | 'velocity' | 'capture' | 'captureDepth';
|
|
177
213
|
interface PipelineEntry {
|
|
178
214
|
state: 'pending' | 'ready' | 'failed';
|
|
179
215
|
pipeline?: GPURenderPipeline;
|
|
@@ -236,12 +272,19 @@ export declare class RawShaderMaterial<U extends {
|
|
|
236
272
|
error?: Error;
|
|
237
273
|
/** @internal Uniform block members with byte offsets; `size` is the block size in bytes. */
|
|
238
274
|
readonly members: readonly Member[];
|
|
275
|
+
/** @internal The generated structs, nested ones first. */
|
|
276
|
+
readonly structs: readonly RawStruct[];
|
|
239
277
|
/** @internal */ readonly size: number;
|
|
240
278
|
/** @internal */ readonly gpu: Map<GPUDevice, MaterialGpu>;
|
|
241
279
|
/** @internal Bumped when the shader code changes. */ revision: number;
|
|
242
280
|
/** @internal Pipelines finished so far: a static shadow map redraws when a caster's pipeline arrives. */ compiled: number;
|
|
281
|
+
/** @internal Bumped by {@link uniformVersion} when the uniform values changed since it last looked. */
|
|
282
|
+
private uniformChanges;
|
|
283
|
+
private uniformSeen?;
|
|
243
284
|
private readonly groups;
|
|
244
285
|
private readonly gbufferName?;
|
|
286
|
+
/** @internal The `captureEntry`, when the material writes SSR's and SSGI's material targets. */
|
|
287
|
+
readonly captureName?: string;
|
|
245
288
|
/** @internal The `velocityEntry`, when the material draws its own motion for TAA. */ readonly velocityName?: string;
|
|
246
289
|
private vertexCode;
|
|
247
290
|
private fragmentCode?;
|
|
@@ -259,7 +302,7 @@ export declare class RawShaderMaterial<U extends {
|
|
|
259
302
|
set fragmentShader(code: string | undefined);
|
|
260
303
|
private setCode;
|
|
261
304
|
/** The declarations added in front of each stage for `mesh` (its `Attributes` struct) or for no attributes. */
|
|
262
|
-
prelude(mesh?: RawMesh): string;
|
|
305
|
+
prelude(mesh?: RawMesh, capture?: boolean): string;
|
|
263
306
|
/** The whole WGSL module of `stage` for `mesh`: the prelude, then your code. */
|
|
264
307
|
code(stage: 'vertex' | 'fragment', mesh?: RawMesh): string;
|
|
265
308
|
/** Releases this material's GPU objects; it rebuilds them if drawn again. */
|
|
@@ -273,15 +316,25 @@ export declare class RawShaderMaterial<U extends {
|
|
|
273
316
|
drawnBy?: RawShaders;
|
|
274
317
|
/** @internal Uploads changed uniforms and (re)builds the material bind group, once per plugin pass. */
|
|
275
318
|
prepare(device: GPUDevice, pass: number, owner?: RawShaders): MaterialGpu;
|
|
319
|
+
/**
|
|
320
|
+
* @internal A number that changes when the uniform values change: the block is written from `uniforms` and compared
|
|
321
|
+
* with the bytes seen last time, so a cached shadow map redraws after a uniform the vertex stage reads changed.
|
|
322
|
+
*/
|
|
323
|
+
uniformVersion(): number;
|
|
276
324
|
private write;
|
|
325
|
+
/** Writes `v` for member or field `m` at byte `at`: a plain value, an array of them, or struct fields, nested too. */
|
|
326
|
+
private store;
|
|
327
|
+
private fields;
|
|
277
328
|
private put;
|
|
278
329
|
/** @internal True when the G-buffer pass has a fragment to draw. */
|
|
279
330
|
get writesGBuffer(): boolean;
|
|
331
|
+
/** @internal The capture module's fragment code: the prelude, the capture hook's declarations, then your code. */
|
|
332
|
+
captureCode(mesh: RawMesh, hook: RawCapture): string;
|
|
280
333
|
/** @internal What differs between the pipelines of one material: the fragment, its targets and the depth state. */
|
|
281
334
|
private target;
|
|
282
335
|
private bias;
|
|
283
336
|
/** @internal The pipeline for `key`, compiling it on first use; undefined while pending or after a failure. */
|
|
284
|
-
pipeline(plugin: RawShaders, gpu: MaterialGpu, device: GPUDevice, mesh: RawMesh, kind: RawPass, c?: RawPassContext, compare?: GPUCompareFunction): GPURenderPipeline | undefined;
|
|
337
|
+
pipeline(plugin: RawShaders, gpu: MaterialGpu, device: GPUDevice, mesh: RawMesh, kind: RawPass, c?: RawPassContext, compare?: GPUCompareFunction, motionFormat?: GPUTextureFormat, capture?: RawCapture): GPURenderPipeline | undefined;
|
|
285
338
|
}
|
|
286
339
|
/** Interleaved CPU copy of one step mode's attributes, uploaded whole or by element range. */
|
|
287
340
|
/**
|
|
@@ -332,6 +385,21 @@ export interface RawShadowContext {
|
|
|
332
385
|
/** Cascade index, 0-3. */
|
|
333
386
|
cascade: number;
|
|
334
387
|
}
|
|
388
|
+
/** What `RawMesh.drawLocalShadow` receives: the `LocalShadowDraw` of `@margoengine/clustered/shadows`. */
|
|
389
|
+
export interface RawLocalShadowDraw {
|
|
390
|
+
context: RawPassContext;
|
|
391
|
+
/** The layer's open depth pass (reversed depth, near 1 and far 0, unless `depthCompare` is `less-equal`). */
|
|
392
|
+
pass: GPURenderPassEncoder;
|
|
393
|
+
/** The layer's world to clip matrix. */
|
|
394
|
+
matrix: Float32Array;
|
|
395
|
+
/** The layer index. */
|
|
396
|
+
layer: number;
|
|
397
|
+
/**
|
|
398
|
+
* The layer's depth test: `greater` for reversed depth (`LocalShadows`, and the default when left out) or
|
|
399
|
+
* `less-equal` for Clustered's integrated `shadows` maps (near 0, far 1).
|
|
400
|
+
*/
|
|
401
|
+
depthCompare?: 'greater' | 'less-equal';
|
|
402
|
+
}
|
|
335
403
|
/** Any raw material: a RawShaderMaterial or a subclass such as ShaderMaterial. */
|
|
336
404
|
export type AnyRawShaderMaterial = RawShaderMaterial<{
|
|
337
405
|
value: unknown;
|
|
@@ -435,12 +503,24 @@ export declare class RawMesh<M extends AnyRawShaderMaterial = AnyRawShaderMateri
|
|
|
435
503
|
* @throws RangeError for a negative or non-integer index.
|
|
436
504
|
*/
|
|
437
505
|
setIndex(index: Uint16Array | Uint32Array | readonly number[] | null): this;
|
|
438
|
-
/**
|
|
506
|
+
/**
|
|
507
|
+
* Changes when a cached shadow map must draw this mesh again: new attributes or indices, a newly compiled pipeline,
|
|
508
|
+
* another material or new uniform values, a moved mesh (its world matrix, the followed core mesh's included) and
|
|
509
|
+
* `invalidateShadow()`. What it cannot see, such as a vertex stage moving points by `camera.time`, a texture or a
|
|
510
|
+
* storage buffer, needs `invalidateShadow()` or a caster that redraws every frame.
|
|
511
|
+
*/
|
|
439
512
|
get shadowVersion(): number;
|
|
513
|
+
private seenWorld?;
|
|
514
|
+
private seenMaterial?;
|
|
440
515
|
/** Redraws a mesh added with `shadows.add(mesh, {static: true})` after its matrix or material changed. */
|
|
441
516
|
invalidateShadow(): void;
|
|
442
517
|
/** Draws the mesh into a cascade of `@margoengine/shadows`; pass the mesh to `shadows.add`. */
|
|
443
518
|
drawShadow(context: RawShadowContext): void;
|
|
519
|
+
/**
|
|
520
|
+
* Draws the mesh into one point, spot, directional or area light map of `@margoengine/clustered/shadows`; pass the
|
|
521
|
+
* mesh to `localShadows.add` (or Clustered's `addShadowCaster`).
|
|
522
|
+
*/
|
|
523
|
+
drawLocalShadow(draw: RawLocalShadowDraw): void;
|
|
444
524
|
/** Releases the GPU buffers and leaves its RawShaders plugin; the mesh cannot be drawn again. */
|
|
445
525
|
dispose(): void;
|
|
446
526
|
[Symbol.dispose]: () => void;
|
|
@@ -480,7 +560,8 @@ export interface RawShadersOptions {
|
|
|
480
560
|
* Engine plugin that draws {@link RawMesh}es in the scene's main colour and depth targets (WebGPU), with the pass's
|
|
481
561
|
* colour format, MSAA sample count and reversed-Z depth; inside a PostStack they land in its scene capture. Opaque
|
|
482
562
|
* meshes draw in one pass, transparent ones (`material.transparent`) in a later pass sorted back to front.
|
|
483
|
-
* `ssao.add(raw)` draws the meshes whose material has `gbufferEntry` into SSAO's G-buffer.
|
|
563
|
+
* `ssao.add(raw)` draws the meshes whose material has `gbufferEntry` into SSAO's G-buffer; `ssr.add(raw)` and
|
|
564
|
+
* `ssgi.add(raw)` draw those whose material has `captureEntry` into SSR's and SSGI's material targets.
|
|
484
565
|
*/
|
|
485
566
|
export declare class RawShaders implements EnginePlugin {
|
|
486
567
|
readonly name: string;
|
|
@@ -503,6 +584,11 @@ export declare class RawShaders implements EnginePlugin {
|
|
|
503
584
|
private shadowEncoder?;
|
|
504
585
|
private shadowPass;
|
|
505
586
|
private readonly shadowWritten;
|
|
587
|
+
/** Camera blocks per `LocalShadows` layer pass, and the encoder each was last written for. */
|
|
588
|
+
private readonly localCameras;
|
|
589
|
+
private readonly localWritten;
|
|
590
|
+
private localEncoder?;
|
|
591
|
+
private readonly localSlots;
|
|
506
592
|
private passes;
|
|
507
593
|
private readonly cameraData;
|
|
508
594
|
private readonly view;
|
|
@@ -510,6 +596,12 @@ export declare class RawShaders implements EnginePlugin {
|
|
|
510
596
|
/** TAA velocity state per TAA view: its camera block, last frame's time and each mesh's last world matrix. */
|
|
511
597
|
private readonly velocityStates;
|
|
512
598
|
private readonly beforeData;
|
|
599
|
+
private capture?;
|
|
600
|
+
/** Camera blocks per capture pass of this frame's encoder, and the encoder they were written for. */
|
|
601
|
+
private readonly captureCameras;
|
|
602
|
+
private captureEncoder?;
|
|
603
|
+
private readonly captureSlots;
|
|
604
|
+
private readonly disposers;
|
|
513
605
|
/** @internal The latest pass token (see `nextPass`). */
|
|
514
606
|
get pass(): number;
|
|
515
607
|
/** @internal The engine whose lighting scene values read. */
|
|
@@ -531,6 +623,13 @@ export declare class RawShaders implements EnginePlugin {
|
|
|
531
623
|
setup(engine: Engine): void;
|
|
532
624
|
registerPasses(graph: FrameGraph): void;
|
|
533
625
|
onDeviceRestored(engine: Engine): void;
|
|
626
|
+
/**
|
|
627
|
+
* Lets a material capture hook (`@margoengine/post` SSR or SSGI: `ssr.add(raw)`) draw the meshes whose material has
|
|
628
|
+
* `captureEntry` with `draw(c, 'capture', ...)`. Returns a remover. Without a hook nothing else changes.
|
|
629
|
+
*/
|
|
630
|
+
setCapture(hook: RawCapture): () => void;
|
|
631
|
+
/** Calls `callback` once when the plugin is disposed (an effect that captures it lets it go); returns a remover. */
|
|
632
|
+
onDispose(callback: () => void): () => void;
|
|
534
633
|
/** Releases every GPU object; meshes stay registered, so the plugin can be attached again. */
|
|
535
634
|
dispose(): void;
|
|
536
635
|
[Symbol.dispose]: () => void;
|
|
@@ -546,15 +645,26 @@ export declare class RawShaders implements EnginePlugin {
|
|
|
546
645
|
nextPass(): number;
|
|
547
646
|
/** @internal Draws `mesh` into one shadow cascade. Shadow passes run before the colour pass, so it uploads for itself. */
|
|
548
647
|
shadow(mesh: RawMesh, { context: c, pass, matrix, cascade }: RawShadowContext): void;
|
|
648
|
+
/** @internal Draws `mesh` into one `LocalShadows` layer, whose depth is reversed. */
|
|
649
|
+
localShadow(mesh: RawMesh, { context: c, pass, matrix, depthCompare }: RawLocalShadowDraw): void;
|
|
650
|
+
private depthCaster;
|
|
549
651
|
/**
|
|
550
652
|
* The `SSAOSource` contract of `@margoengine/post`: meshes whose material has `gbufferEntry` write their own normals and
|
|
551
|
-
* ambient light into SSAO's open G-buffer pass, over the depth the colour pass left.
|
|
653
|
+
* ambient light into SSAO's open G-buffer pass, over the depth the colour pass left. `mode` 'capture' (SSR's and SSGI's
|
|
654
|
+
* `SSRModel` contract): meshes whose material has `captureEntry` draw into the capture hook's pass (`setCapture`).
|
|
552
655
|
*/
|
|
553
|
-
draw(context: PassContext, mode: 'gbuffer' | 'ambient' | 'occlusion', _color: GPUTextureView, _depth: GPUTextureView, _phase?: 'all' | 'opaque' | 'blend', external?: {
|
|
656
|
+
draw(context: PassContext, mode: 'gbuffer' | 'ambient' | 'occlusion' | 'capture', _color: GPUTextureView, _depth: GPUTextureView, _phase?: 'all' | 'opaque' | 'blend', external?: {
|
|
554
657
|
pass: GPURenderPassEncoder;
|
|
555
658
|
view: ArrayLike<number>;
|
|
556
659
|
depthCompare: GPUCompareFunction;
|
|
557
660
|
}): void;
|
|
661
|
+
private drawCapture;
|
|
662
|
+
/**
|
|
663
|
+
* The camera block of one capture pass. A capture may look from elsewhere than the view (LightBounce draws from each
|
|
664
|
+
* light, once per cube face, in one encoder), and the colour pass's block is written once a frame, so each capture
|
|
665
|
+
* pass of an encoder has a block of its own.
|
|
666
|
+
*/
|
|
667
|
+
private captureCamera;
|
|
558
668
|
/**
|
|
559
669
|
* The `TAAVelocityPass` contract of `@margoengine/taa` (`taa.add(raw)`): opaque meshes whose material has
|
|
560
670
|
* `velocityEntry` draw their own motion into TAA's object velocity pass, with last frame's view-projection, world
|
package/dist/raw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as RawMesh, n as RawPicking, r as RawShaderMaterial, i as RawShaders } from "./raw-
|
|
1
|
+
export { t as RawMesh, n as RawPicking, r as RawShaderMaterial, i as RawShaders } from "./raw-0AYej3Ak.js";
|
package/dist/readback.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
|
-
const a=(engine,version="
|
|
4
|
-
import { It as e } from "./node-
|
|
5
|
-
import { c as t, n, t as r } from "./compute-
|
|
3
|
+
const a=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
|
+
import { It as e } from "./node-B6yoIC9V.js";
|
|
5
|
+
import { c as t, n, t as r } from "./compute-CXGG9qvI.js";
|
|
6
6
|
import { MargoError as i } from "@margoengine/math/errors";
|
|
7
7
|
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
8
8
|
//#region src/readback.ts
|
|
@@ -22,7 +22,7 @@ async function c(c, l, u, d, f = {}) {
|
|
|
22
22
|
if (b > v.limits.maxBufferSize) throw RangeError(`computeReadback output of ${b} bytes exceeds the device's ${v.limits.maxBufferSize}; read back a smaller output.`);
|
|
23
23
|
return new Promise((n, r) => {
|
|
24
24
|
let a, o = !1, s = () => {
|
|
25
|
-
p?.removeEventListener("abort", l),
|
|
25
|
+
p?.removeEventListener("abort", l), x(), clearTimeout(S), a?.destroy(), y.program.release(v);
|
|
26
26
|
}, c = (e, t) => {
|
|
27
27
|
if (!o) {
|
|
28
28
|
o = !0;
|
|
@@ -31,14 +31,15 @@ async function c(c, l, u, d, f = {}) {
|
|
|
31
31
|
} catch {}
|
|
32
32
|
t ? n(t) : r(e);
|
|
33
33
|
}
|
|
34
|
-
}, l = () => c(p?.reason ?? new DOMException(`Compute readback "${g}" aborted`, "AbortError")), u = (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
}, l = () => c(p?.reason ?? new DOMException(`Compute readback "${g}" aborted`, "AbortError")), u = () => new i("disposed", `Engine was disposed during compute readback "${g}"; nothing was read back`), f = (e) => c(_?.disposed ? u() : new i("failed", `GPU device was lost (${e.reason}: ${e.message}) during compute readback "${g}"; run it again on a live device`)), h = (e) => {
|
|
35
|
+
if (_?.disposed) return c(u());
|
|
36
|
+
let t = () => c(_?.disposed ? u() : new i("failed", `Compute readback "${g}" failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
37
|
+
(async () => {
|
|
38
|
+
await v.queue.onSubmittedWorkDone(), v.pushErrorScope("validation"), await v.popErrorScope();
|
|
39
|
+
})().then(t, t);
|
|
39
40
|
};
|
|
40
41
|
p?.addEventListener("abort", l, { once: !0 });
|
|
41
|
-
let
|
|
42
|
+
let x = t(v, f), S = m === Infinity ? void 0 : setTimeout(() => c(new i("failed", `Compute readback "${g}" did not finish within ${m} ms; reduce the work or raise the timeout`)), m);
|
|
42
43
|
(async () => {
|
|
43
44
|
v.pushErrorScope("out-of-memory"), v.pushErrorScope("validation");
|
|
44
45
|
let t;
|
|
@@ -76,7 +77,7 @@ async function c(c, l, u, d, f = {}) {
|
|
|
76
77
|
count: d.count
|
|
77
78
|
});
|
|
78
79
|
})().catch((e) => {
|
|
79
|
-
o ||
|
|
80
|
+
o || h(e);
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
83
|
}
|
package/dist/serialization.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { cn as e, d as t, l as n, sn as r } from "./node-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { r as l } from "./raw-
|
|
6
|
-
import { t as u } from "./lighting-
|
|
1
|
+
import { cn as e, d as t, l as n, sn as r } from "./node-B6yoIC9V.js";
|
|
2
|
+
import { n as i } from "./compute-CXGG9qvI.js";
|
|
3
|
+
import { i as a, n as o, r as s } from "./texture-BawKO_h9.js";
|
|
4
|
+
import { t as c } from "./material-CZ8V1FeA.js";
|
|
5
|
+
import { r as l } from "./raw-0AYej3Ak.js";
|
|
6
|
+
import { t as u } from "./lighting-JU9yQPfM.js";
|
|
7
7
|
import { textureArray as d } from "./texture-array.js";
|
|
8
8
|
import { materialParameters as f, restoreMaterialParameters as p } from "@margoengine/materials/serialization";
|
|
9
9
|
//#region src/serialization.ts
|
|
@@ -26,14 +26,14 @@ var m = [
|
|
|
26
26
|
], g = (e, t) => Object.fromEntries(t.map((t) => [t, Reflect.get(e, t)])), _ = [
|
|
27
27
|
{
|
|
28
28
|
type: "shader-node-material",
|
|
29
|
-
test: (e) => e.constructor ===
|
|
29
|
+
test: (e) => e.constructor === c || e.constructor === u,
|
|
30
30
|
capture: (e) => ({
|
|
31
31
|
lighting: e instanceof u,
|
|
32
32
|
parameters: f(e),
|
|
33
33
|
compiled: g(e, [...m, ...e instanceof u ? h : []])
|
|
34
34
|
}),
|
|
35
35
|
restore: (e) => {
|
|
36
|
-
let t = e.lighting ? new u() : new
|
|
36
|
+
let t = e.lighting ? new u() : new c();
|
|
37
37
|
if (!e.compiled || m.some((t) => !Object.hasOwn(e.compiled, t)) || !(e.compiled.program instanceof n)) throw TypeError("Invalid compiled node material; use the matching shader serialization format");
|
|
38
38
|
for (let n of [...m, ...e.lighting ? h : []]) Reflect.set(t, n, e.compiled[n]);
|
|
39
39
|
return p(t, e.parameters), t;
|
|
@@ -51,13 +51,13 @@ var m = [
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
type: "shader-storage",
|
|
54
|
-
test: (e) => e instanceof
|
|
54
|
+
test: (e) => e instanceof i,
|
|
55
55
|
capture: (e) => ({
|
|
56
56
|
data: e.data,
|
|
57
57
|
type: e.type,
|
|
58
58
|
atomic: e.atomic
|
|
59
59
|
}),
|
|
60
|
-
restore: (e) => new
|
|
60
|
+
restore: (e) => new i(e.data, e.type, e.atomic)
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
type: "shader-texture-resource",
|
|
@@ -67,11 +67,11 @@ var m = [
|
|
|
67
67
|
dimension: Reflect.get(e.source, "dimension") ?? "2d"
|
|
68
68
|
}),
|
|
69
69
|
restore: (t) => {
|
|
70
|
-
let
|
|
70
|
+
let i = t.dimension === "cube" ? a(t.source, e(1, 0, 0)) : t.dimension === "3d" ? s(t.source, e(0)) : t.dimension === "2d-array" ? d(t.source, 0, r(0)) : o(t.source, r(0)), c = new n();
|
|
71
71
|
return c.stage({
|
|
72
72
|
kind: "fragment",
|
|
73
73
|
builtins: {}
|
|
74
|
-
}, [
|
|
74
|
+
}, [i]), c.resources[0].resource;
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
{
|
package/dist/shadertoy.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// @margo/core-built
|
|
1
|
+
// @margo/core-built 1.0.0
|
|
2
2
|
import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
|
|
3
3
|
|
|
4
4
|
import { t as e } from "./errors-CsQwshHA.js";
|
|
5
|
-
import { a as t, c as n, l as r, o as i, s as a } from "./raw-
|
|
6
|
-
import { t as o } from "./material-
|
|
5
|
+
import { a as t, c as n, l as r, o as i, s as a } from "./raw-0AYej3Ak.js";
|
|
6
|
+
import { t as o } from "./material-C6bpqlnE.js";
|
|
7
7
|
import { ShaderPass as s } from "./glsl-pass.js";
|
|
8
8
|
import { MargoError as c } from "@margoengine/math/errors";
|
|
9
9
|
//#region ../shared/copy-external.js
|
|
@@ -270,7 +270,7 @@ var F = (e) => `#version 300 es\nin vec3 position;in vec2 uv;out vec2 shadertoyU
|
|
|
270
270
|
format: "rgba32float",
|
|
271
271
|
multisample: { count: 1 },
|
|
272
272
|
hdr: !1
|
|
273
|
-
}), z = class extends s {coreRequirement=__margoCoreRequirement("
|
|
273
|
+
}), z = class extends s {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
274
274
|
constructor(e, t, n, r, i, a, o, s = !1, c) {
|
|
275
275
|
super({
|
|
276
276
|
fragmentShader: t,
|
|
@@ -437,8 +437,8 @@ var F = (e) => `#version 300 es\nin vec3 position;in vec2 uv;out vec2 shadertoyU
|
|
|
437
437
|
dispose() {
|
|
438
438
|
this.blanks.destroy(), super.dispose();
|
|
439
439
|
}
|
|
440
|
-
}, H = 0, U = class t {coreRequirement=__margoCoreRequirement("
|
|
441
|
-
static attach(e, n) {__margoAssertCore(e,__margoCoreRequirement("
|
|
440
|
+
}, H = 0, U = class t {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
441
|
+
static attach(e, n) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
442
442
|
let r = new t(n);
|
|
443
443
|
return e.use(r), r;
|
|
444
444
|
}
|