@hology/webgpu-renderer 0.1.8 → 0.1.9

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
@@ -616,8 +616,8 @@ interface VolumetricFogOptions {
616
616
  /** Temporal sub-froxel jitter accumulated by fog history and optionally TAA. */
617
617
  readonly temporalJitter?: boolean;
618
618
  /**
619
- * Fog-local temporal reconstruction. Unlike temporalJitter, this retains a
620
- * resolved fog history and permits cheaper current-frame sampling.
619
+ * Fog-local temporal reconstruction of the 3D scattering/extinction grid.
620
+ * This history is accumulated before front-to-back integration.
621
621
  */
622
622
  readonly temporal?: false | VolumetricFogTemporalOptions;
623
623
  /** Stable per-ray depth jitter. Breaks slice bands without animated noise. */
@@ -669,6 +669,8 @@ declare class VolumetricFogEffect {
669
669
  private scene;
670
670
  readonly integratedVolume: FrameGraphTextureHandle;
671
671
  readonly columnDepthBounds: FrameGraphTextureHandle;
672
+ readonly scatteringHistoryA: FrameGraphTextureHandle;
673
+ readonly scatteringHistoryB: FrameGraphTextureHandle;
672
674
  private readonly options;
673
675
  private readonly resources;
674
676
  private readonly uniformStorage;
@@ -695,6 +697,16 @@ declare class VolumetricFogEffect {
695
697
  private readonly projectionInverse;
696
698
  private readonly viewProjectionInverse;
697
699
  private readonly previousTemporalViewProjection;
700
+ private readonly previousFroxelViewProjection;
701
+ private readonly previousFroxelCameraPosition;
702
+ private previousFroxelNear;
703
+ private previousFroxelFar;
704
+ private previousFroxelWidth;
705
+ private previousFroxelHeight;
706
+ private froxelHistoryValid;
707
+ private froxelHistoryWriteIndex;
708
+ private activeHistoryRead;
709
+ private activeHistoryWrite;
698
710
  private explicitVolumes;
699
711
  private volumeObjects;
700
712
  private extractedLights;
@@ -735,7 +747,7 @@ declare class VolumetricFogEffect {
735
747
  private getResources;
736
748
  }
737
749
  /** WGSL appended to a material that calls rendererApplyVolumetricFog(). */
738
- declare const VOLUMETRIC_FOG_MATERIAL_WGSL = "\nfn rendererSampleIntegratedFog(uv: vec2<f32>, normalizedDepth: f32) -> vec4<f32> {\n let sliceCount = f32(textureDimensions(volumetricFogTexture).z);\n let slicePosition = clamp(normalizedDepth, 0.0, 1.0) * sliceCount;\n let textureZ = clamp((slicePosition - 0.5) / sliceCount, 0.0, 1.0);\n let integrated = textureSampleLevel(volumetricFogTexture, volumetricFogSampler, vec3<f32>(uv, textureZ), 0.0);\n // The volume stores slice endpoints but has no texel for the near-plane\n // identity value. Reconstruct that missing endpoint for the first slice.\n return mix(vec4<f32>(0.0, 0.0, 0.0, 1.0), integrated, min(slicePosition, 1.0));\n}\nfn rendererApplyVolumetricFog(color: vec4<f32>, worldPosition: vec3<f32>) -> vec4<f32> {\n let clip = rendererCamera.viewProj * vec4<f32>(worldPosition, 1.0);\n let uv = clip.xy / clip.w * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n let distance = length(worldPosition - rendererCamera.cameraPosition.xyz);\n let bounds = textureSampleLevel(volumetricFogBoundsTexture, volumetricFogBoundsSampler, uv, 0.0).rg;\n let z = clamp((distance - bounds.x) / max(bounds.y - bounds.x, 0.001), 0.0, 1.0);\n let fog = rendererSampleIntegratedFog(uv, z);\n return vec4<f32>(fog.rgb + color.rgb * fog.a, color.a);\n}";
750
+ declare const VOLUMETRIC_FOG_MATERIAL_WGSL = "\nfn rendererSampleIntegratedFogRaw(uv: vec2<f32>, normalizedDepth: f32) -> vec4<f32> {\n let sliceCount = f32(textureDimensions(volumetricFogTexture).z);\n let slicePosition = clamp(normalizedDepth, 0.0, 1.0) * sliceCount;\n let textureZ = clamp((slicePosition - 0.5) / sliceCount, 0.0, 1.0);\n let integrated = textureSampleLevel(volumetricFogTexture, volumetricFogSampler, vec3<f32>(uv, textureZ), 0.0);\n // The volume stores slice endpoints but has no texel for the near-plane\n // identity value. Reconstruct that missing endpoint for the first slice.\n return mix(vec4<f32>(0.0, 0.0, 0.0, 1.0), integrated, min(slicePosition, 1.0));\n}\nfn rendererSampleIntegratedFog(uv: vec2<f32>, normalizedDepth: f32) -> vec4<f32> {\n return rendererSampleIntegratedFogRaw(uv, normalizedDepth);\n}\nfn rendererApplyVolumetricFog(color: vec4<f32>, worldPosition: vec3<f32>) -> vec4<f32> {\n let clip = rendererCamera.viewProj * vec4<f32>(worldPosition, 1.0);\n let uv = clip.xy / clip.w * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n let distance = length(worldPosition - rendererCamera.cameraPosition.xyz);\n let bounds = textureSampleLevel(volumetricFogBoundsTexture, volumetricFogBoundsSampler, uv, 0.0).rg;\n let z = clamp(log(max(distance, bounds.x) / bounds.x) / max(log(bounds.y / bounds.x), 0.0001), 0.0, 1.0);\n let fog = rendererSampleIntegratedFog(uv, z);\n return vec4<f32>(fog.rgb + color.rgb * fog.a, color.a);\n}";
739
751
  /** Adds the froxel input; append VOLUMETRIC_FOG_MATERIAL_WGSL and call its helper in fsMain. */
740
752
  declare function configureVolumetricFogMaterial(material: WGSLShaderMaterial, resource?: string, boundsResource?: string): WGSLShaderMaterial;
741
753