@hology/webgpu-renderer 0.1.21 → 0.1.23

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/index.d.ts CHANGED
@@ -32,6 +32,14 @@ interface ResolvedDetailCulling {
32
32
  declare function setObjectDetailCulling(object: Object3D, settings: DetailCullingSettings): void;
33
33
  declare function resolveDetailCulling(object: Object3D | null, registration?: DetailCullingSettings): ResolvedDetailCulling;
34
34
 
35
+ interface StaticSpatialObject {
36
+ /** Refresh after geometry, inherited transforms, or detail policy changes. */
37
+ update(): void;
38
+ /** Edited objects temporarily return to ordinary scene traversal. */
39
+ setEditing(editing: boolean): void;
40
+ dispose(): void;
41
+ }
42
+
35
43
  type ShaderDefineValue = string | number | boolean;
36
44
  type ShaderDefines = Record<string, ShaderDefineValue | null | undefined>;
37
45
 
@@ -120,6 +128,8 @@ declare class WGSLShaderMaterial extends Material {
120
128
  wireframe: boolean;
121
129
  private uniformLayoutCache;
122
130
  private programCacheKeyCache;
131
+ private depthProgramCacheKeyCache;
132
+ private pointShadowProgramCacheKeyCache;
123
133
  private textureListCache;
124
134
  private textureVersionsCache;
125
135
  private textureVersionHashCache;
@@ -152,6 +162,9 @@ declare class WGSLShaderMaterial extends Material {
152
162
  /** Three's default clone path cannot call this material's required constructor. */
153
163
  clone(): this;
154
164
  customProgramCacheKey(): string;
165
+ /** Depth passes can share pipelines despite differences in unused forward shading. */
166
+ getDepthProgramCacheKey(pointShadow?: boolean): string;
167
+ private createProgramCacheKey;
155
168
  getTexturesList(): readonly Texture[];
156
169
  usesSceneTextures(): boolean;
157
170
  usesSceneColor(): boolean;
@@ -342,6 +355,34 @@ interface RendererMaterialPassDescriptor {
342
355
  /** Replace each accepted draw's material while preserving its geometry and instance data. */
343
356
  readonly overrideMaterial?: WGSLShaderMaterial | ((source: WGSLShaderMaterial, skinned: boolean) => WGSLShaderMaterial);
344
357
  }
358
+ interface RendererSceneCaptureOptions {
359
+ /** Exclude objects/subtrees. Static snapshots without a source object pass null. */
360
+ readonly objectFilter?: (object: Object3D | null) => boolean;
361
+ readonly clearColor?: readonly [number, number, number, number];
362
+ /** Defaults to true. Disable point and spot lights for a consistent map view. */
363
+ readonly includeLocalLights?: boolean;
364
+ /** Optional final pass. Must write display-sRGB color into targetView. */
365
+ readonly postProcess?: (context: RendererSceneCapturePostProcessContext) => void;
366
+ }
367
+ interface RendererSceneCapturePostProcessContext {
368
+ readonly device: GPUDevice;
369
+ readonly encoder: GPUCommandEncoder;
370
+ readonly colorView: GPUTextureView;
371
+ readonly depthView: GPUTextureView;
372
+ readonly sampler: GPUSampler;
373
+ readonly targetView: GPUTextureView;
374
+ readonly targetFormat: GPUTextureFormat;
375
+ readonly width: number;
376
+ readonly height: number;
377
+ readonly camera: PerspectiveCamera | OrthographicCamera;
378
+ }
379
+ /** Non-temporal, unshadowed scene view sharing the renderer's GPU resources. */
380
+ interface RendererSceneCapture {
381
+ /** Persistent display-space output when created without a canvas. Owned by the capture. */
382
+ readonly textureView?: GPUTextureView;
383
+ capture(scene: three.Scene, camera: PerspectiveCamera | OrthographicCamera, options?: RendererSceneCaptureOptions): void;
384
+ dispose(): void;
385
+ }
345
386
  interface RendererShadowMapDebugTextureInfo {
346
387
  readonly view: GPUTextureView | null;
347
388
  readonly size: number;
@@ -432,6 +473,12 @@ interface RendererFrameProfile {
432
473
  gpuIndirectDraws?: number;
433
474
  };
434
475
  frameIndex: number;
476
+ /** Internal scene attachment dimensions in physical pixels. */
477
+ renderWidth?: number;
478
+ renderHeight?: number;
479
+ /** Presentation dimensions before any internal resolution scaling. */
480
+ presentationWidth?: number;
481
+ presentationHeight?: number;
435
482
  cpuTimeMs: number;
436
483
  gpuTimeMs: number | null;
437
484
  drawCallCount: number;
@@ -914,11 +961,14 @@ declare class WebGpuRenderer {
914
961
  private sampleCount;
915
962
  private renderScale;
916
963
  private hiZOcclusionCullingEnabled;
964
+ private frameHiZOcclusionCullingNeeded;
917
965
  private multiDrawIndirectEnabled;
918
966
  private dynamicBatchingEnabled;
919
967
  private multiDrawIndirectSupported;
920
968
  private tiledPointLights;
921
969
  private tiledLightingEnabled;
970
+ private readonly transientPointLightsScratch;
971
+ private readonly transientPointScoresScratch;
922
972
  private renderGraphProfilingEnabled;
923
973
  private indirectFirstInstanceSupported;
924
974
  private timestampQuerySupported;
@@ -983,7 +1033,7 @@ declare class WebGpuRenderer {
983
1033
  * `instance_index`. Keep shared default buffers large enough for the packed
984
1034
  * renderer instance range instead of binding one value at index zero.
985
1035
  */
986
- private readonly defaultInstanceAttributeBuffers;
1036
+ private readonly defaultVertexAttributeBuffers;
987
1037
  private readonly textureManager;
988
1038
  private readonly renderGraph;
989
1039
  private readonly nativePostSubmit;
@@ -1013,6 +1063,7 @@ declare class WebGpuRenderer {
1013
1063
  private readonly geometryVertexBufferFastCache;
1014
1064
  private readonly vertexAttributeGroupCache;
1015
1065
  private readonly materialVertexAttributeCache;
1066
+ private readonly sharedVertexAttributeLayouts;
1016
1067
  private readonly vertexBufferBindingPlanCache;
1017
1068
  private readonly preparedVertexBufferCache;
1018
1069
  private readonly vertexAttributeGroupBufferKeyCache;
@@ -1089,6 +1140,23 @@ declare class WebGpuRenderer {
1089
1140
  private readonly objectMotionHistory;
1090
1141
  private readonly cameraFrustumPlanesScratch;
1091
1142
  private readonly objectTraversalStackScratch;
1143
+ private readonly staticSceneSpatialIndex;
1144
+ private readonly staticMeshDraws;
1145
+ private readonly spatialShadowPlanes;
1146
+ private spatialShadowCount;
1147
+ private readonly spatialLocalShadowSpheres;
1148
+ private spatialLocalShadowCount;
1149
+ private readonly spatialShadowMatrix;
1150
+ private spatialIncludeOffscreen;
1151
+ private spatialCameraLayers;
1152
+ private readonly testSpatialCamera;
1153
+ private readonly testSpatialScene;
1154
+ private readonly filterSpatialCaptureObject;
1155
+ private readonly pushSpatialRoot;
1156
+ private readonly collectSpatialMesh;
1157
+ private readonly isSpatialSphereVisible;
1158
+ private isSpatialShadowSphereVisible;
1159
+ private readonly collectSpatialRoot;
1092
1160
  private readonly shadowDrawsScratch;
1093
1161
  private extractingCaster;
1094
1162
  private readonly cameraDetailHistory;
@@ -1101,6 +1169,10 @@ declare class WebGpuRenderer {
1101
1169
  private readonly temporalVisibilityPreviousCameraPosition;
1102
1170
  private readonly shadowViewProjScratch;
1103
1171
  private extractionVersion;
1172
+ private motionHistoryExtractionVersion;
1173
+ private sceneCaptureOptions;
1174
+ private readonly sceneCaptureDisposers;
1175
+ private readonly captureMotionHistory;
1104
1176
  private graphBuilder;
1105
1177
  private createExtractedDirectionalLightScratch;
1106
1178
  private createExtractedHemisphereLightScratch;
@@ -1174,6 +1246,11 @@ declare class WebGpuRenderer {
1174
1246
  setHiZOcclusionCullingEnabled(enabled: boolean): void;
1175
1247
  getHiZOcclusionCullingEnabled(): boolean;
1176
1248
  getHiZOcclusionCullingActive(): boolean;
1249
+ /** Captures and shadow views must not inherit the primary camera's culling. */
1250
+ private isStaticDrawSetCameraVisible;
1251
+ private getCameraStaticDrawSets;
1252
+ private queryStaticShadowResources;
1253
+ private updateVisibilityWorkload;
1177
1254
  setMultiDrawIndirectEnabled(enabled: boolean): void;
1178
1255
  getMultiDrawIndirectEnabled(): boolean;
1179
1256
  /** Toggle without recompiling materials, for scene-specific GPU comparisons. */
@@ -1186,6 +1263,12 @@ declare class WebGpuRenderer {
1186
1263
  setClearColor(color: readonly [number, number, number, number]): void;
1187
1264
  render(scene: Scene, camera: PerspectiveCamera | OrthographicCamera, timeSeconds?: number): void;
1188
1265
  renderAsync(scene: Scene, camera: PerspectiveCamera | OrthographicCamera, timeSeconds?: number): Promise<void>;
1266
+ /**
1267
+ * Creates an independent canvas or sampleable texture view on the same device.
1268
+ * Call capture between frames, before render(): it reuses extraction scratch and
1269
+ * upload buffers, but never advances gameplay motion/visibility history.
1270
+ */
1271
+ createSceneCapture(canvas: HTMLCanvasElement | null, width?: number, height?: number): RendererSceneCapture;
1189
1272
  compile(scene: Scene, camera: PerspectiveCamera | OrthographicCamera): void;
1190
1273
  compileAsync(scene: Scene, camera: PerspectiveCamera | OrthographicCamera): Promise<void>;
1191
1274
  /**
@@ -1203,6 +1286,8 @@ declare class WebGpuRenderer {
1203
1286
  */
1204
1287
  initTexture(texture: Texture): void;
1205
1288
  createStaticDrawSet(root: Object3D, options?: StaticDrawSetOptions): StaticDrawSet;
1289
+ /** Register immutable ordinary meshes without changing their authored parents. */
1290
+ registerStaticSpatialObject(root: Object3D): StaticSpatialObject;
1206
1291
  private disposeStaticDrawSetResource;
1207
1292
  private renderFrame;
1208
1293
  private recordPresentationOverlay;
@@ -1227,6 +1312,7 @@ declare class WebGpuRenderer {
1227
1312
  private transparentDraws;
1228
1313
  private opaqueBatches;
1229
1314
  private acquireDrawCall;
1315
+ private createDrawCall;
1230
1316
  private acquireOpaqueBatchBuilder;
1231
1317
  private populateDrawCall;
1232
1318
  private populateDynamicDrawCall;
@@ -1236,6 +1322,9 @@ declare class WebGpuRenderer {
1236
1322
  private getToonOutlineMaterial;
1237
1323
  private pushToonOutlineDraw;
1238
1324
  private updateTransparentDrawSortDepths;
1325
+ /** Bounded importance selection; stable light IDs break exact ties. */
1326
+ private selectTransientPointLight;
1327
+ private extractPointLight;
1239
1328
  private extractScene;
1240
1329
  private collectLine;
1241
1330
  /**
@@ -1332,6 +1421,7 @@ declare class WebGpuRenderer {
1332
1421
  private getGeometryAttributeBufferKey;
1333
1422
  private getGeometryAttributeGroupBufferKey;
1334
1423
  private getMaterialVertexAttributes;
1424
+ private getSharedVertexAttributeLayout;
1335
1425
  private getGeometryVertexBuffer;
1336
1426
  private cacheGeometryVertexBufferFast;
1337
1427
  private readonly packedVertexGroups;
@@ -1341,7 +1431,7 @@ declare class WebGpuRenderer {
1341
1431
  private prepareGeometryVertexBuffers;
1342
1432
  private getStandardVertexAttribute;
1343
1433
  private prepareDrawGeometryVertexBuffers;
1344
- private getDefaultInstanceAttributeBuffer;
1434
+ private getDefaultVertexAttributeBuffer;
1345
1435
  private getMeshExtractionCacheEntry;
1346
1436
  private getInstancedMeshExtractionCacheEntry;
1347
1437
  private getBatchedMeshExtractionCacheEntry;
@@ -1837,6 +1927,8 @@ declare class OutlineEffect {
1837
1927
  edgeThickness: number;
1838
1928
  edgeSoftness: number;
1839
1929
  readonly selectedObjects: Set<Object3D<three.Object3DEventMap>>;
1930
+ private readonly selectionMembers;
1931
+ private readonly addSelectionMember;
1840
1932
  readonly selectedInstances: OutlineInstanceSelection[];
1841
1933
  private readonly targetPrefix;
1842
1934
  private readonly maskMaterial;
@@ -1851,4 +1943,4 @@ declare class OutlineEffect {
1851
1943
  dispose(): void;
1852
1944
  }
1853
1945
 
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 };
1946
+ 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 RendererSceneCapture, type RendererSceneCaptureOptions, type RendererSceneCapturePostProcessContext, 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, type StaticSpatialObject, 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 };