@hology/webgpu-renderer 0.1.5 → 0.1.6

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
@@ -539,6 +539,15 @@ declare class FrameGraphBuilder {
539
539
  }
540
540
 
541
541
  type VolumetricFogScatteringMode = "volumetric" | "lightShaft";
542
+ type VolumetricFogQuality = "low" | "medium" | "high";
543
+ interface VolumetricFogTemporalOptions {
544
+ /** Previous-frame contribution for stable fog. Defaults to 0.92. */
545
+ readonly historyWeight?: number;
546
+ /** Relative view-depth difference that rejects history. Defaults to 0.04. */
547
+ readonly depthRejection?: number;
548
+ /** Clamp reprojected history to the current 3x3 fog neighborhood. */
549
+ readonly neighborhoodClamp?: boolean;
550
+ }
542
551
  /** Kept structurally compatible with Hology's legacy FogVolumeSettings. */
543
552
  interface VolumetricFogVolumeSettings {
544
553
  readonly object: Object3D;
@@ -559,6 +568,7 @@ declare class VolumetricFogVolumeObject extends Object3D {
559
568
  constructor(volume: VolumetricFogVolumeSettings);
560
569
  }
561
570
  interface VolumetricFogOptions {
571
+ readonly enabled?: boolean;
562
572
  /** Froxel width/height in pixels. 8 is a good desktop default. */
563
573
  readonly froxelPixelSize?: number;
564
574
  /** Logarithmically distributed depth slices. */
@@ -575,8 +585,13 @@ interface VolumetricFogOptions {
575
585
  readonly ambientColor?: Color;
576
586
  /** Rotating shadow taps per froxel. 4 removes block patterns at modest cost. */
577
587
  readonly shadowFilterTaps?: 1 | 4;
578
- /** Temporal sub-froxel jitter, intended to be accumulated by TAA. */
588
+ /** Temporal sub-froxel jitter accumulated by fog history and optionally TAA. */
579
589
  readonly temporalJitter?: boolean;
590
+ /**
591
+ * Fog-local temporal reconstruction. Unlike temporalJitter, this retains a
592
+ * resolved fog history and permits cheaper current-frame sampling.
593
+ */
594
+ readonly temporal?: false | VolumetricFogTemporalOptions;
580
595
  /** Stable per-ray depth jitter. Breaks slice bands without animated noise. */
581
596
  readonly spatialJitter?: boolean;
582
597
  /** Final fog-gradient dithering in approximate 8-bit code values. */
@@ -601,6 +616,8 @@ interface VolumetricFogBlurOptions {
601
616
  interface VolumetricFogInputs {
602
617
  readonly sceneColor: FrameGraphTextureHandle;
603
618
  readonly depth: FrameGraphTextureHandle;
619
+ /** Raw unjittered previous-to-current UV velocity from the opaque MRT. */
620
+ readonly velocity?: FrameGraphTextureHandle;
604
621
  /** Explicit volumes can be mixed with compatible scene marker objects. */
605
622
  readonly volumes?: readonly VolumetricFogVolumeSettings[];
606
623
  /**
@@ -614,6 +631,7 @@ interface VolumetricFogInputs {
614
631
  */
615
632
  readonly lights?: RendererExtractedLightState;
616
633
  }
634
+ declare const VOLUMETRIC_FOG_PRESETS: Readonly<Record<VolumetricFogQuality, VolumetricFogOptions>>;
617
635
  /**
618
636
  * Compute-driven froxel fog. Add it after opaque rendering and before the late
619
637
  * transparent pass. Existing content can use the composite output; transparent
@@ -632,20 +650,32 @@ declare class VolumetricFogEffect {
632
650
  private readonly lightData;
633
651
  private readonly projectionInverse;
634
652
  private readonly viewProjectionInverse;
653
+ private readonly previousTemporalViewProjection;
635
654
  private explicitVolumes;
636
655
  private volumeObjects;
637
656
  private extractedLights;
638
657
  private cascadeDirectionalLights;
639
658
  private compositePass;
640
659
  private readonly blurPassCache;
660
+ private readonly temporalPassCache;
661
+ private temporalWriteIndex;
662
+ private temporalHistoryValid;
663
+ private activeLastFrame;
641
664
  private frameIndex;
642
665
  constructor(scene?: Scene, options?: VolumetricFogOptions);
643
666
  /** Updates the scene traversed for compatible volumes and lights. */
644
667
  setScene(scene: Scene): void;
668
+ get enabled(): boolean;
669
+ setOptions(options: VolumetricFogOptions): void;
670
+ applyPreset(quality: VolumetricFogQuality): void;
671
+ reset(): void;
645
672
  /** Keeps CSM light data in the same near-to-far order as shadow-array layers. */
646
673
  setCascadedDirectionalLights(lights: readonly DirectionalLight[]): void;
647
674
  addPasses(graph: FrameGraphBuilder, inputs: VolumetricFogInputs): FrameGraphTextureHandle;
648
675
  private addBlurredComposite;
676
+ private addTemporalPass;
677
+ consumeTemporalHistoryValid(): boolean;
678
+ updateTemporalUniforms(uniforms: Float32Array, currentViewProjection: Matrix4, currentViewProjectionInverse: Matrix4, temporal: Required<VolumetricFogTemporalOptions>, context: RendererCustomPassContext): void;
649
679
  dispose(): void;
650
680
  private executeFroxels;
651
681
  private collectSceneData;
@@ -850,6 +880,14 @@ declare class WebGpuRenderer {
850
880
  private readonly projectionJitterPixels;
851
881
  private readonly temporalVisibilityCurrentViewProj;
852
882
  private readonly temporalVisibilityPreviousViewProj;
883
+ private readonly motionVectorProjection;
884
+ private readonly motionVectorCurrentViewProj;
885
+ private readonly motionVectorPreviousViewProj;
886
+ private motionVectorProjectionPending;
887
+ private motionVectorHistoryValid;
888
+ private motionVectorHistoryGeneration;
889
+ private lastMotionVectorTimeSeconds;
890
+ private readonly objectMotionHistory;
853
891
  private readonly cameraFrustumPlanesScratch;
854
892
  private readonly objectTraversalStackScratch;
855
893
  private readonly isSphereVisibleScratch;
@@ -899,6 +937,13 @@ declare class WebGpuRenderer {
899
937
  */
900
938
  setProjectionJitter(x: number, y: number): void;
901
939
  clearProjectionJitter(): void;
940
+ /**
941
+ * Supplies the unjittered projection used by motion vectors for the next
942
+ * render. The backend calls this before TAA temporarily jitters the camera.
943
+ */
944
+ setMotionVectorProjection(projection: Matrix4): void;
945
+ /** Suppresses object velocity for one frame without discarding GPU caches. */
946
+ invalidateObjectMotion(object: Object3D): void;
902
947
  getLastFrameProfile(): RendererFrameProfile | null;
903
948
  /**
904
949
  * Invalidates temporal data when this renderer starts presenting a
@@ -975,6 +1020,8 @@ declare class WebGpuRenderer {
975
1020
  */
976
1021
  private collectSprite;
977
1022
  private hasExtractedDirectionalLight;
1023
+ private getObjectMotionHistory;
1024
+ private commitObjectMotionHistory;
978
1025
  private collectMesh;
979
1026
  private prepareSceneForCompilation;
980
1027
  private collectInstancedMesh;
@@ -1126,11 +1173,22 @@ declare class WebGpuRenderer {
1126
1173
 
1127
1174
  interface GTAODenoiseOptions {
1128
1175
  readonly radius?: number;
1176
+ /** Fixed bilateral tap count. Normalized to 4, 8, 12, or 16. */
1177
+ readonly samples?: number;
1129
1178
  readonly depthPhi?: number;
1130
1179
  readonly normalPhi?: number;
1131
1180
  readonly lumaPhi?: number;
1132
1181
  }
1182
+ interface GTAOTemporalOptions {
1183
+ /** Previous-frame contribution for accepted history. Defaults to 0.9. */
1184
+ readonly historyWeight?: number;
1185
+ /** Relative linear view-depth rejection threshold. Defaults to 0.08. */
1186
+ readonly depthRejection?: number;
1187
+ /** Clamp history to the current AO cross-neighborhood. Defaults to true. */
1188
+ readonly neighborhoodClamp?: boolean;
1189
+ }
1133
1190
  interface GTAOOptions {
1191
+ readonly enabled?: boolean;
1134
1192
  /** Resolution relative to the render target. Defaults to 1. */
1135
1193
  readonly resolutionScale?: number;
1136
1194
  readonly radius?: number;
@@ -1142,28 +1200,43 @@ interface GTAOOptions {
1142
1200
  /** Space used by the encoded normal input. Defaults to world. */
1143
1201
  readonly normalSpace?: "world" | "view";
1144
1202
  readonly denoise?: false | GTAODenoiseOptions;
1203
+ /** Velocity-reprojected accumulation. Requires a velocity input. */
1204
+ readonly temporal?: false | GTAOTemporalOptions;
1145
1205
  readonly targetPrefix?: string;
1146
1206
  }
1147
1207
  interface GTAOInputs {
1148
1208
  readonly depth: FrameGraphTextureHandle;
1149
1209
  readonly normal: FrameGraphTextureHandle;
1210
+ readonly velocity?: FrameGraphTextureHandle;
1150
1211
  }
1151
1212
  interface GTAOCompositeOptions {
1152
1213
  readonly intensity?: number;
1153
1214
  readonly power?: number;
1154
1215
  readonly output?: FrameGraphTextureHandle;
1155
1216
  }
1156
- /** Reusable GTAO pass pair. The caller controls where AO is composited. */
1217
+ type GTAOQuality = "off" | "low" | "medium" | "high";
1218
+ declare const GTAO_PRESETS: Readonly<Record<GTAOQuality, Readonly<GTAOOptions>>>;
1219
+ /** Reusable GTAO pass chain. The caller controls where AO is composited. */
1157
1220
  declare class GTAOEffect {
1158
1221
  private readonly options;
1159
1222
  private readonly noiseTexture;
1160
1223
  private readonly gtaoPasses;
1224
+ private readonly temporalPasses;
1161
1225
  private readonly denoisePasses;
1162
1226
  private readonly compositePasses;
1227
+ private writeIndex;
1228
+ private frameIndex;
1229
+ private historyValid;
1163
1230
  constructor(options?: GTAOOptions);
1231
+ get enabled(): boolean;
1232
+ get temporalEnabled(): boolean;
1233
+ setOptions(options: GTAOOptions): void;
1234
+ applyPreset(quality: GTAOQuality): void;
1235
+ reset(): void;
1164
1236
  addPasses(graph: FrameGraphBuilder, inputs: GTAOInputs): FrameGraphTextureHandle;
1165
1237
  addCompositePass(graph: FrameGraphBuilder, sceneColor: FrameGraphTextureHandle, ambientOcclusion: FrameGraphTextureHandle, options?: GTAOCompositeOptions): FrameGraphTextureHandle;
1166
1238
  dispose(): void;
1239
+ consumeHistoryValid(): boolean;
1167
1240
  }
1168
1241
 
1169
1242
  interface SSROptions {
@@ -1218,7 +1291,7 @@ interface TemporalAAOptions {
1218
1291
  readonly targetPrefix?: string;
1219
1292
  }
1220
1293
  declare class TemporalAAEffect {
1221
- readonly renderScale: number;
1294
+ renderScale: number;
1222
1295
  private readonly sampleCount;
1223
1296
  private readonly minCurrentWeight;
1224
1297
  private readonly motionWeightScale;
@@ -1250,8 +1323,14 @@ declare class TemporalAAEffect {
1250
1323
  projectionMatrix: Matrix4;
1251
1324
  projectionMatrixInverse?: Matrix4;
1252
1325
  }): void;
1253
- addPass(graph: FrameGraphBuilder, currentColor: FrameGraphTextureHandle, currentDepth?: FrameGraphTextureHandle): FrameGraphTextureHandle;
1326
+ addPass(graph: FrameGraphBuilder, currentColor: FrameGraphTextureHandle, currentDepth?: FrameGraphTextureHandle, velocity?: FrameGraphTextureHandle): FrameGraphTextureHandle;
1254
1327
  reset(): void;
1328
+ /**
1329
+ * Updates the internal scene scale used to convert the presentation-space
1330
+ * jitter into internal-render pixels. TAA histories remain at presentation
1331
+ * resolution and therefore act as the temporal upscaling target.
1332
+ */
1333
+ setRenderScale(renderScale: number): void;
1255
1334
  private setSize;
1256
1335
  updateResolveUniforms(uniforms: Float32Array, currentViewProjection: Matrix4, currentViewProjectionInverse: Matrix4, context: RendererCustomPassContext): void;
1257
1336
  }
@@ -1400,6 +1479,93 @@ declare class DepthOfFieldEffect {
1400
1479
  addPass(graph: FrameGraphBuilder, source: FrameGraphTextureHandle, depth: FrameGraphTextureHandle): FrameGraphTextureHandle;
1401
1480
  }
1402
1481
 
1482
+ declare enum MotionBlurMode {
1483
+ Disabled = 0,
1484
+ CameraOnly = 1,
1485
+ ObjectAndCamera = 2,
1486
+ ForceObjectBlur = 3
1487
+ }
1488
+ type MotionBlurQuality = "off" | "low" | "medium" | "high";
1489
+ interface MotionBlurOptions {
1490
+ enabled?: boolean;
1491
+ sampleCount?: number;
1492
+ shutterScale?: number;
1493
+ maxBlurPixels?: number;
1494
+ cameraBlurScale?: number;
1495
+ objectBlurScale?: number;
1496
+ depthRejectionStrength?: number;
1497
+ velocityThresholdPixels?: number;
1498
+ dilation?: boolean;
1499
+ debugVelocity?: boolean;
1500
+ targetFrameRate?: number;
1501
+ maxFrameTime?: number;
1502
+ cameraCutDistance?: number;
1503
+ cameraCutRotationThreshold?: number;
1504
+ projectionCutThreshold?: number;
1505
+ targetPrefix?: string;
1506
+ }
1507
+ interface MotionBlurOverride extends Partial<MotionBlurOptions> {
1508
+ duration: number;
1509
+ }
1510
+ interface MotionBlurOverrideHandle {
1511
+ readonly id: number;
1512
+ cancel(): void;
1513
+ }
1514
+ declare const MOTION_BLUR_PRESETS: Readonly<Record<MotionBlurQuality, Readonly<MotionBlurOptions>>>;
1515
+ /**
1516
+ * HDR, depth-aware motion-blur resolve.
1517
+ *
1518
+ * Velocity convention:
1519
+ * - RG points from the previous position to the current position.
1520
+ * - Units are texture UV displacement per rendered frame.
1521
+ * - Y is texture-space down; the node compiler flips WebGPU's Y-up NDC.
1522
+ * - Current/previous matrices are unjittered, so TAA jitter is excluded.
1523
+ * - B stores MotionBlurMode and A stores the authored object scale.
1524
+ */
1525
+ declare class MotionBlurEffect {
1526
+ readonly options: Required<Omit<MotionBlurOptions, "targetPrefix">>;
1527
+ private readonly targetPrefix;
1528
+ private readonly currentViewProjection;
1529
+ private readonly currentInverseViewProjection;
1530
+ private readonly currentInverseProjection;
1531
+ private readonly previousViewProjection;
1532
+ private readonly pendingViewProjection;
1533
+ private readonly previousProjection;
1534
+ private readonly previousCameraWorld;
1535
+ private readonly previousCameraPosition;
1536
+ private readonly currentCameraPosition;
1537
+ private readonly currentJitterUv;
1538
+ private historyValid;
1539
+ private pendingCamera;
1540
+ private width;
1541
+ private height;
1542
+ private timeSeconds;
1543
+ private frameDuration;
1544
+ private previousTimeSeconds;
1545
+ private nextOverrideId;
1546
+ private readonly overrides;
1547
+ private readonly passes;
1548
+ constructor(options?: MotionBlurOptions);
1549
+ applyPreset(quality: MotionBlurQuality): void;
1550
+ prepareCamera(camera: PerspectiveCamera | OrthographicCamera, width: number, height: number, timeSeconds: number): void;
1551
+ commitCamera(): void;
1552
+ setJitterUv(x: number, y: number): void;
1553
+ reset(): void;
1554
+ requiresRendererHistoryReset(): boolean;
1555
+ pushOverride(override: MotionBlurOverride): MotionBlurOverrideHandle;
1556
+ addPass(graph: FrameGraphBuilder, sceneColor: FrameGraphTextureHandle, velocity: FrameGraphTextureHandle, depth?: FrameGraphTextureHandle): FrameGraphTextureHandle;
1557
+ dispose(): void;
1558
+ getTemporalMatrices(): {
1559
+ readonly currentInverseViewProjection: Matrix4;
1560
+ readonly currentInverseProjection: Matrix4;
1561
+ readonly previousViewProjection: Matrix4;
1562
+ };
1563
+ getFrameDuration(): number;
1564
+ getJitterUv(): Vector2;
1565
+ private pruneOverrides;
1566
+ private getResolvedSettings;
1567
+ }
1568
+
1403
1569
  interface OutlineOptions {
1404
1570
  readonly enabled?: boolean;
1405
1571
  readonly visibleEdgeColor?: readonly [number, number, number];
@@ -1441,4 +1607,4 @@ declare class OutlineEffect {
1441
1607
  dispose(): void;
1442
1608
  }
1443
1609
 
1444
- 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 };
1610
+ 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, 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, 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, configureVolumetricFogMaterial };