@pmndrs/vdb 0.1.0 → 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 +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- 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 +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- 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 +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- 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/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- 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 +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- 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 +59 -2
- package/dist/core/source/types.js.map +1 -1
- 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 +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- 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 +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- 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 +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- 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 +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- 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 +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- 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 +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- 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 +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- 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 +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- 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/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- 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 +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- 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 +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- 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 +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- 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 +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- 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 +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- 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 +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- 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 +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- 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 +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- 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 +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- 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 +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- 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/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 +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- 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 +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- 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.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- 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 +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Point sprites (K6.6, design §3.9): the sprite size and attenuation as core WGSL
|
|
3
|
+
* (`vdbPointSpriteWgsl`), which `VDBPoints` (`./three`) calls from its TSL vertex, and a raw sprite pass
|
|
4
|
+
* (`vdbCreatePointPass`) for engine-free hosts. The disc is the adapters' (three keeps his mipmapped
|
|
5
|
+
* alpha map); the raw pass cuts an analytic disc.
|
|
6
|
+
*
|
|
7
|
+
* Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
|
|
8
|
+
* (`src/three-openvdb/points/webgpu/VDBPoints.js`, `points/pointsCore.js`: one instanced quad per point,
|
|
9
|
+
* the attenuated size in pixels with a 1-pixel minimum, the pixel scale `diameter · maxScale · zoom /
|
|
10
|
+
* tan(fov / 2) · height / 2`) and three.js r187 (MIT) `PointsNodeMaterial.setupVertexSprite` (the clip-space
|
|
11
|
+
* offset). Copyright (c) mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: plain WGSL
|
|
12
|
+
* and data; the raw pass's disc is analytic (DIVERGES.md).
|
|
13
|
+
*
|
|
14
|
+
* CPU twins: `tools` `pointSpriteSize`, `pointSpriteVertex`, `pointSpriteClip` (`tools/cpu/points.ts`).
|
|
15
|
+
*/
|
|
16
|
+
import { VDBError } from "../errors.js";
|
|
17
|
+
import { prepareRender, renderPipeline } from "../frame/pipelines.js";
|
|
18
|
+
import { BUFFER_USAGE, STAGE, VDBRetireQueue } from "../frame/resources.js";
|
|
19
|
+
import { VDBUniformWriter, vdbUniformStruct } from "../frame/uniforms.js";
|
|
20
|
+
import { vdbMat4MaxScale, vdbMat4Multiply } from "../../tools/frame/view.js";
|
|
21
|
+
/**
|
|
22
|
+
* The WGSL text of the sprite functions (no bindings, no module):
|
|
23
|
+
*
|
|
24
|
+
* ```wgsl
|
|
25
|
+
* fn vdbPointSpriteSize(pixelScale: f32, viewDepth: f32, minSize: f32) -> f32;
|
|
26
|
+
* fn vdbPointSpriteVertex(clipCentre: vec4f, corner: vec2f, sizePx: f32, viewportSize: vec2f) -> vec4f;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* - `vdbPointSpriteSize`: the sprite's width in pixels, `max(pixelScale / viewDepth, minSize)` (his 1-pixel
|
|
30
|
+
* minimum: sprites under a pixel are still drawn); `viewDepth` is the point's distance along the view
|
|
31
|
+
* axis (`−view.z`).
|
|
32
|
+
* - `vdbPointSpriteVertex`: a quad corner's clip position, `clipCentre + (corner · sizePx / (viewportSize / 2)
|
|
33
|
+
* · clipCentre.w, 0, 0)`; `corner` in `[−0.5, 0.5]²`, `viewportSize` in pixels. The quad is `sizePx` wide
|
|
34
|
+
* on screen whatever the depth.
|
|
35
|
+
*/
|
|
36
|
+
export function vdbPointSpriteWgsl() {
|
|
37
|
+
return POINT_SPRITE_WGSL;
|
|
38
|
+
}
|
|
39
|
+
const POINT_SPRITE_WGSL = /* wgsl */ `fn vdbPointSpriteSize(pixelScale: f32, viewDepth: f32, minSize: f32) -> f32 {
|
|
40
|
+
return max(pixelScale / viewDepth, minSize);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fn vdbPointSpriteVertex(clipCentre: vec4f, corner: vec2f, sizePx: f32, viewportSize: vec2f) -> vec4f {
|
|
44
|
+
return clipCentre + vec4f(corner * sizePx / (viewportSize * 0.5) * clipCentre.w, 0.0, 0.0);
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
/**
|
|
48
|
+
* The pixel scale of {@link vdbPointSpriteSize} (pixels at view depth 1) for a point of world diameter
|
|
49
|
+
* `diameter`: `diameter · maxScale(model) · projection[5] · height / 2`. For a perspective projection
|
|
50
|
+
* `projection[5]` is `zoom / tan(fov / 2)`, his `getAttenuatedPointSize` · `height / 2`.
|
|
51
|
+
*
|
|
52
|
+
* @param diameter World diameter of a point (before the model scale).
|
|
53
|
+
* @param projection Column-major view → clip.
|
|
54
|
+
* @param height Viewport height in pixels.
|
|
55
|
+
* @param model Column-major local → world (default identity).
|
|
56
|
+
*/
|
|
57
|
+
export function vdbPointPixelScale(diameter, projection, height, model) {
|
|
58
|
+
return diameter * (model ? vdbMat4MaxScale(model) : 1) * projection[5] * height * 0.5;
|
|
59
|
+
}
|
|
60
|
+
/** Group 0 binding 0. */
|
|
61
|
+
export const VDB_POINT_PASS_FRAME = vdbUniformStruct("VdbPointPassFrame", [
|
|
62
|
+
{ name: "modelView", type: "mat4x4f" },
|
|
63
|
+
{ name: "projection", type: "mat4x4f" },
|
|
64
|
+
{ name: "viewport", type: "vec4f" },
|
|
65
|
+
{ name: "color", type: "vec4f" },
|
|
66
|
+
// pixelScale, minSize
|
|
67
|
+
{ name: "params", type: "vec4f" },
|
|
68
|
+
]);
|
|
69
|
+
/** The quad's 6 corners (two triangles, three's sprite index order 0 1 2, 0 2 3). */
|
|
70
|
+
export const VDB_POINT_SPRITE_CORNERS = Object.freeze([
|
|
71
|
+
[-0.5, -0.5],
|
|
72
|
+
[0.5, -0.5],
|
|
73
|
+
[0.5, 0.5],
|
|
74
|
+
[-0.5, -0.5],
|
|
75
|
+
[0.5, 0.5],
|
|
76
|
+
[-0.5, 0.5],
|
|
77
|
+
]);
|
|
78
|
+
/** The raw pass's WGSL (`colors`: with the per-point colour attribute). */
|
|
79
|
+
export function vdbPointPassWgsl(colors) {
|
|
80
|
+
const corners = VDB_POINT_SPRITE_CORNERS.map(([x, y]) => `vec2f(${x.toFixed(1)}, ${y.toFixed(1)})`).join(", ");
|
|
81
|
+
return /* wgsl */ `${POINT_SPRITE_WGSL}
|
|
82
|
+
${VDB_POINT_PASS_FRAME.wgsl}
|
|
83
|
+
@group(0) @binding(0) var<uniform> vdbPtFrame: VdbPointPassFrame;
|
|
84
|
+
|
|
85
|
+
struct VdbPointPassVaryings {
|
|
86
|
+
@builtin(position) position: vec4f,
|
|
87
|
+
@location(0) corner: vec2f,
|
|
88
|
+
@location(1) color: vec3f,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
@vertex
|
|
92
|
+
fn vdbPointPassVs(@builtin(vertex_index) i: u32, @location(0) local: vec3f${colors ? ", @location(1) rgb: vec3f" : ""}) -> VdbPointPassVaryings {
|
|
93
|
+
var quad = array<vec2f, 6>(${corners});
|
|
94
|
+
let view = vdbPtFrame.modelView * vec4f(local, 1.0);
|
|
95
|
+
let size = vdbPointSpriteSize(vdbPtFrame.params.x, -view.z, vdbPtFrame.params.y);
|
|
96
|
+
var o: VdbPointPassVaryings;
|
|
97
|
+
o.corner = quad[i];
|
|
98
|
+
o.position = vdbPointSpriteVertex(vdbPtFrame.projection * view, o.corner, size, vdbPtFrame.viewport.zw);
|
|
99
|
+
o.color = vdbPtFrame.color.rgb${colors ? " * rgb" : ""};
|
|
100
|
+
return o;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@fragment
|
|
104
|
+
fn vdbPointPassFs(v: VdbPointPassVaryings) -> @location(0) vec4f {
|
|
105
|
+
if dot(v.corner, v.corner) > 0.25 {
|
|
106
|
+
discard;
|
|
107
|
+
}
|
|
108
|
+
return vec4f(v.color, 1.0);
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
function bad(message) {
|
|
113
|
+
return new VDBError("VDB_BAD_OPTION", `vdbCreatePointPass: ${message}`);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a raw point-sprite pass on `device` (see the file comment): one instanced quad per point, an
|
|
117
|
+
* analytic round disc, depth-tested when `depthFormat` is set.
|
|
118
|
+
*
|
|
119
|
+
* @throws VDBError `VDB_BAD_OPTION` for bad options or data.
|
|
120
|
+
*/
|
|
121
|
+
export function vdbCreatePointPass(device, options) {
|
|
122
|
+
if (!options || typeof options.colorFormat !== "string")
|
|
123
|
+
throw bad("colorFormat is required.");
|
|
124
|
+
const label = options.label ?? "vdb point pass";
|
|
125
|
+
const groups = [{ entries: [{ binding: 0, visibility: STAGE.VERTEX | STAGE.FRAGMENT, buffer: { type: "uniform" } }] }];
|
|
126
|
+
const attribute = (location) => ({ arrayStride: 12, stepMode: "instance", attributes: [{ shaderLocation: location, offset: 0, format: "float32x3" }] });
|
|
127
|
+
const spec = (colors) => ({
|
|
128
|
+
label: `${label}${colors ? " (colors)" : ""}`,
|
|
129
|
+
code: vdbPointPassWgsl(colors),
|
|
130
|
+
vertexEntryPoint: "vdbPointPassVs",
|
|
131
|
+
fragmentEntryPoint: "vdbPointPassFs",
|
|
132
|
+
groups,
|
|
133
|
+
targets: [{ format: options.colorFormat }],
|
|
134
|
+
buffers: colors ? [attribute(0), attribute(1)] : [attribute(0)],
|
|
135
|
+
primitive: { topology: "triangle-list", cullMode: "none" },
|
|
136
|
+
...(options.depthFormat ? { depthStencil: { format: options.depthFormat, depthWriteEnabled: true, depthCompare: options.depthCompare ?? "less" } } : {}),
|
|
137
|
+
});
|
|
138
|
+
const specs = [spec(false), spec(true)];
|
|
139
|
+
const retire = new VDBRetireQueue();
|
|
140
|
+
const writer = new VDBUniformWriter(VDB_POINT_PASS_FRAME.size);
|
|
141
|
+
let uniforms = null;
|
|
142
|
+
let group = null;
|
|
143
|
+
let positions = null;
|
|
144
|
+
let colors = null;
|
|
145
|
+
let count = 0;
|
|
146
|
+
let disposed = false;
|
|
147
|
+
const alive = () => {
|
|
148
|
+
if (disposed)
|
|
149
|
+
throw new VDBError("VDB_DISPOSED", `${label}: disposed.`);
|
|
150
|
+
};
|
|
151
|
+
const upload = (data, n, what) => {
|
|
152
|
+
const b = device.createBuffer({ label: `${label} ${what}`, size: Math.max(16, n * 12), usage: 0x20 /* VERTEX */ | BUFFER_USAGE.COPY_DST });
|
|
153
|
+
if (n > 0)
|
|
154
|
+
device.queue.writeBuffer(b, 0, data.buffer, data.byteOffset, n * 12);
|
|
155
|
+
return b;
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
device,
|
|
159
|
+
get count() {
|
|
160
|
+
return count;
|
|
161
|
+
},
|
|
162
|
+
specs,
|
|
163
|
+
setPoints(data) {
|
|
164
|
+
alive();
|
|
165
|
+
if (!data || !(data.positions instanceof Float32Array) || data.positions.length % 3 !== 0)
|
|
166
|
+
throw bad("positions must be a Float32Array of xyz triples.");
|
|
167
|
+
const n = data.count ?? data.positions.length / 3;
|
|
168
|
+
if (!Number.isInteger(n) || n < 0 || n * 3 > data.positions.length)
|
|
169
|
+
throw bad(`count ${n} does not fit ${data.positions.length / 3} positions.`);
|
|
170
|
+
if (data.colors && data.colors.length < n * 3)
|
|
171
|
+
throw bad("colors must hold count * 3 values.");
|
|
172
|
+
retire.retire(positions);
|
|
173
|
+
retire.retire(colors);
|
|
174
|
+
positions = upload(data.positions, n, "positions");
|
|
175
|
+
colors = data.colors ? upload(data.colors, n, "colors") : null;
|
|
176
|
+
count = n;
|
|
177
|
+
},
|
|
178
|
+
async prepare() {
|
|
179
|
+
alive();
|
|
180
|
+
await Promise.all(specs.map((s) => prepareRender(device, s)));
|
|
181
|
+
},
|
|
182
|
+
record(renderPass, frame) {
|
|
183
|
+
alive();
|
|
184
|
+
retire.advance();
|
|
185
|
+
if (!positions || count === 0)
|
|
186
|
+
return;
|
|
187
|
+
if (!frame || !frame.view || !frame.projection || !frame.viewport)
|
|
188
|
+
throw bad("record: frame needs view, projection and viewport.");
|
|
189
|
+
const [, , vw, vh] = frame.viewport;
|
|
190
|
+
if (!(vw > 0 && vh > 0))
|
|
191
|
+
throw bad(`record: viewport width and height must be > 0, got ${JSON.stringify(frame.viewport)}.`);
|
|
192
|
+
const s = VDB_POINT_PASS_FRAME;
|
|
193
|
+
const modelView = frame.model ? vdbMat4Multiply(frame.view, frame.model) : frame.view;
|
|
194
|
+
const pixelScale = frame.pixelScale ?? vdbPointPixelScale(frame.diameter ?? 1, frame.projection, vh, frame.model);
|
|
195
|
+
writer.set(s, 0, "modelView", modelView);
|
|
196
|
+
writer.set(s, 0, "projection", frame.projection);
|
|
197
|
+
writer.set(s, 0, "viewport", frame.viewport);
|
|
198
|
+
writer.set(s, 0, "color", [...(frame.color ?? [1, 1, 1]), 1]);
|
|
199
|
+
writer.set(s, 0, "params", [pixelScale, frame.minSize ?? 1, 0, 0]);
|
|
200
|
+
const built = renderPipeline(device, specs[colors ? 1 : 0]);
|
|
201
|
+
if (!uniforms) {
|
|
202
|
+
uniforms = device.createBuffer({ label: `${label} uniforms`, size: s.size, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });
|
|
203
|
+
group = device.createBindGroup({ label: `${label} group 0`, layout: built.layouts[0], entries: [{ binding: 0, resource: { buffer: uniforms } }] });
|
|
204
|
+
}
|
|
205
|
+
device.queue.writeBuffer(uniforms, 0, writer.buffer);
|
|
206
|
+
renderPass.setPipeline(built.pipeline);
|
|
207
|
+
renderPass.setBindGroup(0, group);
|
|
208
|
+
renderPass.setVertexBuffer(0, positions);
|
|
209
|
+
if (colors)
|
|
210
|
+
renderPass.setVertexBuffer(1, colors);
|
|
211
|
+
renderPass.draw(6, count);
|
|
212
|
+
},
|
|
213
|
+
dispose() {
|
|
214
|
+
if (disposed)
|
|
215
|
+
return;
|
|
216
|
+
disposed = true;
|
|
217
|
+
retire.drain();
|
|
218
|
+
uniforms?.destroy();
|
|
219
|
+
positions?.destroy();
|
|
220
|
+
colors?.destroy();
|
|
221
|
+
uniforms = positions = colors = null;
|
|
222
|
+
group = null;
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=points.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"points.js","sourceRoot":"","sources":["../../../src/core/surface/points.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAsB,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE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AC,CAAC;QAC5B,CAAC;QACD,OAAO;YACL,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,QAAQ,EAAE,OAAO,EAAE,CAAC;YACpB,SAAS,EAAE,OAAO,EAAE,CAAC;YACrB,MAAM,EAAE,OAAO,EAAE,CAAC;YAClB,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;YACrC,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Point sprites (K6.6, design §3.9): the sprite size and attenuation as core WGSL\n * (`vdbPointSpriteWgsl`), which `VDBPoints` (`./three`) calls from its TSL vertex, and a raw sprite pass\n * (`vdbCreatePointPass`) for engine-free hosts. The disc is the adapters' (three keeps his mipmapped\n * alpha map); the raw pass cuts an analytic disc.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/three-openvdb/points/webgpu/VDBPoints.js`, `points/pointsCore.js`: one instanced quad per point,\n * the attenuated size in pixels with a 1-pixel minimum, the pixel scale `diameter · maxScale · zoom /\n * tan(fov / 2) · height / 2`) and three.js r187 (MIT) `PointsNodeMaterial.setupVertexSprite` (the clip-space\n * offset). Copyright (c) mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: plain WGSL\n * and data; the raw pass's disc is analytic (DIVERGES.md).\n *\n * CPU twins: `tools` `pointSpriteSize`, `pointSpriteVertex`, `pointSpriteClip` (`tools/cpu/points.ts`).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport type { VDBVec3 } from \"../pool/layout.js\";\nimport { prepareRender, renderPipeline, type VDBRenderSpec } from \"../frame/pipelines.js\";\nimport { BUFFER_USAGE, STAGE, VDBRetireQueue } from \"../frame/resources.js\";\nimport { VDBUniformWriter, vdbUniformStruct } from \"../frame/uniforms.js\";\nimport { vdbMat4MaxScale, vdbMat4Multiply, type VDBMat4 } from \"../../tools/frame/view.js\";\n\n/**\n * The WGSL text of the sprite functions (no bindings, no module):\n *\n * ```wgsl\n * fn vdbPointSpriteSize(pixelScale: f32, viewDepth: f32, minSize: f32) -> f32;\n * fn vdbPointSpriteVertex(clipCentre: vec4f, corner: vec2f, sizePx: f32, viewportSize: vec2f) -> vec4f;\n * ```\n *\n * - `vdbPointSpriteSize`: the sprite's width in pixels, `max(pixelScale / viewDepth, minSize)` (his 1-pixel\n * minimum: sprites under a pixel are still drawn); `viewDepth` is the point's distance along the view\n * axis (`−view.z`).\n * - `vdbPointSpriteVertex`: a quad corner's clip position, `clipCentre + (corner · sizePx / (viewportSize / 2)\n * · clipCentre.w, 0, 0)`; `corner` in `[−0.5, 0.5]²`, `viewportSize` in pixels. The quad is `sizePx` wide\n * on screen whatever the depth.\n */\nexport function vdbPointSpriteWgsl(): string {\n return POINT_SPRITE_WGSL;\n}\n\nconst POINT_SPRITE_WGSL = /* wgsl */ `fn vdbPointSpriteSize(pixelScale: f32, viewDepth: f32, minSize: f32) -> f32 {\n return max(pixelScale / viewDepth, minSize);\n}\n\nfn vdbPointSpriteVertex(clipCentre: vec4f, corner: vec2f, sizePx: f32, viewportSize: vec2f) -> vec4f {\n return clipCentre + vec4f(corner * sizePx / (viewportSize * 0.5) * clipCentre.w, 0.0, 0.0);\n}\n`;\n\n/**\n * The pixel scale of {@link vdbPointSpriteSize} (pixels at view depth 1) for a point of world diameter\n * `diameter`: `diameter · maxScale(model) · projection[5] · height / 2`. For a perspective projection\n * `projection[5]` is `zoom / tan(fov / 2)`, his `getAttenuatedPointSize` · `height / 2`.\n *\n * @param diameter World diameter of a point (before the model scale).\n * @param projection Column-major view → clip.\n * @param height Viewport height in pixels.\n * @param model Column-major local → world (default identity).\n */\nexport function vdbPointPixelScale(diameter: number, projection: VDBMat4, height: number, model?: VDBMat4): number {\n return diameter * (model ? vdbMat4MaxScale(model) : 1) * projection[5]! * height * 0.5;\n}\n\n/** Options of {@link vdbCreatePointPass}. */\nexport interface VDBPointPassOptions {\n readonly colorFormat: GPUTextureFormat;\n /** Depth attachment format, or null for none. Default null. */\n readonly depthFormat?: GPUTextureFormat | null;\n /** Depth test when `depthFormat` is set. Default `'less'`. */\n readonly depthCompare?: GPUCompareFunction;\n readonly label?: string;\n}\n\n/** Points to draw (tools `vdbPointRenderData` returns one). */\nexport interface VDBPointPassData {\n /** Local positions, xyz per point. */\n readonly positions: Float32Array;\n /** Linear RGB per point (times the frame colour), or null. */\n readonly colors?: Float32Array | null;\n /** Points to draw. Default `positions.length / 3`. */\n readonly count?: number;\n}\n\n/** The camera of one {@link VDBPointPass.record}. Matrices are column-major. */\nexport interface VDBPointPassFrame {\n readonly view: VDBMat4;\n readonly projection: VDBMat4;\n /** Local → world. Default identity. */\n readonly model?: VDBMat4;\n /** The render pass's viewport in attachment pixels: `[x, y, width, height]`. */\n readonly viewport: readonly [number, number, number, number];\n /** Pixels at view depth 1. Default {@link vdbPointPixelScale}`(diameter, projection, height, model)`. */\n readonly pixelScale?: number;\n /** World diameter for the default pixel scale. Default 1. */\n readonly diameter?: number;\n /** Smallest sprite in pixels. Default 1. */\n readonly minSize?: number;\n /** Colour (times each point's colour). Default white. */\n readonly color?: VDBVec3;\n}\n\n/** A raw point-sprite pass (see the file comment). */\nexport interface VDBPointPass {\n readonly device: GPUDevice;\n /** Points of the last {@link setPoints}. */\n readonly count: number;\n /** The pipeline spec without (`[0]`) and with (`[1]`) the colour attribute. */\n readonly specs: readonly [VDBRenderSpec, VDBRenderSpec];\n /** Uploads the points into buffers the pass owns (the old ones are retired). */\n setPoints(data: VDBPointPassData): void;\n /** Builds both pipelines with the async creators (optional). */\n prepare(): Promise<void>;\n /** Records one instanced draw into the host's render pass (one `record()` per submitted encoder). */\n record(renderPass: GPURenderPassEncoder, frame: VDBPointPassFrame): void;\n /** Destroys the buffers the pass made. Idempotent. */\n dispose(): void;\n}\n\n/** Group 0 binding 0. */\nexport const VDB_POINT_PASS_FRAME = vdbUniformStruct(\"VdbPointPassFrame\", [\n { name: \"modelView\", type: \"mat4x4f\" },\n { name: \"projection\", type: \"mat4x4f\" },\n { name: \"viewport\", type: \"vec4f\" },\n { name: \"color\", type: \"vec4f\" },\n // pixelScale, minSize\n { name: \"params\", type: \"vec4f\" },\n]);\n\n/** The quad's 6 corners (two triangles, three's sprite index order 0 1 2, 0 2 3). */\nexport const VDB_POINT_SPRITE_CORNERS: readonly (readonly [number, number])[] = Object.freeze([\n [-0.5, -0.5],\n [0.5, -0.5],\n [0.5, 0.5],\n [-0.5, -0.5],\n [0.5, 0.5],\n [-0.5, 0.5],\n]);\n\n/** The raw pass's WGSL (`colors`: with the per-point colour attribute). */\nexport function vdbPointPassWgsl(colors: boolean): string {\n const corners = VDB_POINT_SPRITE_CORNERS.map(([x, y]) => `vec2f(${x.toFixed(1)}, ${y.toFixed(1)})`).join(\", \");\n return /* wgsl */ `${POINT_SPRITE_WGSL}\n${VDB_POINT_PASS_FRAME.wgsl}\n@group(0) @binding(0) var<uniform> vdbPtFrame: VdbPointPassFrame;\n\nstruct VdbPointPassVaryings {\n @builtin(position) position: vec4f,\n @location(0) corner: vec2f,\n @location(1) color: vec3f,\n};\n\n@vertex\nfn vdbPointPassVs(@builtin(vertex_index) i: u32, @location(0) local: vec3f${colors ? \", @location(1) rgb: vec3f\" : \"\"}) -> VdbPointPassVaryings {\n var quad = array<vec2f, 6>(${corners});\n let view = vdbPtFrame.modelView * vec4f(local, 1.0);\n let size = vdbPointSpriteSize(vdbPtFrame.params.x, -view.z, vdbPtFrame.params.y);\n var o: VdbPointPassVaryings;\n o.corner = quad[i];\n o.position = vdbPointSpriteVertex(vdbPtFrame.projection * view, o.corner, size, vdbPtFrame.viewport.zw);\n o.color = vdbPtFrame.color.rgb${colors ? \" * rgb\" : \"\"};\n return o;\n}\n\n@fragment\nfn vdbPointPassFs(v: VdbPointPassVaryings) -> @location(0) vec4f {\n if dot(v.corner, v.corner) > 0.25 {\n discard;\n }\n return vec4f(v.color, 1.0);\n}\n`;\n}\n\nfunction bad(message: string): VDBError {\n return new VDBError(\"VDB_BAD_OPTION\", `vdbCreatePointPass: ${message}`);\n}\n\n/**\n * Creates a raw point-sprite pass on `device` (see the file comment): one instanced quad per point, an\n * analytic round disc, depth-tested when `depthFormat` is set.\n *\n * @throws VDBError `VDB_BAD_OPTION` for bad options or data.\n */\nexport function vdbCreatePointPass(device: GPUDevice, options: VDBPointPassOptions): VDBPointPass {\n if (!options || typeof options.colorFormat !== \"string\") throw bad(\"colorFormat is required.\");\n const label = options.label ?? \"vdb point pass\";\n const groups = [{ entries: [{ binding: 0, visibility: STAGE.VERTEX | STAGE.FRAGMENT, buffer: { type: \"uniform\" as const } }] }];\n const attribute = (location: number): GPUVertexBufferLayout => ({ arrayStride: 12, stepMode: \"instance\", attributes: [{ shaderLocation: location, offset: 0, format: \"float32x3\" }] });\n const spec = (colors: boolean): VDBRenderSpec => ({\n label: `${label}${colors ? \" (colors)\" : \"\"}`,\n code: vdbPointPassWgsl(colors),\n vertexEntryPoint: \"vdbPointPassVs\",\n fragmentEntryPoint: \"vdbPointPassFs\",\n groups,\n targets: [{ format: options.colorFormat }],\n buffers: colors ? [attribute(0), attribute(1)] : [attribute(0)],\n primitive: { topology: \"triangle-list\", cullMode: \"none\" },\n ...(options.depthFormat ? { depthStencil: { format: options.depthFormat, depthWriteEnabled: true, depthCompare: options.depthCompare ?? \"less\" } } : {}),\n });\n const specs = [spec(false), spec(true)] as const;\n const retire = new VDBRetireQueue();\n const writer = new VDBUniformWriter(VDB_POINT_PASS_FRAME.size);\n let uniforms: GPUBuffer | null = null;\n let group: GPUBindGroup | null = null;\n let positions: GPUBuffer | null = null;\n let colors: GPUBuffer | null = null;\n let count = 0;\n let disposed = false;\n const alive = () => {\n if (disposed) throw new VDBError(\"VDB_DISPOSED\", `${label}: disposed.`);\n };\n const upload = (data: Float32Array, n: number, what: string): GPUBuffer => {\n const b = device.createBuffer({ label: `${label} ${what}`, size: Math.max(16, n * 12), usage: 0x20 /* VERTEX */ | BUFFER_USAGE.COPY_DST });\n if (n > 0) device.queue.writeBuffer(b, 0, data.buffer, data.byteOffset, n * 12);\n return b;\n };\n\n return {\n device,\n get count() {\n return count;\n },\n specs,\n setPoints(data) {\n alive();\n if (!data || !(data.positions instanceof Float32Array) || data.positions.length % 3 !== 0) throw bad(\"positions must be a Float32Array of xyz triples.\");\n const n = data.count ?? data.positions.length / 3;\n if (!Number.isInteger(n) || n < 0 || n * 3 > data.positions.length) throw bad(`count ${n} does not fit ${data.positions.length / 3} positions.`);\n if (data.colors && data.colors.length < n * 3) throw bad(\"colors must hold count * 3 values.\");\n retire.retire(positions);\n retire.retire(colors);\n positions = upload(data.positions, n, \"positions\");\n colors = data.colors ? upload(data.colors, n, \"colors\") : null;\n count = n;\n },\n async prepare() {\n alive();\n await Promise.all(specs.map((s) => prepareRender(device, s)));\n },\n record(renderPass, frame) {\n alive();\n retire.advance();\n if (!positions || count === 0) return;\n if (!frame || !frame.view || !frame.projection || !frame.viewport) throw bad(\"record: frame needs view, projection and viewport.\");\n const [, , vw, vh] = frame.viewport;\n if (!(vw > 0 && vh > 0)) throw bad(`record: viewport width and height must be > 0, got ${JSON.stringify(frame.viewport)}.`);\n const s = VDB_POINT_PASS_FRAME;\n const modelView = frame.model ? vdbMat4Multiply(frame.view, frame.model) : frame.view;\n const pixelScale = frame.pixelScale ?? vdbPointPixelScale(frame.diameter ?? 1, frame.projection, vh, frame.model);\n writer.set(s, 0, \"modelView\", modelView);\n writer.set(s, 0, \"projection\", frame.projection);\n writer.set(s, 0, \"viewport\", frame.viewport);\n writer.set(s, 0, \"color\", [...(frame.color ?? [1, 1, 1]), 1]);\n writer.set(s, 0, \"params\", [pixelScale, frame.minSize ?? 1, 0, 0]);\n const built = renderPipeline(device, specs[colors ? 1 : 0]);\n if (!uniforms) {\n uniforms = device.createBuffer({ label: `${label} uniforms`, size: s.size, usage: BUFFER_USAGE.UNIFORM | BUFFER_USAGE.COPY_DST });\n group = device.createBindGroup({ label: `${label} group 0`, layout: built.layouts[0]!, entries: [{ binding: 0, resource: { buffer: uniforms } }] });\n }\n device.queue.writeBuffer(uniforms, 0, writer.buffer);\n renderPass.setPipeline(built.pipeline);\n renderPass.setBindGroup(0, group!);\n renderPass.setVertexBuffer(0, positions);\n if (colors) renderPass.setVertexBuffer(1, colors);\n renderPass.draw(6, count);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n retire.drain();\n uniforms?.destroy();\n positions?.destroy();\n colors?.destroy();\n uniforms = positions = colors = null;\n group = null;\n },\n };\n}\n"]}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -2,15 +2,22 @@
|
|
|
2
2
|
* Types and tables shared by the pool (`pool/`) and the WGSL generator
|
|
3
3
|
* (`wgsl/`). One home so the two cannot drift (K1 integration).
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Grid value types the pool can hold and the generated WGSL can decode (NanoVDB
|
|
7
|
+
* `GridType` ids 1, 13-16 and 9). `half` is NanoVDB's `GridType::Half` (raw IEEE
|
|
8
|
+
* binary16 values, implemented in NanoVDB 13.2; K7.H).
|
|
9
|
+
*/
|
|
10
|
+
export type VDBGridTypeName = "float" | "fp4" | "fp8" | "fp16" | "fpn" | "half";
|
|
7
11
|
/**
|
|
8
12
|
* NanoVDB `GridType` id per name (`PNANOVDB_GRID_TYPE_*` in the vendored module).
|
|
9
13
|
* `test/core/types.test.ts` checks it against the vendored stride tables, the
|
|
10
14
|
* vendored WGSL constants and `tools`.
|
|
11
15
|
*/
|
|
12
16
|
export declare const VDB_GRID_TYPE_IDS: Readonly<Record<VDBGridTypeName, number>>;
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Canonical order; the generator sorts `types` into it so equal sets give equal
|
|
19
|
+
* bytes. `half` came last (K7.H), so the order of the older types is unchanged.
|
|
20
|
+
*/
|
|
14
21
|
export declare const VDB_GRID_TYPE_NAMES: readonly VDBGridTypeName[];
|
|
15
22
|
/**
|
|
16
23
|
* Every scalar grid type the pool can hold, for
|
|
@@ -23,6 +30,8 @@ export declare const VDB_GRID_TYPE_NAMES: readonly VDBGridTypeName[];
|
|
|
23
30
|
export declare const VDB_ALL_SCALAR_TYPES: readonly VDBGridTypeName[];
|
|
24
31
|
/** Where a kernel binds the pool: `@group(group) @binding(firstBinding)`. Layout 1 uses one binding (D10). */
|
|
25
32
|
export interface VDBSlot {
|
|
33
|
+
/** The bind group index. */
|
|
26
34
|
readonly group: number;
|
|
35
|
+
/** The binding index of the pool buffer within the group. */
|
|
27
36
|
readonly firstBinding: number;
|
|
28
37
|
}
|
package/dist/core/types.js
CHANGED
|
@@ -13,9 +13,13 @@ export const VDB_GRID_TYPE_IDS = {
|
|
|
13
13
|
fp8: 14,
|
|
14
14
|
fp16: 15,
|
|
15
15
|
fpn: 16,
|
|
16
|
+
half: 9,
|
|
16
17
|
};
|
|
17
|
-
/**
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Canonical order; the generator sorts `types` into it so equal sets give equal
|
|
20
|
+
* bytes. `half` came last (K7.H), so the order of the older types is unchanged.
|
|
21
|
+
*/
|
|
22
|
+
export const VDB_GRID_TYPE_NAMES = ["float", "fp4", "fp8", "fp16", "fpn", "half"];
|
|
19
23
|
/**
|
|
20
24
|
* Every scalar grid type the pool can hold, for
|
|
21
25
|
* `vdbModuleWgsl({ types: VDB_ALL_SCALAR_TYPES, ... })`: a module that reads
|
package/dist/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA8C;IAC1E,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,CAAC;CACR,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA+B,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE9G;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA+B,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Types and tables shared by the pool (`pool/`) and the WGSL generator\n * (`wgsl/`). One home so the two cannot drift (K1 integration).\n */\n\n/**\n * Grid value types the pool can hold and the generated WGSL can decode (NanoVDB\n * `GridType` ids 1, 13-16 and 9). `half` is NanoVDB's `GridType::Half` (raw IEEE\n * binary16 values, implemented in NanoVDB 13.2; K7.H).\n */\nexport type VDBGridTypeName = \"float\" | \"fp4\" | \"fp8\" | \"fp16\" | \"fpn\" | \"half\";\n\n/**\n * NanoVDB `GridType` id per name (`PNANOVDB_GRID_TYPE_*` in the vendored module).\n * `test/core/types.test.ts` checks it against the vendored stride tables, the\n * vendored WGSL constants and `tools`.\n */\nexport const VDB_GRID_TYPE_IDS: Readonly<Record<VDBGridTypeName, number>> = {\n float: 1,\n fp4: 13,\n fp8: 14,\n fp16: 15,\n fpn: 16,\n half: 9,\n};\n\n/**\n * Canonical order; the generator sorts `types` into it so equal sets give equal\n * bytes. `half` came last (K7.H), so the order of the older types is unchanged.\n */\nexport const VDB_GRID_TYPE_NAMES: readonly VDBGridTypeName[] = [\"float\", \"fp4\", \"fp8\", \"fp16\", \"fpn\", \"half\"];\n\n/**\n * Every scalar grid type the pool can hold, for\n * `vdbModuleWgsl({ types: VDB_ALL_SCALAR_TYPES, ... })`: a module that reads\n * any grid a host may add later, so it never has to be regenerated and its\n * pipeline rebuilt. The price is the largest module (every decoder); a host\n * that knows its types up front should list just those. Same contents and\n * order as {@link VDB_GRID_TYPE_NAMES}.\n */\nexport const VDB_ALL_SCALAR_TYPES: readonly VDBGridTypeName[] = Object.freeze([...VDB_GRID_TYPE_NAMES]);\n\n/** Where a kernel binds the pool: `@group(group) @binding(firstBinding)`. Layout 1 uses one binding (D10). */\nexport interface VDBSlot {\n /** The bind group index. */\n readonly group: number;\n /** The binding index of the pool buffer within the group. */\n readonly firstBinding: number;\n}\n"]}
|
package/dist/core/wgsl/api.d.ts
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* Every pool read goes through `vdb_load`, the module's one buffer access,
|
|
8
8
|
* which the generator emits for the chosen binding mode.
|
|
9
9
|
*
|
|
10
|
-
* Layers stack: `sample` includes `read`, `march` includes `sample
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Layers stack: `sample` includes `read`, `march` includes `sample`, and
|
|
11
|
+
* `majorant` (P1.3) includes `sample` and, with `majorant: 'nodeMax'`, `march`
|
|
12
|
+
* (`./majorant.ts`). `reader: 'lean'` (P1.5) swaps the vendored accessor for
|
|
13
|
+
* `./lean.ts`. Each layer is a function of the normalized options and the
|
|
14
|
+
* profile rank.
|
|
13
15
|
*
|
|
14
16
|
* Conventions every layer keeps:
|
|
15
17
|
* - A grid id is usable when it is below `vdbGridCount()` and its record is
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
* occupies `[i, i + 1)` for ray clipping and traversal.
|
|
21
23
|
*/
|
|
22
24
|
import type { VDBGridTypeName } from "../types.js";
|
|
25
|
+
import { type VDBMajorantMode } from "./majorant.js";
|
|
23
26
|
import type { VDBModuleHelper } from "./types.js";
|
|
24
27
|
/** Options the API layer depends on (normalized by the generator). */
|
|
25
28
|
export interface ApiOptions {
|
|
@@ -29,13 +32,34 @@ export interface ApiOptions {
|
|
|
29
32
|
readonly outside: "background" | "zero";
|
|
30
33
|
/** Opt-in helpers, canonical order; the generator has checked each one's profile. */
|
|
31
34
|
readonly helpers: readonly VDBModuleHelper[];
|
|
35
|
+
/** P1.5: the vendored accessor or the lean reader (`./lean.ts`). */
|
|
36
|
+
readonly reader: "vendored" | "lean";
|
|
37
|
+
/** P1.3/P1.4, `majorant` profile only (else `'brick'`): which walk. `'nodeMax'` includes the march layer. */
|
|
38
|
+
readonly majorant: VDBMajorantMode;
|
|
39
|
+
/** `majorant` profile only (else false): emit `vdbMajorantMinimum`. */
|
|
40
|
+
readonly minima: boolean;
|
|
41
|
+
/** EX1f-b: the host's random function the tracking helpers call (a WGSL identifier), else null. */
|
|
42
|
+
readonly random: string | null;
|
|
43
|
+
/** P1.16: what the lean accessor caches (`'leaf'` for the vendored reader, which has its own cache). */
|
|
44
|
+
readonly cache: "leaf" | "lower" | "lowerLeaf";
|
|
32
45
|
}
|
|
46
|
+
/** Whether the module has the march layer: `march`, or `majorant` with `'nodeMax'`. */
|
|
47
|
+
export declare function hasMarch(profileRank: number, o: Pick<ApiOptions, "majorant">): boolean;
|
|
33
48
|
/** Vendored grid-type constant names (after the rename) per compiled type. */
|
|
34
49
|
export declare const GRID_TYPE_CONSTANT: Readonly<Record<VDBGridTypeName, string>>;
|
|
35
50
|
/**
|
|
36
51
|
* API layers in profile order. A profile's API is every layer up to and
|
|
37
|
-
* including its own
|
|
52
|
+
* including its own, except that `majorant` (rank 3) takes the march layer
|
|
53
|
+
* only with `majorant: 'nodeMax'` (P1.3: `brick` / `global` are `sample` plus
|
|
54
|
+
* the walk, K1-core §3.2).
|
|
38
55
|
*/
|
|
39
56
|
export declare const API_LAYERS: readonly ((o: ApiOptions, profileRank: number) => string)[];
|
|
40
|
-
/** The public API text for the profile at `profileRank` (0 = read, 1 = sample, 2 = march), then the requested helpers. */
|
|
57
|
+
/** The public API text for the profile at `profileRank` (0 = read, 1 = sample, 2 = march, 3 = majorant), then the requested helpers. */
|
|
41
58
|
export declare function apiWgsl(profileRank: number, o: ApiOptions): string;
|
|
59
|
+
/** The public functions of an API text: what `keep` can name. */
|
|
60
|
+
export declare function apiPublicFunctions(api: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* P1.16 `keep`: the API text cut to the named public functions and the declarations they reach (by identifier),
|
|
63
|
+
* in the original order. The generator's vendored closure then follows from the cut text.
|
|
64
|
+
*/
|
|
65
|
+
export declare function pruneApiWgsl(api: string, keep: readonly string[]): string;
|
package/dist/core/wgsl/api.js
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* Every pool read goes through `vdb_load`, the module's one buffer access,
|
|
8
8
|
* which the generator emits for the chosen binding mode.
|
|
9
9
|
*
|
|
10
|
-
* Layers stack: `sample` includes `read`, `march` includes `sample
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* Layers stack: `sample` includes `read`, `march` includes `sample`, and
|
|
11
|
+
* `majorant` (P1.3) includes `sample` and, with `majorant: 'nodeMax'`, `march`
|
|
12
|
+
* (`./majorant.ts`). `reader: 'lean'` (P1.5) swaps the vendored accessor for
|
|
13
|
+
* `./lean.ts`. Each layer is a function of the normalized options and the
|
|
14
|
+
* profile rank.
|
|
13
15
|
*
|
|
14
16
|
* Conventions every layer keeps:
|
|
15
17
|
* - A grid id is usable when it is below `vdbGridCount()` and its record is
|
|
@@ -19,7 +21,13 @@
|
|
|
19
21
|
* NanoVDB `SampleFromVoxels`); HDDA cells are floor-based, so voxel `i`
|
|
20
22
|
* occupies `[i, i + 1)` for ray clipping and traversal.
|
|
21
23
|
*/
|
|
24
|
+
import { leanHelperFunctions, leanReadLayer, leanSampleFunctions } from "./lean.js";
|
|
22
25
|
import { levelSetWgsl } from "./level-set.js";
|
|
26
|
+
import { majorantHelpersWgsl, majorantWgsl } from "./majorant.js";
|
|
27
|
+
/** Whether the module has the march layer: `march`, or `majorant` with `'nodeMax'`. */
|
|
28
|
+
export function hasMarch(profileRank, o) {
|
|
29
|
+
return profileRank === 2 || (profileRank === 3 && o.majorant === "nodeMax");
|
|
30
|
+
}
|
|
23
31
|
/** Vendored grid-type constant names (after the rename) per compiled type. */
|
|
24
32
|
export const GRID_TYPE_CONSTANT = {
|
|
25
33
|
float: "VDB_GRID_TYPE_FLOAT",
|
|
@@ -27,31 +35,20 @@ export const GRID_TYPE_CONSTANT = {
|
|
|
27
35
|
fp8: "VDB_GRID_TYPE_FP8",
|
|
28
36
|
fp16: "VDB_GRID_TYPE_FP16",
|
|
29
37
|
fpn: "VDB_GRID_TYPE_FPN",
|
|
38
|
+
half: "VDB_GRID_TYPE_HALF",
|
|
30
39
|
};
|
|
31
40
|
/** Whether the accessor carries the index bbox (only `sample`+ with `outside: 'zero'`). */
|
|
32
41
|
function carriesBBox(profileRank, o) {
|
|
33
42
|
return profileRank >= 1 && o.outside === "zero";
|
|
34
43
|
}
|
|
35
|
-
/** Whether the accessor carries the stats flag and `valueMax` (
|
|
36
|
-
function carriesStats(profileRank) {
|
|
37
|
-
return profileRank
|
|
44
|
+
/** Whether the accessor carries the stats flag and `valueMax` (the march layer). */
|
|
45
|
+
function carriesStats(profileRank, o) {
|
|
46
|
+
return hasMarch(profileRank, o);
|
|
38
47
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const stats = carriesStats(profileRank);
|
|
48
|
+
/** The record functions every reader shares, in emission order. */
|
|
49
|
+
function recordFunctions(o) {
|
|
42
50
|
const typeOk = o.types.map((t) => `t == ${GRID_TYPE_CONSTANT[t]}`).join(" || ");
|
|
43
|
-
|
|
44
|
-
const extraInit = (bbox ? "\n a.lo = vdbIndexMin(g);\n a.hi = vdbIndexMax(g);" : "") +
|
|
45
|
-
(stats
|
|
46
|
-
? "\n a.stats = (vdb_rec(g, VDB_REC_FLAGS) & VDB_REC_FLAG_HAS_STATS) != 0u;\n a.vmax = bitcast<f32>(vdb_rec(g, VDB_REC_VALUE_MAX));"
|
|
47
|
-
: "");
|
|
48
|
-
const parts = [
|
|
49
|
-
`struct VdbAccessor {
|
|
50
|
-
buf: vdb_buf_t,
|
|
51
|
-
gridType: u32,
|
|
52
|
-
ok: bool,
|
|
53
|
-
inner: vdb_readaccessor_t,${extraFields}
|
|
54
|
-
}`,
|
|
51
|
+
return [
|
|
55
52
|
`fn vdb_rec(g: u32, w: u32) -> u32 {
|
|
56
53
|
return vdb_load(VDB_POOL_TABLE_WORD + g * VDB_POOL_RECORD_WORDS + w);
|
|
57
54
|
}`,
|
|
@@ -82,6 +79,26 @@ function readLayer(o, profileRank) {
|
|
|
82
79
|
}
|
|
83
80
|
return bitcast<vec3i>(vec3u(vdb_rec(g, VDB_REC_INDEX_BBOX_MAX), vdb_rec(g, VDB_REC_INDEX_BBOX_MAX + 1u), vdb_rec(g, VDB_REC_INDEX_BBOX_MAX + 2u)));
|
|
84
81
|
}`,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
function readLayer(o, profileRank) {
|
|
85
|
+
const bbox = carriesBBox(profileRank, o);
|
|
86
|
+
if (o.reader === "lean")
|
|
87
|
+
return leanReadLayer(o, bbox, recordFunctions(o));
|
|
88
|
+
const stats = carriesStats(profileRank, o);
|
|
89
|
+
const extraFields = (bbox ? "\n lo: vec3i,\n hi: vec3i," : "") + (stats ? "\n stats: bool,\n vmax: f32," : "");
|
|
90
|
+
const extraInit = (bbox ? "\n a.lo = vdbIndexMin(g);\n a.hi = vdbIndexMax(g);" : "") +
|
|
91
|
+
(stats
|
|
92
|
+
? "\n a.stats = (vdb_rec(g, VDB_REC_FLAGS) & VDB_REC_FLAG_HAS_STATS) != 0u;\n a.vmax = bitcast<f32>(vdb_rec(g, VDB_REC_VALUE_MAX));"
|
|
93
|
+
: "");
|
|
94
|
+
const parts = [
|
|
95
|
+
`struct VdbAccessor {
|
|
96
|
+
buf: vdb_buf_t,
|
|
97
|
+
gridType: u32,
|
|
98
|
+
ok: bool,
|
|
99
|
+
inner: vdb_readaccessor_t,${extraFields}
|
|
100
|
+
}`,
|
|
101
|
+
...recordFunctions(o),
|
|
85
102
|
`fn vdbAccessorInit(g: u32) -> VdbAccessor {
|
|
86
103
|
var a: VdbAccessor;
|
|
87
104
|
a.gridType = vdbGridType(g);
|
|
@@ -133,9 +150,11 @@ function readLayer(o, profileRank) {
|
|
|
133
150
|
* inside), i.e. `xyz` in `[min - 1, max + 1)`.
|
|
134
151
|
* - nearest: the voxel `floor(xyz + 0.5)` must lie in `[min, max]`, i.e.
|
|
135
152
|
* `xyz` in `[min - 0.5, max + 0.5)`; else 0.
|
|
136
|
-
* CPU twins: `tools` `
|
|
153
|
+
* CPU twins: `tools` `vdbSampleTrilinearCpu` / `vdbSampleNearestCpu` with `{ outside: 'zero' }`.
|
|
137
154
|
*/
|
|
138
155
|
function sampleFunction(o, profileRank) {
|
|
156
|
+
if (o.reader === "lean")
|
|
157
|
+
return leanSampleFunctions(o, carriesBBox(profileRank, o));
|
|
139
158
|
const read = (ijk) => `vdb_readaccessor_get_value_float((*acc).gridType, (*acc).buf, &inner, ${ijk})`;
|
|
140
159
|
if (!carriesBBox(profileRank, o)) {
|
|
141
160
|
const lookup = o.sampler === "trilinear" ? "vdb_sample_trilinear_typed((*acc).gridType, (*acc).buf, &inner, xyz)" : read("vec3i(floor(xyz + vec3f(0.5)))");
|
|
@@ -377,7 +396,10 @@ function helperFunctions(o) {
|
|
|
377
396
|
return min(min((*h).next.x, (*h).next.y), min((*h).next.z, (*h).tmax));
|
|
378
397
|
}`);
|
|
379
398
|
}
|
|
380
|
-
|
|
399
|
+
// P1.16: the lean reader's own helpers (its vdbSampleFast, the unchecked init).
|
|
400
|
+
if (o.reader === "lean")
|
|
401
|
+
out.push(...leanHelperFunctions(o, carriesBBox(1, o)));
|
|
402
|
+
if (o.reader !== "lean" && o.helpers.includes("fastTrilinear")) {
|
|
381
403
|
// Only trilinear has 8 taps to share (the generator rejects the helper with 'nearest').
|
|
382
404
|
const inside = carriesBBox(1, o) ? " || any(b < (*acc).lo) || any(b >= (*acc).hi)" : "";
|
|
383
405
|
// Uniform per-tap work (no per-lane choice between a leaf read and a descent: lanes of a SIMD group that
|
|
@@ -449,15 +471,76 @@ function helperFunctions(o) {
|
|
|
449
471
|
// K3.7: the level-set zero-crossing finder and normal (./level-set.ts).
|
|
450
472
|
if (o.helpers.includes("levelSet"))
|
|
451
473
|
out.push(...levelSetWgsl());
|
|
474
|
+
// EX1f-b: the majorant profile's helpers (world and global inits, the two trackers; ./majorant.ts).
|
|
475
|
+
out.push(...majorantHelpersWgsl(o));
|
|
452
476
|
return out;
|
|
453
477
|
}
|
|
454
478
|
/**
|
|
455
479
|
* API layers in profile order. A profile's API is every layer up to and
|
|
456
|
-
* including its own
|
|
480
|
+
* including its own, except that `majorant` (rank 3) takes the march layer
|
|
481
|
+
* only with `majorant: 'nodeMax'` (P1.3: `brick` / `global` are `sample` plus
|
|
482
|
+
* the walk, K1-core §3.2).
|
|
457
483
|
*/
|
|
458
|
-
export const API_LAYERS = [
|
|
459
|
-
|
|
484
|
+
export const API_LAYERS = [
|
|
485
|
+
readLayer,
|
|
486
|
+
sampleLayer,
|
|
487
|
+
marchLayer,
|
|
488
|
+
(o) => majorantWgsl(o),
|
|
489
|
+
];
|
|
490
|
+
/** The public API text for the profile at `profileRank` (0 = read, 1 = sample, 2 = march, 3 = majorant), then the requested helpers. */
|
|
460
491
|
export function apiWgsl(profileRank, o) {
|
|
461
|
-
|
|
492
|
+
const layers = API_LAYERS.slice(0, profileRank + 1).filter((_, i) => i !== 2 || hasMarch(profileRank, o));
|
|
493
|
+
return [...layers.map((layer) => layer(o, profileRank)), ...helperFunctions(o)].join("\n");
|
|
494
|
+
}
|
|
495
|
+
/** The API text as its top-level declarations, in order (every one starts a line with `fn`, `struct` or `alias`). */
|
|
496
|
+
function apiDeclarations(api) {
|
|
497
|
+
const out = [];
|
|
498
|
+
let lines = [];
|
|
499
|
+
const flush = () => {
|
|
500
|
+
if (lines.length === 0)
|
|
501
|
+
return;
|
|
502
|
+
const m = /^(fn|struct|alias)\s+([A-Za-z_][A-Za-z0-9_]*)/.exec(lines[0]);
|
|
503
|
+
if (!m)
|
|
504
|
+
throw new Error(`@pmndrs/vdb: unexpected API text before a declaration: ${lines[0]}`);
|
|
505
|
+
out.push({ kind: m[1], name: m[2], text: lines.join("\n") });
|
|
506
|
+
lines = [];
|
|
507
|
+
};
|
|
508
|
+
for (const line of api.split("\n")) {
|
|
509
|
+
if (/^(fn|struct|alias)\s/.test(line))
|
|
510
|
+
flush();
|
|
511
|
+
lines.push(line);
|
|
512
|
+
}
|
|
513
|
+
flush();
|
|
514
|
+
return out;
|
|
515
|
+
}
|
|
516
|
+
/** The public functions of an API text: what `keep` can name. */
|
|
517
|
+
export function apiPublicFunctions(api) {
|
|
518
|
+
return apiDeclarations(api)
|
|
519
|
+
.filter((d) => d.kind === "fn" && /^vdb[A-Z]/.test(d.name))
|
|
520
|
+
.map((d) => d.name);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* P1.16 `keep`: the API text cut to the named public functions and the declarations they reach (by identifier),
|
|
524
|
+
* in the original order. The generator's vendored closure then follows from the cut text.
|
|
525
|
+
*/
|
|
526
|
+
export function pruneApiWgsl(api, keep) {
|
|
527
|
+
const decls = apiDeclarations(api);
|
|
528
|
+
const byName = new Map(decls.map((d) => [d.name, d]));
|
|
529
|
+
const kept = new Set();
|
|
530
|
+
const stack = [...keep];
|
|
531
|
+
while (stack.length > 0) {
|
|
532
|
+
const name = stack.pop();
|
|
533
|
+
if (kept.has(name))
|
|
534
|
+
continue;
|
|
535
|
+
kept.add(name);
|
|
536
|
+
for (const m of byName.get(name).text.matchAll(/[A-Za-z_][A-Za-z0-9_]*/g)) {
|
|
537
|
+
if (byName.has(m[0]) && !kept.has(m[0]))
|
|
538
|
+
stack.push(m[0]);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return decls
|
|
542
|
+
.filter((d) => kept.has(d.name))
|
|
543
|
+
.map((d) => d.text)
|
|
544
|
+
.join("\n");
|
|
462
545
|
}
|
|
463
546
|
//# sourceMappingURL=api.js.map
|