@pmndrs/vdb 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { type Vec3 } from "../cpu/march.js";
|
|
2
|
+
import { vdbPyramidBaseLevel } from "./pyramid-layout.js";
|
|
3
|
+
export { vdbPyramidBaseLevel };
|
|
4
|
+
/** A float mip atlas in his layout: levels 1..n side by side on x. */
|
|
5
|
+
export interface VDBFloatMipAtlas {
|
|
6
|
+
readonly data: Float32Array;
|
|
7
|
+
readonly dimensions: [number, number, number];
|
|
8
|
+
/** Levels in the atlas (above the base). */
|
|
9
|
+
readonly levels: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* His box mip atlas (frameMipmaps.js `buildAtlas` / `packAtlas` / `downsample`) over float data:
|
|
13
|
+
* levels 1..n with n = ⌈log2(max side)⌉, each the 2x2x2 mean of the level below with edge taps
|
|
14
|
+
* clamped; level l at x = atlasWidth − atlasWidth / 2^(l−1). No 8-bit rounding. Null for a 1³ base.
|
|
15
|
+
*/
|
|
16
|
+
export declare function vdbBoxMipAtlasF32(data: Float32Array, dimensions: readonly number[]): VDBFloatMipAtlas | null;
|
|
17
|
+
/** Options of {@link vdbBoxPyramid}. */
|
|
18
|
+
export interface VDBBoxPyramidOptions {
|
|
19
|
+
/** Inclusive voxel index box the volume's unit box covers. Default: the grid's index bbox. */
|
|
20
|
+
indexBox?: {
|
|
21
|
+
min: Vec3;
|
|
22
|
+
max: Vec3;
|
|
23
|
+
};
|
|
24
|
+
/** Texels on the longest side of the base level at most (R1: `pyramidMax`, default 128). */
|
|
25
|
+
pyramidMax?: number;
|
|
26
|
+
/** Base level override (default {@link vdbPyramidBaseLevel}). */
|
|
27
|
+
level?: number;
|
|
28
|
+
}
|
|
29
|
+
/** The dense coarse levels of a sparse grid (see the file comment). */
|
|
30
|
+
export interface VDBBoxPyramid {
|
|
31
|
+
/** L₀: the level of `data` in level-0 voxels (texel footprint 2^L₀). */
|
|
32
|
+
readonly level: number;
|
|
33
|
+
/** Texels of the base level, ⌈indexBox size / 2^L₀⌉. */
|
|
34
|
+
readonly dimensions: [number, number, number];
|
|
35
|
+
/** Base level, x fastest, the box mean of the sparse grid over each texel's cell. */
|
|
36
|
+
readonly data: Float32Array;
|
|
37
|
+
/** Levels L₀+1… in his atlas layout (null when the base is 1³). */
|
|
38
|
+
readonly atlas: VDBFloatMipAtlas | null;
|
|
39
|
+
/** Total levels the source then has: L₀ + atlas levels. */
|
|
40
|
+
readonly lodLevels: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The coarse pyramid of a sparse FLOAT/Fp grid image (CPU, `vdbResampleGrid` box). The grid's Map must
|
|
44
|
+
* be axis-aligned (vdbResampleGrid's rule).
|
|
45
|
+
*/
|
|
46
|
+
export declare function vdbBoxPyramid(image: Uint32Array, o?: VDBBoxPyramidOptions): VDBBoxPyramid;
|
|
47
|
+
/**
|
|
48
|
+
* Twin of the sparse source's node-average tap (`vdbFrameNodeAverage` in `three/sparse-source.ts`):
|
|
49
|
+
* trilinear interpolation of {@link nodeAverage} over the lattice of aligned `dim`-cells, whose
|
|
50
|
+
* centres are at `dim·j + dim/2 − ½` in index space (voxel centres at integers). `p` is in index
|
|
51
|
+
* space. f32 arithmetic in WGSL order.
|
|
52
|
+
*/
|
|
53
|
+
export declare function vdbFrameNodeAverageSample(image: Uint32Array, p: Vec3, dim: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* Twin of the shadow march's empty-space query (`vdbFrameSkipEmpty`, K3.2): an HDDA over 8³ cells
|
|
56
|
+
* of the ray `o + d·t` (sample space: index space, the trilinear base voxel is `floor(p)`) from `t0`
|
|
57
|
+
* to `t1`. Returns `[ts, te]`: every sample with `t < ts` reads only voxels whose bound is ≤ `cutoff`
|
|
58
|
+
* (so it is skipped exactly), and the cell from `ts` to `te` must be sampled; `[t1, t1]` when the
|
|
59
|
+
* rest is empty. The bound per cell is `cellBoundTrilinear` (the 2x2x2 block a level-0 trilinear tap
|
|
60
|
+
* reads) or, with `dilate`, the max of `nodeMax` over the 3x3x3 cells around (taps of the coarse
|
|
61
|
+
* levels that reach at most 8 voxels past the cell). After `maxCells` empty cells it returns
|
|
62
|
+
* `[ts, ts]` (the caller asks again from there). `ts` steps back by `1e-3` voxel along the ray so a
|
|
63
|
+
* sample on a cell face is never skipped by rounding.
|
|
64
|
+
*/
|
|
65
|
+
export declare function vdbFrameSkipEmpty(image: Uint32Array, o: Vec3, d: Vec3, t0: number, t1: number, cutoff: number, dilate: boolean, maxCells?: number): [number, number];
|
|
66
|
+
/** The non-zero density stats of an image (every leaf voxel, active or not, and active tiles); the source's `stats` rule (K3.2). */
|
|
67
|
+
export declare function vdbSparseDensityStats(image: Uint32Array, clamp01?: boolean): {
|
|
68
|
+
meanNonZero: number;
|
|
69
|
+
max: number;
|
|
70
|
+
activeVoxels: number;
|
|
71
|
+
};
|
|
72
|
+
/** f32 → binary16 bits as the GPU pyramid packs them (three's `DataUtils.toHalfFloat`: truncation; `pyrHalf`). */
|
|
73
|
+
export declare function vdbPyramidHalfBits(v: number): number;
|
|
74
|
+
/** A pyramid as the GPU holds it: every texel through binary16 ({@link vdbPyramidHalfBits}). */
|
|
75
|
+
export declare function vdbPyramidToHalf(p: VDBBoxPyramid): VDBBoxPyramid;
|
|
76
|
+
/** One channel of a {@link VDBSparseVolumeCpu}: a grid image and the inclusive index box the unit box covers. */
|
|
77
|
+
export interface VDBSparseChannelCpu {
|
|
78
|
+
/** The grid image. */
|
|
79
|
+
readonly image: Uint32Array;
|
|
80
|
+
/** The inclusive voxel index box uvw [0, 1]³ maps onto (cell box `[min − ½, max + ½]`). */
|
|
81
|
+
readonly box: {
|
|
82
|
+
readonly min: Vec3;
|
|
83
|
+
readonly max: Vec3;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** One volume of the core sparse source, on the CPU (the twin's input). */
|
|
87
|
+
export interface VDBSparseVolumeCpu {
|
|
88
|
+
/** The source's LOD strategy. */
|
|
89
|
+
readonly lod: "none" | "coarse-pyramid" | "node-average";
|
|
90
|
+
/** The source's `normalize: 'clamp01'`. */
|
|
91
|
+
readonly clamp01?: boolean;
|
|
92
|
+
/** The density grid. */
|
|
93
|
+
readonly density: VDBSparseChannelCpu;
|
|
94
|
+
/** Optional mask grid (level 0). */
|
|
95
|
+
readonly mask?: VDBSparseChannelCpu;
|
|
96
|
+
/** Optional albedo: one grey grid or three (RGB), one box (level 0). */
|
|
97
|
+
readonly albedo?: {
|
|
98
|
+
readonly images: readonly Uint32Array[];
|
|
99
|
+
readonly box: {
|
|
100
|
+
readonly min: Vec3;
|
|
101
|
+
readonly max: Vec3;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/** Optional emission grid (level 0). */
|
|
105
|
+
readonly emission?: VDBSparseChannelCpu;
|
|
106
|
+
/** `'coarse-pyramid'`: the pyramid as the GPU samples it (`vdbPyramidToHalf(vdbBoxPyramid(...))`). */
|
|
107
|
+
readonly pyramid?: VDBBoxPyramid;
|
|
108
|
+
}
|
|
109
|
+
/** A twin sample: the value and the largest magnitude among the values it was blended from (for tolerances). */
|
|
110
|
+
export interface VDBSparseSampleCpu {
|
|
111
|
+
/** The sampled value. */
|
|
112
|
+
readonly value: number;
|
|
113
|
+
/** The largest |tap| the value was interpolated from. */
|
|
114
|
+
readonly scale: number;
|
|
115
|
+
/** True when a pyramid (hardware-filtered r16float) tap contributed. */
|
|
116
|
+
readonly filtered: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** Levels the volume's density has above level 0 (`vdbSrcLodLevels`). */
|
|
119
|
+
export declare function vdbSparseLodLevelsCpu(vol: VDBSparseVolumeCpu): number;
|
|
120
|
+
/** Twin of `vdbSrcDensity(v, uvw, lod)` of the core sparse source (uvw already offset and wrapped by the caller). */
|
|
121
|
+
export declare function vdbSparseDensityCpu(vol: VDBSparseVolumeCpu, uvw: readonly number[], lod: number): VDBSparseSampleCpu;
|
|
122
|
+
/**
|
|
123
|
+
* Issue #2: twin of `vdbSrcDensityStochastic(v, uvw, lod, xi)`: at lod 0, the one voxel of the trilinear cell picked
|
|
124
|
+
* by `xi` (per axis the upper voxel when `xi[a] < frac`, so with probability equal to its trilinear weight; the tree
|
|
125
|
+
* value everywhere, as {@link vdbSparseDensityCpu}'s taps), normalised as {@link vdbSparseDensityCpu}. Its mean over
|
|
126
|
+
* uniform `xi` is the trilinear value (exactly, when `clamp01` is off or the voxels are in [0, 1]). K6.S2: the pick
|
|
127
|
+
* replaces the level-0 trilinear wherever {@link vdbSparseDensityCpu} reads level 0 ('none': every lod; 'coarse-pyramid':
|
|
128
|
+
* below the base level, blended with the base; 'node-average': lod 0); elsewhere it is {@link vdbSparseDensityCpu}.
|
|
129
|
+
*/
|
|
130
|
+
export declare function vdbSparseDensityStochasticCpu(vol: VDBSparseVolumeCpu, uvw: readonly number[], lod: number, xi: readonly number[]): VDBSparseSampleCpu;
|
|
131
|
+
/** Twin of `vdbSrcMask(v, uvw, lod)` (level 0; 1 without a mask). */
|
|
132
|
+
export declare function vdbSparseMaskCpu(vol: VDBSparseVolumeCpu, uvw: readonly number[]): VDBSparseSampleCpu;
|
|
133
|
+
/** Twin of `vdbSrcAlbedo(v, uvw, lod)`: level 0, clamped to [0, 1]; (1, 1, 1) without albedo. */
|
|
134
|
+
export declare function vdbSparseAlbedoCpu(vol: VDBSparseVolumeCpu, uvw: readonly number[]): {
|
|
135
|
+
value: Vec3;
|
|
136
|
+
scale: number;
|
|
137
|
+
};
|
|
138
|
+
/** Twin of `vdbSrcEmission(v, uvw, lod)` (level 0; 0 without emission). */
|
|
139
|
+
export declare function vdbSparseEmissionCpu(vol: VDBSparseVolumeCpu, uvw: readonly number[]): VDBSparseSampleCpu;
|
|
140
|
+
/**
|
|
141
|
+
* Twin of `vdbSrcSkipSpan(v, o, d, t0, t1, lod, cutoff)`: the HDDA query of a march `o + d·t` in uvw (the source
|
|
142
|
+
* box [0, 1]³, no offset or wrap) whose samples are read at `lod`. Exact only where the bound covers every voxel a
|
|
143
|
+
* sample reads (the K3.2 rules): level 0 (2x2x2 block), or the dilated 3x3x3 block for node averages up to level 3
|
|
144
|
+
* and pyramids with L₀ ≤ 2 up to lod 2; off when `lod > 3` (the cost rule) or `skipEmpty` is off: `[t0, 1e30]`.
|
|
145
|
+
* With a mask only a zero bound skips. Returns `[ts, te]` as {@link vdbFrameSkipEmpty}.
|
|
146
|
+
*/
|
|
147
|
+
export declare function vdbSparseSkipSpanCpu(vol: VDBSparseVolumeCpu, o: readonly number[], d: readonly number[], t0: number, t1: number, lod: number, cutoff: number, skipEmpty?: boolean): [number, number];
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/frameMipmaps.js L14–106 (level sizes, 2x2x2 box downsample with
|
|
3
|
+
// clamped edge taps, the mip atlas layout), as float data.
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: f32 data without the 8-bit rounding; the first level comes from a sparse grid through
|
|
6
|
+
// `vdbResampleGrid` (box); node-average sampling and the HDDA skip are ours (K3.2). Divergences:
|
|
7
|
+
// DIVERGES.md (K3.2 rows).
|
|
8
|
+
/**
|
|
9
|
+
* CPU side of the sparse volume source's LOD strategies (K3.2, R1 §4.3) and the CPU twins of its
|
|
10
|
+
* WGSL (`@pmndrs/vdb/three` `sparse-source.ts`):
|
|
11
|
+
*
|
|
12
|
+
* - `'coarse-pyramid'`: {@link vdbBoxPyramid} builds the dense coarse levels his
|
|
13
|
+
* `sampleExtinction(localPos, lod)` reads at lod ≥ 1. The base level L₀ = max(1, ⌈log2(maxTexels /
|
|
14
|
+
* pyramidMax)⌉) is a box resample of the sparse grid (`vdbResampleGrid`, filter `'box'`) to
|
|
15
|
+
* ⌈texels / 2^L₀⌉ voxels over the exact index box, so texel j is centred at uvw (j + 0.5) / dims as
|
|
16
|
+
* his mip levels are; the levels above it are his 2x2x2 box mip atlas, in float
|
|
17
|
+
* ({@link vdbBoxMipAtlasF32}).
|
|
18
|
+
* - `'node-average'`: {@link vdbFrameNodeAverageSample} is the twin of the trilinear interpolation
|
|
19
|
+
* of `vdbNodeAverage` over the leaf (dim 8) or lower-node (dim 128) lattice.
|
|
20
|
+
* - HDDA skip: {@link vdbFrameSkipEmpty} is the twin of the shadow march's empty-space query.
|
|
21
|
+
*
|
|
22
|
+
* Engine-free and core-free (D20): reads the NanoVDB image with the `tools/cpu` twins.
|
|
23
|
+
*/
|
|
24
|
+
import { VDBToolsError } from "../errors.js";
|
|
25
|
+
import { cellBoundTrilinear, hddaCellEnd, hddaInit, hddaStep, indexBBox, leafVoxels, nodeAverage, nodeMax, treeNodes, vdbReadValueF32Cpu } from "../cpu/march.js";
|
|
26
|
+
import { halfToFloat } from "../vdb/half-float.js";
|
|
27
|
+
import { vdbResampleGrid } from "../nanovdb/resample.js";
|
|
28
|
+
import { GRID_OFF_MAP, MAP_OFF_MATD, MAP_OFF_VECD } from "../nanovdb/bytes.js";
|
|
29
|
+
import { vdbBoxPyramidLayout, vdbPyramidBaseLevel, vdbPyramidLevelSize as levelSize } from "./pyramid-layout.js";
|
|
30
|
+
export { vdbPyramidBaseLevel };
|
|
31
|
+
const f = Math.fround;
|
|
32
|
+
/**
|
|
33
|
+
* His box mip atlas (frameMipmaps.js `buildAtlas` / `packAtlas` / `downsample`) over float data:
|
|
34
|
+
* levels 1..n with n = ⌈log2(max side)⌉, each the 2x2x2 mean of the level below with edge taps
|
|
35
|
+
* clamped; level l at x = atlasWidth − atlasWidth / 2^(l−1). No 8-bit rounding. Null for a 1³ base.
|
|
36
|
+
*/
|
|
37
|
+
export function vdbBoxMipAtlasF32(data, dimensions) {
|
|
38
|
+
const [width, height, depth] = dimensions;
|
|
39
|
+
const count = Math.ceil(Math.log2(Math.max(width, height, depth, 1)));
|
|
40
|
+
if (count < 1)
|
|
41
|
+
return null;
|
|
42
|
+
const levels = [];
|
|
43
|
+
let level = { data, width, height, depth };
|
|
44
|
+
for (let index = 1; index <= count; index++) {
|
|
45
|
+
const tw = levelSize(level.width, 1);
|
|
46
|
+
const th = levelSize(level.height, 1);
|
|
47
|
+
const td = levelSize(level.depth, 1);
|
|
48
|
+
const out = new Float32Array(tw * th * td);
|
|
49
|
+
const src = level;
|
|
50
|
+
for (let z = 0; z < td; z++) {
|
|
51
|
+
const z0 = Math.min(z * 2, src.depth - 1);
|
|
52
|
+
const z1 = Math.min(z * 2 + 1, src.depth - 1);
|
|
53
|
+
for (let y = 0; y < th; y++) {
|
|
54
|
+
const y0 = Math.min(y * 2, src.height - 1);
|
|
55
|
+
const y1 = Math.min(y * 2 + 1, src.height - 1);
|
|
56
|
+
const r00 = (y0 + z0 * src.height) * src.width;
|
|
57
|
+
const r10 = (y1 + z0 * src.height) * src.width;
|
|
58
|
+
const r01 = (y0 + z1 * src.height) * src.width;
|
|
59
|
+
const r11 = (y1 + z1 * src.height) * src.width;
|
|
60
|
+
for (let x = 0; x < tw; x++) {
|
|
61
|
+
const x0 = Math.min(x * 2, src.width - 1);
|
|
62
|
+
const x1 = Math.min(x * 2 + 1, src.width - 1);
|
|
63
|
+
const d = src.data;
|
|
64
|
+
out[x + (y + z * th) * tw] =
|
|
65
|
+
(d[x0 + r00] + d[x1 + r00] + d[x0 + r10] + d[x1 + r10] + d[x0 + r01] + d[x1 + r01] + d[x0 + r11] + d[x1 + r11]) / 8;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
level = { data: out, width: tw, height: th, depth: td };
|
|
70
|
+
levels.push(level);
|
|
71
|
+
}
|
|
72
|
+
const atlasWidth = 2 ** Math.max(Math.ceil(Math.log2(width)), levels.length);
|
|
73
|
+
const atlasHeight = levelSize(height, 1);
|
|
74
|
+
const atlasDepth = levelSize(depth, 1);
|
|
75
|
+
const atlas = new Float32Array(atlasWidth * atlasHeight * atlasDepth);
|
|
76
|
+
levels.forEach((l, levelIndex) => {
|
|
77
|
+
const offset = atlasWidth - atlasWidth / 2 ** levelIndex;
|
|
78
|
+
for (let z = 0; z < l.depth; z++) {
|
|
79
|
+
for (let y = 0; y < l.height; y++) {
|
|
80
|
+
const row = (y + z * atlasHeight) * atlasWidth + offset;
|
|
81
|
+
atlas.set(l.data.subarray((y + z * l.height) * l.width, (y + z * l.height + 1) * l.width), row);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return { data: atlas, dimensions: [atlasWidth, atlasHeight, atlasDepth], levels: levels.length };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The coarse pyramid of a sparse FLOAT/Fp grid image (CPU, `vdbResampleGrid` box). The grid's Map must
|
|
89
|
+
* be axis-aligned (vdbResampleGrid's rule).
|
|
90
|
+
*/
|
|
91
|
+
export function vdbBoxPyramid(image, o = {}) {
|
|
92
|
+
const box = o.indexBox ?? indexBBox(image);
|
|
93
|
+
const texels = [box.max[0] - box.min[0] + 1, box.max[1] - box.min[1] + 1, box.max[2] - box.min[2] + 1];
|
|
94
|
+
if (texels.some((t) => !(t > 0)))
|
|
95
|
+
throw new VDBToolsError("VDB_BAD_OPTION", "vdbBoxPyramid: empty index box");
|
|
96
|
+
const layout = vdbBoxPyramidLayout(texels, { ...(o.pyramidMax !== undefined ? { pyramidMax: o.pyramidMax } : {}), ...(o.level !== undefined ? { level: o.level } : {}) });
|
|
97
|
+
const level = layout.level;
|
|
98
|
+
const dims = [...layout.dimensions];
|
|
99
|
+
// The index cell box [min − ½, max + ½] in world (NanoVDB: world = matd · ijk + vecd).
|
|
100
|
+
const view = new DataView(image.buffer, image.byteOffset, image.byteLength);
|
|
101
|
+
const mat = Array.from({ length: 9 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_MATD + i * 8, true));
|
|
102
|
+
const vec = Array.from({ length: 3 }, (_, i) => view.getFloat64(GRID_OFF_MAP + MAP_OFF_VECD + i * 8, true));
|
|
103
|
+
const world = (ijk) => [0, 1, 2].map((r) => mat[r * 3] * ijk[0] + mat[r * 3 + 1] * ijk[1] + mat[r * 3 + 2] * ijk[2] + vec[r]);
|
|
104
|
+
const lo = world([box.min[0] - 0.5, box.min[1] - 0.5, box.min[2] - 0.5]);
|
|
105
|
+
const hi = world([box.max[0] + 0.5, box.max[1] + 0.5, box.max[2] + 0.5]);
|
|
106
|
+
const coarse = vdbResampleGrid(image, { filter: "box", dimensions: dims, bbox: [lo, hi] });
|
|
107
|
+
// Dense readout of the resampled grid (index box [0, dims − 1]); voxels outside its leaves and tiles are background.
|
|
108
|
+
const data = new Float32Array(dims[0] * dims[1] * dims[2]);
|
|
109
|
+
const background = 0;
|
|
110
|
+
if (background !== 0)
|
|
111
|
+
data.fill(background);
|
|
112
|
+
const put = (x, y, z, v) => {
|
|
113
|
+
if (x < 0 || y < 0 || z < 0 || x >= dims[0] || y >= dims[1] || z >= dims[2])
|
|
114
|
+
return;
|
|
115
|
+
data[x + (y + z * dims[1]) * dims[0]] = v;
|
|
116
|
+
};
|
|
117
|
+
for (const node of treeNodes(coarse.image)) {
|
|
118
|
+
for (const t of node.activeTiles) {
|
|
119
|
+
for (let z = 0; z < t.dim; z++)
|
|
120
|
+
for (let y = 0; y < t.dim; y++)
|
|
121
|
+
for (let x = 0; x < t.dim; x++)
|
|
122
|
+
put(t.origin[0] + x, t.origin[1] + y, t.origin[2] + z, t.value);
|
|
123
|
+
}
|
|
124
|
+
if (node.level !== 0)
|
|
125
|
+
continue;
|
|
126
|
+
const { values } = leafVoxels(coarse.image, node.address);
|
|
127
|
+
const [ox, oy, oz] = node.origin;
|
|
128
|
+
for (let n = 0; n < 512; n++)
|
|
129
|
+
put(ox + (n >> 6), oy + ((n >> 3) & 7), oz + (n & 7), values[n]);
|
|
130
|
+
}
|
|
131
|
+
const atlas = vdbBoxMipAtlasF32(data, dims);
|
|
132
|
+
return { level, dimensions: dims, data, atlas, lodLevels: level + (atlas?.levels ?? 0) };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Twin of the sparse source's node-average tap (`vdbFrameNodeAverage` in `three/sparse-source.ts`):
|
|
136
|
+
* trilinear interpolation of {@link nodeAverage} over the lattice of aligned `dim`-cells, whose
|
|
137
|
+
* centres are at `dim·j + dim/2 − ½` in index space (voxel centres at integers). `p` is in index
|
|
138
|
+
* space. f32 arithmetic in WGSL order.
|
|
139
|
+
*/
|
|
140
|
+
export function vdbFrameNodeAverageSample(image, p, dim) {
|
|
141
|
+
const fd = f(dim);
|
|
142
|
+
const half = f(f(0.5 * fd) - 0.5);
|
|
143
|
+
const q = p.map((v) => f(f(v - half) / fd));
|
|
144
|
+
const base = q.map(Math.floor);
|
|
145
|
+
const w = q.map((v, i) => f(v - base[i]));
|
|
146
|
+
const c = [base[0] * dim, base[1] * dim, base[2] * dim];
|
|
147
|
+
const v = [];
|
|
148
|
+
for (let k = 0; k < 8; k++)
|
|
149
|
+
v.push(nodeAverage(image, [c[0] + (k & 1) * dim, c[1] + ((k >> 1) & 1) * dim, c[2] + ((k >> 2) & 1) * dim], dim));
|
|
150
|
+
const mix = (a, b, t) => f(a + f(t * f(b - a)));
|
|
151
|
+
const x00 = mix(v[0], v[1], w[0]);
|
|
152
|
+
const x10 = mix(v[2], v[3], w[0]);
|
|
153
|
+
const x01 = mix(v[4], v[5], w[0]);
|
|
154
|
+
const x11 = mix(v[6], v[7], w[0]);
|
|
155
|
+
return mix(mix(x00, x10, w[1]), mix(x01, x11, w[1]), w[2]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Twin of the shadow march's empty-space query (`vdbFrameSkipEmpty`, K3.2): an HDDA over 8³ cells
|
|
159
|
+
* of the ray `o + d·t` (sample space: index space, the trilinear base voxel is `floor(p)`) from `t0`
|
|
160
|
+
* to `t1`. Returns `[ts, te]`: every sample with `t < ts` reads only voxels whose bound is ≤ `cutoff`
|
|
161
|
+
* (so it is skipped exactly), and the cell from `ts` to `te` must be sampled; `[t1, t1]` when the
|
|
162
|
+
* rest is empty. The bound per cell is `cellBoundTrilinear` (the 2x2x2 block a level-0 trilinear tap
|
|
163
|
+
* reads) or, with `dilate`, the max of `nodeMax` over the 3x3x3 cells around (taps of the coarse
|
|
164
|
+
* levels that reach at most 8 voxels past the cell). After `maxCells` empty cells it returns
|
|
165
|
+
* `[ts, ts]` (the caller asks again from there). `ts` steps back by `1e-3` voxel along the ray so a
|
|
166
|
+
* sample on a cell face is never skipped by rounding.
|
|
167
|
+
*/
|
|
168
|
+
export function vdbFrameSkipEmpty(image, o, d, t0, t1, cutoff, dilate, maxCells = 64) {
|
|
169
|
+
const h = hddaInit(o, t0, d, t1, 8);
|
|
170
|
+
const back = f(1e-3 / Math.max(Math.hypot(d[0], d[1], d[2]), 1e-6));
|
|
171
|
+
let ts = t0;
|
|
172
|
+
for (let n = 0; n < maxCells; n++) {
|
|
173
|
+
const te = hddaCellEnd(h);
|
|
174
|
+
let b;
|
|
175
|
+
if (!dilate)
|
|
176
|
+
b = cellBoundTrilinear(image, h.voxel, 8);
|
|
177
|
+
else {
|
|
178
|
+
b = -Infinity;
|
|
179
|
+
for (let k = 0; k < 27; k++) {
|
|
180
|
+
const c = [h.voxel[0] + ((k % 3) - 1) * 8, h.voxel[1] + ((Math.floor(k / 3) % 3) - 1) * 8, h.voxel[2] + (Math.floor(k / 9) - 1) * 8];
|
|
181
|
+
b = Math.max(b, nodeMax(image, c, 8));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (b > cutoff)
|
|
185
|
+
return [Math.max(t0, f(ts - back)), te];
|
|
186
|
+
ts = te;
|
|
187
|
+
if (!hddaStep(h))
|
|
188
|
+
return [t1, t1];
|
|
189
|
+
}
|
|
190
|
+
return [Math.max(t0, f(ts - back)), Math.max(t0, f(ts - back))];
|
|
191
|
+
}
|
|
192
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
193
|
+
// K6.7: twins of the core sparse source (`core/source/sparse.ts`, `vdbSparseSource`): its `vdbSrc*` WGSL on one
|
|
194
|
+
// volume, the density stats it computes and the f16 pyramid it samples.
|
|
195
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
196
|
+
/** The non-zero density stats of an image (every leaf voxel, active or not, and active tiles); the source's `stats` rule (K3.2). */
|
|
197
|
+
export function vdbSparseDensityStats(image, clamp01 = false) {
|
|
198
|
+
let sum = 0;
|
|
199
|
+
let count = 0;
|
|
200
|
+
let maxValue = 0;
|
|
201
|
+
const add = (v, n) => {
|
|
202
|
+
const x = clamp01 ? Math.min(Math.max(v, 0), 1) : v;
|
|
203
|
+
if (x !== 0) {
|
|
204
|
+
sum += x * n;
|
|
205
|
+
count += n;
|
|
206
|
+
maxValue = Math.max(maxValue, x);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
for (const node of treeNodes(image)) {
|
|
210
|
+
for (const t of node.activeTiles)
|
|
211
|
+
add(t.value, t.dim ** 3);
|
|
212
|
+
if (node.level !== 0)
|
|
213
|
+
continue;
|
|
214
|
+
const { values } = leafVoxels(image, node.address);
|
|
215
|
+
for (let n = 0; n < 512; n++)
|
|
216
|
+
add(values[n], 1);
|
|
217
|
+
}
|
|
218
|
+
return { meanNonZero: count > 0 ? sum / count : 0, max: maxValue, activeVoxels: count };
|
|
219
|
+
}
|
|
220
|
+
/** f32 → binary16 bits as the GPU pyramid packs them (three's `DataUtils.toHalfFloat`: truncation; `pyrHalf`). */
|
|
221
|
+
export function vdbPyramidHalfBits(v) {
|
|
222
|
+
const buf = new DataView(new ArrayBuffer(4));
|
|
223
|
+
buf.setFloat32(0, Math.min(Math.max(v, -65504), 65504), true);
|
|
224
|
+
const bits = buf.getUint32(0, true);
|
|
225
|
+
const e = ((bits >>> 23) & 0xff) - 127;
|
|
226
|
+
let base;
|
|
227
|
+
let shift;
|
|
228
|
+
if (e < -27)
|
|
229
|
+
[base, shift] = [0, 24];
|
|
230
|
+
else if (e < -14)
|
|
231
|
+
[base, shift] = [0x400 >>> (-e - 14), -e - 1];
|
|
232
|
+
else if (e <= 15)
|
|
233
|
+
[base, shift] = [(e + 15) << 10, 13];
|
|
234
|
+
else if (e < 128)
|
|
235
|
+
[base, shift] = [0x7c00, 24];
|
|
236
|
+
else
|
|
237
|
+
[base, shift] = [0x7c00, 13];
|
|
238
|
+
if (bits & 0x80000000)
|
|
239
|
+
base |= 0x8000;
|
|
240
|
+
return base + ((bits & 0x7fffff) >>> shift);
|
|
241
|
+
}
|
|
242
|
+
/** A pyramid as the GPU holds it: every texel through binary16 ({@link vdbPyramidHalfBits}). */
|
|
243
|
+
export function vdbPyramidToHalf(p) {
|
|
244
|
+
const round = (data) => Float32Array.from(data, (v) => halfToFloat(vdbPyramidHalfBits(v)));
|
|
245
|
+
return { ...p, data: round(p.data), atlas: p.atlas ? { ...p.atlas, data: round(p.atlas.data) } : null };
|
|
246
|
+
}
|
|
247
|
+
/** Levels the volume's density has above level 0 (`vdbSrcLodLevels`). */
|
|
248
|
+
export function vdbSparseLodLevelsCpu(vol) {
|
|
249
|
+
return vol.lod === "none" ? 0 : vol.lod === "node-average" ? 7 : (vol.pyramid?.lodLevels ?? 0);
|
|
250
|
+
}
|
|
251
|
+
/** uvw → sample index position, clamped to the voxels, in f32 as the WGSL (`vdbSrcSamplePos`). */
|
|
252
|
+
function samplePos(box, uvw) {
|
|
253
|
+
return [0, 1, 2].map((a) => {
|
|
254
|
+
const lo = box.min[a];
|
|
255
|
+
const size = box.max[a] - lo + 1;
|
|
256
|
+
const p = f(f(lo + f(f(uvw[a]) * size)) - 0.5);
|
|
257
|
+
return Math.min(Math.max(p, lo), lo + size - 1);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
/** Level-0 trilinear (`vdbSample`) with the tap magnitude. */
|
|
261
|
+
function level0(image, p) {
|
|
262
|
+
const b = p.map(Math.floor);
|
|
263
|
+
const w = p.map((v, i) => v - b[i]);
|
|
264
|
+
const t = [];
|
|
265
|
+
for (let k = 0; k < 8; k++)
|
|
266
|
+
t.push(vdbReadValueF32Cpu(image, [b[0] + (k & 1), b[1] + ((k >> 1) & 1), b[2] + ((k >> 2) & 1)]));
|
|
267
|
+
const lerp = (a, c, s) => a + (c - a) * s;
|
|
268
|
+
const x00 = lerp(t[0], t[1], w[0]);
|
|
269
|
+
const x10 = lerp(t[2], t[3], w[0]);
|
|
270
|
+
const x01 = lerp(t[4], t[5], w[0]);
|
|
271
|
+
const x11 = lerp(t[6], t[7], w[0]);
|
|
272
|
+
return { value: lerp(lerp(x00, x10, w[1]), lerp(x01, x11, w[1]), w[2]), scale: Math.max(...t.map(Math.abs)) };
|
|
273
|
+
}
|
|
274
|
+
/** Hardware linear filtering, clamp to edge, of `data` (`dims`) at texel coordinate `texel` (centres at i + ½). */
|
|
275
|
+
function linearTexel(data, dims, texel) {
|
|
276
|
+
const [W, H, D] = [dims[0], dims[1], dims[2]];
|
|
277
|
+
const fx = texel[0] - 0.5;
|
|
278
|
+
const fy = texel[1] - 0.5;
|
|
279
|
+
const fz = texel[2] - 0.5;
|
|
280
|
+
const [x0, y0, z0] = [Math.floor(fx), Math.floor(fy), Math.floor(fz)];
|
|
281
|
+
const [tx, ty, tz] = [fx - x0, fy - y0, fz - z0];
|
|
282
|
+
const cl = (i, n) => Math.min(Math.max(i, 0), n - 1);
|
|
283
|
+
let scale = 0;
|
|
284
|
+
const at = (x, y, z) => {
|
|
285
|
+
const v = data[cl(x, W) + (cl(y, H) + cl(z, D) * H) * W];
|
|
286
|
+
scale = Math.max(scale, Math.abs(v));
|
|
287
|
+
return v;
|
|
288
|
+
};
|
|
289
|
+
const c00 = at(x0, y0, z0) * (1 - tx) + at(x0 + 1, y0, z0) * tx;
|
|
290
|
+
const c10 = at(x0, y0 + 1, z0) * (1 - tx) + at(x0 + 1, y0 + 1, z0) * tx;
|
|
291
|
+
const c01 = at(x0, y0, z0 + 1) * (1 - tx) + at(x0 + 1, y0, z0 + 1) * tx;
|
|
292
|
+
const c11 = at(x0, y0 + 1, z0 + 1) * (1 - tx) + at(x0 + 1, y0 + 1, z0 + 1) * tx;
|
|
293
|
+
return { value: (c00 * (1 - ty) + c10 * ty) * (1 - tz) + (c01 * (1 - ty) + c11 * ty) * tz, scale };
|
|
294
|
+
}
|
|
295
|
+
/** His `sampleMipmapped` over the pyramid (base + atlas), `lod` relative to the base (`vdbSrcPyrSample`). */
|
|
296
|
+
function pyramidSample(p, uvw, lod) {
|
|
297
|
+
const size0 = p.dimensions;
|
|
298
|
+
const base = () => linearTexel(p.data, size0, size0.map((s, a) => Math.min(Math.max(uvw[a] * s, 0.5), s - 0.5)));
|
|
299
|
+
const levels = p.atlas?.levels ?? 0;
|
|
300
|
+
const mip = (level) => {
|
|
301
|
+
const atlas = p.atlas;
|
|
302
|
+
const size = size0.map((t) => Math.max(1, Math.ceil(t / 2 ** level)));
|
|
303
|
+
const offset = atlas.dimensions[0] - atlas.dimensions[0] / 2 ** (level - 1);
|
|
304
|
+
const texel = size.map((s, a) => Math.min(Math.max(uvw[a] * s, 0.5), s - 0.5));
|
|
305
|
+
return linearTexel(atlas.data, atlas.dimensions, [texel[0] + offset, texel[1], texel[2]]);
|
|
306
|
+
};
|
|
307
|
+
const level = Math.min(lod, levels);
|
|
308
|
+
if (level <= 0)
|
|
309
|
+
return base();
|
|
310
|
+
const level0i = Math.floor(level);
|
|
311
|
+
const low = level0i < 0.5 ? base() : mip(level0i);
|
|
312
|
+
const high = mip(Math.min(level0i + 1, levels));
|
|
313
|
+
const t = level - level0i;
|
|
314
|
+
return { value: low.value * (1 - t) + high.value * t, scale: Math.max(low.scale, high.scale) };
|
|
315
|
+
}
|
|
316
|
+
/** Twin of `vdbSrcDensity(v, uvw, lod)` of the core sparse source (uvw already offset and wrapped by the caller). */
|
|
317
|
+
export function vdbSparseDensityCpu(vol, uvw, lod) {
|
|
318
|
+
const { image, box } = vol.density;
|
|
319
|
+
const p = samplePos(box, uvw);
|
|
320
|
+
const out = (s, filtered) => ({
|
|
321
|
+
value: vol.clamp01 ? Math.min(Math.max(s.value, 0), 1) : s.value,
|
|
322
|
+
scale: s.scale,
|
|
323
|
+
filtered,
|
|
324
|
+
});
|
|
325
|
+
if (vol.lod === "none")
|
|
326
|
+
return out(level0(image, p), false);
|
|
327
|
+
const l = Math.min(Math.max(lod, 0), vdbSparseLodLevelsCpu(vol));
|
|
328
|
+
if (vol.lod === "node-average") {
|
|
329
|
+
if (l <= 0)
|
|
330
|
+
return out(level0(image, p), false);
|
|
331
|
+
const fine = l < 3;
|
|
332
|
+
const a = fine ? level0(image, p) : { value: vdbFrameNodeAverageSample(image, p, 8), scale: 0 };
|
|
333
|
+
if (l >= 7) {
|
|
334
|
+
const v = vdbFrameNodeAverageSample(image, p, 128);
|
|
335
|
+
return out({ value: v, scale: Math.abs(v) }, false);
|
|
336
|
+
}
|
|
337
|
+
const b = vdbFrameNodeAverageSample(image, p, fine ? 8 : 128);
|
|
338
|
+
const t = fine ? l / 3 : (l - 3) / 4;
|
|
339
|
+
return out({ value: a.value * (1 - t) + b * t, scale: Math.max(a.scale, Math.abs(a.value), Math.abs(b)) }, false);
|
|
340
|
+
}
|
|
341
|
+
const pyr = vol.pyramid;
|
|
342
|
+
if (!pyr)
|
|
343
|
+
throw new VDBToolsError("VDB_BAD_OPTION", "vdbSparseDensityCpu: lod 'coarse-pyramid' needs the volume's pyramid");
|
|
344
|
+
const L0 = pyr.level;
|
|
345
|
+
if (l <= 0)
|
|
346
|
+
return out(level0(image, p), false);
|
|
347
|
+
if (l < L0) {
|
|
348
|
+
const a = level0(image, p);
|
|
349
|
+
const b = pyramidSample(pyr, uvw, 0);
|
|
350
|
+
const t = l / L0;
|
|
351
|
+
return out({ value: a.value * (1 - t) + b.value * t, scale: Math.max(a.scale, b.scale) }, true);
|
|
352
|
+
}
|
|
353
|
+
return out(pyramidSample(pyr, uvw, l - L0), true);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Issue #2: twin of `vdbSrcDensityStochastic(v, uvw, lod, xi)`: at lod 0, the one voxel of the trilinear cell picked
|
|
357
|
+
* by `xi` (per axis the upper voxel when `xi[a] < frac`, so with probability equal to its trilinear weight; the tree
|
|
358
|
+
* value everywhere, as {@link vdbSparseDensityCpu}'s taps), normalised as {@link vdbSparseDensityCpu}. Its mean over
|
|
359
|
+
* uniform `xi` is the trilinear value (exactly, when `clamp01` is off or the voxels are in [0, 1]). K6.S2: the pick
|
|
360
|
+
* replaces the level-0 trilinear wherever {@link vdbSparseDensityCpu} reads level 0 ('none': every lod; 'coarse-pyramid':
|
|
361
|
+
* below the base level, blended with the base; 'node-average': lod 0); elsewhere it is {@link vdbSparseDensityCpu}.
|
|
362
|
+
*/
|
|
363
|
+
export function vdbSparseDensityStochasticCpu(vol, uvw, lod, xi) {
|
|
364
|
+
// K6.S2: where vdbSrcDensity reads level 0 ('none': every lod; 'coarse-pyramid': below L0, blended with the base;
|
|
365
|
+
// 'node-average': lod 0 only)
|
|
366
|
+
const l = vol.lod === "none" ? 0 : Math.min(Math.max(lod, 0), vdbSparseLodLevelsCpu(vol));
|
|
367
|
+
const L0 = vol.lod === "coarse-pyramid" ? vol.pyramid?.level : undefined;
|
|
368
|
+
if (vol.lod === "node-average" ? lod > 0 : vol.lod === "coarse-pyramid" && (L0 === undefined || l >= L0))
|
|
369
|
+
return vdbSparseDensityCpu(vol, uvw, lod);
|
|
370
|
+
const { image, box } = vol.density;
|
|
371
|
+
const p = samplePos(box, uvw);
|
|
372
|
+
const b = p.map(Math.floor);
|
|
373
|
+
const ijk = [0, 1, 2].map((a) => b[a] + (f(xi[a]) < p[a] - b[a] ? 1 : 0));
|
|
374
|
+
const fine = vdbReadValueF32Cpu(image, ijk);
|
|
375
|
+
const norm = (v) => (vol.clamp01 ? Math.min(Math.max(v, 0), 1) : v);
|
|
376
|
+
if (vol.lod !== "coarse-pyramid" || l <= 0)
|
|
377
|
+
return { value: norm(fine), scale: Math.abs(fine), filtered: false };
|
|
378
|
+
const base = pyramidSample(vol.pyramid, uvw, 0);
|
|
379
|
+
const t = l / L0;
|
|
380
|
+
return { value: norm(fine * (1 - t) + base.value * t), scale: Math.max(Math.abs(fine), base.scale), filtered: true };
|
|
381
|
+
}
|
|
382
|
+
/** Twin of `vdbSrcMask(v, uvw, lod)` (level 0; 1 without a mask). */
|
|
383
|
+
export function vdbSparseMaskCpu(vol, uvw) {
|
|
384
|
+
if (!vol.mask)
|
|
385
|
+
return { value: 1, scale: 1, filtered: false };
|
|
386
|
+
return { ...level0(vol.mask.image, samplePos(vol.mask.box, uvw)), filtered: false };
|
|
387
|
+
}
|
|
388
|
+
/** Twin of `vdbSrcAlbedo(v, uvw, lod)`: level 0, clamped to [0, 1]; (1, 1, 1) without albedo. */
|
|
389
|
+
export function vdbSparseAlbedoCpu(vol, uvw) {
|
|
390
|
+
const a = vol.albedo;
|
|
391
|
+
if (!a)
|
|
392
|
+
return { value: [1, 1, 1], scale: 1 };
|
|
393
|
+
const p = samplePos(a.box, uvw);
|
|
394
|
+
const taps = (a.images.length === 3 ? a.images : [a.images[0], a.images[0], a.images[0]]).map((img) => level0(img, p));
|
|
395
|
+
return { value: taps.map((t) => Math.min(Math.max(t.value, 0), 1)), scale: Math.max(...taps.map((t) => t.scale)) };
|
|
396
|
+
}
|
|
397
|
+
/** Twin of `vdbSrcEmission(v, uvw, lod)` (level 0; 0 without emission). */
|
|
398
|
+
export function vdbSparseEmissionCpu(vol, uvw) {
|
|
399
|
+
if (!vol.emission)
|
|
400
|
+
return { value: 0, scale: 0, filtered: false };
|
|
401
|
+
return { ...level0(vol.emission.image, samplePos(vol.emission.box, uvw)), filtered: false };
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Twin of `vdbSrcSkipSpan(v, o, d, t0, t1, lod, cutoff)`: the HDDA query of a march `o + d·t` in uvw (the source
|
|
405
|
+
* box [0, 1]³, no offset or wrap) whose samples are read at `lod`. Exact only where the bound covers every voxel a
|
|
406
|
+
* sample reads (the K3.2 rules): level 0 (2x2x2 block), or the dilated 3x3x3 block for node averages up to level 3
|
|
407
|
+
* and pyramids with L₀ ≤ 2 up to lod 2; off when `lod > 3` (the cost rule) or `skipEmpty` is off: `[t0, 1e30]`.
|
|
408
|
+
* With a mask only a zero bound skips. Returns `[ts, te]` as {@link vdbFrameSkipEmpty}.
|
|
409
|
+
*/
|
|
410
|
+
export function vdbSparseSkipSpanCpu(vol, o, d, t0, t1, lod, cutoff, skipEmpty = true) {
|
|
411
|
+
let enabled = skipEmpty && lod <= 3;
|
|
412
|
+
let dilate = false;
|
|
413
|
+
const l = Math.min(Math.max(lod, 0), vdbSparseLodLevelsCpu(vol));
|
|
414
|
+
if (vol.lod === "node-average" && l > 0) {
|
|
415
|
+
dilate = true;
|
|
416
|
+
if (l > 3)
|
|
417
|
+
enabled = false;
|
|
418
|
+
}
|
|
419
|
+
else if (vol.lod === "coarse-pyramid" && l > 0) {
|
|
420
|
+
dilate = true;
|
|
421
|
+
if ((vol.pyramid?.level ?? 0) > 2 || l > 2)
|
|
422
|
+
enabled = false;
|
|
423
|
+
}
|
|
424
|
+
if (!enabled)
|
|
425
|
+
return [t0, 1e30];
|
|
426
|
+
const { box, image } = vol.density;
|
|
427
|
+
const o2 = [0, 1, 2].map((a) => f(f(box.min[a] - 0.5) + f(f(o[a]) * (box.max[a] - box.min[a] + 1))));
|
|
428
|
+
const d2 = [0, 1, 2].map((a) => f(f(d[a]) * (box.max[a] - box.min[a] + 1)));
|
|
429
|
+
const c = vol.mask ? 0 : Math.max(cutoff, 0);
|
|
430
|
+
return vdbFrameSkipEmpty(image, o2, d2, t0, t1, c, dilate);
|
|
431
|
+
}
|
|
432
|
+
//# sourceMappingURL=sparse.js.map
|