@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,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* leaf-codec.ts — the leaf value-table encoder abstraction.
|
|
3
|
+
*
|
|
4
|
+
* The leaf is the only block whose *value representation* varies by grid type:
|
|
5
|
+
* FLOAT stores 512 plain f32s; Fp8/FpN store a per-leaf (min, quantum) pair plus
|
|
6
|
+
* a packed bit-stream of quantized codes. Everything else about a grid image
|
|
7
|
+
* (topology, masks, internal-node tables, stats, bbox, GridData) is identical
|
|
8
|
+
* across those types — the internal-node/root tiles and background stay plain
|
|
9
|
+
* f32 even for quantized grids (verified against native fp8/fpn fixtures). So the
|
|
10
|
+
* serializer is parameterised over a {@link VDBLeafCodec}: `serialize.ts` lays out
|
|
11
|
+
* the common blocks and hands each leaf to the codec, which owns the full leaf
|
|
12
|
+
* write (bbox, flags, value mask, value table and per-leaf stats).
|
|
13
|
+
*
|
|
14
|
+
* Three codecs ship:
|
|
15
|
+
* - {@link VDB_FLOAT_LEAF_CODEC} — 512 raw f32 values + f32 stats.
|
|
16
|
+
* - {@link VDB_FP4_LEAF_CODEC} / {@link VDB_FP8_LEAF_CODEC} / {@link VDB_FP16_LEAF_CODEC} — fixed 4/8/16-bit
|
|
17
|
+
* quantization (`LeafData<Fp4|Fp8|Fp16>`).
|
|
18
|
+
* - {@link vdbMakeFpNLeafCodec} — variable bit-width (`LeafData<FpN>`); a
|
|
19
|
+
* per-leaf oracle picks the smallest of 1/2/4/8/16 bits meeting a tolerance.
|
|
20
|
+
* - {@link VDB_HALF_LEAF_CODEC} — 512 raw IEEE binary16 values
|
|
21
|
+
* (`LeafData<Half>`, K7.H); tiles, background and min/max are binary16 too.
|
|
22
|
+
*
|
|
23
|
+
* ## Encode authority
|
|
24
|
+
*
|
|
25
|
+
* The quantization mirrors `nanovdb::tools::CreateNanoGrid` (NanoVDB.h
|
|
26
|
+
* `LeafFnBase`/`LeafData<Fp8|FpN>` + CreateNanoGrid.h `processLeafs`) and must
|
|
27
|
+
* satisfy the repo's proven decoders (`read-value.ts` `leafFp*ReadFloat` and
|
|
28
|
+
* `pnanovdb.wgsl`). Per-leaf `mMinimum`/`mQuantum` = min / (max-min)/((1<<bits)-1)
|
|
29
|
+
* over ALL 512 values (active and inactive). A code is
|
|
30
|
+
* `floor(encode*(v-min) + 0.5)` — round-to-nearest, matching native's
|
|
31
|
+
* dithering-off `DitherLUT` (constant 0.5). Codes are packed LSB-first, value `n`
|
|
32
|
+
* at global bit `n*bits`, identical to the reader's word/shift addressing.
|
|
33
|
+
*/
|
|
34
|
+
import { VDBToolsError } from "../errors.js";
|
|
35
|
+
import { FLOAT_LAYOUT, VEC3F_LAYOUT, FP4_LAYOUT, FP8_LAYOUT, FP16_LAYOUT, FP_LEAF_HEADER_SIZE, FPN_LAYOUT, HALF_LAYOUT, LEAF_FLAG_HAS_BBOX, LEAF_OFF_BBOX_DIF_AND_FLAGS, LEAF_OFF_BBOX_MIN, LEAF_OFF_FP_CODES, LEAF_OFF_FP_MINIMUM, LEAF_OFF_FP_QUANTUM, LEAF_OFF_FP_STAT_AVG, LEAF_OFF_FP_STAT_DEV, LEAF_OFF_FP_STAT_MAX, LEAF_OFF_FP_STAT_MIN, LEAF_TABLE_COUNT, NODE_FLAG_STATS, } from "./bytes.js";
|
|
36
|
+
import { vdbFloatToHalf, vdbRoundToHalf } from "./half.js";
|
|
37
|
+
import { STATS_FLOAT_MAX, STATS_HALF_MAX, Vec3StatsAccumulator } from "./stats.js";
|
|
38
|
+
/** A scalar codec's constant: tiles and backgrounds of scalar grids are numbers. */
|
|
39
|
+
function scalar(value) {
|
|
40
|
+
if (typeof value !== "number")
|
|
41
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `leaf codec: expected a scalar value, got [${value.join(", ")}]`);
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Shared leaf-header write (bbox + dif/flags + value mask) — common to all codecs
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
function clampByte(v) {
|
|
48
|
+
return v < 0 ? 0 : v > 255 ? 255 : v;
|
|
49
|
+
}
|
|
50
|
+
/** Writes bbox_min, bbox_dif_and_flags (with `flagsByte` in the high byte) and
|
|
51
|
+
* the 512-bit value mask. Returns nothing; the codec then writes its table. */
|
|
52
|
+
function writeLeafHeader(w, leafOff, leaf, flagsByte) {
|
|
53
|
+
const s = leaf.stats;
|
|
54
|
+
const bmin = s.isEmpty ? leaf.origin : s.bboxMin;
|
|
55
|
+
const bmax = s.isEmpty ? leaf.origin : s.bboxMax;
|
|
56
|
+
w.setI32(leafOff + LEAF_OFF_BBOX_MIN, bmin[0]);
|
|
57
|
+
w.setI32(leafOff + LEAF_OFF_BBOX_MIN + 4, bmin[1]);
|
|
58
|
+
w.setI32(leafOff + LEAF_OFF_BBOX_MIN + 8, bmin[2]);
|
|
59
|
+
const difX = clampByte(bmax[0] - bmin[0]);
|
|
60
|
+
const difY = clampByte(bmax[1] - bmin[1]);
|
|
61
|
+
const difZ = clampByte(bmax[2] - bmin[2]);
|
|
62
|
+
w.setU32(leafOff + LEAF_OFF_BBOX_DIF_AND_FLAGS, (difX | (difY << 8) | (difZ << 16) | (flagsByte << 24)) >>> 0);
|
|
63
|
+
w.setMaskWords(leafOff + 16, leaf.valueMask);
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// FLOAT
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/** FLOAT leaf codec: 512 raw f32 values, f32 stats. */
|
|
69
|
+
export const VDB_FLOAT_LEAF_CODEC = {
|
|
70
|
+
layout: FLOAT_LAYOUT,
|
|
71
|
+
planLeaf() {
|
|
72
|
+
return { byteSize: FLOAT_LAYOUT.leafSize };
|
|
73
|
+
},
|
|
74
|
+
encodeLeaf(w, leafOff, leaf) {
|
|
75
|
+
writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);
|
|
76
|
+
const L = FLOAT_LAYOUT;
|
|
77
|
+
const values = leaf.values;
|
|
78
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++) {
|
|
79
|
+
w.setF32(leafOff + L.leafOffTable + n * 4, values[n]);
|
|
80
|
+
}
|
|
81
|
+
// Stats block. For an all-inactive leaf the accumulator is empty; write
|
|
82
|
+
// zeros, matching "no active values".
|
|
83
|
+
const s = leaf.stats;
|
|
84
|
+
w.setF32(leafOff + L.leafOffMin, s.storedMin(STATS_FLOAT_MAX));
|
|
85
|
+
w.setF32(leafOff + L.leafOffMax, s.storedMax(STATS_FLOAT_MAX));
|
|
86
|
+
w.setF32(leafOff + L.leafOffAve, s.average);
|
|
87
|
+
w.setF32(leafOff + L.leafOffStdDev, s.stdDev);
|
|
88
|
+
},
|
|
89
|
+
writeConstant(w, off, value) {
|
|
90
|
+
w.setF32(off, scalar(value));
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Half (K7.H)
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
/**
|
|
97
|
+
* Half leaf codec (`LeafData<Half>`, NanoVDB 13.2): 512 raw IEEE binary16
|
|
98
|
+
* values, binary16 min/max and f32 ave/stddev. Values convert with
|
|
99
|
+
* {@link vdbFloatToHalf} (NanoVDB `math::FloatToHalf`, round to nearest even,
|
|
100
|
+
* overflow to infinity), as `tools::createNanoGrid<FloatGrid, Half>` does.
|
|
101
|
+
* `roundValue` makes the build's statistics describe the stored halves.
|
|
102
|
+
*/
|
|
103
|
+
export const VDB_HALF_LEAF_CODEC = {
|
|
104
|
+
layout: HALF_LAYOUT,
|
|
105
|
+
roundValue: vdbRoundToHalf,
|
|
106
|
+
planLeaf() {
|
|
107
|
+
return { byteSize: HALF_LAYOUT.leafSize };
|
|
108
|
+
},
|
|
109
|
+
encodeLeaf(w, leafOff, leaf) {
|
|
110
|
+
writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);
|
|
111
|
+
const L = HALF_LAYOUT;
|
|
112
|
+
const values = leaf.values;
|
|
113
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++)
|
|
114
|
+
w.setU16(leafOff + L.leafOffTable + n * 2, vdbFloatToHalf(values[n]));
|
|
115
|
+
const s = leaf.stats;
|
|
116
|
+
w.setU16(leafOff + L.leafOffMin, vdbFloatToHalf(s.storedMin(STATS_HALF_MAX)));
|
|
117
|
+
w.setU16(leafOff + L.leafOffMax, vdbFloatToHalf(s.storedMax(STATS_HALF_MAX)));
|
|
118
|
+
w.setF32(leafOff + L.leafOffAve, s.average);
|
|
119
|
+
w.setF32(leafOff + L.leafOffStdDev, s.stdDev);
|
|
120
|
+
},
|
|
121
|
+
writeConstant(w, off, value) {
|
|
122
|
+
w.setU16(off, vdbFloatToHalf(scalar(value)));
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
// Vec3f
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
/** Writes a Vec3f (3 x f32) at `off`. */
|
|
129
|
+
function writeVec3(w, off, v) {
|
|
130
|
+
w.setF32(off, v[0]);
|
|
131
|
+
w.setF32(off + 4, v[1]);
|
|
132
|
+
w.setF32(off + 8, v[2]);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Vec3f leaf codec (K4.2): 512 x 3 f32 values (xyz interleaved in
|
|
136
|
+
* `leaf.values`), Vec3f min/max and f32 ave/stddev of the squared lengths
|
|
137
|
+
* (NanoVDB `Stats<Vec3f, 1>`, see {@link Vec3StatsAccumulator}).
|
|
138
|
+
*/
|
|
139
|
+
export const VDB_VEC3F_LEAF_CODEC = {
|
|
140
|
+
layout: VEC3F_LAYOUT,
|
|
141
|
+
components: 3,
|
|
142
|
+
planLeaf() {
|
|
143
|
+
return { byteSize: VEC3F_LAYOUT.leafSize };
|
|
144
|
+
},
|
|
145
|
+
encodeLeaf(w, leafOff, leaf) {
|
|
146
|
+
writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);
|
|
147
|
+
const L = VEC3F_LAYOUT;
|
|
148
|
+
const values = leaf.values;
|
|
149
|
+
for (let i = 0; i < LEAF_TABLE_COUNT * 3; i++)
|
|
150
|
+
w.setF32(leafOff + L.leafOffTable + i * 4, values[i]);
|
|
151
|
+
writeVec3StatsBlock(w, leafOff, L.leafOffMin, L.leafOffMax, L.leafOffAve, L.leafOffStdDev, leaf.stats);
|
|
152
|
+
},
|
|
153
|
+
writeConstant(w, off, value) {
|
|
154
|
+
if (typeof value === "number")
|
|
155
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `Vec3f codec: expected a vector value, got ${value}`);
|
|
156
|
+
writeVec3(w, off, value);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
/** Writes a Vec3f node's stats block: Vec3f min/max (zeros when empty), f32 ave/stddev. */
|
|
160
|
+
export function writeVec3StatsBlock(w, base, offMin, offMax, offAve, offStdDev, stats) {
|
|
161
|
+
const empty = stats.isEmpty || !(stats instanceof Vec3StatsAccumulator);
|
|
162
|
+
writeVec3(w, base + offMin, empty ? [0, 0, 0] : stats.minVec);
|
|
163
|
+
writeVec3(w, base + offMax, empty ? [0, 0, 0] : stats.maxVec);
|
|
164
|
+
w.setF32(base + offAve, stats.average);
|
|
165
|
+
w.setF32(base + offStdDev, stats.stdDev);
|
|
166
|
+
}
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// Quantized (Fp8 / FpN) shared helpers
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
const fround = Math.fround;
|
|
171
|
+
/** Min and max over all 512 leaf values (the affine origin for quantization). */
|
|
172
|
+
function leafMinMax(values) {
|
|
173
|
+
let min = Infinity;
|
|
174
|
+
let max = -Infinity;
|
|
175
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++) {
|
|
176
|
+
const v = values[n];
|
|
177
|
+
if (v < min)
|
|
178
|
+
min = v;
|
|
179
|
+
if (v > max)
|
|
180
|
+
max = v;
|
|
181
|
+
}
|
|
182
|
+
return { min, max };
|
|
183
|
+
}
|
|
184
|
+
/** `floor(encode*(v-min) + 0.5)` in float32, clamped to `[0, mask]`.
|
|
185
|
+
* Matches native `uint(encode*(v-min) + 0.5f)` with dithering disabled. */
|
|
186
|
+
function quantizeF32(v, min, encode, mask) {
|
|
187
|
+
const code = Math.floor(fround(fround(encode * fround(v - min)) + 0.5));
|
|
188
|
+
return code < 0 ? 0 : code > mask ? mask : code;
|
|
189
|
+
}
|
|
190
|
+
/** `floor(encode*(v-min) + 0.5)` in double, clamped — the 16-bit FpN path. */
|
|
191
|
+
function quantizeF64(v, min, encode, mask) {
|
|
192
|
+
const code = Math.floor(encode * (v - min) + 0.5);
|
|
193
|
+
return code < 0 ? 0 : code > mask ? mask : code;
|
|
194
|
+
}
|
|
195
|
+
/** Writes mMinimum, mQuantum (f32) and the four u16 quantized statistics. */
|
|
196
|
+
function writeFpHeaderStats(w, leafOff, min, quantum, stats) {
|
|
197
|
+
w.setF32(leafOff + LEAF_OFF_FP_MINIMUM, min);
|
|
198
|
+
w.setF32(leafOff + LEAF_OFF_FP_QUANTUM, quantum);
|
|
199
|
+
// Quantized active-value statistics (uint16), per LeafFnBase::set{Min,Max,Avg,Dev}.
|
|
200
|
+
const qInv = quantum > 0 ? 1 / quantum : 0;
|
|
201
|
+
const q16 = (x) => {
|
|
202
|
+
const c = Math.floor(x + 0.5);
|
|
203
|
+
return c < 0 ? 0 : c > 0xffff ? 0xffff : c;
|
|
204
|
+
};
|
|
205
|
+
if (stats.isEmpty) {
|
|
206
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_MIN, 0);
|
|
207
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_MAX, 0);
|
|
208
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_AVG, 0);
|
|
209
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_DEV, 0);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_MIN, q16((stats.min - min) * qInv));
|
|
213
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_MAX, q16((stats.max - min) * qInv));
|
|
214
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_AVG, q16((stats.average - min) * qInv));
|
|
215
|
+
w.setU16(leafOff + LEAF_OFF_FP_STAT_DEV, q16(stats.stdDev * qInv));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Packs 512 codes at `bits` bits/value, LSB-first, into the image at
|
|
219
|
+
* `leafOff + 96`. Value `n` occupies global bit range `[n*bits, n*bits+bits)`,
|
|
220
|
+
* exactly what `leafFpReadFloat`'s word/shift addressing reads back.
|
|
221
|
+
*/
|
|
222
|
+
function packCodes(w, leafOff, bits, codeAt) {
|
|
223
|
+
const base = leafOff + LEAF_OFF_FP_CODES;
|
|
224
|
+
const bytes = w.bytes;
|
|
225
|
+
if (bits === 8) {
|
|
226
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++)
|
|
227
|
+
bytes[base + n] = codeAt(n);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (bits === 16) {
|
|
231
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++) {
|
|
232
|
+
const c = codeAt(n);
|
|
233
|
+
bytes[base + 2 * n] = c & 0xff;
|
|
234
|
+
bytes[base + 2 * n + 1] = (c >>> 8) & 0xff;
|
|
235
|
+
}
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
// 1/2/4 bits: sub-byte packing (buffer is zero-initialised, so OR in).
|
|
239
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++) {
|
|
240
|
+
const c = codeAt(n);
|
|
241
|
+
let g = n * bits;
|
|
242
|
+
for (let b = 0; b < bits; b++) {
|
|
243
|
+
if ((c >>> b) & 1)
|
|
244
|
+
bytes[base + (g >>> 3)] |= 1 << (g & 7);
|
|
245
|
+
g++;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// ---------------------------------------------------------------------------
|
|
250
|
+
// Fp4 / Fp8 / Fp16 — fixed bit width
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
function makeFixedLeafCodec(layout, bits) {
|
|
253
|
+
const mask = (1 << bits) - 1;
|
|
254
|
+
return {
|
|
255
|
+
layout,
|
|
256
|
+
planLeaf() {
|
|
257
|
+
return { byteSize: layout.leafSize };
|
|
258
|
+
},
|
|
259
|
+
encodeLeaf(w, leafOff, leaf) {
|
|
260
|
+
writeLeafHeader(w, leafOff, leaf, LEAF_FLAG_HAS_BBOX);
|
|
261
|
+
const { min, max } = leafMinMax(leaf.values);
|
|
262
|
+
const values = leaf.values;
|
|
263
|
+
if (bits === 16) {
|
|
264
|
+
// Same arithmetic as FpN's 16-bit path: double encode, f32-stored quantum.
|
|
265
|
+
const range = max - min;
|
|
266
|
+
writeFpHeaderStats(w, leafOff, min, range > 0 ? range / mask : 0, leaf.stats);
|
|
267
|
+
const encode = range > 0 ? mask / range : 0;
|
|
268
|
+
packCodes(w, leafOff, 16, (n) => quantizeF64(values[n], min, encode, mask));
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const range = fround(max - min);
|
|
272
|
+
const quantum = range > 0 ? fround(range / mask) : 0;
|
|
273
|
+
writeFpHeaderStats(w, leafOff, min, quantum, leaf.stats);
|
|
274
|
+
const encode = range > 0 ? fround(mask / range) : 0;
|
|
275
|
+
packCodes(w, leafOff, bits, (n) => quantizeF32(values[n], min, encode, mask));
|
|
276
|
+
},
|
|
277
|
+
writeConstant(w, off, value) {
|
|
278
|
+
w.setF32(off, scalar(value));
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** Fp4: fixed 4-bit codes (`LeafData<Fp4>`, 16 levels per leaf). */
|
|
283
|
+
export const VDB_FP4_LEAF_CODEC = makeFixedLeafCodec(FP4_LAYOUT, 4);
|
|
284
|
+
/** Fp8: fixed 8-bit codes (`LeafData<Fp8>`). */
|
|
285
|
+
export const VDB_FP8_LEAF_CODEC = makeFixedLeafCodec(FP8_LAYOUT, 8);
|
|
286
|
+
/** Fp16: fixed 16-bit codes (`LeafData<Fp16>`). */
|
|
287
|
+
export const VDB_FP16_LEAF_CODEC = makeFixedLeafCodec(FP16_LAYOUT, 16);
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
// FpN — variable bit-width chosen per leaf by an absolute-difference oracle
|
|
290
|
+
// ---------------------------------------------------------------------------
|
|
291
|
+
/** Native's default absolute tolerance for a FogVolume (`AbsDiff::init`). */
|
|
292
|
+
export const FPN_DEFAULT_TOLERANCE = 0.01;
|
|
293
|
+
const LOG_BITS_MAX = 4; // logBitWidth in [0,4] -> 1,2,4,8,16 bits
|
|
294
|
+
/**
|
|
295
|
+
* Picks the smallest logBitWidth (0..4 -> 1,2,4,8,16 bits) whose float32 encode
|
|
296
|
+
* keeps every one of the 512 values within `tolerance` of its dequantized
|
|
297
|
+
* approximation — the exact loop in `CreateNanoGrid::preProcess<FpN>`.
|
|
298
|
+
*/
|
|
299
|
+
function chooseFpNLogBits(values, min, max, tolerance) {
|
|
300
|
+
const range = fround(max - min);
|
|
301
|
+
if (!(range > 0))
|
|
302
|
+
return 0; // constant leaf -> 1 bit (quantum 0)
|
|
303
|
+
for (let logBits = 0; logBits < LOG_BITS_MAX; logBits++) {
|
|
304
|
+
const mask = (1 << (1 << logBits)) - 1;
|
|
305
|
+
const encode = fround(mask / range);
|
|
306
|
+
const decode = fround(range / mask);
|
|
307
|
+
let ok = true;
|
|
308
|
+
for (let n = 0; n < LEAF_TABLE_COUNT; n++) {
|
|
309
|
+
const exact = values[n];
|
|
310
|
+
const code = quantizeF32(exact, min, encode, mask);
|
|
311
|
+
const approx = fround(fround(code * decode) + min);
|
|
312
|
+
if (fround(Math.abs(exact - approx)) > tolerance) {
|
|
313
|
+
ok = false;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (ok)
|
|
318
|
+
return logBits;
|
|
319
|
+
}
|
|
320
|
+
return LOG_BITS_MAX;
|
|
321
|
+
}
|
|
322
|
+
/** Builds an FpN codec for a given absolute tolerance (default: native's 0.01). */
|
|
323
|
+
export function vdbMakeFpNLeafCodec(tolerance = FPN_DEFAULT_TOLERANCE) {
|
|
324
|
+
return {
|
|
325
|
+
layout: FPN_LAYOUT,
|
|
326
|
+
planLeaf(values) {
|
|
327
|
+
const { min, max } = leafMinMax(values);
|
|
328
|
+
const logBits = chooseFpNLogBits(values, min, max, tolerance);
|
|
329
|
+
const bits = 1 << logBits;
|
|
330
|
+
return { byteSize: FP_LEAF_HEADER_SIZE + bits * 64, logBits };
|
|
331
|
+
},
|
|
332
|
+
encodeLeaf(w, leafOff, leaf, plan) {
|
|
333
|
+
const logBits = plan.logBits;
|
|
334
|
+
const bits = 1 << logBits;
|
|
335
|
+
writeLeafHeader(w, leafOff, leaf, (logBits << 5) | LEAF_FLAG_HAS_BBOX);
|
|
336
|
+
const { min, max } = leafMinMax(leaf.values);
|
|
337
|
+
const range = max - min;
|
|
338
|
+
const mask = (1 << bits) - 1;
|
|
339
|
+
const quantum = range > 0 ? (bits >= 16 ? range / mask : fround(range / mask)) : 0;
|
|
340
|
+
writeFpHeaderStats(w, leafOff, min, quantum, leaf.stats);
|
|
341
|
+
const values = leaf.values;
|
|
342
|
+
if (bits >= 16) {
|
|
343
|
+
const encode = range > 0 ? 65535 / range : 0;
|
|
344
|
+
packCodes(w, leafOff, bits, (n) => quantizeF64(values[n], min, encode, mask));
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
const encode = range > 0 ? fround(mask / fround(range)) : 0;
|
|
348
|
+
packCodes(w, leafOff, bits, (n) => quantizeF32(values[n], min, encode, mask));
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
writeConstant(w, off, value) {
|
|
352
|
+
w.setF32(off, scalar(value));
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=leaf-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaf-codec.js","sourceRoot":"","sources":["../../../src/tools/nanovdb/leaf-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,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AAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC3B,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7C,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACjF,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5D,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAE,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QACD,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK;YACzB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * leaf-codec.ts — the leaf value-table encoder abstraction.\n *\n * The leaf is the only block whose *value representation* varies by grid type:\n * FLOAT stores 512 plain f32s; Fp8/FpN store a per-leaf (min, quantum) pair plus\n * a packed bit-stream of quantized codes. Everything else about a grid image\n * (topology, masks, internal-node tables, stats, bbox, GridData) is identical\n * across those types — the internal-node/root tiles and background stay plain\n * f32 even for quantized grids (verified against native fp8/fpn fixtures). So the\n * serializer is parameterised over a {@link VDBLeafCodec}: `serialize.ts` lays out\n * the common blocks and hands each leaf to the codec, which owns the full leaf\n * write (bbox, flags, value mask, value table and per-leaf stats).\n *\n * Three codecs ship:\n * - {@link VDB_FLOAT_LEAF_CODEC} — 512 raw f32 values + f32 stats.\n * - {@link VDB_FP4_LEAF_CODEC} / {@link VDB_FP8_LEAF_CODEC} / {@link VDB_FP16_LEAF_CODEC} — fixed 4/8/16-bit\n * quantization (`LeafData<Fp4|Fp8|Fp16>`).\n * - {@link vdbMakeFpNLeafCodec} — variable bit-width (`LeafData<FpN>`); a\n * per-leaf oracle picks the smallest of 1/2/4/8/16 bits meeting a tolerance.\n * - {@link VDB_HALF_LEAF_CODEC} — 512 raw IEEE binary16 values\n * (`LeafData<Half>`, K7.H); tiles, background and min/max are binary16 too.\n *\n * ## Encode authority\n *\n * The quantization mirrors `nanovdb::tools::CreateNanoGrid` (NanoVDB.h\n * `LeafFnBase`/`LeafData<Fp8|FpN>` + CreateNanoGrid.h `processLeafs`) and must\n * satisfy the repo's proven decoders (`read-value.ts` `leafFp*ReadFloat` and\n * `pnanovdb.wgsl`). Per-leaf `mMinimum`/`mQuantum` = min / (max-min)/((1<<bits)-1)\n * over ALL 512 values (active and inactive). A code is\n * `floor(encode*(v-min) + 0.5)` — round-to-nearest, matching native's\n * dithering-off `DitherLUT` (constant 0.5). Codes are packed LSB-first, value `n`\n * at global bit `n*bits`, identical to the reader's word/shift addressing.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport {\n FLOAT_LAYOUT,\n VEC3F_LAYOUT,\n FP4_LAYOUT,\n FP8_LAYOUT,\n FP16_LAYOUT,\n FP_LEAF_HEADER_SIZE,\n FPN_LAYOUT,\n type GridTypeLayout,\n HALF_LAYOUT,\n LEAF_FLAG_HAS_BBOX,\n LEAF_OFF_BBOX_DIF_AND_FLAGS,\n LEAF_OFF_BBOX_MIN,\n LEAF_OFF_FP_CODES,\n LEAF_OFF_FP_MINIMUM,\n LEAF_OFF_FP_QUANTUM,\n LEAF_OFF_FP_STAT_AVG,\n LEAF_OFF_FP_STAT_DEV,\n LEAF_OFF_FP_STAT_MAX,\n LEAF_OFF_FP_STAT_MIN,\n LEAF_TABLE_COUNT,\n NODE_FLAG_STATS,\n} from \"./bytes.js\";\nimport type { GridImageWriter } from \"./bytes.js\";\nimport { vdbFloatToHalf, vdbRoundToHalf } from \"./half.js\";\nimport { STATS_FLOAT_MAX, STATS_HALF_MAX, type StatsAccumulator, Vec3StatsAccumulator } from \"./stats.js\";\nimport type { TileValue } from \"./tree.js\";\n\n/** The leaf data a codec needs: origin, all 512 values, mask, active-value stats. */\nexport interface EncodableLeaf {\n origin: [number, number, number];\n values: Float32Array;\n valueMask: Uint32Array;\n stats: StatsAccumulator;\n}\n\n/** Per-leaf encoding plan, computed once by `planLeaf` and reused by `encodeLeaf`. */\nexport interface LeafPlan {\n /** Total byte size of this leaf (header + value table). */\n readonly byteSize: number;\n}\n\n/** Encodes the leaves and constants of one NanoVDB value type (Float, Fp4, Fp8, Fp16, FpN, Vec3f). */\nexport interface VDBLeafCodec {\n /** The grid type's node layout (strides and offsets) that the writer places nodes with. */\n readonly layout: GridTypeLayout;\n /** Scalars per value: 1 (default) or 3 (Vec3f). */\n readonly components?: 1 | 3;\n /**\n * Computes a leaf's encoding plan (its byte size, and for FpN the chosen\n * bit-width) from its 512 values. Called once before layout so variable-size\n * (FpN) leaves can be placed at cumulative offsets.\n *\n * @param values The leaf's 512 values in the leaf's storage order.\n */\n planLeaf(values: Float32Array): LeafPlan;\n /**\n * Writes one leaf's entire block — bbox, `bbox_dif_and_flags`, value mask,\n * value table and per-leaf stats — into the image at absolute byte offset\n * `leafOff`. `plan` is the value returned by {@link planLeaf} for this leaf.\n *\n * @param w The image writer.\n * @param leafOff Absolute byte offset of the leaf in the image.\n * @param leaf The leaf's origin, values, value mask and active-value statistics.\n * @param plan The plan {@link planLeaf} returned for this leaf.\n */\n encodeLeaf(w: GridImageWriter, leafOff: number, leaf: EncodableLeaf, plan: LeafPlan): void;\n /**\n * Writes a single value of the grid's value type: an internal-node tile, the\n * background, or a root/upper/lower min/max statistic of a scalar grid.\n *\n * @param w The image writer.\n * @param off Absolute byte offset to write at.\n * @param value The constant: a number, or `[x, y, z]` for a Vec3f codec.\n */\n writeConstant(w: GridImageWriter, off: number, value: TileValue): void;\n /**\n * Rounds a scalar to what the grid stores (Half: the nearest binary16). When\n * present, `vdbBuildFromLeavesDetailed` passes every leaf value, tile value\n * and the background through it before computing statistics, so min/max/ave\n * describe the stored values (as NanoVDB's GridStats does on a Half grid).\n */\n readonly roundValue?: (value: number) => number;\n}\n\n/** A scalar codec's constant: tiles and backgrounds of scalar grids are numbers. */\nfunction scalar(value: TileValue): number {\n if (typeof value !== \"number\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `leaf codec: expected a scalar value, got [${value.join(\", \")}]`);\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Shared leaf-header write (bbox + dif/flags + value mask) — common to all codecs\n// ---------------------------------------------------------------------------\n\nfunction clampByte(v: number): number {\n return v < 0 ? 0 : v > 255 ? 255 : v;\n}\n\n/** Writes bbox_min, bbox_dif_and_flags (with `flagsByte` in the high byte) and\n * the 512-bit value mask. Returns nothing; the codec then writes its table. */\nfunction writeLeafHeader(\n w: GridImageWriter,\n leafOff: number,\n leaf: EncodableLeaf,\n flagsByte: number,\n): void {\n const s = leaf.stats;\n const bmin = s.isEmpty ? leaf.origin : s.bboxMin;\n const bmax = s.isEmpty ? leaf.origin : s.bboxMax;\n w.setI32(leafOff + LEAF_OFF_BBOX_MIN, bmin[0]);\n w.setI32(leafOff + LEAF_OFF_BBOX_MIN + 4, bmin[1]);\n w.setI32(leafOff + LEAF_OFF_BBOX_MIN + 8, bmin[2]);\n const difX = clampByte(bmax[0] - bmin[0]);\n const difY = clampByte(bmax[1] - bmin[1]);\n const difZ = clampByte(bmax[2] - bmin[2]);\n w.setU32(\n leafOff + LEAF_OFF_BBOX_DIF_AND_FLAGS,\n (difX | (difY << 8) | (difZ << 16) | (flagsByte << 24)) >>> 0,\n );\n w.setMaskWords(leafOff + 16, leaf.valueMask);\n}\n\n// ---------------------------------------------------------------------------\n// FLOAT\n// ---------------------------------------------------------------------------\n\n/** FLOAT leaf codec: 512 raw f32 values, f32 stats. */\nexport const VDB_FLOAT_LEAF_CODEC: VDBLeafCodec = {\n layout: FLOAT_LAYOUT,\n planLeaf() {\n return { byteSize: FLOAT_LAYOUT.leafSize };\n },\n encodeLeaf(w, leafOff, leaf) {\n writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);\n const L = FLOAT_LAYOUT;\n const values = leaf.values;\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) {\n w.setF32(leafOff + L.leafOffTable + n * 4, values[n]!);\n }\n // Stats block. For an all-inactive leaf the accumulator is empty; write\n // zeros, matching \"no active values\".\n const s = leaf.stats;\n w.setF32(leafOff + L.leafOffMin, s.storedMin(STATS_FLOAT_MAX));\n w.setF32(leafOff + L.leafOffMax, s.storedMax(STATS_FLOAT_MAX));\n w.setF32(leafOff + L.leafOffAve, s.average);\n w.setF32(leafOff + L.leafOffStdDev, s.stdDev);\n },\n writeConstant(w, off, value) {\n w.setF32(off, scalar(value));\n },\n};\n\n// ---------------------------------------------------------------------------\n// Half (K7.H)\n// ---------------------------------------------------------------------------\n\n/**\n * Half leaf codec (`LeafData<Half>`, NanoVDB 13.2): 512 raw IEEE binary16\n * values, binary16 min/max and f32 ave/stddev. Values convert with\n * {@link vdbFloatToHalf} (NanoVDB `math::FloatToHalf`, round to nearest even,\n * overflow to infinity), as `tools::createNanoGrid<FloatGrid, Half>` does.\n * `roundValue` makes the build's statistics describe the stored halves.\n */\nexport const VDB_HALF_LEAF_CODEC: VDBLeafCodec = {\n layout: HALF_LAYOUT,\n roundValue: vdbRoundToHalf,\n planLeaf() {\n return { byteSize: HALF_LAYOUT.leafSize };\n },\n encodeLeaf(w, leafOff, leaf) {\n writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);\n const L = HALF_LAYOUT;\n const values = leaf.values;\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) w.setU16(leafOff + L.leafOffTable + n * 2, vdbFloatToHalf(values[n]!));\n const s = leaf.stats;\n w.setU16(leafOff + L.leafOffMin, vdbFloatToHalf(s.storedMin(STATS_HALF_MAX)));\n w.setU16(leafOff + L.leafOffMax, vdbFloatToHalf(s.storedMax(STATS_HALF_MAX)));\n w.setF32(leafOff + L.leafOffAve, s.average);\n w.setF32(leafOff + L.leafOffStdDev, s.stdDev);\n },\n writeConstant(w, off, value) {\n w.setU16(off, vdbFloatToHalf(scalar(value)));\n },\n};\n\n// ---------------------------------------------------------------------------\n// Vec3f\n// ---------------------------------------------------------------------------\n\n/** Writes a Vec3f (3 x f32) at `off`. */\nfunction writeVec3(w: GridImageWriter, off: number, v: readonly number[]): void {\n w.setF32(off, v[0]!);\n w.setF32(off + 4, v[1]!);\n w.setF32(off + 8, v[2]!);\n}\n\n/**\n * Vec3f leaf codec (K4.2): 512 x 3 f32 values (xyz interleaved in\n * `leaf.values`), Vec3f min/max and f32 ave/stddev of the squared lengths\n * (NanoVDB `Stats<Vec3f, 1>`, see {@link Vec3StatsAccumulator}).\n */\nexport const VDB_VEC3F_LEAF_CODEC: VDBLeafCodec = {\n layout: VEC3F_LAYOUT,\n components: 3,\n planLeaf() {\n return { byteSize: VEC3F_LAYOUT.leafSize };\n },\n encodeLeaf(w, leafOff, leaf) {\n writeLeafHeader(w, leafOff, leaf, NODE_FLAG_STATS);\n const L = VEC3F_LAYOUT;\n const values = leaf.values;\n for (let i = 0; i < LEAF_TABLE_COUNT * 3; i++) w.setF32(leafOff + L.leafOffTable + i * 4, values[i]!);\n writeVec3StatsBlock(w, leafOff, L.leafOffMin, L.leafOffMax, L.leafOffAve, L.leafOffStdDev, leaf.stats);\n },\n writeConstant(w, off, value) {\n if (typeof value === \"number\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `Vec3f codec: expected a vector value, got ${value}`);\n writeVec3(w, off, value);\n },\n};\n\n/** Writes a Vec3f node's stats block: Vec3f min/max (zeros when empty), f32 ave/stddev. */\nexport function writeVec3StatsBlock(\n w: GridImageWriter,\n base: number,\n offMin: number,\n offMax: number,\n offAve: number,\n offStdDev: number,\n stats: StatsAccumulator,\n): void {\n const empty = stats.isEmpty || !(stats instanceof Vec3StatsAccumulator);\n writeVec3(w, base + offMin, empty ? [0, 0, 0] : (stats as Vec3StatsAccumulator).minVec);\n writeVec3(w, base + offMax, empty ? [0, 0, 0] : (stats as Vec3StatsAccumulator).maxVec);\n w.setF32(base + offAve, stats.average);\n w.setF32(base + offStdDev, stats.stdDev);\n}\n\n// ---------------------------------------------------------------------------\n// Quantized (Fp8 / FpN) shared helpers\n// ---------------------------------------------------------------------------\n\nconst fround = Math.fround;\n\n/** Min and max over all 512 leaf values (the affine origin for quantization). */\nfunction leafMinMax(values: Float32Array): { min: number; max: number } {\n let min = Infinity;\n let max = -Infinity;\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) {\n const v = values[n]!;\n if (v < min) min = v;\n if (v > max) max = v;\n }\n return { min, max };\n}\n\n/** `floor(encode*(v-min) + 0.5)` in float32, clamped to `[0, mask]`.\n * Matches native `uint(encode*(v-min) + 0.5f)` with dithering disabled. */\nfunction quantizeF32(v: number, min: number, encode: number, mask: number): number {\n const code = Math.floor(fround(fround(encode * fround(v - min)) + 0.5));\n return code < 0 ? 0 : code > mask ? mask : code;\n}\n\n/** `floor(encode*(v-min) + 0.5)` in double, clamped — the 16-bit FpN path. */\nfunction quantizeF64(v: number, min: number, encode: number, mask: number): number {\n const code = Math.floor(encode * (v - min) + 0.5);\n return code < 0 ? 0 : code > mask ? mask : code;\n}\n\n/** Writes mMinimum, mQuantum (f32) and the four u16 quantized statistics. */\nfunction writeFpHeaderStats(\n w: GridImageWriter,\n leafOff: number,\n min: number,\n quantum: number,\n stats: StatsAccumulator,\n): void {\n w.setF32(leafOff + LEAF_OFF_FP_MINIMUM, min);\n w.setF32(leafOff + LEAF_OFF_FP_QUANTUM, quantum);\n // Quantized active-value statistics (uint16), per LeafFnBase::set{Min,Max,Avg,Dev}.\n const qInv = quantum > 0 ? 1 / quantum : 0;\n const q16 = (x: number): number => {\n const c = Math.floor(x + 0.5);\n return c < 0 ? 0 : c > 0xffff ? 0xffff : c;\n };\n if (stats.isEmpty) {\n w.setU16(leafOff + LEAF_OFF_FP_STAT_MIN, 0);\n w.setU16(leafOff + LEAF_OFF_FP_STAT_MAX, 0);\n w.setU16(leafOff + LEAF_OFF_FP_STAT_AVG, 0);\n w.setU16(leafOff + LEAF_OFF_FP_STAT_DEV, 0);\n return;\n }\n w.setU16(leafOff + LEAF_OFF_FP_STAT_MIN, q16((stats.min - min) * qInv));\n w.setU16(leafOff + LEAF_OFF_FP_STAT_MAX, q16((stats.max - min) * qInv));\n w.setU16(leafOff + LEAF_OFF_FP_STAT_AVG, q16((stats.average - min) * qInv));\n w.setU16(leafOff + LEAF_OFF_FP_STAT_DEV, q16(stats.stdDev * qInv));\n}\n\n/**\n * Packs 512 codes at `bits` bits/value, LSB-first, into the image at\n * `leafOff + 96`. Value `n` occupies global bit range `[n*bits, n*bits+bits)`,\n * exactly what `leafFpReadFloat`'s word/shift addressing reads back.\n */\nfunction packCodes(\n w: GridImageWriter,\n leafOff: number,\n bits: number,\n codeAt: (n: number) => number,\n): void {\n const base = leafOff + LEAF_OFF_FP_CODES;\n const bytes = w.bytes;\n if (bits === 8) {\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) bytes[base + n] = codeAt(n);\n return;\n }\n if (bits === 16) {\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) {\n const c = codeAt(n);\n bytes[base + 2 * n] = c & 0xff;\n bytes[base + 2 * n + 1] = (c >>> 8) & 0xff;\n }\n return;\n }\n // 1/2/4 bits: sub-byte packing (buffer is zero-initialised, so OR in).\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) {\n const c = codeAt(n);\n let g = n * bits;\n for (let b = 0; b < bits; b++) {\n if ((c >>> b) & 1) bytes[base + (g >>> 3)]! |= 1 << (g & 7);\n g++;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Fp4 / Fp8 / Fp16 — fixed bit width\n// ---------------------------------------------------------------------------\n\nfunction makeFixedLeafCodec(layout: GridTypeLayout, bits: 4 | 8 | 16): VDBLeafCodec {\n const mask = (1 << bits) - 1;\n return {\n layout,\n planLeaf() {\n return { byteSize: layout.leafSize };\n },\n encodeLeaf(w, leafOff, leaf) {\n writeLeafHeader(w, leafOff, leaf, LEAF_FLAG_HAS_BBOX);\n const { min, max } = leafMinMax(leaf.values);\n const values = leaf.values;\n if (bits === 16) {\n // Same arithmetic as FpN's 16-bit path: double encode, f32-stored quantum.\n const range = max - min;\n writeFpHeaderStats(w, leafOff, min, range > 0 ? range / mask : 0, leaf.stats);\n const encode = range > 0 ? mask / range : 0;\n packCodes(w, leafOff, 16, (n) => quantizeF64(values[n]!, min, encode, mask));\n return;\n }\n const range = fround(max - min);\n const quantum = range > 0 ? fround(range / mask) : 0;\n writeFpHeaderStats(w, leafOff, min, quantum, leaf.stats);\n const encode = range > 0 ? fround(mask / range) : 0;\n packCodes(w, leafOff, bits, (n) => quantizeF32(values[n]!, min, encode, mask));\n },\n writeConstant(w, off, value) {\n w.setF32(off, scalar(value));\n },\n };\n}\n\n/** Fp4: fixed 4-bit codes (`LeafData<Fp4>`, 16 levels per leaf). */\nexport const VDB_FP4_LEAF_CODEC: VDBLeafCodec = makeFixedLeafCodec(FP4_LAYOUT, 4);\n/** Fp8: fixed 8-bit codes (`LeafData<Fp8>`). */\nexport const VDB_FP8_LEAF_CODEC: VDBLeafCodec = makeFixedLeafCodec(FP8_LAYOUT, 8);\n/** Fp16: fixed 16-bit codes (`LeafData<Fp16>`). */\nexport const VDB_FP16_LEAF_CODEC: VDBLeafCodec = makeFixedLeafCodec(FP16_LAYOUT, 16);\n\n// ---------------------------------------------------------------------------\n// FpN — variable bit-width chosen per leaf by an absolute-difference oracle\n// ---------------------------------------------------------------------------\n\n/** Native's default absolute tolerance for a FogVolume (`AbsDiff::init`). */\nexport const FPN_DEFAULT_TOLERANCE = 0.01;\n\nconst LOG_BITS_MAX = 4; // logBitWidth in [0,4] -> 1,2,4,8,16 bits\n\n/**\n * Picks the smallest logBitWidth (0..4 -> 1,2,4,8,16 bits) whose float32 encode\n * keeps every one of the 512 values within `tolerance` of its dequantized\n * approximation — the exact loop in `CreateNanoGrid::preProcess<FpN>`.\n */\nfunction chooseFpNLogBits(values: Float32Array, min: number, max: number, tolerance: number): number {\n const range = fround(max - min);\n if (!(range > 0)) return 0; // constant leaf -> 1 bit (quantum 0)\n for (let logBits = 0; logBits < LOG_BITS_MAX; logBits++) {\n const mask = (1 << (1 << logBits)) - 1;\n const encode = fround(mask / range);\n const decode = fround(range / mask);\n let ok = true;\n for (let n = 0; n < LEAF_TABLE_COUNT; n++) {\n const exact = values[n]!;\n const code = quantizeF32(exact, min, encode, mask);\n const approx = fround(fround(code * decode) + min);\n if (fround(Math.abs(exact - approx)) > tolerance) {\n ok = false;\n break;\n }\n }\n if (ok) return logBits;\n }\n return LOG_BITS_MAX;\n}\n\ninterface FpNPlan extends LeafPlan {\n readonly logBits: number;\n}\n\n/** Builds an FpN codec for a given absolute tolerance (default: native's 0.01). */\nexport function vdbMakeFpNLeafCodec(tolerance: number = FPN_DEFAULT_TOLERANCE): VDBLeafCodec {\n return {\n layout: FPN_LAYOUT,\n planLeaf(values): FpNPlan {\n const { min, max } = leafMinMax(values);\n const logBits = chooseFpNLogBits(values, min, max, tolerance);\n const bits = 1 << logBits;\n return { byteSize: FP_LEAF_HEADER_SIZE + bits * 64, logBits };\n },\n encodeLeaf(w, leafOff, leaf, plan) {\n const logBits = (plan as FpNPlan).logBits;\n const bits = 1 << logBits;\n writeLeafHeader(w, leafOff, leaf, (logBits << 5) | LEAF_FLAG_HAS_BBOX);\n const { min, max } = leafMinMax(leaf.values);\n const range = max - min;\n const mask = (1 << bits) - 1;\n const quantum = range > 0 ? (bits >= 16 ? range / mask : fround(range / mask)) : 0;\n writeFpHeaderStats(w, leafOff, min, quantum, leaf.stats);\n const values = leaf.values;\n if (bits >= 16) {\n const encode = range > 0 ? 65535 / range : 0;\n packCodes(w, leafOff, bits, (n) => quantizeF64(values[n]!, min, encode, mask));\n } else {\n const encode = range > 0 ? fround(mask / fround(range)) : 0;\n packCodes(w, leafOff, bits, (n) => quantizeF32(values[n]!, min, encode, mask));\n }\n },\n writeConstant(w, off, value) {\n w.setF32(off, scalar(value));\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* quantize.ts — re-encode a Float or Half NanoVDB grid image as Fp4, Fp8, Fp16, FpN, Half or Float.
|
|
3
|
+
*
|
|
4
|
+
* Quantization is a leaf-value-representation change only: topology, masks,
|
|
5
|
+
* internal-node tables/stats, GridData and the transform are unchanged. So
|
|
6
|
+
* `quantize` reads the source FLOAT image's leaves (each: 8-aligned origin,
|
|
7
|
+
* all 512 values, value mask), its active tiles (root, upper, lower; kept as
|
|
8
|
+
* tiles since K4.1 — tile values stay plain f32 in Fp8/FpN grids) and its
|
|
9
|
+
* GridData transform/background, then re-runs the leaf-iterator build path
|
|
10
|
+
* ({@link vdbBuildFromLeavesDetailed}) with the chosen quantizing {@link VDBLeafCodec}. The result satisfies the repo's proven decoders
|
|
11
|
+
* (`read-value.ts` `leafFp*ReadFloat`, `pnanovdb.wgsl`).
|
|
12
|
+
*
|
|
13
|
+
* - `fp4` / `fp8` / `fp16` — fixed 4/8/16-bit codes; per-leaf quantum = (max-min)/(2^bits-1).
|
|
14
|
+
* The CreateNanoGrid rules Fp8 uses (min/quantum over all 512 values, round-to-nearest, no
|
|
15
|
+
* dither); `tolerance` is ignored. No native Fp4/Fp16 fixtures exist, so these are verified
|
|
16
|
+
* by decoder round-trip and GPU parity, not byte-compared to `nanovdb_convert`.
|
|
17
|
+
* - `fpn` — per-leaf variable bit-width, smallest of 1/2/4/8/16 bits whose
|
|
18
|
+
* dequantized values stay within `tolerance` (default: native's FogVolume 0.01).
|
|
19
|
+
* - `half` (K7.H) — NanoVDB `GridType::Half` (NanoVDB 13.2): every value (leaf
|
|
20
|
+
* voxels, tiles, background) becomes the nearest IEEE binary16 (round to
|
|
21
|
+
* nearest even, `|v| > 65504` to infinity; NanoVDB `math::FloatToHalf`), as
|
|
22
|
+
* `tools::createNanoGrid<FloatGrid, Half>` writes it; min/max stats are
|
|
23
|
+
* binary16, ave/stddev f32 over the stored halves. Relative error <= 2^-11 in
|
|
24
|
+
* the normal range (6.1e-5 to 65504); absolute <= 2^-25 below it. `tolerance`
|
|
25
|
+
* is ignored. Cross-checked against native NanoVDB v14.0.0
|
|
26
|
+
* (`docker/fixture-bake/bake_half.cpp`, `test/tools/half-native.test.ts`).
|
|
27
|
+
*
|
|
28
|
+
* - `float` (K7.H1) — plain f32 leaves: widens a Half grid exactly (Half ->
|
|
29
|
+
* Float -> Half is the identity), or re-lays out a Float grid.
|
|
30
|
+
*
|
|
31
|
+
* Sources are Float or Half grids (K7.H1; Half values widen to f32 exactly);
|
|
32
|
+
* quantized sources throw, since re-quantizing loses precision twice.
|
|
33
|
+
*/
|
|
34
|
+
import { type VDBBuiltGrid } from "./serialize.js";
|
|
35
|
+
/**
|
|
36
|
+
* Target encoding of {@link vdbQuantize}: fixed 4, 8 or 16-bit codes, FpN (bit-width chosen per leaf by tolerance),
|
|
37
|
+
* Half (raw IEEE binary16, K7.H) or Float (f32; widens a Half source exactly, K7.H1).
|
|
38
|
+
*/
|
|
39
|
+
export type VDBQuantizeMode = "fp4" | "fp8" | "fp16" | "fpn" | "half" | "float";
|
|
40
|
+
/** Options of {@link vdbQuantize}. */
|
|
41
|
+
export interface VDBQuantizeOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Also collapse uniform leaves and nodes of the source into tiles (OpenVDB
|
|
44
|
+
* `prune`, tolerance 0; K4.6). Default false: quantizing keeps the source
|
|
45
|
+
* topology, so a native FLOAT image quantizes to native's Fp8/FpN layout.
|
|
46
|
+
*/
|
|
47
|
+
collapse?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Re-encodes a Float or Half grid image (or built grid) as Fp4/Fp8/Fp16/FpN, Half or Float. Returns a new image.
|
|
51
|
+
*
|
|
52
|
+
* @param input A Float or Half grid image, or a built grid.
|
|
53
|
+
* @param mode Target encoding.
|
|
54
|
+
* @param tolerance Absolute error bound for `'fpn'` (leaf bit-width is chosen to meet it); ignored by the other modes.
|
|
55
|
+
* @param options Topology options (leaf collapsing).
|
|
56
|
+
*/
|
|
57
|
+
export declare function vdbQuantize(input: Uint32Array | VDBBuiltGrid, mode: VDBQuantizeMode, tolerance?: number, options?: VDBQuantizeOptions): Uint32Array;
|
|
58
|
+
/**
|
|
59
|
+
* As {@link vdbQuantize}, but returns the computed metadata alongside the image.
|
|
60
|
+
*
|
|
61
|
+
* @param input A Float or Half grid image, or a built grid.
|
|
62
|
+
* @param mode Target encoding.
|
|
63
|
+
* @param tolerance Absolute error bound for `'fpn'`; ignored by the fixed-width modes.
|
|
64
|
+
* @param options Topology options (leaf collapsing).
|
|
65
|
+
*/
|
|
66
|
+
export declare function vdbQuantizeDetailed(input: Uint32Array | VDBBuiltGrid, mode: VDBQuantizeMode, tolerance?: number, options?: VDBQuantizeOptions): VDBBuiltGrid;
|
|
67
|
+
/**
|
|
68
|
+
* Re-encodes a Float or Half grid image (same type) with uniform leaves and
|
|
69
|
+
* nodes collapsed into tiles (OpenVDB `prune`, tolerance 0; K4.6; Half since
|
|
70
|
+
* K7.H1). Values read back identically; see `tree.ts` for the rules.
|
|
71
|
+
*/
|
|
72
|
+
export declare function vdbCollapseGrid(input: Uint32Array | VDBBuiltGrid): VDBBuiltGrid;
|