@aethervtt/shard-render 0.0.1 → 0.1.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/assets.d.ts +3 -0
- package/dist/assets.js +43 -2
- package/dist/atmosphere-nodes.d.ts +9 -0
- package/dist/atmosphere-nodes.js +57 -18
- package/dist/atmosphere-plugin.js +8 -2
- package/dist/baseline/atmosphere.d.ts +16 -0
- package/dist/baseline/atmosphere.js +301 -0
- package/dist/baseline/data-texture.d.ts +36 -0
- package/dist/baseline/data-texture.js +181 -0
- package/dist/baseline/environment.d.ts +14 -0
- package/dist/baseline/environment.js +368 -0
- package/dist/baseline/exposure.d.ts +25 -0
- package/dist/baseline/exposure.js +120 -0
- package/dist/baseline/lights.d.ts +33 -0
- package/dist/baseline/lights.js +133 -0
- package/dist/baseline/textures.d.ts +97 -0
- package/dist/baseline/textures.js +203 -0
- package/dist/camera.d.ts +2 -0
- package/dist/camera.js +4 -0
- package/dist/culling-shaders.js +21 -2
- package/dist/culling.d.ts +11 -2
- package/dist/culling.js +44 -18
- package/dist/cutaway-plugin.d.ts +48 -0
- package/dist/cutaway-plugin.js +364 -0
- package/dist/cutaway.d.ts +27 -0
- package/dist/cutaway.js +49 -0
- package/dist/data-store.d.ts +69 -0
- package/dist/data-store.js +105 -0
- package/dist/debug-shaders.js +17 -3
- package/dist/debug-views.js +4 -2
- package/dist/deferred-shaders.js +2 -0
- package/dist/deferred.js +24 -3
- package/dist/deform.d.ts +5 -4
- package/dist/deform.js +4 -9
- package/dist/describe-plugin.d.ts +4 -2
- package/dist/describe-plugin.js +75 -3
- package/dist/display-nodes.js +15 -4
- package/dist/dynamic-resolution.d.ts +2 -0
- package/dist/dynamic-resolution.js +6 -1
- package/dist/environment-plugin.js +17 -2
- package/dist/environment-state.d.ts +7 -3
- package/dist/environment-state.js +20 -9
- package/dist/environment.js +7 -1
- package/dist/features.d.ts +49 -0
- package/dist/features.js +106 -0
- package/dist/forward.d.ts +38 -2
- package/dist/forward.js +582 -184
- package/dist/fxaa.js +12 -2
- package/dist/gizmos-plugin.js +7 -0
- package/dist/gizmos.d.ts +3 -3
- package/dist/gizmos.js +11 -13
- package/dist/gpu-assets.d.ts +58 -4
- package/dist/gpu-assets.js +191 -8
- package/dist/graph.d.ts +11 -0
- package/dist/graph.js +30 -5
- package/dist/health.d.ts +58 -0
- package/dist/health.js +112 -0
- package/dist/index.d.ts +30 -11
- package/dist/index.js +286 -9
- package/dist/instances.d.ts +119 -8
- package/dist/instances.js +387 -78
- package/dist/interior-plugin.d.ts +121 -0
- package/dist/interior-plugin.js +465 -0
- package/dist/interior.d.ts +24 -0
- package/dist/interior.js +13 -0
- package/dist/layers.d.ts +35 -0
- package/dist/layers.js +49 -0
- package/dist/lens-plugin.d.ts +43 -0
- package/dist/lens-plugin.js +304 -0
- package/dist/lens.d.ts +41 -0
- package/dist/lens.js +99 -0
- package/dist/lights.d.ts +50 -5
- package/dist/lights.js +101 -22
- package/dist/material-pipelines.d.ts +37 -4
- package/dist/material-pipelines.js +102 -5
- package/dist/materials.d.ts +23 -0
- package/dist/materials.js +44 -1
- package/dist/outline-plugin.d.ts +48 -0
- package/dist/outline-plugin.js +529 -0
- package/dist/outline.d.ts +15 -0
- package/dist/outline.js +42 -0
- package/dist/overlays.js +1 -0
- package/dist/picking.d.ts +17 -0
- package/dist/picking.js +40 -11
- package/dist/pixel-perfect-plugin.js +10 -2
- package/dist/plugin.d.ts +58 -6
- package/dist/plugin.js +191 -24
- package/dist/post-common.d.ts +2 -0
- package/dist/post-common.js +3 -0
- package/dist/post-nodes.d.ts +2 -1
- package/dist/post-nodes.js +111 -19
- package/dist/post-plugin.js +5 -3
- package/dist/post-shaders.js +51 -6
- package/dist/projection.d.ts +24 -0
- package/dist/projection.js +87 -0
- package/dist/readback.d.ts +1 -0
- package/dist/readback.js +1 -0
- package/dist/render-scale.js +1 -0
- package/dist/screen-effects.d.ts +97 -0
- package/dist/screen-effects.js +192 -0
- package/dist/shaders.d.ts +13 -0
- package/dist/shaders.js +131 -29
- package/dist/shadow-catcher.d.ts +9 -0
- package/dist/shadow-catcher.js +133 -0
- package/dist/shadows.d.ts +25 -1
- package/dist/shadows.js +97 -19
- package/dist/standard-fields.d.ts +1 -0
- package/dist/standard-fields.js +5 -0
- package/dist/standard.js +12 -0
- package/dist/stats.d.ts +45 -1
- package/dist/stats.js +91 -3
- package/dist/surface-model.d.ts +57 -0
- package/dist/surface-model.js +289 -0
- package/dist/surface-shaders.d.ts +3 -0
- package/dist/surface-shaders.js +160 -0
- package/dist/surface.d.ts +40 -0
- package/dist/surface.js +86 -0
- package/dist/target.d.ts +1 -13
- package/dist/target.js +1 -26
- package/dist/testing.d.ts +10 -0
- package/dist/testing.js +33 -1
- package/dist/tier.d.ts +13 -0
- package/dist/tier.js +14 -0
- package/dist/timer.d.ts +2 -0
- package/dist/timer.js +7 -1
- package/dist/variants.d.ts +37 -0
- package/dist/variants.js +104 -0
- package/dist/view-visibility-plugin.d.ts +61 -0
- package/dist/view-visibility-plugin.js +267 -0
- package/dist/view-visibility.d.ts +28 -0
- package/dist/view-visibility.js +46 -0
- package/dist/view.d.ts +29 -1
- package/dist/view.js +57 -34
- package/package.json +15 -11
package/dist/instances.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { type World } from '@aethervtt/shard-core';
|
|
2
|
-
import { GpuBuffer,
|
|
2
|
+
import type { GpuBuffer, GpuContext } from '@aethervtt/shard-gpu';
|
|
3
3
|
import type { Mesh } from '@aethervtt/shard-mesh';
|
|
4
4
|
import { MaterialAsset } from './assets.js';
|
|
5
|
+
import { DataStore } from './data-store.js';
|
|
5
6
|
import { DeformStore } from './deform.js';
|
|
6
7
|
export declare const InstanceSlot: import("@aethervtt/shard-core").ComponentDef<{
|
|
7
8
|
readonly slot: import("@aethervtt/shard-core").FieldType<number, "u32">;
|
|
8
9
|
}>;
|
|
9
10
|
export declare const NotShadowCaster: import("@aethervtt/shard-core").ComponentDef<{}>;
|
|
11
|
+
/**
|
|
12
|
+
* Tag: while hidden (Visibility), this mesh still casts shadows. A hidden roof keeps its interior
|
|
13
|
+
* dark (0067): camera views skip it, shadow views draw it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ShadowWhenHidden: import("@aethervtt/shard-core").ComponentDef<{}>;
|
|
10
16
|
export declare const NotShadowReceiver: import("@aethervtt/shard-core").ComponentDef<{}>;
|
|
11
17
|
export declare const Mesh3d: import("@aethervtt/shard-core").ComponentDef<{
|
|
12
18
|
readonly mesh: import("@aethervtt/shard-core").FieldType<import("@aethervtt/shard-core").AssetRef<"Mesh"> | null, "object">;
|
|
@@ -51,8 +57,22 @@ export declare const InstanceFlags: {
|
|
|
51
57
|
readonly Skinned: 32;
|
|
52
58
|
/** Morphed: the vertex stage adds morph target deltas. */
|
|
53
59
|
readonly Morph: 64;
|
|
60
|
+
/** Hidden, but drawn in shadow views (ShadowWhenHidden); Visible is off. */
|
|
61
|
+
readonly ShadowOnly: 128;
|
|
62
|
+
/**
|
|
63
|
+
* May be cut away around a camera's reveal points (Cutaway, 0070). In the record's flags word
|
|
64
|
+
* it rides in bit 28 (`CUTAWAY_BIT`), above the layers and the LOD.
|
|
65
|
+
*/
|
|
66
|
+
readonly Cutaway: 256;
|
|
54
67
|
};
|
|
68
|
+
/** Where `InstanceFlags.Cutaway` sits in the record's flags word (0070). */
|
|
69
|
+
export declare const CUTAWAY_BIT: number;
|
|
70
|
+
/** A slot's flags word: its flags (bits 0–7, Cutaway in 28) and render layers (8–23). */
|
|
71
|
+
export declare function recordFlags(flags: number, layers: number): number;
|
|
55
72
|
/** Record value for "no batch". LOD slots store `LOD_BIT | lodSet`. */
|
|
73
|
+
/** The render layer mask's place in the flags word (bits 8–23; LOD rides in 24–27 when read). */
|
|
74
|
+
export declare const LAYER_SHIFT = 8;
|
|
75
|
+
export declare const LAYER_BITS: number;
|
|
56
76
|
export declare const NO_BATCH = 4294967295;
|
|
57
77
|
export declare const LOD_BIT = 2147483648;
|
|
58
78
|
/** Visible-list entries: slot in the low 28 bits, LOD level in the top 4. */
|
|
@@ -85,6 +105,19 @@ export interface Batch {
|
|
|
85
105
|
/** Per-cull scratch for forward-only slots in deferred views. */
|
|
86
106
|
forwardScratch: Uint32Array;
|
|
87
107
|
forwardCount: number;
|
|
108
|
+
/** The mesh version shadows last saw (cached shadows redraw when it changes, 0055). */
|
|
109
|
+
meshVersion: number;
|
|
110
|
+
/**
|
|
111
|
+
* Instances that can land in this batch and are Cutaway (0070). While any are, a view whose
|
|
112
|
+
* reveal points can cut one this frame draws it with the cutaway variant of its pipeline.
|
|
113
|
+
*/
|
|
114
|
+
cutaway: number;
|
|
115
|
+
/**
|
|
116
|
+
* Drawn in the ground phase (0057): its slots have a GroundLayer, draw in (band, order) order
|
|
117
|
+
* after opaque geometry, and cast no shadows. Kept apart from the same mesh and material off
|
|
118
|
+
* the ground.
|
|
119
|
+
*/
|
|
120
|
+
ground: boolean;
|
|
88
121
|
}
|
|
89
122
|
/** A Lod component's levels resolved to batches, shared by every entity with the same values. */
|
|
90
123
|
export interface LodSet {
|
|
@@ -128,6 +161,12 @@ export interface CullParams {
|
|
|
128
161
|
/** LOD state per slot for this view's camera; updated when `updateLod`. */
|
|
129
162
|
lodState: Uint8Array | undefined;
|
|
130
163
|
updateLod: boolean;
|
|
164
|
+
/** Render layers the view draws (0057): slots sharing no bit are culled first. Default: all. */
|
|
165
|
+
layers?: number;
|
|
166
|
+
/** Slots this view doesn't draw (ViewVisibility, 0070): a bit per slot. */
|
|
167
|
+
hidden?: Uint32Array | undefined;
|
|
168
|
+
/** Where those bits start in the GPU's hidden-set buffer, or NO_HIDDEN. */
|
|
169
|
+
hiddenBase?: number;
|
|
131
170
|
}
|
|
132
171
|
/**
|
|
133
172
|
* World bounding sphere of a slot: the mesh's local sphere (from its bounds) through the slot's
|
|
@@ -167,7 +206,7 @@ export declare class InstanceStore {
|
|
|
167
206
|
* Each slot's InstanceFlags, mirrored from its record: prepare compares against these every
|
|
168
207
|
* frame, and reading them from the 64-byte records would touch a cache line per instance.
|
|
169
208
|
*/
|
|
170
|
-
flags:
|
|
209
|
+
flags: Uint16Array<ArrayBuffer>;
|
|
171
210
|
/** Hidden instances per ECS table id, from the last time prepare visited the table. */
|
|
172
211
|
readonly tableHidden: number[];
|
|
173
212
|
/** Batch index (>= 0), LOD set (-2 - index), or -1 (none), per slot. */
|
|
@@ -201,7 +240,7 @@ export declare class InstanceStore {
|
|
|
201
240
|
private lastMoved;
|
|
202
241
|
private lastMovedCount;
|
|
203
242
|
private frame;
|
|
204
|
-
readonly prevBuffer:
|
|
243
|
+
readonly prevBuffer: DataStore;
|
|
205
244
|
private readonly free;
|
|
206
245
|
/** Slots waiting for their mesh or material to load. */
|
|
207
246
|
readonly pending: Set<number>;
|
|
@@ -209,9 +248,24 @@ export declare class InstanceStore {
|
|
|
209
248
|
/** Batches in draw order (sorted by pipeline, then material, then mesh). */
|
|
210
249
|
readonly sorted: Batch[];
|
|
211
250
|
private readonly byMesh;
|
|
251
|
+
private readonly byMeshGround;
|
|
252
|
+
/**
|
|
253
|
+
* Render layer mask per slot (0057); 1 for slots without RenderLayers. It also rides in bits
|
|
254
|
+
* 8–23 of the record's flags word, where the GPU culler reads it.
|
|
255
|
+
*/
|
|
256
|
+
layers: Uint16Array<ArrayBuffer>;
|
|
257
|
+
/** Ground key per slot, (level, band, order) packed; NaN off the ground (0057, 0067). */
|
|
258
|
+
groundKeys: Float64Array<ArrayBuffer>;
|
|
212
259
|
readonly lodSets: LodSet[];
|
|
213
260
|
private readonly lodByKey;
|
|
214
261
|
readonly defaultMaterial: MaterialAsset;
|
|
262
|
+
/**
|
|
263
|
+
* What stand-ins for failed meshes are drawn with (0061): matte gray, or magenta in a dev build
|
|
264
|
+
* (`DevMode`, read by prepareInstances).
|
|
265
|
+
*/
|
|
266
|
+
readonly missingMaterial: MaterialAsset;
|
|
267
|
+
/** A development build: the missing material turns magenta. */
|
|
268
|
+
dev: boolean;
|
|
215
269
|
/** Bytes of instance data uploaded this frame. */
|
|
216
270
|
uploadedBytes: number;
|
|
217
271
|
/** Slots with a batch and not hidden, and hidden ones: stats for GPU-culled views. */
|
|
@@ -219,11 +273,18 @@ export declare class InstanceStore {
|
|
|
219
273
|
hiddenCount: number;
|
|
220
274
|
/** Bumps when batches or LOD sets change shape (the GPU tables re-upload). */
|
|
221
275
|
structureVersion: number;
|
|
276
|
+
/** Bumps when a slot is allocated or freed (hidden sets resolve again, 0070). */
|
|
277
|
+
slotEpoch: number;
|
|
278
|
+
/**
|
|
279
|
+
* Bumps when what casts shadows changes other than by moving: a slot's batch, its caster or
|
|
280
|
+
* visible flag, or a batch's mesh data. Cached shadow maps (0055) redraw when it moves.
|
|
281
|
+
*/
|
|
282
|
+
shadowEpoch: number;
|
|
222
283
|
/** Visible slot lists of every CPU-culled view this frame, concatenated. */
|
|
223
284
|
visible: Uint32Array<ArrayBuffer>;
|
|
224
285
|
visibleCount: number;
|
|
225
|
-
readonly instanceBuffer:
|
|
226
|
-
readonly visibleBuffer:
|
|
286
|
+
readonly instanceBuffer: DataStore;
|
|
287
|
+
readonly visibleBuffer: DataStore;
|
|
227
288
|
private generation;
|
|
228
289
|
private readonly gpu;
|
|
229
290
|
bindGroup: GPUBindGroup | undefined;
|
|
@@ -240,6 +301,13 @@ export declare class InstanceStore {
|
|
|
240
301
|
get live(): number;
|
|
241
302
|
private grow;
|
|
242
303
|
alloc(entity: number): number;
|
|
304
|
+
/** A slot's render layer mask (0057). What casts shadows in a view may change: cached maps redraw. */
|
|
305
|
+
setLayers(slot: number, mask: number): void;
|
|
306
|
+
/**
|
|
307
|
+
* A slot's ground key (0057): `groundKey(band, order, level)`, or NaN off the ground. Returns whether
|
|
308
|
+
* it moved on or off the ground (its batch must be resolved again).
|
|
309
|
+
*/
|
|
310
|
+
setGround(slot: number, key: number): boolean;
|
|
243
311
|
release(slot: number): void;
|
|
244
312
|
private boundsDirty;
|
|
245
313
|
private readonly cachedBounds;
|
|
@@ -265,11 +333,26 @@ export declare class InstanceStore {
|
|
|
265
333
|
settleMoved(): void;
|
|
266
334
|
/** Assigns a slot to a batch (>= 0), a LOD set (-2 - index), or nothing (-1). */
|
|
267
335
|
assign(slot: number, assignment: number): void;
|
|
336
|
+
/** Adds `delta` to the cutaway count of every batch the slot can land in (0070). */
|
|
337
|
+
countCutaway(slot: number, delta: number): void;
|
|
338
|
+
/**
|
|
339
|
+
* Bumps `shadowEpoch` if any batch's mesh data changed since the last call (a structure chunk
|
|
340
|
+
* rebuilt in place). One compare per batch.
|
|
341
|
+
*/
|
|
342
|
+
checkMeshVersions(): void;
|
|
343
|
+
/**
|
|
344
|
+
* Whether a visible caster that moved this frame touches the half-spaces `planes`, where it
|
|
345
|
+
* was or where it is now. Call after prepare. Skinned and morphed poses aren't moves; see
|
|
346
|
+
* `deforming`.
|
|
347
|
+
*/
|
|
348
|
+
movedCasterIn(planes: Float32Array): boolean;
|
|
349
|
+
/** Whether skinned or morphed poses are being written this frame (their shadows move). */
|
|
350
|
+
get deforming(): boolean;
|
|
268
351
|
/** A plain batch assignment. */
|
|
269
352
|
setBatch(slot: number, index: number): void;
|
|
270
353
|
private addMember;
|
|
271
354
|
private removeMember;
|
|
272
|
-
batchFor(mesh: Mesh, material: MaterialAsset, meshGuid: string | undefined, materialGuid: string | undefined): Batch;
|
|
355
|
+
batchFor(mesh: Mesh, material: MaterialAsset, meshGuid: string | undefined, materialGuid: string | undefined, ground?: boolean): Batch;
|
|
273
356
|
/** The LOD set for a Lod value and material (created on first use). Undefined if a mesh is missing. */
|
|
274
357
|
lodSetFor(lod: LodValue, material: MaterialAsset, materialGuid: string | undefined, meshes: import('@aethervtt/shard-assets').AssetStore<Mesh, 'Mesh'>): LodSet | undefined;
|
|
275
358
|
/** Orders batches by pipeline (set by the renderer: material type and variant). */
|
|
@@ -291,15 +374,37 @@ export declare class InstanceStore {
|
|
|
291
374
|
private tBatches;
|
|
292
375
|
private tDepths;
|
|
293
376
|
private readonly tOrder;
|
|
377
|
+
private groundCount;
|
|
378
|
+
private gSlots;
|
|
379
|
+
private gBatches;
|
|
380
|
+
private gKeys;
|
|
381
|
+
private readonly gOrder;
|
|
294
382
|
/**
|
|
295
383
|
* CPU culling of every slot into `list` (and, for camera views, `transparent` back to front and
|
|
296
384
|
* deferred `forwardOnly`). Same tests as the GPU culler: bounding sphere against the frustum,
|
|
297
385
|
* visibility range, LOD level. `bounds` gets the union of what passed (cascade fitting). With
|
|
298
386
|
* `transparentOnly`, only blended batches are culled (the GPU culls the rest).
|
|
299
387
|
*/
|
|
300
|
-
cullCpu(list: DrawList, params: CullParams, bounds?: Float32Array, transparent?: DrawList, forward?: Float32Array, forwardOnly?: DrawList, transparentOnly?: boolean): void;
|
|
388
|
+
cullCpu(list: DrawList, params: CullParams, bounds?: Float32Array, transparent?: DrawList, forward?: Float32Array, forwardOnly?: DrawList, transparentOnly?: boolean, ground?: DrawList, overlay?: DrawList): void;
|
|
301
389
|
/** Transparent-only CPU cull over blended batches' members (LOD slots aren't members). */
|
|
302
390
|
cullTransparentMembers(list: DrawList, params: CullParams, forward: Float32Array): void;
|
|
391
|
+
/**
|
|
392
|
+
* Ground-only CPU cull over ground batches' members (0057), for views the GPU culls: the ground
|
|
393
|
+
* list is always built on the CPU, in (band, order) order.
|
|
394
|
+
*/
|
|
395
|
+
cullGroundMembers(list: DrawList, params: CullParams, overlay?: DrawList): void;
|
|
396
|
+
private pushGround;
|
|
397
|
+
/**
|
|
398
|
+
* Packs visible-list entries (a slot in the low 28 bits, 4 spare bits a pass may use, like an
|
|
399
|
+
* outline style) into `list`, one draw per batch: for passes that draw chosen slots (0057's
|
|
400
|
+
* outline mask). `batches` holds each entry's batch index. Skips entries whose batch isn't ready.
|
|
401
|
+
*/
|
|
402
|
+
packEntries(list: DrawList, entries: Uint32Array, batches: Int32Array, count: number): void;
|
|
403
|
+
/**
|
|
404
|
+
* Sorts this cull's ground instances by (level, band, order), then batch; runs of a batch share a
|
|
405
|
+
* draw. With `overlay`, bands from OVERLAY_BAND up go there instead (0058).
|
|
406
|
+
*/
|
|
407
|
+
private packGround;
|
|
303
408
|
/**
|
|
304
409
|
* CPU culling with positional arguments: planes, flag mask, bounds, transparent list, eye, view
|
|
305
410
|
* direction, and the deferred forward-only list. LOD selects fresh (no hysteresis state).
|
|
@@ -335,8 +440,14 @@ export declare class InstanceStore {
|
|
|
335
440
|
}
|
|
336
441
|
/** Projected diameter of a sphere as a fraction of viewport height. Mirrors the cull shader. */
|
|
337
442
|
export declare function lodSize(radius: number, distance: number, params: CullParams): number;
|
|
338
|
-
|
|
443
|
+
/** The instances bind group's layout: storage on the full tier, data textures on baseline. */
|
|
444
|
+
export declare function createInstanceLayout(gpu: GpuContext, store: InstanceStore): GPUBindGroupLayout;
|
|
339
445
|
export declare const Instances: import("@aethervtt/shard-core").ResourceDef<InstanceStore>;
|
|
446
|
+
/**
|
|
447
|
+
* Ground draw order: level (−16..15, 0067), then band, then order. Exact in a double: 5 + 16 + 32
|
|
448
|
+
* bits.
|
|
449
|
+
*/
|
|
450
|
+
export declare function groundKey(band: number, order: number, level?: number): number;
|
|
340
451
|
/** Present when skinningPlugin is installed: SkinnedMesh and MorphWeights deform what they draw. */
|
|
341
452
|
export declare const DeformPath: import("@aethervtt/shard-core").ResourceDef<{
|
|
342
453
|
installed: true;
|