@pmndrs/vdb 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +59 -2
- package/dist/core/source/types.js.map +1 -1
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// the box helpers, through ./volume-source.ts).
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0): the source half of createVolumeUniforms /
|
|
2
|
+
// createVolumeNodes (frameShaderChunks.js L729–763, L834–1028), whose sparse-grid port (the TSL half) was deleted in K6.11
|
|
3
|
+
// (D35); this file is the handle the core's sparse source is made from.
|
|
5
4
|
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
6
|
-
//
|
|
7
|
-
// instead of an 8-bit 3D texture; three LOD strategies instead of his box mip atlas; an HDDA
|
|
8
|
-
// empty-space query for marches. Divergences: DIVERGES.md (K3.2 rows), V23–V25.
|
|
5
|
+
// Divergences: DIVERGES.md (K3.2 rows), V23–V25, V145.
|
|
9
6
|
/**
|
|
10
7
|
* The sparse volume source (K3.2, R1 §4.2–4.3): a `VDBGridPool` grid behind the same seam as the
|
|
11
8
|
* dense `.wvdb` source, so `VDBFrameVolume` renders NanoVDB grids.
|
|
@@ -14,23 +11,28 @@
|
|
|
14
11
|
* const source = vdbSparseSource(grids, { density: id }, { lod: "coarse-pyramid", images: { density: image } });
|
|
15
12
|
* const volume = new VDBFrameVolume(source, { extinction: 100 }); // box: the grid's world box
|
|
16
13
|
*
|
|
14
|
+
* K6.8a / K6.11: the source is a handle (grids, ids, options, boxes, stats, the image-follow state). `VDBFrameRenderer`
|
|
15
|
+
* reads it into the core's sparse source (`vdbSparseSource`), which builds its own pyramids and reads the grids itself.
|
|
16
|
+
* The handle holds no GPU object. (Custom TSL materials sample a pooled grid through `VDBGridNode`; custom WGSL or compute
|
|
17
|
+
* uses the core source's `wgsl()`.)
|
|
18
|
+
*
|
|
17
19
|
* Positions are his local unit box [-0.5, 0.5]³; uvw = local + 0.5 (+ offset, wrapped) maps onto the
|
|
18
20
|
* channel grid's index cell box `[min − ½, max + ½]` (voxel centres at integers), so uvw
|
|
19
21
|
* (i + 0.5) / N lands on voxel min + i as on a dense texel centre. The sample position is clamped to
|
|
20
|
-
* `[min, max]` (his clamp-to-edge). Level 0 is the pool's trilinear
|
|
22
|
+
* `[min, max]` (his clamp-to-edge). Level 0 is the pool's trilinear sample; with the node helper
|
|
21
23
|
* `'fastTrilinear'` (recommended, K3.2d) it is `vdbSampleFast` through one accessor per shader invocation
|
|
22
|
-
* (`cacheAccessor`): the same values, 1.5–2× faster on the hardware GPU (docs/archive/handoffs/K3-2d.md).
|
|
24
|
+
* (`cacheAccessor`): the same values, 1.5–2× faster on the hardware GPU (docs/archive/handoffs/K3-2d.md). (The core's
|
|
25
|
+
* sparse source reads these options.)
|
|
23
26
|
*
|
|
24
27
|
* LOD (`lod`, his `sampleExtinction(localPos, lod)` at lod ≥ 1; R1 §4.3):
|
|
25
28
|
* - `'none'`: level 0 always (no prefilter; aliases when a froxel spans many voxels). lodLevels 0.
|
|
26
29
|
* - `'coarse-pyramid'` (default, the K3.2 A/B pick): a dense r16f pyramid from L₀ = max(1, ⌈log2(maxTexels / pyramidMax)⌉):
|
|
27
30
|
* the base is a box resample of the grid, the levels above it his box mip atlas. lod in (0, L₀)
|
|
28
31
|
* blends level 0 toward L₀; lod ≥ L₀ samples the pyramid as his mip atlas. GPU bytes: ~2 B × (base
|
|
29
|
-
* + atlas) texels.
|
|
30
|
-
*
|
|
31
|
-
* (`pool.replace`: a sequence frame)
|
|
32
|
-
*
|
|
33
|
-
* texels to ≤ 1 f16 ulp (e2e/k3-pyramid.spec.ts).
|
|
32
|
+
* + atlas) texels. The core's sparse source builds it on the GPU from the pool grid (K3.2a: the core's
|
|
33
|
+
* `vdbCreateBoxPyramid`, no CPU image needed) and rebuilds it when the grid's image changes
|
|
34
|
+
* (`pool.replace`: a sequence frame). K6.11: the CPU build (`pyramidBuild: 'cpu'`, the three textures' static path) is
|
|
35
|
+
* deleted; `@pmndrs/vdb/tools` `vdbBoxPyramid` stays the GPU build's CPU twin.
|
|
34
36
|
* - `'node-average'`: no extra memory: trilinear over the node averages (`vdbNodeAverage`) at
|
|
35
37
|
* level 3 (leaves, the exact 8³ box mean for fog leaves) and level 7 (lower nodes, the mean of
|
|
36
38
|
* their active voxels); lod in (0, 3) blends level 0 → 3, (3, 7) blends 3 → 7. Needs stats.
|
|
@@ -41,28 +43,15 @@
|
|
|
41
43
|
* Following the image (`followImage`, G16a): the index boxes, world box and pyramid are fixed when the source is
|
|
42
44
|
* made unless it follows the grids' images. Then a `pool.replace` that changes a channel grid's box (a coarse-first
|
|
43
45
|
* swap: the preview, then the full grid in the same id) is re-read from `pool.info` once the new image is resident:
|
|
44
|
-
* new
|
|
45
|
-
* range as a uniform, and a new `version`, which a `VDBFrameVolume` follows with its box. No shader is rebuilt, and the
|
|
46
|
-
* pyramid kernels of every type the `VDBGridNode` decodes are compiled up front.
|
|
46
|
+
* the new layout, the LOD range and a new `version`, which a `VDBFrameVolume` follows with its box. No shader is rebuilt.
|
|
47
47
|
*
|
|
48
48
|
* Mask, albedo and emission grids (optional, scalar; albedo may be three grids for RGB) are read at
|
|
49
49
|
* level 0 only. One VDB module per shader: every grid goes through the one `VDBGridNode`.
|
|
50
50
|
*/
|
|
51
|
-
import * as THREE from "three";
|
|
52
|
-
import * as TSL from "three/tsl";
|
|
53
|
-
import { code, wgslFn } from "three/tsl";
|
|
54
51
|
import { VDBError } from "../core/errors.js";
|
|
55
|
-
import { vdbCreateBoxPyramid, warmBoxPyramidPipelines } from "../core/compute/pyramid.js";
|
|
56
|
-
import { vdbBoxPyramid } from "../tools/frame/sparse.js";
|
|
57
52
|
import { vdbBoxPyramidLayout } from "../tools/frame/pyramid-layout.js";
|
|
58
|
-
import { getGPUTexture, webgpuBackendOf } from "./device.js";
|
|
59
53
|
import { leafVoxels, treeNodes } from "../tools/cpu/march.js";
|
|
60
|
-
import { vdbSample } from "./grid-node.js";
|
|
61
|
-
import { vdbBoxNodes, vdbDensityScaleOf, vdbGridUv, vdbMaxComponent, vdbMipSampler, } from "./volume-source.js";
|
|
62
|
-
const { If, clamp, float, int, log2, max, min, mix, pow, select, texture3D, uint, uniform, vec2, vec3 } = TSL;
|
|
63
54
|
const bad = (message) => new VDBError("VDB_BAD_OPTION", `vdbSparseSource: ${message}`);
|
|
64
|
-
/** G16a: the pyramid texture nodes of a following source's uniforms (their textures change with the layout). */
|
|
65
|
-
const pyramidTextures = new WeakMap();
|
|
66
55
|
/** The non-zero density stats of an image (all leaf voxels, active or not, and active tiles). */
|
|
67
56
|
function imageStats(image, clamp01) {
|
|
68
57
|
let sum = 0;
|
|
@@ -101,123 +90,16 @@ function worldBox(box, m) {
|
|
|
101
90
|
}
|
|
102
91
|
return [lo, hi];
|
|
103
92
|
}
|
|
104
|
-
/**
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
half = new Uint16Array(data.length);
|
|
109
|
-
for (let i = 0; i < data.length; i++)
|
|
110
|
-
half[i] = THREE.DataUtils.toHalfFloat(data[i]);
|
|
111
|
-
}
|
|
112
|
-
const [w, h, d] = dims;
|
|
113
|
-
const texture = new THREE.Data3DTexture(half, w, h, d);
|
|
114
|
-
// A GPU-written texture: three allocates it (createTexture) but never uploads (no data to upload).
|
|
115
|
-
if (!half)
|
|
116
|
-
texture.source.dataReady = false;
|
|
117
|
-
texture.format = THREE.RedFormat;
|
|
118
|
-
texture.type = THREE.HalfFloatType;
|
|
119
|
-
texture.minFilter = THREE.LinearFilter;
|
|
120
|
-
texture.magFilter = THREE.LinearFilter;
|
|
121
|
-
texture.unpackAlignment = 1;
|
|
122
|
-
texture.generateMipmaps = false;
|
|
123
|
-
texture.needsUpdate = true;
|
|
124
|
-
return texture;
|
|
93
|
+
/** Local unit box → sample index space: p = min − ½ + (local + ½)·size (column-major). */
|
|
94
|
+
function boxToSourceOf(b, texels) {
|
|
95
|
+
const [sx, sy, sz] = texels;
|
|
96
|
+
return new Float32Array([sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, b.min[0] - 0.5 + 0.5 * sx, b.min[1] - 0.5 + 0.5 * sy, b.min[2] - 0.5 + 0.5 * sz, 1]);
|
|
125
97
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let base = floor(q);
|
|
132
|
-
let w = q - base;
|
|
133
|
-
let c = vec3i(base) * i32(dim);
|
|
134
|
-
// One call site in a loop: SwiftShader compiles 8 inlined tree walks very slowly.
|
|
135
|
-
var v: array<f32, 8>;
|
|
136
|
-
for (var k = 0u; k < 8u; k++) {
|
|
137
|
-
v[k] = vdbNodeAverage(&acc, c + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, (k >> 2u) & 1u)) * i32(dim), dim);
|
|
138
|
-
}
|
|
139
|
-
let x00 = v[0] + w.x * (v[1] - v[0]);
|
|
140
|
-
let x10 = v[2] + w.x * (v[3] - v[2]);
|
|
141
|
-
let x01 = v[4] + w.x * (v[5] - v[4]);
|
|
142
|
-
let x11 = v[6] + w.x * (v[7] - v[6]);
|
|
143
|
-
let y0 = x00 + w.y * (x10 - x00);
|
|
144
|
-
let y1 = x01 + w.y * (x11 - x01);
|
|
145
|
-
return y0 + w.z * (y1 - y0);
|
|
146
|
-
}`;
|
|
147
|
-
// The 'node-average' density at a lod (one call per sample: level 0 → 3 → 7 blends, two taps at most).
|
|
148
|
-
const nodeLodWgsl = (sample) => /* wgsl */ `fn vdbFrameNodeLod(g: u32, p: vec3f, lod: f32) -> f32 {
|
|
149
|
-
var acc = vdbAccessorInit(g);
|
|
150
|
-
if lod <= 0.0 {
|
|
151
|
-
return ${sample}(&acc, p);
|
|
152
|
-
}
|
|
153
|
-
let fine = lod < 3.0;
|
|
154
|
-
var a = 0.0;
|
|
155
|
-
if fine {
|
|
156
|
-
a = ${sample}(&acc, p);
|
|
157
|
-
} else {
|
|
158
|
-
a = vdbFrameNodeAverage(g, p, 8u);
|
|
159
|
-
}
|
|
160
|
-
if lod >= 7.0 {
|
|
161
|
-
return vdbFrameNodeAverage(g, p, 128u);
|
|
162
|
-
}
|
|
163
|
-
let b = vdbFrameNodeAverage(g, p, select(128u, 8u, fine));
|
|
164
|
-
let t = select((lod - 3.0) / 4.0, lod / 3.0, fine);
|
|
165
|
-
return mix(a, b, t);
|
|
166
|
-
}`;
|
|
167
|
-
// K3.2d: level-0 density through the source's own sampler: vdbSampleFast (helper 'fastTrilinear') and/or one
|
|
168
|
-
// accessor per invocation kept in a private variable (copied in and out: WGSL can't pass a ptr<private> where
|
|
169
|
-
// the API takes ptr<function>). Same values as vdbSample with a fresh accessor (the accessor cache only skips
|
|
170
|
-
// the descent).
|
|
171
|
-
const SAMPLE_CACHE_WGSL = /* wgsl */ `var<private> vdbFrameAcc: VdbAccessor;
|
|
172
|
-
var<private> vdbFrameAccGrid: u32 = 0xffffffffu;`;
|
|
173
|
-
const sampleWgsl = (fast, cached) => {
|
|
174
|
-
const call = fast ? "vdbSampleFast" : "vdbSample";
|
|
175
|
-
return cached
|
|
176
|
-
? /* wgsl */ `fn vdbFrameSample(g: u32, xyz: vec3f) -> f32 {
|
|
177
|
-
if vdbFrameAccGrid != g {
|
|
178
|
-
vdbFrameAcc = vdbAccessorInit(g);
|
|
179
|
-
vdbFrameAccGrid = g;
|
|
180
|
-
}
|
|
181
|
-
var a = vdbFrameAcc;
|
|
182
|
-
let v = ${call}(&a, xyz);
|
|
183
|
-
vdbFrameAcc = a;
|
|
184
|
-
return v;
|
|
185
|
-
}`
|
|
186
|
-
: /* wgsl */ `fn vdbFrameSample(g: u32, xyz: vec3f) -> f32 {
|
|
187
|
-
var a = vdbAccessorInit(g);
|
|
188
|
-
return ${call}(&a, xyz);
|
|
189
|
-
}`;
|
|
190
|
-
};
|
|
191
|
-
// The HDDA empty-space query; CPU twin tools vdbFrameSkipEmpty (see there for the contract).
|
|
192
|
-
const SKIP_EMPTY_WGSL = /* wgsl */ `fn vdbFrameSkipEmpty(g: u32, o: vec3f, d: vec3f, t0: f32, t1: f32, cutoff: f32, dilate: u32) -> vec2f {
|
|
193
|
-
var acc = vdbAccessorInit(g);
|
|
194
|
-
var h: VdbHdda;
|
|
195
|
-
vdbHddaInit(&h, o, t0, d, t1, 8u);
|
|
196
|
-
let back = 1e-3 / max(length(d), 1e-6);
|
|
197
|
-
var ts = t0;
|
|
198
|
-
for (var n = 0u; n < 64u; n++) {
|
|
199
|
-
let te = vdbHddaCellEnd(&h);
|
|
200
|
-
var b = 0.0;
|
|
201
|
-
if dilate == 0u {
|
|
202
|
-
b = vdbCellBoundTrilinear(&acc, h.voxel, 8u);
|
|
203
|
-
} else {
|
|
204
|
-
b = -1e30;
|
|
205
|
-
for (var k = 0u; k < 27u; k++) {
|
|
206
|
-
let c = vec3i(i32(k % 3u) - 1, i32((k / 3u) % 3u) - 1, i32(k / 9u) - 1) * 8;
|
|
207
|
-
b = max(b, vdbNodeMax(&acc, h.voxel + c, 8u));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if b > cutoff {
|
|
211
|
-
return vec2f(max(t0, ts - back), te);
|
|
212
|
-
}
|
|
213
|
-
ts = te;
|
|
214
|
-
if !vdbHddaStep(&h) {
|
|
215
|
-
return vec2f(t1, t1);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
let r = max(t0, ts - back);
|
|
219
|
-
return vec2f(r, r);
|
|
220
|
-
}`;
|
|
98
|
+
const texelsOf = (b) => [b.max[0] - b.min[0] + 1, b.max[1] - b.min[1] + 1, b.max[2] - b.min[2] + 1];
|
|
99
|
+
/**
|
|
100
|
+
* The handle (K6.8a): grids, ids, options, boxes, stats and the image-follow state. The frame renderer reads these into
|
|
101
|
+
* the core's sparse source.
|
|
102
|
+
*/
|
|
221
103
|
class SparseSource {
|
|
222
104
|
kind = "sparse";
|
|
223
105
|
grids;
|
|
@@ -234,34 +116,24 @@ class SparseSource {
|
|
|
234
116
|
statsUpdates = 0;
|
|
235
117
|
boxToSource;
|
|
236
118
|
bbox;
|
|
237
|
-
pyramid;
|
|
238
|
-
gpuBytes;
|
|
239
119
|
fastTrilinear;
|
|
240
120
|
cacheAccessor;
|
|
241
121
|
followImage;
|
|
242
|
-
|
|
122
|
+
pyramidOptions;
|
|
123
|
+
/** K3.2f (internal): the core source's brick cache. */
|
|
124
|
+
brickCache;
|
|
125
|
+
/** K3.2f-e (internal): the core source's other brick options (validated by the core source). */
|
|
126
|
+
brickOptions;
|
|
243
127
|
layoutUpdates = 0;
|
|
244
|
-
/** G16a: the newest channel imageRevision the layout describes, the pool revision last checked
|
|
245
|
-
layoutRevision = -1;
|
|
246
|
-
layoutPoolRevision = -1;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
pyramidMaxOption;
|
|
250
|
-
/** G16a: the atlas node's texture when the layout has no atlas (a 1³ zero texture of its own). */
|
|
251
|
-
emptyAtlas = null;
|
|
252
|
-
poolRevisionSeen = -1;
|
|
253
|
-
poolIds;
|
|
254
|
-
versionSeen = { poolRevision: -1, value: 0 };
|
|
255
|
-
nodeAverageCache = null;
|
|
256
|
-
nodeLodCache = null;
|
|
257
|
-
skipCache = null;
|
|
258
|
-
sampleCache = null;
|
|
128
|
+
/** G16a: the newest channel imageRevision the layout describes, the pool revision last checked. */
|
|
129
|
+
#layoutRevision = -1;
|
|
130
|
+
#layoutPoolRevision = -1;
|
|
131
|
+
#poolIds;
|
|
132
|
+
#versionSeen = { poolRevision: -1, value: 0 };
|
|
259
133
|
/** K3.2e: the density imageRevision the stats describe, the pool revision last checked, and a readback in flight. */
|
|
260
|
-
statsRevision = -1;
|
|
261
|
-
statsPoolRevisionSeen = -1;
|
|
262
|
-
statsReadback = null;
|
|
263
|
-
/** K5.9a: each of this source's uniforms re-applies its density scale with the new mean when a readback lands. */
|
|
264
|
-
statsListeners = new Set();
|
|
134
|
+
#statsRevision = -1;
|
|
135
|
+
#statsPoolRevisionSeen = -1;
|
|
136
|
+
#statsReadback = null;
|
|
265
137
|
constructor(grids, ids, o) {
|
|
266
138
|
const pool = grids.pool;
|
|
267
139
|
if (typeof pool.info !== "function")
|
|
@@ -285,6 +157,17 @@ class SparseSource {
|
|
|
285
157
|
throw bad("fastTrilinear needs the VDBGridNode's sampler 'trilinear'.");
|
|
286
158
|
this.fastTrilinear = fastTrilinear;
|
|
287
159
|
this.cacheAccessor = o.cacheAccessor ?? true;
|
|
160
|
+
const brickCache = o.brickCache ?? "off";
|
|
161
|
+
if (brickCache !== "off" && brickCache !== "f32" && brickCache !== "f16")
|
|
162
|
+
throw bad(`brickCache must be 'off', 'f32' or 'f16', got ${JSON.stringify(brickCache)}.`);
|
|
163
|
+
this.brickCache = brickCache;
|
|
164
|
+
const io = o;
|
|
165
|
+
this.brickOptions = Object.freeze({
|
|
166
|
+
...(io.brickKernels !== undefined ? { brickKernels: io.brickKernels } : {}),
|
|
167
|
+
...(io.brickMarkStats !== undefined ? { brickMarkStats: io.brickMarkStats } : {}),
|
|
168
|
+
...(io.brickCapacity !== undefined ? { brickCapacity: io.brickCapacity } : {}),
|
|
169
|
+
...(io.brickBudget !== undefined ? { brickBudget: io.brickBudget } : {}),
|
|
170
|
+
});
|
|
288
171
|
const followImage = o.followImage ?? false;
|
|
289
172
|
if (typeof followImage !== "boolean")
|
|
290
173
|
throw bad("followImage must be a boolean.");
|
|
@@ -292,11 +175,8 @@ class SparseSource {
|
|
|
292
175
|
const fixed = ["indexBox", "auxIndexBoxes", "bbox"].filter((k) => o[k] !== undefined);
|
|
293
176
|
if (fixed.length)
|
|
294
177
|
throw bad(`followImage re-reads every box from the pool; drop ${fixed.join(", ")} (fixed boxes).`);
|
|
295
|
-
if (lod === "coarse-pyramid" && o.pyramidBuild === "cpu")
|
|
296
|
-
throw bad("followImage rebuilds the pyramid from the pool on the GPU; use pyramidBuild 'gpu' (the default).");
|
|
297
178
|
}
|
|
298
179
|
this.followImage = followImage;
|
|
299
|
-
this.pyramidMaxOption = o.pyramidMax !== undefined ? { pyramidMax: o.pyramidMax } : {};
|
|
300
180
|
const density = info(ids.density);
|
|
301
181
|
if (lod === "node-average" && !density.hasStats)
|
|
302
182
|
throw bad("lod 'node-average' reads node statistics; this grid has none (rebuild it with stats).");
|
|
@@ -313,7 +193,7 @@ class SparseSource {
|
|
|
313
193
|
this.auxBoxes = { mask: box(ids.mask, aux.mask), albedo: box(albedoId, aux.albedo), emission: box(ids.emission, aux.emission) };
|
|
314
194
|
this.channels = { mask: ids.mask !== undefined, albedo: ids.albedo !== undefined, emission: ids.emission !== undefined };
|
|
315
195
|
const b = this.indexBox;
|
|
316
|
-
this.texels =
|
|
196
|
+
this.texels = texelsOf(b);
|
|
317
197
|
if (this.texels.some((t) => !(t > 0)))
|
|
318
198
|
throw bad("the density index box is empty.");
|
|
319
199
|
const image = o.images?.density;
|
|
@@ -323,107 +203,36 @@ class SparseSource {
|
|
|
323
203
|
this.stats = imageStats(image, normalize === "clamp01");
|
|
324
204
|
else
|
|
325
205
|
throw bad("pass images.density (the CPU image, for the density stats) or stats.");
|
|
326
|
-
this
|
|
327
|
-
|
|
328
|
-
const [sx, sy, sz] = this.texels;
|
|
329
|
-
this.boxToSource = new Float32Array([sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, b.min[0] - 0.5 + 0.5 * sx, b.min[1] - 0.5 + 0.5 * sy, b.min[2] - 0.5 + 0.5 * sz, 1]);
|
|
206
|
+
this.#statsRevision = density.imageRevision ?? -1;
|
|
207
|
+
this.boxToSource = boxToSourceOf(b, this.texels);
|
|
330
208
|
this.bbox = o.bbox ? [[...o.bbox[0]], [...o.bbox[1]]] : worldBox(b, density.indexToWorld);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
throw bad(`unknown pyramidBuild ${JSON.stringify(build)}; use 'gpu' or 'cpu'.`);
|
|
336
|
-
const pyramidMax = o.pyramidMax !== undefined ? { pyramidMax: o.pyramidMax } : {};
|
|
337
|
-
if (build === "cpu") {
|
|
338
|
-
if (!image)
|
|
339
|
-
throw bad("pyramidBuild 'cpu' builds the pyramid from images.density; pass it, or use pyramidBuild 'gpu' (the default).");
|
|
340
|
-
const p = vdbBoxPyramid(image, { indexBox: b, ...pyramidMax });
|
|
341
|
-
pyramid = {
|
|
342
|
-
build,
|
|
343
|
-
level: p.level,
|
|
344
|
-
dimensions: p.dimensions,
|
|
345
|
-
atlas: p.atlas,
|
|
346
|
-
lodLevels: p.lodLevels,
|
|
347
|
-
data: p.data,
|
|
348
|
-
map: halfTexture(p.data, p.dimensions),
|
|
349
|
-
mip: p.atlas ? halfTexture(p.atlas.data, p.atlas.dimensions) : null,
|
|
350
|
-
gpu: null,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
const renderer = grids.renderer;
|
|
355
|
-
let device;
|
|
356
|
-
try {
|
|
357
|
-
device = webgpuBackendOf(renderer, "vdbSparseSource").device;
|
|
358
|
-
}
|
|
359
|
-
catch {
|
|
360
|
-
throw bad("pyramidBuild 'gpu' (the default for lod 'coarse-pyramid') needs the VDBGridNode's initialized WebGPURenderer; use pyramidBuild 'cpu' with images.density otherwise.");
|
|
361
|
-
}
|
|
362
|
-
const initTexture = renderer.initTexture;
|
|
363
|
-
if (typeof initTexture !== "function")
|
|
364
|
-
throw bad("pyramidBuild 'gpu' needs renderer.initTexture (three r187 WebGPURenderer).");
|
|
365
|
-
// G16a: a following source compiles the pyramid kernels of every type the node decodes now, so a swap to
|
|
366
|
-
// another grid type creates no pipeline.
|
|
367
|
-
if (followImage)
|
|
368
|
-
warmBoxPyramidPipelines(device, grids.options.types);
|
|
369
|
-
pyramid = this.gpuPyramid(b, ids.density);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
this.pyramid = pyramid;
|
|
373
|
-
this.lodLevels = lod === "none" ? 0 : lod === "node-average" ? 7 : pyramid.lodLevels;
|
|
374
|
-
this.poolIds = [...new Set(channelIds)];
|
|
375
|
-
this.gpuBytes = this.measure();
|
|
376
|
-
this.layoutRevision = this.poolIds.reduce((r, id) => Math.max(r, info(id).imageRevision ?? 0), 0);
|
|
377
|
-
this.refreshPyramid();
|
|
378
|
-
}
|
|
379
|
-
/** GPU bytes of the channel grids' pool ranges and the pyramid (see the interface). */
|
|
380
|
-
measure() {
|
|
381
|
-
const pool = this.grids.pool;
|
|
382
|
-
const p = this.pyramid;
|
|
383
|
-
const atlasTexels = p?.atlas ? p.atlas.dimensions[0] * p.atlas.dimensions[1] * p.atlas.dimensions[2] : 0;
|
|
384
|
-
const pyramidBytes = p ? 2 * (p.dimensions[0] * p.dimensions[1] * p.dimensions[2] + atlasTexels) : 0;
|
|
385
|
-
return { pool: this.poolIds.reduce((s, id) => s + pool.info(id).capacity, 0), pyramid: pyramidBytes, pyramidScratch: p?.gpu?.gpuBytes.scratch ?? 0 };
|
|
209
|
+
this.pyramidOptions = o.pyramidMax !== undefined ? { pyramidMax: o.pyramidMax } : {};
|
|
210
|
+
this.lodLevels = this.#lodLevelsOf(this.texels);
|
|
211
|
+
this.#poolIds = [...new Set(channelIds)];
|
|
212
|
+
this.#layoutRevision = this.#poolIds.reduce((r, id) => Math.max(r, info(id).imageRevision ?? 0), 0);
|
|
386
213
|
}
|
|
387
|
-
/** The
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
map.name = "vdbSparseSource pyramid base";
|
|
396
|
-
if (mip)
|
|
397
|
-
mip.name = "vdbSparseSource pyramid atlas";
|
|
398
|
-
for (const t of [map, mip])
|
|
399
|
-
if (t)
|
|
400
|
-
renderer.initTexture(t);
|
|
401
|
-
const gpu = vdbCreateBoxPyramid(device, this.grids.pool, densityId, {
|
|
402
|
-
indexBox: box,
|
|
403
|
-
...this.pyramidMaxOption,
|
|
404
|
-
targets: { base: getGPUTexture(renderer, map), atlas: mip ? getGPUTexture(renderer, mip) : null },
|
|
405
|
-
label: "vdbSparseSource pyramid",
|
|
406
|
-
});
|
|
407
|
-
return {
|
|
408
|
-
build: "gpu",
|
|
409
|
-
level: layout.level,
|
|
410
|
-
dimensions: [...layout.dimensions],
|
|
411
|
-
atlas: layout.atlas ? { dimensions: [...layout.atlas.dimensions], levels: layout.atlas.levels.length } : null,
|
|
412
|
-
lodLevels: layout.lodLevels,
|
|
413
|
-
map,
|
|
414
|
-
mip,
|
|
415
|
-
gpu,
|
|
416
|
-
};
|
|
214
|
+
/** The LOD range: 0 (`'none'`), 7 (`'node-average'`), the pyramid layout's levels (`'coarse-pyramid'`). */
|
|
215
|
+
#lodLevelsOf(texels) {
|
|
216
|
+
if (this.lod === "none")
|
|
217
|
+
return 0;
|
|
218
|
+
if (this.lod === "node-average")
|
|
219
|
+
return 7;
|
|
220
|
+
const { pyramidMax } = this.pyramidOptions;
|
|
221
|
+
return vdbBoxPyramidLayout(texels, pyramidMax !== undefined ? { pyramidMax } : {}).lodLevels;
|
|
417
222
|
}
|
|
418
|
-
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
223
|
+
/** GPU bytes of the channel grids' pool ranges. */
|
|
224
|
+
get gpuBytes() {
|
|
225
|
+
const pool = this.grids.pool;
|
|
226
|
+
let bytes = 0;
|
|
227
|
+
for (const id of this.#poolIds) {
|
|
228
|
+
try {
|
|
229
|
+
bytes += pool.info(id).capacity;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
// A removed grid holds no pool range.
|
|
233
|
+
}
|
|
425
234
|
}
|
|
426
|
-
return
|
|
235
|
+
return { pool: bytes };
|
|
427
236
|
}
|
|
428
237
|
/**
|
|
429
238
|
* G16a (`followImage`): re-reads the layout when a channel grid's image changed and every channel grid is resident
|
|
@@ -435,12 +244,12 @@ class SparseSource {
|
|
|
435
244
|
if (!this.followImage)
|
|
436
245
|
return false;
|
|
437
246
|
const pool = this.grids.pool;
|
|
438
|
-
if (typeof pool.revision !== "number" || pool.revision === this
|
|
247
|
+
if (typeof pool.revision !== "number" || pool.revision === this.#layoutPoolRevision)
|
|
439
248
|
return false;
|
|
440
249
|
let revision = 0;
|
|
441
250
|
let resident = true;
|
|
442
251
|
const infos = [];
|
|
443
|
-
for (const id of this
|
|
252
|
+
for (const id of this.#poolIds) {
|
|
444
253
|
let i;
|
|
445
254
|
try {
|
|
446
255
|
i = pool.info(id);
|
|
@@ -453,8 +262,8 @@ class SparseSource {
|
|
|
453
262
|
resident = false;
|
|
454
263
|
infos.push({ id, type: i.type });
|
|
455
264
|
}
|
|
456
|
-
if (revision === this
|
|
457
|
-
this
|
|
265
|
+
if (revision === this.#layoutRevision) {
|
|
266
|
+
this.#layoutPoolRevision = pool.revision;
|
|
458
267
|
return false;
|
|
459
268
|
}
|
|
460
269
|
if (!resident)
|
|
@@ -462,9 +271,9 @@ class SparseSource {
|
|
|
462
271
|
// A new image of a type the module does not decode would read 0 through the new boxes, silently: say so instead
|
|
463
272
|
// (every call until the source is remade over a node that compiles it).
|
|
464
273
|
this.checkTypes(infos, "a channel grid's new image");
|
|
465
|
-
this
|
|
466
|
-
this
|
|
467
|
-
this
|
|
274
|
+
this.#relayout();
|
|
275
|
+
this.#layoutRevision = revision;
|
|
276
|
+
this.#layoutPoolRevision = pool.revision;
|
|
468
277
|
return true;
|
|
469
278
|
}
|
|
470
279
|
/**
|
|
@@ -482,7 +291,7 @@ class SparseSource {
|
|
|
482
291
|
`${compiled.join(", ")}; it would read 0. Make the VDBGridNode with types that include every type the images will have ` +
|
|
483
292
|
`(a coarse-first stream lists them in VDBCoarseFirstEvent.types: types: event.types), then make the source over it.`);
|
|
484
293
|
}
|
|
485
|
-
relayout() {
|
|
294
|
+
#relayout() {
|
|
486
295
|
const pool = this.grids.pool;
|
|
487
296
|
const ids = this.ids;
|
|
488
297
|
const density = pool.info(ids.density);
|
|
@@ -490,38 +299,14 @@ class SparseSource {
|
|
|
490
299
|
const old = this.indexBox;
|
|
491
300
|
const moved = b.min.some((v, a) => v !== old.min[a]) || b.max.some((v, a) => v !== old.max[a]);
|
|
492
301
|
this.indexBox = b;
|
|
493
|
-
this.texels =
|
|
494
|
-
|
|
495
|
-
this.boxToSource = new Float32Array([sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, b.min[0] - 0.5 + 0.5 * sx, b.min[1] - 0.5 + 0.5 * sy, b.min[2] - 0.5 + 0.5 * sz, 1]);
|
|
302
|
+
this.texels = texelsOf(b);
|
|
303
|
+
this.boxToSource = boxToSourceOf(b, this.texels);
|
|
496
304
|
this.bbox = worldBox(b, density.indexToWorld);
|
|
497
305
|
const auxBox = (id) => (id === undefined ? null : { min: [...pool.info(id).indexBBox.min], max: [...pool.info(id).indexBBox.max] });
|
|
498
306
|
this.auxBoxes = { mask: auxBox(ids.mask), albedo: auxBox(Array.isArray(ids.albedo) ? ids.albedo[0] : ids.albedo), emission: auxBox(ids.emission) };
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (moved && previous?.gpu) {
|
|
502
|
-
this.pyramid = this.gpuPyramid(b, ids.density);
|
|
503
|
-
this.lodLevels = this.pyramid.lodLevels;
|
|
504
|
-
this.poolRevisionSeen = -1;
|
|
505
|
-
}
|
|
506
|
-
this.gpuBytes = this.measure();
|
|
307
|
+
if (moved)
|
|
308
|
+
this.lodLevels = this.#lodLevelsOf(this.texels);
|
|
507
309
|
this.layoutUpdates++;
|
|
508
|
-
for (const apply of this.layoutListeners)
|
|
509
|
-
apply();
|
|
510
|
-
// After the uniforms point at the new textures, the old ones go, but not yet: three r187's texture.dispose()
|
|
511
|
-
// destroys the GPUTexture at once, and a pass this render already recorded (not submitted yet) may bind them.
|
|
512
|
-
// Renders submit in the task that records them, so wait past this task, then for the queue's submitted work.
|
|
513
|
-
if (previous !== this.pyramid && previous) {
|
|
514
|
-
const retire = () => {
|
|
515
|
-
previous.gpu?.destroy();
|
|
516
|
-
previous.map.dispose();
|
|
517
|
-
previous.mip?.dispose();
|
|
518
|
-
};
|
|
519
|
-
const device = this.grids.pool.device;
|
|
520
|
-
if (device?.queue)
|
|
521
|
-
setTimeout(() => void device.queue.onSubmittedWorkDone().then(retire, retire), 0);
|
|
522
|
-
else
|
|
523
|
-
retire();
|
|
524
|
-
}
|
|
525
310
|
}
|
|
526
311
|
/**
|
|
527
312
|
* Content version: the newest `imageRevision` of the channel grids (K3.2a), so a `pool.replace` (a
|
|
@@ -533,14 +318,14 @@ class SparseSource {
|
|
|
533
318
|
// resident and the boxes were re-read), so a VDBFrameVolume re-reads its box and the uniforms then.
|
|
534
319
|
if (this.followImage) {
|
|
535
320
|
this.syncLayout();
|
|
536
|
-
return this
|
|
321
|
+
return this.#layoutRevision;
|
|
537
322
|
}
|
|
538
323
|
const pool = this.grids.pool;
|
|
539
324
|
if (typeof pool.revision !== "number")
|
|
540
325
|
return 0;
|
|
541
|
-
if (pool.revision !== this
|
|
326
|
+
if (pool.revision !== this.#versionSeen.poolRevision) {
|
|
542
327
|
let value = 0;
|
|
543
|
-
for (const id of this
|
|
328
|
+
for (const id of this.#poolIds) {
|
|
544
329
|
try {
|
|
545
330
|
value = Math.max(value, pool.info(id).imageRevision ?? 0);
|
|
546
331
|
}
|
|
@@ -548,38 +333,16 @@ class SparseSource {
|
|
|
548
333
|
// A removed grid: keep the others' revision.
|
|
549
334
|
}
|
|
550
335
|
}
|
|
551
|
-
this
|
|
552
|
-
}
|
|
553
|
-
return this.versionSeen.value;
|
|
554
|
-
}
|
|
555
|
-
refreshPyramid() {
|
|
556
|
-
this.syncLayout();
|
|
557
|
-
const gpu = this.pyramid?.gpu;
|
|
558
|
-
if (!gpu)
|
|
559
|
-
return false;
|
|
560
|
-
// Cheap test first: the pool's revision moves on any change; the grid's imageRevision tells whether this one did.
|
|
561
|
-
const pool = this.grids.pool;
|
|
562
|
-
if (pool.revision === this.poolRevisionSeen)
|
|
563
|
-
return false;
|
|
564
|
-
const device = pool.device;
|
|
565
|
-
const encoder = device.createCommandEncoder({ label: "vdbSparseSource pyramid" });
|
|
566
|
-
if (!gpu.update(encoder)) {
|
|
567
|
-
// Not resident yet (the update that writes it is still to come): look again next time.
|
|
568
|
-
if (!gpu.stale)
|
|
569
|
-
this.poolRevisionSeen = pool.revision;
|
|
570
|
-
return false;
|
|
336
|
+
this.#versionSeen = { poolRevision: pool.revision, value };
|
|
571
337
|
}
|
|
572
|
-
|
|
573
|
-
this.poolRevisionSeen = pool.revision;
|
|
574
|
-
this.pyramidBuilds++;
|
|
575
|
-
return true;
|
|
338
|
+
return this.#versionSeen.value;
|
|
576
339
|
}
|
|
577
340
|
refreshStats() {
|
|
578
|
-
if (this
|
|
579
|
-
return this
|
|
341
|
+
if (this.#statsReadback)
|
|
342
|
+
return this.#statsReadback;
|
|
580
343
|
const pool = this.grids.pool;
|
|
581
344
|
// Cheap test first (once per render): the pool's revision moves on any change.
|
|
582
|
-
if (typeof pool.revision !== "number" || pool.revision === this
|
|
345
|
+
if (typeof pool.revision !== "number" || pool.revision === this.#statsPoolRevisionSeen || !pool.device || !pool.buffer)
|
|
583
346
|
return Promise.resolve(false);
|
|
584
347
|
let info;
|
|
585
348
|
try {
|
|
@@ -589,8 +352,8 @@ class SparseSource {
|
|
|
589
352
|
return Promise.resolve(false); // removed: keep the last stats
|
|
590
353
|
}
|
|
591
354
|
const revision = info.imageRevision ?? -1;
|
|
592
|
-
if (revision === this
|
|
593
|
-
this
|
|
355
|
+
if (revision === this.#statsRevision) {
|
|
356
|
+
this.#statsPoolRevisionSeen = pool.revision;
|
|
594
357
|
return Promise.resolve(false);
|
|
595
358
|
}
|
|
596
359
|
// Not written yet (the update that writes it is still to come): look again next time.
|
|
@@ -603,268 +366,34 @@ class SparseSource {
|
|
|
603
366
|
encoder.copyBufferToBuffer(buffer, info.imageOffset, staging, 0, bytes);
|
|
604
367
|
device.queue.submit([encoder.finish()]);
|
|
605
368
|
const seen = pool.revision;
|
|
606
|
-
this
|
|
369
|
+
this.#statsReadback = staging
|
|
607
370
|
.mapAsync(0x1) // GPUMapMode.READ
|
|
608
371
|
.then(() => {
|
|
609
372
|
const image = new Uint32Array(staging.getMappedRange().slice(0));
|
|
610
373
|
this.stats = imageStats(image, this.normalize === "clamp01");
|
|
611
|
-
this
|
|
612
|
-
this
|
|
374
|
+
this.#statsRevision = revision;
|
|
375
|
+
this.#statsPoolRevisionSeen = seen;
|
|
613
376
|
this.statsUpdates++;
|
|
614
|
-
for (const apply of this.statsListeners)
|
|
615
|
-
apply();
|
|
616
377
|
return true;
|
|
617
378
|
})
|
|
618
379
|
.catch(() => false)
|
|
619
380
|
.finally(() => {
|
|
620
381
|
staging.destroy();
|
|
621
|
-
this
|
|
382
|
+
this.#statsReadback = null;
|
|
622
383
|
});
|
|
623
|
-
return this
|
|
624
|
-
}
|
|
625
|
-
nodeAverageFn() {
|
|
626
|
-
this.nodeAverageCache ??= wgslFn(NODE_AVERAGE_WGSL, [this.grids.module]);
|
|
627
|
-
return this.nodeAverageCache;
|
|
628
|
-
}
|
|
629
|
-
nodeLodFn() {
|
|
630
|
-
this.nodeLodCache ??= wgslFn(nodeLodWgsl(this.fastTrilinear ? "vdbSampleFast" : "vdbSample"), [this.grids.module, this.nodeAverageFn()]);
|
|
631
|
-
return this.nodeLodCache;
|
|
632
|
-
}
|
|
633
|
-
/** `vdbFrameSample(g, xyz) -> f32`: level 0 (index space) as configured (`fastTrilinear`, `cacheAccessor`). */
|
|
634
|
-
sampleFn() {
|
|
635
|
-
this.sampleCache ??= wgslFn(sampleWgsl(this.fastTrilinear, this.cacheAccessor), (this.cacheAccessor ? [this.grids.module, code(SAMPLE_CACHE_WGSL, [this.grids.module])] : [this.grids.module]));
|
|
636
|
-
return this.sampleCache;
|
|
637
|
-
}
|
|
638
|
-
skipEmptyFn() {
|
|
639
|
-
this.skipCache ??= wgslFn(SKIP_EMPTY_WGSL, [this.grids.module]);
|
|
640
|
-
return this.skipCache;
|
|
641
|
-
}
|
|
642
|
-
createUniforms(p) {
|
|
643
|
-
let densityScale = p.densityScale ?? 1.0;
|
|
644
|
-
let normalize = p.normalizeDensity ?? true;
|
|
645
|
-
const boxUniform = (bx) => bx ? { min: uniform(new THREE.Vector3(...bx.min)), size: uniform(new THREE.Vector3(bx.max[0] - bx.min[0] + 1, bx.max[1] - bx.min[1] + 1, bx.max[2] - bx.min[2] + 1)) } : null;
|
|
646
|
-
const levels = uniform(this.lodLevels);
|
|
647
|
-
// K3.2e: the mean follows the density image (refreshStats, checked once per render, reads a replaced image
|
|
648
|
-
// back). K5.9a: the new mean is applied once, when the readback lands; the render update never writes the
|
|
649
|
-
// value, so a value set per draw (VDBFrameVolume's densityScale, through setVolumeUniforms) stays as set.
|
|
650
|
-
const densityScaleU = uniform(vdbDensityScaleOf(this, densityScale, normalize)).onRenderUpdate(() => {
|
|
651
|
-
this.syncLayout();
|
|
652
|
-
void this.refreshStats();
|
|
653
|
-
return undefined;
|
|
654
|
-
});
|
|
655
|
-
const applyStats = () => {
|
|
656
|
-
densityScaleU.value = vdbDensityScaleOf(this, densityScale, normalize);
|
|
657
|
-
};
|
|
658
|
-
this.statsListeners.add(applyStats);
|
|
659
|
-
const pyr = this.pyramid;
|
|
660
|
-
// G16a: a following source samples its pyramid through texture nodes made here (one pair per uniforms), so a new
|
|
661
|
-
// layout swaps their textures; the atlas node always exists (a 1³ texture when the layout has none).
|
|
662
|
-
const textures = this.followImage && pyr ? { map: texture3D(pyr.map), mip: texture3D(this.atlasTexture()) } : null;
|
|
663
|
-
const u = {
|
|
664
|
-
worldScale: uniform(p.worldScale ?? 1.0),
|
|
665
|
-
gridTexels: uniform(new THREE.Vector3(...this.texels)),
|
|
666
|
-
mipAtlasSize: uniform(new THREE.Vector3(1, 1, 1)),
|
|
667
|
-
maps: { density: null, mask: null, albedo: null, emission: null },
|
|
668
|
-
mipMaps: { density: null, mask: null, albedo: null, emission: null },
|
|
669
|
-
// getSampledLod reads density (and mask) levels; aux channels are level 0 only but report the same.
|
|
670
|
-
mipLevels: { density: levels, mask: levels, albedo: levels, emission: levels },
|
|
671
|
-
baseColor: uniform(new THREE.Color(p.baseColor ?? 0xffffff)),
|
|
672
|
-
extinction: uniform(p.extinction ?? 100.0),
|
|
673
|
-
densityScale: densityScaleU,
|
|
674
|
-
densityCutoff: uniform(p.densityCutoff ?? 0.0),
|
|
675
|
-
emissiveIntensity: uniform(p.emissiveIntensity ?? 1.0),
|
|
676
|
-
temperatureRange: uniform(new THREE.Vector2(...(p.temperatureRange ?? [0.0, 6500.0]))),
|
|
677
|
-
offset3D: uniform(new THREE.Vector3().copy((p.offset3D ?? { x: 0, y: 0, z: 0 }))),
|
|
678
|
-
wrap3D: uniform(p.wrap3D ?? THREE.ClampToEdgeWrapping, "int"),
|
|
679
|
-
boxes: { density: boxUniform(this.indexBox), mask: boxUniform(this.auxBoxes.mask), albedo: boxUniform(this.auxBoxes.albedo), emission: boxUniform(this.auxBoxes.emission) },
|
|
680
|
-
// The GPU pyramid rebuilds (on an image change) from here: once per render that samples it.
|
|
681
|
-
pyramidLevel: pyr?.gpu ? uniform(pyr.level).onRenderUpdate(() => void this.refreshPyramid()) : uniform(pyr?.level ?? 0),
|
|
682
|
-
pyramidLevels: uniform(pyr?.atlas?.levels ?? 0),
|
|
683
|
-
pyramidTexels: uniform(new THREE.Vector3(...(pyr?.dimensions ?? [1, 1, 1]))),
|
|
684
|
-
pyramidAtlasSize: uniform(new THREE.Vector3(...(pyr?.atlas?.dimensions ?? [1, 1, 1]))),
|
|
685
|
-
update: (s, o = {}) => {
|
|
686
|
-
if (s !== this)
|
|
687
|
-
throw bad("these uniforms belong to another source.");
|
|
688
|
-
if (o.densityScale !== undefined)
|
|
689
|
-
densityScale = o.densityScale;
|
|
690
|
-
if (o.normalizeDensity !== undefined)
|
|
691
|
-
normalize = o.normalizeDensity;
|
|
692
|
-
densityScaleU.value = vdbDensityScaleOf(this, densityScale, normalize);
|
|
693
|
-
if (this.followImage)
|
|
694
|
-
applyLayout();
|
|
695
|
-
},
|
|
696
|
-
dispose: () => {
|
|
697
|
-
this.statsListeners.delete(applyStats);
|
|
698
|
-
this.layoutListeners.delete(applyLayout);
|
|
699
|
-
pyramidTextures.delete(u);
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
// G16a: the layout as uniform values (and texture swaps), applied again after every re-read.
|
|
703
|
-
const setBox = (b, bx) => {
|
|
704
|
-
if (!b || !bx)
|
|
705
|
-
return;
|
|
706
|
-
b.min.value.set(...bx.min);
|
|
707
|
-
b.size.value.set(bx.max[0] - bx.min[0] + 1, bx.max[1] - bx.min[1] + 1, bx.max[2] - bx.min[2] + 1);
|
|
708
|
-
};
|
|
709
|
-
const applyLayout = () => {
|
|
710
|
-
u.gridTexels.value.set(...this.texels);
|
|
711
|
-
setBox(u.boxes.density, this.indexBox);
|
|
712
|
-
setBox(u.boxes.mask, this.auxBoxes.mask);
|
|
713
|
-
setBox(u.boxes.albedo, this.auxBoxes.albedo);
|
|
714
|
-
setBox(u.boxes.emission, this.auxBoxes.emission);
|
|
715
|
-
levels.value = this.lodLevels;
|
|
716
|
-
const p = this.pyramid;
|
|
717
|
-
if (!p)
|
|
718
|
-
return;
|
|
719
|
-
u.pyramidLevel.value = p.level;
|
|
720
|
-
u.pyramidLevels.value = p.atlas?.levels ?? 0;
|
|
721
|
-
u.pyramidTexels.value.set(...p.dimensions);
|
|
722
|
-
u.pyramidAtlasSize.value.set(...(p.atlas?.dimensions ?? [1, 1, 1]));
|
|
723
|
-
if (textures) {
|
|
724
|
-
textures.map.value = p.map;
|
|
725
|
-
textures.mip.value = this.atlasTexture();
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
if (this.followImage) {
|
|
729
|
-
this.layoutListeners.add(applyLayout);
|
|
730
|
-
if (textures)
|
|
731
|
-
pyramidTextures.set(u, textures);
|
|
732
|
-
}
|
|
733
|
-
return u;
|
|
734
|
-
}
|
|
735
|
-
createNodes(u0, o) {
|
|
736
|
-
const u = u0;
|
|
737
|
-
if (!u.boxes)
|
|
738
|
-
throw bad("createNodes needs this source's uniforms (vdbVolumeUniforms(source)).");
|
|
739
|
-
const { grids, ids, lod } = this;
|
|
740
|
-
const useMipmaps = o.useMipmaps ?? this.lodLevels > 0;
|
|
741
|
-
const gridUv = vdbGridUv(u);
|
|
742
|
-
const clamp01 = this.normalize === "clamp01";
|
|
743
|
-
// G16a: a following source's LOD range is a uniform (it changes with the layout); otherwise a constant.
|
|
744
|
-
const lodMax = this.followImage ? u.mipLevels.density : float(this.lodLevels);
|
|
745
|
-
const followTextures = this.followImage ? pyramidTextures.get(u) : undefined;
|
|
746
|
-
// uvw → sample index space, clamped to the voxels (his clamp-to-edge).
|
|
747
|
-
const samplePos = (box, uvw) => clamp(box.min.add(uvw.mul(box.size)).sub(0.5), box.min, box.min.add(box.size).sub(1.0));
|
|
748
|
-
const level0 = this.fastTrilinear || this.cacheAccessor ? (id, p) => this.sampleFn()(uint(id), p) : (id, p) => vdbSample(grids, id, p, { space: "index" });
|
|
749
|
-
const densityAt = (uvw, lodIn) => {
|
|
750
|
-
const p = samplePos(u.boxes.density, uvw).toVar();
|
|
751
|
-
if (!useMipmaps || lod === "none")
|
|
752
|
-
return level0(ids.density, p);
|
|
753
|
-
const l = clamp(lodIn, 0.0, lodMax).toVar();
|
|
754
|
-
if (lod === "node-average")
|
|
755
|
-
return this.nodeLodFn()(uint(ids.density), p, l);
|
|
756
|
-
const r = float(0.0).toVar();
|
|
757
|
-
// coarse-pyramid
|
|
758
|
-
const pyr = this.pyramid;
|
|
759
|
-
if (this.followImage && !followTextures)
|
|
760
|
-
throw bad("createNodes needs this source's uniforms (vdbVolumeUniforms(source)).");
|
|
761
|
-
const pyrMap = followTextures ? followTextures.map : texture3D(pyr.map);
|
|
762
|
-
const pyrMip = followTextures ? followTextures.mip : pyr.mip ? texture3D(pyr.mip) : null;
|
|
763
|
-
const { sampleMipmapped } = vdbMipSampler(u.pyramidTexels, u.pyramidAtlasSize);
|
|
764
|
-
const coarse = (rel) => (pyrMip ? sampleMipmapped(pyrMap, pyrMip, u.pyramidLevels, uvw, rel).r : pyrMap.sample(uvw).level(float(0.0)).r);
|
|
765
|
-
// K3.2d: one level-0 call site (each inlines the whole tree walk), shared by the two branches below.
|
|
766
|
-
const fine = float(0.0).toVar();
|
|
767
|
-
If(l.lessThan(u.pyramidLevel), () => {
|
|
768
|
-
fine.assign(level0(ids.density, p));
|
|
769
|
-
});
|
|
770
|
-
If(l.lessThanEqual(0.0), () => {
|
|
771
|
-
r.assign(fine);
|
|
772
|
-
})
|
|
773
|
-
.ElseIf(l.lessThan(u.pyramidLevel), () => {
|
|
774
|
-
r.assign(mix(fine, coarse(float(0.0)), l.div(u.pyramidLevel)));
|
|
775
|
-
})
|
|
776
|
-
.Else(() => {
|
|
777
|
-
r.assign(coarse(l.sub(u.pyramidLevel)));
|
|
778
|
-
});
|
|
779
|
-
return r;
|
|
780
|
-
};
|
|
781
|
-
// L892
|
|
782
|
-
const getLod = (localSize) => max(0.0, log2(localSize.mul(vdbMaxComponent(u.gridTexels))));
|
|
783
|
-
// L914–936: extinction per world unit; the mask at local + 0.5 (no offset or wrap), as his.
|
|
784
|
-
const sampleExtinction = (localPosition, lodIn) => {
|
|
785
|
-
const mask = this.channels.mask ? level0(ids.mask, samplePos(u.boxes.mask, localPosition.add(0.5))) : float(1.0);
|
|
786
|
-
const raw = densityAt(gridUv(localPosition), lodIn);
|
|
787
|
-
const value = (clamp01 ? clamp(raw, 0.0, 1.0) : raw).mul(mask);
|
|
788
|
-
return select(value.greaterThan(u.densityCutoff), value, float(0.0)).mul(u.densityScale).mul(u.extinction).div(u.worldScale);
|
|
789
|
-
};
|
|
790
|
-
// L960–971 (level 0)
|
|
791
|
-
const sampleAlbedo = (localPosition) => {
|
|
792
|
-
if (!this.channels.albedo)
|
|
793
|
-
return u.baseColor.mul(vec3(1.0));
|
|
794
|
-
const p = samplePos(u.boxes.albedo, gridUv(localPosition)).toVar();
|
|
795
|
-
const a = ids.albedo;
|
|
796
|
-
const rgb = Array.isArray(a) ? vec3(level0(a[0], p), level0(a[1], p), level0(a[2], p)) : vec3(level0(a, p));
|
|
797
|
-
return u.baseColor.mul(clamp(rgb, 0.0, 1.0));
|
|
798
|
-
};
|
|
799
|
-
// L990–1017 (level 0), colour via the caller's hook (V24).
|
|
800
|
-
const emissionColor = o.emissionColor ?? (() => vec3(1.0));
|
|
801
|
-
const sampleEmission = (localPosition) => {
|
|
802
|
-
if (!this.channels.emission)
|
|
803
|
-
return vec3(0.0);
|
|
804
|
-
const range = u.temperatureRange;
|
|
805
|
-
const value = level0(ids.emission, samplePos(u.boxes.emission, gridUv(localPosition)));
|
|
806
|
-
const temperature = mix(range.x, range.y, value);
|
|
807
|
-
const power = pow(temperature.div(max(range.y, 1.0)), 4.0);
|
|
808
|
-
const color = select(temperature.greaterThan(0.0), emissionColor(temperature), vec3(0.0));
|
|
809
|
-
return color.mul(power).mul(u.emissiveIntensity);
|
|
810
|
-
};
|
|
811
|
-
// HDDA empty-space query (R1 §4.3 "HDDA gains"): exact only where the bound covers every voxel a
|
|
812
|
-
// sample reads: level 0 (the trilinear 2x2x2 cell block), or a coarse level whose taps reach at
|
|
813
|
-
// most 8 voxels past the cell (dilated 3x3x3 block): node averages up to level 3, pyramid bases
|
|
814
|
-
// up to level 2. Wrapping or an offset moves samples off the ray's cells: no skipping then.
|
|
815
|
-
const skipEmpty = (origin, direction, t0, t1, lodIn) => {
|
|
816
|
-
const box = u.boxes.density;
|
|
817
|
-
const l = useMipmaps && lod !== "none" ? clamp(lodIn, 0.0, lodMax) : float(0.0);
|
|
818
|
-
const dilate = int(0).toVar();
|
|
819
|
-
// Cost rule (K3.2 A/B): a walk visits 8³ cells at 8 node lookups each, so it only pays while samples are at
|
|
820
|
-
// most one cell apart (the march's lod ≤ 3, i.e. steps ≤ 8 voxels); sparser marches sample everything.
|
|
821
|
-
const enabled = u.wrap3D
|
|
822
|
-
.equal(int(THREE.ClampToEdgeWrapping))
|
|
823
|
-
.and(vdbMaxComponent(u.offset3D.abs()).equal(0.0))
|
|
824
|
-
.and(lodIn.lessThanEqual(3.0))
|
|
825
|
-
.toVar();
|
|
826
|
-
if (useMipmaps && lod === "node-average") {
|
|
827
|
-
If(l.greaterThan(0.0), () => {
|
|
828
|
-
dilate.assign(1);
|
|
829
|
-
If(l.greaterThan(3.0), () => {
|
|
830
|
-
enabled.assign(false);
|
|
831
|
-
});
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
else if (useMipmaps && lod === "coarse-pyramid") {
|
|
835
|
-
If(l.greaterThan(0.0), () => {
|
|
836
|
-
dilate.assign(1);
|
|
837
|
-
If(u.pyramidLevel.greaterThan(2.0).or(l.greaterThan(2.0)), () => {
|
|
838
|
-
enabled.assign(false);
|
|
839
|
-
});
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
const result = vec2(t0, 1e30).toVar();
|
|
843
|
-
If(enabled, () => {
|
|
844
|
-
const o2 = box.min.sub(0.5).add(origin.add(0.5).mul(box.size));
|
|
845
|
-
const d2 = direction.mul(box.size);
|
|
846
|
-
// The mask multiplies the density, so with a mask only a zero bound is a safe skip.
|
|
847
|
-
const cutoff = this.channels.mask ? float(0.0) : max(u.densityCutoff, 0.0);
|
|
848
|
-
result.assign(this.skipEmptyFn()(uint(ids.density), o2, d2, t0, t1, cutoff, dilate.toUint()));
|
|
849
|
-
});
|
|
850
|
-
return result;
|
|
851
|
-
};
|
|
852
|
-
return { getLod, sampleExtinction, sampleAlbedo, sampleEmission, ...vdbBoxNodes, skipEmpty };
|
|
384
|
+
return this.#statsReadback;
|
|
853
385
|
}
|
|
854
386
|
dispose() {
|
|
855
|
-
this.pyramid?.gpu?.destroy();
|
|
856
|
-
this.pyramid?.map.dispose();
|
|
857
|
-
this.pyramid?.mip?.dispose();
|
|
858
|
-
this.emptyAtlas?.dispose();
|
|
859
|
-
this.layoutListeners.clear();
|
|
860
|
-
this.statsListeners.clear();
|
|
861
387
|
}
|
|
862
388
|
}
|
|
863
389
|
/**
|
|
864
390
|
* A sparse volume source over pool grids (see the file comment). `grids` must be a `VDBGridNode`
|
|
865
391
|
* made with profile `'march'` and helpers `['cellBoundTrilinear', 'hddaCellEnd']` (+ `'nodeAverage'`
|
|
866
|
-
* for that LOD). The source holds no
|
|
867
|
-
*
|
|
392
|
+
* for that LOD). The source holds no GPU object (the pool's grid buffer is the pool's).
|
|
393
|
+
*
|
|
394
|
+
* @param grids A `VDBGridNode` with profile `march` and the helpers the LOD needs.
|
|
395
|
+
* @param ids The pool ids of the density grid and optional channels.
|
|
396
|
+
* @param options LOD, normalization, boxes, pyramid and sampling options.
|
|
868
397
|
*/
|
|
869
398
|
export function vdbSparseSource(grids, ids, options = {}) {
|
|
870
399
|
if (!grids || typeof grids !== "object" || !("module" in grids))
|