@hology/webgpu-renderer 0.1.2 → 0.1.4

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
@@ -78,6 +78,8 @@ interface WGSLShaderMaterialParameters extends MaterialParameters {
78
78
  storageBuffers?: Record<string, WGSLStorageBufferBinding>;
79
79
  vertexAttributes?: readonly WGSLVertexAttributeBinding[];
80
80
  primitiveTopology?: GPUPrimitiveTopology;
81
+ /** Hash mutable uniform values on every renderer update. */
82
+ uniformValuesAutoUpdate?: boolean;
81
83
  /** Render triangle meshes as one-pixel triangle edges, matching Three.js wireframe materials. */
82
84
  wireframe?: boolean;
83
85
  }
@@ -108,6 +110,19 @@ declare class WGSLShaderMaterial extends Material {
108
110
  private storageBufferListCache;
109
111
  private textureLayoutKeyDeviceCache;
110
112
  private textureLayoutKeyCache;
113
+ /**
114
+ * Whether the renderer should hash mutable uniform values while rendering.
115
+ * Disable this for materials whose uniform changes are explicitly invalidated
116
+ * through `uniformValuesNeedsUpdate`.
117
+ */
118
+ uniformValuesAutoUpdate: boolean;
119
+ /**
120
+ * Incremented by setting uniformValuesNeedsUpdate to true.
121
+ * Each renderer resource keeps its own observed version, so one invalidation
122
+ * safely updates forward, depth, shadow, and other material variants.
123
+ */
124
+ uniformValuesAutoVersion: number;
125
+ set uniformValuesNeedsUpdate(value: boolean);
111
126
  constructor(parameters: WGSLShaderMaterialParameters);
112
127
  getUniformLayout(): UniformLayout;
113
128
  setUniform(name: string, definition: WGSLShaderMaterialUniformInput): this;
@@ -211,6 +226,11 @@ interface StaticDrawSet {
211
226
  dispose(): void;
212
227
  }
213
228
  interface RendererGraphBuilderContext {
229
+ /**
230
+ * Visible fog-volume marker objects collected during ordinary scene
231
+ * extraction. Passing this list to volumetric fog avoids another scene walk.
232
+ */
233
+ readonly fogVolumeObjects: readonly Object3D[];
214
234
  addDirectionalShadowPass(): void;
215
235
  addPointShadowPass(): void;
216
236
  addSpotShadowPass(): void;
@@ -487,6 +507,11 @@ interface VolumetricFogInputs {
487
507
  readonly depth: FrameGraphTextureHandle;
488
508
  /** Explicit volumes can be mixed with compatible scene marker objects. */
489
509
  readonly volumes?: readonly VolumetricFogVolumeSettings[];
510
+ /**
511
+ * Fog marker objects already collected by the renderer. When supplied, this
512
+ * list is authoritative and avoids traversing the scene for volumes.
513
+ */
514
+ readonly volumeObjects?: readonly Object3D[];
490
515
  }
491
516
  /**
492
517
  * Compute-driven froxel fog. Add it after opaque rendering and before the late
@@ -507,6 +532,7 @@ declare class VolumetricFogEffect {
507
532
  private readonly projectionInverse;
508
533
  private readonly viewProjectionInverse;
509
534
  private explicitVolumes;
535
+ private volumeObjects;
510
536
  private cascadeDirectionalLights;
511
537
  private compositePass;
512
538
  private readonly blurPassCache;
@@ -640,6 +666,12 @@ declare class WebGpuRenderer {
640
666
  /** Fast variants for MRT/non-default target format combinations. */
641
667
  private readonly forwardMaterialTargetFastCache;
642
668
  private readonly forwardMaterialFrameCache;
669
+ /**
670
+ * DrawCall objects are pooled and many draws share one MaterialResource.
671
+ * Once a resource has passed its structural/material/texture checks in an
672
+ * extraction, avoid repeating texture-list scans for every matching draw.
673
+ */
674
+ private readonly drawMaterialResourceFrameValidation;
643
675
  private readonly depthMaterialFastCache;
644
676
  private readonly sharedForwardPipelineCache;
645
677
  private readonly sharedForwardPipelinePromiseCache;
@@ -679,7 +711,13 @@ declare class WebGpuRenderer {
679
711
  private readonly vertexAttributeGroupCache;
680
712
  private readonly vertexAttributeGroupBufferKeyCache;
681
713
  private readonly compileDrawScratch;
682
- private readonly indirectSubmissionStreamsScratch;
714
+ private readonly dynamicIndirectSubmissionCache;
715
+ private readonly indirectStreamKeyCache;
716
+ private nextIndirectStreamKey;
717
+ private indirectBundleInvalidationVersion;
718
+ private readonly colorFormatsIdentityCache;
719
+ private readonly colorFormatsValueCache;
720
+ private nextColorFormatsId;
683
721
  private readonly renderBundleScratch;
684
722
  private readonly directBundleDrawStatsScratch;
685
723
  private readonly sortedOpaqueBatchesScratch;
@@ -706,6 +744,7 @@ declare class WebGpuRenderer {
706
744
  private readonly activeDirectionalLightsScratch;
707
745
  private readonly activePointLightsScratch;
708
746
  private readonly activeSpotLightsScratch;
747
+ private readonly fogVolumeObjectsScratch;
709
748
  private readonly resolvedMeshMaterialsScratch;
710
749
  private readonly extractedLightsScratch;
711
750
  private readonly extractedFrameScratch;
@@ -866,8 +905,12 @@ declare class WebGpuRenderer {
866
905
  private getShadowCameraBuffer;
867
906
  private getSharedShadowBindGroupForCameraBuffer;
868
907
  private buildIndirectSubmissionStreams;
908
+ private getIndirectStreamKey;
869
909
  private getOrCreateStaticIndirectSubmissionStreams;
870
910
  private getOrCreateIndirectForwardBundle;
911
+ private setRetainedIndirectBundleState;
912
+ private getIndirectBundleHash;
913
+ private getColorFormatsId;
871
914
  private getDirectForwardBundleKey;
872
915
  private getOrCreateDirectForwardBundle;
873
916
  private getOrCreateStaticMaterialBundle;
@@ -1145,6 +1188,49 @@ declare class FXAAEffect {
1145
1188
  addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, options?: FXAACompositeOptions): FrameGraphTextureHandle;
1146
1189
  }
1147
1190
 
1191
+ type SMAAQualityPreset = "low" | "medium" | "high" | "ultra";
1192
+ type SMAAEdgeDetectionMode = "luma" | "color";
1193
+ interface SMAAOptions {
1194
+ /** Pattern-search budget. Defaults to `high` (16 orthogonal and 8 diagonal steps). */
1195
+ readonly quality?: SMAAQualityPreset;
1196
+ /** Perceptual edge threshold. Defaults to 0.08, which retains dark toon outlines. */
1197
+ readonly threshold?: number;
1198
+ /** Rejects edges weak relative to their neighborhood. Defaults to 0.5. */
1199
+ readonly localContrastAdaptation?: number;
1200
+ /** Luma is fastest; color retains isoluminant stylized edges. Defaults to `color`. */
1201
+ readonly edgeDetection?: SMAAEdgeDetectionMode;
1202
+ /** Corner rounding from 0 (preserve) to 1 (round). Defaults to 0.25. */
1203
+ readonly cornerRounding?: number;
1204
+ /** Optional contrast-adaptive sharpening, from 0 to 1. Defaults to 0. */
1205
+ readonly sharpness?: number;
1206
+ readonly targetPrefix?: string;
1207
+ }
1208
+ interface SMAACompositeOptions {
1209
+ readonly output?: FrameGraphTextureHandle;
1210
+ }
1211
+ /**
1212
+ * SMAA 1x with local contrast adaptation, accurate area classification,
1213
+ * diagonal detection, corner preservation, and optional fused sharpening.
1214
+ */
1215
+ declare class SMAAEffect {
1216
+ threshold: number;
1217
+ localContrastAdaptation: number;
1218
+ edgeDetection: SMAAEdgeDetectionMode;
1219
+ cornerRounding: number;
1220
+ sharpness: number;
1221
+ private readonly quality;
1222
+ private readonly targetPrefix;
1223
+ private readonly areaTexture;
1224
+ private readonly edgePasses;
1225
+ private readonly weightPasses;
1226
+ private readonly blendPasses;
1227
+ constructor(options?: SMAAOptions);
1228
+ addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, options?: SMAACompositeOptions): FrameGraphTextureHandle;
1229
+ dispose(): void;
1230
+ get searchSteps(): number;
1231
+ get diagonalSteps(): number;
1232
+ }
1233
+
1148
1234
  interface BloomOptions {
1149
1235
  /** Overall bloom contribution. Defaults to 0.9. */
1150
1236
  readonly strength?: number;
@@ -1264,4 +1350,4 @@ declare class OutlineEffect {
1264
1350
  dispose(): void;
1265
1351
  }
1266
1352
 
1267
- 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, OutlineEffect, type OutlineInputs, type OutlineInstanceSelection, type OutlineOptions, 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, 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, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogScatteringMode, 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, configureVolumetricFogMaterial };
1353
+ 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, OutlineEffect, type OutlineInputs, type OutlineInstanceSelection, type OutlineOptions, 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, 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, type VolumetricFogBlurOptions, VolumetricFogEffect, type VolumetricFogInputs, type VolumetricFogOptions, type VolumetricFogScatteringMode, 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, configureVolumetricFogMaterial };