@luma.gl/engine 10.0.0-beta.4 → 10.0.0-rc.2
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/THIRD-PARTY-NOTICES.md +82 -0
- package/dist/animation/animation-track.d.ts +7 -0
- package/dist/animation/animation-track.d.ts.map +1 -1
- package/dist/animation/animation-track.js.map +1 -1
- package/dist/animation/node-animation-binding.cjs +1 -0
- package/dist/animation/node-animation-binding.d.ts +2 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +6 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/animation/scenegraph-gpu-animation-layout.cjs +99 -0
- package/dist/animation/scenegraph-gpu-animation-layout.d.ts +69 -0
- package/dist/animation/scenegraph-gpu-animation-layout.d.ts.map +1 -0
- package/dist/animation/scenegraph-gpu-animation-layout.js +90 -0
- package/dist/animation/scenegraph-gpu-animation-layout.js.map +1 -0
- package/dist/animation/scenegraph-gpu-animation.cjs +281 -0
- package/dist/animation/scenegraph-gpu-animation.d.ts +54 -0
- package/dist/animation/scenegraph-gpu-animation.d.ts.map +1 -0
- package/dist/animation/scenegraph-gpu-animation.js +274 -0
- package/dist/animation/scenegraph-gpu-animation.js.map +1 -0
- package/dist/arrow/arrow-picking.cjs +4 -3
- package/dist/arrow/arrow-picking.d.ts +15 -5
- package/dist/arrow/arrow-picking.d.ts.map +1 -1
- package/dist/arrow/arrow-picking.js +16 -5
- package/dist/arrow/arrow-picking.js.map +1 -1
- package/dist/arrow/index.cjs.map +1 -1
- package/dist/audio/audio-controller.cjs +6 -2
- package/dist/audio/audio-controller.d.ts.map +1 -1
- package/dist/audio/audio-controller.js +6 -2
- package/dist/audio/audio-controller.js.map +1 -1
- package/dist/audio/audio-graph.cjs +26 -2
- package/dist/audio/audio-graph.d.ts +9 -0
- package/dist/audio/audio-graph.d.ts.map +1 -1
- package/dist/audio/audio-graph.js +35 -10
- package/dist/audio/audio-graph.js.map +1 -1
- package/dist/dist.dev.js +1689 -1094
- package/dist/dist.min.js +69 -70
- package/dist/effects/glfx-effects.cjs +261 -0
- package/dist/effects/glfx-effects.d.ts +959 -0
- package/dist/effects/glfx-effects.d.ts.map +1 -0
- package/dist/effects/glfx-effects.js +200 -0
- package/dist/effects/glfx-effects.js.map +1 -0
- package/dist/effects/graph/gpu-effect-operation.cjs +402 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts +101 -0
- package/dist/effects/graph/gpu-effect-operation.d.ts.map +1 -0
- package/dist/effects/graph/gpu-effect-operation.js +410 -0
- package/dist/effects/graph/gpu-effect-operation.js.map +1 -0
- package/dist/effects/graph/temporal-graph-history.cjs +48 -0
- package/dist/effects/graph/temporal-graph-history.d.ts +17 -0
- package/dist/effects/graph/temporal-graph-history.d.ts.map +1 -0
- package/dist/effects/graph/temporal-graph-history.js +30 -0
- package/dist/effects/graph/temporal-graph-history.js.map +1 -0
- package/dist/effects/index.cjs +117 -30
- package/dist/effects/index.cjs.map +3 -3
- package/dist/effects/index.d.ts +34 -18
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/index.js +31 -18
- package/dist/effects/index.js.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.cjs +9 -2
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts +19 -0
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js +6 -0
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.cjs +9 -2
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts +41 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js +6 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/tone-mapping.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.cjs +200 -13
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts +992 -6
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js +199 -10
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts +3 -3
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.js.map +1 -1
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.cjs +41 -40
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +116 -8
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js +38 -37
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.js.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.cjs +83 -66
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +470 -2
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js +80 -62
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.js.map +1 -1
- package/dist/effects/passes/screen-space/copy-pass.cjs +7 -0
- package/dist/effects/passes/screen-space/copy-pass.d.ts +1 -0
- package/dist/effects/passes/screen-space/copy-pass.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/copy-pass.js +4 -0
- package/dist/effects/passes/screen-space/copy-pass.js.map +1 -1
- package/dist/effects/passes/screen-space/depth-aware-blur.cjs +14 -5
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts +125 -17
- package/dist/effects/passes/screen-space/depth-aware-blur.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/depth-aware-blur.js +11 -3
- package/dist/effects/passes/screen-space/depth-aware-blur.js.map +1 -1
- package/dist/effects/passes/screen-space/dof.cjs +19 -3
- package/dist/effects/passes/screen-space/dof.d.ts +181 -0
- package/dist/effects/passes/screen-space/dof.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/dof.js +17 -3
- package/dist/effects/passes/screen-space/dof.js.map +1 -1
- package/dist/effects/passes/screen-space/gtao.cjs +82 -62
- package/dist/effects/passes/screen-space/gtao.d.ts +608 -3
- package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.js +83 -60
- package/dist/effects/passes/screen-space/gtao.js.map +1 -1
- package/dist/effects/passes/screen-space/hdr-auto-exposure.cjs +103 -79
- package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts +225 -3
- package/dist/effects/passes/screen-space/hdr-auto-exposure.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/hdr-auto-exposure.js +102 -77
- package/dist/effects/passes/screen-space/hdr-auto-exposure.js.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.cjs +14 -0
- package/dist/effects/passes/screen-space/height-fog.d.ts +71 -0
- package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.js +16 -3
- package/dist/effects/passes/screen-space/height-fog.js.map +1 -1
- package/dist/effects/passes/screen-space/motion-blur.cjs +7 -8
- package/dist/effects/passes/screen-space/motion-blur.d.ts +41 -2
- package/dist/effects/passes/screen-space/motion-blur.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/motion-blur.js +6 -6
- package/dist/effects/passes/screen-space/motion-blur.js.map +1 -1
- package/dist/effects/passes/screen-space/outlines.cjs +143 -18
- package/dist/effects/passes/screen-space/outlines.d.ts +162 -3
- package/dist/effects/passes/screen-space/outlines.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/outlines.js +137 -15
- package/dist/effects/passes/screen-space/outlines.js.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.cjs +70 -61
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +309 -2
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.js +69 -59
- package/dist/effects/passes/screen-space/screen-space-global-illumination.js.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.cjs +151 -83
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +778 -7
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.js +148 -79
- package/dist/effects/passes/screen-space/screen-space-reflections.js.map +1 -1
- package/dist/effects/passes/screen-space/selection-outline.cjs +12 -2
- package/dist/effects/passes/screen-space/selection-outline.d.ts +44 -0
- package/dist/effects/passes/screen-space/selection-outline.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/selection-outline.js +9 -0
- package/dist/effects/passes/screen-space/selection-outline.js.map +1 -1
- package/dist/effects/passes/screen-space/ssao.cjs +69 -44
- package/dist/effects/passes/screen-space/ssao.d.ts +648 -3
- package/dist/effects/passes/screen-space/ssao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/ssao.js +67 -42
- package/dist/effects/passes/screen-space/ssao.js.map +1 -1
- package/dist/effects/passes/screen-space/temporal-antialiasing.cjs +42 -30
- package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts +107 -6
- package/dist/effects/passes/screen-space/temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/temporal-antialiasing.js +40 -27
- package/dist/effects/passes/screen-space/temporal-antialiasing.js.map +1 -1
- package/dist/effects/passes/screen-space/temporal-frame.cjs +34 -0
- package/dist/effects/passes/screen-space/temporal-frame.d.ts +23 -0
- package/dist/effects/passes/screen-space/temporal-frame.d.ts.map +1 -0
- package/dist/effects/passes/screen-space/temporal-frame.js +16 -0
- package/dist/effects/passes/screen-space/temporal-frame.js.map +1 -0
- package/dist/effects/passes/screen-space/volumetric-fog.cjs +25 -22
- package/dist/effects/passes/screen-space/volumetric-fog.d.ts +161 -2
- package/dist/effects/passes/screen-space/volumetric-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/volumetric-fog.js +27 -21
- package/dist/effects/passes/screen-space/volumetric-fog.js.map +1 -1
- package/dist/effects/temporal-upscale/index.cjs +40 -0
- package/dist/effects/temporal-upscale/index.d.ts +5 -0
- package/dist/effects/temporal-upscale/index.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/index.js +6 -0
- package/dist/effects/temporal-upscale/index.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-math.cjs +202 -0
- package/dist/effects/temporal-upscale/temporal-math.d.ts +101 -0
- package/dist/effects/temporal-upscale/temporal-math.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-math.js +202 -0
- package/dist/effects/temporal-upscale/temporal-math.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.cjs +353 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts +7 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.js +321 -0
- package/dist/effects/temporal-upscale/temporal-upscale-shaders.js.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.cjs +392 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.d.ts +143 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.d.ts.map +1 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.js +385 -0
- package/dist/effects/temporal-upscale/temporal-upscaler.js.map +1 -0
- package/dist/experimental-controls.cjs +13 -3
- package/dist/experimental-controls.d.ts +2 -1
- package/dist/experimental-controls.d.ts.map +1 -1
- package/dist/experimental-controls.js +1 -1
- package/dist/experimental-controls.js.map +1 -1
- package/dist/experimental-materials.cjs +37 -3
- package/dist/experimental-materials.d.ts +2 -1
- package/dist/experimental-materials.d.ts.map +1 -1
- package/dist/experimental-materials.js +1 -1
- package/dist/experimental-materials.js.map +1 -1
- package/dist/experimental-textures.cjs +13 -3
- package/dist/experimental-textures.d.ts +2 -1
- package/dist/experimental-textures.d.ts.map +1 -1
- package/dist/experimental-textures.js +1 -1
- package/dist/experimental-textures.js.map +1 -1
- package/dist/experimental-webxr.cjs +17 -3
- package/dist/experimental-webxr.d.ts +2 -1
- package/dist/experimental-webxr.d.ts.map +1 -1
- package/dist/experimental-webxr.js +1 -1
- package/dist/experimental-webxr.js.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.cjs +34 -71
- package/dist/gltf/gltf/create-gltf-model.d.ts +3 -0
- package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.js +40 -74
- package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +46 -4
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +9 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +54 -4
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.cjs +25 -136
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts +4 -8
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.js +27 -139
- package/dist/gltf/gltf/gltf-animated-crowd.js.map +1 -1
- package/dist/gltf/gltf/gltf-animation-nodes.cjs +84 -0
- package/dist/gltf/gltf/gltf-animation-nodes.d.ts +11 -0
- package/dist/gltf/gltf/gltf-animation-nodes.d.ts.map +1 -0
- package/dist/gltf/gltf/gltf-animation-nodes.js +62 -0
- package/dist/gltf/gltf/gltf-animation-nodes.js.map +1 -0
- package/dist/gltf/gltf/gltf-animator.cjs +8 -2
- package/dist/gltf/gltf/gltf-animator.d.ts +6 -1
- package/dist/gltf/gltf/gltf-animator.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animator.js +10 -2
- package/dist/gltf/gltf/gltf-animator.js.map +1 -1
- package/dist/gltf/gltf/gltf-gpu-animation-controller.cjs +81 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts +9 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.d.ts.map +1 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.js +67 -0
- package/dist/gltf/gltf/gltf-gpu-animation-controller.js.map +1 -0
- package/dist/gltf/gltf/gltf-gpu-animation.cjs +33 -28
- package/dist/gltf/gltf/gltf-gpu-animation.d.ts +7 -26
- package/dist/gltf/gltf/gltf-gpu-animation.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-gpu-animation.js +29 -28
- package/dist/gltf/gltf/gltf-gpu-animation.js.map +1 -1
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +2 -2
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf.cjs +4 -2
- package/dist/gltf/parsers/parse-gltf.d.ts +3 -0
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +7 -2
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/graph/models/index.cjs.map +2 -2
- package/dist/graph/physics/index.cjs +5 -0
- package/dist/graph/physics/index.cjs.map +3 -3
- package/dist/graph/physics/index.d.ts +1 -0
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/index.js +1 -0
- package/dist/graph/physics/index.js.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +21 -0
- package/dist/graph/physics/physics-controller-geometry.d.ts +8 -1
- package/dist/graph/physics/physics-controller-geometry.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.js +22 -0
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
- package/dist/graph/physics/scenegraph-session.d.ts +1 -1
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -1
- package/dist/graph/tables/index.cjs.map +2 -2
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.cjs +47 -28
- package/dist/lighting/ambient-occlusion-pass.d.ts +12 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.js +45 -26
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -1
- package/dist/lighting/clustered-light-grid.cjs +71 -20
- package/dist/lighting/clustered-light-grid.d.ts +37 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -1
- package/dist/lighting/clustered-light-grid.js +68 -18
- package/dist/lighting/clustered-light-grid.js.map +1 -1
- package/dist/lighting/contact-shadow-composite.cjs +72 -51
- package/dist/lighting/contact-shadow-composite.d.ts +274 -3
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -1
- package/dist/lighting/contact-shadow-composite.js +72 -50
- package/dist/lighting/contact-shadow-composite.js.map +1 -1
- package/dist/lighting/contact-shadow-pass.cjs +50 -39
- package/dist/lighting/contact-shadow-pass.d.ts +8 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -1
- package/dist/lighting/contact-shadow-pass.js +47 -37
- package/dist/lighting/contact-shadow-pass.js.map +1 -1
- package/dist/lighting/cortao/cortao-occluder-lookup-table.cjs +96 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts +41 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.js +94 -0
- package/dist/lighting/cortao/cortao-occluder-lookup-table.js.map +1 -0
- package/dist/lighting/cortao/cortao-parameters.cjs +127 -0
- package/dist/lighting/cortao/cortao-parameters.d.ts +95 -0
- package/dist/lighting/cortao/cortao-parameters.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-parameters.js +122 -0
- package/dist/lighting/cortao/cortao-parameters.js.map +1 -0
- package/dist/lighting/cortao/cortao-pass.cjs +100 -0
- package/dist/lighting/cortao/cortao-pass.d.ts +33 -0
- package/dist/lighting/cortao/cortao-pass.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-pass.js +84 -0
- package/dist/lighting/cortao/cortao-pass.js.map +1 -0
- package/dist/lighting/cortao/cortao-passes.cjs +42 -0
- package/dist/lighting/cortao/cortao-passes.d.ts +38 -0
- package/dist/lighting/cortao/cortao-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-passes.js +19 -0
- package/dist/lighting/cortao/cortao-passes.js.map +1 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.cjs +606 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts +49 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.js +610 -0
- package/dist/lighting/cortao/cortao-shaders-wgsl.js.map +1 -0
- package/dist/lighting/cortao/cortao-shaders.cjs +667 -0
- package/dist/lighting/cortao/cortao-shaders.d.ts +118 -0
- package/dist/lighting/cortao/cortao-shaders.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-shaders.js +657 -0
- package/dist/lighting/cortao/cortao-shaders.js.map +1 -0
- package/dist/lighting/cortao/cortao-upsample.cjs +191 -0
- package/dist/lighting/cortao/cortao-upsample.d.ts +16 -0
- package/dist/lighting/cortao/cortao-upsample.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-upsample.js +159 -0
- package/dist/lighting/cortao/cortao-upsample.js.map +1 -0
- package/dist/lighting/cortao/cortao-webgl-passes.cjs +229 -0
- package/dist/lighting/cortao/cortao-webgl-passes.d.ts +28 -0
- package/dist/lighting/cortao/cortao-webgl-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-webgl-passes.js +212 -0
- package/dist/lighting/cortao/cortao-webgl-passes.js.map +1 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.cjs +348 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.d.ts +31 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.d.ts.map +1 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.js +335 -0
- package/dist/lighting/cortao/cortao-webgpu-passes.js.map +1 -0
- package/dist/lighting/index.cjs +13 -2
- package/dist/lighting/index.cjs.map +3 -3
- package/dist/lighting/index.d.ts +11 -6
- package/dist/lighting/index.d.ts.map +1 -1
- package/dist/lighting/index.js +6 -5
- package/dist/lighting/index.js.map +1 -1
- package/dist/lighting/shadow-map-renderer.cjs +40 -37
- package/dist/lighting/shadow-map-renderer.d.ts +15 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -1
- package/dist/lighting/shadow-map-renderer.js +37 -35
- package/dist/lighting/shadow-map-renderer.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +39 -16
- package/dist/model/gpu-vector-model.d.ts +8 -0
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +46 -18
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/passes/effect-renderer.cjs +155 -0
- package/dist/passes/effect-renderer.d.ts +158 -0
- package/dist/passes/effect-renderer.d.ts.map +1 -0
- package/dist/passes/effect-renderer.js +143 -0
- package/dist/passes/effect-renderer.js.map +1 -0
- package/dist/passes/scene-capture-pass.cjs +42 -0
- package/dist/passes/scene-capture-pass.d.ts +29 -0
- package/dist/passes/scene-capture-pass.d.ts.map +1 -0
- package/dist/passes/scene-capture-pass.js +21 -0
- package/dist/passes/scene-capture-pass.js.map +1 -0
- package/dist/passes/shader-pass-renderer.cjs +94 -68
- package/dist/passes/shader-pass-renderer.d.ts +32 -15
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +104 -76
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/scenegraph/model-node.cjs +2 -0
- package/dist/scenegraph/model-node.d.ts +4 -0
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/model-node.js +2 -0
- package/dist/scenegraph/model-node.js.map +1 -1
- package/dist/splats/gpu-paged-splat-renderer.cjs +52 -8
- package/dist/splats/gpu-paged-splat-renderer.d.ts +16 -3
- package/dist/splats/gpu-paged-splat-renderer.d.ts.map +1 -1
- package/dist/splats/gpu-paged-splat-renderer.js +55 -9
- package/dist/splats/gpu-paged-splat-renderer.js.map +1 -1
- package/dist/splats/gpu-paged-splat-shaders.cjs +3 -1
- package/dist/splats/gpu-paged-splat-shaders.d.ts.map +1 -1
- package/dist/splats/gpu-paged-splat-shaders.js +3 -1
- package/dist/splats/gpu-paged-splat-shaders.js.map +1 -1
- package/dist/splats/index.cjs.map +2 -2
- package/dist/text/fonts/atlas/browser-font-atlas.cjs +10 -1
- package/dist/text/fonts/atlas/browser-font-atlas.d.ts +3 -1
- package/dist/text/fonts/atlas/browser-font-atlas.d.ts.map +1 -1
- package/dist/text/fonts/atlas/browser-font-atlas.js +10 -2
- package/dist/text/fonts/atlas/browser-font-atlas.js.map +1 -1
- package/dist/text/fonts/atlas/lru-cache.cjs +4 -0
- package/dist/text/fonts/atlas/lru-cache.d.ts +3 -1
- package/dist/text/fonts/atlas/lru-cache.d.ts.map +1 -1
- package/dist/text/fonts/atlas/lru-cache.js +4 -0
- package/dist/text/fonts/atlas/lru-cache.js.map +1 -1
- package/dist/text/fonts/index.cjs +2 -0
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/fonts/index.d.ts +1 -1
- package/dist/text/fonts/index.d.ts.map +1 -1
- package/dist/text/fonts/index.js +1 -1
- package/dist/text/fonts/index.js.map +1 -1
- package/dist/text/index.cjs.map +1 -1
- package/package.json +8 -8
- package/src/animation/animation-track.ts +5 -0
- package/src/animation/node-animation-binding.ts +9 -8
- package/src/animation/scenegraph-gpu-animation-layout.ts +195 -0
- package/src/animation/scenegraph-gpu-animation.ts +340 -0
- package/src/arrow/arrow-picking.ts +23 -11
- package/src/audio/audio-controller.ts +4 -1
- package/src/audio/audio-graph.ts +46 -25
- package/src/effects/README.md +38 -14
- package/src/effects/glfx-effects.ts +227 -0
- package/src/effects/graph/gpu-effect-operation.ts +601 -0
- package/src/effects/graph/temporal-graph-history.ts +46 -0
- package/src/effects/index.ts +81 -19
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +8 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/tone-mapping.ts +8 -0
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-composite-shader-pass.ts +219 -19
- package/src/effects/passes/postprocessing/image-blur-filters/bloom-compute-pyramid.ts +6 -6
- package/src/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +45 -45
- package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +88 -68
- package/src/effects/passes/screen-space/copy-pass.ts +4 -0
- package/src/effects/passes/screen-space/depth-aware-blur.ts +13 -3
- package/src/effects/passes/screen-space/dof.ts +20 -3
- package/src/effects/passes/screen-space/gtao.ts +91 -65
- package/src/effects/passes/screen-space/hdr-auto-exposure.ts +109 -84
- package/src/effects/passes/screen-space/height-fog.ts +18 -3
- package/src/effects/passes/screen-space/motion-blur.ts +8 -7
- package/src/effects/passes/screen-space/outlines.ts +143 -17
- package/src/effects/passes/screen-space/screen-space-global-illumination.ts +75 -64
- package/src/effects/passes/screen-space/screen-space-reflections.ts +158 -95
- package/src/effects/passes/screen-space/selection-outline.ts +11 -0
- package/src/effects/passes/screen-space/ssao.ts +79 -46
- package/src/effects/passes/screen-space/temporal-antialiasing.ts +43 -33
- package/src/effects/passes/screen-space/temporal-frame.ts +33 -0
- package/src/effects/passes/screen-space/volumetric-fog.ts +30 -24
- package/src/effects/temporal-upscale/index.ts +20 -0
- package/src/effects/temporal-upscale/temporal-math.ts +308 -0
- package/src/effects/temporal-upscale/temporal-upscale-shaders.ts +326 -0
- package/src/effects/temporal-upscale/temporal-upscaler.ts +538 -0
- package/src/experimental-controls.ts +13 -1
- package/src/experimental-materials.ts +37 -1
- package/src/experimental-textures.ts +9 -1
- package/src/experimental-webxr.ts +18 -1
- package/src/gltf/gltf/create-gltf-model.ts +59 -90
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +71 -5
- package/src/gltf/gltf/gltf-animated-crowd.ts +30 -177
- package/src/gltf/gltf/gltf-animation-nodes.ts +82 -0
- package/src/gltf/gltf/gltf-animator.ts +15 -4
- package/src/gltf/gltf/gltf-gpu-animation-controller.ts +88 -0
- package/src/gltf/gltf/gltf-gpu-animation.ts +53 -60
- package/src/gltf/index.ts +5 -0
- package/src/gltf/parsers/parse-gltf.ts +12 -2
- package/src/graph/physics/index.ts +4 -0
- package/src/graph/physics/physics-controller-geometry.ts +33 -1
- package/src/index.ts +25 -0
- package/src/lighting/ambient-occlusion-pass.ts +62 -28
- package/src/lighting/clustered-light-grid.ts +87 -30
- package/src/lighting/contact-shadow-composite.ts +80 -52
- package/src/lighting/contact-shadow-pass.ts +59 -39
- package/src/lighting/cortao/cortao-occluder-lookup-table.ts +138 -0
- package/src/lighting/cortao/cortao-parameters.ts +218 -0
- package/src/lighting/cortao/cortao-pass.ts +136 -0
- package/src/lighting/cortao/cortao-passes.ts +50 -0
- package/src/lighting/cortao/cortao-shaders-wgsl.ts +633 -0
- package/src/lighting/cortao/cortao-shaders.ts +674 -0
- package/src/lighting/cortao/cortao-upsample.ts +177 -0
- package/src/lighting/cortao/cortao-webgl-passes.ts +284 -0
- package/src/lighting/cortao/cortao-webgpu-passes.ts +430 -0
- package/src/lighting/index.ts +12 -3
- package/src/lighting/shadow-map-renderer.ts +57 -43
- package/src/model/gpu-vector-model.ts +47 -18
- package/src/passes/effect-renderer.ts +332 -0
- package/src/passes/scene-capture-pass.ts +51 -0
- package/src/passes/shader-pass-renderer.ts +164 -115
- package/src/scenegraph/model-node.ts +5 -0
- package/src/splats/README.md +1 -1
- package/src/splats/gpu-paged-splat-renderer.ts +77 -9
- package/src/splats/gpu-paged-splat-shaders.ts +7 -1
- package/src/text/fonts/atlas/browser-font-atlas.ts +12 -2
- package/src/text/fonts/atlas/lru-cache.ts +6 -1
- package/src/text/fonts/index.ts +1 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Texture } from '@luma.gl/core';
|
|
2
|
-
import type { CompositeShaderPass } from '@luma.gl/shaders';
|
|
3
2
|
import type { NumberArray16 } from '@math.gl/core/types';
|
|
4
3
|
export type SSRQuality = 'fast' | 'balanced' | 'detailed';
|
|
5
4
|
/** Relative workload presets. Actual frame cost depends on scene, viewport, and device. */
|
|
@@ -294,11 +293,783 @@ export declare const ssrComposite: {
|
|
|
294
293
|
readonly sampler: true;
|
|
295
294
|
}];
|
|
296
295
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
296
|
+
/** Screen-space reflections with velocity or camera reprojection. */
|
|
297
|
+
export declare const ssr: {
|
|
298
|
+
readonly name: "ssrCompositeShaderPass";
|
|
299
|
+
readonly optionDefaults: SSRCompositeShaderPassOptions;
|
|
300
|
+
readonly scaleResources: {
|
|
301
|
+
readonly option: "resolutionScale";
|
|
302
|
+
readonly targets: readonly ["ssrRaw", "ssrHistory", "ssrHistoryDepth", "ssrScratch", "ssrReflection"];
|
|
303
|
+
readonly defaultScale: 1;
|
|
304
|
+
readonly fallback: {
|
|
305
|
+
readonly option: "quality";
|
|
306
|
+
readonly values: {
|
|
307
|
+
readonly fast: 0.25;
|
|
308
|
+
readonly balanced: 0.5;
|
|
309
|
+
readonly detailed: 1;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
readonly optionUniforms: {
|
|
314
|
+
readonly ssrTrace: {
|
|
315
|
+
readonly sampleCount: {
|
|
316
|
+
readonly option: "quality";
|
|
317
|
+
readonly values: {
|
|
318
|
+
readonly fast: 32;
|
|
319
|
+
readonly balanced: 96;
|
|
320
|
+
readonly detailed: 96;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
readonly ssrTemporal: {
|
|
325
|
+
readonly historyWeight: {
|
|
326
|
+
readonly option: "quality";
|
|
327
|
+
readonly values: {
|
|
328
|
+
readonly fast: 0.9;
|
|
329
|
+
readonly balanced: 0.8;
|
|
330
|
+
readonly detailed: 0.8;
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
readonly ssrCameraTemporal: {
|
|
335
|
+
readonly historyWeight: {
|
|
336
|
+
readonly option: "quality";
|
|
337
|
+
readonly values: {
|
|
338
|
+
readonly fast: 0.9;
|
|
339
|
+
readonly balanced: 0.8;
|
|
340
|
+
readonly detailed: 0.8;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
readonly ssrSpatial: {
|
|
345
|
+
readonly maxRadius: {
|
|
346
|
+
readonly option: "quality";
|
|
347
|
+
readonly values: {
|
|
348
|
+
readonly fast: 3;
|
|
349
|
+
readonly balanced: 2;
|
|
350
|
+
readonly detailed: 2;
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
readonly resources: {
|
|
356
|
+
readonly ssrRaw: {
|
|
357
|
+
readonly scale: [1, 1];
|
|
358
|
+
readonly format: "rgba16float";
|
|
359
|
+
};
|
|
360
|
+
readonly ssrHistory: {
|
|
361
|
+
readonly scale: [1, 1];
|
|
362
|
+
readonly format: "rgba16float";
|
|
363
|
+
readonly lifetime: "history";
|
|
364
|
+
readonly initialize: {
|
|
365
|
+
readonly clearColor: [0, 0, 0, 0];
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
readonly ssrHistoryDepth: {
|
|
369
|
+
readonly scale: [1, 1];
|
|
370
|
+
readonly format: "rgba16float";
|
|
371
|
+
readonly lifetime: "history";
|
|
372
|
+
readonly initialize: {
|
|
373
|
+
readonly clearColor: [1, 0, 0, 1];
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
readonly ssrScratch: {
|
|
377
|
+
readonly scale: [1, 1];
|
|
378
|
+
readonly format: "rgba16float";
|
|
379
|
+
};
|
|
380
|
+
readonly ssrReflection: {
|
|
381
|
+
readonly scale: [1, 1];
|
|
382
|
+
readonly format: "rgba16float";
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
readonly passes: [{
|
|
386
|
+
readonly kind: "sample";
|
|
387
|
+
readonly module: {
|
|
388
|
+
readonly name: "ssrTrace";
|
|
389
|
+
readonly source: "const SSR_TWO_PI: f32 = 6.283185307179586;\n\nstruct SSRTraceUniforms {\n projectionMatrix: mat4x4f,\n inverseProjectionMatrix: mat4x4f,\n intensity: f32,\n maxDistance: f32,\n thickness: f32,\n sampleCount: f32,\n maxRoughness: f32,\n frameIndex: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrTrace: SSRTraceUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrTrace_reconstructViewPosition(uv: vec2f, depth: f32) -> vec3f {\n let clip = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, depth, 1.0);\n let viewPosition = ssrTrace.inverseProjectionMatrix * clip;\n return viewPosition.xyz / max(viewPosition.w, 0.00001);\n}\n\nfn ssrTrace_projectViewPosition(position: vec3f) -> vec2f {\n let clip = ssrTrace.projectionMatrix * vec4f(position, 1.0);\n let normalizedDeviceCoordinate = clip.xy / max(clip.w, 0.00001);\n return vec2f(\n normalizedDeviceCoordinate.x * 0.5 + 0.5,\n 0.5 - normalizedDeviceCoordinate.y * 0.5\n );\n}\n\nfn ssrTrace_hash(value: vec2f, frameIndex: f32) -> f32 {\n let temporalPhase = fract(frameIndex * 0.61803398875) * SSR_TWO_PI;\n return fract(sin(dot(value, vec2f(12.9898, 78.233)) + temporalPhase) * 43758.5453);\n}\n\nfn ssrTrace_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let sceneCoord = texCoord;\n let normalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, sceneCoord, 0);\n let normal = normalize(normalRoughness.xyz * 2.0 - 1.0);\n let roughness = clamp(normalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, sceneCoord, 0);\n if (centerDepth >= 0.99999 || roughness >= ssrTrace.maxRoughness ||\n ssrTrace.intensity <= 0.0001) {\n return vec4f(0.0);\n }\n\n let viewPosition = ssrTrace_reconstructViewPosition(sceneCoord, centerDepth);\n let incidentDirection = normalize(viewPosition);\n let mirrorDirection = normalize(reflect(incidentDirection, normal));\n let pixelCoordinate = floor(sceneCoord * vec2f(textureDimensions(depthTexture)));\n let noise = ssrTrace_hash(pixelCoordinate, ssrTrace.frameIndex);\n let noiseAngle = noise * SSR_TWO_PI;\n let referenceAxis = select(\n vec3f(0.0, 1.0, 0.0),\n vec3f(1.0, 0.0, 0.0),\n abs(mirrorDirection.y) > 0.9\n );\n let tangent = normalize(cross(referenceAxis, mirrorDirection));\n let bitangent = normalize(cross(mirrorDirection, tangent));\n let roughnessCone = roughness * roughness * 0.32;\n let reflectedRay = normalize(\n mirrorDirection + (tangent * cos(noiseAngle) + bitangent * sin(noiseAngle)) * roughnessCone\n );\n let rayOrigin = viewPosition + normal * max(ssrTrace.thickness * 0.12, 0.025);\n\n var reflection = vec3f(0.0);\n var confidence = 0.0;\n var previousTravel = 0.06;\n var previousDepthDelta = -ssrTrace.thickness;\n let minimumSampleCount = ceil(\n ssrTrace.maxDistance / max(ssrTrace.thickness * 0.72, 0.12)\n );\n let effectiveSampleCount = min(96.0, max(ssrTrace.sampleCount, minimumSampleCount));\n for (var sampleIndex: i32 = 1; sampleIndex <= 96; sampleIndex++) {\n if (f32(sampleIndex) > effectiveSampleCount) {\n break;\n }\n let fraction = (f32(sampleIndex) - noise * 0.42) / max(effectiveSampleCount, 1.0);\n let travel = 0.08 + pow(max(fraction, 0.0), 1.3) * ssrTrace.maxDistance;\n let rayPosition = rayOrigin + reflectedRay * travel;\n if (rayPosition.z >= -0.04) {\n break;\n }\n let sampleCoord = ssrTrace_projectViewPosition(rayPosition);\n if (any(sampleCoord <= vec2f(0.0)) || any(sampleCoord >= vec2f(1.0))) {\n break;\n }\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n if (sampleDepth >= 0.99999) {\n previousTravel = travel;\n previousDepthDelta = -ssrTrace.thickness;\n continue;\n }\n let scenePosition = ssrTrace_reconstructViewPosition(sampleCoord, sampleDepth);\n let depthDelta = (-rayPosition.z) - (-scenePosition.z);\n let rayStepLength = max(travel - previousTravel, 0.001);\n let hitThickness = max(ssrTrace.thickness, rayStepLength * 1.2) + travel * 0.008;\n let crossesCandidateSurface = previousDepthDelta <= 0.0 && depthDelta >= 0.0;\n let screenTravelPixels = length((sampleCoord - sceneCoord) * texSize);\n var entersCandidateSurface = true;\n if (crossesCandidateSurface && depthDelta < hitThickness && screenTravelPixels > 1.25) {\n let candidateNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n entersCandidateSurface = dot(reflectedRay, candidateNormal) < -0.015;\n if (entersCandidateSurface) {\n var nearTravel = previousTravel;\n var farTravel = travel;\n var hitCoord = sampleCoord;\n for (var refinementIndex: i32 = 0; refinementIndex < 5; refinementIndex++) {\n let refinedTravel = (nearTravel + farTravel) * 0.5;\n let refinedPosition = rayOrigin + reflectedRay * refinedTravel;\n let refinedCoord = ssrTrace_projectViewPosition(refinedPosition);\n let refinedDepth = textureSampleLevel(depthTexture, depthTextureSampler, refinedCoord, 0);\n let refinedScenePosition = ssrTrace_reconstructViewPosition(refinedCoord, refinedDepth);\n if ((-refinedPosition.z) - (-refinedScenePosition.z) >= 0.0) {\n farTravel = refinedTravel;\n hitCoord = refinedCoord;\n } else {\n nearTravel = refinedTravel;\n }\n }\n reflection = textureSampleLevel(sourceTexture, sourceTextureSampler, hitCoord, 0).rgb;\n let screenEdge = min(\n min(hitCoord.x, hitCoord.y),\n min(1.0 - hitCoord.x, 1.0 - hitCoord.y)\n );\n let fresnel = mix(\n 0.32,\n 1.0,\n pow(1.0 - max(dot(-incidentDirection, normal), 0.0), 5.0)\n );\n let roughnessFade = pow(1.0 - roughness / max(ssrTrace.maxRoughness, 0.001), 1.5);\n let distanceFade = 1.0 - clamp(farTravel / ssrTrace.maxDistance, 0.0, 1.0);\n confidence = smoothstep(0.0, 0.09, screenEdge) * roughnessFade * fresnel *\n distanceFade * ssrTrace.intensity;\n break;\n }\n }\n previousTravel = travel;\n previousDepthDelta = select(-ssrTrace.thickness, depthDelta, entersCandidateSurface);\n }\n\n return vec4f(reflection, clamp(confidence, 0.0, 1.0));\n}";
|
|
390
|
+
readonly bindingLayout: readonly [{
|
|
391
|
+
readonly name: "depthTexture";
|
|
392
|
+
readonly group: 0;
|
|
393
|
+
}, {
|
|
394
|
+
readonly name: "normalTexture";
|
|
395
|
+
readonly group: 0;
|
|
396
|
+
}];
|
|
397
|
+
readonly props: Partial<SSRTraceUniforms> & SSRTraceBindings;
|
|
398
|
+
readonly uniforms: SSRTraceUniforms;
|
|
399
|
+
readonly bindings: SSRTraceBindings;
|
|
400
|
+
readonly uniformTypes: {
|
|
401
|
+
readonly projectionMatrix: "mat4x4<f32>";
|
|
402
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
403
|
+
readonly intensity: "f32";
|
|
404
|
+
readonly maxDistance: "f32";
|
|
405
|
+
readonly thickness: "f32";
|
|
406
|
+
readonly sampleCount: "f32";
|
|
407
|
+
readonly maxRoughness: "f32";
|
|
408
|
+
readonly frameIndex: "f32";
|
|
409
|
+
};
|
|
410
|
+
readonly propTypes: {
|
|
411
|
+
readonly projectionMatrix: {
|
|
412
|
+
readonly value: NumberArray16;
|
|
413
|
+
readonly private: true;
|
|
414
|
+
};
|
|
415
|
+
readonly inverseProjectionMatrix: {
|
|
416
|
+
readonly value: NumberArray16;
|
|
417
|
+
readonly private: true;
|
|
418
|
+
};
|
|
419
|
+
readonly intensity: {
|
|
420
|
+
readonly value: 1.35;
|
|
421
|
+
readonly min: 0;
|
|
422
|
+
readonly softMax: 4;
|
|
423
|
+
};
|
|
424
|
+
readonly maxDistance: {
|
|
425
|
+
readonly value: 60;
|
|
426
|
+
readonly min: 1;
|
|
427
|
+
readonly softMax: 180;
|
|
428
|
+
};
|
|
429
|
+
readonly thickness: {
|
|
430
|
+
readonly value: 0.45;
|
|
431
|
+
readonly min: 0.02;
|
|
432
|
+
readonly softMax: 3;
|
|
433
|
+
};
|
|
434
|
+
readonly sampleCount: {
|
|
435
|
+
readonly value: 48;
|
|
436
|
+
readonly min: 8;
|
|
437
|
+
readonly max: 96;
|
|
438
|
+
};
|
|
439
|
+
readonly maxRoughness: {
|
|
440
|
+
readonly value: 0.88;
|
|
441
|
+
readonly min: 0.1;
|
|
442
|
+
readonly max: 1;
|
|
443
|
+
};
|
|
444
|
+
readonly frameIndex: {
|
|
445
|
+
readonly value: 0;
|
|
446
|
+
readonly private: true;
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
readonly passes: [{
|
|
450
|
+
readonly sampler: true;
|
|
451
|
+
}];
|
|
452
|
+
};
|
|
453
|
+
readonly inputs: {
|
|
454
|
+
readonly sourceTexture: "previous";
|
|
455
|
+
};
|
|
456
|
+
readonly output: "ssrRaw";
|
|
457
|
+
}, {
|
|
458
|
+
readonly kind: "sample";
|
|
459
|
+
readonly module: {
|
|
460
|
+
readonly name: "ssrTemporal";
|
|
461
|
+
readonly source: "\nfn temporal_getTexelCoordinate(coordinate: vec2f, dimensions: vec2u) -> vec2i {\n return clamp(vec2i(coordinate * vec2f(dimensions)), vec2i(0), vec2i(dimensions) - vec2i(1));\n}\n\nfn temporal_getClipPosition(coordinate: vec2f, depth: f32) -> vec4f {\n return vec4f(coordinate * vec2f(2.0, -2.0) + vec2f(-1.0, 1.0), depth, 1.0);\n}\n\n// Returns previous UV, device depth, and validity. Matrices use WebGPU clip depth.\nfn temporal_getPreviousFrame(previousClip: vec4f, jitter: vec2f, epsilon: f32) -> vec4f {\n if (previousClip.w <= epsilon) { return vec4f(0.0); }\n let position = previousClip.xyz / previousClip.w;\n let coordinate = position.xy * vec2f(0.5, -0.5) + vec2f(0.5) + jitter;\n let valid = all(coordinate >= vec2f(0.0)) && all(coordinate <= vec2f(1.0)) &&\n position.z >= 0.0 && position.z <= 1.0;\n return vec4f(coordinate, position.z, select(0.0, 1.0, valid));\n}\n\nfn temporal_getViewDepth(\n coordinate: vec2f, depth: f32, inverseProjection: mat4x4f, epsilon: f32\n) -> f32 {\n let position = inverseProjection * temporal_getClipPosition(coordinate, depth);\n return abs(position.z / max(abs(position.w), epsilon));\n}\n\nstruct TemporalColorBounds { minimum: vec4f, maximum: vec4f };\nfn temporal_getColorBounds(\n sourceTexture: texture_2d<f32>, sourceTextureSampler: sampler,\n coordinate: vec2f, current: vec4f\n) -> TemporalColorBounds {\n let texel = 1.0 / vec2f(textureDimensions(sourceTexture));\n var minimum = current;\n var maximum = current;\n for (var vertical = -1; vertical <= 1; vertical++) {\n for (var horizontal = -1; horizontal <= 1; horizontal++) {\n let sampleCoordinate = clamp(coordinate + vec2f(f32(horizontal), f32(vertical)) * texel,\n vec2f(0.0), vec2f(1.0));\n let sample = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoordinate, 0);\n minimum = min(minimum, sample);\n maximum = max(maximum, sample);\n }\n }\n return TemporalColorBounds(minimum, maximum);\n}\n\nstruct TemporalHistoryFootprint { base: vec2i, fraction: vec2f, dimensions: vec2u };\nstruct TemporalHistoryTap { coordinate: vec2i, normalizedCoordinate: vec2f, weight: f32 };\nfn temporal_getHistoryFootprint(coordinate: vec2f, dimensions: vec2u) -> TemporalHistoryFootprint {\n let position = coordinate * vec2f(dimensions) - vec2f(0.5);\n return TemporalHistoryFootprint(vec2i(floor(position)), fract(position), dimensions);\n}\nfn temporal_getHistoryTap(footprint: TemporalHistoryFootprint, offset: vec2i) -> TemporalHistoryTap {\n let coordinate = clamp(footprint.base + offset, vec2i(0), vec2i(footprint.dimensions) - vec2i(1));\n let horizontalWeight = select(1.0 - footprint.fraction.x, footprint.fraction.x, offset.x == 1);\n let verticalWeight = select(1.0 - footprint.fraction.y, footprint.fraction.y, offset.y == 1);\n return TemporalHistoryTap(coordinate,\n (vec2f(coordinate) + vec2f(0.5)) / vec2f(footprint.dimensions), horizontalWeight * verticalWeight);\n}\n\nstruct SSRTemporalUniforms {\n inverseProjectionMatrix: mat4x4f,\n historyWeight: f32,\n depthThreshold: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrTemporal: SSRTemporalUniforms;\n@group(0) @binding(auto) var historyTexture: texture_2d<f32>;\n@group(0) @binding(auto) var historyTextureSampler: sampler;\n@group(0) @binding(auto) var velocityTexture: texture_2d<f32>;\n@group(0) @binding(auto) var velocityTextureSampler: sampler;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var previousDepthTexture: texture_2d<f32>;\n@group(0) @binding(auto) var previousDepthTextureSampler: sampler;\n\nfn ssrTemporal_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let current = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let currentDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (currentDepth >= 0.99999) {\n return vec4f(0.0);\n }\n\n let velocity = textureSampleLevel(velocityTexture, velocityTextureSampler, texCoord, 0).xy;\n let previousCoord = texCoord - velocity;\n let validCoordinate = all(previousCoord >= vec2f(0.0)) &&\n all(previousCoord <= vec2f(1.0));\n let clampedPreviousCoord = clamp(previousCoord, vec2f(0.0), vec2f(1.0));\n let previousDepth = textureSampleLevel(\n previousDepthTexture,\n previousDepthTextureSampler,\n clampedPreviousCoord,\n 0\n ).r;\n let currentViewDepth = temporal_getViewDepth(texCoord, currentDepth, ssrTemporal.inverseProjectionMatrix, 0.00001);\n let previousViewDepth = temporal_getViewDepth(clampedPreviousCoord, previousDepth, ssrTemporal.inverseProjectionMatrix, 0.00001);\n let relativeDepthDifference = abs(previousViewDepth - currentViewDepth) /\n max(currentViewDepth, 0.0001);\n let validDepth = relativeDepthDifference < ssrTemporal.depthThreshold;\n\n let bounds = temporal_getColorBounds(sourceTexture, sourceTextureSampler, texCoord, current);\n let minimumReflection = bounds.minimum;\n let maximumReflection = bounds.maximum;\n\n let historyReflection = textureSampleLevel(\n historyTexture,\n historyTextureSampler,\n clampedPreviousCoord,\n 0\n );\n let validHistory = validCoordinate && validDepth && historyReflection.a > 0.001;\n if (!validHistory) {\n return current;\n }\n\n let hasCurrentSupport = maximumReflection.a > 0.001;\n if (!hasCurrentSupport) {\n return vec4f(\n historyReflection.rgb,\n historyReflection.a * ssrTemporal.historyWeight\n );\n }\n\n let clampedHistory = clamp(historyReflection, minimumReflection, maximumReflection);\n return mix(current, clampedHistory, ssrTemporal.historyWeight);\n}";
|
|
462
|
+
readonly bindingLayout: readonly [{
|
|
463
|
+
readonly name: "historyTexture";
|
|
464
|
+
readonly group: 0;
|
|
465
|
+
}, {
|
|
466
|
+
readonly name: "velocityTexture";
|
|
467
|
+
readonly group: 0;
|
|
468
|
+
}, {
|
|
469
|
+
readonly name: "depthTexture";
|
|
470
|
+
readonly group: 0;
|
|
471
|
+
}, {
|
|
472
|
+
readonly name: "previousDepthTexture";
|
|
473
|
+
readonly group: 0;
|
|
474
|
+
}];
|
|
475
|
+
readonly props: Partial<SSRTemporalUniforms> & SSRTemporalBindings;
|
|
476
|
+
readonly uniforms: SSRTemporalUniforms;
|
|
477
|
+
readonly bindings: SSRTemporalBindings;
|
|
478
|
+
readonly uniformTypes: {
|
|
479
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
480
|
+
readonly historyWeight: "f32";
|
|
481
|
+
readonly depthThreshold: "f32";
|
|
482
|
+
};
|
|
483
|
+
readonly propTypes: {
|
|
484
|
+
readonly inverseProjectionMatrix: {
|
|
485
|
+
readonly value: NumberArray16;
|
|
486
|
+
readonly private: true;
|
|
487
|
+
};
|
|
488
|
+
readonly historyWeight: {
|
|
489
|
+
readonly value: 0.86;
|
|
490
|
+
readonly min: 0;
|
|
491
|
+
readonly max: 0.97;
|
|
492
|
+
};
|
|
493
|
+
readonly depthThreshold: {
|
|
494
|
+
readonly value: 0.018;
|
|
495
|
+
readonly min: 0.0001;
|
|
496
|
+
readonly softMax: 0.1;
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
readonly passes: [{
|
|
500
|
+
readonly sampler: true;
|
|
501
|
+
}];
|
|
502
|
+
};
|
|
503
|
+
readonly inputs: {
|
|
504
|
+
readonly sourceTexture: "ssrRaw";
|
|
505
|
+
readonly historyTexture: "ssrHistory";
|
|
506
|
+
readonly previousDepthTexture: "ssrHistoryDepth";
|
|
507
|
+
};
|
|
508
|
+
readonly output: "ssrHistory";
|
|
509
|
+
}, {
|
|
510
|
+
readonly kind: "sample";
|
|
511
|
+
readonly module: {
|
|
512
|
+
readonly name: "ssrDepthHistoryCopy";
|
|
513
|
+
readonly source: "@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n\nfn ssrDepthHistoryCopy_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let depth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n return vec4f(depth, 0.0, 0.0, 1.0);\n}";
|
|
514
|
+
readonly bindingLayout: readonly [{
|
|
515
|
+
readonly name: "depthTexture";
|
|
516
|
+
readonly group: 0;
|
|
517
|
+
}];
|
|
518
|
+
readonly passes: [{
|
|
519
|
+
readonly sampler: true;
|
|
520
|
+
}];
|
|
521
|
+
};
|
|
522
|
+
readonly inputs: {
|
|
523
|
+
readonly sourceTexture: "previous";
|
|
524
|
+
};
|
|
525
|
+
readonly output: "ssrHistoryDepth";
|
|
526
|
+
}, {
|
|
527
|
+
readonly kind: "sample";
|
|
528
|
+
readonly module: {
|
|
529
|
+
readonly name: "ssrSpatial";
|
|
530
|
+
readonly source: "struct SSRSpatialUniforms {\n inverseProjectionMatrix: mat4x4f,\n direction: vec2f,\n maxRadius: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrSpatial: SSRSpatialUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrSpatial_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrSpatial.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrSpatial_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centerReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let centerNormalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0);\n let roughness = clamp(centerNormalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return vec4f(0.0);\n }\n let centerViewDepth = ssrSpatial_reconstructViewDepth(texCoord, centerDepth);\n let hasCenterReflection = centerReflection.a > 0.001;\n if (!hasCenterReflection && roughness >= 0.28) {\n return centerReflection;\n }\n let minimumRadius = select(5.0, 0.95, hasCenterReflection);\n let radius = clamp(\n max(roughness * roughness * ssrSpatial.maxRadius, minimumRadius),\n minimumRadius,\n 6.0\n );\n\n let centerNormal = normalize(centerNormalRoughness.rgb * 2.0 - 1.0);\n let texel = ssrSpatial.direction / vec2f(textureDimensions(sourceTexture));\n let centerWeight = select(0.0, 1.0, hasCenterReflection);\n var reflection = centerReflection * centerWeight;\n var totalWeight = centerWeight;\n var supportingSampleCount = 0u;\n for (var sampleIndex: i32 = 1; sampleIndex <= 6; sampleIndex++) {\n if (f32(sampleIndex) > ceil(radius)) {\n break;\n }\n for (var side: i32 = -1; side <= 1; side += 2) {\n let sampleCoord = clamp(\n texCoord + texel * f32(sampleIndex * side),\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let sampleViewDepth = ssrSpatial_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrSpatial.depthSigma * ssrSpatial.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 16.0);\n let distanceWeight = exp(\n -f32(sampleIndex * sampleIndex) / max(2.0 * radius * radius, 0.1)\n );\n let sampleReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoord, 0);\n let confidenceWeight = smoothstep(0.001, 0.12, sampleReflection.a);\n let belongsToSamePlane = dot(centerNormal, sampleNormal) > 0.9995;\n let surfaceWeight = select(0.0, 1.0, hasCenterReflection || belongsToSamePlane);\n let weight = depthWeight * normalWeight * distanceWeight * confidenceWeight * surfaceWeight;\n if (weight > 0.001) {\n supportingSampleCount += 1u;\n }\n reflection += sampleReflection * weight;\n totalWeight += weight;\n }\n }\n\n if ((!hasCenterReflection && supportingSampleCount < 2u) || totalWeight <= 0.0001) {\n return centerReflection;\n }\n return reflection / totalWeight;\n}";
|
|
531
|
+
readonly bindingLayout: readonly [{
|
|
532
|
+
readonly name: "depthTexture";
|
|
533
|
+
readonly group: 0;
|
|
534
|
+
}, {
|
|
535
|
+
readonly name: "normalTexture";
|
|
536
|
+
readonly group: 0;
|
|
537
|
+
}];
|
|
538
|
+
readonly props: Partial<SSRSpatialUniforms> & SSRSpatialBindings;
|
|
539
|
+
readonly uniforms: SSRSpatialUniforms;
|
|
540
|
+
readonly bindings: SSRSpatialBindings;
|
|
541
|
+
readonly uniformTypes: {
|
|
542
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
543
|
+
readonly direction: "vec2<f32>";
|
|
544
|
+
readonly maxRadius: "f32";
|
|
545
|
+
readonly depthSigma: "f32";
|
|
546
|
+
};
|
|
547
|
+
readonly propTypes: {
|
|
548
|
+
readonly inverseProjectionMatrix: {
|
|
549
|
+
readonly value: NumberArray16;
|
|
550
|
+
readonly private: true;
|
|
551
|
+
};
|
|
552
|
+
readonly direction: {
|
|
553
|
+
readonly value: readonly [1, 0];
|
|
554
|
+
};
|
|
555
|
+
readonly maxRadius: {
|
|
556
|
+
readonly value: 5;
|
|
557
|
+
readonly min: 0;
|
|
558
|
+
readonly max: 8;
|
|
559
|
+
};
|
|
560
|
+
readonly depthSigma: {
|
|
561
|
+
readonly value: 0.035;
|
|
562
|
+
readonly min: 0.0001;
|
|
563
|
+
readonly softMax: 0.2;
|
|
564
|
+
};
|
|
565
|
+
};
|
|
566
|
+
readonly passes: [{
|
|
567
|
+
readonly sampler: true;
|
|
568
|
+
}];
|
|
569
|
+
};
|
|
570
|
+
readonly inputs: {
|
|
571
|
+
readonly sourceTexture: "ssrHistory";
|
|
572
|
+
};
|
|
573
|
+
readonly output: "ssrScratch";
|
|
574
|
+
readonly uniforms: {
|
|
575
|
+
readonly direction: readonly [1, 0];
|
|
576
|
+
};
|
|
577
|
+
}, {
|
|
578
|
+
readonly kind: "sample";
|
|
579
|
+
readonly module: {
|
|
580
|
+
readonly name: "ssrSpatial";
|
|
581
|
+
readonly source: "struct SSRSpatialUniforms {\n inverseProjectionMatrix: mat4x4f,\n direction: vec2f,\n maxRadius: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrSpatial: SSRSpatialUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrSpatial_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrSpatial.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrSpatial_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centerReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let centerNormalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0);\n let roughness = clamp(centerNormalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return vec4f(0.0);\n }\n let centerViewDepth = ssrSpatial_reconstructViewDepth(texCoord, centerDepth);\n let hasCenterReflection = centerReflection.a > 0.001;\n if (!hasCenterReflection && roughness >= 0.28) {\n return centerReflection;\n }\n let minimumRadius = select(5.0, 0.95, hasCenterReflection);\n let radius = clamp(\n max(roughness * roughness * ssrSpatial.maxRadius, minimumRadius),\n minimumRadius,\n 6.0\n );\n\n let centerNormal = normalize(centerNormalRoughness.rgb * 2.0 - 1.0);\n let texel = ssrSpatial.direction / vec2f(textureDimensions(sourceTexture));\n let centerWeight = select(0.0, 1.0, hasCenterReflection);\n var reflection = centerReflection * centerWeight;\n var totalWeight = centerWeight;\n var supportingSampleCount = 0u;\n for (var sampleIndex: i32 = 1; sampleIndex <= 6; sampleIndex++) {\n if (f32(sampleIndex) > ceil(radius)) {\n break;\n }\n for (var side: i32 = -1; side <= 1; side += 2) {\n let sampleCoord = clamp(\n texCoord + texel * f32(sampleIndex * side),\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let sampleViewDepth = ssrSpatial_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrSpatial.depthSigma * ssrSpatial.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 16.0);\n let distanceWeight = exp(\n -f32(sampleIndex * sampleIndex) / max(2.0 * radius * radius, 0.1)\n );\n let sampleReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoord, 0);\n let confidenceWeight = smoothstep(0.001, 0.12, sampleReflection.a);\n let belongsToSamePlane = dot(centerNormal, sampleNormal) > 0.9995;\n let surfaceWeight = select(0.0, 1.0, hasCenterReflection || belongsToSamePlane);\n let weight = depthWeight * normalWeight * distanceWeight * confidenceWeight * surfaceWeight;\n if (weight > 0.001) {\n supportingSampleCount += 1u;\n }\n reflection += sampleReflection * weight;\n totalWeight += weight;\n }\n }\n\n if ((!hasCenterReflection && supportingSampleCount < 2u) || totalWeight <= 0.0001) {\n return centerReflection;\n }\n return reflection / totalWeight;\n}";
|
|
582
|
+
readonly bindingLayout: readonly [{
|
|
583
|
+
readonly name: "depthTexture";
|
|
584
|
+
readonly group: 0;
|
|
585
|
+
}, {
|
|
586
|
+
readonly name: "normalTexture";
|
|
587
|
+
readonly group: 0;
|
|
588
|
+
}];
|
|
589
|
+
readonly props: Partial<SSRSpatialUniforms> & SSRSpatialBindings;
|
|
590
|
+
readonly uniforms: SSRSpatialUniforms;
|
|
591
|
+
readonly bindings: SSRSpatialBindings;
|
|
592
|
+
readonly uniformTypes: {
|
|
593
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
594
|
+
readonly direction: "vec2<f32>";
|
|
595
|
+
readonly maxRadius: "f32";
|
|
596
|
+
readonly depthSigma: "f32";
|
|
597
|
+
};
|
|
598
|
+
readonly propTypes: {
|
|
599
|
+
readonly inverseProjectionMatrix: {
|
|
600
|
+
readonly value: NumberArray16;
|
|
601
|
+
readonly private: true;
|
|
602
|
+
};
|
|
603
|
+
readonly direction: {
|
|
604
|
+
readonly value: readonly [1, 0];
|
|
605
|
+
};
|
|
606
|
+
readonly maxRadius: {
|
|
607
|
+
readonly value: 5;
|
|
608
|
+
readonly min: 0;
|
|
609
|
+
readonly max: 8;
|
|
610
|
+
};
|
|
611
|
+
readonly depthSigma: {
|
|
612
|
+
readonly value: 0.035;
|
|
613
|
+
readonly min: 0.0001;
|
|
614
|
+
readonly softMax: 0.2;
|
|
615
|
+
};
|
|
616
|
+
};
|
|
617
|
+
readonly passes: [{
|
|
618
|
+
readonly sampler: true;
|
|
619
|
+
}];
|
|
620
|
+
};
|
|
621
|
+
readonly inputs: {
|
|
622
|
+
readonly sourceTexture: "ssrScratch";
|
|
623
|
+
};
|
|
624
|
+
readonly output: "ssrReflection";
|
|
625
|
+
readonly uniforms: {
|
|
626
|
+
readonly direction: readonly [0, 1];
|
|
627
|
+
};
|
|
628
|
+
}, {
|
|
629
|
+
readonly kind: "sample";
|
|
630
|
+
readonly module: {
|
|
631
|
+
readonly name: "ssrComposite";
|
|
632
|
+
readonly source: "struct SSRCompositeUniforms {\n inverseProjectionMatrix: mat4x4f,\n strength: f32,\n debugMode: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrComposite: SSRCompositeUniforms;\n@group(0) @binding(auto) var reflectionTexture: texture_2d<f32>;\n@group(0) @binding(auto) var reflectionTextureSampler: sampler;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrComposite_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrComposite.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrComposite_upsampleReflection(texCoord: vec2f) -> vec4f {\n let reflectionSize = vec2f(textureDimensions(reflectionTexture));\n let reflectionPosition = texCoord * reflectionSize - vec2f(0.5);\n let reflectionBase = vec2i(floor(reflectionPosition));\n let reflectionFraction = fract(reflectionPosition);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return textureSampleLevel(reflectionTexture, reflectionTextureSampler, texCoord, 0);\n }\n let centerViewDepth = ssrComposite_reconstructViewDepth(texCoord, centerDepth);\n let centerNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0).rgb * 2.0 - 1.0\n );\n\n var reflection = vec4f(0.0);\n var totalWeight = 0.0;\n for (var sampleY: i32 = 0; sampleY <= 1; sampleY++) {\n for (var sampleX: i32 = 0; sampleX <= 1; sampleX++) {\n let reflectionPixel = clamp(\n reflectionBase + vec2i(sampleX, sampleY),\n vec2i(0),\n vec2i(reflectionSize) - vec2i(1)\n );\n let sampleCoord = (vec2f(reflectionPixel) + vec2f(0.5)) / reflectionSize;\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let horizontalWeight = select(\n 1.0 - reflectionFraction.x,\n reflectionFraction.x,\n sampleX == 1\n );\n let verticalWeight = select(\n 1.0 - reflectionFraction.y,\n reflectionFraction.y,\n sampleY == 1\n );\n let sampleViewDepth = ssrComposite_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrComposite.depthSigma * ssrComposite.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 12.0);\n let weight = horizontalWeight * verticalWeight * depthWeight * normalWeight;\n reflection += textureLoad(reflectionTexture, reflectionPixel, 0) * weight;\n totalWeight += weight;\n }\n }\n return reflection / max(totalWeight, 0.00001);\n}\n\nfn ssrComposite_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let color = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let reflection = ssrComposite_upsampleReflection(texCoord);\n if (ssrComposite.debugMode > 1.5) {\n let confidence = clamp(reflection.a, 0.0, 1.0);\n let lowConfidence = vec3f(0.045, 0.08, 0.22);\n let highConfidence = vec3f(1.0, 0.7, 0.16);\n return vec4f(mix(lowConfidence, highConfidence, confidence), 1.0);\n }\n if (ssrComposite.debugMode > 0.5) {\n return vec4f(reflection.rgb * reflection.a, 1.0);\n }\n let reflectionWeight = clamp(reflection.a * ssrComposite.strength, 0.0, 1.0);\n return vec4f(color.rgb + reflection.rgb * reflectionWeight, color.a);\n}";
|
|
633
|
+
readonly bindingLayout: readonly [{
|
|
634
|
+
readonly name: "reflectionTexture";
|
|
635
|
+
readonly group: 0;
|
|
636
|
+
}, {
|
|
637
|
+
readonly name: "depthTexture";
|
|
638
|
+
readonly group: 0;
|
|
639
|
+
}, {
|
|
640
|
+
readonly name: "normalTexture";
|
|
641
|
+
readonly group: 0;
|
|
642
|
+
}];
|
|
643
|
+
readonly props: Partial<SSRCompositeUniforms> & SSRCompositeBindings;
|
|
644
|
+
readonly uniforms: SSRCompositeUniforms;
|
|
645
|
+
readonly bindings: SSRCompositeBindings;
|
|
646
|
+
readonly uniformTypes: {
|
|
647
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
648
|
+
readonly strength: "f32";
|
|
649
|
+
readonly debugMode: "f32";
|
|
650
|
+
readonly depthSigma: "f32";
|
|
651
|
+
};
|
|
652
|
+
readonly propTypes: {
|
|
653
|
+
readonly inverseProjectionMatrix: {
|
|
654
|
+
readonly value: NumberArray16;
|
|
655
|
+
readonly private: true;
|
|
656
|
+
};
|
|
657
|
+
readonly strength: {
|
|
658
|
+
readonly value: 1;
|
|
659
|
+
readonly min: 0;
|
|
660
|
+
readonly softMax: 2;
|
|
661
|
+
};
|
|
662
|
+
readonly debugMode: {
|
|
663
|
+
readonly value: 0;
|
|
664
|
+
readonly min: 0;
|
|
665
|
+
readonly max: 2;
|
|
666
|
+
readonly private: true;
|
|
667
|
+
};
|
|
668
|
+
readonly depthSigma: {
|
|
669
|
+
readonly value: 0.04;
|
|
670
|
+
readonly min: 0.0001;
|
|
671
|
+
readonly softMax: 0.2;
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
readonly passes: [{
|
|
675
|
+
readonly sampler: true;
|
|
676
|
+
}];
|
|
677
|
+
};
|
|
678
|
+
readonly inputs: {
|
|
679
|
+
readonly sourceTexture: "previous";
|
|
680
|
+
readonly reflectionTexture: "ssrReflection";
|
|
681
|
+
};
|
|
682
|
+
}];
|
|
683
|
+
readonly variants: {
|
|
684
|
+
readonly option: "reprojection";
|
|
685
|
+
readonly values: {
|
|
686
|
+
readonly camera: {
|
|
687
|
+
readonly resources: {
|
|
688
|
+
readonly ssrHistoryDepth: {
|
|
689
|
+
readonly format: "rgba8unorm";
|
|
690
|
+
readonly lifetime: "history";
|
|
691
|
+
readonly initialize: {
|
|
692
|
+
readonly clearColor: [1, 1, 1, 1];
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
readonly ssrHistoryNormal: {
|
|
696
|
+
readonly format: "rgba8unorm";
|
|
697
|
+
readonly lifetime: "history";
|
|
698
|
+
readonly initialize: {
|
|
699
|
+
readonly clearColor: [0.5, 0.5, 1, 1];
|
|
700
|
+
};
|
|
701
|
+
};
|
|
702
|
+
readonly ssrRaw: {
|
|
703
|
+
readonly scale: [1, 1];
|
|
704
|
+
readonly format: "rgba16float";
|
|
705
|
+
};
|
|
706
|
+
readonly ssrHistory: {
|
|
707
|
+
readonly scale: [1, 1];
|
|
708
|
+
readonly format: "rgba16float";
|
|
709
|
+
readonly lifetime: "history";
|
|
710
|
+
readonly initialize: {
|
|
711
|
+
readonly clearColor: [0, 0, 0, 0];
|
|
712
|
+
};
|
|
713
|
+
};
|
|
714
|
+
readonly ssrScratch: {
|
|
715
|
+
readonly scale: [1, 1];
|
|
716
|
+
readonly format: "rgba16float";
|
|
717
|
+
};
|
|
718
|
+
readonly ssrReflection: {
|
|
719
|
+
readonly scale: [1, 1];
|
|
720
|
+
readonly format: "rgba16float";
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
readonly passes: [{
|
|
724
|
+
readonly kind: "sample";
|
|
725
|
+
readonly module: {
|
|
726
|
+
readonly name: "ssrTrace";
|
|
727
|
+
readonly source: "const SSR_TWO_PI: f32 = 6.283185307179586;\n\nstruct SSRTraceUniforms {\n projectionMatrix: mat4x4f,\n inverseProjectionMatrix: mat4x4f,\n intensity: f32,\n maxDistance: f32,\n thickness: f32,\n sampleCount: f32,\n maxRoughness: f32,\n frameIndex: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrTrace: SSRTraceUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrTrace_reconstructViewPosition(uv: vec2f, depth: f32) -> vec3f {\n let clip = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, depth, 1.0);\n let viewPosition = ssrTrace.inverseProjectionMatrix * clip;\n return viewPosition.xyz / max(viewPosition.w, 0.00001);\n}\n\nfn ssrTrace_projectViewPosition(position: vec3f) -> vec2f {\n let clip = ssrTrace.projectionMatrix * vec4f(position, 1.0);\n let normalizedDeviceCoordinate = clip.xy / max(clip.w, 0.00001);\n return vec2f(\n normalizedDeviceCoordinate.x * 0.5 + 0.5,\n 0.5 - normalizedDeviceCoordinate.y * 0.5\n );\n}\n\nfn ssrTrace_hash(value: vec2f, frameIndex: f32) -> f32 {\n let temporalPhase = fract(frameIndex * 0.61803398875) * SSR_TWO_PI;\n return fract(sin(dot(value, vec2f(12.9898, 78.233)) + temporalPhase) * 43758.5453);\n}\n\nfn ssrTrace_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let sceneCoord = texCoord;\n let normalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, sceneCoord, 0);\n let normal = normalize(normalRoughness.xyz * 2.0 - 1.0);\n let roughness = clamp(normalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, sceneCoord, 0);\n if (centerDepth >= 0.99999 || roughness >= ssrTrace.maxRoughness ||\n ssrTrace.intensity <= 0.0001) {\n return vec4f(0.0);\n }\n\n let viewPosition = ssrTrace_reconstructViewPosition(sceneCoord, centerDepth);\n let incidentDirection = normalize(viewPosition);\n let mirrorDirection = normalize(reflect(incidentDirection, normal));\n let pixelCoordinate = floor(sceneCoord * vec2f(textureDimensions(depthTexture)));\n let noise = ssrTrace_hash(pixelCoordinate, ssrTrace.frameIndex);\n let noiseAngle = noise * SSR_TWO_PI;\n let referenceAxis = select(\n vec3f(0.0, 1.0, 0.0),\n vec3f(1.0, 0.0, 0.0),\n abs(mirrorDirection.y) > 0.9\n );\n let tangent = normalize(cross(referenceAxis, mirrorDirection));\n let bitangent = normalize(cross(mirrorDirection, tangent));\n let roughnessCone = roughness * roughness * 0.32;\n let reflectedRay = normalize(\n mirrorDirection + (tangent * cos(noiseAngle) + bitangent * sin(noiseAngle)) * roughnessCone\n );\n let rayOrigin = viewPosition + normal * max(ssrTrace.thickness * 0.12, 0.025);\n\n var reflection = vec3f(0.0);\n var confidence = 0.0;\n var previousTravel = 0.06;\n var previousDepthDelta = -ssrTrace.thickness;\n let minimumSampleCount = ceil(\n ssrTrace.maxDistance / max(ssrTrace.thickness * 0.72, 0.12)\n );\n let effectiveSampleCount = min(96.0, max(ssrTrace.sampleCount, minimumSampleCount));\n for (var sampleIndex: i32 = 1; sampleIndex <= 96; sampleIndex++) {\n if (f32(sampleIndex) > effectiveSampleCount) {\n break;\n }\n let fraction = (f32(sampleIndex) - noise * 0.42) / max(effectiveSampleCount, 1.0);\n let travel = 0.08 + pow(max(fraction, 0.0), 1.3) * ssrTrace.maxDistance;\n let rayPosition = rayOrigin + reflectedRay * travel;\n if (rayPosition.z >= -0.04) {\n break;\n }\n let sampleCoord = ssrTrace_projectViewPosition(rayPosition);\n if (any(sampleCoord <= vec2f(0.0)) || any(sampleCoord >= vec2f(1.0))) {\n break;\n }\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n if (sampleDepth >= 0.99999) {\n previousTravel = travel;\n previousDepthDelta = -ssrTrace.thickness;\n continue;\n }\n let scenePosition = ssrTrace_reconstructViewPosition(sampleCoord, sampleDepth);\n let depthDelta = (-rayPosition.z) - (-scenePosition.z);\n let rayStepLength = max(travel - previousTravel, 0.001);\n let hitThickness = max(ssrTrace.thickness, rayStepLength * 1.2) + travel * 0.008;\n let crossesCandidateSurface = previousDepthDelta <= 0.0 && depthDelta >= 0.0;\n let screenTravelPixels = length((sampleCoord - sceneCoord) * texSize);\n var entersCandidateSurface = true;\n if (crossesCandidateSurface && depthDelta < hitThickness && screenTravelPixels > 1.25) {\n let candidateNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n entersCandidateSurface = dot(reflectedRay, candidateNormal) < -0.015;\n if (entersCandidateSurface) {\n var nearTravel = previousTravel;\n var farTravel = travel;\n var hitCoord = sampleCoord;\n for (var refinementIndex: i32 = 0; refinementIndex < 5; refinementIndex++) {\n let refinedTravel = (nearTravel + farTravel) * 0.5;\n let refinedPosition = rayOrigin + reflectedRay * refinedTravel;\n let refinedCoord = ssrTrace_projectViewPosition(refinedPosition);\n let refinedDepth = textureSampleLevel(depthTexture, depthTextureSampler, refinedCoord, 0);\n let refinedScenePosition = ssrTrace_reconstructViewPosition(refinedCoord, refinedDepth);\n if ((-refinedPosition.z) - (-refinedScenePosition.z) >= 0.0) {\n farTravel = refinedTravel;\n hitCoord = refinedCoord;\n } else {\n nearTravel = refinedTravel;\n }\n }\n reflection = textureSampleLevel(sourceTexture, sourceTextureSampler, hitCoord, 0).rgb;\n let screenEdge = min(\n min(hitCoord.x, hitCoord.y),\n min(1.0 - hitCoord.x, 1.0 - hitCoord.y)\n );\n let fresnel = mix(\n 0.32,\n 1.0,\n pow(1.0 - max(dot(-incidentDirection, normal), 0.0), 5.0)\n );\n let roughnessFade = pow(1.0 - roughness / max(ssrTrace.maxRoughness, 0.001), 1.5);\n let distanceFade = 1.0 - clamp(farTravel / ssrTrace.maxDistance, 0.0, 1.0);\n confidence = smoothstep(0.0, 0.09, screenEdge) * roughnessFade * fresnel *\n distanceFade * ssrTrace.intensity;\n break;\n }\n }\n previousTravel = travel;\n previousDepthDelta = select(-ssrTrace.thickness, depthDelta, entersCandidateSurface);\n }\n\n return vec4f(reflection, clamp(confidence, 0.0, 1.0));\n}";
|
|
728
|
+
readonly bindingLayout: readonly [{
|
|
729
|
+
readonly name: "depthTexture";
|
|
730
|
+
readonly group: 0;
|
|
731
|
+
}, {
|
|
732
|
+
readonly name: "normalTexture";
|
|
733
|
+
readonly group: 0;
|
|
734
|
+
}];
|
|
735
|
+
readonly props: Partial<SSRTraceUniforms> & SSRTraceBindings;
|
|
736
|
+
readonly uniforms: SSRTraceUniforms;
|
|
737
|
+
readonly bindings: SSRTraceBindings;
|
|
738
|
+
readonly uniformTypes: {
|
|
739
|
+
readonly projectionMatrix: "mat4x4<f32>";
|
|
740
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
741
|
+
readonly intensity: "f32";
|
|
742
|
+
readonly maxDistance: "f32";
|
|
743
|
+
readonly thickness: "f32";
|
|
744
|
+
readonly sampleCount: "f32";
|
|
745
|
+
readonly maxRoughness: "f32";
|
|
746
|
+
readonly frameIndex: "f32";
|
|
747
|
+
};
|
|
748
|
+
readonly propTypes: {
|
|
749
|
+
readonly projectionMatrix: {
|
|
750
|
+
readonly value: NumberArray16;
|
|
751
|
+
readonly private: true;
|
|
752
|
+
};
|
|
753
|
+
readonly inverseProjectionMatrix: {
|
|
754
|
+
readonly value: NumberArray16;
|
|
755
|
+
readonly private: true;
|
|
756
|
+
};
|
|
757
|
+
readonly intensity: {
|
|
758
|
+
readonly value: 1.35;
|
|
759
|
+
readonly min: 0;
|
|
760
|
+
readonly softMax: 4;
|
|
761
|
+
};
|
|
762
|
+
readonly maxDistance: {
|
|
763
|
+
readonly value: 60;
|
|
764
|
+
readonly min: 1;
|
|
765
|
+
readonly softMax: 180;
|
|
766
|
+
};
|
|
767
|
+
readonly thickness: {
|
|
768
|
+
readonly value: 0.45;
|
|
769
|
+
readonly min: 0.02;
|
|
770
|
+
readonly softMax: 3;
|
|
771
|
+
};
|
|
772
|
+
readonly sampleCount: {
|
|
773
|
+
readonly value: 48;
|
|
774
|
+
readonly min: 8;
|
|
775
|
+
readonly max: 96;
|
|
776
|
+
};
|
|
777
|
+
readonly maxRoughness: {
|
|
778
|
+
readonly value: 0.88;
|
|
779
|
+
readonly min: 0.1;
|
|
780
|
+
readonly max: 1;
|
|
781
|
+
};
|
|
782
|
+
readonly frameIndex: {
|
|
783
|
+
readonly value: 0;
|
|
784
|
+
readonly private: true;
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
readonly passes: [{
|
|
788
|
+
readonly sampler: true;
|
|
789
|
+
}];
|
|
790
|
+
};
|
|
791
|
+
readonly inputs: {
|
|
792
|
+
readonly sourceTexture: "previous";
|
|
793
|
+
};
|
|
794
|
+
readonly output: "ssrRaw";
|
|
795
|
+
}, {
|
|
796
|
+
readonly kind: "sample";
|
|
797
|
+
readonly module: {
|
|
798
|
+
readonly name: "ssrCameraTemporal";
|
|
799
|
+
readonly source: "\n\nfn temporal_getTexelCoordinate(coordinate: vec2f, dimensions: vec2u) -> vec2i {\n return clamp(vec2i(coordinate * vec2f(dimensions)), vec2i(0), vec2i(dimensions) - vec2i(1));\n}\n\nfn temporal_getClipPosition(coordinate: vec2f, depth: f32) -> vec4f {\n return vec4f(coordinate * vec2f(2.0, -2.0) + vec2f(-1.0, 1.0), depth, 1.0);\n}\n\n// Returns previous UV, device depth, and validity. Matrices use WebGPU clip depth.\nfn temporal_getPreviousFrame(previousClip: vec4f, jitter: vec2f, epsilon: f32) -> vec4f {\n if (previousClip.w <= epsilon) { return vec4f(0.0); }\n let position = previousClip.xyz / previousClip.w;\n let coordinate = position.xy * vec2f(0.5, -0.5) + vec2f(0.5) + jitter;\n let valid = all(coordinate >= vec2f(0.0)) && all(coordinate <= vec2f(1.0)) &&\n position.z >= 0.0 && position.z <= 1.0;\n return vec4f(coordinate, position.z, select(0.0, 1.0, valid));\n}\n\nfn temporal_getViewDepth(\n coordinate: vec2f, depth: f32, inverseProjection: mat4x4f, epsilon: f32\n) -> f32 {\n let position = inverseProjection * temporal_getClipPosition(coordinate, depth);\n return abs(position.z / max(abs(position.w), epsilon));\n}\n\nstruct TemporalColorBounds { minimum: vec4f, maximum: vec4f };\nfn temporal_getColorBounds(\n sourceTexture: texture_2d<f32>, sourceTextureSampler: sampler,\n coordinate: vec2f, current: vec4f\n) -> TemporalColorBounds {\n let texel = 1.0 / vec2f(textureDimensions(sourceTexture));\n var minimum = current;\n var maximum = current;\n for (var vertical = -1; vertical <= 1; vertical++) {\n for (var horizontal = -1; horizontal <= 1; horizontal++) {\n let sampleCoordinate = clamp(coordinate + vec2f(f32(horizontal), f32(vertical)) * texel,\n vec2f(0.0), vec2f(1.0));\n let sample = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoordinate, 0);\n minimum = min(minimum, sample);\n maximum = max(maximum, sample);\n }\n }\n return TemporalColorBounds(minimum, maximum);\n}\n\nstruct TemporalHistoryFootprint { base: vec2i, fraction: vec2f, dimensions: vec2u };\nstruct TemporalHistoryTap { coordinate: vec2i, normalizedCoordinate: vec2f, weight: f32 };\nfn temporal_getHistoryFootprint(coordinate: vec2f, dimensions: vec2u) -> TemporalHistoryFootprint {\n let position = coordinate * vec2f(dimensions) - vec2f(0.5);\n return TemporalHistoryFootprint(vec2i(floor(position)), fract(position), dimensions);\n}\nfn temporal_getHistoryTap(footprint: TemporalHistoryFootprint, offset: vec2i) -> TemporalHistoryTap {\n let coordinate = clamp(footprint.base + offset, vec2i(0), vec2i(footprint.dimensions) - vec2i(1));\n let horizontalWeight = select(1.0 - footprint.fraction.x, footprint.fraction.x, offset.x == 1);\n let verticalWeight = select(1.0 - footprint.fraction.y, footprint.fraction.y, offset.y == 1);\n return TemporalHistoryTap(coordinate,\n (vec2f(coordinate) + vec2f(0.5)) / vec2f(footprint.dimensions), horizontalWeight * verticalWeight);\n}\n\nstruct SSRCameraTemporalUniforms {\n currentClipToPreviousClip: mat4x4f,\n currentViewToPreviousView: mat4x4f,\n previousInverseProjectionMatrix: mat4x4f,\n historyWeight: f32,\n depthThreshold: f32,\n normalThreshold: f32,\n};\n@group(0) @binding(auto) var<uniform> ssrCameraTemporal: SSRCameraTemporalUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var historyTexture: texture_2d<f32>;\n@group(0) @binding(auto) var previousDepthTexture: texture_2d<f32>;\n@group(0) @binding(auto) var previousNormalTexture: texture_2d<f32>;\n\nfn ssrCameraTemporal_sampleColor(\n sourceTexture: texture_2d<f32>, sourceTextureSampler: sampler,\n texSize: vec2f, texCoord: vec2f\n) -> vec4f {\n let current = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let currentDepth = textureLoad(depthTexture,\n temporal_getTexelCoordinate(texCoord, textureDimensions(depthTexture)), 0);\n if (currentDepth >= 0.99999 || ssrCameraTemporal.historyWeight <= 0.0) {return current;}\n let previousClip = ssrCameraTemporal.currentClipToPreviousClip *\n temporal_getClipPosition(texCoord, currentDepth);\n let previousFrame = temporal_getPreviousFrame(previousClip, vec2f(0.0), 0.000001);\n if (previousFrame.w < 0.5 || previousFrame.z >= 1.0) {return current;}\n let previousCoordinate = previousFrame.xy;\n let currentSurface = textureLoad(normalTexture,\n temporal_getTexelCoordinate(texCoord, textureDimensions(normalTexture)), 0);\n let expectedNormal = normalize((ssrCameraTemporal.currentViewToPreviousView *\n vec4f(currentSurface.xyz * 2.0 - 1.0, 0.0)).xyz);\n let expectedDepth = temporal_getViewDepth(previousCoordinate, previousFrame.z,\n ssrCameraTemporal.previousInverseProjectionMatrix, 0.000001);\n let footprint = temporal_getHistoryFootprint(previousCoordinate, textureDimensions(historyTexture));\n var accumulatedHistory = vec4f(0.0);\n var accumulatedWeight = 0.0;\n // Validate each bilinear tap before mixing to avoid borrowing a foreground edge's history.\n for (var vertical = 0; vertical < 2; vertical++) {\n for (var horizontal = 0; horizontal < 2; horizontal++) {\n let tap = temporal_getHistoryTap(footprint, vec2i(horizontal, vertical));\n let tapCoordinate = tap.normalizedCoordinate;\n let packedDepth = textureLoad(previousDepthTexture,\n temporal_getTexelCoordinate(tapCoordinate, textureDimensions(previousDepthTexture)), 0).rgb;\n let depth = dot(round(packedDepth * 255.0), vec3f(65536.0, 256.0, 1.0)) / 16777215.0;\n let surface = textureLoad(previousNormalTexture,\n temporal_getTexelCoordinate(tapCoordinate, textureDimensions(previousNormalTexture)), 0);\n let normal = normalize(surface.xyz * 2.0 - 1.0);\n let depthDifference = abs(temporal_getViewDepth(tapCoordinate, depth,\n ssrCameraTemporal.previousInverseProjectionMatrix, 0.000001) - expectedDepth) /\n max(expectedDepth, 0.000001);\n let valid = depth < 0.99999 && depthDifference <= ssrCameraTemporal.depthThreshold &&\n dot(normal, expectedNormal) >= ssrCameraTemporal.normalThreshold &&\n abs(surface.a - currentSurface.a) < 0.05;\n let weight = select(0.0, tap.weight, valid);\n accumulatedHistory += textureLoad(historyTexture, tap.coordinate, 0) * weight;\n accumulatedWeight += weight;\n }\n }\n if (accumulatedWeight <= 0.000001) {return current;}\n let history = accumulatedHistory / accumulatedWeight;\n let bounds = temporal_getColorBounds(sourceTexture, sourceTextureSampler, texCoord, current);\n // Missing rays may retain confidence briefly, but never increase it without current support.\n let weight = clamp(ssrCameraTemporal.historyWeight, 0.0, 0.97);\n if (bounds.maximum.a <= 0.001) {return vec4f(history.rgb, history.a * weight);}\n return mix(current, clamp(history, bounds.minimum, bounds.maximum), weight);\n}\n";
|
|
800
|
+
readonly bindingLayout: readonly [{
|
|
801
|
+
readonly name: "depthTexture";
|
|
802
|
+
readonly group: 0;
|
|
803
|
+
}, {
|
|
804
|
+
readonly name: "normalTexture";
|
|
805
|
+
readonly group: 0;
|
|
806
|
+
}, {
|
|
807
|
+
readonly name: "historyTexture";
|
|
808
|
+
readonly group: 0;
|
|
809
|
+
}, {
|
|
810
|
+
readonly name: "previousDepthTexture";
|
|
811
|
+
readonly group: 0;
|
|
812
|
+
}, {
|
|
813
|
+
readonly name: "previousNormalTexture";
|
|
814
|
+
readonly group: 0;
|
|
815
|
+
}];
|
|
816
|
+
readonly props: Partial<import("./ssr-camera-temporal").SSRCameraTemporalUniforms> & {
|
|
817
|
+
depthTexture?: Texture;
|
|
818
|
+
normalTexture?: Texture;
|
|
819
|
+
historyTexture?: Texture;
|
|
820
|
+
previousDepthTexture?: Texture;
|
|
821
|
+
previousNormalTexture?: Texture;
|
|
822
|
+
};
|
|
823
|
+
readonly uniforms: import("./ssr-camera-temporal").SSRCameraTemporalUniforms;
|
|
824
|
+
readonly bindings: {
|
|
825
|
+
depthTexture?: Texture;
|
|
826
|
+
normalTexture?: Texture;
|
|
827
|
+
historyTexture?: Texture;
|
|
828
|
+
previousDepthTexture?: Texture;
|
|
829
|
+
previousNormalTexture?: Texture;
|
|
830
|
+
};
|
|
831
|
+
readonly uniformTypes: {
|
|
832
|
+
readonly currentClipToPreviousClip: "mat4x4<f32>";
|
|
833
|
+
readonly currentViewToPreviousView: "mat4x4<f32>";
|
|
834
|
+
readonly previousInverseProjectionMatrix: "mat4x4<f32>";
|
|
835
|
+
readonly historyWeight: "f32";
|
|
836
|
+
readonly depthThreshold: "f32";
|
|
837
|
+
readonly normalThreshold: "f32";
|
|
838
|
+
};
|
|
839
|
+
readonly propTypes: {
|
|
840
|
+
readonly currentClipToPreviousClip: {
|
|
841
|
+
readonly value: NumberArray16;
|
|
842
|
+
readonly private: true;
|
|
843
|
+
};
|
|
844
|
+
readonly currentViewToPreviousView: {
|
|
845
|
+
readonly value: NumberArray16;
|
|
846
|
+
readonly private: true;
|
|
847
|
+
};
|
|
848
|
+
readonly previousInverseProjectionMatrix: {
|
|
849
|
+
readonly value: NumberArray16;
|
|
850
|
+
readonly private: true;
|
|
851
|
+
};
|
|
852
|
+
readonly historyWeight: {
|
|
853
|
+
readonly value: 0.8;
|
|
854
|
+
readonly min: 0;
|
|
855
|
+
readonly max: 0.97;
|
|
856
|
+
};
|
|
857
|
+
readonly depthThreshold: {
|
|
858
|
+
readonly value: 0.01;
|
|
859
|
+
readonly min: 0.0001;
|
|
860
|
+
readonly max: 0.1;
|
|
861
|
+
};
|
|
862
|
+
readonly normalThreshold: {
|
|
863
|
+
readonly value: 0.96;
|
|
864
|
+
readonly min: -1;
|
|
865
|
+
readonly max: 1;
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
readonly passes: [{
|
|
869
|
+
readonly sampler: true;
|
|
870
|
+
}];
|
|
871
|
+
};
|
|
872
|
+
readonly inputs: {
|
|
873
|
+
readonly previousNormalTexture: "ssrHistoryNormal";
|
|
874
|
+
readonly sourceTexture: "ssrRaw";
|
|
875
|
+
readonly historyTexture: "ssrHistory";
|
|
876
|
+
readonly previousDepthTexture: "ssrHistoryDepth";
|
|
877
|
+
};
|
|
878
|
+
readonly output: "ssrHistory";
|
|
879
|
+
}, {
|
|
880
|
+
readonly kind: "sample";
|
|
881
|
+
readonly module: {
|
|
882
|
+
readonly name: "ssrCameraDepthHistoryCopy";
|
|
883
|
+
readonly source: "\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\nfn ssrCameraDepthHistoryCopy_sampleColor(\n sourceTexture: texture_2d<f32>, sourceTextureSampler: sampler,\n texSize: vec2f, texCoord: vec2f\n) -> vec4f {\n let dimensions = textureDimensions(depthTexture);\n let coordinate = clamp(vec2i(texCoord * vec2f(dimensions)), vec2i(0), vec2i(dimensions) - vec2i(1));\n let depth = textureLoad(depthTexture, coordinate, 0);\n let packed = u32(round(clamp(depth, 0.0, 1.0) * 16777215.0));\n return vec4f(vec3f(f32((packed >> 16u) & 255u), f32((packed >> 8u) & 255u), f32(packed & 255u)) / 255.0, 1.0);\n}";
|
|
884
|
+
readonly bindingLayout: readonly [{
|
|
885
|
+
readonly name: "depthTexture";
|
|
886
|
+
readonly group: 0;
|
|
887
|
+
}];
|
|
888
|
+
readonly passes: [{
|
|
889
|
+
readonly sampler: true;
|
|
890
|
+
}];
|
|
891
|
+
};
|
|
892
|
+
readonly inputs: {
|
|
893
|
+
readonly sourceTexture: "previous";
|
|
894
|
+
};
|
|
895
|
+
readonly output: "ssrHistoryDepth";
|
|
896
|
+
}, {
|
|
897
|
+
readonly kind: "sample";
|
|
898
|
+
readonly module: {
|
|
899
|
+
readonly name: "ssrNormalHistoryCopy";
|
|
900
|
+
readonly source: "\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\nfn ssrNormalHistoryCopy_sampleColor(\n sourceTexture: texture_2d<f32>, sourceTextureSampler: sampler,\n texSize: vec2f, texCoord: vec2f\n) -> vec4f {\n let dimensions = textureDimensions(normalTexture);\n let coordinate = clamp(vec2i(texCoord * vec2f(dimensions)), vec2i(0), vec2i(dimensions) - vec2i(1));\n return textureLoad(normalTexture, coordinate, 0);\n}";
|
|
901
|
+
readonly bindingLayout: readonly [{
|
|
902
|
+
readonly name: "normalTexture";
|
|
903
|
+
readonly group: 0;
|
|
904
|
+
}];
|
|
905
|
+
readonly passes: [{
|
|
906
|
+
readonly sampler: true;
|
|
907
|
+
}];
|
|
908
|
+
};
|
|
909
|
+
readonly inputs: {
|
|
910
|
+
readonly sourceTexture: "previous";
|
|
911
|
+
};
|
|
912
|
+
readonly output: "ssrHistoryNormal";
|
|
913
|
+
}, {
|
|
914
|
+
readonly kind: "sample";
|
|
915
|
+
readonly module: {
|
|
916
|
+
readonly name: "ssrSpatial";
|
|
917
|
+
readonly source: "struct SSRSpatialUniforms {\n inverseProjectionMatrix: mat4x4f,\n direction: vec2f,\n maxRadius: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrSpatial: SSRSpatialUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrSpatial_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrSpatial.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrSpatial_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centerReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let centerNormalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0);\n let roughness = clamp(centerNormalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return vec4f(0.0);\n }\n let centerViewDepth = ssrSpatial_reconstructViewDepth(texCoord, centerDepth);\n let hasCenterReflection = centerReflection.a > 0.001;\n if (!hasCenterReflection && roughness >= 0.28) {\n return centerReflection;\n }\n let minimumRadius = select(5.0, 0.95, hasCenterReflection);\n let radius = clamp(\n max(roughness * roughness * ssrSpatial.maxRadius, minimumRadius),\n minimumRadius,\n 6.0\n );\n\n let centerNormal = normalize(centerNormalRoughness.rgb * 2.0 - 1.0);\n let texel = ssrSpatial.direction / vec2f(textureDimensions(sourceTexture));\n let centerWeight = select(0.0, 1.0, hasCenterReflection);\n var reflection = centerReflection * centerWeight;\n var totalWeight = centerWeight;\n var supportingSampleCount = 0u;\n for (var sampleIndex: i32 = 1; sampleIndex <= 6; sampleIndex++) {\n if (f32(sampleIndex) > ceil(radius)) {\n break;\n }\n for (var side: i32 = -1; side <= 1; side += 2) {\n let sampleCoord = clamp(\n texCoord + texel * f32(sampleIndex * side),\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let sampleViewDepth = ssrSpatial_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrSpatial.depthSigma * ssrSpatial.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 16.0);\n let distanceWeight = exp(\n -f32(sampleIndex * sampleIndex) / max(2.0 * radius * radius, 0.1)\n );\n let sampleReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoord, 0);\n let confidenceWeight = smoothstep(0.001, 0.12, sampleReflection.a);\n let belongsToSamePlane = dot(centerNormal, sampleNormal) > 0.9995;\n let surfaceWeight = select(0.0, 1.0, hasCenterReflection || belongsToSamePlane);\n let weight = depthWeight * normalWeight * distanceWeight * confidenceWeight * surfaceWeight;\n if (weight > 0.001) {\n supportingSampleCount += 1u;\n }\n reflection += sampleReflection * weight;\n totalWeight += weight;\n }\n }\n\n if ((!hasCenterReflection && supportingSampleCount < 2u) || totalWeight <= 0.0001) {\n return centerReflection;\n }\n return reflection / totalWeight;\n}";
|
|
918
|
+
readonly bindingLayout: readonly [{
|
|
919
|
+
readonly name: "depthTexture";
|
|
920
|
+
readonly group: 0;
|
|
921
|
+
}, {
|
|
922
|
+
readonly name: "normalTexture";
|
|
923
|
+
readonly group: 0;
|
|
924
|
+
}];
|
|
925
|
+
readonly props: Partial<SSRSpatialUniforms> & SSRSpatialBindings;
|
|
926
|
+
readonly uniforms: SSRSpatialUniforms;
|
|
927
|
+
readonly bindings: SSRSpatialBindings;
|
|
928
|
+
readonly uniformTypes: {
|
|
929
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
930
|
+
readonly direction: "vec2<f32>";
|
|
931
|
+
readonly maxRadius: "f32";
|
|
932
|
+
readonly depthSigma: "f32";
|
|
933
|
+
};
|
|
934
|
+
readonly propTypes: {
|
|
935
|
+
readonly inverseProjectionMatrix: {
|
|
936
|
+
readonly value: NumberArray16;
|
|
937
|
+
readonly private: true;
|
|
938
|
+
};
|
|
939
|
+
readonly direction: {
|
|
940
|
+
readonly value: readonly [1, 0];
|
|
941
|
+
};
|
|
942
|
+
readonly maxRadius: {
|
|
943
|
+
readonly value: 5;
|
|
944
|
+
readonly min: 0;
|
|
945
|
+
readonly max: 8;
|
|
946
|
+
};
|
|
947
|
+
readonly depthSigma: {
|
|
948
|
+
readonly value: 0.035;
|
|
949
|
+
readonly min: 0.0001;
|
|
950
|
+
readonly softMax: 0.2;
|
|
951
|
+
};
|
|
952
|
+
};
|
|
953
|
+
readonly passes: [{
|
|
954
|
+
readonly sampler: true;
|
|
955
|
+
}];
|
|
956
|
+
};
|
|
957
|
+
readonly inputs: {
|
|
958
|
+
readonly sourceTexture: "ssrHistory";
|
|
959
|
+
};
|
|
960
|
+
readonly output: "ssrScratch";
|
|
961
|
+
readonly uniforms: {
|
|
962
|
+
readonly direction: readonly [1, 0];
|
|
963
|
+
};
|
|
964
|
+
}, {
|
|
965
|
+
readonly kind: "sample";
|
|
966
|
+
readonly module: {
|
|
967
|
+
readonly name: "ssrSpatial";
|
|
968
|
+
readonly source: "struct SSRSpatialUniforms {\n inverseProjectionMatrix: mat4x4f,\n direction: vec2f,\n maxRadius: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrSpatial: SSRSpatialUniforms;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrSpatial_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrSpatial.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrSpatial_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let centerReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let centerNormalRoughness = textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0);\n let roughness = clamp(centerNormalRoughness.a, 0.0, 1.0);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return vec4f(0.0);\n }\n let centerViewDepth = ssrSpatial_reconstructViewDepth(texCoord, centerDepth);\n let hasCenterReflection = centerReflection.a > 0.001;\n if (!hasCenterReflection && roughness >= 0.28) {\n return centerReflection;\n }\n let minimumRadius = select(5.0, 0.95, hasCenterReflection);\n let radius = clamp(\n max(roughness * roughness * ssrSpatial.maxRadius, minimumRadius),\n minimumRadius,\n 6.0\n );\n\n let centerNormal = normalize(centerNormalRoughness.rgb * 2.0 - 1.0);\n let texel = ssrSpatial.direction / vec2f(textureDimensions(sourceTexture));\n let centerWeight = select(0.0, 1.0, hasCenterReflection);\n var reflection = centerReflection * centerWeight;\n var totalWeight = centerWeight;\n var supportingSampleCount = 0u;\n for (var sampleIndex: i32 = 1; sampleIndex <= 6; sampleIndex++) {\n if (f32(sampleIndex) > ceil(radius)) {\n break;\n }\n for (var side: i32 = -1; side <= 1; side += 2) {\n let sampleCoord = clamp(\n texCoord + texel * f32(sampleIndex * side),\n vec2f(0.0),\n vec2f(1.0)\n );\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let sampleViewDepth = ssrSpatial_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrSpatial.depthSigma * ssrSpatial.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 16.0);\n let distanceWeight = exp(\n -f32(sampleIndex * sampleIndex) / max(2.0 * radius * radius, 0.1)\n );\n let sampleReflection = textureSampleLevel(sourceTexture, sourceTextureSampler, sampleCoord, 0);\n let confidenceWeight = smoothstep(0.001, 0.12, sampleReflection.a);\n let belongsToSamePlane = dot(centerNormal, sampleNormal) > 0.9995;\n let surfaceWeight = select(0.0, 1.0, hasCenterReflection || belongsToSamePlane);\n let weight = depthWeight * normalWeight * distanceWeight * confidenceWeight * surfaceWeight;\n if (weight > 0.001) {\n supportingSampleCount += 1u;\n }\n reflection += sampleReflection * weight;\n totalWeight += weight;\n }\n }\n\n if ((!hasCenterReflection && supportingSampleCount < 2u) || totalWeight <= 0.0001) {\n return centerReflection;\n }\n return reflection / totalWeight;\n}";
|
|
969
|
+
readonly bindingLayout: readonly [{
|
|
970
|
+
readonly name: "depthTexture";
|
|
971
|
+
readonly group: 0;
|
|
972
|
+
}, {
|
|
973
|
+
readonly name: "normalTexture";
|
|
974
|
+
readonly group: 0;
|
|
975
|
+
}];
|
|
976
|
+
readonly props: Partial<SSRSpatialUniforms> & SSRSpatialBindings;
|
|
977
|
+
readonly uniforms: SSRSpatialUniforms;
|
|
978
|
+
readonly bindings: SSRSpatialBindings;
|
|
979
|
+
readonly uniformTypes: {
|
|
980
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
981
|
+
readonly direction: "vec2<f32>";
|
|
982
|
+
readonly maxRadius: "f32";
|
|
983
|
+
readonly depthSigma: "f32";
|
|
984
|
+
};
|
|
985
|
+
readonly propTypes: {
|
|
986
|
+
readonly inverseProjectionMatrix: {
|
|
987
|
+
readonly value: NumberArray16;
|
|
988
|
+
readonly private: true;
|
|
989
|
+
};
|
|
990
|
+
readonly direction: {
|
|
991
|
+
readonly value: readonly [1, 0];
|
|
992
|
+
};
|
|
993
|
+
readonly maxRadius: {
|
|
994
|
+
readonly value: 5;
|
|
995
|
+
readonly min: 0;
|
|
996
|
+
readonly max: 8;
|
|
997
|
+
};
|
|
998
|
+
readonly depthSigma: {
|
|
999
|
+
readonly value: 0.035;
|
|
1000
|
+
readonly min: 0.0001;
|
|
1001
|
+
readonly softMax: 0.2;
|
|
1002
|
+
};
|
|
1003
|
+
};
|
|
1004
|
+
readonly passes: [{
|
|
1005
|
+
readonly sampler: true;
|
|
1006
|
+
}];
|
|
1007
|
+
};
|
|
1008
|
+
readonly inputs: {
|
|
1009
|
+
readonly sourceTexture: "ssrScratch";
|
|
1010
|
+
};
|
|
1011
|
+
readonly output: "ssrReflection";
|
|
1012
|
+
readonly uniforms: {
|
|
1013
|
+
readonly direction: readonly [0, 1];
|
|
1014
|
+
};
|
|
1015
|
+
}, {
|
|
1016
|
+
readonly kind: "sample";
|
|
1017
|
+
readonly module: {
|
|
1018
|
+
readonly name: "ssrComposite";
|
|
1019
|
+
readonly source: "struct SSRCompositeUniforms {\n inverseProjectionMatrix: mat4x4f,\n strength: f32,\n debugMode: f32,\n depthSigma: f32,\n};\n\n@group(0) @binding(auto) var<uniform> ssrComposite: SSRCompositeUniforms;\n@group(0) @binding(auto) var reflectionTexture: texture_2d<f32>;\n@group(0) @binding(auto) var reflectionTextureSampler: sampler;\n@group(0) @binding(auto) var depthTexture: texture_depth_2d;\n@group(0) @binding(auto) var depthTextureSampler: sampler;\n@group(0) @binding(auto) var normalTexture: texture_2d<f32>;\n@group(0) @binding(auto) var normalTextureSampler: sampler;\n\nfn ssrComposite_reconstructViewDepth(texCoord: vec2f, depth: f32) -> f32 {\n let clip = vec4f(texCoord.x * 2.0 - 1.0, 1.0 - texCoord.y * 2.0, depth, 1.0);\n let viewPosition = ssrComposite.inverseProjectionMatrix * clip;\n return abs(viewPosition.z / max(abs(viewPosition.w), 0.00001));\n}\n\nfn ssrComposite_upsampleReflection(texCoord: vec2f) -> vec4f {\n let reflectionSize = vec2f(textureDimensions(reflectionTexture));\n let reflectionPosition = texCoord * reflectionSize - vec2f(0.5);\n let reflectionBase = vec2i(floor(reflectionPosition));\n let reflectionFraction = fract(reflectionPosition);\n let centerDepth = textureSampleLevel(depthTexture, depthTextureSampler, texCoord, 0);\n if (centerDepth >= 0.99999) {\n return textureSampleLevel(reflectionTexture, reflectionTextureSampler, texCoord, 0);\n }\n let centerViewDepth = ssrComposite_reconstructViewDepth(texCoord, centerDepth);\n let centerNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, texCoord, 0).rgb * 2.0 - 1.0\n );\n\n var reflection = vec4f(0.0);\n var totalWeight = 0.0;\n for (var sampleY: i32 = 0; sampleY <= 1; sampleY++) {\n for (var sampleX: i32 = 0; sampleX <= 1; sampleX++) {\n let reflectionPixel = clamp(\n reflectionBase + vec2i(sampleX, sampleY),\n vec2i(0),\n vec2i(reflectionSize) - vec2i(1)\n );\n let sampleCoord = (vec2f(reflectionPixel) + vec2f(0.5)) / reflectionSize;\n let sampleDepth = textureSampleLevel(depthTexture, depthTextureSampler, sampleCoord, 0);\n let sampleNormal = normalize(\n textureSampleLevel(normalTexture, normalTextureSampler, sampleCoord, 0).rgb * 2.0 - 1.0\n );\n let horizontalWeight = select(\n 1.0 - reflectionFraction.x,\n reflectionFraction.x,\n sampleX == 1\n );\n let verticalWeight = select(\n 1.0 - reflectionFraction.y,\n reflectionFraction.y,\n sampleY == 1\n );\n let sampleViewDepth = ssrComposite_reconstructViewDepth(sampleCoord, sampleDepth);\n let relativeDepthDelta = abs(sampleViewDepth - centerViewDepth) /\n max(centerViewDepth, 0.0001);\n let depthWeight = exp(\n -(relativeDepthDelta * relativeDepthDelta) /\n max(2.0 * ssrComposite.depthSigma * ssrComposite.depthSigma, 0.000001)\n );\n let normalWeight = pow(max(dot(centerNormal, sampleNormal), 0.0), 12.0);\n let weight = horizontalWeight * verticalWeight * depthWeight * normalWeight;\n reflection += textureLoad(reflectionTexture, reflectionPixel, 0) * weight;\n totalWeight += weight;\n }\n }\n return reflection / max(totalWeight, 0.00001);\n}\n\nfn ssrComposite_sampleColor(\n sourceTexture: texture_2d<f32>,\n sourceTextureSampler: sampler,\n texSize: vec2f,\n texCoord: vec2f\n) -> vec4f {\n let color = textureSampleLevel(sourceTexture, sourceTextureSampler, texCoord, 0);\n let reflection = ssrComposite_upsampleReflection(texCoord);\n if (ssrComposite.debugMode > 1.5) {\n let confidence = clamp(reflection.a, 0.0, 1.0);\n let lowConfidence = vec3f(0.045, 0.08, 0.22);\n let highConfidence = vec3f(1.0, 0.7, 0.16);\n return vec4f(mix(lowConfidence, highConfidence, confidence), 1.0);\n }\n if (ssrComposite.debugMode > 0.5) {\n return vec4f(reflection.rgb * reflection.a, 1.0);\n }\n let reflectionWeight = clamp(reflection.a * ssrComposite.strength, 0.0, 1.0);\n return vec4f(color.rgb + reflection.rgb * reflectionWeight, color.a);\n}";
|
|
1020
|
+
readonly bindingLayout: readonly [{
|
|
1021
|
+
readonly name: "reflectionTexture";
|
|
1022
|
+
readonly group: 0;
|
|
1023
|
+
}, {
|
|
1024
|
+
readonly name: "depthTexture";
|
|
1025
|
+
readonly group: 0;
|
|
1026
|
+
}, {
|
|
1027
|
+
readonly name: "normalTexture";
|
|
1028
|
+
readonly group: 0;
|
|
1029
|
+
}];
|
|
1030
|
+
readonly props: Partial<SSRCompositeUniforms> & SSRCompositeBindings;
|
|
1031
|
+
readonly uniforms: SSRCompositeUniforms;
|
|
1032
|
+
readonly bindings: SSRCompositeBindings;
|
|
1033
|
+
readonly uniformTypes: {
|
|
1034
|
+
readonly inverseProjectionMatrix: "mat4x4<f32>";
|
|
1035
|
+
readonly strength: "f32";
|
|
1036
|
+
readonly debugMode: "f32";
|
|
1037
|
+
readonly depthSigma: "f32";
|
|
1038
|
+
};
|
|
1039
|
+
readonly propTypes: {
|
|
1040
|
+
readonly inverseProjectionMatrix: {
|
|
1041
|
+
readonly value: NumberArray16;
|
|
1042
|
+
readonly private: true;
|
|
1043
|
+
};
|
|
1044
|
+
readonly strength: {
|
|
1045
|
+
readonly value: 1;
|
|
1046
|
+
readonly min: 0;
|
|
1047
|
+
readonly softMax: 2;
|
|
1048
|
+
};
|
|
1049
|
+
readonly debugMode: {
|
|
1050
|
+
readonly value: 0;
|
|
1051
|
+
readonly min: 0;
|
|
1052
|
+
readonly max: 2;
|
|
1053
|
+
readonly private: true;
|
|
1054
|
+
};
|
|
1055
|
+
readonly depthSigma: {
|
|
1056
|
+
readonly value: 0.04;
|
|
1057
|
+
readonly min: 0.0001;
|
|
1058
|
+
readonly softMax: 0.2;
|
|
1059
|
+
};
|
|
1060
|
+
};
|
|
1061
|
+
readonly passes: [{
|
|
1062
|
+
readonly sampler: true;
|
|
1063
|
+
}];
|
|
1064
|
+
};
|
|
1065
|
+
readonly inputs: {
|
|
1066
|
+
readonly sourceTexture: "previous";
|
|
1067
|
+
readonly reflectionTexture: "ssrReflection";
|
|
1068
|
+
};
|
|
1069
|
+
}];
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
303
1074
|
export {};
|
|
304
1075
|
//# sourceMappingURL=screen-space-reflections.d.ts.map
|