@pmndrs/vdb 0.0.0-stage → 0.2.0
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/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/core/frame/wgsl/resolve.ts"],"names":[],"mappings":"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","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L31–217 (reprojection into the previous froxel\n// grid, the motion-weighted blend, the 6-neighbour clamp; K3.5: the spectral second target);\n// src/three-openvdb/frame/webgpu/FrameIntegrateMaterial.js L219–294 (the slice march: T < 0.001 stop; K3.5: the\n// spectral march with the alpha of each channel, L140–217).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: one compute thread per froxel column walks the slices (design §3.4): the temporal blend runs\n// inside the scan (the history sampled with hardware trilinear, the same clamps as his bilinear + slice\n// lerp; z neighbours from the column), and the integrate march becomes a prefix of (radiance, opacity\n// 1 − T) at the slice boundaries, read by the composite with two taps. K6.4 spectral: the second scatter texture\n// (red, blue alpha) shares the reprojection, the history stacks both along z, the scan keeps T of each channel and\n// writes the red and blue opacity to a second prefix. Divergences: DIVERGES.md (K6.1, K6.4 rows).\n\n/**\n * `vdbFrameResolveCs` (design §3.3): per (x, y) column of the dispatch box, z = 0..D−1: with `temporal`\n * his reprojection and clamp (writes the next history), then his integrate step; writes boundary z + 1 of\n * the prefix W × H × (D + 1) = (Σ radiance, 1 − T). Outside this frame's area it writes zeros. CPU twins:\n * tools/frame `vdbFrameReproject`, `vdbFrameTemporalFroxel`, `vdbFrameScanColumn` (K6.4: `vdbFrameScanColumnSpectral`).\n *\n * K6.4 `spectral`: `scatterAlpha` (red α, blue α, 0, green α) is blended with the same reprojection; the history is\n * W × H × 2D (z < D the scatter, z ≥ D the alpha); the prefix keeps (Σ radiance rgb, 1 − T green) and the alpha prefix\n * (1 − T red, 1 − T blue) in `alphaFormat` (rg16float with `texture-formats-tier1`, else rgba16float); the scan stops\n * adding once every channel's T < 0.001 (his maxComponent break).\n */\n\nimport { frameChunksWgsl } from \"./chunks.js\";\n\n/** Group-1 bindings of the resolve kernel (K6.4 spectral: the alpha scatter and prefix). */\nexport const RESOLVE_BINDINGS = { scatter: 0, integrated: 1, historyIn: 2, historyOut: 3, scatterAlpha: 4, integratedAlpha: 5 } as const;\n\n/** Pipeline-key options of the resolve kernel. */\nexport interface VDBFrameResolveOptions {\n readonly temporal: boolean;\n /** K6.4: spectral (the alpha scatter, stacked history and alpha prefix). */\n readonly spectral?: boolean;\n /** K6.4: the alpha prefix's storage format (default rgba16float). */\n readonly alphaFormat?: \"rg16float\" | \"rgba16float\";\n}\n\n/** The resolve kernel's WGSL after `vdbFrameUniformsWgsl()`. */\nexport function vdbFrameResolveWgsl(o: VDBFrameResolveOptions): string {\n const b = RESOLVE_BINDINGS;\n const spectral = !!o.spectral;\n const alphaFormat = o.alphaFormat ?? \"rgba16float\";\n const temporalBindings = o.temporal\n ? `@group(1) @binding(${b.historyIn}) var vdbFrameHistoryIn: texture_3d<f32>;\n@group(1) @binding(${b.historyOut}) var vdbFrameHistoryOut: texture_storage_3d<rgba16float, write>;`\n : \"\";\n const spectralBindings = spectral\n ? `@group(1) @binding(${b.scatterAlpha}) var vdbFrameScatterAlphaIn: texture_3d<f32>;\n@group(1) @binding(${b.integratedAlpha}) var vdbFrameIntegratedAlphaOut: texture_storage_3d<${alphaFormat}, write>;`\n : \"\";\n const temporalFns = o.temporal\n ? `\n// His reprojection of one froxel's centre into the previous froxel grid: the history coordinate (texel units in x, y; the\n// clamped slice in z) and the motion blend; valid false: no history there.\nstruct VdbFrameReprojected {\n valid: bool,\n uv: vec2f,\n slice: f32,\n blend: f32,\n};\nfn vdbFrameReprojectCell(cell: vec3u) -> VdbFrameReprojected {\n var out: VdbFrameReprojected;\n out.valid = false;\n let grid = vdbFrame.grid;\n let slice = f32(cell.z);\n let uv = (vec2f(cell.xy) + 0.5) / grid.xy;\n let viewDepth = vdbFrameSliceDepth((slice + 0.5) / grid.z);\n let world = vdbFrame.cameraWorld * vec4f(vdbFrameViewPosition(uv, viewDepth), 1.0);\n let previousView = vdbFrame.previousView * world;\n let previousClip = vdbFrame.previousProjection * previousView;\n if (previousClip.w <= 0.0) {\n return out;\n }\n let previousUv = previousClip.xy / previousClip.w * 0.5 + 0.5;\n let previousRange = vdbFrame.range.zw;\n let previousT = log(max(-previousView.z, 1e-6) / previousRange.x) / log(previousRange.y / previousRange.x);\n let previousSlice = previousT * grid.z - 0.5;\n let inside = min(previousUv.x, previousUv.y) >= 0.0 && max(previousUv.x, previousUv.y) <= 1.0 && previousSlice >= -0.5 && previousSlice <= grid.z - 0.5;\n if (!inside) {\n return out;\n }\n // Bilinear in the slice (cells clamped half a cell inside), linear between the clamped slices: hardware trilinear.\n out.valid = true;\n out.uv = clamp(previousUv * grid.xy, vec2f(0.5), grid.xy - 0.5) / grid.xy;\n out.slice = clamp(previousSlice, 0.0, grid.z - 1.0);\n let motion = length(vec3f((previousUv - uv) * grid.xy, previousSlice - slice));\n out.blend = mix(vdbFrame.jitterFade.z, 1.0, clamp(motion * 4.0, 0.0, 1.0));\n return out;\n}\n// His temporal pass on one texture: the history (layer offset: the spectral alpha half) clamped to the current froxel\n// and its 6 neighbours, blended with the current value by the motion.\nfn vdbFrameTemporal(scatter: texture_3d<f32>, cell: vec3u, r: VdbFrameReprojected, layerOffset: f32, current: vec4f, below: vec4f, above: vec4f, hasBelow: bool, hasAbove: bool) -> vec4f {\n if (!r.valid) {\n return current;\n }\n let historyZ = (r.slice + 0.5 + layerOffset) / f32(textureDimensions(vdbFrameHistoryIn).z);\n let history = textureSampleLevel(vdbFrameHistoryIn, vdbFrameLinear, vec3f(r.uv, historyZ), 0.0);\n let last = vec2i(vdbFrame.grid.xy) - 1;\n let c = vec2i(cell.xy);\n let z = i32(cell.z);\n var lo = current;\n var hi = current;\n for (var n = 0; n < 4; n++) {\n var q = c;\n if (n == 0) { q.x = max(c.x - 1, 0); }\n if (n == 1) { q.x = min(c.x + 1, last.x); }\n if (n == 2) { q.y = max(c.y - 1, 0); }\n if (n == 3) { q.y = min(c.y + 1, last.y); }\n let neighbor = textureLoad(scatter, vec3i(q, z), 0);\n lo = min(lo, neighbor);\n hi = max(hi, neighbor);\n }\n if (hasBelow) {\n lo = min(lo, below);\n hi = max(hi, below);\n }\n if (hasAbove) {\n lo = min(lo, above);\n hi = max(hi, above);\n }\n return mix(clamp(history, lo, hi), current, vec4f(r.blend));\n}\n`\n : \"\";\n const temporalStep = (texture: string, offset: string, cur: string, below: string, above: string) =>\n `vdbFrameTemporal(${texture}, vec3u(x, y, z), reprojected, ${offset}, ${cur}, ${below}, ${above}, z > 0u, z + 1u < depth)`;\n const resolveStep = o.temporal\n ? ` var froxel = vec4f(0.0);${spectral ? \"\\n var froxelAlpha = vec4f(0.0);\" : \"\"}\n if (inSlices) {\n froxel = current;${spectral ? \"\\n froxelAlpha = currentAlpha;\" : \"\"}\n if (vdbFrame.jitterFade.w > 0.5) {\n let reprojected = vdbFrameReprojectCell(vec3u(x, y, z));\n froxel = ${temporalStep(\"vdbFrameScatterIn\", \"0.0\", \"current\", \"below\", \"above\")};${spectral ? `\\n froxelAlpha = ${temporalStep(\"vdbFrameScatterAlphaIn\", \"f32(depth)\", \"currentAlpha\", \"belowAlpha\", \"aboveAlpha\")};` : \"\"}\n }\n }\n textureStore(vdbFrameHistoryOut, vec3u(x, y, z), froxel);${spectral ? \"\\n textureStore(vdbFrameHistoryOut, vec3u(x, y, z + depth), froxelAlpha);\" : \"\"}`\n : ` let froxel = current;${spectral ? \"\\n let froxelAlpha = currentAlpha;\" : \"\"}`;\n const clearHistory = o.temporal ? ` textureStore(vdbFrameHistoryOut, vec3u(x, y, z), vec4f(0.0));\\n${spectral ? \" textureStore(vdbFrameHistoryOut, vec3u(x, y, z + depth), vec4f(0.0));\\n\" : \"\"}` : \"\";\n const clearAlpha = spectral ? ` textureStore(vdbFrameIntegratedAlphaOut, vec3u(x, y, z + 1u), vec4f(0.0));\\n` : \"\";\n\n // the integrate step (grey: one T; spectral: T of each channel, his maxComponent stop)\n const scan = spectral\n ? ` var radiance = vec3f(0.0);\n var transmittance = vec3f(1.0);\n var below = vec4f(0.0);\n var belowAlpha = vec4f(0.0);\n var current = textureLoad(vdbFrameScatterIn, vec3u(x, y, 0u), 0);\n var currentAlpha = textureLoad(vdbFrameScatterAlphaIn, vec3u(x, y, 0u), 0);\n for (var z = 0u; z < depth; z++) {\n let next = vec3u(x, y, min(z + 1u, depth - 1u));\n let above = textureLoad(vdbFrameScatterIn, next, 0);\n let aboveAlpha = textureLoad(vdbFrameScatterAlphaIn, next, 0);\n let inSlices = f32(z) >= areaSlices.x && f32(z) < areaSlices.y;\n${resolveStep}\n // his spectral integrate step over a whole slice; nothing more once every channel's T < 0.001\n let alpha = clamp(vec3f(froxelAlpha.x, froxel.w, froxelAlpha.y), vec3f(0.0), vec3f(1.0));\n if (max(transmittance.x, max(transmittance.y, transmittance.z)) >= VDB_FRAME_SCAN_STOP && max(alpha.x, max(alpha.y, alpha.z)) > 0.0) {\n radiance += transmittance * froxel.rgb;\n transmittance *= vec3f(1.0) - alpha;\n }\n textureStore(vdbFrameIntegratedOut, vec3u(x, y, z + 1u), vec4f(radiance, 1.0 - transmittance.y));\n textureStore(vdbFrameIntegratedAlphaOut, vec3u(x, y, z + 1u), vec4f(1.0 - transmittance.x, 1.0 - transmittance.z, 0.0, 0.0));\n below = current;\n belowAlpha = currentAlpha;\n current = above;\n currentAlpha = aboveAlpha;\n }`\n : ` var radiance = vec3f(0.0);\n var transmittance = 1.0;\n var below = vec4f(0.0);\n var current = textureLoad(vdbFrameScatterIn, vec3u(x, y, 0u), 0);\n for (var z = 0u; z < depth; z++) {\n let above = textureLoad(vdbFrameScatterIn, vec3u(x, y, min(z + 1u, depth - 1u)), 0);\n let inSlices = f32(z) >= areaSlices.x && f32(z) < areaSlices.y;\n${resolveStep}\n // his integrate step over a whole slice; nothing more once T < 0.001\n let alpha = clamp(froxel.w, 0.0, 1.0);\n if (transmittance >= VDB_FRAME_SCAN_STOP && alpha > 0.0) {\n radiance += transmittance * froxel.rgb;\n transmittance *= 1.0 - alpha;\n }\n textureStore(vdbFrameIntegratedOut, vec3u(x, y, z + 1u), vec4f(radiance, 1.0 - transmittance));\n below = current;\n current = above;\n }`;\n\n return `${frameChunksWgsl([\"sliceDepth\", \"viewPosition\"])}\n@group(1) @binding(${b.scatter}) var vdbFrameScatterIn: texture_3d<f32>;\n@group(1) @binding(${b.integrated}) var vdbFrameIntegratedOut: texture_storage_3d<rgba16float, write>;\n${temporalBindings}\n${spectralBindings}\n\nconst VDB_FRAME_SCAN_STOP: f32 = 0.001;\n${temporalFns}\n@compute @workgroup_size(8, 8, 1)\nfn vdbFrameResolveCs(@builtin(global_invocation_id) gid: vec3u) {\n let box = vdbFrame.dispatchBox;\n if (gid.x >= box.z || gid.y >= box.w) {\n return;\n }\n let x = box.x + gid.x;\n let y = box.y + gid.y;\n let depth = u32(vdbFrame.grid.z);\n let area = vdbFrame.areaRect;\n let areaSlices = vdbFrame.areaSlices;\n let p = vec2f(f32(x), f32(y));\n let inRect = p.x >= area.x && p.y >= area.y && p.x < area.z && p.y < area.w;\n textureStore(vdbFrameIntegratedOut, vec3u(x, y, 0u), vec4f(0.0));${spectral ? \"\\n textureStore(vdbFrameIntegratedAlphaOut, vec3u(x, y, 0u), vec4f(0.0));\" : \"\"}\n if (!inRect) {\n for (var z = 0u; z < depth; z++) {\n${clearHistory}${clearAlpha} textureStore(vdbFrameIntegratedOut, vec3u(x, y, z + 1u), vec4f(0.0));\n }\n return;\n }\n${scan}\n}\n`;\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Most layers of a map (directional cascades; a point map has 6 faces). */
|
|
2
|
+
export declare const VDB_VOLUME_SHADOW_MAX_CASCADES = 4;
|
|
3
|
+
/** One map piece the shadow kernel draws (group 1, dynamic offset, 256 B stride). */
|
|
4
|
+
export declare const VDB_FRAME_SHADOW_PIECE: import("../uniforms.js").VDBUniformStruct;
|
|
5
|
+
/** Dynamic-offset stride of the piece records. */
|
|
6
|
+
export declare const VDB_FRAME_SHADOW_PIECE_STRIDE = 256;
|
|
7
|
+
/** The drawn view of one map (a uniform buffer per map; the receivers' `view`). */
|
|
8
|
+
export declare const VDB_VOLUME_SHADOW_VIEW: import("../uniforms.js").VDBUniformStruct;
|
|
9
|
+
/** Group-1 bindings of the shadow map kernel (K6.4 spectral: the optical depth rgb map). */
|
|
10
|
+
export declare const VOLUME_SHADOW_BINDINGS: {
|
|
11
|
+
readonly piece: 0;
|
|
12
|
+
readonly grid: 1;
|
|
13
|
+
readonly map: 2;
|
|
14
|
+
readonly rgb: 3;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* WGSL for hosts that receive volume shadows in their own shaders (design §2.5): the `VdbVolumeShadowView` struct and
|
|
18
|
+
*
|
|
19
|
+
* fn vdbVolumeShadow(map: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> f32
|
|
20
|
+
* fn vdbVolumeShadowCube(map: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> f32
|
|
21
|
+
*
|
|
22
|
+
* Bind a map's `texture` (a `'2d-array'` view; point maps a `'cube'` view), a filtering sampler (linear, clamp to edge)
|
|
23
|
+
* and its `view` buffer (`var<uniform>`). `viewDepth` is the receiver's distance in front of the camera (directional
|
|
24
|
+
* cascades). Multiply the result into the light's shadow. CPU twin: tools/frame `vdbFrameVolumeShadowLookup`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function vdbVolumeShadowWgsl(): string;
|
|
27
|
+
/** The shadow map kernel (after `vdbFrameUniformsWgsl()`; source-free: it reads the shadow grid stack). */
|
|
28
|
+
export declare function vdbFrameVolumeShadowWgsl(o?: {
|
|
29
|
+
spectral?: boolean;
|
|
30
|
+
}): string;
|
|
31
|
+
/**
|
|
32
|
+
* The `?probe=shadow` receiver kernel (harness): `vdbVolumeShadow` / `vdbVolumeShadowCube` on rows of (world, view depth);
|
|
33
|
+
* K6.4 `spectral`: `vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb` with the rgb twin at binding 4 (rows become rgb, depth).
|
|
34
|
+
*/
|
|
35
|
+
export declare function vdbVolumeShadowProbeWgsl(cube: boolean, spectral?: boolean): string;
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–48 (frameShadowDepth), L90–172 (the Beer shadow
|
|
3
|
+
// map pass); src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L248–290 (getCascadeLookup), L344–372 (the
|
|
4
|
+
// receiver transmittance); past the pin: his 62a6e3e (receivers read the state the map was drawn with).
|
|
5
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
6
|
+
// Changes: a compute kernel per map piece (K6.5, design §2.6, §3.7) instead of a fullscreen pass per tile or cube
|
|
7
|
+
// face: texels from the drawing camera's inverse view-projection (spot, cascades) or the cube face table (point); the
|
|
8
|
+
// maps are 2d-array textures (cascades / faces as layers; a point map is sampled through a cube view). Receivers are WGSL
|
|
9
|
+
// functions the host calls with the map and its drawn view (a uniform buffer the core writes when it draws the piece).
|
|
10
|
+
// CPU twins: tools/frame/shadows.ts. Divergences: DIVERGES.md (K6.5 rows).
|
|
11
|
+
/**
|
|
12
|
+
* The volume shadow maps on meshes (K6.5):
|
|
13
|
+
*
|
|
14
|
+
* - `vdbFrameVolumeShadowCs` (8×8×1; a piece's size² × layers): one Beer map texel per thread from the last shadow
|
|
15
|
+
* grid cascade: (τ·first, τ·last, 0, τ) with first / last the depths (÷ far) of the first and last non-empty steps.
|
|
16
|
+
* - `vdbVolumeShadowWgsl()`: `vdbVolumeShadow(map, smp, view, world, viewDepth)` (directional cascades and spot maps,
|
|
17
|
+
* a `texture_2d_array`) and `vdbVolumeShadowCube(map, smp, view, world)` (point maps through a `texture_cube` view):
|
|
18
|
+
* the transmittance at a receiver, read with `view`, the state the map was drawn with (his 62a6e3e by construction).
|
|
19
|
+
*/
|
|
20
|
+
import { vdbUniformStruct } from "../uniforms.js";
|
|
21
|
+
/** Most layers of a map (directional cascades; a point map has 6 faces). */
|
|
22
|
+
export const VDB_VOLUME_SHADOW_MAX_CASCADES = 4;
|
|
23
|
+
/** One map piece the shadow kernel draws (group 1, dynamic offset, 256 B stride). */
|
|
24
|
+
export const VDB_FRAME_SHADOW_PIECE = vdbUniformStruct("VdbFrameShadowPiece", [
|
|
25
|
+
// clip → world of the camera that draws the piece (spot, cascade); unused for a cube
|
|
26
|
+
{ name: "inverseViewProjection", type: "mat4x4f" },
|
|
27
|
+
// camera position (the perspective ray origin; the depth origin), perspective (0/1)
|
|
28
|
+
{ name: "camera", type: "vec4f" },
|
|
29
|
+
// forward axis (orthographic depth), far plane (depths are stored ÷ far)
|
|
30
|
+
{ name: "forward", type: "vec4f" },
|
|
31
|
+
// first layer, size (texels per side), kind (0 camera, 2 cube: 6 layers from the first), march steps
|
|
32
|
+
{ name: "info", type: "vec4u" },
|
|
33
|
+
// K6.4: spectral (1: also write the optical depth rgb map), spare
|
|
34
|
+
{ name: "spectral", type: "vec4u" },
|
|
35
|
+
]);
|
|
36
|
+
/** Dynamic-offset stride of the piece records. */
|
|
37
|
+
export const VDB_FRAME_SHADOW_PIECE_STRIDE = 256;
|
|
38
|
+
/** The drawn view of one map (a uniform buffer per map; the receivers' `view`). */
|
|
39
|
+
export const VDB_VOLUME_SHADOW_VIEW = vdbUniformStruct("VdbVolumeShadowView", [
|
|
40
|
+
// the view-projection each layer was drawn with (cascades; spot: [0])
|
|
41
|
+
{ name: "viewProjection", type: "mat4x4f", count: VDB_VOLUME_SHADOW_MAX_CASCADES },
|
|
42
|
+
// the ray origin of each layer (xyz) and its far plane (w)
|
|
43
|
+
{ name: "origin", type: "vec4f", count: VDB_VOLUME_SHADOW_MAX_CASCADES },
|
|
44
|
+
// forward axis (xyz; orthographic depth), perspective (0/1)
|
|
45
|
+
{ name: "forward", type: "vec4f" },
|
|
46
|
+
// the cascade far distances (view depth) the layers were drawn for
|
|
47
|
+
{ name: "breaks", type: "vec4f" },
|
|
48
|
+
// kind (0 directional cascades, 1 spot, 2 point), cascade count, size, enabled (0: transmittance 1)
|
|
49
|
+
{ name: "info", type: "vec4u" },
|
|
50
|
+
// K6.4: spectral (1: the map has an optical depth rgb twin; 0: the rgb receivers return the grey value), spare
|
|
51
|
+
{ name: "spectral", type: "vec4u" },
|
|
52
|
+
]);
|
|
53
|
+
/** Group-1 bindings of the shadow map kernel (K6.4 spectral: the optical depth rgb map). */
|
|
54
|
+
export const VOLUME_SHADOW_BINDINGS = { piece: 0, grid: 1, map: 2, rgb: 3 };
|
|
55
|
+
/** The receiver functions' WGSL (the `VdbVolumeShadowView` struct and the Beer depth maths) without the struct. */
|
|
56
|
+
const RECEIVER_FUNCTIONS = `// The depth of a world point for layer l of a drawn map: distance from the origin (perspective) or along forward
|
|
57
|
+
fn vdbVolumeShadowDepthOf(view: VdbVolumeShadowView, layer: u32, world: vec3f) -> f32 {
|
|
58
|
+
let offset = world - view.origin[layer].xyz;
|
|
59
|
+
return select(dot(offset, view.forward.xyz), length(offset), view.forward.w > 0.5);
|
|
60
|
+
}
|
|
61
|
+
// The Beer map texel at a receiver depth: the optical depth grows linearly from the first to the last density
|
|
62
|
+
fn vdbVolumeShadowBeer(texel: vec4f, depth: f32, far: f32) -> f32 {
|
|
63
|
+
let opticalDepth = texel.w;
|
|
64
|
+
if (!(opticalDepth > 1e-4)) {
|
|
65
|
+
return 1.0;
|
|
66
|
+
}
|
|
67
|
+
let first = texel.x / opticalDepth * far;
|
|
68
|
+
let last = texel.y / opticalDepth * far;
|
|
69
|
+
let along = clamp((depth - first) / max(last - first, 1e-4), 0.0, 1.0);
|
|
70
|
+
return exp(-opticalDepth * along);
|
|
71
|
+
}
|
|
72
|
+
// The layer and uv of a world point in a directional (cascades by the receiver's view depth) or spot map, read with the
|
|
73
|
+
// view the map was drawn with; layer < 0: outside the map (or the map is disabled)
|
|
74
|
+
struct VdbVolumeShadowTexel {
|
|
75
|
+
layer: i32,
|
|
76
|
+
uv: vec2f,
|
|
77
|
+
};
|
|
78
|
+
fn vdbVolumeShadowTexelOf(view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> VdbVolumeShadowTexel {
|
|
79
|
+
var out = VdbVolumeShadowTexel(-1, vec2f(0.0));
|
|
80
|
+
if (view.info.w == 0u) {
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
var layer = 0u;
|
|
84
|
+
var uv: vec2f;
|
|
85
|
+
if (view.info.x == 0u) {
|
|
86
|
+
let count = view.info.y;
|
|
87
|
+
for (var i = 0u; i < ${VDB_VOLUME_SHADOW_MAX_CASCADES - 1}u; i++) {
|
|
88
|
+
if (viewDepth > view.breaks[i] && i + 1u < count) {
|
|
89
|
+
layer += 1u;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let clip = view.viewProjection[layer] * vec4f(world, 1.0);
|
|
93
|
+
let tile = vec2f(clip.x * 0.5 + 0.5, 0.5 - clip.y * 0.5);
|
|
94
|
+
let lastBreak = view.breaks[min(max(count, 1u) - 1u, 3u)];
|
|
95
|
+
if (!(viewDepth <= lastBreak && all(tile >= vec2f(0.0)) && all(tile <= vec2f(1.0)))) {
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
let inset = 0.5 / f32(view.info.z);
|
|
99
|
+
uv = clamp(tile, vec2f(inset), vec2f(1.0 - inset));
|
|
100
|
+
} else {
|
|
101
|
+
let clip = view.viewProjection[0] * vec4f(world, 1.0);
|
|
102
|
+
let ndc = clip.xy / clip.w;
|
|
103
|
+
uv = vec2f(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5);
|
|
104
|
+
if (!(clip.w > 0.0 && all(uv >= vec2f(0.0)) && all(uv <= vec2f(1.0)))) {
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return VdbVolumeShadowTexel(i32(layer), uv);
|
|
109
|
+
}
|
|
110
|
+
// Directional (cascades by the receiver's view depth) and spot maps: the volume transmittance at a world point,
|
|
111
|
+
// read with the view the map was drawn with; 1 outside the map, or when the map is disabled
|
|
112
|
+
fn vdbVolumeShadow(map: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> f32 {
|
|
113
|
+
let t = vdbVolumeShadowTexelOf(view, world, viewDepth);
|
|
114
|
+
if (t.layer < 0) {
|
|
115
|
+
return 1.0;
|
|
116
|
+
}
|
|
117
|
+
let layer = u32(t.layer);
|
|
118
|
+
let texel = textureSampleLevel(map, smp, t.uv, layer, 0.0);
|
|
119
|
+
return vdbVolumeShadowBeer(texel, vdbVolumeShadowDepthOf(view, layer, world), view.origin[layer].w);
|
|
120
|
+
}
|
|
121
|
+
// K6.4: the position along the Beer texel's first-to-last span at a receiver depth (0 before, 1 after); -1: no shadow
|
|
122
|
+
fn vdbVolumeShadowAlong(texel: vec4f, depth: f32, far: f32) -> f32 {
|
|
123
|
+
let opticalDepth = texel.w;
|
|
124
|
+
if (!(opticalDepth > 1e-4)) {
|
|
125
|
+
return -1.0;
|
|
126
|
+
}
|
|
127
|
+
let first = texel.x / opticalDepth * far;
|
|
128
|
+
let last = texel.y / opticalDepth * far;
|
|
129
|
+
return clamp((depth - first) / max(last - first, 1e-4), 0.0, 1.0);
|
|
130
|
+
}
|
|
131
|
+
// K6.4 spectral maps: the transmittance of each channel (his spectral receivers: exp(-optical depth rgb x along)) from the
|
|
132
|
+
// map's rgb twin (VDBVolumeShadowMap.rgbTexture); a grey map (bind it twice) gives its grey value in every channel
|
|
133
|
+
fn vdbVolumeShadowRgb(map: texture_2d_array<f32>, rgb: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> vec3f {
|
|
134
|
+
let t = vdbVolumeShadowTexelOf(view, world, viewDepth);
|
|
135
|
+
if (t.layer < 0) {
|
|
136
|
+
return vec3f(1.0);
|
|
137
|
+
}
|
|
138
|
+
let layer = u32(t.layer);
|
|
139
|
+
let texel = textureSampleLevel(map, smp, t.uv, layer, 0.0);
|
|
140
|
+
let far = view.origin[layer].w;
|
|
141
|
+
let depth = vdbVolumeShadowDepthOf(view, layer, world);
|
|
142
|
+
if (view.spectral.x == 0u) {
|
|
143
|
+
return vec3f(vdbVolumeShadowBeer(texel, depth, far));
|
|
144
|
+
}
|
|
145
|
+
let along = vdbVolumeShadowAlong(texel, depth, far);
|
|
146
|
+
if (along < 0.0) {
|
|
147
|
+
return vec3f(1.0);
|
|
148
|
+
}
|
|
149
|
+
return exp(-textureSampleLevel(rgb, smp, t.uv, layer, 0.0).xyz * along);
|
|
150
|
+
}
|
|
151
|
+
// Point maps (a cube view of the 6 faces): the transmittance along the direction from the drawn light position
|
|
152
|
+
fn vdbVolumeShadowCube(map: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> f32 {
|
|
153
|
+
if (view.info.w == 0u) {
|
|
154
|
+
return 1.0;
|
|
155
|
+
}
|
|
156
|
+
let offset = world - view.origin[0].xyz;
|
|
157
|
+
let texel = textureSampleLevel(map, smp, offset, 0.0);
|
|
158
|
+
return vdbVolumeShadowBeer(texel, length(offset), view.origin[0].w);
|
|
159
|
+
}
|
|
160
|
+
// K6.4 spectral point maps: rgb is a cube view of the map's rgb twin (a grey map: pass its own cube view twice)
|
|
161
|
+
fn vdbVolumeShadowCubeRgb(map: texture_cube<f32>, rgb: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> vec3f {
|
|
162
|
+
if (view.info.w == 0u) {
|
|
163
|
+
return vec3f(1.0);
|
|
164
|
+
}
|
|
165
|
+
let offset = world - view.origin[0].xyz;
|
|
166
|
+
let texel = textureSampleLevel(map, smp, offset, 0.0);
|
|
167
|
+
if (view.spectral.x == 0u) {
|
|
168
|
+
return vec3f(vdbVolumeShadowBeer(texel, length(offset), view.origin[0].w));
|
|
169
|
+
}
|
|
170
|
+
let along = vdbVolumeShadowAlong(texel, length(offset), view.origin[0].w);
|
|
171
|
+
if (along < 0.0) {
|
|
172
|
+
return vec3f(1.0);
|
|
173
|
+
}
|
|
174
|
+
return exp(-textureSampleLevel(rgb, smp, offset, 0.0).xyz * along);
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
/**
|
|
178
|
+
* WGSL for hosts that receive volume shadows in their own shaders (design §2.5): the `VdbVolumeShadowView` struct and
|
|
179
|
+
*
|
|
180
|
+
* fn vdbVolumeShadow(map: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> f32
|
|
181
|
+
* fn vdbVolumeShadowCube(map: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> f32
|
|
182
|
+
*
|
|
183
|
+
* Bind a map's `texture` (a `'2d-array'` view; point maps a `'cube'` view), a filtering sampler (linear, clamp to edge)
|
|
184
|
+
* and its `view` buffer (`var<uniform>`). `viewDepth` is the receiver's distance in front of the camera (directional
|
|
185
|
+
* cascades). Multiply the result into the light's shadow. CPU twin: tools/frame `vdbFrameVolumeShadowLookup`.
|
|
186
|
+
*/
|
|
187
|
+
export function vdbVolumeShadowWgsl() {
|
|
188
|
+
return `${VDB_VOLUME_SHADOW_VIEW.wgsl}${RECEIVER_FUNCTIONS}`;
|
|
189
|
+
}
|
|
190
|
+
/** The shadow map kernel (after `vdbFrameUniformsWgsl()`; source-free: it reads the shadow grid stack). */
|
|
191
|
+
export function vdbFrameVolumeShadowWgsl(o = {}) {
|
|
192
|
+
const b = VOLUME_SHADOW_BINDINGS;
|
|
193
|
+
const spectral = !!o.spectral;
|
|
194
|
+
return `${VDB_FRAME_SHADOW_PIECE.wgsl}
|
|
195
|
+
@group(1) @binding(${b.piece}) var<uniform> vdbFrameShadowPiece: VdbFrameShadowPiece;
|
|
196
|
+
@group(1) @binding(${b.grid}) var vdbFrameShadowGrid: texture_3d<f32>;
|
|
197
|
+
@group(1) @binding(${b.map}) var vdbFrameShadowMapOut: texture_storage_2d_array<rgba16float, write>;${spectral ? `
|
|
198
|
+
@group(1) @binding(${b.rgb}) var vdbFrameShadowRgbOut: texture_storage_2d_array<rgba16float, write>;` : ""}
|
|
199
|
+
|
|
200
|
+
const VDB_FRAME_SHADOW_MAX_OPTICAL_DEPTH: f32 = 8.0;
|
|
201
|
+
|
|
202
|
+
// The cube face table (WebGPU / Vulkan face selection): face 0..5 (+x, -x, +y, -y, +z, -z), (a, b) = (s, t) * 2 - 1
|
|
203
|
+
fn vdbFrameShadowCubeDirection(face: u32, a: f32, b: f32) -> vec3f {
|
|
204
|
+
switch (face) {
|
|
205
|
+
case 0u: { return vec3f(1.0, -b, -a); }
|
|
206
|
+
case 1u: { return vec3f(-1.0, -b, a); }
|
|
207
|
+
case 2u: { return vec3f(a, 1.0, b); }
|
|
208
|
+
case 3u: { return vec3f(a, -1.0, -b); }
|
|
209
|
+
case 4u: { return vec3f(a, -b, 1.0); }
|
|
210
|
+
default: { return vec3f(-a, -b, -1.0); }
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
fn vdbFrameShadowUnproject(ndc: vec2f, z: f32) -> vec3f {
|
|
214
|
+
let p = vdbFrameShadowPiece.inverseViewProjection * vec4f(ndc, z, 1.0);
|
|
215
|
+
return p.xyz / p.w;
|
|
216
|
+
}
|
|
217
|
+
// frameShadowDepth for the piece's camera
|
|
218
|
+
fn vdbFrameShadowPieceDepth(world: vec3f) -> f32 {
|
|
219
|
+
let offset = world - vdbFrameShadowPiece.camera.xyz;
|
|
220
|
+
return select(dot(offset, vdbFrameShadowPiece.forward.xyz), length(offset), vdbFrameShadowPiece.camera.w > 0.5);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// One Beer map texel: the texel's light ray marched through the last grid cascade with the piece's steps, each
|
|
224
|
+
// sample at the middle of its step; stops past optical depth 8. Empty texels are 0 (the linear filter stays right).
|
|
225
|
+
@compute @workgroup_size(8, 8, 1)
|
|
226
|
+
fn vdbFrameVolumeShadowCs(@builtin(global_invocation_id) gid: vec3u) {
|
|
227
|
+
let info = vdbFrameShadowPiece.info;
|
|
228
|
+
let size = info.y;
|
|
229
|
+
if (gid.x >= size || gid.y >= size) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
let st = (vec2f(gid.xy) + 0.5) / f32(size);
|
|
233
|
+
var origin = vdbFrameShadowPiece.camera.xyz;
|
|
234
|
+
var direction: vec3f;
|
|
235
|
+
var layer = info.x;
|
|
236
|
+
if (info.z == 2u) {
|
|
237
|
+
direction = normalize(vdbFrameShadowCubeDirection(gid.z, st.x * 2.0 - 1.0, st.y * 2.0 - 1.0));
|
|
238
|
+
layer = info.x + gid.z;
|
|
239
|
+
} else {
|
|
240
|
+
let ndc = vec2f(st.x * 2.0 - 1.0, 1.0 - st.y * 2.0);
|
|
241
|
+
let near = vdbFrameShadowUnproject(ndc, 0.25);
|
|
242
|
+
direction = normalize(vdbFrameShadowUnproject(ndc, 0.75) - near);
|
|
243
|
+
if (vdbFrameShadowPiece.camera.w < 0.5) {
|
|
244
|
+
origin = near - direction * dot(near - vdbFrameShadowPiece.camera.xyz, direction);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
var opticalDepth = ${spectral ? "vec3f(0.0)" : "0.0"};
|
|
248
|
+
var first = 0.0;
|
|
249
|
+
var last = 0.0;
|
|
250
|
+
let count = u32(vdbFrame.gridLayout.x);
|
|
251
|
+
if (count > 0u) {
|
|
252
|
+
let cascade = count - 1u;
|
|
253
|
+
let boxMin = vdbFrame.gridMin[cascade].xyz;
|
|
254
|
+
let boxMax = boxMin + vdbFrame.gridSize[cascade].xyz;
|
|
255
|
+
let inverseDirection = vec3f(1.0) / direction;
|
|
256
|
+
let tA = (boxMin - origin) * inverseDirection;
|
|
257
|
+
let tB = (boxMax - origin) * inverseDirection;
|
|
258
|
+
let tMin = min(tA, tB);
|
|
259
|
+
let tMax = max(tA, tB);
|
|
260
|
+
let tStart = max(0.0, max(tMin.x, max(tMin.y, tMin.z)));
|
|
261
|
+
let tEnd = min(tMax.x, min(tMax.y, tMax.z));
|
|
262
|
+
if (tEnd > tStart) {
|
|
263
|
+
let steps = max(info.w, 1u);
|
|
264
|
+
let stepLength = (tEnd - tStart) / f32(steps);
|
|
265
|
+
var firstT = -1.0;
|
|
266
|
+
var lastT = -1.0;
|
|
267
|
+
for (var i = 0u; i < steps; i++) {
|
|
268
|
+
if (${spectral ? "min(opticalDepth.x, min(opticalDepth.y, opticalDepth.z))" : "opticalDepth"} > VDB_FRAME_SHADOW_MAX_OPTICAL_DEPTH) {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
let t = tStart + f32(i) * stepLength;
|
|
272
|
+
let p = origin + direction * (t + stepLength * 0.5);
|
|
273
|
+
let extinction = vdbFrameStackSample(vdbFrameShadowGrid, vdbFrame.shadowOrigin[cascade].xyz, vdbFrameGridUvw(cascade, p)).${spectral ? "xyz" : "x"};
|
|
274
|
+
if (${spectral ? "dot(extinction, vec3f(1.0))" : "extinction"} > 0.0) {
|
|
275
|
+
if (firstT < 0.0) {
|
|
276
|
+
firstT = t;
|
|
277
|
+
}
|
|
278
|
+
lastT = t + stepLength;
|
|
279
|
+
opticalDepth += extinction * stepLength;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (${spectral ? "dot(opticalDepth, vec3f(1.0))" : "opticalDepth"} > 0.0) {
|
|
283
|
+
let far = vdbFrameShadowPiece.forward.w;
|
|
284
|
+
first = vdbFrameShadowPieceDepth(origin + direction * firstT) / far;
|
|
285
|
+
last = vdbFrameShadowPieceDepth(origin + direction * lastT) / far;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
${spectral
|
|
290
|
+
? ` // his spectral map: (first, last) x the channel mean, and (optical depth rgb, 0) in the rgb twin
|
|
291
|
+
let mean = dot(opticalDepth, vec3f(1.0 / 3.0));
|
|
292
|
+
textureStore(vdbFrameShadowMapOut, gid.xy, layer, vec4f(first * mean, last * mean, 0.0, mean));
|
|
293
|
+
textureStore(vdbFrameShadowRgbOut, gid.xy, layer, vec4f(opticalDepth, 0.0));`
|
|
294
|
+
: " textureStore(vdbFrameShadowMapOut, gid.xy, layer, vec4f(first * opticalDepth, last * opticalDepth, 0.0, opticalDepth));"}
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The `?probe=shadow` receiver kernel (harness): `vdbVolumeShadow` / `vdbVolumeShadowCube` on rows of (world, view depth);
|
|
300
|
+
* K6.4 `spectral`: `vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb` with the rgb twin at binding 4 (rows become rgb, depth).
|
|
301
|
+
*/
|
|
302
|
+
export function vdbVolumeShadowProbeWgsl(cube, spectral = false) {
|
|
303
|
+
const type = cube ? "texture_cube<f32>" : "texture_2d_array<f32>";
|
|
304
|
+
const call = spectral
|
|
305
|
+
? cube
|
|
306
|
+
? "vec4f(vdbVolumeShadowCubeRgb(vdbProbeMap, vdbProbeRgb, vdbProbeSampler, vdbProbeView, row.xyz), row.w)"
|
|
307
|
+
: "vec4f(vdbVolumeShadowRgb(vdbProbeMap, vdbProbeRgb, vdbProbeSampler, vdbProbeView, row.xyz, row.w), row.w)"
|
|
308
|
+
: cube
|
|
309
|
+
? "vec4f(vdbVolumeShadowCube(vdbProbeMap, vdbProbeSampler, vdbProbeView, row.xyz), row.yzw)"
|
|
310
|
+
: "vec4f(vdbVolumeShadow(vdbProbeMap, vdbProbeSampler, vdbProbeView, row.xyz, row.w), row.yzw)";
|
|
311
|
+
return `${vdbVolumeShadowWgsl()}
|
|
312
|
+
@group(0) @binding(0) var<uniform> vdbProbeView: VdbVolumeShadowView;
|
|
313
|
+
@group(0) @binding(1) var vdbProbeMap: ${type};
|
|
314
|
+
@group(0) @binding(2) var vdbProbeSampler: sampler;
|
|
315
|
+
@group(0) @binding(3) var<storage, read_write> vdbProbeRows: array<vec4f>;
|
|
316
|
+
${spectral ? `@group(0) @binding(4) var vdbProbeRgb: ${type};
|
|
317
|
+
` : ""}
|
|
318
|
+
@compute @workgroup_size(64, 1, 1)
|
|
319
|
+
fn vdbVolumeShadowProbeCs(@builtin(global_invocation_id) gid: vec3u) {
|
|
320
|
+
if (gid.x >= arrayLength(&vdbProbeRows)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
let row = vdbProbeRows[gid.x];
|
|
324
|
+
vdbProbeRows[gid.x] = ${call};
|
|
325
|
+
}
|
|
326
|
+
`;
|
|
327
|
+
}
|
|
328
|
+
//# sourceMappingURL=shadows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadows.js","sourceRoot":"","sources":["../../../../src/core/frame/wgsl/shadows.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oHAAoH;AACpH,+GAA+G;AAC/G,0GAA0G;AAC1G,4GAA4G;AAC5G,kHAAkH;AAClH,sHAAsH;AACtH,0HAA0H;AAC1H,uHAAuH;AACvH,2EAA2E;AAE3E;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEhD,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,qBAAqB,EAAE;IAC5E,qFAAqF;IACrF,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,EAAE;IAClD,oFAAoF;IACpF,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;IACjC,yEAAyE;IACzE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;IAClC,qGAAqG;IACrG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,kEAAkE;IAClE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE;CACpC,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAEjD,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC,qBAAqB,EAAE;IAC5E,sEAAsE;IACtE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,8BAA8B,EAAE;IAClF,2DAA2D;IAC3D,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,8BAA8B,EAAE;IACxE,4DAA4D;IAC5D,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;IAClC,mEAAmE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;IACjC,oGAAoG;IACpG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/B,+GAA+G;IAC/G,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE;CACpC,CAAC,CAAC;AAEH,4FAA4F;AAC5F,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAW,CAAC;AAErF,mHAAmH;AACnH,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BA+BA,8BAA8B,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyF5D,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,GAAG,sBAAsB,CAAC,IAAI,GAAG,kBAAkB,EAAE,CAAC;AAC/D,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,wBAAwB,CAAC,IAA4B,EAAE;IACrE,MAAM,CAAC,GAAG,sBAAsB,CAAC;IACjC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9B,OAAO,GAAG,sBAAsB,CAAC,IAAI;qBAClB,CAAC,CAAC,KAAK;qBACP,CAAC,CAAC,IAAI;qBACN,CAAC,CAAC,GAAG,4EAA4E,QAAQ,CAAC,CAAC,CAAC;qBAC5F,CAAC,CAAC,GAAG,2EAA2E,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAiDnF,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;cAqBxC,QAAQ,CAAC,CAAC,CAAC,0DAA0D,CAAC,CAAC,CAAC,cAAc;;;;;oIAKgC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG;cAC5I,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,YAAY;;;;;;;;YAQzD,QAAQ,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,cAAc;;;;;;;EAOrE,QAAQ;QACN,CAAC,CAAC;;;+EAGyE;QAC3E,CAAC,CAAC,2HAA2H;;CAEhI,CAAC;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAa,EAAE,QAAQ,GAAG,KAAK;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,uBAAuB,CAAC;IAClE,MAAM,IAAI,GAAG,QAAQ;QACnB,CAAC,CAAC,IAAI;YACJ,CAAC,CAAC,wGAAwG;YAC1G,CAAC,CAAC,2GAA2G;QAC/G,CAAC,CAAC,IAAI;YACJ,CAAC,CAAC,0FAA0F;YAC5F,CAAC,CAAC,6FAA6F,CAAC;IACpG,OAAO,GAAG,mBAAmB,EAAE;;yCAEQ,IAAI;;;EAG3C,QAAQ,CAAC,CAAC,CAAC,0CAA0C,IAAI;CAC1D,CAAC,CAAC,CAAC,EAAE;;;;;;;0BAOoB,IAAI;;CAE7B,CAAC;AACF,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–48 (frameShadowDepth), L90–172 (the Beer shadow\n// map pass); src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L248–290 (getCascadeLookup), L344–372 (the\n// receiver transmittance); past the pin: his 62a6e3e (receivers read the state the map was drawn with).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: a compute kernel per map piece (K6.5, design §2.6, §3.7) instead of a fullscreen pass per tile or cube\n// face: texels from the drawing camera's inverse view-projection (spot, cascades) or the cube face table (point); the\n// maps are 2d-array textures (cascades / faces as layers; a point map is sampled through a cube view). Receivers are WGSL\n// functions the host calls with the map and its drawn view (a uniform buffer the core writes when it draws the piece).\n// CPU twins: tools/frame/shadows.ts. Divergences: DIVERGES.md (K6.5 rows).\n\n/**\n * The volume shadow maps on meshes (K6.5):\n *\n * - `vdbFrameVolumeShadowCs` (8×8×1; a piece's size² × layers): one Beer map texel per thread from the last shadow\n * grid cascade: (τ·first, τ·last, 0, τ) with first / last the depths (÷ far) of the first and last non-empty steps.\n * - `vdbVolumeShadowWgsl()`: `vdbVolumeShadow(map, smp, view, world, viewDepth)` (directional cascades and spot maps,\n * a `texture_2d_array`) and `vdbVolumeShadowCube(map, smp, view, world)` (point maps through a `texture_cube` view):\n * the transmittance at a receiver, read with `view`, the state the map was drawn with (his 62a6e3e by construction).\n */\n\nimport { vdbUniformStruct } from \"../uniforms.js\";\n\n/** Most layers of a map (directional cascades; a point map has 6 faces). */\nexport const VDB_VOLUME_SHADOW_MAX_CASCADES = 4;\n\n/** One map piece the shadow kernel draws (group 1, dynamic offset, 256 B stride). */\nexport const VDB_FRAME_SHADOW_PIECE = vdbUniformStruct(\"VdbFrameShadowPiece\", [\n // clip → world of the camera that draws the piece (spot, cascade); unused for a cube\n { name: \"inverseViewProjection\", type: \"mat4x4f\" },\n // camera position (the perspective ray origin; the depth origin), perspective (0/1)\n { name: \"camera\", type: \"vec4f\" },\n // forward axis (orthographic depth), far plane (depths are stored ÷ far)\n { name: \"forward\", type: \"vec4f\" },\n // first layer, size (texels per side), kind (0 camera, 2 cube: 6 layers from the first), march steps\n { name: \"info\", type: \"vec4u\" },\n // K6.4: spectral (1: also write the optical depth rgb map), spare\n { name: \"spectral\", type: \"vec4u\" },\n]);\n\n/** Dynamic-offset stride of the piece records. */\nexport const VDB_FRAME_SHADOW_PIECE_STRIDE = 256;\n\n/** The drawn view of one map (a uniform buffer per map; the receivers' `view`). */\nexport const VDB_VOLUME_SHADOW_VIEW = vdbUniformStruct(\"VdbVolumeShadowView\", [\n // the view-projection each layer was drawn with (cascades; spot: [0])\n { name: \"viewProjection\", type: \"mat4x4f\", count: VDB_VOLUME_SHADOW_MAX_CASCADES },\n // the ray origin of each layer (xyz) and its far plane (w)\n { name: \"origin\", type: \"vec4f\", count: VDB_VOLUME_SHADOW_MAX_CASCADES },\n // forward axis (xyz; orthographic depth), perspective (0/1)\n { name: \"forward\", type: \"vec4f\" },\n // the cascade far distances (view depth) the layers were drawn for\n { name: \"breaks\", type: \"vec4f\" },\n // kind (0 directional cascades, 1 spot, 2 point), cascade count, size, enabled (0: transmittance 1)\n { name: \"info\", type: \"vec4u\" },\n // K6.4: spectral (1: the map has an optical depth rgb twin; 0: the rgb receivers return the grey value), spare\n { name: \"spectral\", type: \"vec4u\" },\n]);\n\n/** Group-1 bindings of the shadow map kernel (K6.4 spectral: the optical depth rgb map). */\nexport const VOLUME_SHADOW_BINDINGS = { piece: 0, grid: 1, map: 2, rgb: 3 } as const;\n\n/** The receiver functions' WGSL (the `VdbVolumeShadowView` struct and the Beer depth maths) without the struct. */\nconst RECEIVER_FUNCTIONS = `// The depth of a world point for layer l of a drawn map: distance from the origin (perspective) or along forward\nfn vdbVolumeShadowDepthOf(view: VdbVolumeShadowView, layer: u32, world: vec3f) -> f32 {\n let offset = world - view.origin[layer].xyz;\n return select(dot(offset, view.forward.xyz), length(offset), view.forward.w > 0.5);\n}\n// The Beer map texel at a receiver depth: the optical depth grows linearly from the first to the last density\nfn vdbVolumeShadowBeer(texel: vec4f, depth: f32, far: f32) -> f32 {\n let opticalDepth = texel.w;\n if (!(opticalDepth > 1e-4)) {\n return 1.0;\n }\n let first = texel.x / opticalDepth * far;\n let last = texel.y / opticalDepth * far;\n let along = clamp((depth - first) / max(last - first, 1e-4), 0.0, 1.0);\n return exp(-opticalDepth * along);\n}\n// The layer and uv of a world point in a directional (cascades by the receiver's view depth) or spot map, read with the\n// view the map was drawn with; layer < 0: outside the map (or the map is disabled)\nstruct VdbVolumeShadowTexel {\n layer: i32,\n uv: vec2f,\n};\nfn vdbVolumeShadowTexelOf(view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> VdbVolumeShadowTexel {\n var out = VdbVolumeShadowTexel(-1, vec2f(0.0));\n if (view.info.w == 0u) {\n return out;\n }\n var layer = 0u;\n var uv: vec2f;\n if (view.info.x == 0u) {\n let count = view.info.y;\n for (var i = 0u; i < ${VDB_VOLUME_SHADOW_MAX_CASCADES - 1}u; i++) {\n if (viewDepth > view.breaks[i] && i + 1u < count) {\n layer += 1u;\n }\n }\n let clip = view.viewProjection[layer] * vec4f(world, 1.0);\n let tile = vec2f(clip.x * 0.5 + 0.5, 0.5 - clip.y * 0.5);\n let lastBreak = view.breaks[min(max(count, 1u) - 1u, 3u)];\n if (!(viewDepth <= lastBreak && all(tile >= vec2f(0.0)) && all(tile <= vec2f(1.0)))) {\n return out;\n }\n let inset = 0.5 / f32(view.info.z);\n uv = clamp(tile, vec2f(inset), vec2f(1.0 - inset));\n } else {\n let clip = view.viewProjection[0] * vec4f(world, 1.0);\n let ndc = clip.xy / clip.w;\n uv = vec2f(ndc.x * 0.5 + 0.5, 0.5 - ndc.y * 0.5);\n if (!(clip.w > 0.0 && all(uv >= vec2f(0.0)) && all(uv <= vec2f(1.0)))) {\n return out;\n }\n }\n return VdbVolumeShadowTexel(i32(layer), uv);\n}\n// Directional (cascades by the receiver's view depth) and spot maps: the volume transmittance at a world point,\n// read with the view the map was drawn with; 1 outside the map, or when the map is disabled\nfn vdbVolumeShadow(map: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> f32 {\n let t = vdbVolumeShadowTexelOf(view, world, viewDepth);\n if (t.layer < 0) {\n return 1.0;\n }\n let layer = u32(t.layer);\n let texel = textureSampleLevel(map, smp, t.uv, layer, 0.0);\n return vdbVolumeShadowBeer(texel, vdbVolumeShadowDepthOf(view, layer, world), view.origin[layer].w);\n}\n// K6.4: the position along the Beer texel's first-to-last span at a receiver depth (0 before, 1 after); -1: no shadow\nfn vdbVolumeShadowAlong(texel: vec4f, depth: f32, far: f32) -> f32 {\n let opticalDepth = texel.w;\n if (!(opticalDepth > 1e-4)) {\n return -1.0;\n }\n let first = texel.x / opticalDepth * far;\n let last = texel.y / opticalDepth * far;\n return clamp((depth - first) / max(last - first, 1e-4), 0.0, 1.0);\n}\n// K6.4 spectral maps: the transmittance of each channel (his spectral receivers: exp(-optical depth rgb x along)) from the\n// map's rgb twin (VDBVolumeShadowMap.rgbTexture); a grey map (bind it twice) gives its grey value in every channel\nfn vdbVolumeShadowRgb(map: texture_2d_array<f32>, rgb: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> vec3f {\n let t = vdbVolumeShadowTexelOf(view, world, viewDepth);\n if (t.layer < 0) {\n return vec3f(1.0);\n }\n let layer = u32(t.layer);\n let texel = textureSampleLevel(map, smp, t.uv, layer, 0.0);\n let far = view.origin[layer].w;\n let depth = vdbVolumeShadowDepthOf(view, layer, world);\n if (view.spectral.x == 0u) {\n return vec3f(vdbVolumeShadowBeer(texel, depth, far));\n }\n let along = vdbVolumeShadowAlong(texel, depth, far);\n if (along < 0.0) {\n return vec3f(1.0);\n }\n return exp(-textureSampleLevel(rgb, smp, t.uv, layer, 0.0).xyz * along);\n}\n// Point maps (a cube view of the 6 faces): the transmittance along the direction from the drawn light position\nfn vdbVolumeShadowCube(map: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> f32 {\n if (view.info.w == 0u) {\n return 1.0;\n }\n let offset = world - view.origin[0].xyz;\n let texel = textureSampleLevel(map, smp, offset, 0.0);\n return vdbVolumeShadowBeer(texel, length(offset), view.origin[0].w);\n}\n// K6.4 spectral point maps: rgb is a cube view of the map's rgb twin (a grey map: pass its own cube view twice)\nfn vdbVolumeShadowCubeRgb(map: texture_cube<f32>, rgb: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> vec3f {\n if (view.info.w == 0u) {\n return vec3f(1.0);\n }\n let offset = world - view.origin[0].xyz;\n let texel = textureSampleLevel(map, smp, offset, 0.0);\n if (view.spectral.x == 0u) {\n return vec3f(vdbVolumeShadowBeer(texel, length(offset), view.origin[0].w));\n }\n let along = vdbVolumeShadowAlong(texel, length(offset), view.origin[0].w);\n if (along < 0.0) {\n return vec3f(1.0);\n }\n return exp(-textureSampleLevel(rgb, smp, offset, 0.0).xyz * along);\n}\n`;\n\n/**\n * WGSL for hosts that receive volume shadows in their own shaders (design §2.5): the `VdbVolumeShadowView` struct and\n *\n * fn vdbVolumeShadow(map: texture_2d_array<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f, viewDepth: f32) -> f32\n * fn vdbVolumeShadowCube(map: texture_cube<f32>, smp: sampler, view: VdbVolumeShadowView, world: vec3f) -> f32\n *\n * Bind a map's `texture` (a `'2d-array'` view; point maps a `'cube'` view), a filtering sampler (linear, clamp to edge)\n * and its `view` buffer (`var<uniform>`). `viewDepth` is the receiver's distance in front of the camera (directional\n * cascades). Multiply the result into the light's shadow. CPU twin: tools/frame `vdbFrameVolumeShadowLookup`.\n */\nexport function vdbVolumeShadowWgsl(): string {\n return `${VDB_VOLUME_SHADOW_VIEW.wgsl}${RECEIVER_FUNCTIONS}`;\n}\n\n/** The shadow map kernel (after `vdbFrameUniformsWgsl()`; source-free: it reads the shadow grid stack). */\nexport function vdbFrameVolumeShadowWgsl(o: { spectral?: boolean } = {}): string {\n const b = VOLUME_SHADOW_BINDINGS;\n const spectral = !!o.spectral;\n return `${VDB_FRAME_SHADOW_PIECE.wgsl}\n@group(1) @binding(${b.piece}) var<uniform> vdbFrameShadowPiece: VdbFrameShadowPiece;\n@group(1) @binding(${b.grid}) var vdbFrameShadowGrid: texture_3d<f32>;\n@group(1) @binding(${b.map}) var vdbFrameShadowMapOut: texture_storage_2d_array<rgba16float, write>;${spectral ? `\n@group(1) @binding(${b.rgb}) var vdbFrameShadowRgbOut: texture_storage_2d_array<rgba16float, write>;` : \"\"}\n\nconst VDB_FRAME_SHADOW_MAX_OPTICAL_DEPTH: f32 = 8.0;\n\n// The cube face table (WebGPU / Vulkan face selection): face 0..5 (+x, -x, +y, -y, +z, -z), (a, b) = (s, t) * 2 - 1\nfn vdbFrameShadowCubeDirection(face: u32, a: f32, b: f32) -> vec3f {\n switch (face) {\n case 0u: { return vec3f(1.0, -b, -a); }\n case 1u: { return vec3f(-1.0, -b, a); }\n case 2u: { return vec3f(a, 1.0, b); }\n case 3u: { return vec3f(a, -1.0, -b); }\n case 4u: { return vec3f(a, -b, 1.0); }\n default: { return vec3f(-a, -b, -1.0); }\n }\n}\nfn vdbFrameShadowUnproject(ndc: vec2f, z: f32) -> vec3f {\n let p = vdbFrameShadowPiece.inverseViewProjection * vec4f(ndc, z, 1.0);\n return p.xyz / p.w;\n}\n// frameShadowDepth for the piece's camera\nfn vdbFrameShadowPieceDepth(world: vec3f) -> f32 {\n let offset = world - vdbFrameShadowPiece.camera.xyz;\n return select(dot(offset, vdbFrameShadowPiece.forward.xyz), length(offset), vdbFrameShadowPiece.camera.w > 0.5);\n}\n\n// One Beer map texel: the texel's light ray marched through the last grid cascade with the piece's steps, each\n// sample at the middle of its step; stops past optical depth 8. Empty texels are 0 (the linear filter stays right).\n@compute @workgroup_size(8, 8, 1)\nfn vdbFrameVolumeShadowCs(@builtin(global_invocation_id) gid: vec3u) {\n let info = vdbFrameShadowPiece.info;\n let size = info.y;\n if (gid.x >= size || gid.y >= size) {\n return;\n }\n let st = (vec2f(gid.xy) + 0.5) / f32(size);\n var origin = vdbFrameShadowPiece.camera.xyz;\n var direction: vec3f;\n var layer = info.x;\n if (info.z == 2u) {\n direction = normalize(vdbFrameShadowCubeDirection(gid.z, st.x * 2.0 - 1.0, st.y * 2.0 - 1.0));\n layer = info.x + gid.z;\n } else {\n let ndc = vec2f(st.x * 2.0 - 1.0, 1.0 - st.y * 2.0);\n let near = vdbFrameShadowUnproject(ndc, 0.25);\n direction = normalize(vdbFrameShadowUnproject(ndc, 0.75) - near);\n if (vdbFrameShadowPiece.camera.w < 0.5) {\n origin = near - direction * dot(near - vdbFrameShadowPiece.camera.xyz, direction);\n }\n }\n var opticalDepth = ${spectral ? \"vec3f(0.0)\" : \"0.0\"};\n var first = 0.0;\n var last = 0.0;\n let count = u32(vdbFrame.gridLayout.x);\n if (count > 0u) {\n let cascade = count - 1u;\n let boxMin = vdbFrame.gridMin[cascade].xyz;\n let boxMax = boxMin + vdbFrame.gridSize[cascade].xyz;\n let inverseDirection = vec3f(1.0) / direction;\n let tA = (boxMin - origin) * inverseDirection;\n let tB = (boxMax - origin) * inverseDirection;\n let tMin = min(tA, tB);\n let tMax = max(tA, tB);\n let tStart = max(0.0, max(tMin.x, max(tMin.y, tMin.z)));\n let tEnd = min(tMax.x, min(tMax.y, tMax.z));\n if (tEnd > tStart) {\n let steps = max(info.w, 1u);\n let stepLength = (tEnd - tStart) / f32(steps);\n var firstT = -1.0;\n var lastT = -1.0;\n for (var i = 0u; i < steps; i++) {\n if (${spectral ? \"min(opticalDepth.x, min(opticalDepth.y, opticalDepth.z))\" : \"opticalDepth\"} > VDB_FRAME_SHADOW_MAX_OPTICAL_DEPTH) {\n break;\n }\n let t = tStart + f32(i) * stepLength;\n let p = origin + direction * (t + stepLength * 0.5);\n let extinction = vdbFrameStackSample(vdbFrameShadowGrid, vdbFrame.shadowOrigin[cascade].xyz, vdbFrameGridUvw(cascade, p)).${spectral ? \"xyz\" : \"x\"};\n if (${spectral ? \"dot(extinction, vec3f(1.0))\" : \"extinction\"} > 0.0) {\n if (firstT < 0.0) {\n firstT = t;\n }\n lastT = t + stepLength;\n opticalDepth += extinction * stepLength;\n }\n }\n if (${spectral ? \"dot(opticalDepth, vec3f(1.0))\" : \"opticalDepth\"} > 0.0) {\n let far = vdbFrameShadowPiece.forward.w;\n first = vdbFrameShadowPieceDepth(origin + direction * firstT) / far;\n last = vdbFrameShadowPieceDepth(origin + direction * lastT) / far;\n }\n }\n }\n${spectral\n ? ` // his spectral map: (first, last) x the channel mean, and (optical depth rgb, 0) in the rgb twin\n let mean = dot(opticalDepth, vec3f(1.0 / 3.0));\n textureStore(vdbFrameShadowMapOut, gid.xy, layer, vec4f(first * mean, last * mean, 0.0, mean));\n textureStore(vdbFrameShadowRgbOut, gid.xy, layer, vec4f(opticalDepth, 0.0));`\n : \" textureStore(vdbFrameShadowMapOut, gid.xy, layer, vec4f(first * opticalDepth, last * opticalDepth, 0.0, opticalDepth));\"}\n}\n`;\n}\n\n/**\n * The `?probe=shadow` receiver kernel (harness): `vdbVolumeShadow` / `vdbVolumeShadowCube` on rows of (world, view depth);\n * K6.4 `spectral`: `vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb` with the rgb twin at binding 4 (rows become rgb, depth).\n */\nexport function vdbVolumeShadowProbeWgsl(cube: boolean, spectral = false): string {\n const type = cube ? \"texture_cube<f32>\" : \"texture_2d_array<f32>\";\n const call = spectral\n ? cube\n ? \"vec4f(vdbVolumeShadowCubeRgb(vdbProbeMap, vdbProbeRgb, vdbProbeSampler, vdbProbeView, row.xyz), row.w)\"\n : \"vec4f(vdbVolumeShadowRgb(vdbProbeMap, vdbProbeRgb, vdbProbeSampler, vdbProbeView, row.xyz, row.w), row.w)\"\n : cube\n ? \"vec4f(vdbVolumeShadowCube(vdbProbeMap, vdbProbeSampler, vdbProbeView, row.xyz), row.yzw)\"\n : \"vec4f(vdbVolumeShadow(vdbProbeMap, vdbProbeSampler, vdbProbeView, row.xyz, row.w), row.yzw)\";\n return `${vdbVolumeShadowWgsl()}\n@group(0) @binding(0) var<uniform> vdbProbeView: VdbVolumeShadowView;\n@group(0) @binding(1) var vdbProbeMap: ${type};\n@group(0) @binding(2) var vdbProbeSampler: sampler;\n@group(0) @binding(3) var<storage, read_write> vdbProbeRows: array<vec4f>;\n${spectral ? `@group(0) @binding(4) var vdbProbeRgb: ${type};\n` : \"\"}\n@compute @workgroup_size(64, 1, 1)\nfn vdbVolumeShadowProbeCs(@builtin(global_invocation_id) gid: vec3u) {\n if (gid.x >= arrayLength(&vdbProbeRows)) {\n return;\n }\n let row = vdbProbeRows[gid.x];\n vdbProbeRows[gid.x] = ${call};\n}\n`;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IEEE 754 binary16 -> number, for the few Half fields the pool reads from a
|
|
3
|
+
* grid header (root background and min/max; K7.H). The core never imports
|
|
4
|
+
* `tools` (D20), so this restates `tools`' `vdbHalfToFloat`;
|
|
5
|
+
* `test/core/half.test.ts` checks the two agree on all 65536 bit patterns.
|
|
6
|
+
*
|
|
7
|
+
* Exact: every binary16 value (subnormals, infinities, NaN) is representable
|
|
8
|
+
* as an f32 and as a JS number. Same result as NanoVDB `math::HalfToFloat`
|
|
9
|
+
* (`nanovdb/math/HalfLite.h`, from Imath) and WGSL `unpack2x16float`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function halfBitsToNumber(bits: number): number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IEEE 754 binary16 -> number, for the few Half fields the pool reads from a
|
|
3
|
+
* grid header (root background and min/max; K7.H). The core never imports
|
|
4
|
+
* `tools` (D20), so this restates `tools`' `vdbHalfToFloat`;
|
|
5
|
+
* `test/core/half.test.ts` checks the two agree on all 65536 bit patterns.
|
|
6
|
+
*
|
|
7
|
+
* Exact: every binary16 value (subnormals, infinities, NaN) is representable
|
|
8
|
+
* as an f32 and as a JS number. Same result as NanoVDB `math::HalfToFloat`
|
|
9
|
+
* (`nanovdb/math/HalfLite.h`, from Imath) and WGSL `unpack2x16float`.
|
|
10
|
+
*/
|
|
11
|
+
export function halfBitsToNumber(bits) {
|
|
12
|
+
const h = bits & 0xffff;
|
|
13
|
+
const sign = h & 0x8000 ? -1 : 1;
|
|
14
|
+
const exp = (h >>> 10) & 0x1f;
|
|
15
|
+
const man = h & 0x3ff;
|
|
16
|
+
if (exp === 0)
|
|
17
|
+
return sign * man * 2 ** -24;
|
|
18
|
+
if (exp === 31)
|
|
19
|
+
return man === 0 ? sign * Infinity : NaN;
|
|
20
|
+
return sign * (1024 + man) * 2 ** (exp - 25);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=half.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"half.js","sourceRoot":"","sources":["../../src/core/half.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;IACxB,MAAM,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAC9B,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,IAAI,GAAG,KAAK,CAAC;QAAE,OAAO,IAAI,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5C,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC;IACzD,OAAO,IAAI,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * IEEE 754 binary16 -> number, for the few Half fields the pool reads from a\n * grid header (root background and min/max; K7.H). The core never imports\n * `tools` (D20), so this restates `tools`' `vdbHalfToFloat`;\n * `test/core/half.test.ts` checks the two agree on all 65536 bit patterns.\n *\n * Exact: every binary16 value (subnormals, infinities, NaN) is representable\n * as an f32 and as a JS number. Same result as NanoVDB `math::HalfToFloat`\n * (`nanovdb/math/HalfLite.h`, from Imath) and WGSL `unpack2x16float`.\n */\nexport function halfBitsToNumber(bits: number): number {\n const h = bits & 0xffff;\n const sign = h & 0x8000 ? -1 : 1;\n const exp = (h >>> 10) & 0x1f;\n const man = h & 0x3ff;\n if (exp === 0) return sign * man * 2 ** -24;\n if (exp === 31) return man === 0 ? sign * Infinity : NaN;\n return sign * (1024 + man) * 2 ** (exp - 25);\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,
|
|
3
|
+
* the generated `vdb*` WGSL module that reads it, and compute tools that run on it.
|
|
4
|
+
*
|
|
5
|
+
* Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in
|
|
6
|
+
* `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).
|
|
7
|
+
*
|
|
8
|
+
* K6.8 (0.2.0) adds the frame renderer (`vdbCreateFrameRenderer`), the sparse volume source (`vdbSparseSource`), the
|
|
9
|
+
* level-set and point passes, the receiver WGSL for host materials, and `VDBSequence`.
|
|
10
|
+
*
|
|
11
|
+
* This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in
|
|
12
|
+
* `./internal.ts`, imported by path by tests and harnesses; it is not a package export.
|
|
13
|
+
*/
|
|
14
|
+
/// <reference types="@webgpu/types" preserve="true" />
|
|
15
|
+
export { VDBError } from "./errors.js";
|
|
16
|
+
export type { VDBErrorCode } from "./errors.js";
|
|
17
|
+
export { VDBGridPool } from "./pool/pool.js";
|
|
18
|
+
export type { VDBAddOptions, VDBBrickMajorant, VDBBrickMajorantOptions, VDBGridInfo, VDBGridPoolOptions, VDBTransformInput, } from "./pool/pool.js";
|
|
19
|
+
/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */
|
|
20
|
+
export { VDB_GPU_LAYOUT_VERSION } from "./pool/layout.js";
|
|
21
|
+
export type { VDBVec3 } from "./pool/layout.js";
|
|
22
|
+
export { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from "./wgsl/generate.js";
|
|
23
|
+
export type { VDBBufferModuleOptions, VDBModuleCommonOptions, VDBModuleHelper, VDBModuleOptions, VDBModulePoolLike, VDBModuleProfile, VDBModuleTypeCheck, VDBSlotModuleOptions, } from "./wgsl/types.js";
|
|
24
|
+
export { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from "./types.js";
|
|
25
|
+
export type { VDBGridTypeName, VDBSlot } from "./types.js";
|
|
26
|
+
export { vdbApplyValueTransform, vdbDecodeToAtlas, vdbGridStats, VDB_VALUE_TRANSFORM_PRESETS } from "./compute/index.js";
|
|
27
|
+
export { vdbCreateBoxPyramid } from "./compute/index.js";
|
|
28
|
+
export type { VDBBoxPyramid, VDBBoxPyramidOptions, VDBBoxPyramidRecordOptions } from "./compute/index.js";
|
|
29
|
+
export type { VDBBoxPyramidLayout, VDBPyramidAtlasLevel } from "../tools/frame/pyramid-layout.js";
|
|
30
|
+
export type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions, VDBGridStats, VDBGridStatsOptions, VDBReadback, VDBValueTransform, VDBValueTransformPreset, } from "./compute/index.js";
|
|
31
|
+
export { vdbDenseSource } from "./source/dense.js";
|
|
32
|
+
export type { VDBDenseSource, VDBDenseSourceOptions } from "./source/dense.js";
|
|
33
|
+
export type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceInfo, VDBVolumeSourceWgslOptions } from "./source/types.js";
|
|
34
|
+
export { vdbCreateFrameRenderer } from "./frame/renderer.js";
|
|
35
|
+
export type { VDBFrameRenderer, VDBFrameRendererOptions } from "./frame/renderer.js";
|
|
36
|
+
export { vdbFrameDefaultSettings } from "./frame/settings.js";
|
|
37
|
+
export type { VDBFrameSettings, VDBFramePhaseName, VDBFrameMultipleScatteringMode } from "./frame/settings.js";
|
|
38
|
+
export { VDB_FRAME_ALL_LIGHTS, VDB_FRAME_LIGHT_BITS, vdbFrameDefaultVolumeParams } from "./frame/types.js";
|
|
39
|
+
export type { VDBEmissionColor, VDBFrameCamera, VDBFrameEmissionLightSettings, VDBFrameEmissionProbes, VDBFrameEnvironment, VDBFrameInput, VDBFrameLight, VDBFrameMat4, VDBFrameOccluder, VDBFrameOutputs, VDBFrameRedrawStats, VDBFrameTargets, VDBFrameTimestamps, VDBFrameUpdate, VDBFrameUpdateOptions, VDBFrameVec3, VDBFrameVolume, VDBFrameVolumeParams, VDBFrameWrap, VDBFroxelLayout, VDBVolumeShadowDrawn, VDBVolumeShadowMap, VDBVolumeShadowRequest, } from "./frame/types.js";
|
|
40
|
+
/** EXPERIMENTAL (K6.3): the generic small-MLP data of `multipleScattering` `'mlp'` / `'neural'` (`VDBFrameRenderer.mlp`). */
|
|
41
|
+
export type { VDBFrameMlp, VDBFrameMlpLayer } from "../tools/frame/mlp.js";
|
|
42
|
+
export { vdbFrameIntegrateEntries, vdbFrameIntegrateWgsl } from "./frame/wgsl/integrate.js";
|
|
43
|
+
export type { VDBFrameIntegrateWgslOptions } from "./frame/wgsl/integrate.js";
|
|
44
|
+
export { VDB_VOLUME_SHADOW_MAX_CASCADES, VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from "./frame/wgsl/shadows.js";
|
|
45
|
+
export { VDB_EMISSION_GRID, vdbEmissionProbeWgsl } from "./frame/wgsl/emission.js";
|
|
46
|
+
export { vdbSparseSource } from "./source/sparse.js";
|
|
47
|
+
export type { VDBSparseIndexBox, VDBSparseLod, VDBSparseSource, VDBSparseSourceOptions, VDBSparseSourceUpdate, VDBSparseVolume, VDBSparseVolumeOptions, VDBSparseVolumeGrids, } from "./source/sparse.js";
|
|
48
|
+
export type { VDBVolumeSlot } from "./source/types.js";
|
|
49
|
+
export { vdbCreateLevelSetPass, vdbLevelSetSurfaceWgsl, vdbCreatePointPass, vdbPointSpriteWgsl } from "./surface/index.js";
|
|
50
|
+
export type { VDBLevelSetPassDraw, VDBLevelSetPassFrame, VDBLevelSetPass, VDBLevelSetPassOptions, VDBLevelSetPassPool, VDBPointPassData, VDBPointPassFrame, VDBPointPass, VDBPointPassOptions } from "./surface/index.js";
|
|
51
|
+
export { VDBSequence } from "./sequence.js";
|
|
52
|
+
export type { VDBSequenceFrameLoader, VDBSequenceLoopMode, VDBSequenceOptions, VDBSequencePoolLike, VDBSequenceRange, VDBSequenceStats, VDBSequenceTarget } from "./sequence.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
/**
|
|
3
|
+
* @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,
|
|
4
|
+
* the generated `vdb*` WGSL module that reads it, and compute tools that run on it.
|
|
5
|
+
*
|
|
6
|
+
* Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in
|
|
7
|
+
* `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).
|
|
8
|
+
*
|
|
9
|
+
* K6.8 (0.2.0) adds the frame renderer (`vdbCreateFrameRenderer`), the sparse volume source (`vdbSparseSource`), the
|
|
10
|
+
* level-set and point passes, the receiver WGSL for host materials, and `VDBSequence`.
|
|
11
|
+
*
|
|
12
|
+
* This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in
|
|
13
|
+
* `./internal.ts`, imported by path by tests and harnesses; it is not a package export.
|
|
14
|
+
*/
|
|
15
|
+
export { VDBError } from "./errors.js";
|
|
16
|
+
export { VDBGridPool } from "./pool/pool.js";
|
|
17
|
+
/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */
|
|
18
|
+
export { VDB_GPU_LAYOUT_VERSION } from "./pool/layout.js";
|
|
19
|
+
// K1.4a: WGSL module generator (docs/dev/design/K1-core.md §3).
|
|
20
|
+
export { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from "./wgsl/generate.js";
|
|
21
|
+
export { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from "./types.js";
|
|
22
|
+
// K2.3: compute tools on the pool (D36: the GPU is the default and carries no suffix). `@pmndrs/vdb/three` wraps them
|
|
23
|
+
// with the same names (renderer in, promise out) and `@pmndrs/vdb/tools` has the `*Cpu` versions.
|
|
24
|
+
export { vdbApplyValueTransform, vdbDecodeToAtlas, vdbGridStats, VDB_VALUE_TRANSFORM_PRESETS } from "./compute/index.js";
|
|
25
|
+
// K3.2a: the sparse source's coarse pyramid built on the GPU.
|
|
26
|
+
export { vdbCreateBoxPyramid } from "./compute/index.js";
|
|
27
|
+
// K3.0: the volume-source seam (R1 §4.2) and its dense `.wvdb` source.
|
|
28
|
+
export { vdbDenseSource } from "./source/dense.js";
|
|
29
|
+
// K6.8 (0.2.0, D34): the core frame renderer — compute kernels on 3D textures on the host's device, recorded into the
|
|
30
|
+
// host's encoder (design docs/dev/design/K6-core-renderer.md §2). `./three` is a thin adapter over it.
|
|
31
|
+
export { vdbCreateFrameRenderer } from "./frame/renderer.js";
|
|
32
|
+
export { vdbFrameDefaultSettings } from "./frame/settings.js";
|
|
33
|
+
export { VDB_FRAME_ALL_LIGHTS, VDB_FRAME_LIGHT_BITS, vdbFrameDefaultVolumeParams } from "./frame/types.js";
|
|
34
|
+
// Host seams (design §2.5): the composite as a function in the host's own pass, and the receivers of the volume shadow
|
|
35
|
+
// maps (`vdbVolumeShadow`, `vdbVolumeShadowCube`, K6.4 `vdbVolumeShadowRgb`, `vdbVolumeShadowCubeRgb`) and of the emission
|
|
36
|
+
// probes (`vdbEmissionIrradiance`), with the layouts of their uniform buffers.
|
|
37
|
+
export { vdbFrameIntegrateEntries, vdbFrameIntegrateWgsl } from "./frame/wgsl/integrate.js";
|
|
38
|
+
export { VDB_VOLUME_SHADOW_MAX_CASCADES, VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from "./frame/wgsl/shadows.js";
|
|
39
|
+
export { VDB_EMISSION_GRID, vdbEmissionProbeWgsl } from "./frame/wgsl/emission.js";
|
|
40
|
+
// K6.7: one sparse volume source for every volume of a pool (pyramids packed in one atlas).
|
|
41
|
+
export { vdbSparseSource } from "./source/sparse.js";
|
|
42
|
+
// K6.6: level-set surfaces and point sprites (WGSL for host materials, raw passes for engine-free hosts).
|
|
43
|
+
export { vdbCreateLevelSetPass, vdbLevelSetSurfaceWgsl, vdbCreatePointPass, vdbPointSpriteWgsl } from "./surface/index.js";
|
|
44
|
+
// K6.8 (Q7): the sequence player, engine-free (`./three` re-exports it).
|
|
45
|
+
export { VDBSequence } from "./sequence.js";
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAS7C,8EAA8E;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,gEAAgE;AAChE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWrF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE1F,sHAAsH;AACtH,kGAAkG;AAClG,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACzH,8DAA8D;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAezD,uEAAuE;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,sHAAsH;AACtH,uGAAuG;AACvG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AA4B3G,uHAAuH;AACvH,2HAA2H;AAC3H,+EAA+E;AAC/E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE5F,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACnF,4FAA4F;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAYrD,0GAA0G;AAC1G,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE3H,yEAAyE;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/// <reference types=\"@webgpu/types\" preserve=\"true\" />\n/**\n * @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,\n * the generated `vdb*` WGSL module that reads it, and compute tools that run on it.\n *\n * Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in\n * `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).\n *\n * K6.8 (0.2.0) adds the frame renderer (`vdbCreateFrameRenderer`), the sparse volume source (`vdbSparseSource`), the\n * level-set and point passes, the receiver WGSL for host materials, and `VDBSequence`.\n *\n * This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in\n * `./internal.ts`, imported by path by tests and harnesses; it is not a package export.\n */\n\nexport { VDBError } from \"./errors.js\";\nexport type { VDBErrorCode } from \"./errors.js\";\n\nexport { VDBGridPool } from \"./pool/pool.js\";\nexport type {\n VDBAddOptions,\n VDBBrickMajorant,\n VDBBrickMajorantOptions,\n VDBGridInfo,\n VDBGridPoolOptions,\n VDBTransformInput,\n} from \"./pool/pool.js\";\n/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */\nexport { VDB_GPU_LAYOUT_VERSION } from \"./pool/layout.js\";\nexport type { VDBVec3 } from \"./pool/layout.js\";\n// K1.4a: WGSL module generator (docs/dev/design/K1-core.md §3).\nexport { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from \"./wgsl/generate.js\";\nexport type {\n VDBBufferModuleOptions,\n VDBModuleCommonOptions,\n VDBModuleHelper,\n VDBModuleOptions,\n VDBModulePoolLike,\n VDBModuleProfile,\n VDBModuleTypeCheck,\n VDBSlotModuleOptions,\n} from \"./wgsl/types.js\";\nexport { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from \"./types.js\";\nexport type { VDBGridTypeName, VDBSlot } from \"./types.js\";\n// K2.3: compute tools on the pool (D36: the GPU is the default and carries no suffix). `@pmndrs/vdb/three` wraps them\n// with the same names (renderer in, promise out) and `@pmndrs/vdb/tools` has the `*Cpu` versions.\nexport { vdbApplyValueTransform, vdbDecodeToAtlas, vdbGridStats, VDB_VALUE_TRANSFORM_PRESETS } from \"./compute/index.js\";\n// K3.2a: the sparse source's coarse pyramid built on the GPU.\nexport { vdbCreateBoxPyramid } from \"./compute/index.js\";\nexport type { VDBBoxPyramid, VDBBoxPyramidOptions, VDBBoxPyramidRecordOptions } from \"./compute/index.js\";\nexport type { VDBBoxPyramidLayout, VDBPyramidAtlasLevel } from \"../tools/frame/pyramid-layout.js\";\nexport type {\n VDBAtlasFilter,\n VDBAtlasFormat,\n VDBAtlas,\n VDBAtlasReadback,\n VDBDecodeToAtlasOptions,\n VDBGridStats,\n VDBGridStatsOptions,\n VDBReadback,\n VDBValueTransform,\n VDBValueTransformPreset,\n} from \"./compute/index.js\";\n// K3.0: the volume-source seam (R1 §4.2) and its dense `.wvdb` source.\nexport { vdbDenseSource } from \"./source/dense.js\";\nexport type { VDBDenseSource, VDBDenseSourceOptions } from \"./source/dense.js\";\nexport type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceInfo, VDBVolumeSourceWgslOptions } from \"./source/types.js\";\n\n// K6.8 (0.2.0, D34): the core frame renderer — compute kernels on 3D textures on the host's device, recorded into the\n// host's encoder (design docs/dev/design/K6-core-renderer.md §2). `./three` is a thin adapter over it.\nexport { vdbCreateFrameRenderer } from \"./frame/renderer.js\";\nexport type { VDBFrameRenderer, VDBFrameRendererOptions } from \"./frame/renderer.js\";\nexport { vdbFrameDefaultSettings } from \"./frame/settings.js\";\nexport type { VDBFrameSettings, VDBFramePhaseName, VDBFrameMultipleScatteringMode } from \"./frame/settings.js\";\nexport { VDB_FRAME_ALL_LIGHTS, VDB_FRAME_LIGHT_BITS, vdbFrameDefaultVolumeParams } from \"./frame/types.js\";\nexport type {\n VDBEmissionColor,\n VDBFrameCamera,\n VDBFrameEmissionLightSettings,\n VDBFrameEmissionProbes,\n VDBFrameEnvironment,\n VDBFrameInput,\n VDBFrameLight,\n VDBFrameMat4,\n VDBFrameOccluder,\n VDBFrameOutputs,\n VDBFrameRedrawStats,\n VDBFrameTargets,\n VDBFrameTimestamps,\n VDBFrameUpdate,\n VDBFrameUpdateOptions,\n VDBFrameVec3,\n VDBFrameVolume,\n VDBFrameVolumeParams,\n VDBFrameWrap,\n VDBFroxelLayout,\n VDBVolumeShadowDrawn,\n VDBVolumeShadowMap,\n VDBVolumeShadowRequest,\n} from \"./frame/types.js\";\n/** EXPERIMENTAL (K6.3): the generic small-MLP data of `multipleScattering` `'mlp'` / `'neural'` (`VDBFrameRenderer.mlp`). */\nexport type { VDBFrameMlp, VDBFrameMlpLayer } from \"../tools/frame/mlp.js\";\n// Host seams (design §2.5): the composite as a function in the host's own pass, and the receivers of the volume shadow\n// maps (`vdbVolumeShadow`, `vdbVolumeShadowCube`, K6.4 `vdbVolumeShadowRgb`, `vdbVolumeShadowCubeRgb`) and of the emission\n// probes (`vdbEmissionIrradiance`), with the layouts of their uniform buffers.\nexport { vdbFrameIntegrateEntries, vdbFrameIntegrateWgsl } from \"./frame/wgsl/integrate.js\";\nexport type { VDBFrameIntegrateWgslOptions } from \"./frame/wgsl/integrate.js\";\nexport { VDB_VOLUME_SHADOW_MAX_CASCADES, VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from \"./frame/wgsl/shadows.js\";\nexport { VDB_EMISSION_GRID, vdbEmissionProbeWgsl } from \"./frame/wgsl/emission.js\";\n// K6.7: one sparse volume source for every volume of a pool (pyramids packed in one atlas).\nexport { vdbSparseSource } from \"./source/sparse.js\";\nexport type {\n VDBSparseIndexBox,\n VDBSparseLod,\n VDBSparseSource,\n VDBSparseSourceOptions,\n VDBSparseSourceUpdate,\n VDBSparseVolume,\n VDBSparseVolumeOptions,\n VDBSparseVolumeGrids,\n} from \"./source/sparse.js\";\nexport type { VDBVolumeSlot } from \"./source/types.js\";\n// K6.6: level-set surfaces and point sprites (WGSL for host materials, raw passes for engine-free hosts).\nexport { vdbCreateLevelSetPass, vdbLevelSetSurfaceWgsl, vdbCreatePointPass, vdbPointSpriteWgsl } from \"./surface/index.js\";\nexport type { VDBLevelSetPassDraw, VDBLevelSetPassFrame, VDBLevelSetPass, VDBLevelSetPassOptions, VDBLevelSetPassPool, VDBPointPassData, VDBPointPassFrame, VDBPointPass, VDBPointPassOptions } from \"./surface/index.js\";\n// K6.8 (Q7): the sequence player, engine-free (`./three` re-exports it).\nexport { VDBSequence } from \"./sequence.js\";\nexport type { VDBSequenceFrameLoader, VDBSequenceLoopMode, VDBSequenceOptions, VDBSequencePoolLike, VDBSequenceRange, VDBSequenceStats, VDBSequenceTarget } from \"./sequence.js\";\n"]}
|