@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,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1.16: an instrumented twin of the lean reader (`core/wgsl/lean.ts`, `reader: 'lean'`), statement for statement,
|
|
3
|
+
* that counts every `vdb_load` it makes: how many pool words one `vdbAccessorInit`, `vdbReadValue`, `vdbIsActive` or
|
|
4
|
+
* `vdbSample` reads, for each accessor cache (`'leaf'`, `'lower'`, `'lowerLeaf'`), each init (checked, unchecked)
|
|
5
|
+
* and each grid type. Counts, never timings.
|
|
6
|
+
*
|
|
7
|
+
* It returns the values too (f32, the WGSL's decode; `mix(a, b, t)` as `a + (b - a) * t`, the form SwiftShader
|
|
8
|
+
* evaluates, so the samples equal the GPU's bit for bit there; WGSL allows `a * (1 - t) + b * t` too), so a test holds it against
|
|
9
|
+
* `vdbReadValueF32Cpu` / `vdbSampleTrilinearCpu`: a twin that read the wrong word would return the wrong value.
|
|
10
|
+
*
|
|
11
|
+
* It runs on the grid image alone. The pool-table words an init reads (grid count, the record's flags, type, image
|
|
12
|
+
* offset and index bbox) are counted as loads of named pseudo-words, since their values come from the image here.
|
|
13
|
+
*
|
|
14
|
+
* Tools internal (`src/tools/internal.ts`), not a package export.
|
|
15
|
+
*/
|
|
16
|
+
import { vdbHalfToFloat } from "../nanovdb/half.js";
|
|
17
|
+
import { VDBToolsError } from "../errors.js";
|
|
18
|
+
import { indexBBox } from "./march.js";
|
|
19
|
+
const GRID_SIZE = 672;
|
|
20
|
+
const GRID_TYPE_WORD = 636 >>> 2;
|
|
21
|
+
const TYPE = { float: 1, half: 9, fp4: 13, fp8: 14, fp16: 15, fpn: 16 };
|
|
22
|
+
const f = Math.fround;
|
|
23
|
+
/** Pseudo-addresses of the pool-table words (negative: never an image word). */
|
|
24
|
+
const T_COUNT = -1;
|
|
25
|
+
const T_FLAGS = -2;
|
|
26
|
+
const T_TYPE = -3;
|
|
27
|
+
const T_OFFSET = -4;
|
|
28
|
+
const T_BBOX = -10;
|
|
29
|
+
/** The lean reader on one grid image, counting loads. */
|
|
30
|
+
export class LeanReadCounter {
|
|
31
|
+
image;
|
|
32
|
+
cache;
|
|
33
|
+
zero;
|
|
34
|
+
gridType;
|
|
35
|
+
compiledTypes;
|
|
36
|
+
lo;
|
|
37
|
+
hi;
|
|
38
|
+
table = 0;
|
|
39
|
+
loads = 0;
|
|
40
|
+
seen = new Set();
|
|
41
|
+
constructor(image, options = {}) {
|
|
42
|
+
this.image = image;
|
|
43
|
+
this.cache = options.cache ?? "leaf";
|
|
44
|
+
this.zero = (options.outside ?? "background") === "zero";
|
|
45
|
+
this.compiledTypes = options.compiledTypes ?? 1;
|
|
46
|
+
this.gridType = image[GRID_TYPE_WORD];
|
|
47
|
+
if (!Object.values(TYPE).includes(this.gridType)) {
|
|
48
|
+
throw new VDBToolsError("VDB_UNSUPPORTED", `LeanReadCounter: grid type ${this.gridType} is not Float, Half, Fp4, Fp8, Fp16 or FpN.`);
|
|
49
|
+
}
|
|
50
|
+
const { min, max } = indexBBox(image);
|
|
51
|
+
this.lo = [min[0], min[1], min[2]];
|
|
52
|
+
this.hi = [max[0], max[1], max[2]];
|
|
53
|
+
}
|
|
54
|
+
/** Forget the loads counted so far. */
|
|
55
|
+
reset() {
|
|
56
|
+
this.table = 0;
|
|
57
|
+
this.loads = 0;
|
|
58
|
+
this.seen.clear();
|
|
59
|
+
}
|
|
60
|
+
/** Loads since the last `reset()`. */
|
|
61
|
+
get counts() {
|
|
62
|
+
return { table: this.table, image: this.loads, distinct: this.seen.size };
|
|
63
|
+
}
|
|
64
|
+
rec(word) {
|
|
65
|
+
this.table++;
|
|
66
|
+
this.seen.add(word);
|
|
67
|
+
}
|
|
68
|
+
/** `vdb_ln_w`. */
|
|
69
|
+
w(a) {
|
|
70
|
+
this.loads++;
|
|
71
|
+
this.seen.add(a >>> 2);
|
|
72
|
+
return this.image[a >>> 2];
|
|
73
|
+
}
|
|
74
|
+
bit(m, n) {
|
|
75
|
+
return (this.w(m + 4 * (n >>> 5)) >>> (n & 31)) & 1;
|
|
76
|
+
}
|
|
77
|
+
/** `vdb_live(g)`: the grid count and the record's flags. */
|
|
78
|
+
live() {
|
|
79
|
+
this.rec(T_COUNT);
|
|
80
|
+
this.rec(T_FLAGS);
|
|
81
|
+
}
|
|
82
|
+
root = 0;
|
|
83
|
+
/**
|
|
84
|
+
* `vdbAccessorInit(g)` (`'checked'`) or the helper `vdbAccessorInitUnchecked(g)`.
|
|
85
|
+
* Checked: `vdbGridType` (live check, type), the image offset, the root offset (an image word) and, with
|
|
86
|
+
* `outside: 'zero'`, `vdbIndexMin` and `vdbIndexMax` (a live check and 3 words each).
|
|
87
|
+
* Unchecked: the type (only in a module of several types), the image offset, the root offset, the 6 bbox words.
|
|
88
|
+
*/
|
|
89
|
+
accessor(init = "checked") {
|
|
90
|
+
if (init === "checked") {
|
|
91
|
+
this.live();
|
|
92
|
+
this.rec(T_TYPE);
|
|
93
|
+
this.rec(T_OFFSET);
|
|
94
|
+
this.root = GRID_SIZE + this.w(GRID_SIZE + 24);
|
|
95
|
+
if (this.zero) {
|
|
96
|
+
for (let side = 0; side < 2; side++) {
|
|
97
|
+
this.live();
|
|
98
|
+
for (let k = 0; k < 3; k++)
|
|
99
|
+
this.rec(T_BBOX - side * 3 - k);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (this.compiledTypes > 1)
|
|
105
|
+
this.rec(T_TYPE);
|
|
106
|
+
this.rec(T_OFFSET);
|
|
107
|
+
this.root = GRID_SIZE + this.w(GRID_SIZE + 24);
|
|
108
|
+
if (this.zero)
|
|
109
|
+
for (let k = 0; k < 6; k++)
|
|
110
|
+
this.rec(T_BBOX - k);
|
|
111
|
+
}
|
|
112
|
+
return { ok: true, lk: [0, 0, 0], la: 0, qk: [0, 0, 0], qa: 0 };
|
|
113
|
+
}
|
|
114
|
+
/** `vdb_ln_lower`: (address, level) with level 1 the lower node, 2 upper tile, 3 root tile, 4 background; then (mask word address, bit). */
|
|
115
|
+
lower(i, j, k) {
|
|
116
|
+
const ux = i >>> 0;
|
|
117
|
+
const uy = j >>> 0;
|
|
118
|
+
const uz = k >>> 0;
|
|
119
|
+
const kl = ((uz >>> 12) | ((uy >>> 12) << 21)) >>> 0;
|
|
120
|
+
const kh = ((uy >>> 23) | ((ux >>> 12) << 10)) >>> 0;
|
|
121
|
+
const r = this.root;
|
|
122
|
+
const n = this.w(r + 24);
|
|
123
|
+
for (let t = 0; t < n; t++) {
|
|
124
|
+
const e = r + 64 + t * 32;
|
|
125
|
+
if (this.w(e) !== kl || this.w(e + 4) !== kh)
|
|
126
|
+
continue;
|
|
127
|
+
const c = this.w(e + 8);
|
|
128
|
+
if (c === 0 && this.w(e + 12) === 0)
|
|
129
|
+
return [e + 20, 3, e + 16, 0];
|
|
130
|
+
const p = r + c;
|
|
131
|
+
const un = (((ux & 4095) >>> 7) << 10) | (((uy & 4095) >>> 7) << 5) | ((uz & 4095) >>> 7);
|
|
132
|
+
const ue = p + 8256 + 8 * un;
|
|
133
|
+
if (this.bit(p + 4128, un) === 0)
|
|
134
|
+
return [ue, 2, p + 32, un];
|
|
135
|
+
return [p + this.w(ue), 1, 0, 0];
|
|
136
|
+
}
|
|
137
|
+
return [r + 28, 4, 0, 0];
|
|
138
|
+
}
|
|
139
|
+
/** `vdb_ln_down`: the lower node's child lookup: (address, level 0 leaf / 1 lower tile, mask word address, bit). */
|
|
140
|
+
down(q, i, j, k) {
|
|
141
|
+
const ln = (((i & 127) >>> 3) << 8) | (((j & 127) >>> 3) << 4) | ((k & 127) >>> 3);
|
|
142
|
+
const fe = q + 1088 + 8 * ln;
|
|
143
|
+
if (this.bit(q + 544, ln) === 0)
|
|
144
|
+
return [fe, 1, q + 32, ln];
|
|
145
|
+
const l = q + this.w(fe);
|
|
146
|
+
return [l, 0, l + 16, ((i & 7) << 6) | ((j & 7) << 3) | (k & 7)];
|
|
147
|
+
}
|
|
148
|
+
/** `vdb_ln_find`: the whole descent. */
|
|
149
|
+
find(i, j, k) {
|
|
150
|
+
const lw = this.lower(i, j, k);
|
|
151
|
+
if (lw[1] !== 1)
|
|
152
|
+
return lw;
|
|
153
|
+
return this.down(lw[0], i, j, k);
|
|
154
|
+
}
|
|
155
|
+
f32(a) {
|
|
156
|
+
const u = this.w(a);
|
|
157
|
+
return new Float32Array(new Uint32Array([u]).buffer)[0];
|
|
158
|
+
}
|
|
159
|
+
/** `vdb_ln_tile`: a tile or background slot. */
|
|
160
|
+
tile(a) {
|
|
161
|
+
if (this.gridType === TYPE.half)
|
|
162
|
+
return vdbHalfToFloat((this.w(a) >>> ((a & 2) << 3)) & 0xffff);
|
|
163
|
+
return this.f32(a);
|
|
164
|
+
}
|
|
165
|
+
/** `vdb_ln_leaf`: voxel `n` of the leaf at `l`. */
|
|
166
|
+
leaf(l, n) {
|
|
167
|
+
const t = this.gridType;
|
|
168
|
+
if (t === TYPE.float)
|
|
169
|
+
return this.f32(l + 96 + 4 * n);
|
|
170
|
+
if (t === TYPE.half)
|
|
171
|
+
return vdbHalfToFloat((this.w(l + 96 + 2 * n) >>> ((n & 1) << 4)) & 0xffff);
|
|
172
|
+
const lb = t === TYPE.fp4 ? 2 : t === TYPE.fp8 ? 3 : t === TYPE.fp16 ? 4 : this.w(l + 12) >>> 29;
|
|
173
|
+
const pw = 5 - lb;
|
|
174
|
+
const bits = 1 << lb;
|
|
175
|
+
const mask = bits === 32 ? 0xffffffff : (1 << bits) - 1;
|
|
176
|
+
const c = ((this.w(l + 96 + ((n >>> pw) << 2)) >>> ((n & ((1 << pw) - 1)) << lb)) & mask) >>> 0;
|
|
177
|
+
const quantum = this.f32(l + 84);
|
|
178
|
+
const minimum = this.f32(l + 80);
|
|
179
|
+
return f(f(f(c) * quantum) + minimum);
|
|
180
|
+
}
|
|
181
|
+
differs(key, i, j, k, m) {
|
|
182
|
+
return (i & m) !== key[0] || (j & m) !== key[1] || (k & m) !== key[2];
|
|
183
|
+
}
|
|
184
|
+
/** `vdbReadValue(&acc, ijk)`. */
|
|
185
|
+
readValue(acc, ijk) {
|
|
186
|
+
if (!acc.ok)
|
|
187
|
+
return 0;
|
|
188
|
+
const [i, j, k] = ijk;
|
|
189
|
+
const n = ((i & 7) << 6) | ((j & 7) << 3) | (k & 7);
|
|
190
|
+
if (this.cache === "leaf") {
|
|
191
|
+
if (acc.la === 0 || this.differs(acc.lk, i, j, k, -8)) {
|
|
192
|
+
const fd = this.find(i, j, k);
|
|
193
|
+
if (fd[1] !== 0)
|
|
194
|
+
return this.tile(fd[0]);
|
|
195
|
+
acc.la = fd[0];
|
|
196
|
+
acc.lk = [i & -8, j & -8, k & -8];
|
|
197
|
+
}
|
|
198
|
+
return this.leaf(acc.la, n);
|
|
199
|
+
}
|
|
200
|
+
const both = this.cache === "lowerLeaf";
|
|
201
|
+
if (both && !(acc.la === 0 || this.differs(acc.lk, i, j, k, -8)))
|
|
202
|
+
return this.leaf(acc.la, n);
|
|
203
|
+
// The lower node: the cached one, else a walk from the root.
|
|
204
|
+
let q = both ? acc.qa : acc.la;
|
|
205
|
+
if (q === 0 || this.differs(both ? acc.qk : acc.lk, i, j, k, -128)) {
|
|
206
|
+
const lw = this.lower(i, j, k);
|
|
207
|
+
if (lw[1] !== 1)
|
|
208
|
+
return this.tile(lw[0]);
|
|
209
|
+
q = lw[0];
|
|
210
|
+
const key = [i & -128, j & -128, k & -128];
|
|
211
|
+
if (both) {
|
|
212
|
+
acc.qa = q;
|
|
213
|
+
acc.qk = key;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
acc.la = q;
|
|
217
|
+
acc.lk = key;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const d = this.down(q, i, j, k);
|
|
221
|
+
if (d[1] !== 0)
|
|
222
|
+
return this.tile(d[0]);
|
|
223
|
+
if (both) {
|
|
224
|
+
acc.la = d[0];
|
|
225
|
+
acc.lk = [i & -8, j & -8, k & -8];
|
|
226
|
+
return this.leaf(acc.la, n);
|
|
227
|
+
}
|
|
228
|
+
return this.leaf(d[0], d[3]);
|
|
229
|
+
}
|
|
230
|
+
/** `vdbIsActive(&acc, ijk)` (no cache: a walk from the root every time). */
|
|
231
|
+
isActive(acc, ijk) {
|
|
232
|
+
if (!acc.ok)
|
|
233
|
+
return false;
|
|
234
|
+
const fd = this.find(ijk[0], ijk[1], ijk[2]);
|
|
235
|
+
return fd[1] < 4 && this.bit(fd[2], fd[3]) !== 0;
|
|
236
|
+
}
|
|
237
|
+
tap(acc, i, j, k) {
|
|
238
|
+
if (this.zero && (i < this.lo[0] || j < this.lo[1] || k < this.lo[2] || i > this.hi[0] || j > this.hi[1] || k > this.hi[2]))
|
|
239
|
+
return 0;
|
|
240
|
+
return this.readValue(acc, [i, j, k]);
|
|
241
|
+
}
|
|
242
|
+
/** `vdbSample(&acc, xyz)`, trilinear (and `vdbSampleFast`, the same function under the lean reader). */
|
|
243
|
+
sample(acc, xyz) {
|
|
244
|
+
const bx = Math.floor(xyz[0]);
|
|
245
|
+
const by = Math.floor(xyz[1]);
|
|
246
|
+
const bz = Math.floor(xyz[2]);
|
|
247
|
+
if (!acc.ok)
|
|
248
|
+
return 0;
|
|
249
|
+
if (this.zero && (bx < this.lo[0] - 1 || by < this.lo[1] - 1 || bz < this.lo[2] - 1 || bx > this.hi[0] || by > this.hi[1] || bz > this.hi[2]))
|
|
250
|
+
return 0;
|
|
251
|
+
const ux = f(xyz[0] - bx);
|
|
252
|
+
const uy = f(xyz[1] - by);
|
|
253
|
+
const uz = f(xyz[2] - bz);
|
|
254
|
+
const mix = (a, b, t) => f(a + f(f(b - a) * t));
|
|
255
|
+
const x00 = mix(this.tap(acc, bx, by, bz), this.tap(acc, bx + 1, by, bz), ux);
|
|
256
|
+
const x10 = mix(this.tap(acc, bx, by + 1, bz), this.tap(acc, bx + 1, by + 1, bz), ux);
|
|
257
|
+
const x01 = mix(this.tap(acc, bx, by, bz + 1), this.tap(acc, bx + 1, by, bz + 1), ux);
|
|
258
|
+
const x11 = mix(this.tap(acc, bx, by + 1, bz + 1), this.tap(acc, bx + 1, by + 1, bz + 1), ux);
|
|
259
|
+
return mix(mix(x00, x10, uy), mix(x01, x11, uy), uz);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=lean-reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lean-reads.js","sourceRoot":"","sources":["../../../src/tools/cpu/lean-reads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAoCvC,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,CAAC;AACjC,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAW,CAAC;AACjF,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;AAEtB,gFAAgF;AAChF,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC;AACnB,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC;AACnB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAClB,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC;AACpB,MAAM,MAAM,GAAG,CAAC,EAAE,CAAC;AAEnB,yDAAyD;AACzD,MAAM,OAAO,eAAe;IACjB,KAAK,CAAc;IACnB,KAAK,CAAY;IACjB,IAAI,CAAU;IACd,QAAQ,CAAS;IACT,aAAa,CAAS;IACtB,EAAE,CAA2B;IAC7B,EAAE,CAA2B;IACtC,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAG,CAAC,CAAC;IACD,IAAI,GAAG,IA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GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACtF,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9F,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACvD,CAAC;CACF","sourcesContent":["/**\n * P1.16: an instrumented twin of the lean reader (`core/wgsl/lean.ts`, `reader: 'lean'`), statement for statement,\n * that counts every `vdb_load` it makes: how many pool words one `vdbAccessorInit`, `vdbReadValue`, `vdbIsActive` or\n * `vdbSample` reads, for each accessor cache (`'leaf'`, `'lower'`, `'lowerLeaf'`), each init (checked, unchecked)\n * and each grid type. Counts, never timings.\n *\n * It returns the values too (f32, the WGSL's decode; `mix(a, b, t)` as `a + (b - a) * t`, the form SwiftShader\n * evaluates, so the samples equal the GPU's bit for bit there; WGSL allows `a * (1 - t) + b * t` too), so a test holds it against\n * `vdbReadValueF32Cpu` / `vdbSampleTrilinearCpu`: a twin that read the wrong word would return the wrong value.\n *\n * It runs on the grid image alone. The pool-table words an init reads (grid count, the record's flags, type, image\n * offset and index bbox) are counted as loads of named pseudo-words, since their values come from the image here.\n *\n * Tools internal (`src/tools/internal.ts`), not a package export.\n */\nimport { vdbHalfToFloat } from \"../nanovdb/half.js\";\nimport { VDBToolsError } from \"../errors.js\";\nimport { indexBBox } from \"./march.js\";\n\n/** What the lean accessor caches (the module option `cache`). */\nexport type LeanCache = \"leaf\" | \"lower\" | \"lowerLeaf\";\n\n/** Options of {@link LeanReadCounter}: the module options that change what a read loads. */\nexport interface LeanReadOptions {\n /** The accessor cache. Default `'leaf'`. */\n cache?: LeanCache;\n /** `'zero'`: taps outside the index bbox read 0 without a load, and an init reads the bbox. Default `'background'`. */\n outside?: \"background\" | \"zero\";\n /** Grid types the module compiles: with 1 (default) the unchecked init does not read the record's type. */\n compiledTypes?: number;\n}\n\n/** The lean `VdbAccessor`. */\nexport interface LeanAccessor {\n ok: boolean;\n /** Leaf cache: origin (`ijk & -8`) and byte address (0 = none); with cache `'lower'` the lower node (`ijk & -128`). */\n lk: [number, number, number];\n la: number;\n /** `'lowerLeaf'`: the lower node. */\n qk: [number, number, number];\n qa: number;\n}\n\n/** Loads since the last {@link LeanReadCounter.reset}. */\nexport interface LeanReadCounts {\n /** Pool-table words (the grid count and the grid's record). */\n table: number;\n /** Words of the grid image. */\n image: number;\n /** Different words among them (a word loaded twice counts once). */\n distinct: number;\n}\n\nconst GRID_SIZE = 672;\nconst GRID_TYPE_WORD = 636 >>> 2;\nconst TYPE = { float: 1, half: 9, fp4: 13, fp8: 14, fp16: 15, fpn: 16 } as const;\nconst f = Math.fround;\n\n/** Pseudo-addresses of the pool-table words (negative: never an image word). */\nconst T_COUNT = -1;\nconst T_FLAGS = -2;\nconst T_TYPE = -3;\nconst T_OFFSET = -4;\nconst T_BBOX = -10;\n\n/** The lean reader on one grid image, counting loads. */\nexport class LeanReadCounter {\n readonly image: Uint32Array;\n readonly cache: LeanCache;\n readonly zero: boolean;\n readonly gridType: number;\n private readonly compiledTypes: number;\n private readonly lo: [number, number, number];\n private readonly hi: [number, number, number];\n private table = 0;\n private loads = 0;\n private readonly seen = new Set<number>();\n\n constructor(image: Uint32Array, options: LeanReadOptions = {}) {\n this.image = image;\n this.cache = options.cache ?? \"leaf\";\n this.zero = (options.outside ?? \"background\") === \"zero\";\n this.compiledTypes = options.compiledTypes ?? 1;\n this.gridType = image[GRID_TYPE_WORD] as number;\n if (!(Object.values(TYPE) as number[]).includes(this.gridType)) {\n throw new VDBToolsError(\"VDB_UNSUPPORTED\", `LeanReadCounter: grid type ${this.gridType} is not Float, Half, Fp4, Fp8, Fp16 or FpN.`);\n }\n const { min, max } = indexBBox(image);\n this.lo = [min[0], min[1], min[2]];\n this.hi = [max[0], max[1], max[2]];\n }\n\n /** Forget the loads counted so far. */\n reset(): void {\n this.table = 0;\n this.loads = 0;\n this.seen.clear();\n }\n\n /** Loads since the last `reset()`. */\n get counts(): LeanReadCounts {\n return { table: this.table, image: this.loads, distinct: this.seen.size };\n }\n\n private rec(word: number): void {\n this.table++;\n this.seen.add(word);\n }\n\n /** `vdb_ln_w`. */\n private w(a: number): number {\n this.loads++;\n this.seen.add(a >>> 2);\n return this.image[a >>> 2] as number;\n }\n\n private bit(m: number, n: number): number {\n return (this.w(m + 4 * (n >>> 5)) >>> (n & 31)) & 1;\n }\n\n /** `vdb_live(g)`: the grid count and the record's flags. */\n private live(): void {\n this.rec(T_COUNT);\n this.rec(T_FLAGS);\n }\n\n private root = 0;\n\n /**\n * `vdbAccessorInit(g)` (`'checked'`) or the helper `vdbAccessorInitUnchecked(g)`.\n * Checked: `vdbGridType` (live check, type), the image offset, the root offset (an image word) and, with\n * `outside: 'zero'`, `vdbIndexMin` and `vdbIndexMax` (a live check and 3 words each).\n * Unchecked: the type (only in a module of several types), the image offset, the root offset, the 6 bbox words.\n */\n accessor(init: \"checked\" | \"unchecked\" = \"checked\"): LeanAccessor {\n if (init === \"checked\") {\n this.live();\n this.rec(T_TYPE);\n this.rec(T_OFFSET);\n this.root = GRID_SIZE + this.w(GRID_SIZE + 24);\n if (this.zero) {\n for (let side = 0; side < 2; side++) {\n this.live();\n for (let k = 0; k < 3; k++) this.rec(T_BBOX - side * 3 - k);\n }\n }\n } else {\n if (this.compiledTypes > 1) this.rec(T_TYPE);\n this.rec(T_OFFSET);\n this.root = GRID_SIZE + this.w(GRID_SIZE + 24);\n if (this.zero) for (let k = 0; k < 6; k++) this.rec(T_BBOX - k);\n }\n return { ok: true, lk: [0, 0, 0], la: 0, qk: [0, 0, 0], qa: 0 };\n }\n\n /** `vdb_ln_lower`: (address, level) with level 1 the lower node, 2 upper tile, 3 root tile, 4 background; then (mask word address, bit). */\n private lower(i: number, j: number, k: number): [number, number, number, number] {\n const ux = i >>> 0;\n const uy = j >>> 0;\n const uz = k >>> 0;\n const kl = ((uz >>> 12) | ((uy >>> 12) << 21)) >>> 0;\n const kh = ((uy >>> 23) | ((ux >>> 12) << 10)) >>> 0;\n const r = this.root;\n const n = this.w(r + 24);\n for (let t = 0; t < n; t++) {\n const e = r + 64 + t * 32;\n if (this.w(e) !== kl || this.w(e + 4) !== kh) continue;\n const c = this.w(e + 8);\n if (c === 0 && this.w(e + 12) === 0) return [e + 20, 3, e + 16, 0];\n const p = r + c;\n const un = (((ux & 4095) >>> 7) << 10) | (((uy & 4095) >>> 7) << 5) | ((uz & 4095) >>> 7);\n const ue = p + 8256 + 8 * un;\n if (this.bit(p + 4128, un) === 0) return [ue, 2, p + 32, un];\n return [p + this.w(ue), 1, 0, 0];\n }\n return [r + 28, 4, 0, 0];\n }\n\n /** `vdb_ln_down`: the lower node's child lookup: (address, level 0 leaf / 1 lower tile, mask word address, bit). */\n private down(q: number, i: number, j: number, k: number): [number, number, number, number] {\n const ln = (((i & 127) >>> 3) << 8) | (((j & 127) >>> 3) << 4) | ((k & 127) >>> 3);\n const fe = q + 1088 + 8 * ln;\n if (this.bit(q + 544, ln) === 0) return [fe, 1, q + 32, ln];\n const l = q + this.w(fe);\n return [l, 0, l + 16, ((i & 7) << 6) | ((j & 7) << 3) | (k & 7)];\n }\n\n /** `vdb_ln_find`: the whole descent. */\n private find(i: number, j: number, k: number): [number, number, number, number] {\n const lw = this.lower(i, j, k);\n if (lw[1] !== 1) return lw;\n return this.down(lw[0], i, j, k);\n }\n\n private f32(a: number): number {\n const u = this.w(a);\n return new Float32Array(new Uint32Array([u]).buffer)[0] as number;\n }\n\n /** `vdb_ln_tile`: a tile or background slot. */\n private tile(a: number): number {\n if (this.gridType === TYPE.half) return vdbHalfToFloat((this.w(a) >>> ((a & 2) << 3)) & 0xffff);\n return this.f32(a);\n }\n\n /** `vdb_ln_leaf`: voxel `n` of the leaf at `l`. */\n private leaf(l: number, n: number): number {\n const t = this.gridType;\n if (t === TYPE.float) return this.f32(l + 96 + 4 * n);\n if (t === TYPE.half) return vdbHalfToFloat((this.w(l + 96 + 2 * n) >>> ((n & 1) << 4)) & 0xffff);\n const lb = t === TYPE.fp4 ? 2 : t === TYPE.fp8 ? 3 : t === TYPE.fp16 ? 4 : this.w(l + 12) >>> 29;\n const pw = 5 - lb;\n const bits = 1 << lb;\n const mask = bits === 32 ? 0xffffffff : (1 << bits) - 1;\n const c = ((this.w(l + 96 + ((n >>> pw) << 2)) >>> ((n & ((1 << pw) - 1)) << lb)) & mask) >>> 0;\n const quantum = this.f32(l + 84);\n const minimum = this.f32(l + 80);\n return f(f(f(c) * quantum) + minimum);\n }\n\n private differs(key: [number, number, number], i: number, j: number, k: number, m: number): boolean {\n return (i & m) !== key[0] || (j & m) !== key[1] || (k & m) !== key[2];\n }\n\n /** `vdbReadValue(&acc, ijk)`. */\n readValue(acc: LeanAccessor, ijk: readonly [number, number, number]): number {\n if (!acc.ok) return 0;\n const [i, j, k] = ijk;\n const n = ((i & 7) << 6) | ((j & 7) << 3) | (k & 7);\n if (this.cache === \"leaf\") {\n if (acc.la === 0 || this.differs(acc.lk, i, j, k, -8)) {\n const fd = this.find(i, j, k);\n if (fd[1] !== 0) return this.tile(fd[0]);\n acc.la = fd[0];\n acc.lk = [i & -8, j & -8, k & -8];\n }\n return this.leaf(acc.la, n);\n }\n const both = this.cache === \"lowerLeaf\";\n if (both && !(acc.la === 0 || this.differs(acc.lk, i, j, k, -8))) return this.leaf(acc.la, n);\n // The lower node: the cached one, else a walk from the root.\n let q = both ? acc.qa : acc.la;\n if (q === 0 || this.differs(both ? acc.qk : acc.lk, i, j, k, -128)) {\n const lw = this.lower(i, j, k);\n if (lw[1] !== 1) return this.tile(lw[0]);\n q = lw[0];\n const key: [number, number, number] = [i & -128, j & -128, k & -128];\n if (both) {\n acc.qa = q;\n acc.qk = key;\n } else {\n acc.la = q;\n acc.lk = key;\n }\n }\n const d = this.down(q, i, j, k);\n if (d[1] !== 0) return this.tile(d[0]);\n if (both) {\n acc.la = d[0];\n acc.lk = [i & -8, j & -8, k & -8];\n return this.leaf(acc.la, n);\n }\n return this.leaf(d[0], d[3]);\n }\n\n /** `vdbIsActive(&acc, ijk)` (no cache: a walk from the root every time). */\n isActive(acc: LeanAccessor, ijk: readonly [number, number, number]): boolean {\n if (!acc.ok) return false;\n const fd = this.find(ijk[0], ijk[1], ijk[2]);\n return fd[1] < 4 && this.bit(fd[2], fd[3]) !== 0;\n }\n\n private tap(acc: LeanAccessor, i: number, j: number, k: number): number {\n if (this.zero && (i < this.lo[0] || j < this.lo[1] || k < this.lo[2] || i > this.hi[0] || j > this.hi[1] || k > this.hi[2])) return 0;\n return this.readValue(acc, [i, j, k]);\n }\n\n /** `vdbSample(&acc, xyz)`, trilinear (and `vdbSampleFast`, the same function under the lean reader). */\n sample(acc: LeanAccessor, xyz: readonly [number, number, number]): number {\n const bx = Math.floor(xyz[0]);\n const by = Math.floor(xyz[1]);\n const bz = Math.floor(xyz[2]);\n if (!acc.ok) return 0;\n if (this.zero && (bx < this.lo[0] - 1 || by < this.lo[1] - 1 || bz < this.lo[2] - 1 || bx > this.hi[0] || by > this.hi[1] || bz > this.hi[2])) return 0;\n const ux = f(xyz[0] - bx);\n const uy = f(xyz[1] - by);\n const uz = f(xyz[2] - bz);\n const mix = (a: number, b: number, t: number): number => f(a + f(f(b - a) * t));\n const x00 = mix(this.tap(acc, bx, by, bz), this.tap(acc, bx + 1, by, bz), ux);\n const x10 = mix(this.tap(acc, bx, by + 1, bz), this.tap(acc, bx + 1, by + 1, bz), ux);\n const x01 = mix(this.tap(acc, bx, by, bz + 1), this.tap(acc, bx + 1, by, bz + 1), ux);\n const x11 = mix(this.tap(acc, bx, by + 1, bz + 1), this.tap(acc, bx + 1, by + 1, bz + 1), ux);\n return mix(mix(x00, x10, uy), mix(x01, x11, uy), uz);\n }\n}\n"]}
|
|
@@ -36,7 +36,7 @@ export interface LevelSetHit {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* f32 trilinear sample with the vendored tap order: taps through
|
|
39
|
-
* `
|
|
39
|
+
* `vdbReadValueF32Cpu`, `mix(a, b, t)` as `a + t * (b - a)`, each op rounded.
|
|
40
40
|
*/
|
|
41
41
|
export declare function sampleTrilinearF32(gridWords: Uint32Array, xyz: readonly number[]): number;
|
|
42
42
|
/**
|
|
@@ -49,7 +49,7 @@ export declare function levelSetHit(gridWords: Uint32Array, origin: readonly num
|
|
|
49
49
|
/**
|
|
50
50
|
* Brute-force oracle for {@link levelSetHit}: a fixed-step march (`step`
|
|
51
51
|
* voxels, default 0.125) through the whole support-box interval with no
|
|
52
|
-
* skipping and no sphere steps (f64 trilinear through `
|
|
52
|
+
* skipping and no sphere steps (f64 trilinear through `vdbReadValueF32Cpu` taps),
|
|
53
53
|
* then the same bisection + secant refinement in f64. Slow; for tests.
|
|
54
54
|
*/
|
|
55
55
|
export declare function levelSetHitReference(gridWords: Uint32Array, origin: readonly number[], direction: readonly number[], t: readonly [number, number], options?: {
|
|
@@ -60,7 +60,9 @@ export declare function levelSetHitReference(gridWords: Uint32Array, origin: rea
|
|
|
60
60
|
};
|
|
61
61
|
/**
|
|
62
62
|
* Twin of `vdbLevelSetGradient(acc, xyz, h)`: central differences of the f32
|
|
63
|
-
* trilinear sample at +/- `h` index voxels, in SDF units per voxel.
|
|
63
|
+
* trilinear sample at +/- `h` index voxels, in SDF units per voxel. `h <= 0`
|
|
64
|
+
* (G13c-a): the exact gradient of the trilinear cell holding `xyz`, per axis the
|
|
65
|
+
* difference of the samples on the cell's two faces through `xyz`.
|
|
64
66
|
*/
|
|
65
67
|
export declare function levelSetGradient(gridWords: Uint32Array, xyz: readonly number[], h?: number): Vec3;
|
|
66
68
|
/**
|
|
@@ -70,3 +72,40 @@ export declare function levelSetGradient(gridWords: Uint32Array, xyz: readonly n
|
|
|
70
72
|
* used). A zero gradient gives `[0, 1, 0]`.
|
|
71
73
|
*/
|
|
72
74
|
export declare function levelSetNormal(gridWords: Uint32Array, xyz: readonly number[], worldToIndex: ArrayLike<number>, h?: number): Vec3;
|
|
75
|
+
/** A world-space view ray: `origin + dir · t`, `t` in `span`. */
|
|
76
|
+
export interface LevelSetRay {
|
|
77
|
+
origin: Vec3;
|
|
78
|
+
dir: Vec3;
|
|
79
|
+
span: [number, number];
|
|
80
|
+
}
|
|
81
|
+
/** Result of {@link levelSetSurface}. */
|
|
82
|
+
export interface LevelSetSurface {
|
|
83
|
+
hit: boolean;
|
|
84
|
+
/** World units along the ray (0 on a miss). */
|
|
85
|
+
t: number;
|
|
86
|
+
/** World hit (zeros on a miss). */
|
|
87
|
+
world: Vec3;
|
|
88
|
+
/** Outward world unit normal (zeros on a miss). */
|
|
89
|
+
normal: Vec3;
|
|
90
|
+
/** `clip.z / clip.w` of the hit (0 on a miss). */
|
|
91
|
+
ndcDepth: number;
|
|
92
|
+
/** Trilinear samples of the trace. */
|
|
93
|
+
samples: number;
|
|
94
|
+
}
|
|
95
|
+
/** Options of {@link levelSetSurface}. */
|
|
96
|
+
export interface LevelSetSurfaceOptions extends LevelSetHitOptions {
|
|
97
|
+
/** Central-difference step of the normal in index voxels. Default 1; `<= 0`: the trilinear cell's exact gradient. */
|
|
98
|
+
normalStep?: number;
|
|
99
|
+
}
|
|
100
|
+
/** Twin of `vdbLevelSetPixelUv(fragCoord, viewport)`: a fragment position (pixel centre `x + 0.5`) as a viewport uv (y down). */
|
|
101
|
+
export declare function levelSetPixelUv(fragCoord: readonly [number, number], viewport: readonly [number, number, number, number]): [number, number];
|
|
102
|
+
/** Twin of `vdbLevelSetViewRay(uv, projectionInverse, cameraWorld, orthographic)`. */
|
|
103
|
+
export declare function levelSetViewRay(uv: readonly [number, number], projectionInverse: ArrayLike<number>, cameraWorld: ArrayLike<number>, orthographic: boolean): LevelSetRay;
|
|
104
|
+
/** The NDC depth `clip.z / clip.w` of a world point (the surface's `ndcDepth`). */
|
|
105
|
+
export declare function levelSetNdcDepth(world: readonly number[], viewProjection: ArrayLike<number>): number;
|
|
106
|
+
/**
|
|
107
|
+
* Twin of `vdbLevelSetSurface(g, ray, viewProjection, sdfToIndex, maxSamples, normalStep)`: the trace
|
|
108
|
+
* ({@link levelSetHit}) in the grid's index space, then the world hit, the world normal
|
|
109
|
+
* ({@link levelSetNormal}) and the NDC depth ({@link levelSetNdcDepth}).
|
|
110
|
+
*/
|
|
111
|
+
export declare function levelSetSurface(gridWords: Uint32Array, ray: LevelSetRay, worldToIndex: ArrayLike<number>, viewProjection: ArrayLike<number>, options?: LevelSetSurfaceOptions): LevelSetSurface;
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
* NanoVDB tree at full resolution, HDDA skip, bisection, normals through the
|
|
16
16
|
* grid affine (DIVERGES.md).
|
|
17
17
|
*/
|
|
18
|
-
import { getDim, hddaInit, hddaStep, hddaUpdate, indexBBox,
|
|
18
|
+
import { getDim, hddaInit, hddaStep, hddaUpdate, indexBBox, vdbReadValueF32Cpu } from "./march.js";
|
|
19
19
|
const f = Math.fround;
|
|
20
20
|
/**
|
|
21
21
|
* f32 trilinear sample with the vendored tap order: taps through
|
|
22
|
-
* `
|
|
22
|
+
* `vdbReadValueF32Cpu`, `mix(a, b, t)` as `a + t * (b - a)`, each op rounded.
|
|
23
23
|
*/
|
|
24
24
|
export function sampleTrilinearF32(gridWords, xyz) {
|
|
25
25
|
const bx = Math.floor(xyz[0]);
|
|
@@ -28,7 +28,7 @@ export function sampleTrilinearF32(gridWords, xyz) {
|
|
|
28
28
|
const u = f(xyz[0] - bx);
|
|
29
29
|
const v = f(xyz[1] - by);
|
|
30
30
|
const w = f(xyz[2] - bz);
|
|
31
|
-
const c = (dx, dy, dz) =>
|
|
31
|
+
const c = (dx, dy, dz) => vdbReadValueF32Cpu(gridWords, [bx + dx, by + dy, bz + dz]);
|
|
32
32
|
const mix = (a, b, t) => f(a + f(t * f(b - a)));
|
|
33
33
|
const x00 = mix(c(0, 0, 0), c(1, 0, 0), u);
|
|
34
34
|
const x10 = mix(c(0, 1, 0), c(1, 1, 0), u);
|
|
@@ -43,7 +43,7 @@ function skipCell(gridWords, c, dim) {
|
|
|
43
43
|
const p = [c[0] + (k & 1) * dim, c[1] + ((k >> 1) & 1) * dim, c[2] + ((k >> 2) & 1) * dim];
|
|
44
44
|
if (getDim(gridWords, p) < dim)
|
|
45
45
|
return false;
|
|
46
|
-
if (!(
|
|
46
|
+
if (!(vdbReadValueF32Cpu(gridWords, p) > 0))
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
return true;
|
|
@@ -176,7 +176,7 @@ export function levelSetHit(gridWords, origin, direction, t, options = {}) {
|
|
|
176
176
|
/**
|
|
177
177
|
* Brute-force oracle for {@link levelSetHit}: a fixed-step march (`step`
|
|
178
178
|
* voxels, default 0.125) through the whole support-box interval with no
|
|
179
|
-
* skipping and no sphere steps (f64 trilinear through `
|
|
179
|
+
* skipping and no sphere steps (f64 trilinear through `vdbReadValueF32Cpu` taps),
|
|
180
180
|
* then the same bisection + secant refinement in f64. Slow; for tests.
|
|
181
181
|
*/
|
|
182
182
|
export function levelSetHitReference(gridWords, origin, direction, t, options = {}) {
|
|
@@ -192,7 +192,7 @@ export function levelSetHitReference(gridWords, origin, direction, t, options =
|
|
|
192
192
|
const p = [o[0] + d[0] * tt, o[1] + d[1] * tt, o[2] + d[2] * tt];
|
|
193
193
|
const b = p.map(Math.floor);
|
|
194
194
|
const u = [p[0] - b[0], p[1] - b[1], p[2] - b[2]];
|
|
195
|
-
const tap = (dx, dy, dz) =>
|
|
195
|
+
const tap = (dx, dy, dz) => vdbReadValueF32Cpu(gridWords, [b[0] + dx, b[1] + dy, b[2] + dz]);
|
|
196
196
|
const l = (a, bb, s) => a + (bb - a) * s;
|
|
197
197
|
return l(l(l(tap(0, 0, 0), tap(1, 0, 0), u[0]), l(tap(0, 1, 0), tap(1, 1, 0), u[0]), u[1]), l(l(tap(0, 0, 1), tap(1, 0, 1), u[0]), l(tap(0, 1, 1), tap(1, 1, 1), u[0]), u[1]), u[2]);
|
|
198
198
|
};
|
|
@@ -230,10 +230,20 @@ export function levelSetHitReference(gridWords, origin, direction, t, options =
|
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
232
232
|
* Twin of `vdbLevelSetGradient(acc, xyz, h)`: central differences of the f32
|
|
233
|
-
* trilinear sample at +/- `h` index voxels, in SDF units per voxel.
|
|
233
|
+
* trilinear sample at +/- `h` index voxels, in SDF units per voxel. `h <= 0`
|
|
234
|
+
* (G13c-a): the exact gradient of the trilinear cell holding `xyz`, per axis the
|
|
235
|
+
* difference of the samples on the cell's two faces through `xyz`.
|
|
234
236
|
*/
|
|
235
237
|
export function levelSetGradient(gridWords, xyz, h = 1) {
|
|
236
238
|
const p = [f(xyz[0]), f(xyz[1]), f(xyz[2])];
|
|
239
|
+
if (!(h > 0)) {
|
|
240
|
+
const face = (axis, end) => {
|
|
241
|
+
const q = [p[0], p[1], p[2]];
|
|
242
|
+
q[axis] = Math.floor(p[axis]) + end;
|
|
243
|
+
return sampleTrilinearF32(gridWords, q);
|
|
244
|
+
};
|
|
245
|
+
return [f(face(0, 1) - face(0, 0)), f(face(1, 1) - face(1, 0)), f(face(2, 1) - face(2, 0))];
|
|
246
|
+
}
|
|
237
247
|
const s = (dx, dy, dz) => sampleTrilinearF32(gridWords, [f(p[0] + dx), f(p[1] + dy), f(p[2] + dz)]);
|
|
238
248
|
const hh = f(h);
|
|
239
249
|
const den = f(2 * hh);
|
|
@@ -258,4 +268,46 @@ export function levelSetNormal(gridWords, xyz, worldToIndex, h = 1) {
|
|
|
258
268
|
return [0, 1, 0];
|
|
259
269
|
return [n[0] / l, n[1] / l, n[2] / l];
|
|
260
270
|
}
|
|
271
|
+
const mat4Vec4 = (m, v) => [0, 1, 2, 3].map((r) => m[r] * v[0] + m[4 + r] * v[1] + m[8 + r] * v[2] + m[12 + r] * v[3]);
|
|
272
|
+
const normalize3 = (v) => {
|
|
273
|
+
const l = Math.hypot(v[0], v[1], v[2]);
|
|
274
|
+
return [v[0] / l, v[1] / l, v[2] / l];
|
|
275
|
+
};
|
|
276
|
+
const affine34 = (m, p, w) => [
|
|
277
|
+
m[0] * p[0] + m[1] * p[1] + m[2] * p[2] + m[3] * w,
|
|
278
|
+
m[4] * p[0] + m[5] * p[1] + m[6] * p[2] + m[7] * w,
|
|
279
|
+
m[8] * p[0] + m[9] * p[1] + m[10] * p[2] + m[11] * w,
|
|
280
|
+
];
|
|
281
|
+
/** Twin of `vdbLevelSetPixelUv(fragCoord, viewport)`: a fragment position (pixel centre `x + 0.5`) as a viewport uv (y down). */
|
|
282
|
+
export function levelSetPixelUv(fragCoord, viewport) {
|
|
283
|
+
return [(fragCoord[0] - viewport[0]) / viewport[2], (fragCoord[1] - viewport[1]) / viewport[3]];
|
|
284
|
+
}
|
|
285
|
+
/** Twin of `vdbLevelSetViewRay(uv, projectionInverse, cameraWorld, orthographic)`. */
|
|
286
|
+
export function levelSetViewRay(uv, projectionInverse, cameraWorld, orthographic) {
|
|
287
|
+
const clip = mat4Vec4(projectionInverse, [uv[0] * 2 - 1, 1 - uv[1] * 2, 0.5, 1]);
|
|
288
|
+
const view = [clip[0] / clip[3], clip[1] / clip[3], clip[2] / clip[3]];
|
|
289
|
+
if (orthographic) {
|
|
290
|
+
const o = mat4Vec4(cameraWorld, [view[0], view[1], 0, 1]);
|
|
291
|
+
return { origin: [o[0], o[1], o[2]], dir: normalize3(mat4Vec4(cameraWorld, [0, 0, -1, 0])), span: [-1e5, 1e5] };
|
|
292
|
+
}
|
|
293
|
+
return { origin: [cameraWorld[12], cameraWorld[13], cameraWorld[14]], dir: normalize3(mat4Vec4(cameraWorld, [...normalize3(view), 0])), span: [0, 1e30] };
|
|
294
|
+
}
|
|
295
|
+
/** The NDC depth `clip.z / clip.w` of a world point (the surface's `ndcDepth`). */
|
|
296
|
+
export function levelSetNdcDepth(world, viewProjection) {
|
|
297
|
+
const c = mat4Vec4(viewProjection, [world[0], world[1], world[2], 1]);
|
|
298
|
+
return c[2] / c[3];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Twin of `vdbLevelSetSurface(g, ray, viewProjection, sdfToIndex, maxSamples, normalStep)`: the trace
|
|
302
|
+
* ({@link levelSetHit}) in the grid's index space, then the world hit, the world normal
|
|
303
|
+
* ({@link levelSetNormal}) and the NDC depth ({@link levelSetNdcDepth}).
|
|
304
|
+
*/
|
|
305
|
+
export function levelSetSurface(gridWords, ray, worldToIndex, viewProjection, options = {}) {
|
|
306
|
+
const h = levelSetHit(gridWords, affine34(worldToIndex, ray.origin, 1), affine34(worldToIndex, ray.dir, 0), ray.span, options);
|
|
307
|
+
if (!h.hit)
|
|
308
|
+
return { hit: false, t: 0, world: [0, 0, 0], normal: [0, 0, 0], ndcDepth: 0, samples: h.samples };
|
|
309
|
+
const world = [ray.origin[0] + ray.dir[0] * h.t, ray.origin[1] + ray.dir[1] * h.t, ray.origin[2] + ray.dir[2] * h.t];
|
|
310
|
+
const normal = levelSetNormal(gridWords, affine34(worldToIndex, world, 1), worldToIndex, options.normalStep ?? 1);
|
|
311
|
+
return { hit: true, t: h.t, world, normal, ndcDepth: levelSetNdcDepth(world, viewProjection), samples: h.samples };
|
|
312
|
+
}
|
|
261
313
|
//# sourceMappingURL=level-set.js.map
|