@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,198 @@
|
|
|
1
|
+
import type { VDBGridTypeName, VDBSlot } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generator profiles; each includes the previous one, except that `majorant`
|
|
4
|
+
* (P1.3) is `sample` plus the majorant walk, and includes `march` only with
|
|
5
|
+
* `majorant: 'nodeMax'`.
|
|
6
|
+
*/
|
|
7
|
+
export type VDBModuleProfile = "read" | "sample" | "march" | "majorant";
|
|
8
|
+
/**
|
|
9
|
+
* Opt-in WGSL helpers (K1.7a). None is emitted unless listed in `helpers`, so
|
|
10
|
+
* a module without them is byte-identical to one generated before they
|
|
11
|
+
* existed.
|
|
12
|
+
*
|
|
13
|
+
* - `'cellBoundTrilinear'` (`march`): `vdbCellBoundTrilinear(acc, ijk, dim) -> f32`,
|
|
14
|
+
* the max of `vdbNodeMax` over the 2x2x2 block of `dim`-cells starting at
|
|
15
|
+
* the cell that holds `ijk`: a bound for every trilinear sample whose base
|
|
16
|
+
* voxel `floor(p)` lies in that cell.
|
|
17
|
+
* - `'hddaCellEnd'` (`march`): `vdbHddaCellEnd(h: ptr<function, VdbHdda>) -> f32`,
|
|
18
|
+
* the ray `t` where the HDDA's current cell ends (`min(next, tmax)`).
|
|
19
|
+
* - `'nodeAverage'` (`march`): `vdbNodeAverage(acc, ijk, dim) -> f32`, the box
|
|
20
|
+
* mean of the aligned `dim`-cell (8: leaf, 128: lower) holding `ijk` from the
|
|
21
|
+
* node's average statistic (K3.2, the `'node-average'` LOD of the sparse
|
|
22
|
+
* volume source): a tile's value; a leaf's `ave * activeVoxels / 512`
|
|
23
|
+
* (inactive voxels count as 0, the fog background); a lower node's `ave`
|
|
24
|
+
* (the mean of its ACTIVE voxels; also for `dim > 128`). Without stats, the value at `ijk`.
|
|
25
|
+
* - `'rayClipSupport'` (`sample`+): `vdbRayClipSupport(g, o, d, t) -> bool`,
|
|
26
|
+
* `vdbRayClip` against the sampler's support box: `[min - 1, max + 1)` for
|
|
27
|
+
* trilinear, `[min - 0.5, max + 0.5)` for nearest.
|
|
28
|
+
* - `'fastTrilinear'` (`sample`+, sampler `'trilinear'`; K3.2d): `vdbSampleFast(acc, xyz) -> f32`,
|
|
29
|
+
* bit-identical to `vdbSample`: it takes the base voxel's lower node (the
|
|
30
|
+
* accessor's cached one, else one descent) and reads each of the 8 taps as
|
|
31
|
+
* one lower-node child lookup, the same work in every lane (no per-tap tree
|
|
32
|
+
* walk, no leaf-cache thrash where the cell straddles leaves); a base on a
|
|
33
|
+
* lower node's +x/+y/+z face (or, with `outside: 'zero'`, whose taps leave
|
|
34
|
+
* the index bbox) calls `vdbSample`. Reuse the accessor across samples to
|
|
35
|
+
* keep its cached lower node.
|
|
36
|
+
* - `'levelSet'` (`march`, K3.7): `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`,
|
|
37
|
+
* the first zero crossing of a level set's trilinear SDF along an index-space
|
|
38
|
+
* ray (HDDA skip of tile and background cells above 0, sphere trace, bisection
|
|
39
|
+
* + secant), `vdbLevelSetGradient(acc, xyz, h) -> vec3f` (central differences,
|
|
40
|
+
* index space) and `vdbLevelSetNormal(g, xyz, h) -> vec3f` (world unit normal).
|
|
41
|
+
* CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`.
|
|
42
|
+
* - `'majorantWorld'` (`majorant`, EX1f-b): `vdbMajorantInitWorld(g, o, d, tMin, tMax) -> VdbMajorantIter`,
|
|
43
|
+
* `vdbMajorantInit` for a world-space ray. `d` is not renormalized, so `t` stays the caller's world parameter.
|
|
44
|
+
* - `'majorantGlobal'` (`majorant` with `'brick'` or `'global'`): `vdbMajorantInitGlobal(g, o, d, tMin, tMax)`, the
|
|
45
|
+
* one-segment walk on the grid's global bound whatever brick bounds it has: pick bricks or the global bound per
|
|
46
|
+
* ray at run time, in one module.
|
|
47
|
+
* - `'deltaTrack'` (`majorant`; needs the `random` option): `vdbDeltaTrack(it, acc, sigma, maxLookups) -> VdbCollision`
|
|
48
|
+
* (`t`, `density`, `hit`, `truncated`, `steps`, `lookups`), delta tracking over the rest of a walk: the next real
|
|
49
|
+
* collision of the medium whose extinction is `sigma * vdbSample`.
|
|
50
|
+
* - `'ratioTrack'` (`majorant`; needs `random`): `vdbRatioTrack(it, acc, sigma, cutoff, maxLookups) -> VdbTransmittance`
|
|
51
|
+
* (`value`, `truncated`, `steps`, `lookups`), ratio tracking over the rest of a walk: an unbiased transmittance for
|
|
52
|
+
* the per-channel extinctions `sigma.rgb * vdbSample` under one shared majorant; Russian roulette below `cutoff`.
|
|
53
|
+
* CPU twins of the walk and the trackers: `tools` `vdbMajorantWalk`, `vdbDeltaTrack`, `vdbRatioTrack`.
|
|
54
|
+
* - `'accessorUnchecked'` (`reader: 'lean'`, P1.16): `vdbAccessorInitUnchecked(g) -> VdbAccessor`, `vdbAccessorInit`
|
|
55
|
+
* without the liveness and type checks, for a grid id the host KNOWS is live and of a compiled type (a dead or
|
|
56
|
+
* foreign id reads unrelated words as a tree). It reads 2 pool words (3 in a module of several types; 6 more
|
|
57
|
+
* with `outside: 'zero'`) where `vdbAccessorInit` reads 5 (15). For a kernel that cannot keep one accessor per
|
|
58
|
+
* ray; keeping one is cheaper still.
|
|
59
|
+
* With `reader: 'lean'` and a `cache` of `'lower'` or `'lowerLeaf'`, `'fastTrilinear'` emits `vdbSampleFast` as
|
|
60
|
+
* `vdbSample` itself (its taps already are lower-node lookups), so one kernel text serves both readers.
|
|
61
|
+
*/
|
|
62
|
+
export type VDBModuleHelper = "cellBoundTrilinear" | "hddaCellEnd" | "levelSet" | "nodeAverage" | "rayClipSupport" | "fastTrilinear" | "majorantWorld" | "majorantGlobal" | "deltaTrack" | "ratioTrack" | "accessorUnchecked";
|
|
63
|
+
/** Options every binding mode shares. */
|
|
64
|
+
export interface VDBModuleCommonOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Grid types to decode; others compile out and read 0. At least one.
|
|
67
|
+
*
|
|
68
|
+
* A module must be generated for every type the host may ever add to the
|
|
69
|
+
* pool, or regenerated (and its pipeline rebuilt) when a new type arrives:
|
|
70
|
+
* `pool.types` only lists the grids present now. Pass
|
|
71
|
+
* `VDB_ALL_SCALAR_TYPES` to never rebuild (the largest module), and call
|
|
72
|
+
* `vdbCheckModule(pool, options)` after each `add`.
|
|
73
|
+
*/
|
|
74
|
+
readonly types: Iterable<VDBGridTypeName>;
|
|
75
|
+
/** Which functions the module includes (see {@link VDBModuleProfile}). */
|
|
76
|
+
readonly profile: VDBModuleProfile;
|
|
77
|
+
/** `sample`+: `'trilinear'` (default) or `'nearest'` (rounds to the closest voxel). */
|
|
78
|
+
readonly sampler?: "trilinear" | "nearest" | undefined;
|
|
79
|
+
/** `read`+: `false` drops `vdbIsActive`. Default `true`. */
|
|
80
|
+
readonly isActive?: boolean | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* `sample`+: `'background'` (default, NanoVDB: the tree's background value)
|
|
83
|
+
* or `'zero'`: sample the field that is 0 outside the index bbox `[min, max]`
|
|
84
|
+
* (voxels). Trilinear is then 0 outside `[min - 1, max + 1)`, nearest outside
|
|
85
|
+
* `[min - 0.5, max + 0.5)` (voxel centres at integers).
|
|
86
|
+
*/
|
|
87
|
+
readonly outside?: "background" | "zero" | undefined;
|
|
88
|
+
/** Opt-in helpers ({@link VDBModuleHelper}); a set: order and duplicates don't matter. Default none. */
|
|
89
|
+
readonly helpers?: Iterable<VDBModuleHelper> | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* `majorant` profile only (P1.3, P1.4): the walk `vdbMajorantInit` / `vdbMajorantNext` compile.
|
|
92
|
+
* - `'brick'` (default): the DDA over the grid's brick-majorant cells (`pool.setMajorant` with
|
|
93
|
+
* `tools` `vdbBrickMajorant`); a grid without them walks as `'global'`.
|
|
94
|
+
* - `'global'`: one segment over the sampler's support box, bounded by the record's `valueMax`.
|
|
95
|
+
* - `'nodeMax'`: an HDDA over the tree bounded by node stats (needs `HAS_MIN_MAX`; adds the march
|
|
96
|
+
* layer, so the module is about 10 KiB larger).
|
|
97
|
+
* Every mode also has `vdbMajorantGlobal(g) -> f32`, the scalar bound.
|
|
98
|
+
*/
|
|
99
|
+
readonly majorant?: "brick" | "global" | "nodeMax" | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* `majorant` profile only: also emit `vdbMajorantMinimum(it) -> f32`, the lower bound of the last
|
|
102
|
+
* segment (the brick minima when the grid's majorant has them, else 0). Default false.
|
|
103
|
+
*/
|
|
104
|
+
readonly minima?: boolean | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* The voxel reader (P1.5): `'vendored'` (default; the audited PNanoVDB accessor) or `'lean'`, a
|
|
107
|
+
* compact descent with a one-leaf cache, about a fifth of the size (`read` / Float ≤ 4 KiB), for kernels
|
|
108
|
+
* near a compiler's size limit. Same public functions and values. Profiles `read`, `sample` and
|
|
109
|
+
* `majorant` with `'brick'` / `'global'`; no march layer, and of the helpers only `'rayClipSupport'` and
|
|
110
|
+
* the majorant profile's (`'majorantWorld'`, `'majorantGlobal'`, `'deltaTrack'`, `'ratioTrack'`).
|
|
111
|
+
*/
|
|
112
|
+
readonly reader?: "vendored" | "lean" | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Helpers `'deltaTrack'` / `'ratioTrack'` only (EX1f-b), and required by them: the name of the host's random
|
|
115
|
+
* function, `fn <name>() -> f32`, declared anywhere in the same shader, returning uniform numbers in [0, 1). The
|
|
116
|
+
* trackers call it by name; the module declares no random state of its own. A plain WGSL identifier that does
|
|
117
|
+
* not start with `vdb` (the module's own prefix).
|
|
118
|
+
*/
|
|
119
|
+
readonly random?: string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* `reader: 'lean'` only (P1.16): what the accessor remembers between reads. Same values in every mode; they
|
|
122
|
+
* differ in the pool words a read loads (docs: "Reads per lookup").
|
|
123
|
+
* - `'leaf'` (default): the last leaf. A read in it loads 1 word, any other read walks the tree from the root
|
|
124
|
+
* (8 words). The 8 taps of a trilinear sample that straddles a leaf face in x walk 8 times.
|
|
125
|
+
* - `'lower'`: the last lower node (a 128-voxel block). Every read in it is one child lookup and the value,
|
|
126
|
+
* 3 words, the same work for every tap of every sample (the `vdbSampleFast` design, K3.2d).
|
|
127
|
+
* - `'lowerLeaf'` (experimental): both. 1 word in the cached leaf, 3 in the cached lower node: the fewest
|
|
128
|
+
* words. Its values equal the CPU twins' on SwiftShader and on Apple Metal, but a wrong image was seen on
|
|
129
|
+
* Apple Metal in one large host kernel (issue #74: pmndrs/pathtracer's 56 KB megakernel; the reader's values
|
|
130
|
+
* were right, other variables of the kernel were not, and `'lower'` fails the same way there once its read
|
|
131
|
+
* function is a few statements longer). Use `'lower'`, and compare a large kernel's image with a reference on
|
|
132
|
+
* Metal after any change of the reader options.
|
|
133
|
+
*
|
|
134
|
+
* A zero-valued accessor (`var acc: VdbAccessor;`, not yet from an init function) is the null accessor in every
|
|
135
|
+
* mode and both readers: `acc.ok` is false, and `vdbReadValue`, `vdbSample` and `vdbIsActive` return 0 / false.
|
|
136
|
+
* A kernel may declare one and assign `vdbAccessorInit(g)` at the first lookup.
|
|
137
|
+
*/
|
|
138
|
+
readonly cache?: "leaf" | "lower" | "lowerLeaf" | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Keep only these public functions and what they call (P1.16): a kernel near a compiler's size limit lists the
|
|
141
|
+
* functions it calls, e.g. `['vdbAccessorInit', 'vdbSample', 'vdbMajorantInit', 'vdbMajorantNext']`, and the
|
|
142
|
+
* module drops the rest (transforms, `vdbRayClip`, `vdbIsActive`, ...). Each name must be a `vdb*` function the
|
|
143
|
+
* module would otherwise have. Default: everything. It shortens the module's text; a host that already removes
|
|
144
|
+
* unreachable functions from its shader (a tree-shaking bundler of WGSL) gains nothing from it.
|
|
145
|
+
*/
|
|
146
|
+
readonly keep?: Iterable<string> | undefined;
|
|
147
|
+
}
|
|
148
|
+
/** `slot` mode: the module declares `@group(g) @binding(b) var<storage, read> vdbPool: array<u32>;`. */
|
|
149
|
+
export interface VDBSlotModuleOptions extends VDBModuleCommonOptions {
|
|
150
|
+
/** The same `VDBSlot` that `vdbModuleEntries(slot)` and `pool.bindGroupEntry(slot)` take. */
|
|
151
|
+
readonly slot: VDBSlot;
|
|
152
|
+
/** Absent in slot mode. */
|
|
153
|
+
readonly buffer?: undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* `buffer` mode: the module declares nothing and reads the host's
|
|
157
|
+
* `array<u32>` through this WGSL expression (engine adapters, e.g.
|
|
158
|
+
* `'vdbPool.value'` from three's TSL).
|
|
159
|
+
*/
|
|
160
|
+
export interface VDBBufferModuleOptions extends VDBModuleCommonOptions {
|
|
161
|
+
/** WGSL expression of the host's `array<u32>` the module reads. */
|
|
162
|
+
readonly buffer: string;
|
|
163
|
+
/** Absent in buffer mode. */
|
|
164
|
+
readonly slot?: undefined;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Options of `vdbModuleWgsl` (docs/dev/design/K1-core.md §3.1): exactly one of
|
|
168
|
+
* `slot` / `buffer`. Annotate a host's options as `VDBSlotModuleOptions` to
|
|
169
|
+
* read `options.slot` without a non-null assertion.
|
|
170
|
+
*/
|
|
171
|
+
export type VDBModuleOptions = VDBSlotModuleOptions | VDBBufferModuleOptions;
|
|
172
|
+
/**
|
|
173
|
+
* The type/layout-only form of `vdbCheckModule`'s options: the types a module
|
|
174
|
+
* decodes and, optionally, the pool layout it targets (default
|
|
175
|
+
* `VDB_GPU_LAYOUT_VERSION`). No binding or profile needed.
|
|
176
|
+
*/
|
|
177
|
+
export interface VDBModuleTypeCheck {
|
|
178
|
+
/** Grid types the module decodes. */
|
|
179
|
+
readonly types: Iterable<VDBGridTypeName>;
|
|
180
|
+
/** Pool layout the module targets. Default `VDB_GPU_LAYOUT_VERSION`. */
|
|
181
|
+
readonly layoutVersion?: number | undefined;
|
|
182
|
+
}
|
|
183
|
+
/** What `vdbCheckModule` needs from a pool (structural, so tests and adapters can pass plain objects). */
|
|
184
|
+
export interface VDBModulePoolLike {
|
|
185
|
+
/** Grid types the pool holds now. */
|
|
186
|
+
readonly types: Iterable<VDBGridTypeName>;
|
|
187
|
+
/** The pool's layout version. */
|
|
188
|
+
readonly layoutVersion: number;
|
|
189
|
+
/**
|
|
190
|
+
* Optional (`VDBGridPool` has it; EX1f-a): the live grids whose global value bound is not finite. With it,
|
|
191
|
+
* `vdbCheckModule` throws `VDB_NO_STATS` for a `majorant` module that would walk one of them on that bound.
|
|
192
|
+
*/
|
|
193
|
+
readonly unboundedGrids?: Iterable<{
|
|
194
|
+
readonly id: number;
|
|
195
|
+
readonly hasStats: boolean;
|
|
196
|
+
readonly hasBrickMajorant: boolean;
|
|
197
|
+
}> | undefined;
|
|
198
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/wgsl/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { VDBGridTypeName, VDBSlot } from \"../types.js\";\n\n/**\n * Generator profiles; each includes the previous one, except that `majorant`\n * (P1.3) is `sample` plus the majorant walk, and includes `march` only with\n * `majorant: 'nodeMax'`.\n */\nexport type VDBModuleProfile = \"read\" | \"sample\" | \"march\" | \"majorant\";\n\n/**\n * Opt-in WGSL helpers (K1.7a). None is emitted unless listed in `helpers`, so\n * a module without them is byte-identical to one generated before they\n * existed.\n *\n * - `'cellBoundTrilinear'` (`march`): `vdbCellBoundTrilinear(acc, ijk, dim) -> f32`,\n * the max of `vdbNodeMax` over the 2x2x2 block of `dim`-cells starting at\n * the cell that holds `ijk`: a bound for every trilinear sample whose base\n * voxel `floor(p)` lies in that cell.\n * - `'hddaCellEnd'` (`march`): `vdbHddaCellEnd(h: ptr<function, VdbHdda>) -> f32`,\n * the ray `t` where the HDDA's current cell ends (`min(next, tmax)`).\n * - `'nodeAverage'` (`march`): `vdbNodeAverage(acc, ijk, dim) -> f32`, the box\n * mean of the aligned `dim`-cell (8: leaf, 128: lower) holding `ijk` from the\n * node's average statistic (K3.2, the `'node-average'` LOD of the sparse\n * volume source): a tile's value; a leaf's `ave * activeVoxels / 512`\n * (inactive voxels count as 0, the fog background); a lower node's `ave`\n * (the mean of its ACTIVE voxels; also for `dim > 128`). Without stats, the value at `ijk`.\n * - `'rayClipSupport'` (`sample`+): `vdbRayClipSupport(g, o, d, t) -> bool`,\n * `vdbRayClip` against the sampler's support box: `[min - 1, max + 1)` for\n * trilinear, `[min - 0.5, max + 0.5)` for nearest.\n * - `'fastTrilinear'` (`sample`+, sampler `'trilinear'`; K3.2d): `vdbSampleFast(acc, xyz) -> f32`,\n * bit-identical to `vdbSample`: it takes the base voxel's lower node (the\n * accessor's cached one, else one descent) and reads each of the 8 taps as\n * one lower-node child lookup, the same work in every lane (no per-tap tree\n * walk, no leaf-cache thrash where the cell straddles leaves); a base on a\n * lower node's +x/+y/+z face (or, with `outside: 'zero'`, whose taps leave\n * the index bbox) calls `vdbSample`. Reuse the accessor across samples to\n * keep its cached lower node.\n * - `'levelSet'` (`march`, K3.7): `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`,\n * the first zero crossing of a level set's trilinear SDF along an index-space\n * ray (HDDA skip of tile and background cells above 0, sphere trace, bisection\n * + secant), `vdbLevelSetGradient(acc, xyz, h) -> vec3f` (central differences,\n * index space) and `vdbLevelSetNormal(g, xyz, h) -> vec3f` (world unit normal).\n * CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`.\n * - `'majorantWorld'` (`majorant`, EX1f-b): `vdbMajorantInitWorld(g, o, d, tMin, tMax) -> VdbMajorantIter`,\n * `vdbMajorantInit` for a world-space ray. `d` is not renormalized, so `t` stays the caller's world parameter.\n * - `'majorantGlobal'` (`majorant` with `'brick'` or `'global'`): `vdbMajorantInitGlobal(g, o, d, tMin, tMax)`, the\n * one-segment walk on the grid's global bound whatever brick bounds it has: pick bricks or the global bound per\n * ray at run time, in one module.\n * - `'deltaTrack'` (`majorant`; needs the `random` option): `vdbDeltaTrack(it, acc, sigma, maxLookups) -> VdbCollision`\n * (`t`, `density`, `hit`, `truncated`, `steps`, `lookups`), delta tracking over the rest of a walk: the next real\n * collision of the medium whose extinction is `sigma * vdbSample`.\n * - `'ratioTrack'` (`majorant`; needs `random`): `vdbRatioTrack(it, acc, sigma, cutoff, maxLookups) -> VdbTransmittance`\n * (`value`, `truncated`, `steps`, `lookups`), ratio tracking over the rest of a walk: an unbiased transmittance for\n * the per-channel extinctions `sigma.rgb * vdbSample` under one shared majorant; Russian roulette below `cutoff`.\n * CPU twins of the walk and the trackers: `tools` `vdbMajorantWalk`, `vdbDeltaTrack`, `vdbRatioTrack`.\n * - `'accessorUnchecked'` (`reader: 'lean'`, P1.16): `vdbAccessorInitUnchecked(g) -> VdbAccessor`, `vdbAccessorInit`\n * without the liveness and type checks, for a grid id the host KNOWS is live and of a compiled type (a dead or\n * foreign id reads unrelated words as a tree). It reads 2 pool words (3 in a module of several types; 6 more\n * with `outside: 'zero'`) where `vdbAccessorInit` reads 5 (15). For a kernel that cannot keep one accessor per\n * ray; keeping one is cheaper still.\n * With `reader: 'lean'` and a `cache` of `'lower'` or `'lowerLeaf'`, `'fastTrilinear'` emits `vdbSampleFast` as\n * `vdbSample` itself (its taps already are lower-node lookups), so one kernel text serves both readers.\n */\nexport type VDBModuleHelper =\n | \"cellBoundTrilinear\"\n | \"hddaCellEnd\"\n | \"levelSet\"\n | \"nodeAverage\"\n | \"rayClipSupport\"\n | \"fastTrilinear\"\n | \"majorantWorld\"\n | \"majorantGlobal\"\n | \"deltaTrack\"\n | \"ratioTrack\"\n | \"accessorUnchecked\";\n\n/** Options every binding mode shares. */\nexport interface VDBModuleCommonOptions {\n /**\n * Grid types to decode; others compile out and read 0. At least one.\n *\n * A module must be generated for every type the host may ever add to the\n * pool, or regenerated (and its pipeline rebuilt) when a new type arrives:\n * `pool.types` only lists the grids present now. Pass\n * `VDB_ALL_SCALAR_TYPES` to never rebuild (the largest module), and call\n * `vdbCheckModule(pool, options)` after each `add`.\n */\n readonly types: Iterable<VDBGridTypeName>;\n /** Which functions the module includes (see {@link VDBModuleProfile}). */\n readonly profile: VDBModuleProfile;\n /** `sample`+: `'trilinear'` (default) or `'nearest'` (rounds to the closest voxel). */\n readonly sampler?: \"trilinear\" | \"nearest\" | undefined;\n /** `read`+: `false` drops `vdbIsActive`. Default `true`. */\n readonly isActive?: boolean | undefined;\n /**\n * `sample`+: `'background'` (default, NanoVDB: the tree's background value)\n * or `'zero'`: sample the field that is 0 outside the index bbox `[min, max]`\n * (voxels). Trilinear is then 0 outside `[min - 1, max + 1)`, nearest outside\n * `[min - 0.5, max + 0.5)` (voxel centres at integers).\n */\n readonly outside?: \"background\" | \"zero\" | undefined;\n /** Opt-in helpers ({@link VDBModuleHelper}); a set: order and duplicates don't matter. Default none. */\n readonly helpers?: Iterable<VDBModuleHelper> | undefined;\n /**\n * `majorant` profile only (P1.3, P1.4): the walk `vdbMajorantInit` / `vdbMajorantNext` compile.\n * - `'brick'` (default): the DDA over the grid's brick-majorant cells (`pool.setMajorant` with\n * `tools` `vdbBrickMajorant`); a grid without them walks as `'global'`.\n * - `'global'`: one segment over the sampler's support box, bounded by the record's `valueMax`.\n * - `'nodeMax'`: an HDDA over the tree bounded by node stats (needs `HAS_MIN_MAX`; adds the march\n * layer, so the module is about 10 KiB larger).\n * Every mode also has `vdbMajorantGlobal(g) -> f32`, the scalar bound.\n */\n readonly majorant?: \"brick\" | \"global\" | \"nodeMax\" | undefined;\n /**\n * `majorant` profile only: also emit `vdbMajorantMinimum(it) -> f32`, the lower bound of the last\n * segment (the brick minima when the grid's majorant has them, else 0). Default false.\n */\n readonly minima?: boolean | undefined;\n /**\n * The voxel reader (P1.5): `'vendored'` (default; the audited PNanoVDB accessor) or `'lean'`, a\n * compact descent with a one-leaf cache, about a fifth of the size (`read` / Float ≤ 4 KiB), for kernels\n * near a compiler's size limit. Same public functions and values. Profiles `read`, `sample` and\n * `majorant` with `'brick'` / `'global'`; no march layer, and of the helpers only `'rayClipSupport'` and\n * the majorant profile's (`'majorantWorld'`, `'majorantGlobal'`, `'deltaTrack'`, `'ratioTrack'`).\n */\n readonly reader?: \"vendored\" | \"lean\" | undefined;\n /**\n * Helpers `'deltaTrack'` / `'ratioTrack'` only (EX1f-b), and required by them: the name of the host's random\n * function, `fn <name>() -> f32`, declared anywhere in the same shader, returning uniform numbers in [0, 1). The\n * trackers call it by name; the module declares no random state of its own. A plain WGSL identifier that does\n * not start with `vdb` (the module's own prefix).\n */\n readonly random?: string | undefined;\n /**\n * `reader: 'lean'` only (P1.16): what the accessor remembers between reads. Same values in every mode; they\n * differ in the pool words a read loads (docs: \"Reads per lookup\").\n * - `'leaf'` (default): the last leaf. A read in it loads 1 word, any other read walks the tree from the root\n * (8 words). The 8 taps of a trilinear sample that straddles a leaf face in x walk 8 times.\n * - `'lower'`: the last lower node (a 128-voxel block). Every read in it is one child lookup and the value,\n * 3 words, the same work for every tap of every sample (the `vdbSampleFast` design, K3.2d).\n * - `'lowerLeaf'` (experimental): both. 1 word in the cached leaf, 3 in the cached lower node: the fewest\n * words. Its values equal the CPU twins' on SwiftShader and on Apple Metal, but a wrong image was seen on\n * Apple Metal in one large host kernel (issue #74: pmndrs/pathtracer's 56 KB megakernel; the reader's values\n * were right, other variables of the kernel were not, and `'lower'` fails the same way there once its read\n * function is a few statements longer). Use `'lower'`, and compare a large kernel's image with a reference on\n * Metal after any change of the reader options.\n *\n * A zero-valued accessor (`var acc: VdbAccessor;`, not yet from an init function) is the null accessor in every\n * mode and both readers: `acc.ok` is false, and `vdbReadValue`, `vdbSample` and `vdbIsActive` return 0 / false.\n * A kernel may declare one and assign `vdbAccessorInit(g)` at the first lookup.\n */\n readonly cache?: \"leaf\" | \"lower\" | \"lowerLeaf\" | undefined;\n /**\n * Keep only these public functions and what they call (P1.16): a kernel near a compiler's size limit lists the\n * functions it calls, e.g. `['vdbAccessorInit', 'vdbSample', 'vdbMajorantInit', 'vdbMajorantNext']`, and the\n * module drops the rest (transforms, `vdbRayClip`, `vdbIsActive`, ...). Each name must be a `vdb*` function the\n * module would otherwise have. Default: everything. It shortens the module's text; a host that already removes\n * unreachable functions from its shader (a tree-shaking bundler of WGSL) gains nothing from it.\n */\n readonly keep?: Iterable<string> | undefined;\n}\n\n/** `slot` mode: the module declares `@group(g) @binding(b) var<storage, read> vdbPool: array<u32>;`. */\nexport interface VDBSlotModuleOptions extends VDBModuleCommonOptions {\n /** The same `VDBSlot` that `vdbModuleEntries(slot)` and `pool.bindGroupEntry(slot)` take. */\n readonly slot: VDBSlot;\n /** Absent in slot mode. */\n readonly buffer?: undefined;\n}\n\n/**\n * `buffer` mode: the module declares nothing and reads the host's\n * `array<u32>` through this WGSL expression (engine adapters, e.g.\n * `'vdbPool.value'` from three's TSL).\n */\nexport interface VDBBufferModuleOptions extends VDBModuleCommonOptions {\n /** WGSL expression of the host's `array<u32>` the module reads. */\n readonly buffer: string;\n /** Absent in buffer mode. */\n readonly slot?: undefined;\n}\n\n/**\n * Options of `vdbModuleWgsl` (docs/dev/design/K1-core.md §3.1): exactly one of\n * `slot` / `buffer`. Annotate a host's options as `VDBSlotModuleOptions` to\n * read `options.slot` without a non-null assertion.\n */\nexport type VDBModuleOptions = VDBSlotModuleOptions | VDBBufferModuleOptions;\n\n/**\n * The type/layout-only form of `vdbCheckModule`'s options: the types a module\n * decodes and, optionally, the pool layout it targets (default\n * `VDB_GPU_LAYOUT_VERSION`). No binding or profile needed.\n */\nexport interface VDBModuleTypeCheck {\n /** Grid types the module decodes. */\n readonly types: Iterable<VDBGridTypeName>;\n /** Pool layout the module targets. Default `VDB_GPU_LAYOUT_VERSION`. */\n readonly layoutVersion?: number | undefined;\n}\n\n/** What `vdbCheckModule` needs from a pool (structural, so tests and adapters can pass plain objects). */\nexport interface VDBModulePoolLike {\n /** Grid types the pool holds now. */\n readonly types: Iterable<VDBGridTypeName>;\n /** The pool's layout version. */\n readonly layoutVersion: number;\n /**\n * Optional (`VDBGridPool` has it; EX1f-a): the live grids whose global value bound is not finite. With it,\n * `vdbCheckModule` throws `VDB_NO_STATS` for a `majorant` module that would walk one of them on that bound.\n */\n readonly unboundedGrids?: Iterable<{ readonly id: number; readonly hasStats: boolean; readonly hasBrickMajorant: boolean }> | undefined;\n}\n"]}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vdbStreamCoarseFirst` (K4.16): stream a coarse-first `.nvdb`
|
|
3
|
+
* (`vdbBakeCoarseFirst`, docs/dev/design/K4-5-coarse-first.md option a) into one
|
|
4
|
+
* pool id. The preview is added as soon as its bytes are in, with the full
|
|
5
|
+
* grid's size reserved, and each finer grid replaces it in place:
|
|
6
|
+
*
|
|
7
|
+
* const res = await fetch(url);
|
|
8
|
+
* const { id } = await vdbStreamCoarseFirst(pool, res, {
|
|
9
|
+
* onGrid: (e) => { if (e.final) console.log("full grid"); },
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* 1. `id = pool.add(preview, { capacity })`, where `capacity` is the largest
|
|
13
|
+
* grid of the family announced so far (a segment lists every grid's
|
|
14
|
+
* FileMetaData before any data, so the full grid's size is known);
|
|
15
|
+
* 2. `pool.replace(id, finer)` for each finer grid, the full grid last.
|
|
16
|
+
*
|
|
17
|
+
* A file baked with `segments: 'per-grid'` (K7.12) announces each grid only
|
|
18
|
+
* when its segment starts: the preview is added with its own size (the full
|
|
19
|
+
* grid's `replace` then moves it to a larger range), and until the full grid's
|
|
20
|
+
* segment starts `voxelRatio` is 1 and `types` lists only the grids seen.
|
|
21
|
+
* Make a `VDBGridNode` with every type you bake, or bake the default layout.
|
|
22
|
+
*
|
|
23
|
+
* The id, its bind-group slot and any instance transform stay. Each image's
|
|
24
|
+
* own Map places it, and a preview covers the full grid's world box, so the
|
|
25
|
+
* world placement is unchanged. Things the caller re-derives after a swap
|
|
26
|
+
* (the `onGrid` callback is the place, or the opt-in `bind` option, which does these
|
|
27
|
+
* three steps for you after every swap):
|
|
28
|
+
* - `replace` drops a brick majorant: call `pool.setMajorant` again;
|
|
29
|
+
* - a `VDBVolumeMaterial` with an explicit `densityScale` (extinction per
|
|
30
|
+
* index voxel): a preview with k-times larger voxels has 1/k the optical
|
|
31
|
+
* depth at the same value, so scale it by `voxelRatio` while a preview
|
|
32
|
+
* shows, and back to 1 at `final`. A material on its defaults needs nothing
|
|
33
|
+
* (EX1a): its `opticalDepth` is relative to the grid's index box and mean
|
|
34
|
+
* density, both of which it reads again after the swap;
|
|
35
|
+
* - the proxy mesh: a new `vdbProxyGeometry(pool.info(id))` (the preview's
|
|
36
|
+
* box is the full box grown to whole preview voxels).
|
|
37
|
+
*
|
|
38
|
+
* Into the froxel renderer (G16a): at the first event make the `VDBGridNode`
|
|
39
|
+
* with `types: event.types` (every grid type of the family) and the sparse
|
|
40
|
+
* source with `followImage: true`; the source re-reads its boxes after each
|
|
41
|
+
* swap and the `VDBFrameVolume` follows, with no new node, source, volume or
|
|
42
|
+
* shader. Froxels integrate in world space: no `voxelRatio` scale there.
|
|
43
|
+
*
|
|
44
|
+
* Without `bind` it touches only `pool.add` / `pool.replace`, so it works with
|
|
45
|
+
* any `VDBGridPool` host. It lives in `./three` because `tools` may not import
|
|
46
|
+
* the core (D20).
|
|
47
|
+
*/
|
|
48
|
+
import type * as THREE from "three";
|
|
49
|
+
import type { VDBBrickMajorant } from "../core/index.js";
|
|
50
|
+
import { type VDBGridTypeName } from "../core/types.js";
|
|
51
|
+
import { type VDBProxyGridInfo } from "./material.js";
|
|
52
|
+
import { type NvdbProgress, type NvdbStreamGrid, type NvdbStreamReaderOptions } from "../tools/index.js";
|
|
53
|
+
/** The part of a `VDBGridPool` the loader uses. */
|
|
54
|
+
export interface VDBCoarseFirstPoolLike {
|
|
55
|
+
/**
|
|
56
|
+
* Stages a grid image and returns its pool id (`VDBGridPool.add`).
|
|
57
|
+
*
|
|
58
|
+
* @param image The grid image.
|
|
59
|
+
* @param options Reserved capacity and label.
|
|
60
|
+
*/
|
|
61
|
+
add(image: Uint32Array, options?: {
|
|
62
|
+
capacity?: number;
|
|
63
|
+
label?: string;
|
|
64
|
+
}): number;
|
|
65
|
+
/**
|
|
66
|
+
* Stages a new image for grid `id` (`VDBGridPool.replace`).
|
|
67
|
+
*
|
|
68
|
+
* @param id The grid's pool id.
|
|
69
|
+
* @param image The new grid image.
|
|
70
|
+
*/
|
|
71
|
+
replace(id: number, image: Uint32Array): void;
|
|
72
|
+
}
|
|
73
|
+
/** The extra pool calls `bind` makes (a `VDBGridPool` has them all). */
|
|
74
|
+
export interface VDBCoarseFirstBindPoolLike {
|
|
75
|
+
/** Writes the staged changes to the GPU (`VDBGridPool.flush`). */
|
|
76
|
+
flush(): void;
|
|
77
|
+
/** Reports a grid's index box and transform (`VDBGridPool.info`). */
|
|
78
|
+
info(id: number): VDBProxyGridInfo;
|
|
79
|
+
/**
|
|
80
|
+
* Sets or clears a grid's brick-majorant bounds (`VDBGridPool.setMajorant`).
|
|
81
|
+
*
|
|
82
|
+
* @param id The grid's pool id.
|
|
83
|
+
* @param majorant The brick bounds, or `null` to clear them.
|
|
84
|
+
*/
|
|
85
|
+
setMajorant(id: number, majorant: VDBBrickMajorant | null): void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* What to keep in step with the pool id after each swap (K5.4c). Every member is optional; the fields are read at
|
|
89
|
+
* each swap, so they may be assigned later (for example in `onGrid`, once the first grid exists).
|
|
90
|
+
*/
|
|
91
|
+
export interface VDBCoarseFirstBind {
|
|
92
|
+
/**
|
|
93
|
+
* A material to scale: `material.densityScale.value = base * event.voxelRatio`, so a preview with k-times larger
|
|
94
|
+
* voxels keeps the full grid's optical depth and the full grid gets `base` back. `base` is `densityScale` below,
|
|
95
|
+
* else the material's value the first time `bind` is applied to it. A `VDBVolumeMaterial` on its defaults has
|
|
96
|
+
* `densityScale` 0 (its `opticalDepth` follows the grid by itself), so it stays 0: nothing to scale.
|
|
97
|
+
*/
|
|
98
|
+
material?: {
|
|
99
|
+
densityScale: {
|
|
100
|
+
value: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** The base density scale for `material`. Default: the material's current value at the first swap. */
|
|
104
|
+
densityScale?: number;
|
|
105
|
+
/** A proxy mesh: its geometry is replaced (and the old one disposed) with `vdbProxyGeometry(pool.info(id))`. */
|
|
106
|
+
mesh?: {
|
|
107
|
+
geometry: THREE.BufferGeometry;
|
|
108
|
+
};
|
|
109
|
+
/** `vdbProxyGeometry` padding for `mesh` (default 0). */
|
|
110
|
+
proxyPad?: number;
|
|
111
|
+
/** A `VDBGridNode`: `pool.flush()` then `grids.update()`, so its shaders see the swapped grid. */
|
|
112
|
+
grids?: {
|
|
113
|
+
update(): void;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Brick majorant for the grid just shown (`replace` drops the old one). Return `null` / `undefined` to leave the grid
|
|
117
|
+
* without one, e.g. for a preview.
|
|
118
|
+
*/
|
|
119
|
+
majorant?: (event: VDBCoarseFirstEvent) => VDBBrickMajorant | null | undefined;
|
|
120
|
+
}
|
|
121
|
+
/** What a coarse-first stream delivers. */
|
|
122
|
+
export type VDBCoarseFirstSource = Response | ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
|
|
123
|
+
/** One grid shown in the pool. */
|
|
124
|
+
export interface VDBCoarseFirstEvent {
|
|
125
|
+
/** The pool id (the same for every grid of the family). */
|
|
126
|
+
id: number;
|
|
127
|
+
/** The grid as the stream reader emitted it (`lod` is null for the full grid). */
|
|
128
|
+
grid: NvdbStreamGrid;
|
|
129
|
+
/** True for the full grid: the last swap. */
|
|
130
|
+
final: boolean;
|
|
131
|
+
/** `'add'` for the first grid shown, `'replace'` after. */
|
|
132
|
+
action: "add" | "replace";
|
|
133
|
+
/** File bytes received when the grid was shown (decoded bytes; see the e2e for compressed counts). */
|
|
134
|
+
bytesReceived: number;
|
|
135
|
+
/** Expected file size when the grid was shown, or null if unknown (K4.20; see `NvdbProgress.bytesTotal`). */
|
|
136
|
+
bytesTotal: number | null;
|
|
137
|
+
/**
|
|
138
|
+
* This grid's voxel size over the full grid's (x axis): 1 for the full grid, > 1 for a preview. 1 while the full
|
|
139
|
+
* grid is not announced yet (a `segments: 'per-grid'` file, K7.12).
|
|
140
|
+
*/
|
|
141
|
+
voxelRatio: number;
|
|
142
|
+
/**
|
|
143
|
+
* G16a: the grid types of the family's grids announced so far (a one-segment file lists every grid's metadata
|
|
144
|
+
* before any data, so this holds the full grid's type from the first event on; a per-grid-segment file, K7.12, adds
|
|
145
|
+
* each grid's type when its segment starts), in `VDB_GRID_TYPE_NAMES` order (`float, fp4, fp8, fp16, fpn, half`, not
|
|
146
|
+
* alphabetical), each once. A `VDBGridNode` made with `types: event.types` decodes the
|
|
147
|
+
* preview and the full grid with one module (a baked FpN preview and an Fp8 full grid differ), so a source made
|
|
148
|
+
* with `followImage` swaps without a recompile.
|
|
149
|
+
*/
|
|
150
|
+
types: VDBGridTypeName[];
|
|
151
|
+
}
|
|
152
|
+
/** Options of {@link vdbStreamCoarseFirst}. */
|
|
153
|
+
export interface VDBCoarseFirstOptions {
|
|
154
|
+
/** Which family to load, by the full grid's name. Default: the first grid's family. */
|
|
155
|
+
gridName?: string;
|
|
156
|
+
/** Pool label for the id. Default: the full grid's name. */
|
|
157
|
+
label?: string;
|
|
158
|
+
/** Limits for the stream reader. */
|
|
159
|
+
reader?: NvdbStreamReaderOptions;
|
|
160
|
+
/**
|
|
161
|
+
* Keeps a material, proxy mesh, grid node and majorant in step with each swap, before `onGrid` runs (see
|
|
162
|
+
* {@link VDBCoarseFirstBind} and {@link vdbCoarseFirstApply}). Needs a pool with `flush` / `info` / `setMajorant`
|
|
163
|
+
* (a `VDBGridPool`).
|
|
164
|
+
*/
|
|
165
|
+
bind?: VDBCoarseFirstBind;
|
|
166
|
+
/** Called after each `pool.add` / `pool.replace` (preview, then finer grids, then the full grid), after `bind`. */
|
|
167
|
+
onGrid?: (event: VDBCoarseFirstEvent) => void;
|
|
168
|
+
/** Called after every received chunk with the byte progress (K4.20). `bytesTotal` is the Response's Content-Length, else derived from the file's metadata. */
|
|
169
|
+
onProgress?: (progress: NvdbProgress) => void;
|
|
170
|
+
/** Aborts the read (rejects with the signal's reason; the id, if added, stays in the pool). */
|
|
171
|
+
signal?: AbortSignal;
|
|
172
|
+
}
|
|
173
|
+
/** What {@link vdbStreamCoarseFirst} resolves with once the full grid is in the pool. */
|
|
174
|
+
export interface VDBCoarseFirstResult {
|
|
175
|
+
/** The pool id the preview and every finer grid were shown in. */
|
|
176
|
+
id: number;
|
|
177
|
+
/** Every grid shown, in order (the preview(s), then the full grid). */
|
|
178
|
+
shown: VDBCoarseFirstEvent[];
|
|
179
|
+
/** File bytes received when the first grid was added. */
|
|
180
|
+
firstBytes: number;
|
|
181
|
+
/** File bytes received when the full grid replaced the preview. */
|
|
182
|
+
fullBytes: number;
|
|
183
|
+
/** Expected file size when the full grid arrived, or null if unknown. */
|
|
184
|
+
bytesTotal: number | null;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The work `bind` does after a swap, callable on its own from an async `onGrid` (or any code that shows a
|
|
188
|
+
* {@link VDBCoarseFirstEvent}): majorant, proxy geometry, `pool.flush()` + `grids.update()`, density scale. It never
|
|
189
|
+
* touches what `bind` leaves out.
|
|
190
|
+
*
|
|
191
|
+
* @param pool The pool the grid is in (with `flush`, `info` and `setMajorant` when `bind` needs them).
|
|
192
|
+
* @param event The swap to follow, as passed to `onGrid`.
|
|
193
|
+
* @param bind What to keep in step: material, proxy mesh, grid node, majorant.
|
|
194
|
+
*/
|
|
195
|
+
export declare function vdbCoarseFirstApply(pool: VDBCoarseFirstPoolLike & Partial<VDBCoarseFirstBindPoolLike>, event: VDBCoarseFirstEvent, bind: VDBCoarseFirstBind): void;
|
|
196
|
+
/**
|
|
197
|
+
* Streams a coarse-first `.nvdb` into one pool id: `add` the first grid of the
|
|
198
|
+
* family with the family's largest size reserved, then `replace` with each
|
|
199
|
+
* finer grid. Resolves when the full grid is in the pool (the rest of the
|
|
200
|
+
* stream is cancelled). Rejects with the reader's `NvdbFormatError` on bad
|
|
201
|
+
* or truncated data.
|
|
202
|
+
*
|
|
203
|
+
* @param pool The pool the grid is added to and replaced in.
|
|
204
|
+
* @param source A `fetch` `Response`, a byte `ReadableStream` or an async iterable of chunks.
|
|
205
|
+
* @param options Family name, label, reader limits, `bind`, callbacks and an abort signal.
|
|
206
|
+
*/
|
|
207
|
+
export declare function vdbStreamCoarseFirst(pool: VDBCoarseFirstPoolLike & Partial<VDBCoarseFirstBindPoolLike>, source: VDBCoarseFirstSource, options?: VDBCoarseFirstOptions): Promise<VDBCoarseFirstResult>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `vdbStreamCoarseFirst` (K4.16): stream a coarse-first `.nvdb`
|
|
3
|
+
* (`vdbBakeCoarseFirst`, docs/dev/design/K4-5-coarse-first.md option a) into one
|
|
4
|
+
* pool id. The preview is added as soon as its bytes are in, with the full
|
|
5
|
+
* grid's size reserved, and each finer grid replaces it in place:
|
|
6
|
+
*
|
|
7
|
+
* const res = await fetch(url);
|
|
8
|
+
* const { id } = await vdbStreamCoarseFirst(pool, res, {
|
|
9
|
+
* onGrid: (e) => { if (e.final) console.log("full grid"); },
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* 1. `id = pool.add(preview, { capacity })`, where `capacity` is the largest
|
|
13
|
+
* grid of the family announced so far (a segment lists every grid's
|
|
14
|
+
* FileMetaData before any data, so the full grid's size is known);
|
|
15
|
+
* 2. `pool.replace(id, finer)` for each finer grid, the full grid last.
|
|
16
|
+
*
|
|
17
|
+
* A file baked with `segments: 'per-grid'` (K7.12) announces each grid only
|
|
18
|
+
* when its segment starts: the preview is added with its own size (the full
|
|
19
|
+
* grid's `replace` then moves it to a larger range), and until the full grid's
|
|
20
|
+
* segment starts `voxelRatio` is 1 and `types` lists only the grids seen.
|
|
21
|
+
* Make a `VDBGridNode` with every type you bake, or bake the default layout.
|
|
22
|
+
*
|
|
23
|
+
* The id, its bind-group slot and any instance transform stay. Each image's
|
|
24
|
+
* own Map places it, and a preview covers the full grid's world box, so the
|
|
25
|
+
* world placement is unchanged. Things the caller re-derives after a swap
|
|
26
|
+
* (the `onGrid` callback is the place, or the opt-in `bind` option, which does these
|
|
27
|
+
* three steps for you after every swap):
|
|
28
|
+
* - `replace` drops a brick majorant: call `pool.setMajorant` again;
|
|
29
|
+
* - a `VDBVolumeMaterial` with an explicit `densityScale` (extinction per
|
|
30
|
+
* index voxel): a preview with k-times larger voxels has 1/k the optical
|
|
31
|
+
* depth at the same value, so scale it by `voxelRatio` while a preview
|
|
32
|
+
* shows, and back to 1 at `final`. A material on its defaults needs nothing
|
|
33
|
+
* (EX1a): its `opticalDepth` is relative to the grid's index box and mean
|
|
34
|
+
* density, both of which it reads again after the swap;
|
|
35
|
+
* - the proxy mesh: a new `vdbProxyGeometry(pool.info(id))` (the preview's
|
|
36
|
+
* box is the full box grown to whole preview voxels).
|
|
37
|
+
*
|
|
38
|
+
* Into the froxel renderer (G16a): at the first event make the `VDBGridNode`
|
|
39
|
+
* with `types: event.types` (every grid type of the family) and the sparse
|
|
40
|
+
* source with `followImage: true`; the source re-reads its boxes after each
|
|
41
|
+
* swap and the `VDBFrameVolume` follows, with no new node, source, volume or
|
|
42
|
+
* shader. Froxels integrate in world space: no `voxelRatio` scale there.
|
|
43
|
+
*
|
|
44
|
+
* Without `bind` it touches only `pool.add` / `pool.replace`, so it works with
|
|
45
|
+
* any `VDBGridPool` host. It lives in `./three` because `tools` may not import
|
|
46
|
+
* the core (D20).
|
|
47
|
+
*/
|
|
48
|
+
import { VDBError } from "../core/errors.js";
|
|
49
|
+
import { VDB_GRID_TYPE_NAMES } from "../core/types.js";
|
|
50
|
+
import { vdbProxyGeometry } from "./material.js";
|
|
51
|
+
import { nvdbResponseLength } from "../tools/nvdb-stream.js";
|
|
52
|
+
import { NvdbStreamReader, parseNvdbLodName, } from "../tools/index.js";
|
|
53
|
+
/** The base density scale of each bound material (the value seen at its first swap, unless `bind.densityScale` says). */
|
|
54
|
+
const baseScale = new WeakMap();
|
|
55
|
+
/**
|
|
56
|
+
* The work `bind` does after a swap, callable on its own from an async `onGrid` (or any code that shows a
|
|
57
|
+
* {@link VDBCoarseFirstEvent}): majorant, proxy geometry, `pool.flush()` + `grids.update()`, density scale. It never
|
|
58
|
+
* touches what `bind` leaves out.
|
|
59
|
+
*
|
|
60
|
+
* @param pool The pool the grid is in (with `flush`, `info` and `setMajorant` when `bind` needs them).
|
|
61
|
+
* @param event The swap to follow, as passed to `onGrid`.
|
|
62
|
+
* @param bind What to keep in step: material, proxy mesh, grid node, majorant.
|
|
63
|
+
*/
|
|
64
|
+
export function vdbCoarseFirstApply(pool, event, bind) {
|
|
65
|
+
const need = (name) => {
|
|
66
|
+
const fn = pool[name];
|
|
67
|
+
if (typeof fn !== "function") {
|
|
68
|
+
throw new VDBError("VDB_BAD_OPTION", `vdbStreamCoarseFirst: \`bind\` needs a pool with ${name}() (a VDBGridPool).`);
|
|
69
|
+
}
|
|
70
|
+
return fn.bind(pool);
|
|
71
|
+
};
|
|
72
|
+
if (bind.majorant) {
|
|
73
|
+
const majorant = bind.majorant(event);
|
|
74
|
+
if (majorant)
|
|
75
|
+
need("setMajorant")(event.id, majorant);
|
|
76
|
+
}
|
|
77
|
+
if (bind.mesh) {
|
|
78
|
+
const next = vdbProxyGeometry(need("info")(event.id), bind.proxyPad === undefined ? {} : { pad: bind.proxyPad });
|
|
79
|
+
bind.mesh.geometry.dispose();
|
|
80
|
+
bind.mesh.geometry = next;
|
|
81
|
+
}
|
|
82
|
+
if (bind.grids) {
|
|
83
|
+
need("flush")();
|
|
84
|
+
bind.grids.update();
|
|
85
|
+
}
|
|
86
|
+
const material = bind.material;
|
|
87
|
+
if (material) {
|
|
88
|
+
const base = bind.densityScale ?? baseScale.get(material) ?? material.densityScale.value;
|
|
89
|
+
baseScale.set(material, base);
|
|
90
|
+
material.densityScale.value = base * event.voxelRatio;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const familyOf = (name) => parseNvdbLodName(name).baseName;
|
|
94
|
+
/** Finest first: the full grid (lod null) beats any preview; a larger resolution beats a smaller. */
|
|
95
|
+
function finer(a, b) {
|
|
96
|
+
if (b === null)
|
|
97
|
+
return true;
|
|
98
|
+
if (b.lod === null)
|
|
99
|
+
return false;
|
|
100
|
+
if (a.lod === null)
|
|
101
|
+
return true;
|
|
102
|
+
return a.lod > b.lod;
|
|
103
|
+
}
|
|
104
|
+
function chunks(source) {
|
|
105
|
+
const stream = source instanceof Response ? source.body : source;
|
|
106
|
+
if (source instanceof Response && !source.ok) {
|
|
107
|
+
throw new VDBError("VDB_BAD_OPTION", `vdbStreamCoarseFirst: the response is ${source.status} ${source.statusText} (${source.url}).`);
|
|
108
|
+
}
|
|
109
|
+
if (stream === null)
|
|
110
|
+
throw new VDBError("VDB_BAD_OPTION", "vdbStreamCoarseFirst: the response has no body.");
|
|
111
|
+
if (typeof stream.getReader === "function") {
|
|
112
|
+
const reader = stream.getReader();
|
|
113
|
+
return {
|
|
114
|
+
iterate: {
|
|
115
|
+
async *[Symbol.asyncIterator]() {
|
|
116
|
+
for (;;) {
|
|
117
|
+
const { done, value } = await reader.read();
|
|
118
|
+
if (done)
|
|
119
|
+
return;
|
|
120
|
+
yield value;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
cancel: () => reader.cancel().catch(() => undefined),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const iterable = stream;
|
|
128
|
+
return { iterate: iterable, cancel: async () => undefined };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Streams a coarse-first `.nvdb` into one pool id: `add` the first grid of the
|
|
132
|
+
* family with the family's largest size reserved, then `replace` with each
|
|
133
|
+
* finer grid. Resolves when the full grid is in the pool (the rest of the
|
|
134
|
+
* stream is cancelled). Rejects with the reader's `NvdbFormatError` on bad
|
|
135
|
+
* or truncated data.
|
|
136
|
+
*
|
|
137
|
+
* @param pool The pool the grid is added to and replaced in.
|
|
138
|
+
* @param source A `fetch` `Response`, a byte `ReadableStream` or an async iterable of chunks.
|
|
139
|
+
* @param options Family name, label, reader limits, `bind`, callbacks and an abort signal.
|
|
140
|
+
*/
|
|
141
|
+
export async function vdbStreamCoarseFirst(pool, source, options = {}) {
|
|
142
|
+
const signal = options.signal;
|
|
143
|
+
signal?.throwIfAborted();
|
|
144
|
+
const wire = source instanceof Response ? nvdbResponseLength(source) : null;
|
|
145
|
+
const reader = new NvdbStreamReader({
|
|
146
|
+
...options.reader,
|
|
147
|
+
...(wire !== null && options.reader?.bytesTotal === undefined ? { bytesTotal: wire } : {}),
|
|
148
|
+
...(options.onProgress ? { onProgress: options.onProgress } : {}),
|
|
149
|
+
});
|
|
150
|
+
const { iterate, cancel } = chunks(source);
|
|
151
|
+
let family = options.gridName ?? null;
|
|
152
|
+
let id = -1;
|
|
153
|
+
let current = null;
|
|
154
|
+
const shown = [];
|
|
155
|
+
const familyGrids = () => reader.grids.filter((g) => familyOf(g.name) === family);
|
|
156
|
+
const fullVoxel = (grid) => {
|
|
157
|
+
const full = familyGrids().find((g) => g.name === family);
|
|
158
|
+
return full ? grid.metadata.voxelSize[0] / full.voxelSize[0] : 1;
|
|
159
|
+
};
|
|
160
|
+
// The reader accepts only the pool's scalar types (Float, Fp4, Fp8, Fp16, FpN, Half: the names in lower case).
|
|
161
|
+
const familyTypes = () => {
|
|
162
|
+
const names = new Set(familyGrids().map((g) => g.gridType.toLowerCase()));
|
|
163
|
+
return VDB_GRID_TYPE_NAMES.filter((t) => names.has(t));
|
|
164
|
+
};
|
|
165
|
+
try {
|
|
166
|
+
for await (const chunk of iterate) {
|
|
167
|
+
signal?.throwIfAborted();
|
|
168
|
+
for (const grid of reader.push(chunk)) {
|
|
169
|
+
family ??= grid.baseName;
|
|
170
|
+
if (grid.baseName !== family || !finer(grid, current))
|
|
171
|
+
continue;
|
|
172
|
+
const final = grid.lod === null;
|
|
173
|
+
let action;
|
|
174
|
+
if (id < 0) {
|
|
175
|
+
const capacity = Math.max(...familyGrids().map((g) => g.gridByteSize));
|
|
176
|
+
id = pool.add(grid.image, { capacity, label: options.label ?? family });
|
|
177
|
+
action = "add";
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
pool.replace(id, grid.image);
|
|
181
|
+
action = "replace";
|
|
182
|
+
}
|
|
183
|
+
current = grid;
|
|
184
|
+
const event = { id, grid, final, action, bytesReceived: grid.bytesReceived, bytesTotal: grid.bytesTotal, voxelRatio: fullVoxel(grid), types: familyTypes() };
|
|
185
|
+
shown.push(event);
|
|
186
|
+
if (options.bind)
|
|
187
|
+
vdbCoarseFirstApply(pool, event, options.bind);
|
|
188
|
+
options.onGrid?.(event);
|
|
189
|
+
if (final) {
|
|
190
|
+
await cancel();
|
|
191
|
+
return { id, shown, firstBytes: shown[0].bytesReceived, fullBytes: grid.bytesReceived, bytesTotal: grid.bytesTotal };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
reader.end();
|
|
196
|
+
}
|
|
197
|
+
catch (err) {
|
|
198
|
+
await cancel();
|
|
199
|
+
throw err;
|
|
200
|
+
}
|
|
201
|
+
throw new VDBError("VDB_BAD_IMAGE", family === null
|
|
202
|
+
? "vdbStreamCoarseFirst: the stream held no grid."
|
|
203
|
+
: `vdbStreamCoarseFirst: the stream ended without the full grid "${family}" (grids: ${reader.grids.map((g) => g.name).join(", ")}).`);
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=coarse-first.js.map
|