@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,110 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (the dense texture setup this handle describes);
|
|
3
|
+
// src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: TypeScript; K6.11 (D35): a handle only. His `createVolumeUniforms` / `createVolumeNodes` shape (the TSL half,
|
|
6
|
+
// `vdbVolumeUniforms` / `vdbVolumeNodes`) and the three textures are deleted: the core's `vdbDenseSource` reads the volume.
|
|
7
|
+
// Divergences: DIVERGES.md V23–V25.
|
|
8
|
+
/**
|
|
9
|
+
* The dense `.wvdb` volume source in three (K3.0, R1 §4.2): a handle `VDBFrameVolume` draws.
|
|
10
|
+
*
|
|
11
|
+
* const file = readWvdb(bytes);
|
|
12
|
+
* const volume = wvdbDenseVolume(file); // @pmndrs/vdb/tools: his 8-bit texels + mip atlas
|
|
13
|
+
* const source = vdbDenseTextures(volume); // the handle
|
|
14
|
+
* const frameVolume = new VDBFrameVolume(source, { extinction: 100 });
|
|
15
|
+
*
|
|
16
|
+
* K6.11: the handle holds no GPU object. `VDBFrameRenderer` reads `source.volume` into the core's dense source
|
|
17
|
+
* (`vdbDenseSource`, which makes the textures and the `vdbSrc*` WGSL). A custom TSL material samples a pooled grid
|
|
18
|
+
* through `VDBGridNode`; custom WGSL or compute uses the core source's `wgsl()`.
|
|
19
|
+
*/
|
|
20
|
+
import { VDBError } from "../core/errors.js";
|
|
21
|
+
const CHANNELS = ["density", "mask", "albedo", "emission"];
|
|
22
|
+
const channelsOf = (v) => ({
|
|
23
|
+
density: v.density,
|
|
24
|
+
mask: v.mask,
|
|
25
|
+
albedo: v.albedo,
|
|
26
|
+
emission: v.emission,
|
|
27
|
+
});
|
|
28
|
+
const sameDims = (a, b) => !!a && !!b && a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
29
|
+
class ThreeDenseSource {
|
|
30
|
+
kind = "dense";
|
|
31
|
+
boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);
|
|
32
|
+
channels;
|
|
33
|
+
volume;
|
|
34
|
+
texels;
|
|
35
|
+
lodLevels;
|
|
36
|
+
stats;
|
|
37
|
+
version = 0;
|
|
38
|
+
warnedExtra = new Set();
|
|
39
|
+
#shape;
|
|
40
|
+
constructor(volume) {
|
|
41
|
+
this.volume = volume;
|
|
42
|
+
this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };
|
|
43
|
+
const c = channelsOf(volume);
|
|
44
|
+
this.#shape = Object.fromEntries(CHANNELS.map((n) => [n, c[n] ? { mip: !!c[n].mip } : null]));
|
|
45
|
+
this.texels = [...volume.dimensions];
|
|
46
|
+
this.lodLevels = volume.density.mip?.levels ?? 0;
|
|
47
|
+
this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
|
|
48
|
+
}
|
|
49
|
+
replace(volume) {
|
|
50
|
+
if (!volume || volume.kind !== "dense" || !volume.density) {
|
|
51
|
+
throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures.replace: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).");
|
|
52
|
+
}
|
|
53
|
+
const shape = this.#shape;
|
|
54
|
+
const next = channelsOf(volume);
|
|
55
|
+
const densityMip = next.density.mip;
|
|
56
|
+
if (!!shape.density.mip !== !!densityMip && shape.density.mip) {
|
|
57
|
+
throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures.replace: the frame's density has no mip atlas but the source's has; bake every frame with mipmaps, or make the source without.");
|
|
58
|
+
}
|
|
59
|
+
// K5.9 (sequences): a channel the source has and the frame lacks reads its absent value (mask and albedo 1,
|
|
60
|
+
// emission 0; the core's dense source does that); a channel (or mip atlas) the source lacks is ignored, since the
|
|
61
|
+
// shaders were built without it (warned once: make the source from a frame that has every channel).
|
|
62
|
+
for (const name of CHANNELS) {
|
|
63
|
+
const s = shape[name];
|
|
64
|
+
const v = next[name];
|
|
65
|
+
if (!s && v) {
|
|
66
|
+
if (!this.warnedExtra.has(name)) {
|
|
67
|
+
this.warnedExtra.add(name);
|
|
68
|
+
console.warn(`vdbDenseTextures.replace: the frame has a ${name} channel the source was made without; it is ignored.`);
|
|
69
|
+
}
|
|
70
|
+
next[name] = null;
|
|
71
|
+
}
|
|
72
|
+
else if (s && v && s.mip !== !!v.mip && s.mip) {
|
|
73
|
+
throw new VDBError("VDB_BAD_OPTION", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// WVDBLoader.js L37–48 updateTexture: a new size is a new texture (here: bumps `version`).
|
|
77
|
+
const before = channelsOf(this.volume);
|
|
78
|
+
let resized = false;
|
|
79
|
+
for (const name of CHANNELS) {
|
|
80
|
+
const o = before[name];
|
|
81
|
+
const v = next[name];
|
|
82
|
+
if (!o || !v)
|
|
83
|
+
continue;
|
|
84
|
+
if (!sameDims(o.dimensions, v.dimensions) || (!!o.mip && !!v.mip && !sameDims(o.mip.dimensions, v.mip.dimensions)))
|
|
85
|
+
resized = true;
|
|
86
|
+
}
|
|
87
|
+
// A frame with another world box (his WVDB sequences give each frame its own) also bumps `version`, so a
|
|
88
|
+
// VDBFrameVolume whose box is the source's moves its box (an empty frame's null box keeps the last one).
|
|
89
|
+
const a = this.volume.bbox;
|
|
90
|
+
const b = volume.bbox;
|
|
91
|
+
const moved = !!b && (!a || a.some((corner, i) => corner.some((v, k) => v !== b[i][k])));
|
|
92
|
+
if (resized || moved)
|
|
93
|
+
this.version++;
|
|
94
|
+
this.volume = volume;
|
|
95
|
+
this.texels = [...volume.dimensions];
|
|
96
|
+
this.lodLevels = shape.density.mip ? (volume.density.mip?.levels ?? 0) : 0;
|
|
97
|
+
this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };
|
|
98
|
+
}
|
|
99
|
+
dispose() {
|
|
100
|
+
// No GPU object: the core's dense source (the frame renderer's) owns the textures.
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** A dense `.wvdb` volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as a handle for `VDBFrameVolume`. */
|
|
104
|
+
export function vdbDenseTextures(volume) {
|
|
105
|
+
if (!volume || volume.kind !== "dense" || !volume.density) {
|
|
106
|
+
throw new VDBError("VDB_BAD_OPTION", "vdbDenseTextures: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).");
|
|
107
|
+
}
|
|
108
|
+
return new ThreeDenseSource(volume);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=volume-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volume-source.js","sourceRoot":"","sources":["../../src/three/volume-source.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kHAAkH;AAClH,iFAAiF;AACjF,4GAA4G;AAC5G,yHAAyH;AACzH,4HAA4H;AAC5H,oCAAoC;AAEpC;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAM7C,MAAM,QAAQ,GAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAqBnF,MAAM,UAAU,GAAG,CAAC,CAAkB,EAAgD,EAAE,CAAC,CAAC;IACxF,OAAO,EAAE,CAAC,CAAC,OAAO;IAClB,IAAI,EAAE,CAAC,CAAC,IAAI;IACZ,MAAM,EAAE,CAAC,CAAC,MAAM;IAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;CACrB,CAAC,CAAC;AAKH,MAAM,QAAQ,GAAG,CAAC,CAAgC,EAAE,CAAgC,EAAW,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAA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AAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,OAAO,IAAI,KAAK;YAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,CAA6B,CAAC;QACjE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,OAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,KAAK,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;IAC9G,CAAC;IAED,OAAO;QACL,mFAAmF;IACrF,CAAC;CACF;AAED,wGAAwG;AACxG,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC1D,MAAM,IAAI,QAAQ,CAAC,gBAAgB,EAAE,mFAAmF,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/FrameVolume.js L14–22, L357–405 (the dense texture setup this handle describes);\n// src/three-openvdb/frame/webgpu/frameMipmaps.js L183–189 (mip atlas texture).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; K6.11 (D35): a handle only. His `createVolumeUniforms` / `createVolumeNodes` shape (the TSL half,\n// `vdbVolumeUniforms` / `vdbVolumeNodes`) and the three textures are deleted: the core's `vdbDenseSource` reads the volume.\n// Divergences: DIVERGES.md V23–V25.\n\n/**\n * The dense `.wvdb` volume source in three (K3.0, R1 §4.2): a handle `VDBFrameVolume` draws.\n *\n * const file = readWvdb(bytes);\n * const volume = wvdbDenseVolume(file); // @pmndrs/vdb/tools: his 8-bit texels + mip atlas\n * const source = vdbDenseTextures(volume); // the handle\n * const frameVolume = new VDBFrameVolume(source, { extinction: 100 });\n *\n * K6.11: the handle holds no GPU object. `VDBFrameRenderer` reads `source.volume` into the core's dense source\n * (`vdbDenseSource`, which makes the textures and the `vdbSrc*` WGSL). A custom TSL material samples a pooled grid\n * through `VDBGridNode`; custom WGSL or compute uses the core source's `wgsl()`.\n */\n\nimport { VDBError } from \"../core/errors.js\";\nimport type { VDBVolumeChannels, VDBVolumeSourceInfo } from \"../core/source/types.js\";\nimport type { WvdbDenseTexture, WvdbDenseVolume } from \"../tools/wvdb/dense.js\";\nimport type { VDBThreeSparseSource } from \"./sparse-source.js\";\n\ntype ChannelName = \"density\" | \"mask\" | \"albedo\" | \"emission\";\nconst CHANNELS: readonly ChannelName[] = [\"density\", \"mask\", \"albedo\", \"emission\"];\n\n/** A dense source as a handle (the descriptive part of `VDBVolumeSource`; no raw bindings). */\nexport interface VDBThreeDenseSource extends VDBVolumeSourceInfo {\n /** Always `\"dense\"`. */\n readonly kind: \"dense\";\n /** The `.wvdb` volume currently set (`VDBFrameVolume`: the core frame renderer uploads it into its own textures). */\n readonly volume: WvdbDenseVolume;\n /**\n * Swap in another LOD or sequence frame. New sizes bump `version`, and so does a frame with another `.wvdb` box\n * (a `VDBFrameVolume` follows by itself, its box too unless it was given a `bbox`). A channel the source lacks is\n * ignored (warned once). The density's mip atlas must stay if the source has one.\n */\n replace(volume: WvdbDenseVolume): void;\n /** Releases the handle (it holds no GPU object). */\n dispose(): void;\n}\n\n/** A volume source `VDBFrameVolume` reads: a dense `.wvdb` volume or a pool grid. */\nexport type VDBThreeVolumeSource = VDBThreeDenseSource | VDBThreeSparseSource;\n\nconst channelsOf = (v: WvdbDenseVolume): Record<ChannelName, WvdbDenseTexture | null> => ({\n density: v.density,\n mask: v.mask,\n albedo: v.albedo,\n emission: v.emission,\n});\n\n/** Which channels (and whether each has a mip atlas) a dense source was made with; fixed for its life. */\ntype DenseShape = Record<ChannelName, { mip: boolean } | null>;\n\nconst sameDims = (a: readonly number[] | undefined, b: readonly number[] | undefined): boolean => !!a && !!b && a[0] === b[0] && a[1] === b[1] && a[2] === b[2];\n\nclass ThreeDenseSource implements VDBThreeDenseSource {\n readonly kind = \"dense\" as const;\n readonly boxToSource = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.5, 0.5, 0.5, 1]);\n readonly channels: VDBVolumeChannels;\n volume: WvdbDenseVolume;\n texels: [number, number, number];\n lodLevels: number;\n stats: { meanNonZero: number; max: number; activeVoxels: number };\n version = 0;\n private readonly warnedExtra = new Set<ChannelName>();\n readonly #shape: DenseShape;\n\n constructor(volume: WvdbDenseVolume) {\n this.volume = volume;\n this.channels = { mask: !!volume.mask, albedo: !!volume.albedo, emission: !!volume.emission };\n const c = channelsOf(volume);\n this.#shape = Object.fromEntries(CHANNELS.map((n) => [n, c[n] ? { mip: !!c[n]!.mip } : null])) as DenseShape;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = volume.density.mip?.levels ?? 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n replace(volume: WvdbDenseVolume): void {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n const shape = this.#shape;\n const next = channelsOf(volume);\n const densityMip = next.density!.mip;\n if (!!shape.density!.mip !== !!densityMip && shape.density!.mip) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures.replace: the frame's density has no mip atlas but the source's has; bake every frame with mipmaps, or make the source without.\");\n }\n // K5.9 (sequences): a channel the source has and the frame lacks reads its absent value (mask and albedo 1,\n // emission 0; the core's dense source does that); a channel (or mip atlas) the source lacks is ignored, since the\n // shaders were built without it (warned once: make the source from a frame that has every channel).\n for (const name of CHANNELS) {\n const s = shape[name];\n const v = next[name];\n if (!s && v) {\n if (!this.warnedExtra.has(name)) {\n this.warnedExtra.add(name);\n console.warn(`vdbDenseTextures.replace: the frame has a ${name} channel the source was made without; it is ignored.`);\n }\n next[name] = null;\n } else if (s && v && s.mip !== !!v.mip && s.mip) {\n throw new VDBError(\"VDB_BAD_OPTION\", `vdbDenseTextures.replace: the frame's ${name} channel has no mip atlas but the source's has; make a new source.`);\n }\n }\n // WVDBLoader.js L37–48 updateTexture: a new size is a new texture (here: bumps `version`).\n const before = channelsOf(this.volume);\n let resized = false;\n for (const name of CHANNELS) {\n const o = before[name];\n const v = next[name];\n if (!o || !v) continue;\n if (!sameDims(o.dimensions, v.dimensions) || (!!o.mip && !!v.mip && !sameDims(o.mip.dimensions, v.mip.dimensions))) resized = true;\n }\n // A frame with another world box (his WVDB sequences give each frame its own) also bumps `version`, so a\n // VDBFrameVolume whose box is the source's moves its box (an empty frame's null box keeps the last one).\n const a = this.volume.bbox;\n const b = volume.bbox;\n const moved = !!b && (!a || a.some((corner, i) => corner.some((v, k) => v !== b[i]![k])));\n if (resized || moved) this.version++;\n this.volume = volume;\n this.texels = [...volume.dimensions] as [number, number, number];\n this.lodLevels = shape.density!.mip ? (volume.density.mip?.levels ?? 0) : 0;\n this.stats = { meanNonZero: volume.meanDensity, max: volume.maxDensity, activeVoxels: volume.activeTexels };\n }\n\n dispose(): void {\n // No GPU object: the core's dense source (the frame renderer's) owns the textures.\n }\n}\n\n/** A dense `.wvdb` volume (`wvdbDenseVolume`, `@pmndrs/vdb/tools`) as a handle for `VDBFrameVolume`. */\nexport function vdbDenseTextures(volume: WvdbDenseVolume): VDBThreeDenseSource {\n if (!volume || volume.kind !== \"dense\" || !volume.density) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"vdbDenseTextures: pass a dense volume from wvdbDenseVolume() (@pmndrs/vdb/tools).\");\n }\n return new ThreeDenseSource(volume);\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { VDBVec3 } from "../vdb/types.js";
|
|
2
|
+
/** pmndrs/pathtracer's V3.2 sparse brick atlas (its `BrickAtlas`), built by {@link vdbBrickAtlas}. */
|
|
3
|
+
export interface VDBBrickAtlas {
|
|
4
|
+
/** The dense grid's voxel counts (`[0, resolution)` in index space). */
|
|
5
|
+
resolution: VDBVec3;
|
|
6
|
+
/** Bricks per axis over the grid: `floor((resolution + 8) / 8)` (its `brickDims`). */
|
|
7
|
+
cells: VDBVec3;
|
|
8
|
+
/** Atlas size in bricks. */
|
|
9
|
+
bricks: VDBVec3;
|
|
10
|
+
/** Atlas size in texels (`bricks * 9`). */
|
|
11
|
+
dims: VDBVec3;
|
|
12
|
+
/** The atlas texels, x fastest; voxels outside the grid (and empty texels) are 0. */
|
|
13
|
+
data: Float32Array;
|
|
14
|
+
/** One texel per brick of `cells`, x fastest: `0xffffffff` (empty) or `bx | by << 10 | bz << 20` (atlas brick). */
|
|
15
|
+
indirection: Uint32Array;
|
|
16
|
+
/** Occupied bricks. */
|
|
17
|
+
occupied: number;
|
|
18
|
+
}
|
|
19
|
+
/** Options of {@link vdbBrickAtlas}. */
|
|
20
|
+
export interface VDBBrickAtlasOptions {
|
|
21
|
+
/** The dense grid's voxel counts. Default `indexBBoxMax + 1` (the grid's bbox must lie in `[0, resolution - 1]`). */
|
|
22
|
+
resolution?: VDBVec3;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Builds pmndrs/pathtracer's V3.2 brick atlas and indirection (`volumes.gridLayout: 'atlas'`) from a NanoVDB grid image
|
|
26
|
+
* (P1.12): the arrays its `buildBrickAtlas(resolution, dense)` gives for the dense grid of the same field, without
|
|
27
|
+
* making that dense grid. Values come from the tree (leaf voxels active or not, tiles, the background), 0 outside the
|
|
28
|
+
* index bbox and outside `[0, resolution)` (the P1.1 contract: for a `vdbBuildFromDense` image of its array, the
|
|
29
|
+
* same array). Works on every scalar grid type (Fp values as decoded by the readers).
|
|
30
|
+
*
|
|
31
|
+
* @param image The grid image (little-endian u32 words, `GridData` at word 0).
|
|
32
|
+
* @param options The dense grid's resolution.
|
|
33
|
+
* @throws VDBToolsError `VDB_BAD_OPTION` for a bad resolution, a bbox outside it, or more occupied bricks than its
|
|
34
|
+
* 10-bit atlas coordinates hold.
|
|
35
|
+
*/
|
|
36
|
+
export declare function vdbBrickAtlas(image: Uint32Array, options?: VDBBrickAtlasOptions): VDBBrickAtlas;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1.12, the optional "B" path of the pathtracer integration: a NanoVDB grid to pmndrs/pathtracer's V3.2 sparse
|
|
3
|
+
* brick atlas + indirection (`volumes.gridLayout: 'atlas'`, its `buildBrickAtlas(resolution, dense)` in
|
|
4
|
+
* `packages/pathtracer/src/volume/volume.ts`, MIT, read at main `06488fa`), straight from the tree's leaves and tiles,
|
|
5
|
+
* without a dense copy of the grid. Its kernels then read the atlas as they do today; the `.nvdb` is only the
|
|
6
|
+
* delivery format.
|
|
7
|
+
*
|
|
8
|
+
* The layout is its own (bit for bit on the same field): bricks of 8³ cells, brick `c` holding the voxels
|
|
9
|
+
* `[8c - 1, 8c + 7]` (its trilinear support, `ATLAS_CELL = 9` texels per side), a brick occupied when its majorant is
|
|
10
|
+
* above 0 (`vdbBrickMajorant(image, { align: 'pathtracer' })`, equal to its `brickMajorants`, P1.2), occupied bricks
|
|
11
|
+
* packed in x-fastest cell order into a near-cubic block of `ceil(cbrt(occupied))²` bricks per layer, and an `r32uint`
|
|
12
|
+
* indirection `bx | by << 10 | bz << 20` (`0xffffffff` for an empty brick). The field is the P1.1 contract's: the grid
|
|
13
|
+
* inside its index bbox, 0 outside it and outside `[0, resolution)`.
|
|
14
|
+
*/
|
|
15
|
+
import { VDBToolsError } from "../errors.js";
|
|
16
|
+
import { brickMajorantLayout, vdbBrickMajorant } from "./majorant.js";
|
|
17
|
+
import { forEachTreeRegion, indexBBox, leafVoxels } from "./march.js";
|
|
18
|
+
/** Brick edge in voxels (its `BRICK`). */
|
|
19
|
+
const BRICK = 8;
|
|
20
|
+
/** Atlas texels per brick side (its `ATLAS_CELL`: the brick plus a one-voxel apron on the low side). */
|
|
21
|
+
const CELL = BRICK + 1;
|
|
22
|
+
/** Indirection value of an empty brick (its `ATLAS_EMPTY`). */
|
|
23
|
+
const EMPTY = 0xffffffff;
|
|
24
|
+
/**
|
|
25
|
+
* Builds pmndrs/pathtracer's V3.2 brick atlas and indirection (`volumes.gridLayout: 'atlas'`) from a NanoVDB grid image
|
|
26
|
+
* (P1.12): the arrays its `buildBrickAtlas(resolution, dense)` gives for the dense grid of the same field, without
|
|
27
|
+
* making that dense grid. Values come from the tree (leaf voxels active or not, tiles, the background), 0 outside the
|
|
28
|
+
* index bbox and outside `[0, resolution)` (the P1.1 contract: for a `vdbBuildFromDense` image of its array, the
|
|
29
|
+
* same array). Works on every scalar grid type (Fp values as decoded by the readers).
|
|
30
|
+
*
|
|
31
|
+
* @param image The grid image (little-endian u32 words, `GridData` at word 0).
|
|
32
|
+
* @param options The dense grid's resolution.
|
|
33
|
+
* @throws VDBToolsError `VDB_BAD_OPTION` for a bad resolution, a bbox outside it, or more occupied bricks than its
|
|
34
|
+
* 10-bit atlas coordinates hold.
|
|
35
|
+
*/
|
|
36
|
+
export function vdbBrickAtlas(image, options = {}) {
|
|
37
|
+
const { min, max } = indexBBox(image);
|
|
38
|
+
const resolution = options.resolution;
|
|
39
|
+
let layout;
|
|
40
|
+
try {
|
|
41
|
+
layout = brickMajorantLayout(min, max, { align: "pathtracer", ...(resolution !== undefined ? { resolution } : {}) });
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e instanceof VDBToolsError)
|
|
45
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `vdbBrickAtlas: ${e.message.replace(/^.*?vdbBrickMajorant: /, "")}`);
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
const n = layout.resolution;
|
|
49
|
+
const cells = layout.dims;
|
|
50
|
+
const total = cells[0] * cells[1] * cells[2];
|
|
51
|
+
// A brick is occupied when its majorant (over the 9³ voxels its lookups read) is above 0: its `brickMajorants(..) > 0`.
|
|
52
|
+
const mj = vdbBrickMajorant(image, { align: "pathtracer", resolution: n }).data;
|
|
53
|
+
let occupied = 0;
|
|
54
|
+
for (let i = 0; i < total; i++)
|
|
55
|
+
if (mj[i] > 0)
|
|
56
|
+
occupied++;
|
|
57
|
+
const ax = Math.max(1, Math.ceil(Math.cbrt(occupied)));
|
|
58
|
+
const ay = ax;
|
|
59
|
+
const az = Math.max(1, Math.ceil(occupied / (ax * ay)));
|
|
60
|
+
if (ax > 1023 || az > 1023)
|
|
61
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `vdbBrickAtlas: ${occupied} bricks do not fit the atlas's 10-bit brick coordinates.`);
|
|
62
|
+
const dims = [ax * CELL, ay * CELL, az * CELL];
|
|
63
|
+
const data = new Float32Array(dims[0] * dims[1] * dims[2]);
|
|
64
|
+
const indirection = new Uint32Array(total).fill(EMPTY);
|
|
65
|
+
/** Atlas texel origin of each cell's brick (-1: empty). */
|
|
66
|
+
const slot = new Int32Array(total).fill(-1);
|
|
67
|
+
let k = 0;
|
|
68
|
+
for (let i = 0; i < total; i++) {
|
|
69
|
+
if (!(mj[i] > 0))
|
|
70
|
+
continue;
|
|
71
|
+
const bx = k % ax;
|
|
72
|
+
const by = Math.floor(k / ax) % ay;
|
|
73
|
+
const bz = Math.floor(k / (ax * ay));
|
|
74
|
+
k++;
|
|
75
|
+
indirection[i] = (bx | (by << 10) | (bz << 20)) >>> 0;
|
|
76
|
+
slot[i] = bx * CELL + dims[0] * (by * CELL + dims[1] * (bz * CELL));
|
|
77
|
+
}
|
|
78
|
+
// Where the field comes from the tree: the bbox inside [0, n).
|
|
79
|
+
const domLo = [Math.max(min[0], 0), Math.max(min[1], 0), Math.max(min[2], 0)];
|
|
80
|
+
const domHi = [Math.min(max[0], n[0] - 1), Math.min(max[1], n[1] - 1), Math.min(max[2], n[2] - 1)];
|
|
81
|
+
if (domLo.some((v, a) => v > domHi[a]))
|
|
82
|
+
return { resolution: [...n], cells: [...cells], bricks: [ax, ay, az], dims, data, indirection, occupied };
|
|
83
|
+
/** Calls `fill(texel, x, y, z)` for every voxel of the box [a, b] (inclusive, clipped to the domain) in every occupied brick that holds it. */
|
|
84
|
+
const each = (a, b, fill) => {
|
|
85
|
+
const lo = [0, 1, 2].map((q) => Math.max(a[q], domLo[q]));
|
|
86
|
+
const hi = [0, 1, 2].map((q) => Math.min(b[q], domHi[q]));
|
|
87
|
+
if (lo.some((v, q) => v > hi[q]))
|
|
88
|
+
return;
|
|
89
|
+
// Brick c holds [8c - 1, 8c + 7]: the bricks meeting [lo, hi] are ceil((lo - 7) / 8) .. floor((hi + 1) / 8).
|
|
90
|
+
const c0 = lo.map((v, q) => Math.max(0, Math.ceil((v - 7) / BRICK)));
|
|
91
|
+
const c1 = hi.map((v, q) => Math.min(cells[q] - 1, Math.floor((v + 1) / BRICK)));
|
|
92
|
+
for (let cz = c0[2]; cz <= c1[2]; cz++)
|
|
93
|
+
for (let cy = c0[1]; cy <= c1[1]; cy++)
|
|
94
|
+
for (let cx = c0[0]; cx <= c1[0]; cx++) {
|
|
95
|
+
const base = slot[cx + cells[0] * (cy + cells[1] * cz)];
|
|
96
|
+
if (base < 0)
|
|
97
|
+
continue;
|
|
98
|
+
const o = [cx * BRICK - 1, cy * BRICK - 1, cz * BRICK - 1];
|
|
99
|
+
const x0 = Math.max(lo[0], o[0]), x1 = Math.min(hi[0], o[0] + BRICK);
|
|
100
|
+
const y0 = Math.max(lo[1], o[1]), y1 = Math.min(hi[1], o[1] + BRICK);
|
|
101
|
+
const z0 = Math.max(lo[2], o[2]), z1 = Math.min(hi[2], o[2] + BRICK);
|
|
102
|
+
for (let z = z0; z <= z1; z++)
|
|
103
|
+
for (let y = y0; y <= y1; y++) {
|
|
104
|
+
const row = base + (x0 - o[0]) + dims[0] * (y - o[1] + dims[1] * (z - o[2]));
|
|
105
|
+
for (let x = x0; x <= x1; x++)
|
|
106
|
+
fill(row + (x - x0), x, y, z);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
// Space under no root tile reads the background: fill it first (a no-op for background 0), then the tree overwrites.
|
|
111
|
+
const regions = [];
|
|
112
|
+
const { background } = forEachTreeRegion(image, (r) => {
|
|
113
|
+
regions.push({ lo: r.origin, hi: [r.origin[0] + r.dim - 1, r.origin[1] + r.dim - 1, r.origin[2] + r.dim - 1], level: r.level, leaf: r.leaf, value: r.value });
|
|
114
|
+
});
|
|
115
|
+
if (background !== 0)
|
|
116
|
+
each(domLo, domHi, (t) => (data[t] = background));
|
|
117
|
+
for (const r of regions) {
|
|
118
|
+
if (r.level > 0) {
|
|
119
|
+
const v = r.value;
|
|
120
|
+
each(r.lo, r.hi, (t) => (data[t] = v));
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const { values } = leafVoxels(image, r.leaf);
|
|
124
|
+
const [ox, oy, oz] = r.lo;
|
|
125
|
+
each(r.lo, r.hi, (t, x, y, z) => (data[t] = values[((x - ox) << 6) | ((y - oy) << 3) | (z - oz)]));
|
|
126
|
+
}
|
|
127
|
+
return { resolution: [...n], cells: [...cells], bricks: [ax, ay, az], dims, data, indirection, occupied };
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=brick-atlas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brick-atlas.js","sourceRoot":"","sources":["../../../src/tools/cpu/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M,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAE,CAAC,CAAC,CAAC;IACtG,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;AAC5G,CAAC","sourcesContent":["/**\n * P1.12, the optional \"B\" path of the pathtracer integration: a NanoVDB grid to pmndrs/pathtracer's V3.2 sparse\n * brick atlas + indirection (`volumes.gridLayout: 'atlas'`, its `buildBrickAtlas(resolution, dense)` in\n * `packages/pathtracer/src/volume/volume.ts`, MIT, read at main `06488fa`), straight from the tree's leaves and tiles,\n * without a dense copy of the grid. Its kernels then read the atlas as they do today; the `.nvdb` is only the\n * delivery format.\n *\n * The layout is its own (bit for bit on the same field): bricks of 8³ cells, brick `c` holding the voxels\n * `[8c - 1, 8c + 7]` (its trilinear support, `ATLAS_CELL = 9` texels per side), a brick occupied when its majorant is\n * above 0 (`vdbBrickMajorant(image, { align: 'pathtracer' })`, equal to its `brickMajorants`, P1.2), occupied bricks\n * packed in x-fastest cell order into a near-cubic block of `ceil(cbrt(occupied))²` bricks per layer, and an `r32uint`\n * indirection `bx | by << 10 | bz << 20` (`0xffffffff` for an empty brick). The field is the P1.1 contract's: the grid\n * inside its index bbox, 0 outside it and outside `[0, resolution)`.\n */\nimport { VDBToolsError } from \"../errors.js\";\nimport type { VDBVec3 } from \"../vdb/types.js\";\nimport { brickMajorantLayout, vdbBrickMajorant } from \"./majorant.js\";\nimport { forEachTreeRegion, indexBBox, leafVoxels, type Vec3 } from \"./march.js\";\n\n/** Brick edge in voxels (its `BRICK`). */\nconst BRICK = 8;\n/** Atlas texels per brick side (its `ATLAS_CELL`: the brick plus a one-voxel apron on the low side). */\nconst CELL = BRICK + 1;\n/** Indirection value of an empty brick (its `ATLAS_EMPTY`). */\nconst EMPTY = 0xffffffff;\n\n/** pmndrs/pathtracer's V3.2 sparse brick atlas (its `BrickAtlas`), built by {@link vdbBrickAtlas}. */\nexport interface VDBBrickAtlas {\n /** The dense grid's voxel counts (`[0, resolution)` in index space). */\n resolution: VDBVec3;\n /** Bricks per axis over the grid: `floor((resolution + 8) / 8)` (its `brickDims`). */\n cells: VDBVec3;\n /** Atlas size in bricks. */\n bricks: VDBVec3;\n /** Atlas size in texels (`bricks * 9`). */\n dims: VDBVec3;\n /** The atlas texels, x fastest; voxels outside the grid (and empty texels) are 0. */\n data: Float32Array;\n /** One texel per brick of `cells`, x fastest: `0xffffffff` (empty) or `bx | by << 10 | bz << 20` (atlas brick). */\n indirection: Uint32Array;\n /** Occupied bricks. */\n occupied: number;\n}\n\n/** Options of {@link vdbBrickAtlas}. */\nexport interface VDBBrickAtlasOptions {\n /** The dense grid's voxel counts. Default `indexBBoxMax + 1` (the grid's bbox must lie in `[0, resolution - 1]`). */\n resolution?: VDBVec3;\n}\n\n/**\n * Builds pmndrs/pathtracer's V3.2 brick atlas and indirection (`volumes.gridLayout: 'atlas'`) from a NanoVDB grid image\n * (P1.12): the arrays its `buildBrickAtlas(resolution, dense)` gives for the dense grid of the same field, without\n * making that dense grid. Values come from the tree (leaf voxels active or not, tiles, the background), 0 outside the\n * index bbox and outside `[0, resolution)` (the P1.1 contract: for a `vdbBuildFromDense` image of its array, the\n * same array). Works on every scalar grid type (Fp values as decoded by the readers).\n *\n * @param image The grid image (little-endian u32 words, `GridData` at word 0).\n * @param options The dense grid's resolution.\n * @throws VDBToolsError `VDB_BAD_OPTION` for a bad resolution, a bbox outside it, or more occupied bricks than its\n * 10-bit atlas coordinates hold.\n */\nexport function vdbBrickAtlas(image: Uint32Array, options: VDBBrickAtlasOptions = {}): VDBBrickAtlas {\n const { min, max } = indexBBox(image);\n const resolution = options.resolution;\n let layout: ReturnType<typeof brickMajorantLayout>;\n try {\n layout = brickMajorantLayout(min, max, { align: \"pathtracer\", ...(resolution !== undefined ? { resolution } : {}) });\n } catch (e) {\n if (e instanceof VDBToolsError) throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbBrickAtlas: ${e.message.replace(/^.*?vdbBrickMajorant: /, \"\")}`);\n throw e;\n }\n const n = layout.resolution;\n const cells = layout.dims;\n const total = cells[0] * cells[1] * cells[2];\n // A brick is occupied when its majorant (over the 9³ voxels its lookups read) is above 0: its `brickMajorants(..) > 0`.\n const mj = vdbBrickMajorant(image, { align: \"pathtracer\", resolution: n }).data;\n let occupied = 0;\n for (let i = 0; i < total; i++) if (mj[i]! > 0) occupied++;\n const ax = Math.max(1, Math.ceil(Math.cbrt(occupied)));\n const ay = ax;\n const az = Math.max(1, Math.ceil(occupied / (ax * ay)));\n if (ax > 1023 || az > 1023) throw new VDBToolsError(\"VDB_BAD_OPTION\", `vdbBrickAtlas: ${occupied} bricks do not fit the atlas's 10-bit brick coordinates.`);\n const dims: Vec3 = [ax * CELL, ay * CELL, az * CELL];\n const data = new Float32Array(dims[0] * dims[1] * dims[2]);\n const indirection = new Uint32Array(total).fill(EMPTY);\n /** Atlas texel origin of each cell's brick (-1: empty). */\n const slot = new Int32Array(total).fill(-1);\n let k = 0;\n for (let i = 0; i < total; i++) {\n if (!(mj[i]! > 0)) continue;\n const bx = k % ax;\n const by = Math.floor(k / ax) % ay;\n const bz = Math.floor(k / (ax * ay));\n k++;\n indirection[i] = (bx | (by << 10) | (bz << 20)) >>> 0;\n slot[i] = bx * CELL + dims[0] * (by * CELL + dims[1] * (bz * CELL));\n }\n\n // Where the field comes from the tree: the bbox inside [0, n).\n const domLo: Vec3 = [Math.max(min[0], 0), Math.max(min[1], 0), Math.max(min[2], 0)];\n const domHi: Vec3 = [Math.min(max[0], n[0] - 1), Math.min(max[1], n[1] - 1), Math.min(max[2], n[2] - 1)];\n if (domLo.some((v, a) => v > domHi[a]!)) return { resolution: [...n], cells: [...cells], bricks: [ax, ay, az], dims, data, indirection, occupied };\n /** Calls `fill(texel, x, y, z)` for every voxel of the box [a, b] (inclusive, clipped to the domain) in every occupied brick that holds it. */\n const each = (a: Vec3, b: Vec3, fill: (texel: number, x: number, y: number, z: number) => void) => {\n const lo = [0, 1, 2].map((q) => Math.max(a[q]!, domLo[q]!));\n const hi = [0, 1, 2].map((q) => Math.min(b[q]!, domHi[q]!));\n if (lo.some((v, q) => v > hi[q]!)) return;\n // Brick c holds [8c - 1, 8c + 7]: the bricks meeting [lo, hi] are ceil((lo - 7) / 8) .. floor((hi + 1) / 8).\n const c0 = lo.map((v, q) => Math.max(0, Math.ceil((v - 7) / BRICK)));\n const c1 = hi.map((v, q) => Math.min(cells[q]! - 1, Math.floor((v + 1) / BRICK)));\n for (let cz = c0[2]!; cz <= c1[2]!; cz++)\n for (let cy = c0[1]!; cy <= c1[1]!; cy++)\n for (let cx = c0[0]!; cx <= c1[0]!; cx++) {\n const base = slot[cx + cells[0] * (cy + cells[1] * cz)]!;\n if (base < 0) continue;\n const o = [cx * BRICK - 1, cy * BRICK - 1, cz * BRICK - 1];\n const x0 = Math.max(lo[0]!, o[0]!), x1 = Math.min(hi[0]!, o[0]! + BRICK);\n const y0 = Math.max(lo[1]!, o[1]!), y1 = Math.min(hi[1]!, o[1]! + BRICK);\n const z0 = Math.max(lo[2]!, o[2]!), z1 = Math.min(hi[2]!, o[2]! + BRICK);\n for (let z = z0; z <= z1; z++)\n for (let y = y0; y <= y1; y++) {\n const row = base + (x0 - o[0]!) + dims[0] * (y - o[1]! + dims[1] * (z - o[2]!));\n for (let x = x0; x <= x1; x++) fill(row + (x - x0), x, y, z);\n }\n }\n };\n // Space under no root tile reads the background: fill it first (a no-op for background 0), then the tree overwrites.\n const regions: { lo: Vec3; hi: Vec3; level: number; leaf: number; value: number }[] = [];\n const { background } = forEachTreeRegion(image, (r) => {\n regions.push({ lo: r.origin, hi: [r.origin[0] + r.dim - 1, r.origin[1] + r.dim - 1, r.origin[2] + r.dim - 1], level: r.level, leaf: r.leaf, value: r.value });\n });\n if (background !== 0) each(domLo, domHi, (t) => (data[t] = background));\n for (const r of regions) {\n if (r.level > 0) {\n const v = r.value;\n each(r.lo, r.hi, (t) => (data[t] = v));\n continue;\n }\n const { values } = leafVoxels(image, r.leaf);\n const [ox, oy, oz] = r.lo;\n each(r.lo, r.hi, (t, x, y, z) => (data[t] = values[((x - ox) << 6) | ((y - oy) << 3) | (z - oz)]!));\n }\n return { resolution: [...n], cells: [...cells], bricks: [ax, ay, az], dims, data, indirection, occupied };\n}\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** Fixed-point scale of the GPU fast path's 64-bit sum (2^20). */
|
|
2
|
+
export declare const GRID_STATS_SUM_SCALE = 1048576;
|
|
3
|
+
/** Index bbox, inclusive on both ends. */
|
|
4
|
+
export interface IndexBBox {
|
|
5
|
+
min: readonly [number, number, number];
|
|
6
|
+
max: readonly [number, number, number];
|
|
7
|
+
}
|
|
8
|
+
/** Per-axis voxel count of an inclusive-max index bbox (`max - min + 1`). */
|
|
9
|
+
export declare function bboxSize(bbox: IndexBBox): [number, number, number];
|
|
10
|
+
/**
|
|
11
|
+
* `decodeToAtlas` output resolution: each axis of the index bbox clamped to
|
|
12
|
+
* `maxDim` (a literal per-axis clamp, not a proportional downscale; v1).
|
|
13
|
+
*/
|
|
14
|
+
export declare function atlasDims(bbox: IndexBBox, maxDim: number): [number, number, number];
|
|
15
|
+
/** The root node's stored min/max statistics (f32; binary16 decoded for Half), meaningful when the grid has stats. */
|
|
16
|
+
export declare function rootStats(gridWords: Uint32Array): {
|
|
17
|
+
min: number;
|
|
18
|
+
max: number;
|
|
19
|
+
};
|
|
20
|
+
/** Options of {@link vdbGridStatsCpu}. */
|
|
21
|
+
export interface VDBGridStatsCpuOptions {
|
|
22
|
+
/** Histogram bins (default 256). */
|
|
23
|
+
histogramBins?: number;
|
|
24
|
+
}
|
|
25
|
+
/** Result of {@link vdbGridStatsCpu}, the twin of the GPU `gridStats` result. */
|
|
26
|
+
export interface VDBGridStatsCpuResult {
|
|
27
|
+
/** Smallest active value. */
|
|
28
|
+
min: number;
|
|
29
|
+
/** Largest active value. */
|
|
30
|
+
max: number;
|
|
31
|
+
/** Mean of the active values. */
|
|
32
|
+
mean: number;
|
|
33
|
+
/** Counts of active voxels per bin over {@link range}. */
|
|
34
|
+
histogram: Uint32Array;
|
|
35
|
+
/** Number of active voxels in the index bbox. */
|
|
36
|
+
activeVoxelCount: number;
|
|
37
|
+
/** The path the GPU takes for this grid: `true` when the root min is ≥ 0 (atomics). */
|
|
38
|
+
usedAtomicFastPath: boolean;
|
|
39
|
+
/** The histogram range: the root min/max statistics. */
|
|
40
|
+
range: {
|
|
41
|
+
min: number;
|
|
42
|
+
max: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Twin of `gridStats`: min, max, mean and a histogram over the ACTIVE voxels of
|
|
47
|
+
* the dense index bbox, read as the GPU reads them (`vdbIsActive`,
|
|
48
|
+
* `vdbReadValue`). The histogram spans the root statistics `[rootMin,
|
|
49
|
+
* rootMax]`.
|
|
50
|
+
*
|
|
51
|
+
* Both GPU paths are reproduced: the atomics path (root min ≥ 0) normalizes in
|
|
52
|
+
* f32 and sums `u32(norm * 2^20)` in a 64-bit integer; the dump path (root min
|
|
53
|
+
* < 0) reduces f32 values in f64 on the CPU. The f32 normalization divides, so
|
|
54
|
+
* a GPU with an inexact division may put a voxel in the neighbouring bin or
|
|
55
|
+
* shift the mean by a fixed-point step.
|
|
56
|
+
*
|
|
57
|
+
* @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).
|
|
58
|
+
* @param options Histogram bin count.
|
|
59
|
+
*/
|
|
60
|
+
export declare function vdbGridStatsCpu(gridWords: Uint32Array, options?: VDBGridStatsCpuOptions): VDBGridStatsCpuResult;
|
|
61
|
+
/** How an atlas samples the grid: the nearest voxel or trilinear interpolation. */
|
|
62
|
+
export type VDBAtlasFilter = "nearest" | "trilinear";
|
|
63
|
+
/** Texel format of a decoded atlas: 8-bit unsigned or 32-bit float. */
|
|
64
|
+
export type VDBAtlasFormat = "uint8" | "float32";
|
|
65
|
+
export interface AtlasFromRawOptions {
|
|
66
|
+
format: VDBAtlasFormat;
|
|
67
|
+
normalize: boolean;
|
|
68
|
+
range: {
|
|
69
|
+
min: number;
|
|
70
|
+
max: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Post-readback step of `decodeToAtlas` (v1, in f64): `uint8` maps `[min,
|
|
75
|
+
* max]` to `[0, 255]` with `Math.round` (or clamps the raw value when not
|
|
76
|
+
* normalizing); `float32` maps to `[0, 1]` or returns `raw` itself.
|
|
77
|
+
*/
|
|
78
|
+
export declare function atlasFromRaw(raw: Float32Array, o: AtlasFromRawOptions): Uint8Array | Float32Array;
|
|
79
|
+
/** Options of {@link vdbDecodeToAtlasCpu}. */
|
|
80
|
+
export interface VDBDecodeToAtlasCpuOptions {
|
|
81
|
+
/** Longest atlas side in texels (default 256). */
|
|
82
|
+
maxDim?: number;
|
|
83
|
+
/** Sampling filter (default `'trilinear'`). */
|
|
84
|
+
filter?: VDBAtlasFilter;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Twin of the `decodeToAtlas` pass before normalization: one f32 per output
|
|
88
|
+
* voxel (x fastest), sampled at index position `min + (i + 0.5) * size / dims
|
|
89
|
+
* - 0.5` (cell `i` of `dims` over `[min, max]`, `size = max - min + 1`; voxel
|
|
90
|
+
* centres at full resolution, K2.6) with `vdbReadValue(floor(p + 0.5))` (`'nearest'`) or
|
|
91
|
+
* the vendored trilinear (`'trilinear'`, the default). Feed the result to
|
|
92
|
+
* {@link atlasFromRaw} for the formatted atlas.
|
|
93
|
+
*
|
|
94
|
+
* @param gridWords The grid image (little-endian u32 words, `GridData` at word 0).
|
|
95
|
+
* @param options Longest atlas side and filter.
|
|
96
|
+
*/
|
|
97
|
+
export declare function vdbDecodeToAtlasCpu(gridWords: Uint32Array, options?: VDBDecodeToAtlasCpuOptions): {
|
|
98
|
+
raw: Float32Array;
|
|
99
|
+
dims: [number, number, number];
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Returns a copy of a Float or Half grid image with `fn` applied to every leaf
|
|
103
|
+
* voxel value inside the index bbox (active or inactive), rounded to f32 (and,
|
|
104
|
+
* in a Half grid, then to the nearest binary16 as `vdbFloatToHalf` does; K7.H1). Tile,
|
|
105
|
+
* background and out-of-bbox leaf values are left alone, exactly as v1's GPU
|
|
106
|
+
* `valueTransform` did (it visited the dense bbox and rewrote level-0
|
|
107
|
+
* addresses only).
|
|
108
|
+
*
|
|
109
|
+
* The image's statistics (root/node min, max, average, deviation) are NOT
|
|
110
|
+
* recomputed: they describe the source values. Tools that trust them
|
|
111
|
+
* (`gridStats`' range, `vdbNodeMax` skipping) see stale bounds; rebuild the
|
|
112
|
+
* grid (e.g. `vdbBuildFromDense`) when they matter.
|
|
113
|
+
*
|
|
114
|
+
* Float and Half only: quantized (Fp*) leaves would need re-encoding.
|
|
115
|
+
*/
|
|
116
|
+
export declare function transformLeafValues(gridWords: Uint32Array, fn: (value: number) => number): Uint32Array;
|