@pmndrs/vdb 0.0.0-stage → 0.1.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 +137 -0
- package/LICENSE +21 -0
- package/README.md +448 -2
- package/THIRD_PARTY_NOTICES.md +147 -0
- package/dist/core/compute/atlas.d.ts +94 -0
- package/dist/core/compute/atlas.js +98 -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/pyramid.d.ts +105 -0
- package/dist/core/compute/pyramid.js +455 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +115 -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 +71 -0
- package/dist/core/compute/stats.js +188 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +23 -0
- package/dist/core/compute/value-transform.js +58 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +11 -0
- package/dist/core/errors.js +9 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +27 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +15 -0
- package/dist/core/internal.js +15 -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 +82 -0
- package/dist/core/pool/image-header.js +175 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +164 -0
- package/dist/core/pool/layout.js +267 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +40 -0
- package/dist/core/pool/limits.js +79 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +279 -0
- package/dist/core/pool/pool.js +953 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/source/dense.d.ts +19 -0
- package/dist/core/source/dense.js +287 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/types.d.ts +63 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/types.d.ts +28 -0
- package/dist/core/types.js +28 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +41 -0
- package/dist/core/wgsl/api.js +463 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +82 -0
- package/dist/core/wgsl/generate.js +505 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +54 -0
- package/dist/core/wgsl/level-set.js +194 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -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 +104 -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 +162 -0
- package/dist/three/coarse-first.js +187 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +63 -0
- package/dist/three/compute.js +56 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +59 -0
- package/dist/three/device.js +59 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/blackbody.d.ts +42 -0
- package/dist/three/frame/blackbody.js +74 -0
- package/dist/three/frame/blackbody.js.map +1 -0
- package/dist/three/frame/chunks.d.ts +157 -0
- package/dist/three/frame/chunks.js +559 -0
- package/dist/three/frame/chunks.js.map +1 -0
- package/dist/three/frame/density-material.d.ts +53 -0
- package/dist/three/frame/density-material.js +353 -0
- package/dist/three/frame/density-material.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +167 -0
- package/dist/three/frame/emission-light.js +655 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/environment-grid-material.d.ts +21 -0
- package/dist/three/frame/environment-grid-material.js +184 -0
- package/dist/three/frame/environment-grid-material.js.map +1 -0
- package/dist/three/frame/environment-material.d.ts +22 -0
- package/dist/three/frame/environment-material.js +87 -0
- package/dist/three/frame/environment-material.js.map +1 -0
- package/dist/three/frame/grid-mip-material.d.ts +12 -0
- package/dist/three/frame/grid-mip-material.js +61 -0
- package/dist/three/frame/grid-mip-material.js.map +1 -0
- package/dist/three/frame/index.d.ts +39 -0
- package/dist/three/frame/index.js +35 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/inject-material.d.ts +56 -0
- package/dist/three/frame/inject-material.js +424 -0
- package/dist/three/frame/inject-material.js.map +1 -0
- package/dist/three/frame/integrate-material.d.ts +26 -0
- package/dist/three/frame/integrate-material.js +198 -0
- package/dist/three/frame/integrate-material.js.map +1 -0
- package/dist/three/frame/layout.d.ts +34 -0
- package/dist/three/frame/layout.js +48 -0
- package/dist/three/frame/layout.js.map +1 -0
- package/dist/three/frame/lighting-material.d.ts +41 -0
- package/dist/three/frame/lighting-material.js +257 -0
- package/dist/three/frame/lighting-material.js.map +1 -0
- package/dist/three/frame/lights.d.ts +11 -0
- package/dist/three/frame/lights.js +16 -0
- package/dist/three/frame/lights.js.map +1 -0
- package/dist/three/frame/medium.d.ts +21 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/neural.d.ts +14 -0
- package/dist/three/frame/neural.js +105 -0
- package/dist/three/frame/neural.js.map +1 -0
- package/dist/three/frame/phase.d.ts +44 -0
- package/dist/three/frame/phase.js +80 -0
- package/dist/three/frame/phase.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +493 -0
- package/dist/three/frame/renderer.js +1498 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/shadow-density-material.d.ts +30 -0
- package/dist/three/frame/shadow-density-material.js +123 -0
- package/dist/three/frame/shadow-density-material.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +18 -0
- package/dist/three/frame/spectrum.js +36 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/temporal-material.d.ts +29 -0
- package/dist/three/frame/temporal-material.js +152 -0
- package/dist/three/frame/temporal-material.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +65 -0
- package/dist/three/frame/three-internals.js +150 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/transmittance-material.d.ts +31 -0
- package/dist/three/frame/transmittance-material.js +315 -0
- package/dist/three/frame/transmittance-material.js.map +1 -0
- package/dist/three/frame/view.d.ts +103 -0
- package/dist/three/frame/view.js +296 -0
- package/dist/three/frame/view.js.map +1 -0
- package/dist/three/frame/volume-shadow-material.d.ts +36 -0
- package/dist/three/frame/volume-shadow-material.js +128 -0
- package/dist/three/frame/volume-shadow-material.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +153 -0
- package/dist/three/frame/volume-shadows.js +756 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +172 -0
- package/dist/three/frame/volume.js +256 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +196 -0
- package/dist/three/grid-node.js +510 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +43 -0
- package/dist/three/index.js +49 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +14 -0
- package/dist/three/internal.js +14 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +112 -0
- package/dist/three/level-set-material.js +204 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/material.d.ts +194 -0
- package/dist/three/material.js +359 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +84 -0
- package/dist/three/points.js +130 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sequence.d.ts +317 -0
- package/dist/three/sequence.js +526 -0
- package/dist/three/sequence.js.map +1 -0
- package/dist/three/sparse-source.d.ts +233 -0
- package/dist/three/sparse-source.js +876 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +167 -0
- package/dist/three/volume-source.js +353 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +97 -0
- package/dist/tools/cpu/compute.js +218 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +72 -0
- package/dist/tools/cpu/level-set.js +261 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +206 -0
- package/dist/tools/cpu/march.js +575 -0
- package/dist/tools/cpu/march.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 +31 -0
- package/dist/tools/cpu/read-value.js +336 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
- package/dist/tools/cpu/sample-trilinear.js +156 -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 +1058 -0
- package/dist/tools/cpu/stride-tables.generated.js +1266 -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/errors.d.ts +57 -0
- package/dist/tools/errors.js +58 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +42 -0
- package/dist/tools/frame/blackbody.js +116 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +128 -0
- package/dist/tools/frame/emission.js +282 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +105 -0
- package/dist/tools/frame/environment.js +268 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +302 -0
- package/dist/tools/frame/grid.js +703 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +136 -0
- package/dist/tools/frame/index.js +348 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +61 -0
- package/dist/tools/frame/medium.js +99 -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 +54 -0
- package/dist/tools/frame/mie.js +176 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +9 -0
- package/dist/tools/frame/neural-weights.js +245 -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/pyramid-layout.d.ts +38 -0
- package/dist/tools/frame/pyramid-layout.js +53 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +80 -0
- package/dist/tools/frame/shadows.js +182 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +65 -0
- package/dist/tools/frame/sparse.js +191 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +203 -0
- package/dist/tools/frame/spectral.js +550 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/index.d.ts +106 -0
- package/dist/tools/index.js +88 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +46 -0
- package/dist/tools/internal.js +31 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
- package/dist/tools/nanovdb/build-from-vdb.js +92 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +220 -0
- package/dist/tools/nanovdb/bytes.js +345 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
- package/dist/tools/nanovdb/coarse-first.js +86 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +32 -0
- package/dist/tools/nanovdb/index.js +24 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +24 -0
- package/dist/tools/nanovdb/inspect.js +63 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
- package/dist/tools/nanovdb/leaf-codec.js +320 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +43 -0
- package/dist/tools/nanovdb/quantize.js +277 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +160 -0
- package/dist/tools/nanovdb/resample.js +679 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +145 -0
- package/dist/tools/nanovdb/serialize.js +395 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +58 -0
- package/dist/tools/nanovdb/stats.js +149 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +26 -0
- package/dist/tools/nanovdb/transform.js +91 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +175 -0
- package/dist/tools/nanovdb/tree.js +518 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
- package/dist/tools/nanovdb/write-nvdb.js +210 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +195 -0
- package/dist/tools/nvdb-file.js +606 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +138 -0
- package/dist/tools/nvdb-stream.js +365 -0
- package/dist/tools/nvdb-stream.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.d.ts +56 -0
- package/dist/tools/vdb/blosc.js +231 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +40 -0
- package/dist/tools/vdb/byte-reader.js +139 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +73 -0
- package/dist/tools/vdb/compression.js +249 -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 +147 -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 +3 -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/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 +25 -0
- package/dist/tools/vdb/parse.js +171 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +31 -0
- package/dist/tools/vdb/point-render-data.js +57 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +160 -0
- package/dist/tools/vdb/points.js +794 -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 +138 -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 +116 -0
- package/dist/tools/wvdb/bake.js +311 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +112 -0
- package/dist/tools/wvdb/dense.js +309 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +161 -0
- package/dist/tools/wvdb/format.js +303 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +13 -0
- package/dist/tools/wvdb/index.js +14 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +48 -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 +54 -0
- package/dist/tools/wvdb/nanovdb.js +60 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +260 -0
- package/dist/tools/wvdb/read.js +743 -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 +127 -0
- package/dist/tools/wvdb/write.js +396 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +82 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +85 -0
- package/vendor/pnanovdb.wgsl +1539 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sparse volume source (K3.2, R1 §4.2–4.3): a `VDBGridPool` grid behind the same seam as the
|
|
3
|
+
* dense `.wvdb` source, so `VDBFrameVolume` renders NanoVDB grids.
|
|
4
|
+
*
|
|
5
|
+
* const grids = new VDBGridNode(renderer, pool, { profile: "march", helpers: ["cellBoundTrilinear", "hddaCellEnd", "nodeAverage", "fastTrilinear"] });
|
|
6
|
+
* const source = vdbSparseSource(grids, { density: id }, { lod: "coarse-pyramid", images: { density: image } });
|
|
7
|
+
* const volume = new VDBFrameVolume(source, { extinction: 100 }); // box: the grid's world box
|
|
8
|
+
*
|
|
9
|
+
* Positions are his local unit box [-0.5, 0.5]³; uvw = local + 0.5 (+ offset, wrapped) maps onto the
|
|
10
|
+
* channel grid's index cell box `[min − ½, max + ½]` (voxel centres at integers), so uvw
|
|
11
|
+
* (i + 0.5) / N lands on voxel min + i as on a dense texel centre. The sample position is clamped to
|
|
12
|
+
* `[min, max]` (his clamp-to-edge). Level 0 is the pool's trilinear `vdbSample`; with the node helper
|
|
13
|
+
* `'fastTrilinear'` (recommended, K3.2d) it is `vdbSampleFast` through one accessor per shader invocation
|
|
14
|
+
* (`cacheAccessor`): the same values, 1.5–2× faster on the hardware GPU (docs/archive/handoffs/K3-2d.md).
|
|
15
|
+
*
|
|
16
|
+
* LOD (`lod`, his `sampleExtinction(localPos, lod)` at lod ≥ 1; R1 §4.3):
|
|
17
|
+
* - `'none'`: level 0 always (no prefilter; aliases when a froxel spans many voxels). lodLevels 0.
|
|
18
|
+
* - `'coarse-pyramid'` (default, the K3.2 A/B pick): a dense r16f pyramid from L₀ = max(1, ⌈log2(maxTexels / pyramidMax)⌉):
|
|
19
|
+
* the base is a box resample of the grid, the levels above it his box mip atlas. lod in (0, L₀)
|
|
20
|
+
* blends level 0 toward L₀; lod ≥ L₀ samples the pyramid as his mip atlas. GPU bytes: ~2 B × (base
|
|
21
|
+
* + atlas) texels. Built on the GPU from the pool grid by default (`pyramidBuild: 'gpu'`, K3.2a: the
|
|
22
|
+
* core's `vdbCreateBoxPyramid`, no CPU image needed) and rebuilt when the grid's image changes
|
|
23
|
+
* (`pool.replace`: a sequence frame), checked once per render that samples it; `'cpu'` keeps the
|
|
24
|
+
* K3.2 path (`@pmndrs/vdb/tools` `vdbBoxPyramid` from `images.density`, static). Both give the same
|
|
25
|
+
* texels to ≤ 1 f16 ulp (e2e/k3-pyramid.spec.ts).
|
|
26
|
+
* - `'node-average'`: no extra memory: trilinear over the node averages (`vdbNodeAverage`) at
|
|
27
|
+
* level 3 (leaves, the exact 8³ box mean for fog leaves) and level 7 (lower nodes, the mean of
|
|
28
|
+
* their active voxels); lod in (0, 3) blends level 0 → 3, (3, 7) blends 3 → 7. Needs stats.
|
|
29
|
+
*
|
|
30
|
+
* HDDA: `skipEmpty` lets a march jump samples that are provably 0 (`VDBFrameVolume` `hdda`, default
|
|
31
|
+
* off since D30 / D31: it slowed the shadow march on Apple GPUs; the image is the same either way).
|
|
32
|
+
*
|
|
33
|
+
* Following the image (`followImage`, G16a): the index boxes, world box and pyramid are fixed when the source is
|
|
34
|
+
* made unless it follows the grids' images. Then a `pool.replace` that changes a channel grid's box (a coarse-first
|
|
35
|
+
* swap: the preview, then the full grid in the same id) is re-read from `pool.info` once the new image is resident:
|
|
36
|
+
* new box uniforms, a new GPU pyramid of the new size (its textures swapped into the same texture nodes), the LOD
|
|
37
|
+
* range as a uniform, and a new `version`, which a `VDBFrameVolume` follows with its box. No shader is rebuilt, and the
|
|
38
|
+
* pyramid kernels of every type the `VDBGridNode` decodes are compiled up front.
|
|
39
|
+
*
|
|
40
|
+
* Mask, albedo and emission grids (optional, scalar; albedo may be three grids for RGB) are read at
|
|
41
|
+
* level 0 only. One VDB module per shader: every grid goes through the one `VDBGridNode`.
|
|
42
|
+
*/
|
|
43
|
+
import * as THREE from "three";
|
|
44
|
+
import { type VDBBoxPyramidGpu } from "../core/compute/pyramid.js";
|
|
45
|
+
import { type VDBGridNode, type VDBTslNode } from "./grid-node.js";
|
|
46
|
+
import { type VDBThreeSourceFactory, type VDBVolumeUniforms } from "./volume-source.js";
|
|
47
|
+
type Vec3 = [number, number, number];
|
|
48
|
+
/** The LOD strategies of the sparse source (R1 §4.3); see the file comment. */
|
|
49
|
+
export type VDBSparseLod = "none" | "coarse-pyramid" | "node-average";
|
|
50
|
+
/** The pool grid ids of the channels. `albedo`: one grey grid or three (RGB). */
|
|
51
|
+
export interface VDBSparseSourceGrids {
|
|
52
|
+
density: number;
|
|
53
|
+
mask?: number;
|
|
54
|
+
albedo?: number | readonly [number, number, number];
|
|
55
|
+
emission?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Inclusive voxel index box. */
|
|
58
|
+
export interface VDBIndexBox {
|
|
59
|
+
min: Vec3;
|
|
60
|
+
max: Vec3;
|
|
61
|
+
}
|
|
62
|
+
/** Options of {@link vdbSparseSource}. */
|
|
63
|
+
export interface VDBSparseSourceOptions {
|
|
64
|
+
/**
|
|
65
|
+
* LOD strategy. Default `'coarse-pyramid'`, the K3.2 A/B's pick (closest to his mips, low flicker, cheap to
|
|
66
|
+
* sample; needs `images.density`); see docs/archive/handoffs/K3-2.md.
|
|
67
|
+
*/
|
|
68
|
+
lod?: VDBSparseLod;
|
|
69
|
+
/** `'coarse-pyramid'`: base level texels on the longest side at most (default 128). */
|
|
70
|
+
pyramidMax?: number;
|
|
71
|
+
/**
|
|
72
|
+
* `'coarse-pyramid'`: where the pyramid is built. `'gpu'` (default, K3.2a): a compute pass over the
|
|
73
|
+
* pool grid on the renderer's device (the core's `vdbCreateBoxPyramid`), rebuilt when the grid's
|
|
74
|
+
* `imageRevision` changes; needs an initialized WebGPURenderer behind the `VDBGridNode`. `'cpu'`:
|
|
75
|
+
* `vdbBoxPyramid` from `images.density` (the K3.2 path, static; the GPU build's twin).
|
|
76
|
+
*/
|
|
77
|
+
pyramidBuild?: "gpu" | "cpu";
|
|
78
|
+
/** `'none'` (default): raw floats. `'clamp01'`: clamp each density sample to [0, 1] (his 8-bit range; parity A/B). */
|
|
79
|
+
normalize?: "none" | "clamp01";
|
|
80
|
+
/** CPU copies of the grid images: the density stats (and a `pyramidBuild: 'cpu'` pyramid) read `density`. */
|
|
81
|
+
images?: {
|
|
82
|
+
density?: Uint32Array;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Density stats (`normalizeDensity` divides by `meanNonZero`). Default: computed from `images.density`.
|
|
86
|
+
* Either way they describe the image at creation; after the density grid's image changes (`pool.replace`,
|
|
87
|
+
* its `imageRevision`) the source reads the new image back from the pool and recomputes them (K3.2e; see
|
|
88
|
+
* `statsUpdates`).
|
|
89
|
+
*/
|
|
90
|
+
stats?: {
|
|
91
|
+
meanNonZero: number;
|
|
92
|
+
max: number;
|
|
93
|
+
activeVoxels: number;
|
|
94
|
+
};
|
|
95
|
+
/** Density index box the unit box covers (default: the grid's index bbox). Aux grids use their own. */
|
|
96
|
+
indexBox?: VDBIndexBox;
|
|
97
|
+
/**
|
|
98
|
+
* K3.6: index boxes the unit box covers in the aux grids (default: each grid's own index bbox). Grids converted
|
|
99
|
+
* from one dense `.wvdb` level (`wvdbDenseToNvdb`) share the texture's box (`textureIndexBox`); pass it so a
|
|
100
|
+
* sparse emission or mask channel lines up with the density (its active bbox is usually smaller).
|
|
101
|
+
*/
|
|
102
|
+
auxIndexBoxes?: Partial<Record<"mask" | "albedo" | "emission", VDBIndexBox>>;
|
|
103
|
+
/** World box (default: the density cell box through the grid's transform, as an AABB). */
|
|
104
|
+
bbox?: [Vec3, Vec3];
|
|
105
|
+
/**
|
|
106
|
+
* K3.2d: level-0 samples through `vdbSampleFast` (the 8 trilinear taps as lower-node child lookups, no
|
|
107
|
+
* tree walk per tap; bit-identical to `vdbSample`). Needs the `VDBGridNode` helper `'fastTrilinear'`.
|
|
108
|
+
* Default: on when the node has the helper.
|
|
109
|
+
*/
|
|
110
|
+
fastTrilinear?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* K3.2d: keep one accessor per shader invocation (a WGSL `var<private>`) across the samples of a march
|
|
113
|
+
* instead of a fresh one per sample, so consecutive samples reuse its cached leaf/lower/upper nodes. The
|
|
114
|
+
* values are the same either way. Default true (the K3.2d hardware A/B: with `fastTrilinear`, whose taps
|
|
115
|
+
* start from the cached lower node, 10–25% off the source passes; alone it changes little).
|
|
116
|
+
*/
|
|
117
|
+
cacheAccessor?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* G16a: follow the grids' images. When a channel grid's `imageRevision` moves (a `pool.replace`, e.g. a
|
|
120
|
+
* `vdbStreamCoarseFirst` swap from the preview to the full grid) and every channel grid is resident again, the
|
|
121
|
+
* source re-reads its index boxes, world box and transform from `pool.info`, rebuilds the coarse pyramid at the
|
|
122
|
+
* new size and bumps `version` (a `VDBFrameVolume` whose box is the source's follows it). Boxes, sizes and LOD
|
|
123
|
+
* levels are uniforms in this mode, so nothing recompiles; give the `VDBGridNode` every grid type the images will
|
|
124
|
+
* have (`types`, e.g. `VDBCoarseFirstEvent.types`): a new image of a type the node does not compile throws
|
|
125
|
+
* `VDB_TYPE_NOT_COMPILED` when the source re-reads it (it would read 0). Default false: the boxes are fixed when the
|
|
126
|
+
* source is made. Not with `indexBox`, `auxIndexBoxes`, `bbox` or `pyramidBuild: 'cpu'`.
|
|
127
|
+
*/
|
|
128
|
+
followImage?: boolean;
|
|
129
|
+
}
|
|
130
|
+
/** The coarse pyramid of a `'coarse-pyramid'` sparse source. */
|
|
131
|
+
export interface VDBSparsePyramid {
|
|
132
|
+
/** Where it was built (see `pyramidBuild`). */
|
|
133
|
+
readonly build: "gpu" | "cpu";
|
|
134
|
+
/** L₀: the base level in level-0 voxels. */
|
|
135
|
+
readonly level: number;
|
|
136
|
+
/** Texels of the base level. */
|
|
137
|
+
readonly dimensions: [number, number, number];
|
|
138
|
+
/** His atlas of the levels above the base (null for a 1³ base); `data` on the CPU path only. */
|
|
139
|
+
readonly atlas: {
|
|
140
|
+
readonly dimensions: [number, number, number];
|
|
141
|
+
readonly levels: number;
|
|
142
|
+
readonly data?: Float32Array;
|
|
143
|
+
} | null;
|
|
144
|
+
/** L₀ + atlas levels. */
|
|
145
|
+
readonly lodLevels: number;
|
|
146
|
+
/** The base level's f32 texels (CPU path only). */
|
|
147
|
+
readonly data?: Float32Array;
|
|
148
|
+
/** r16f textures: the base level and the atlas. */
|
|
149
|
+
readonly map: THREE.Data3DTexture;
|
|
150
|
+
readonly mip: THREE.Data3DTexture | null;
|
|
151
|
+
/** The core GPU pyramid writing into `map` / `mip` (GPU path), else null. */
|
|
152
|
+
readonly gpu: VDBBoxPyramidGpu | null;
|
|
153
|
+
}
|
|
154
|
+
/** The sparse source in three. */
|
|
155
|
+
export interface VDBThreeSparseSource extends VDBThreeSourceFactory {
|
|
156
|
+
readonly grids: VDBGridNode;
|
|
157
|
+
readonly ids: Readonly<VDBSparseSourceGrids>;
|
|
158
|
+
readonly lod: VDBSparseLod;
|
|
159
|
+
readonly normalize: "none" | "clamp01";
|
|
160
|
+
/** The density index box the unit box covers. */
|
|
161
|
+
readonly indexBox: VDBIndexBox;
|
|
162
|
+
/** `'coarse-pyramid'` only: the pyramid and its textures. */
|
|
163
|
+
readonly pyramid: VDBSparsePyramid | null;
|
|
164
|
+
/** K3.2d: level 0 through `vdbSampleFast` (see the option). */
|
|
165
|
+
readonly fastTrilinear: boolean;
|
|
166
|
+
/** K3.2d: one accessor per invocation across samples (see the option). */
|
|
167
|
+
readonly cacheAccessor: boolean;
|
|
168
|
+
/** G16a: the boxes follow the grids' images (see the option). */
|
|
169
|
+
readonly followImage: boolean;
|
|
170
|
+
/** G16a: times the boxes (and the pyramid, if its size changed) were re-read after an image change. */
|
|
171
|
+
readonly layoutUpdates: number;
|
|
172
|
+
/**
|
|
173
|
+
* GPU bytes: the grids' pool capacity, the pyramid textures (r16f) and the GPU build's scratch
|
|
174
|
+
* buffers (kept for rebuilds; 0 on the CPU path).
|
|
175
|
+
*/
|
|
176
|
+
readonly gpuBytes: {
|
|
177
|
+
readonly pool: number;
|
|
178
|
+
readonly pyramid: number;
|
|
179
|
+
readonly pyramidScratch: number;
|
|
180
|
+
};
|
|
181
|
+
/** GPU pyramid builds recorded so far (the first, then one per image change). */
|
|
182
|
+
readonly pyramidBuilds: number;
|
|
183
|
+
/** Density stats (`normalizeDensity`'s `meanNonZero`): of the density image at creation, then of the latest one read back (K3.2e). */
|
|
184
|
+
readonly stats: {
|
|
185
|
+
readonly meanNonZero: number;
|
|
186
|
+
readonly max: number;
|
|
187
|
+
readonly activeVoxels: number;
|
|
188
|
+
};
|
|
189
|
+
/** Times the stats were recomputed after an image change (K3.2e). */
|
|
190
|
+
readonly statsUpdates: number;
|
|
191
|
+
/**
|
|
192
|
+
* K3.2e: if the density grid's image changed since the stats were computed and it is resident, reads it
|
|
193
|
+
* back from the pool (own encoder, submitted) and recomputes the stats (tools' twin of the CPU path);
|
|
194
|
+
* resolves to whether it did. Renders call it themselves (the density scale uniform's render update) and
|
|
195
|
+
* apply the new mean to the uniforms when the readback lands (K5.9a: a per-draw value, e.g. `VDBFrameVolume.densityScale`, is never overwritten); call it after `pool.update` was
|
|
196
|
+
* submitted, as `grids.update()`.
|
|
197
|
+
*/
|
|
198
|
+
refreshStats(): Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* GPU path: rebuilds the pyramid now (own encoder, submitted) if the density grid's image changed
|
|
201
|
+
* since the last build and it is resident; returns whether it did. Renders that sample the pyramid
|
|
202
|
+
* call it themselves; call it after `pool.update` was submitted, as `grids.update()`.
|
|
203
|
+
*/
|
|
204
|
+
refreshPyramid(): boolean;
|
|
205
|
+
/**
|
|
206
|
+
* The source's WGSL helpers as `wgslFn` nodes (including the grid module), for probes and tests:
|
|
207
|
+
* `vdbFrameNodeAverage(g, p, dim) -> f32` (CPU twin `tools` `vdbFrameNodeAverageSample`) and
|
|
208
|
+
* `vdbFrameSkipEmpty(g, o, d, t0, t1, cutoff, dilate) -> vec2f` (twin `vdbFrameSkipEmpty`).
|
|
209
|
+
*/
|
|
210
|
+
nodeAverageFn(): VDBTslNode;
|
|
211
|
+
skipEmptyFn(): VDBTslNode;
|
|
212
|
+
dispose(): void;
|
|
213
|
+
}
|
|
214
|
+
/** Uniforms of a sparse source: his `VDBVolumeUniforms` plus the channel boxes and pyramid sizes. */
|
|
215
|
+
export interface VDBSparseVolumeUniforms extends VDBVolumeUniforms {
|
|
216
|
+
/** Per channel: index min and size of the index box (voxels). */
|
|
217
|
+
readonly boxes: Readonly<Record<"density" | "mask" | "albedo" | "emission", {
|
|
218
|
+
min: VDBTslNode;
|
|
219
|
+
size: VDBTslNode;
|
|
220
|
+
} | null>>;
|
|
221
|
+
readonly pyramidLevel: VDBTslNode;
|
|
222
|
+
readonly pyramidLevels: VDBTslNode;
|
|
223
|
+
readonly pyramidTexels: VDBTslNode;
|
|
224
|
+
readonly pyramidAtlasSize: VDBTslNode;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* A sparse volume source over pool grids (see the file comment). `grids` must be a `VDBGridNode`
|
|
228
|
+
* made with profile `'march'` and helpers `['cellBoundTrilinear', 'hddaCellEnd']` (+ `'nodeAverage'`
|
|
229
|
+
* for that LOD). The source holds no grid buffer of its own (the pool's), only the pyramid textures
|
|
230
|
+
* (and, building on the GPU, the build's scratch buffers).
|
|
231
|
+
*/
|
|
232
|
+
export declare function vdbSparseSource(grids: VDBGridNode, ids: VDBSparseSourceGrids, options?: VDBSparseSourceOptions): VDBThreeSparseSource;
|
|
233
|
+
export {};
|