@aethervtt/shard-render 0.1.0 → 0.2.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/ablation.d.ts +74 -0
- package/dist/ablation.js +117 -0
- package/dist/atmosphere-nodes.js +100 -12
- package/dist/atmosphere-shaders.js +17 -5
- package/dist/baseline/exposure.d.ts +1 -1
- package/dist/baseline/exposure.js +18 -5
- package/dist/crowd.d.ts +21 -0
- package/dist/crowd.js +121 -0
- package/dist/decals-plugin.d.ts +5 -0
- package/dist/decals-plugin.js +54 -0
- package/dist/decals.d.ts +69 -0
- package/dist/decals.js +326 -0
- package/dist/deferred.js +4 -1
- package/dist/display-nodes.js +24 -11
- package/dist/foliage-budget.d.ts +64 -0
- package/dist/foliage-budget.js +108 -0
- package/dist/foliage-path.d.ts +19 -0
- package/dist/foliage-path.js +7 -0
- package/dist/foliage-shaders.d.ts +11 -0
- package/dist/foliage-shaders.js +504 -0
- package/dist/foliage.d.ts +194 -0
- package/dist/foliage.js +1027 -0
- package/dist/forward.js +26 -2
- package/dist/graph.d.ts +34 -0
- package/dist/graph.js +139 -14
- package/dist/index.d.ts +11 -1
- package/dist/index.js +57 -0
- package/dist/overlay-registry.d.ts +3 -1
- package/dist/overlay-registry.js +3 -1
- package/dist/overlays.js +5 -2
- package/dist/perf-overlay.d.ts +9 -0
- package/dist/perf-overlay.js +125 -0
- package/dist/plugin.d.ts +11 -1
- package/dist/plugin.js +33 -2
- package/dist/post-common.d.ts +20 -2
- package/dist/post-common.js +79 -2
- package/dist/post-nodes.d.ts +5 -0
- package/dist/post-nodes.js +136 -104
- package/dist/post-scene.d.ts +130 -0
- package/dist/post-scene.js +164 -0
- package/dist/post-shaders.js +41 -63
- package/dist/post.js +11 -1
- package/dist/ribbons-plugin.d.ts +5 -0
- package/dist/ribbons-plugin.js +59 -0
- package/dist/ribbons.d.ts +44 -0
- package/dist/ribbons.js +288 -0
- package/dist/scenario.d.ts +70 -0
- package/dist/scenario.js +125 -0
- package/dist/shaders.js +58 -5
- package/dist/shadows.d.ts +2 -1
- package/dist/shadows.js +3 -1
- package/dist/standard.js +6 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.js +6 -0
- package/dist/timer.d.ts +16 -1
- package/dist/timer.js +66 -19
- package/dist/vfx-draw.d.ts +37 -0
- package/dist/vfx-draw.js +291 -0
- package/dist/vfx-state.d.ts +42 -0
- package/dist/vfx-state.js +81 -0
- package/dist/vfx.d.ts +69 -0
- package/dist/vfx.js +103 -0
- package/package.json +19 -11
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { type AssetRef } from '@aethervtt/shard-core';
|
|
2
|
+
import { type PerfBudgetsData } from '@aethervtt/shard-runtime';
|
|
3
|
+
import { CoveredGpuTime, FoliageController } from './foliage-budget.js';
|
|
4
|
+
/** A chunk of foliage to place: its ground (a patch grid) and its lattice. */
|
|
5
|
+
export interface FoliageChunk {
|
|
6
|
+
/** Patch vertices per side (the ground's grid, e.g. a terrain chunk's 33). */
|
|
7
|
+
grid: number;
|
|
8
|
+
/** grid² positions (xyz), in the chunk's frame (see `FoliageLayer.setTransform`). */
|
|
9
|
+
positions: Float32Array;
|
|
10
|
+
/** grid² unit normals (xyz). */
|
|
11
|
+
normals: Float32Array;
|
|
12
|
+
/** grid² density factors in [0, 1]: masks and biomes, interpolated between vertices. */
|
|
13
|
+
density: Float32Array;
|
|
14
|
+
/** Global lattice coordinates of the chunk's first cell, and its lattice domain (a cube face). */
|
|
15
|
+
cell0: readonly [number, number];
|
|
16
|
+
domain: number;
|
|
17
|
+
/** Chance a cell holds an item (density × cell area, ≤ 1) and jitter as a fraction of a cell. */
|
|
18
|
+
accept: number;
|
|
19
|
+
jitter: number;
|
|
20
|
+
/**
|
|
21
|
+
* The chunk's origin in its surface's frame: up is radial from the surface's center (a planet).
|
|
22
|
+
* Undefined: up is the chunk frame's +Y (a mesh).
|
|
23
|
+
*/
|
|
24
|
+
radial?: readonly [number, number, number];
|
|
25
|
+
/** Footprints kept clear (x, y, z, radius), in the chunk's frame: props' bounds. */
|
|
26
|
+
avoid?: Float32Array;
|
|
27
|
+
}
|
|
28
|
+
export interface FoliageLayerOptions {
|
|
29
|
+
label: string;
|
|
30
|
+
/** The meshes it draws (a rule's variants), all with `material`. */
|
|
31
|
+
meshes: AssetRef<'Mesh'>[];
|
|
32
|
+
/** Cumulative chance of each mesh, ending at 1. */
|
|
33
|
+
weights: ArrayLike<number>;
|
|
34
|
+
material: AssetRef<'Material'>;
|
|
35
|
+
/** The rule's seed: placement hashes it with each cell. */
|
|
36
|
+
seed: number;
|
|
37
|
+
/** Lattice cells per chunk side (instances a chunk holds: cells²). */
|
|
38
|
+
cells: number;
|
|
39
|
+
/** Distance from the camera at which it exists (m). */
|
|
40
|
+
range: number;
|
|
41
|
+
/** Casts shadows within this distance of the camera (0: never). */
|
|
42
|
+
shadowRange: number;
|
|
43
|
+
/** Scale range [min, max]. */
|
|
44
|
+
scale: readonly [number, number];
|
|
45
|
+
/** Up from radial (0) to the ground's normal (1). */
|
|
46
|
+
align: number;
|
|
47
|
+
/** Where thinning starts, as a fraction of `range` (default 0.5). */
|
|
48
|
+
thinFrom?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Each mesh's lower levels of detail (fewer triangles), drawn farther out: `lods[m]` for
|
|
51
|
+
* `meshes[m]`. Grass clumps come with blades of 2 and 1 segments.
|
|
52
|
+
*/
|
|
53
|
+
lods?: readonly (readonly AssetRef<'Mesh'>[])[];
|
|
54
|
+
/** Where each lower level begins, as fractions of `range` (default 0.3, 0.6). */
|
|
55
|
+
lodDistances?: readonly number[];
|
|
56
|
+
}
|
|
57
|
+
/** A placement waiting for this frame's dispatch. */
|
|
58
|
+
interface Pending {
|
|
59
|
+
slot: number;
|
|
60
|
+
chunk: FoliageChunk;
|
|
61
|
+
}
|
|
62
|
+
interface ViewBuffers {
|
|
63
|
+
visible: GPUBuffer;
|
|
64
|
+
args: GPUBuffer;
|
|
65
|
+
classes: GPUBuffer;
|
|
66
|
+
counts: GPUBuffer;
|
|
67
|
+
params: GPUBuffer;
|
|
68
|
+
draw: GPUBuffer;
|
|
69
|
+
cullGroup: GPUBindGroup | undefined;
|
|
70
|
+
drawGroup: GPUBindGroup | undefined;
|
|
71
|
+
/** Capacity, drawable count and buffers' generation it was made for. */
|
|
72
|
+
capacity: number;
|
|
73
|
+
drawables: number;
|
|
74
|
+
generation: number;
|
|
75
|
+
/** Frame it was last culled, so draws skip views that weren't. */
|
|
76
|
+
culled: number;
|
|
77
|
+
/** Instance counts read back per (list, drawable), and whether a read is in flight. */
|
|
78
|
+
read_: Uint32Array;
|
|
79
|
+
reading: boolean;
|
|
80
|
+
readback: GPUBuffer | undefined;
|
|
81
|
+
/** Frame of the last read-back. */
|
|
82
|
+
read: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* GPU-only instances of a rule's meshes (spec 0045): one storage buffer of 16-byte instances,
|
|
86
|
+
* `cells²` per chunk slot, placed by compute from each chunk's ground patch, culled per camera
|
|
87
|
+
* (frustum, distance, thinning) into indirect draws, drawn with the material's own hooks. No
|
|
88
|
+
* entities, and no per-instance CPU work.
|
|
89
|
+
*/
|
|
90
|
+
export declare class FoliageLayer {
|
|
91
|
+
readonly options: FoliageLayerOptions;
|
|
92
|
+
readonly perChunk: number;
|
|
93
|
+
/** What draws: each mesh's levels in order (`meshes[m]` then `lods[m]`), and where each mesh's start. */
|
|
94
|
+
readonly drawables: AssetRef<'Mesh'>[];
|
|
95
|
+
readonly levels: Uint32Array;
|
|
96
|
+
/** Chunks in the layer: their inputs (kept to place again after growth or device loss). */
|
|
97
|
+
readonly chunks: Map<number, FoliageChunk>;
|
|
98
|
+
/** Per slot: chunk → origin-relative world rows (12), bounds (min xyz, size xyz), active. */
|
|
99
|
+
private records;
|
|
100
|
+
private slots;
|
|
101
|
+
private readonly free;
|
|
102
|
+
readonly pending: Pending[];
|
|
103
|
+
/** Buffers, made in the place node. */
|
|
104
|
+
instances: GPUBuffer | undefined;
|
|
105
|
+
chunkBuffer: GPUBuffer | undefined;
|
|
106
|
+
meshInfo: GPUBuffer | undefined;
|
|
107
|
+
levelBuffer: GPUBuffer | undefined;
|
|
108
|
+
/** Slots the instance buffer holds, and its device generation. */
|
|
109
|
+
capacitySlots: number;
|
|
110
|
+
generation: number;
|
|
111
|
+
readonly views: Map<string, ViewBuffers>;
|
|
112
|
+
/** Largest mesh bounding radius (m, unscaled): culling's sphere. */
|
|
113
|
+
meshRadius: number;
|
|
114
|
+
disposed: boolean;
|
|
115
|
+
constructor(options: FoliageLayerOptions);
|
|
116
|
+
/** A free chunk slot. */
|
|
117
|
+
allocate(): number;
|
|
118
|
+
/** Places a chunk in a slot (on the GPU, in the next frame's place pass). */
|
|
119
|
+
setChunk(slot: number, chunk: FoliageChunk): void;
|
|
120
|
+
private queue;
|
|
121
|
+
/** Frees a slot: its instances stop drawing at once. */
|
|
122
|
+
removeChunk(slot: number): void;
|
|
123
|
+
/**
|
|
124
|
+
* The chunk's frame in the world, origin-relative, as an affine's three rows (12 floats,
|
|
125
|
+
* row-major: rotation and translation). Set it every frame the frame moves (an origin shift).
|
|
126
|
+
*/
|
|
127
|
+
setTransform(slot: number, rows: ArrayLike<number>): void;
|
|
128
|
+
/** Chunk slots in use. */
|
|
129
|
+
get chunkCount(): number;
|
|
130
|
+
/** Instances this layer can hold. */
|
|
131
|
+
get capacity(): number;
|
|
132
|
+
/** The last read-back instance counts for a camera: in view, and casting shadows. */
|
|
133
|
+
visible(view: string): {
|
|
134
|
+
drawn: number;
|
|
135
|
+
shadows: number;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* The last read-back counts per drawable for a camera (`drawables[d]`: a mesh or one of its
|
|
139
|
+
* LODs), in view and casting shadows.
|
|
140
|
+
*/
|
|
141
|
+
visibleByDrawable(view: string): {
|
|
142
|
+
drawn: number[];
|
|
143
|
+
shadows: number[];
|
|
144
|
+
};
|
|
145
|
+
/** Slot records for the GPU this frame. */
|
|
146
|
+
get chunkRecords(): Float32Array;
|
|
147
|
+
get slotCount(): number;
|
|
148
|
+
/** Releases its GPU buffers (the layer stops drawing). */
|
|
149
|
+
dispose(): void;
|
|
150
|
+
}
|
|
151
|
+
/** Every foliage layer, drawn by `foliagePlugin`. */
|
|
152
|
+
export declare class FoliageLayerSet {
|
|
153
|
+
readonly layers: Set<FoliageLayer>;
|
|
154
|
+
/** Density and range under the budget (0075, `FoliageBudget`): full detail without a target. */
|
|
155
|
+
readonly steer: FoliageController;
|
|
156
|
+
/** Foliage's GPU time a frame: every `gpu:foliage/*` pass (0074's covers rule). */
|
|
157
|
+
readonly gpuTime: CoveredGpuTime;
|
|
158
|
+
/** The scenario slice the target came from, kept until the scenario or budgets change. */
|
|
159
|
+
sliceFor: string | null;
|
|
160
|
+
sliceData: PerfBudgetsData | undefined;
|
|
161
|
+
sliceMs: number;
|
|
162
|
+
/** The shared GPU objects (pipelines, staging buffers), made on first use. */
|
|
163
|
+
gpu: FoliageGpu | undefined;
|
|
164
|
+
add(layer: FoliageLayer): FoliageLayer;
|
|
165
|
+
remove(layer: FoliageLayer): void;
|
|
166
|
+
/** Releases every layer and the shared buffers (the app is going away). */
|
|
167
|
+
dispose(): void;
|
|
168
|
+
}
|
|
169
|
+
export declare const FoliageLayers: import("@aethervtt/shard-core").ResourceDef<FoliageLayerSet>;
|
|
170
|
+
interface FoliageGpu {
|
|
171
|
+
generation: number;
|
|
172
|
+
placeLayout: GPUBindGroupLayout;
|
|
173
|
+
cullLayout: GPUBindGroupLayout;
|
|
174
|
+
drawLayout: GPUBindGroupLayout;
|
|
175
|
+
place: GPUComputePipeline | undefined;
|
|
176
|
+
reset: GPUComputePipeline | undefined;
|
|
177
|
+
cull: GPUComputePipeline | undefined;
|
|
178
|
+
scan: GPUComputePipeline | undefined;
|
|
179
|
+
scatter: GPUComputePipeline | undefined;
|
|
180
|
+
params: GPUBuffer;
|
|
181
|
+
paramsSize: number;
|
|
182
|
+
patch: GPUBuffer;
|
|
183
|
+
patchSize: number;
|
|
184
|
+
avoid: GPUBuffer;
|
|
185
|
+
avoidSize: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* GPU foliage (0045): layers of instances placed by compute from ground patches, culled per camera,
|
|
189
|
+
* drawn indirectly with their material's hooks in its own forward pass (`foliage/draw`, so its GPU
|
|
190
|
+
* time is its own: 0075), the G-buffer and the shadow passes. The scatter package feeds it; no
|
|
191
|
+
* entities are involved. `FoliageBudget` keeps its GPU time inside a target.
|
|
192
|
+
*/
|
|
193
|
+
export declare const foliagePlugin: import("@aethervtt/shard-runtime").Plugin;
|
|
194
|
+
export {};
|