@hology/webgpu-renderer 0.1.19 → 0.1.20
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 +200 -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,7 @@ interface RendererOptions {
|
|
|
308
213
|
clearColor?: readonly [number, number, number, number];
|
|
309
214
|
powerPreference?: GPUPowerPreference;
|
|
310
215
|
shadowMapSize?: number;
|
|
216
|
+
directionalShadowUpdates?: DirectionalShadowUpdateOptions;
|
|
311
217
|
pointShadowMapSize?: number;
|
|
312
218
|
sampleCount?: number;
|
|
313
219
|
hiZOcclusionCulling?: boolean;
|
|
@@ -357,6 +263,8 @@ interface RendererOptions {
|
|
|
357
263
|
invokeObjectRenderCallbacks?: boolean;
|
|
358
264
|
}
|
|
359
265
|
interface StaticDrawSetOptions {
|
|
266
|
+
/** Defaults inherited by objects without overrides. Frozen at registration. */
|
|
267
|
+
detailCulling?: DetailCullingSettings;
|
|
360
268
|
label?: string;
|
|
361
269
|
onUnsupported?: "throw" | "skip";
|
|
362
270
|
/**
|
|
@@ -494,11 +402,16 @@ interface RendererCustomPassDescriptor {
|
|
|
494
402
|
execute(context: RendererCustomPassContext): void;
|
|
495
403
|
}
|
|
496
404
|
interface RendererPassProfile {
|
|
405
|
+
/** Submission upper bound for GPU-indirect draws; exact for direct draws. */
|
|
406
|
+
triangleCount?: number;
|
|
407
|
+
drawCallCount?: number;
|
|
497
408
|
name: string;
|
|
498
409
|
cpuTimeMs: number;
|
|
499
410
|
gpuTimeMs: number | null;
|
|
500
411
|
}
|
|
501
412
|
interface RendererVisibilityProfile {
|
|
413
|
+
/** Actual triangles in GPU camera-visible indirect arguments (one color submission). */
|
|
414
|
+
visibleTriangles?: number;
|
|
502
415
|
totalInstances: number;
|
|
503
416
|
visibleInstances: number;
|
|
504
417
|
culledInstances: number;
|
|
@@ -508,10 +421,17 @@ interface RendererVisibilityProfile {
|
|
|
508
421
|
staticVisibleInstances: number;
|
|
509
422
|
}
|
|
510
423
|
interface RendererFrameProfile {
|
|
424
|
+
directionalShadows?: {
|
|
425
|
+
updatedLayers: number;
|
|
426
|
+
reusedLayers: number;
|
|
427
|
+
forcedLayers: number;
|
|
428
|
+
updateMask: number;
|
|
429
|
+
};
|
|
511
430
|
frameIndex: number;
|
|
512
431
|
cpuTimeMs: number;
|
|
513
432
|
gpuTimeMs: number | null;
|
|
514
433
|
drawCallCount: number;
|
|
434
|
+
/** Counts repeated passes; upper bound for GPU-indirect draws, not unique visible geometry. */
|
|
515
435
|
triangleCount: number;
|
|
516
436
|
cpuPhases: {
|
|
517
437
|
extractSceneMs: number;
|
|
@@ -532,6 +452,141 @@ interface RendererFrameProfile {
|
|
|
532
452
|
visibility: RendererVisibilityProfile | null;
|
|
533
453
|
}
|
|
534
454
|
|
|
455
|
+
interface TextureResource {
|
|
456
|
+
version: number;
|
|
457
|
+
width: number;
|
|
458
|
+
height: number;
|
|
459
|
+
depthOrArrayLayers: number;
|
|
460
|
+
format: GPUTextureFormat;
|
|
461
|
+
textureDimension: GPUTextureDimension;
|
|
462
|
+
viewDimension: GPUTextureViewDimension;
|
|
463
|
+
sampleType: GPUTextureSampleType;
|
|
464
|
+
samplerBindingType: GPUSamplerBindingType;
|
|
465
|
+
mipLevelCount: number;
|
|
466
|
+
texture: GPUTexture;
|
|
467
|
+
view: GPUTextureView;
|
|
468
|
+
sampler: GPUSampler;
|
|
469
|
+
}
|
|
470
|
+
interface ExtractedLightState {
|
|
471
|
+
ambient: Vector4;
|
|
472
|
+
hemisphere: ExtractedHemisphereLight | null;
|
|
473
|
+
directionals: ExtractedDirectionalLight[];
|
|
474
|
+
points: ExtractedPointLight[];
|
|
475
|
+
spots: ExtractedSpotLight[];
|
|
476
|
+
directional: ExtractedDirectionalLight | null;
|
|
477
|
+
point: ExtractedPointLight | null;
|
|
478
|
+
spot: ExtractedSpotLight | null;
|
|
479
|
+
}
|
|
480
|
+
interface ExtractedHemisphereLight {
|
|
481
|
+
direction: Vector3;
|
|
482
|
+
skyColor: Vector3;
|
|
483
|
+
groundColor: Vector3;
|
|
484
|
+
intensity: number;
|
|
485
|
+
}
|
|
486
|
+
interface ExtractedDirectionalLight {
|
|
487
|
+
/** Actual WebGPU (0..1 depth) projection of this frame's retained shadow layer. */
|
|
488
|
+
shadowViewProjection?: Matrix4;
|
|
489
|
+
sourceLight: DirectionalLight | null;
|
|
490
|
+
position: Vector3;
|
|
491
|
+
target: Vector3;
|
|
492
|
+
direction: Vector3;
|
|
493
|
+
color: Vector3;
|
|
494
|
+
intensity: number;
|
|
495
|
+
volumetricIntensity: number;
|
|
496
|
+
castShadow: boolean;
|
|
497
|
+
shadowBias: number;
|
|
498
|
+
shadowNormalBias: number;
|
|
499
|
+
shadowRadius: number;
|
|
500
|
+
shadowIntensity: number;
|
|
501
|
+
shadowMapSize: number;
|
|
502
|
+
shadowCameraLeft: number;
|
|
503
|
+
shadowCameraRight: number;
|
|
504
|
+
shadowCameraTop: number;
|
|
505
|
+
shadowCameraBottom: number;
|
|
506
|
+
shadowCameraNear: number;
|
|
507
|
+
shadowCameraFar: number;
|
|
508
|
+
}
|
|
509
|
+
interface ExtractedPointLight {
|
|
510
|
+
sourceLight: PointLight;
|
|
511
|
+
position: Vector3;
|
|
512
|
+
color: Vector3;
|
|
513
|
+
intensity: number;
|
|
514
|
+
volumetricIntensity: number;
|
|
515
|
+
distance: number;
|
|
516
|
+
range: number;
|
|
517
|
+
decay: number;
|
|
518
|
+
castShadow: boolean;
|
|
519
|
+
shadowBias: number;
|
|
520
|
+
shadowNormalBias: number;
|
|
521
|
+
shadowRadius: number;
|
|
522
|
+
shadowIntensity: number;
|
|
523
|
+
shadowMapSize: number;
|
|
524
|
+
shadowCameraNear: number;
|
|
525
|
+
shadowCameraFar: number;
|
|
526
|
+
}
|
|
527
|
+
interface ExtractedSpotLight {
|
|
528
|
+
sourceLight: SpotLight;
|
|
529
|
+
position: Vector3;
|
|
530
|
+
direction: Vector3;
|
|
531
|
+
color: Vector3;
|
|
532
|
+
intensity: number;
|
|
533
|
+
volumetricIntensity: number;
|
|
534
|
+
range: number;
|
|
535
|
+
angle: number;
|
|
536
|
+
penumbra: number;
|
|
537
|
+
decay: number;
|
|
538
|
+
castShadow: boolean;
|
|
539
|
+
shadowBias: number;
|
|
540
|
+
shadowNormalBias: number;
|
|
541
|
+
shadowRadius: number;
|
|
542
|
+
shadowIntensity: number;
|
|
543
|
+
shadowMapSize: number;
|
|
544
|
+
shadowCameraNear: number;
|
|
545
|
+
shadowCameraFar: number;
|
|
546
|
+
shadowCameraFov: number;
|
|
547
|
+
map: Texture | null;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** Opt-in temporal caching for directional shadow maps, independent of render FPS. */
|
|
551
|
+
interface DirectionalShadowUpdateOptions {
|
|
552
|
+
enabled?: boolean;
|
|
553
|
+
/** Upper limit for ordinary layer refreshes, in updates/second. Default 60. */
|
|
554
|
+
maxUpdateHz?: number;
|
|
555
|
+
/** Near-to-far maximum rates. Default [60, 30, 15, 7.5]. */
|
|
556
|
+
cascadeUpdateHz?: readonly number[];
|
|
557
|
+
/** Ordinary refresh budget. Hard invalidations bypass it. Default 2. */
|
|
558
|
+
maxUpdatesPerFrame?: number;
|
|
559
|
+
/** Extra light-space coverage per side, as a fraction of nominal extent. Default .05. */
|
|
560
|
+
coverageMargin?: number;
|
|
561
|
+
/** Viewer displacement in one frame that invalidates all layers. Default 10 world units. */
|
|
562
|
+
teleportDistance?: number;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Lighting and post-processing stay in linear HDR until the present pass.
|
|
567
|
+
* The canvas format is intentionally kept separate because it is a display
|
|
568
|
+
* target, not an intermediate scene-color target.
|
|
569
|
+
*/
|
|
570
|
+
declare const SCENE_COLOR_FORMAT: GPUTextureFormat;
|
|
571
|
+
|
|
572
|
+
declare function createRenderPipelineAsync(device: GPUDevice, descriptor: GPURenderPipelineDescriptor): Promise<GPURenderPipeline>;
|
|
573
|
+
declare function createComputePipelineAsync(device: GPUDevice, descriptor: GPUComputePipelineDescriptor): Promise<GPUComputePipeline>;
|
|
574
|
+
|
|
575
|
+
interface ComputeKernelDescriptor {
|
|
576
|
+
label?: string;
|
|
577
|
+
code: string;
|
|
578
|
+
entryPoint?: string;
|
|
579
|
+
bindGroupLayoutEntries: GPUBindGroupLayoutEntry[];
|
|
580
|
+
}
|
|
581
|
+
declare class ComputeKernel {
|
|
582
|
+
readonly layout: GPUBindGroupLayout;
|
|
583
|
+
readonly pipeline: GPUComputePipeline;
|
|
584
|
+
static createAsync(device: GPUDevice, descriptor: ComputeKernelDescriptor): Promise<ComputeKernel>;
|
|
585
|
+
/** The optional pipeline allows adopting an already compiled kernel. */
|
|
586
|
+
constructor(device: GPUDevice, descriptor: ComputeKernelDescriptor, pipeline?: GPUComputePipeline);
|
|
587
|
+
createBindGroup(device: GPUDevice, entries: GPUBindGroupEntry[], label?: string): GPUBindGroup;
|
|
588
|
+
}
|
|
589
|
+
|
|
535
590
|
type FrameGraphTextureHandle = string;
|
|
536
591
|
interface FrameGraphPassDescriptor {
|
|
537
592
|
readonly name: string;
|
|
@@ -874,6 +929,8 @@ declare class WebGpuRenderer {
|
|
|
874
929
|
* so regular meshes see that change without paying resolver work per mesh.
|
|
875
930
|
*/
|
|
876
931
|
private readonly resolvedMaterialFrameCache;
|
|
932
|
+
private readonly repeatedMeshInstances;
|
|
933
|
+
private readonly repeatedInstanceResources;
|
|
877
934
|
private readonly instancedMeshExtractionCache;
|
|
878
935
|
private readonly batchedMeshExtractionCache;
|
|
879
936
|
private readonly materialCache;
|
|
@@ -929,6 +986,7 @@ declare class WebGpuRenderer {
|
|
|
929
986
|
private readonly presentationOverlay;
|
|
930
987
|
private readonly presentationOverlayContext;
|
|
931
988
|
private readonly directionalShadowCameras;
|
|
989
|
+
private readonly directionalShadowScheduler;
|
|
932
990
|
private readonly pointShadowCameras;
|
|
933
991
|
private readonly spotShadowCameras;
|
|
934
992
|
private readonly colorTargetCache;
|
|
@@ -974,6 +1032,14 @@ declare class WebGpuRenderer {
|
|
|
974
1032
|
private staticFrameToken;
|
|
975
1033
|
private hizResourceVersion;
|
|
976
1034
|
private graphTextureResourceVersion;
|
|
1035
|
+
private transmissionSnapshotTexture;
|
|
1036
|
+
private transmissionSnapshotView;
|
|
1037
|
+
private transmissionSnapshotSize;
|
|
1038
|
+
private transmissionMipViews;
|
|
1039
|
+
private transmissionMipBindGroups;
|
|
1040
|
+
private transmissionSourceBindGroups;
|
|
1041
|
+
private transmissionSnapshotPipeline;
|
|
1042
|
+
private transmissionSampler;
|
|
977
1043
|
private readonly visibilityParamsUpload;
|
|
978
1044
|
private drawMetadataUpload;
|
|
979
1045
|
private indirectDrawUpload;
|
|
@@ -1017,6 +1083,9 @@ declare class WebGpuRenderer {
|
|
|
1017
1083
|
private readonly objectMotionHistory;
|
|
1018
1084
|
private readonly cameraFrustumPlanesScratch;
|
|
1019
1085
|
private readonly objectTraversalStackScratch;
|
|
1086
|
+
private readonly shadowDrawsScratch;
|
|
1087
|
+
private extractingCaster;
|
|
1088
|
+
private readonly cameraDetailHistory;
|
|
1020
1089
|
private readonly isSphereVisibleScratch;
|
|
1021
1090
|
private readonly isSphereVisibleForCompilationScratch;
|
|
1022
1091
|
private readonly updateExtractedBoundsFromMatrixScratch;
|
|
@@ -1063,6 +1132,9 @@ declare class WebGpuRenderer {
|
|
|
1063
1132
|
}[], lights?: readonly DirectionalLight[]): void;
|
|
1064
1133
|
/** Sets the base resolution used by directional shadow-map array layers. */
|
|
1065
1134
|
setDirectionalShadowMapSize(size: number): void;
|
|
1135
|
+
setDirectionalShadowUpdateOptions(options: DirectionalShadowUpdateOptions): void;
|
|
1136
|
+
/** Invalidate retained maps after discontinuous caster/scene changes. */
|
|
1137
|
+
invalidateDirectionalShadows(): void;
|
|
1066
1138
|
setDirectionalShadowsEnabled(enabled: boolean): void;
|
|
1067
1139
|
setRenderGraphProfilingEnabled(enabled: boolean): void;
|
|
1068
1140
|
getRenderGraphProfilingEnabled(): boolean;
|
|
@@ -1129,6 +1201,8 @@ declare class WebGpuRenderer {
|
|
|
1129
1201
|
private recordPresentationOverlay;
|
|
1130
1202
|
destroy(): void;
|
|
1131
1203
|
private createStaticPipelines;
|
|
1204
|
+
private ensureTransmissionSnapshot;
|
|
1205
|
+
private copyTransmissionSnapshot;
|
|
1132
1206
|
private recreateShadowResources;
|
|
1133
1207
|
private recreateDirectionalShadowResources;
|
|
1134
1208
|
private ensureShadowTextureSizes;
|
|
@@ -1342,6 +1416,10 @@ interface GTAOTemporalOptions {
|
|
|
1342
1416
|
readonly neighborhoodClamp?: boolean;
|
|
1343
1417
|
}
|
|
1344
1418
|
interface GTAOOptions {
|
|
1419
|
+
/** Strength used by addCompositePass unless explicitly overridden. Defaults to 0.6. */
|
|
1420
|
+
readonly intensity?: number;
|
|
1421
|
+
/** Visibility exponent used by addCompositePass. Defaults to 1. */
|
|
1422
|
+
readonly power?: number;
|
|
1345
1423
|
readonly enabled?: boolean;
|
|
1346
1424
|
/** Resolution relative to the render target. Defaults to 1. */
|
|
1347
1425
|
readonly resolutionScale?: number;
|
|
@@ -1765,4 +1843,4 @@ declare class OutlineEffect {
|
|
|
1765
1843
|
dispose(): void;
|
|
1766
1844
|
}
|
|
1767
1845
|
|
|
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 };
|
|
1846
|
+
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 };
|