@hology/webgpu-renderer 0.1.19 → 0.1.21
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/README.md +49 -0
- package/dist/index.d.ts +208 -122
- package/dist/index.js +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -426,3 +426,52 @@ Natural follow-ups from here:
|
|
|
426
426
|
- add cascaded directional shadows, light arrays, and shadow atlases
|
|
427
427
|
- add material templates and pipeline caches for larger shader families
|
|
428
428
|
- separate extraction, render graph nodes, and resource registries into dedicated modules
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
### Automatic detail rejection
|
|
432
|
+
|
|
433
|
+
WebGPU objects default to a conservative minimum bounding-sphere diameter of 2 render pixels, with a separate 2-shadow-texel threshold for directional casters. This rejects detail before vertex processing; it does not generate mesh LODs or change geometry. Long thin objects use their longest extent through the enclosing sphere, and camera/near-plane intersections are retained.
|
|
434
|
+
|
|
435
|
+
```ts
|
|
436
|
+
import { setObjectDetailCulling } from '@hology/webgpu-renderer';
|
|
437
|
+
|
|
438
|
+
// Defaults for an entire scene / actor hierarchy; descendants can override fields.
|
|
439
|
+
setObjectDetailCulling(scene, { minScreenSize: 2, shadow: { minScreenSize: 2 } });
|
|
440
|
+
setObjectDetailCulling(importantActor, { enabled: false, shadow: { enabled: false } });
|
|
441
|
+
setObjectDetailCulling(smallProp, { maxDistance: 100, shadow: { minScreenSize: 4, maxDistance: 200 } });
|
|
442
|
+
renderer.createStaticDrawSet(root, { detailCulling: { minScreenSize: 3 } });
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Settings are stored in `Object3D.userData.detailCulling` and inherited from parents, field by field. `enabled: false` disables automatic rejection in that domain; an explicit distance still applies. Zero distance disables distance rejection. Distances are measured from the viewer to the sphere surface. Camera and shadow settings are independent. Hology's `RenderingView.setObjectDetailCulling` exposes the same runtime object policy, and `SceneObject.detailCulling` carries it through materialization. Objects with different policies remain separate in materialization and renderer batching.
|
|
446
|
+
|
|
447
|
+
Static registration freezes settings and bounds. Change policies before registration, or dispose and re-register a static set after changing them. The existing 32-byte GPU instance metadata stores camera threshold and distance in its formerly reserved words. Camera rejection runs in the existing visibility compute kernel, before frustum/Hi-Z work, with no additional compute dispatch or visibility readback. A persistent bit in the visibility mask provides 115% entry / 85% exit hysteresis. Ordinary meshes receive CPU detail decisions before batching, with object history; already-instanced dynamic/resident batches conservatively use their aggregate bounds. Per-instance dynamic/resident compaction is not added here.
|
|
448
|
+
|
|
449
|
+
Directional shadows use independent light-space sphere tests over the complete cascade camera volume, including off-camera casters. Spatial chunks remain a broad phase. A CPU mirror of the immutable sphere metadata selects contiguous source-instance runs from the resident buffer; pooled draw descriptors avoid per-frame descriptor allocation. Cascade histories use the same hysteresis band. This path adds CPU selection/encoding work in exchange for fewer shadow vertices; it does not reuse the camera's compacted instance list. Point and spot shadow detail policies are not changed.
|
|
450
|
+
|
|
451
|
+
Profiling now includes per-pass `triangleCount` and `drawCallCount`. Indirect submission counters remain **upper bounds**, since the CPU records registered draw capacity; they include repeated depth/color/shadow submissions. `visibility.visibleTriangles` reads actual index/instance counts from the camera's indirect arguments and represents one GPU-culled camera submission, excluding direct and transparent draws. Directional shadow run counts are exact. GPU profiling readback is diagnostic only, never needed for culling.
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
### Cached directional shadow updates
|
|
455
|
+
|
|
456
|
+
Temporal shadow scheduling is opt-in. Configure the renderer with `directionalShadowUpdates`, or call `setDirectionalShadowUpdateOptions`. Hology exposes the same method on `RenderingView`.
|
|
457
|
+
|
|
458
|
+
```ts
|
|
459
|
+
renderingView.setDirectionalShadowUpdateOptions({
|
|
460
|
+
enabled: true,
|
|
461
|
+
maxUpdateHz: 60,
|
|
462
|
+
cascadeUpdateHz: [60, 30, 15, 7.5],
|
|
463
|
+
maxUpdatesPerFrame: 2,
|
|
464
|
+
coverageMargin: 0.05,
|
|
465
|
+
teleportDistance: 10,
|
|
466
|
+
});
|
|
467
|
+
// Call after discontinuous dynamic-caster changes or other external scene edits.
|
|
468
|
+
renderingView.invalidateDirectionalShadows();
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
Ordinary refreshes use monotonic-time deadlines, independent of render FPS and simulation time. Initial deadlines are staggered; the oldest overdue deadline wins the ordinary per-frame budget. Rates are upper bounds, rather than guaranteed frequencies if the budget cannot sustain the requested workload. Hard invalidation bypasses both the budget and rate cap.
|
|
472
|
+
|
|
473
|
+
Each retained map keeps its rendered light camera and sampling matrix. Material and volumetric-fog sampling share the renderer's cached light-uniform matrices. Custom graph consumers can use `RendererExtractedLightState.directionals[i].shadowViewProjection` (WebGPU 0�1 depth) rather than reconstructing a matrix from the current scene light. Temporal camera jitter does not invalidate maps. Initialisation, shadow-texture reallocation, light identity/direction, cascade-range changes, FOV/aspect/clip changes, viewer teleports and static draw-set membership/enabled changes force refresh. The complete nominal light volume must fit inside the cached padded volume; coverage loss forces a layer update even before its deadline. Camera turns/translations that remain inside coverage may reuse the map.
|
|
474
|
+
|
|
475
|
+
Coverage padding adds conservative caster coverage and slightly reduces effective shadow texel density. Lower far-cascade rates introduce bounded temporal lag for moving casters. Use higher rates or disable scheduling where that tradeoff is unsuitable. Static material/uniform edits and discontinuous dynamic-caster edits that are not represented by the tracked scene state should explicitly invalidate shadows. This path does not cache point or spot shadows.
|
|
476
|
+
|
|
477
|
+
`RendererFrameProfile.directionalShadows` reports updated/reused/forced layer counts and an update bit mask. Per-pass triangle statistics count only newly submitted shadow geometry on refresh frames. Camera visibility remains independent.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three from 'three';
|
|
2
|
-
import { Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters,
|
|
2
|
+
import { Object3D, Color, Vector2, Vector3, Vector4, Matrix3, Matrix4, Material, Texture, MaterialParameters, PerspectiveCamera, OrthographicCamera, BufferGeometry, DirectionalLight, PointLight, SpotLight, Scene } from 'three';
|
|
3
3
|
export { AmbientLight, BackSide, BatchedMesh, Bone, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, Color, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedArrayTexture as CompressedTextureArray, CubeTexture, Data3DTexture, DataArrayTexture, DataTexture, DepthTexture, DirectionalLight, DoubleSide, FrontSide, Group, HemisphereLight, InstancedMesh, MathUtils, Matrix4, Mesh, Object3D, OrthographicCamera, PerspectiveCamera, PlaneGeometry, PointLight, RepeatWrapping, Scene, Skeleton, SkinnedMesh, SphereGeometry, SpotLight, Texture, Vector2, Vector3, Vector4 } from 'three';
|
|
4
4
|
|
|
5
5
|
interface PipelineDiagnosticOrigin {
|
|
@@ -9,6 +9,29 @@ interface PipelineDiagnosticOrigin {
|
|
|
9
9
|
declare function setPipelineDiagnosticLoading(device: GPUDevice, loading: boolean, phase: string): void;
|
|
10
10
|
declare function registerPipelineDiagnosticOrigin(device: GPUDevice, label: string, origin: PipelineDiagnosticOrigin): void;
|
|
11
11
|
|
|
12
|
+
/** Detail rejection, not mesh simplification. Diameters are measured in render pixels / shadow texels. */
|
|
13
|
+
interface DetailCullingSettings {
|
|
14
|
+
/** Disable automatic camera detail rejection; explicit maxDistance still applies. */
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
minScreenSize?: number;
|
|
17
|
+
/** Distance to the bounding sphere surface in world units. Zero disables. */
|
|
18
|
+
maxDistance?: number;
|
|
19
|
+
shadow?: {
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
minScreenSize?: number;
|
|
22
|
+
maxDistance?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface ResolvedDetailCulling {
|
|
26
|
+
minScreenSize: number;
|
|
27
|
+
maxDistance: number;
|
|
28
|
+
shadowMinScreenSize: number;
|
|
29
|
+
shadowMaxDistance: number;
|
|
30
|
+
}
|
|
31
|
+
/** Serialized in Object3D.userData, inherited through parents, and usable by runtime-created objects. */
|
|
32
|
+
declare function setObjectDetailCulling(object: Object3D, settings: DetailCullingSettings): void;
|
|
33
|
+
declare function resolveDetailCulling(object: Object3D | null, registration?: DetailCullingSettings): ResolvedDetailCulling;
|
|
34
|
+
|
|
12
35
|
type ShaderDefineValue = string | number | boolean;
|
|
13
36
|
type ShaderDefines = Record<string, ShaderDefineValue | null | undefined>;
|
|
14
37
|
|
|
@@ -145,30 +168,8 @@ declare class WGSLShaderMaterial extends Material {
|
|
|
145
168
|
private invalidateBindingCache;
|
|
146
169
|
}
|
|
147
170
|
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
* The canvas format is intentionally kept separate because it is a display
|
|
151
|
-
* target, not an intermediate scene-color target.
|
|
152
|
-
*/
|
|
153
|
-
declare const SCENE_COLOR_FORMAT: GPUTextureFormat;
|
|
154
|
-
|
|
155
|
-
declare function createRenderPipelineAsync(device: GPUDevice, descriptor: GPURenderPipelineDescriptor): Promise<GPURenderPipeline>;
|
|
156
|
-
declare function createComputePipelineAsync(device: GPUDevice, descriptor: GPUComputePipelineDescriptor): Promise<GPUComputePipeline>;
|
|
157
|
-
|
|
158
|
-
interface ComputeKernelDescriptor {
|
|
159
|
-
label?: string;
|
|
160
|
-
code: string;
|
|
161
|
-
entryPoint?: string;
|
|
162
|
-
bindGroupLayoutEntries: GPUBindGroupLayoutEntry[];
|
|
163
|
-
}
|
|
164
|
-
declare class ComputeKernel {
|
|
165
|
-
readonly layout: GPUBindGroupLayout;
|
|
166
|
-
readonly pipeline: GPUComputePipeline;
|
|
167
|
-
static createAsync(device: GPUDevice, descriptor: ComputeKernelDescriptor): Promise<ComputeKernel>;
|
|
168
|
-
/** The optional pipeline allows adopting an already compiled kernel. */
|
|
169
|
-
constructor(device: GPUDevice, descriptor: ComputeKernelDescriptor, pipeline?: GPUComputePipeline);
|
|
170
|
-
createBindGroup(device: GPUDevice, entries: GPUBindGroupEntry[], label?: string): GPUBindGroup;
|
|
171
|
-
}
|
|
171
|
+
/** Shared renderer lighting ABI for procedural particle geometry. */
|
|
172
|
+
declare function buildParticleLightingShaderHeader(receiveShadow?: boolean, modelMatrixBody?: string): string;
|
|
172
173
|
|
|
173
174
|
interface RenderGraphContext {
|
|
174
175
|
readonly device: GPUDevice;
|
|
@@ -198,102 +199,6 @@ declare class RenderGraph {
|
|
|
198
199
|
private resolveExecutionOrder;
|
|
199
200
|
}
|
|
200
201
|
|
|
201
|
-
/** Shared renderer lighting ABI for procedural particle geometry. */
|
|
202
|
-
declare function buildParticleLightingShaderHeader(receiveShadow?: boolean, modelMatrixBody?: string): string;
|
|
203
|
-
|
|
204
|
-
interface TextureResource {
|
|
205
|
-
version: number;
|
|
206
|
-
width: number;
|
|
207
|
-
height: number;
|
|
208
|
-
depthOrArrayLayers: number;
|
|
209
|
-
format: GPUTextureFormat;
|
|
210
|
-
textureDimension: GPUTextureDimension;
|
|
211
|
-
viewDimension: GPUTextureViewDimension;
|
|
212
|
-
sampleType: GPUTextureSampleType;
|
|
213
|
-
samplerBindingType: GPUSamplerBindingType;
|
|
214
|
-
mipLevelCount: number;
|
|
215
|
-
texture: GPUTexture;
|
|
216
|
-
view: GPUTextureView;
|
|
217
|
-
sampler: GPUSampler;
|
|
218
|
-
}
|
|
219
|
-
interface ExtractedLightState {
|
|
220
|
-
ambient: Vector4;
|
|
221
|
-
hemisphere: ExtractedHemisphereLight | null;
|
|
222
|
-
directionals: ExtractedDirectionalLight[];
|
|
223
|
-
points: ExtractedPointLight[];
|
|
224
|
-
spots: ExtractedSpotLight[];
|
|
225
|
-
directional: ExtractedDirectionalLight | null;
|
|
226
|
-
point: ExtractedPointLight | null;
|
|
227
|
-
spot: ExtractedSpotLight | null;
|
|
228
|
-
}
|
|
229
|
-
interface ExtractedHemisphereLight {
|
|
230
|
-
direction: Vector3;
|
|
231
|
-
skyColor: Vector3;
|
|
232
|
-
groundColor: Vector3;
|
|
233
|
-
intensity: number;
|
|
234
|
-
}
|
|
235
|
-
interface ExtractedDirectionalLight {
|
|
236
|
-
sourceLight: DirectionalLight | null;
|
|
237
|
-
position: Vector3;
|
|
238
|
-
target: Vector3;
|
|
239
|
-
direction: Vector3;
|
|
240
|
-
color: Vector3;
|
|
241
|
-
intensity: number;
|
|
242
|
-
volumetricIntensity: number;
|
|
243
|
-
castShadow: boolean;
|
|
244
|
-
shadowBias: number;
|
|
245
|
-
shadowNormalBias: number;
|
|
246
|
-
shadowRadius: number;
|
|
247
|
-
shadowIntensity: number;
|
|
248
|
-
shadowMapSize: number;
|
|
249
|
-
shadowCameraLeft: number;
|
|
250
|
-
shadowCameraRight: number;
|
|
251
|
-
shadowCameraTop: number;
|
|
252
|
-
shadowCameraBottom: number;
|
|
253
|
-
shadowCameraNear: number;
|
|
254
|
-
shadowCameraFar: number;
|
|
255
|
-
}
|
|
256
|
-
interface ExtractedPointLight {
|
|
257
|
-
sourceLight: PointLight;
|
|
258
|
-
position: Vector3;
|
|
259
|
-
color: Vector3;
|
|
260
|
-
intensity: number;
|
|
261
|
-
volumetricIntensity: number;
|
|
262
|
-
distance: number;
|
|
263
|
-
range: number;
|
|
264
|
-
decay: number;
|
|
265
|
-
castShadow: boolean;
|
|
266
|
-
shadowBias: number;
|
|
267
|
-
shadowNormalBias: number;
|
|
268
|
-
shadowRadius: number;
|
|
269
|
-
shadowIntensity: number;
|
|
270
|
-
shadowMapSize: number;
|
|
271
|
-
shadowCameraNear: number;
|
|
272
|
-
shadowCameraFar: number;
|
|
273
|
-
}
|
|
274
|
-
interface ExtractedSpotLight {
|
|
275
|
-
sourceLight: SpotLight;
|
|
276
|
-
position: Vector3;
|
|
277
|
-
direction: Vector3;
|
|
278
|
-
color: Vector3;
|
|
279
|
-
intensity: number;
|
|
280
|
-
volumetricIntensity: number;
|
|
281
|
-
range: number;
|
|
282
|
-
angle: number;
|
|
283
|
-
penumbra: number;
|
|
284
|
-
decay: number;
|
|
285
|
-
castShadow: boolean;
|
|
286
|
-
shadowBias: number;
|
|
287
|
-
shadowNormalBias: number;
|
|
288
|
-
shadowRadius: number;
|
|
289
|
-
shadowIntensity: number;
|
|
290
|
-
shadowMapSize: number;
|
|
291
|
-
shadowCameraNear: number;
|
|
292
|
-
shadowCameraFar: number;
|
|
293
|
-
shadowCameraFov: number;
|
|
294
|
-
map: Texture | null;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
202
|
/** Camera-visible lights collected during the renderer's scene extraction. */
|
|
298
203
|
type RendererExtractedLightState = ExtractedLightState;
|
|
299
204
|
/**
|
|
@@ -308,6 +213,9 @@ interface RendererOptions {
|
|
|
308
213
|
clearColor?: readonly [number, number, number, number];
|
|
309
214
|
powerPreference?: GPUPowerPreference;
|
|
310
215
|
shadowMapSize?: number;
|
|
216
|
+
directionalShadowUpdates?: DirectionalShadowUpdateOptions;
|
|
217
|
+
/** GPU caster selection/indirect submission for supported static draws. Defaults to true. */
|
|
218
|
+
directionalShadowGpuCulling?: boolean;
|
|
311
219
|
pointShadowMapSize?: number;
|
|
312
220
|
sampleCount?: number;
|
|
313
221
|
hiZOcclusionCulling?: boolean;
|
|
@@ -357,6 +265,8 @@ interface RendererOptions {
|
|
|
357
265
|
invokeObjectRenderCallbacks?: boolean;
|
|
358
266
|
}
|
|
359
267
|
interface StaticDrawSetOptions {
|
|
268
|
+
/** Defaults inherited by objects without overrides. Frozen at registration. */
|
|
269
|
+
detailCulling?: DetailCullingSettings;
|
|
360
270
|
label?: string;
|
|
361
271
|
onUnsupported?: "throw" | "skip";
|
|
362
272
|
/**
|
|
@@ -494,11 +404,16 @@ interface RendererCustomPassDescriptor {
|
|
|
494
404
|
execute(context: RendererCustomPassContext): void;
|
|
495
405
|
}
|
|
496
406
|
interface RendererPassProfile {
|
|
407
|
+
/** Submission upper bound for GPU-indirect draws; exact for direct draws. */
|
|
408
|
+
triangleCount?: number;
|
|
409
|
+
drawCallCount?: number;
|
|
497
410
|
name: string;
|
|
498
411
|
cpuTimeMs: number;
|
|
499
412
|
gpuTimeMs: number | null;
|
|
500
413
|
}
|
|
501
414
|
interface RendererVisibilityProfile {
|
|
415
|
+
/** Actual triangles in GPU camera-visible indirect arguments (one color submission). */
|
|
416
|
+
visibleTriangles?: number;
|
|
502
417
|
totalInstances: number;
|
|
503
418
|
visibleInstances: number;
|
|
504
419
|
culledInstances: number;
|
|
@@ -508,10 +423,19 @@ interface RendererVisibilityProfile {
|
|
|
508
423
|
staticVisibleInstances: number;
|
|
509
424
|
}
|
|
510
425
|
interface RendererFrameProfile {
|
|
426
|
+
directionalShadows?: {
|
|
427
|
+
updatedLayers: number;
|
|
428
|
+
reusedLayers: number;
|
|
429
|
+
forcedLayers: number;
|
|
430
|
+
updateMask: number;
|
|
431
|
+
/** Indirect command count; triangle counters remain upper bounds with GPU culling. */
|
|
432
|
+
gpuIndirectDraws?: number;
|
|
433
|
+
};
|
|
511
434
|
frameIndex: number;
|
|
512
435
|
cpuTimeMs: number;
|
|
513
436
|
gpuTimeMs: number | null;
|
|
514
437
|
drawCallCount: number;
|
|
438
|
+
/** Counts repeated passes; upper bound for GPU-indirect draws, not unique visible geometry. */
|
|
515
439
|
triangleCount: number;
|
|
516
440
|
cpuPhases: {
|
|
517
441
|
extractSceneMs: number;
|
|
@@ -532,6 +456,141 @@ interface RendererFrameProfile {
|
|
|
532
456
|
visibility: RendererVisibilityProfile | null;
|
|
533
457
|
}
|
|
534
458
|
|
|
459
|
+
interface TextureResource {
|
|
460
|
+
version: number;
|
|
461
|
+
width: number;
|
|
462
|
+
height: number;
|
|
463
|
+
depthOrArrayLayers: number;
|
|
464
|
+
format: GPUTextureFormat;
|
|
465
|
+
textureDimension: GPUTextureDimension;
|
|
466
|
+
viewDimension: GPUTextureViewDimension;
|
|
467
|
+
sampleType: GPUTextureSampleType;
|
|
468
|
+
samplerBindingType: GPUSamplerBindingType;
|
|
469
|
+
mipLevelCount: number;
|
|
470
|
+
texture: GPUTexture;
|
|
471
|
+
view: GPUTextureView;
|
|
472
|
+
sampler: GPUSampler;
|
|
473
|
+
}
|
|
474
|
+
interface ExtractedLightState {
|
|
475
|
+
ambient: Vector4;
|
|
476
|
+
hemisphere: ExtractedHemisphereLight | null;
|
|
477
|
+
directionals: ExtractedDirectionalLight[];
|
|
478
|
+
points: ExtractedPointLight[];
|
|
479
|
+
spots: ExtractedSpotLight[];
|
|
480
|
+
directional: ExtractedDirectionalLight | null;
|
|
481
|
+
point: ExtractedPointLight | null;
|
|
482
|
+
spot: ExtractedSpotLight | null;
|
|
483
|
+
}
|
|
484
|
+
interface ExtractedHemisphereLight {
|
|
485
|
+
direction: Vector3;
|
|
486
|
+
skyColor: Vector3;
|
|
487
|
+
groundColor: Vector3;
|
|
488
|
+
intensity: number;
|
|
489
|
+
}
|
|
490
|
+
interface ExtractedDirectionalLight {
|
|
491
|
+
/** Actual WebGPU (0..1 depth) projection of this frame's retained shadow layer. */
|
|
492
|
+
shadowViewProjection?: Matrix4;
|
|
493
|
+
sourceLight: DirectionalLight | null;
|
|
494
|
+
position: Vector3;
|
|
495
|
+
target: Vector3;
|
|
496
|
+
direction: Vector3;
|
|
497
|
+
color: Vector3;
|
|
498
|
+
intensity: number;
|
|
499
|
+
volumetricIntensity: number;
|
|
500
|
+
castShadow: boolean;
|
|
501
|
+
shadowBias: number;
|
|
502
|
+
shadowNormalBias: number;
|
|
503
|
+
shadowRadius: number;
|
|
504
|
+
shadowIntensity: number;
|
|
505
|
+
shadowMapSize: number;
|
|
506
|
+
shadowCameraLeft: number;
|
|
507
|
+
shadowCameraRight: number;
|
|
508
|
+
shadowCameraTop: number;
|
|
509
|
+
shadowCameraBottom: number;
|
|
510
|
+
shadowCameraNear: number;
|
|
511
|
+
shadowCameraFar: number;
|
|
512
|
+
}
|
|
513
|
+
interface ExtractedPointLight {
|
|
514
|
+
sourceLight: PointLight;
|
|
515
|
+
position: Vector3;
|
|
516
|
+
color: Vector3;
|
|
517
|
+
intensity: number;
|
|
518
|
+
volumetricIntensity: number;
|
|
519
|
+
distance: number;
|
|
520
|
+
range: number;
|
|
521
|
+
decay: number;
|
|
522
|
+
castShadow: boolean;
|
|
523
|
+
shadowBias: number;
|
|
524
|
+
shadowNormalBias: number;
|
|
525
|
+
shadowRadius: number;
|
|
526
|
+
shadowIntensity: number;
|
|
527
|
+
shadowMapSize: number;
|
|
528
|
+
shadowCameraNear: number;
|
|
529
|
+
shadowCameraFar: number;
|
|
530
|
+
}
|
|
531
|
+
interface ExtractedSpotLight {
|
|
532
|
+
sourceLight: SpotLight;
|
|
533
|
+
position: Vector3;
|
|
534
|
+
direction: Vector3;
|
|
535
|
+
color: Vector3;
|
|
536
|
+
intensity: number;
|
|
537
|
+
volumetricIntensity: number;
|
|
538
|
+
range: number;
|
|
539
|
+
angle: number;
|
|
540
|
+
penumbra: number;
|
|
541
|
+
decay: number;
|
|
542
|
+
castShadow: boolean;
|
|
543
|
+
shadowBias: number;
|
|
544
|
+
shadowNormalBias: number;
|
|
545
|
+
shadowRadius: number;
|
|
546
|
+
shadowIntensity: number;
|
|
547
|
+
shadowMapSize: number;
|
|
548
|
+
shadowCameraNear: number;
|
|
549
|
+
shadowCameraFar: number;
|
|
550
|
+
shadowCameraFov: number;
|
|
551
|
+
map: Texture | null;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/** Opt-in temporal caching for directional shadow maps, independent of render FPS. */
|
|
555
|
+
interface DirectionalShadowUpdateOptions {
|
|
556
|
+
enabled?: boolean;
|
|
557
|
+
/** Upper limit for ordinary layer refreshes, in updates/second. Default 60. */
|
|
558
|
+
maxUpdateHz?: number;
|
|
559
|
+
/** Near-to-far maximum rates. Default [60, 30, 15, 7.5]. */
|
|
560
|
+
cascadeUpdateHz?: readonly number[];
|
|
561
|
+
/** Ordinary refresh budget. Hard invalidations bypass it. Default 2. */
|
|
562
|
+
maxUpdatesPerFrame?: number;
|
|
563
|
+
/** Extra light-space coverage per side, as a fraction of nominal extent. Default .05. */
|
|
564
|
+
coverageMargin?: number;
|
|
565
|
+
/** Viewer displacement in one frame that invalidates all layers. Default 10 world units. */
|
|
566
|
+
teleportDistance?: number;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Lighting and post-processing stay in linear HDR until the present pass.
|
|
571
|
+
* The canvas format is intentionally kept separate because it is a display
|
|
572
|
+
* target, not an intermediate scene-color target.
|
|
573
|
+
*/
|
|
574
|
+
declare const SCENE_COLOR_FORMAT: GPUTextureFormat;
|
|
575
|
+
|
|
576
|
+
declare function createRenderPipelineAsync(device: GPUDevice, descriptor: GPURenderPipelineDescriptor): Promise<GPURenderPipeline>;
|
|
577
|
+
declare function createComputePipelineAsync(device: GPUDevice, descriptor: GPUComputePipelineDescriptor): Promise<GPUComputePipeline>;
|
|
578
|
+
|
|
579
|
+
interface ComputeKernelDescriptor {
|
|
580
|
+
label?: string;
|
|
581
|
+
code: string;
|
|
582
|
+
entryPoint?: string;
|
|
583
|
+
bindGroupLayoutEntries: GPUBindGroupLayoutEntry[];
|
|
584
|
+
}
|
|
585
|
+
declare class ComputeKernel {
|
|
586
|
+
readonly layout: GPUBindGroupLayout;
|
|
587
|
+
readonly pipeline: GPUComputePipeline;
|
|
588
|
+
static createAsync(device: GPUDevice, descriptor: ComputeKernelDescriptor): Promise<ComputeKernel>;
|
|
589
|
+
/** The optional pipeline allows adopting an already compiled kernel. */
|
|
590
|
+
constructor(device: GPUDevice, descriptor: ComputeKernelDescriptor, pipeline?: GPUComputePipeline);
|
|
591
|
+
createBindGroup(device: GPUDevice, entries: GPUBindGroupEntry[], label?: string): GPUBindGroup;
|
|
592
|
+
}
|
|
593
|
+
|
|
535
594
|
type FrameGraphTextureHandle = string;
|
|
536
595
|
interface FrameGraphPassDescriptor {
|
|
537
596
|
readonly name: string;
|
|
@@ -874,6 +933,8 @@ declare class WebGpuRenderer {
|
|
|
874
933
|
* so regular meshes see that change without paying resolver work per mesh.
|
|
875
934
|
*/
|
|
876
935
|
private readonly resolvedMaterialFrameCache;
|
|
936
|
+
private readonly repeatedMeshInstances;
|
|
937
|
+
private readonly repeatedInstanceResources;
|
|
877
938
|
private readonly instancedMeshExtractionCache;
|
|
878
939
|
private readonly batchedMeshExtractionCache;
|
|
879
940
|
private readonly materialCache;
|
|
@@ -929,6 +990,9 @@ declare class WebGpuRenderer {
|
|
|
929
990
|
private readonly presentationOverlay;
|
|
930
991
|
private readonly presentationOverlayContext;
|
|
931
992
|
private readonly directionalShadowCameras;
|
|
993
|
+
private readonly directionalShadowScheduler;
|
|
994
|
+
private readonly directionalShadowGpu;
|
|
995
|
+
private readonly directionalShadowSubmissionStats;
|
|
932
996
|
private readonly pointShadowCameras;
|
|
933
997
|
private readonly spotShadowCameras;
|
|
934
998
|
private readonly colorTargetCache;
|
|
@@ -974,6 +1038,14 @@ declare class WebGpuRenderer {
|
|
|
974
1038
|
private staticFrameToken;
|
|
975
1039
|
private hizResourceVersion;
|
|
976
1040
|
private graphTextureResourceVersion;
|
|
1041
|
+
private transmissionSnapshotTexture;
|
|
1042
|
+
private transmissionSnapshotView;
|
|
1043
|
+
private transmissionSnapshotSize;
|
|
1044
|
+
private transmissionMipViews;
|
|
1045
|
+
private transmissionMipBindGroups;
|
|
1046
|
+
private transmissionSourceBindGroups;
|
|
1047
|
+
private transmissionSnapshotPipeline;
|
|
1048
|
+
private transmissionSampler;
|
|
977
1049
|
private readonly visibilityParamsUpload;
|
|
978
1050
|
private drawMetadataUpload;
|
|
979
1051
|
private indirectDrawUpload;
|
|
@@ -1017,6 +1089,9 @@ declare class WebGpuRenderer {
|
|
|
1017
1089
|
private readonly objectMotionHistory;
|
|
1018
1090
|
private readonly cameraFrustumPlanesScratch;
|
|
1019
1091
|
private readonly objectTraversalStackScratch;
|
|
1092
|
+
private readonly shadowDrawsScratch;
|
|
1093
|
+
private extractingCaster;
|
|
1094
|
+
private readonly cameraDetailHistory;
|
|
1020
1095
|
private readonly isSphereVisibleScratch;
|
|
1021
1096
|
private readonly isSphereVisibleForCompilationScratch;
|
|
1022
1097
|
private readonly updateExtractedBoundsFromMatrixScratch;
|
|
@@ -1063,6 +1138,10 @@ declare class WebGpuRenderer {
|
|
|
1063
1138
|
}[], lights?: readonly DirectionalLight[]): void;
|
|
1064
1139
|
/** Sets the base resolution used by directional shadow-map array layers. */
|
|
1065
1140
|
setDirectionalShadowMapSize(size: number): void;
|
|
1141
|
+
setDirectionalShadowUpdateOptions(options: DirectionalShadowUpdateOptions): void;
|
|
1142
|
+
/** Invalidate retained maps after discontinuous caster/scene changes. */
|
|
1143
|
+
invalidateDirectionalShadows(): void;
|
|
1144
|
+
setDirectionalShadowGpuCullingEnabled(enabled: boolean): void;
|
|
1066
1145
|
setDirectionalShadowsEnabled(enabled: boolean): void;
|
|
1067
1146
|
setRenderGraphProfilingEnabled(enabled: boolean): void;
|
|
1068
1147
|
getRenderGraphProfilingEnabled(): boolean;
|
|
@@ -1129,6 +1208,8 @@ declare class WebGpuRenderer {
|
|
|
1129
1208
|
private recordPresentationOverlay;
|
|
1130
1209
|
destroy(): void;
|
|
1131
1210
|
private createStaticPipelines;
|
|
1211
|
+
private ensureTransmissionSnapshot;
|
|
1212
|
+
private copyTransmissionSnapshot;
|
|
1132
1213
|
private recreateShadowResources;
|
|
1133
1214
|
private recreateDirectionalShadowResources;
|
|
1134
1215
|
private ensureShadowTextureSizes;
|
|
@@ -1253,6 +1334,7 @@ declare class WebGpuRenderer {
|
|
|
1253
1334
|
private getMaterialVertexAttributes;
|
|
1254
1335
|
private getGeometryVertexBuffer;
|
|
1255
1336
|
private cacheGeometryVertexBufferFast;
|
|
1337
|
+
private readonly packedVertexGroups;
|
|
1256
1338
|
private getInterleavedGeometryVertexBuffer;
|
|
1257
1339
|
private ensureWireframeIndex;
|
|
1258
1340
|
private bindGeometryVertexBuffers;
|
|
@@ -1342,6 +1424,10 @@ interface GTAOTemporalOptions {
|
|
|
1342
1424
|
readonly neighborhoodClamp?: boolean;
|
|
1343
1425
|
}
|
|
1344
1426
|
interface GTAOOptions {
|
|
1427
|
+
/** Strength used by addCompositePass unless explicitly overridden. Defaults to 0.6. */
|
|
1428
|
+
readonly intensity?: number;
|
|
1429
|
+
/** Visibility exponent used by addCompositePass. Defaults to 1. */
|
|
1430
|
+
readonly power?: number;
|
|
1345
1431
|
readonly enabled?: boolean;
|
|
1346
1432
|
/** Resolution relative to the render target. Defaults to 1. */
|
|
1347
1433
|
readonly resolutionScale?: number;
|
|
@@ -1765,4 +1851,4 @@ declare class OutlineEffect {
|
|
|
1765
1851
|
dispose(): void;
|
|
1766
1852
|
}
|
|
1767
1853
|
|
|
1768
|
-
export { type BloomCompositeOptions, BloomEffect, type BloomOptions, ColorGradingEffect, type ColorGradingOptions, type ColorGradingRange, type ColorGradingVector, type CompiledNodeFullscreenShader, ComputeKernel, type ComputeKernelDescriptor, DEFAULT_WGSL_VERTEX_ATTRIBUTES, DepthOfFieldEffect, type DepthOfFieldOptions, type FXAACompositeOptions, FXAAEffect, type FXAAOptions, FrameGraphBuilder, type FrameGraphFullscreenPassDescriptor, type FrameGraphMaterialPassDescriptor, type FrameGraphNodeFullscreenPassDescriptor, type FrameGraphPassDescriptor, type FrameGraphTextureHandle, type GTAOCompositeOptions, type GTAODenoiseOptions, GTAOEffect, type GTAOInputs, type GTAOOptions, type GTAOQuality, type GTAOTemporalOptions, GTAO_PRESETS, MOTION_BLUR_PRESETS, MotionBlurEffect, MotionBlurMode, type MotionBlurOptions, type MotionBlurOverride, type MotionBlurOverrideHandle, type MotionBlurQuality, OutlineEffect, type OutlineInputs, type OutlineInstanceSelection, type OutlineOptions, type PipelineDiagnosticOrigin, RenderGraph, type RenderGraphContext, type RenderGraphExecutionObserver, type RenderGraphPass, type RendererColorTargetDescriptor, type RendererCustomPassContext, type RendererCustomPassDescriptor, type RendererFrameProfile, type RendererGraphBuilder, type RendererGraphBuilderContext, type RendererMaterialPassDescriptor, type RendererMaterialResolver, type RendererOptions, type RendererPassProfile, type RendererShadowMapDebugInfo, type RendererShadowMapDebugTextureInfo, type RendererTextureTargetDescriptor, type RendererVisibilityProfile, SCENE_COLOR_FORMAT, type SMAACompositeOptions, type SMAAEdgeDetectionMode, SMAAEffect, type SMAAOptions, type SMAAQualityPreset, SSREffect, type SSRInputs, type SSROptions, type ShaderDefineValue, type ShaderDefines, type StaticDrawSet, type StaticDrawSetOptions, TemporalAAEffect, type TemporalAAOptions, type ToneMappingMode, type ToonOutlineParameters, type UniformDefinition, type UniformType, type UniformValue, VOLUMETRIC_FOG_MATERIAL_WGSL, VOLUMETRIC_FOG_PRESETS, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogQuality, type VolumetricFogScatteringMode, type VolumetricFogTemporalOptions, VolumetricFogVolumeObject, type VolumetricFogVolumeSettings, type WGSLGraphTextureDimension, type WGSLGraphTextureInput, type WGSLSceneTextureSemantic, WGSLShaderMaterial, type WGSLShaderMaterialParameters, type WGSLShaderMaterialUniform, type WGSLShaderMaterialUniformInput, type WGSLStorageBufferBinding, type WGSLStorageBufferVisibility, type WGSLSupportedVertexFormat, type WGSLVertexAttributeBinding, WebGpuPMREMGenerator, WebGpuRenderer, buildParticleLightingShaderHeader, configureVolumetricFogMaterial, createComputePipelineAsync, createRenderPipelineAsync, registerPipelineDiagnosticOrigin, setPipelineDiagnosticLoading };
|
|
1854
|
+
export { type BloomCompositeOptions, BloomEffect, type BloomOptions, ColorGradingEffect, type ColorGradingOptions, type ColorGradingRange, type ColorGradingVector, type CompiledNodeFullscreenShader, ComputeKernel, type ComputeKernelDescriptor, DEFAULT_WGSL_VERTEX_ATTRIBUTES, DepthOfFieldEffect, type DepthOfFieldOptions, type DetailCullingSettings, type DirectionalShadowUpdateOptions, type FXAACompositeOptions, FXAAEffect, type FXAAOptions, FrameGraphBuilder, type FrameGraphFullscreenPassDescriptor, type FrameGraphMaterialPassDescriptor, type FrameGraphNodeFullscreenPassDescriptor, type FrameGraphPassDescriptor, type FrameGraphTextureHandle, type GTAOCompositeOptions, type GTAODenoiseOptions, GTAOEffect, type GTAOInputs, type GTAOOptions, type GTAOQuality, type GTAOTemporalOptions, GTAO_PRESETS, MOTION_BLUR_PRESETS, MotionBlurEffect, MotionBlurMode, type MotionBlurOptions, type MotionBlurOverride, type MotionBlurOverrideHandle, type MotionBlurQuality, OutlineEffect, type OutlineInputs, type OutlineInstanceSelection, type OutlineOptions, type PipelineDiagnosticOrigin, RenderGraph, type RenderGraphContext, type RenderGraphExecutionObserver, type RenderGraphPass, type RendererColorTargetDescriptor, type RendererCustomPassContext, type RendererCustomPassDescriptor, type RendererFrameProfile, type RendererGraphBuilder, type RendererGraphBuilderContext, type RendererMaterialPassDescriptor, type RendererMaterialResolver, type RendererOptions, type RendererPassProfile, type RendererShadowMapDebugInfo, type RendererShadowMapDebugTextureInfo, type RendererTextureTargetDescriptor, type RendererVisibilityProfile, SCENE_COLOR_FORMAT, type SMAACompositeOptions, type SMAAEdgeDetectionMode, SMAAEffect, type SMAAOptions, type SMAAQualityPreset, SSREffect, type SSRInputs, type SSROptions, type ShaderDefineValue, type ShaderDefines, type StaticDrawSet, type StaticDrawSetOptions, TemporalAAEffect, type TemporalAAOptions, type ToneMappingMode, type ToonOutlineParameters, type UniformDefinition, type UniformType, type UniformValue, VOLUMETRIC_FOG_MATERIAL_WGSL, VOLUMETRIC_FOG_PRESETS, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogQuality, type VolumetricFogScatteringMode, type VolumetricFogTemporalOptions, VolumetricFogVolumeObject, type VolumetricFogVolumeSettings, type WGSLGraphTextureDimension, type WGSLGraphTextureInput, type WGSLSceneTextureSemantic, WGSLShaderMaterial, type WGSLShaderMaterialParameters, type WGSLShaderMaterialUniform, type WGSLShaderMaterialUniformInput, type WGSLStorageBufferBinding, type WGSLStorageBufferVisibility, type WGSLSupportedVertexFormat, type WGSLVertexAttributeBinding, WebGpuPMREMGenerator, WebGpuRenderer, buildParticleLightingShaderHeader, configureVolumetricFogMaterial, createComputePipelineAsync, createRenderPipelineAsync, registerPipelineDiagnosticOrigin, resolveDetailCulling, setObjectDetailCulling, setPipelineDiagnosticLoading };
|