@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,36 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/frameSpectrum.js (all, 42 lines: wavelengths, Ångström exponents,
|
|
3
|
+
// getFrameExtinctionSpectrum; K3.5: the spectral slot groups, L35–42).
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: TypeScript. Divergences: none.
|
|
6
|
+
/** Wavelengths in nm of the red, green and blue channels. Green is the reference (550 nm). */
|
|
7
|
+
export const frameSpectrumWavelengths = [650.0, 550.0, 450.0];
|
|
8
|
+
const referenceWavelength = frameSpectrumWavelengths[1];
|
|
9
|
+
const toNumber = (value, fallback) => (Number.isFinite(Number(value)) ? Number(value) : fallback);
|
|
10
|
+
/** Measured Ångström exponents (his VDB-116 research; Dubovik 2002, Bodhaine 1999). */
|
|
11
|
+
export const frameAngstromExponents = {
|
|
12
|
+
cloud: 0.0,
|
|
13
|
+
dust: 0.3,
|
|
14
|
+
smoke: 1.8,
|
|
15
|
+
air: 4.09,
|
|
16
|
+
};
|
|
17
|
+
/** A preset name of {@link frameAngstromExponents} or a number. Unknown names give 0 (grey). */
|
|
18
|
+
export const getFrameAngstromExponent = (value) => typeof value === "string" ? (frameAngstromExponents[value] ?? 0.0) : toNumber(value, 0.0);
|
|
19
|
+
/**
|
|
20
|
+
* Extinction scale of each channel: extinctionScale × (wavelength / 550)^−angstromExponent. Only
|
|
21
|
+
* spectral shaders read it (renderer `settings.spectral`); the grey passes keep it for the uniform layout.
|
|
22
|
+
*/
|
|
23
|
+
export const getFrameExtinctionSpectrum = (frameVolume, target) => {
|
|
24
|
+
const scale = frameVolume.extinctionScale;
|
|
25
|
+
const exponent = getFrameAngstromExponent(frameVolume.angstromExponent);
|
|
26
|
+
const channel = (index, value) => Math.max(0.0, toNumber(value, 1.0)) * Math.pow(frameSpectrumWavelengths[index] / referenceWavelength, -exponent);
|
|
27
|
+
return target.set(channel(0, scale?.x), channel(1, scale?.y), channel(2, scale?.z));
|
|
28
|
+
};
|
|
29
|
+
// NOTE Spectral transmittance of 'frame' lighting: light slots in groups. One pass for each group in use.
|
|
30
|
+
// Group 0: sky up, sky down and slot 0. Group g (1 to 3): slots 2g - 1 and 2g. Each direction is marched one time.
|
|
31
|
+
// NOTE A group has two entries of (vec3 x, vec3 y): sky (x up, y down) or a slot (x total, y direct),
|
|
32
|
+
// packed in 3 RGBA targets: (a.x, a.y.r), (a.y.gb, b.x.rg), (b.x.b, b.y).
|
|
33
|
+
export const frameSpectralGroupCount = 4;
|
|
34
|
+
/** Groups in use for the number of light slots in use (0 to 6). */
|
|
35
|
+
export const getFrameSpectralGroups = (slotCount) => 1 + Math.ceil(Math.max(0, slotCount - 1) / 2);
|
|
36
|
+
//# sourceMappingURL=spectrum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectrum.js","sourceRoot":"","sources":["../../../src/three/frame/spectrum.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mGAAmG;AACnG,yEAAyE;AACzE,4GAA4G;AAC5G,0CAA0C;AAI1C,8FAA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AAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF,0GAA0G;AAC1G,mHAAmH;AACnH,sGAAsG;AACtG,0EAA0E;AAC1E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameSpectrum.js (all, 42 lines: wavelengths, Ångström exponents,\n// getFrameExtinctionSpectrum; K3.5: the spectral slot groups, L35–42).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript. Divergences: none.\n\nimport type { Vector3, Vector3Like } from \"three\";\n\n/** Wavelengths in nm of the red, green and blue channels. Green is the reference (550 nm). */\nexport const frameSpectrumWavelengths = [650.0, 550.0, 450.0] as const;\n\nconst referenceWavelength = frameSpectrumWavelengths[1];\n\nconst toNumber = (value: unknown, fallback: number) => (Number.isFinite(Number(value)) ? Number(value) : fallback);\n\n/** Measured Ångström exponents (his VDB-116 research; Dubovik 2002, Bodhaine 1999). */\nexport const frameAngstromExponents: Readonly<Record<string, number>> = {\n cloud: 0.0,\n dust: 0.3,\n smoke: 1.8,\n air: 4.09,\n};\n\n/** A preset name of {@link frameAngstromExponents} or a number. Unknown names give 0 (grey). */\nexport const getFrameAngstromExponent = (value: string | number | undefined) =>\n typeof value === \"string\" ? (frameAngstromExponents[value] ?? 0.0) : toNumber(value, 0.0);\n\n/**\n * Extinction scale of each channel: extinctionScale × (wavelength / 550)^−angstromExponent. Only\n * spectral shaders read it (renderer `settings.spectral`); the grey passes keep it for the uniform layout.\n */\nexport const getFrameExtinctionSpectrum = (\n frameVolume: { extinctionScale?: Vector3Like; angstromExponent?: string | number },\n target: Vector3,\n) => {\n const scale = frameVolume.extinctionScale;\n const exponent = getFrameAngstromExponent(frameVolume.angstromExponent);\n const channel = (index: number, value: unknown) =>\n Math.max(0.0, toNumber(value, 1.0)) * Math.pow(frameSpectrumWavelengths[index]! / referenceWavelength, -exponent);\n\n return target.set(channel(0, scale?.x), channel(1, scale?.y), channel(2, scale?.z));\n};\n\n// NOTE Spectral transmittance of 'frame' lighting: light slots in groups. One pass for each group in use.\n// Group 0: sky up, sky down and slot 0. Group g (1 to 3): slots 2g - 1 and 2g. Each direction is marched one time.\n// NOTE A group has two entries of (vec3 x, vec3 y): sky (x up, y down) or a slot (x total, y direct),\n// packed in 3 RGBA targets: (a.x, a.y.r), (a.y.gb, b.x.rg), (b.x.b, b.y).\nexport const frameSpectralGroupCount = 4;\n\n/** Groups in use for the number of light slots in use (0 to 6). */\nexport const getFrameSpectralGroups = (slotCount: number) => 1 + Math.ceil(Math.max(0, slotCount - 1) / 2);\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NodeMaterial } from "three/webgpu";
|
|
2
|
+
import type { VDBTslNode } from "../grid-node.js";
|
|
3
|
+
import { type FroxelUniforms, type TileUniforms } from "./chunks.js";
|
|
4
|
+
export interface VDBFrameTemporalMaterialOptions {
|
|
5
|
+
froxelUniforms: FroxelUniforms;
|
|
6
|
+
froxelTileUniforms: TileUniforms;
|
|
7
|
+
froxelAreaUniforms: {
|
|
8
|
+
frameAreaRect: VDBTslNode;
|
|
9
|
+
frameAreaSliceStart: VDBTslNode;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare class VDBFrameTemporalMaterial extends NodeMaterial {
|
|
13
|
+
readonly frameCurrentMap: any;
|
|
14
|
+
readonly frameHistoryMap: any;
|
|
15
|
+
readonly frameCurrentAlphaMap: any;
|
|
16
|
+
readonly frameHistoryAlphaMap: any;
|
|
17
|
+
spectral: boolean;
|
|
18
|
+
readonly frameUseHistory: any;
|
|
19
|
+
readonly frameTemporalBlend: any;
|
|
20
|
+
readonly frameCameraMatrixWorld: any;
|
|
21
|
+
readonly framePreviousViewMatrix: any;
|
|
22
|
+
readonly framePreviousProjectionMatrix: any;
|
|
23
|
+
readonly framePreviousRange: any;
|
|
24
|
+
readonly froxelUniforms: FroxelUniforms;
|
|
25
|
+
constructor(o: VDBFrameTemporalMaterialOptions);
|
|
26
|
+
setSpectral(spectral: boolean): void;
|
|
27
|
+
rebuildNodes(): void;
|
|
28
|
+
createFragmentNode(maps: [VDBTslNode, VDBTslNode][], outputs?: VDBTslNode[] | null): VDBTslNode;
|
|
29
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L31–217 (K3.5: with the spectral second
|
|
3
|
+
// atlas target: setSpectral, rebuildNodes, the [current, history] map pairs).
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: TypeScript. Divergences: none.
|
|
6
|
+
/**
|
|
7
|
+
* The temporal pass (R1 §2 step 5): blends this frame's froxels with the previous frames', each
|
|
8
|
+
* froxel centre reprojected into the previous froxel grid (bilinear in the slice, linear between
|
|
9
|
+
* slices), the history clamped to the current froxel's 6 neighbours (less ghosting), and the history
|
|
10
|
+
* weight dropping to 0 for a quarter cell of motion or more. CPU twin of the reprojection:
|
|
11
|
+
* `@pmndrs/vdb/tools` `vdbFrameReproject`. Spectral (K3.5): both atlas targets are blended and
|
|
12
|
+
* clamped with one reprojection.
|
|
13
|
+
*/
|
|
14
|
+
import * as THREE from "three";
|
|
15
|
+
import { NodeMaterial } from "three/webgpu";
|
|
16
|
+
import * as TSL from "three/tsl";
|
|
17
|
+
import { frameFragCoord, frameGetViewPosition, frameLoad, frameSample, frameSliceDepth, frameTileVertex } from "./chunks.js";
|
|
18
|
+
const { Fn, If, clamp, floor, ivec2, length, log, max, min, mix, mod, outputStruct, property, texture, uniform, vec2, vec3, vec4 } = TSL;
|
|
19
|
+
// NOTE Blends the froxels of this frame with the reprojected froxels of the previous frames
|
|
20
|
+
export class VDBFrameTemporalMaterial extends NodeMaterial {
|
|
21
|
+
frameCurrentMap = texture(new THREE.Texture());
|
|
22
|
+
frameHistoryMap = texture(new THREE.Texture());
|
|
23
|
+
// NOTE Renderer settings.spectral: second atlas target (red alpha, blue alpha, 0, green alpha)
|
|
24
|
+
frameCurrentAlphaMap = texture(new THREE.Texture());
|
|
25
|
+
frameHistoryAlphaMap = texture(new THREE.Texture());
|
|
26
|
+
spectral = false;
|
|
27
|
+
frameUseHistory = uniform(0, "int");
|
|
28
|
+
frameTemporalBlend = uniform(0.1);
|
|
29
|
+
frameCameraMatrixWorld = uniform(new THREE.Matrix4());
|
|
30
|
+
framePreviousViewMatrix = uniform(new THREE.Matrix4());
|
|
31
|
+
framePreviousProjectionMatrix = uniform(new THREE.Matrix4());
|
|
32
|
+
framePreviousRange = uniform(new THREE.Vector2(0.1, 1.0));
|
|
33
|
+
froxelUniforms;
|
|
34
|
+
constructor(o) {
|
|
35
|
+
super();
|
|
36
|
+
this.name = "VDBFrameTemporalMaterial";
|
|
37
|
+
this.froxelUniforms = o.froxelUniforms;
|
|
38
|
+
// NOTE Only the froxel area of the volumes. The renderer clears the target first.
|
|
39
|
+
this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);
|
|
40
|
+
this.rebuildNodes();
|
|
41
|
+
this.side = THREE.DoubleSide;
|
|
42
|
+
this.forceSinglePass = true;
|
|
43
|
+
this.depthTest = false;
|
|
44
|
+
this.depthWrite = false;
|
|
45
|
+
this.blending = THREE.NoBlending;
|
|
46
|
+
}
|
|
47
|
+
setSpectral(spectral) {
|
|
48
|
+
if (spectral !== this.spectral) {
|
|
49
|
+
this.spectral = spectral;
|
|
50
|
+
this.rebuildNodes();
|
|
51
|
+
this.needsUpdate = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// NOTE Spectral: both atlas targets are blended and clamped. They share one reprojection.
|
|
55
|
+
rebuildNodes() {
|
|
56
|
+
if (!this.spectral) {
|
|
57
|
+
this.colorNode = null;
|
|
58
|
+
this.outputNode = null;
|
|
59
|
+
this.fragmentNode = this.createFragmentNode([[this.frameCurrentMap, this.frameHistoryMap]]);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const outputs = [property("vec4"), property("vec4")];
|
|
63
|
+
this.fragmentNode = null;
|
|
64
|
+
this.colorNode = this.createFragmentNode([
|
|
65
|
+
[this.frameCurrentMap, this.frameHistoryMap],
|
|
66
|
+
[this.frameCurrentAlphaMap, this.frameHistoryAlphaMap],
|
|
67
|
+
], outputs);
|
|
68
|
+
this.outputNode = outputStruct(...outputs);
|
|
69
|
+
}
|
|
70
|
+
// NOTE maps: [current, history] pairs. outputs: property nodes for each pair, or null for one output.
|
|
71
|
+
createFragmentNode(maps, outputs = null) {
|
|
72
|
+
const { froxelUniforms } = this;
|
|
73
|
+
const { froxelGrid, froxelColumns, froxelAtlasSize } = froxelUniforms;
|
|
74
|
+
const getTileOrigin = (slice) => vec2(mod(slice, froxelColumns), floor(slice.div(froxelColumns))).mul(froxelGrid.xy);
|
|
75
|
+
// NOTE Bilinear filter in the slice. Half a cell inside the tile, then the filter does not read other tiles.
|
|
76
|
+
const sampleHistory = (historyMap, slice, uv) => {
|
|
77
|
+
const cell = clamp(uv.mul(froxelGrid.xy), vec2(0.5), froxelGrid.xy.sub(0.5));
|
|
78
|
+
return frameSample(historyMap, getTileOrigin(slice).add(cell).div(froxelAtlasSize));
|
|
79
|
+
};
|
|
80
|
+
const loadCurrent = (currentMap, texel) => frameLoad(currentMap, ivec2(texel), froxelAtlasSize);
|
|
81
|
+
return Fn(() => {
|
|
82
|
+
const fragCoord = frameFragCoord(froxelAtlasSize).toVar();
|
|
83
|
+
const currents = maps.map(([currentMap]) => loadCurrent(currentMap, fragCoord).toVar());
|
|
84
|
+
const resolved = currents.map((current) => vec4(current).toVar());
|
|
85
|
+
const tile = floor(fragCoord.div(froxelGrid.xy)).toVar();
|
|
86
|
+
const slice = tile.y.mul(froxelColumns).add(tile.x).toVar();
|
|
87
|
+
If(this.frameUseHistory.equal(1).and(slice.lessThan(froxelGrid.z)), () => {
|
|
88
|
+
// NOTE Reproject the froxel center into the froxel grid of the previous frame
|
|
89
|
+
const cell = fragCoord.sub(tile.mul(froxelGrid.xy)).toVar();
|
|
90
|
+
const uv = cell.div(froxelGrid.xy);
|
|
91
|
+
const viewDepth = frameSliceDepth(froxelUniforms, slice.add(0.5).div(froxelGrid.z));
|
|
92
|
+
const worldPosition = this.frameCameraMatrixWorld.mul(vec4(frameGetViewPosition(froxelUniforms, uv, viewDepth), 1.0));
|
|
93
|
+
const previousView = this.framePreviousViewMatrix.mul(worldPosition).toVar();
|
|
94
|
+
const previousClip = this.framePreviousProjectionMatrix.mul(previousView).toVar();
|
|
95
|
+
If(previousClip.w.greaterThan(0.0), () => {
|
|
96
|
+
const previousUv = previousClip.xy.div(previousClip.w).mul(0.5).add(0.5).toVar();
|
|
97
|
+
const previousRange = this.framePreviousRange;
|
|
98
|
+
const previousT = log(max(previousView.z.negate(), 1e-6).div(previousRange.x)).div(log(previousRange.y.div(previousRange.x)));
|
|
99
|
+
const previousSlice = previousT.mul(froxelGrid.z).sub(0.5).toVar();
|
|
100
|
+
const inside = min(previousUv.x, previousUv.y)
|
|
101
|
+
.greaterThanEqual(0.0)
|
|
102
|
+
.and(max(previousUv.x, previousUv.y).lessThanEqual(1.0))
|
|
103
|
+
.and(previousSlice.greaterThanEqual(-0.5))
|
|
104
|
+
.and(previousSlice.lessThanEqual(froxelGrid.z.sub(0.5)));
|
|
105
|
+
If(inside, () => {
|
|
106
|
+
const slice0 = clamp(floor(previousSlice), 0.0, froxelGrid.z.sub(1.0)).toVar();
|
|
107
|
+
const slice1 = min(slice0.add(1.0), froxelGrid.z.sub(1.0));
|
|
108
|
+
const sliceBlend = clamp(previousSlice.sub(slice0), 0.0, 1.0).toVar();
|
|
109
|
+
// NOTE The history counts less as the froxel moves: a quarter of a cell of motion in a frame uses only the
|
|
110
|
+
// current froxel. A still camera moves no froxel, so the history still gathers the jittered samples.
|
|
111
|
+
const motion = length(vec3(previousUv.sub(uv).mul(froxelGrid.xy), previousSlice.sub(slice)));
|
|
112
|
+
const blend = mix(this.frameTemporalBlend, 1.0, clamp(motion.mul(4.0), 0.0, 1.0)).toVar();
|
|
113
|
+
const histories = maps.map(([, historyMap]) => mix(sampleHistory(historyMap, slice0, previousUv), sampleHistory(historyMap, slice1, previousUv), sliceBlend));
|
|
114
|
+
// NOTE Clamp the history to the current neighbors. This limits ghosting of moving volumes.
|
|
115
|
+
const tileOrigin = tile.mul(froxelGrid.xy);
|
|
116
|
+
const cellMax = froxelGrid.xy.sub(1.0);
|
|
117
|
+
const neighborMins = currents.map((current) => vec4(current).toVar());
|
|
118
|
+
const neighborMaxs = currents.map((current) => vec4(current).toVar());
|
|
119
|
+
const addNeighbor = (texel) => {
|
|
120
|
+
maps.forEach(([currentMap], index) => {
|
|
121
|
+
const neighbor = loadCurrent(currentMap, texel).toVar();
|
|
122
|
+
neighborMins[index].assign(min(neighborMins[index], neighbor));
|
|
123
|
+
neighborMaxs[index].assign(max(neighborMaxs[index], neighbor));
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
[
|
|
127
|
+
vec2(max(cell.x.sub(1.0), 0.5), cell.y),
|
|
128
|
+
vec2(min(cell.x.add(1.0), cellMax.x.add(0.5)), cell.y),
|
|
129
|
+
vec2(cell.x, max(cell.y.sub(1.0), 0.5)),
|
|
130
|
+
vec2(cell.x, min(cell.y.add(1.0), cellMax.y.add(0.5))),
|
|
131
|
+
].forEach((neighborCell) => {
|
|
132
|
+
addNeighbor(tileOrigin.add(neighborCell));
|
|
133
|
+
});
|
|
134
|
+
[-1.0, 1.0].forEach((offset) => {
|
|
135
|
+
const neighborSlice = slice.add(offset);
|
|
136
|
+
If(neighborSlice.greaterThanEqual(0.0).and(neighborSlice.lessThan(froxelGrid.z)), () => {
|
|
137
|
+
addNeighbor(getTileOrigin(neighborSlice).add(cell));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
resolved.forEach((value, index) => value.assign(mix(clamp(histories[index], neighborMins[index], neighborMaxs[index]), currents[index], blend)));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
if (outputs) {
|
|
145
|
+
outputs.forEach((output, index) => output.assign(resolved[index]));
|
|
146
|
+
return vec4(0.0);
|
|
147
|
+
}
|
|
148
|
+
return resolved[0];
|
|
149
|
+
})();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=temporal-material.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temporal-material.js","sourceRoot":"","sources":["../../../src/three/frame/temporal-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,oGAAoG;AACpG,gFAAgF;AAChF,4GAA4G;AAC5G,0CAA0C;AAE1C;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAA0C,MAAM,aAAa,CAAC;AAErK,MAAM,EAAE,EAAE,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AC,CAAC;YAEH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;YAED,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameTemporalMaterial.js L31–217 (K3.5: with the spectral second\n// atlas target: setSpectral, rebuildNodes, the [current, history] map pairs).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript. Divergences: none.\n\n/**\n * The temporal pass (R1 §2 step 5): blends this frame's froxels with the previous frames', each\n * froxel centre reprojected into the previous froxel grid (bilinear in the slice, linear between\n * slices), the history clamped to the current froxel's 6 neighbours (less ghosting), and the history\n * weight dropping to 0 for a quarter cell of motion or more. CPU twin of the reprojection:\n * `@pmndrs/vdb/tools` `vdbFrameReproject`. Spectral (K3.5): both atlas targets are blended and\n * clamped with one reprojection.\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { frameFragCoord, frameGetViewPosition, frameLoad, frameSample, frameSliceDepth, frameTileVertex, type FroxelUniforms, type TileUniforms } from \"./chunks.js\";\n\nconst { Fn, If, clamp, floor, ivec2, length, log, max, min, mix, mod, outputStruct, property, texture, uniform, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\nexport interface VDBFrameTemporalMaterialOptions {\n froxelUniforms: FroxelUniforms;\n froxelTileUniforms: TileUniforms;\n froxelAreaUniforms: { frameAreaRect: VDBTslNode; frameAreaSliceStart: VDBTslNode };\n}\n\n// NOTE Blends the froxels of this frame with the reprojected froxels of the previous frames\nexport class VDBFrameTemporalMaterial extends NodeMaterial {\n readonly frameCurrentMap = texture(new THREE.Texture());\n readonly frameHistoryMap = texture(new THREE.Texture());\n // NOTE Renderer settings.spectral: second atlas target (red alpha, blue alpha, 0, green alpha)\n readonly frameCurrentAlphaMap = texture(new THREE.Texture());\n readonly frameHistoryAlphaMap = texture(new THREE.Texture());\n spectral = false;\n readonly frameUseHistory = uniform(0, \"int\");\n readonly frameTemporalBlend = uniform(0.1);\n readonly frameCameraMatrixWorld = uniform(new THREE.Matrix4());\n readonly framePreviousViewMatrix = uniform(new THREE.Matrix4());\n readonly framePreviousProjectionMatrix = uniform(new THREE.Matrix4());\n readonly framePreviousRange = uniform(new THREE.Vector2(0.1, 1.0));\n readonly froxelUniforms: FroxelUniforms;\n\n constructor(o: VDBFrameTemporalMaterialOptions) {\n super();\n\n this.name = \"VDBFrameTemporalMaterial\";\n this.froxelUniforms = o.froxelUniforms;\n\n // NOTE Only the froxel area of the volumes. The renderer clears the target first.\n this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);\n this.rebuildNodes();\n\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.depthTest = false;\n this.depthWrite = false;\n this.blending = THREE.NoBlending;\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.rebuildNodes();\n this.needsUpdate = true;\n }\n }\n\n // NOTE Spectral: both atlas targets are blended and clamped. They share one reprojection.\n rebuildNodes(): void {\n if (!this.spectral) {\n this.colorNode = null;\n this.outputNode = null;\n this.fragmentNode = this.createFragmentNode([[this.frameCurrentMap, this.frameHistoryMap]]);\n\n return;\n }\n\n const outputs = [property(\"vec4\"), property(\"vec4\")];\n\n this.fragmentNode = null;\n this.colorNode = this.createFragmentNode(\n [\n [this.frameCurrentMap, this.frameHistoryMap],\n [this.frameCurrentAlphaMap, this.frameHistoryAlphaMap],\n ],\n outputs,\n );\n this.outputNode = outputStruct(...outputs);\n }\n\n // NOTE maps: [current, history] pairs. outputs: property nodes for each pair, or null for one output.\n createFragmentNode(maps: [VDBTslNode, VDBTslNode][], outputs: VDBTslNode[] | null = null): VDBTslNode {\n const { froxelUniforms } = this;\n const { froxelGrid, froxelColumns, froxelAtlasSize } = froxelUniforms;\n\n const getTileOrigin = (slice: VDBTslNode) => vec2(mod(slice, froxelColumns), floor(slice.div(froxelColumns))).mul(froxelGrid.xy);\n\n // NOTE Bilinear filter in the slice. Half a cell inside the tile, then the filter does not read other tiles.\n const sampleHistory = (historyMap: VDBTslNode, slice: VDBTslNode, uv: VDBTslNode) => {\n const cell = clamp(uv.mul(froxelGrid.xy), vec2(0.5), froxelGrid.xy.sub(0.5));\n\n return frameSample(historyMap, getTileOrigin(slice).add(cell).div(froxelAtlasSize));\n };\n\n const loadCurrent = (currentMap: VDBTslNode, texel: VDBTslNode) => frameLoad(currentMap, ivec2(texel), froxelAtlasSize);\n\n return Fn(() => {\n const fragCoord = frameFragCoord(froxelAtlasSize).toVar();\n const currents = maps.map(([currentMap]) => loadCurrent(currentMap, fragCoord).toVar());\n const resolved = currents.map((current) => vec4(current).toVar());\n\n const tile = floor(fragCoord.div(froxelGrid.xy)).toVar();\n const slice = tile.y.mul(froxelColumns).add(tile.x).toVar();\n\n If(this.frameUseHistory.equal(1).and(slice.lessThan(froxelGrid.z)), () => {\n // NOTE Reproject the froxel center into the froxel grid of the previous frame\n const cell = fragCoord.sub(tile.mul(froxelGrid.xy)).toVar();\n const uv = cell.div(froxelGrid.xy);\n const viewDepth = frameSliceDepth(froxelUniforms, slice.add(0.5).div(froxelGrid.z));\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(frameGetViewPosition(froxelUniforms, uv, viewDepth), 1.0));\n const previousView = this.framePreviousViewMatrix.mul(worldPosition).toVar();\n const previousClip = this.framePreviousProjectionMatrix.mul(previousView).toVar();\n\n If(previousClip.w.greaterThan(0.0), () => {\n const previousUv = previousClip.xy.div(previousClip.w).mul(0.5).add(0.5).toVar();\n const previousRange = this.framePreviousRange;\n const previousT = log(max(previousView.z.negate(), 1e-6).div(previousRange.x)).div(log(previousRange.y.div(previousRange.x)));\n const previousSlice = previousT.mul(froxelGrid.z).sub(0.5).toVar();\n\n const inside = min(previousUv.x, previousUv.y)\n .greaterThanEqual(0.0)\n .and(max(previousUv.x, previousUv.y).lessThanEqual(1.0))\n .and(previousSlice.greaterThanEqual(-0.5))\n .and(previousSlice.lessThanEqual(froxelGrid.z.sub(0.5)));\n\n If(inside, () => {\n const slice0 = clamp(floor(previousSlice), 0.0, froxelGrid.z.sub(1.0)).toVar();\n const slice1 = min(slice0.add(1.0), froxelGrid.z.sub(1.0));\n const sliceBlend = clamp(previousSlice.sub(slice0), 0.0, 1.0).toVar();\n\n // NOTE The history counts less as the froxel moves: a quarter of a cell of motion in a frame uses only the\n // current froxel. A still camera moves no froxel, so the history still gathers the jittered samples.\n const motion = length(vec3(previousUv.sub(uv).mul(froxelGrid.xy), previousSlice.sub(slice)));\n const blend = mix(this.frameTemporalBlend, 1.0, clamp(motion.mul(4.0), 0.0, 1.0)).toVar();\n const histories = maps.map(([, historyMap]) => mix(sampleHistory(historyMap, slice0, previousUv), sampleHistory(historyMap, slice1, previousUv), sliceBlend));\n\n // NOTE Clamp the history to the current neighbors. This limits ghosting of moving volumes.\n const tileOrigin = tile.mul(froxelGrid.xy);\n const cellMax = froxelGrid.xy.sub(1.0);\n const neighborMins = currents.map((current) => vec4(current).toVar());\n const neighborMaxs = currents.map((current) => vec4(current).toVar());\n\n const addNeighbor = (texel: VDBTslNode) => {\n maps.forEach(([currentMap], index) => {\n const neighbor = loadCurrent(currentMap, texel).toVar();\n\n neighborMins[index]!.assign(min(neighborMins[index], neighbor));\n neighborMaxs[index]!.assign(max(neighborMaxs[index], neighbor));\n });\n };\n\n [\n vec2(max(cell.x.sub(1.0), 0.5), cell.y),\n vec2(min(cell.x.add(1.0), cellMax.x.add(0.5)), cell.y),\n vec2(cell.x, max(cell.y.sub(1.0), 0.5)),\n vec2(cell.x, min(cell.y.add(1.0), cellMax.y.add(0.5))),\n ].forEach((neighborCell) => {\n addNeighbor(tileOrigin.add(neighborCell));\n });\n\n [-1.0, 1.0].forEach((offset) => {\n const neighborSlice = slice.add(offset);\n\n If(neighborSlice.greaterThanEqual(0.0).and(neighborSlice.lessThan(froxelGrid.z)), () => {\n addNeighbor(getTileOrigin(neighborSlice).add(cell));\n });\n });\n\n resolved.forEach((value, index) => value.assign(mix(clamp(histories[index], neighborMins[index], neighborMaxs[index]), currents[index], blend)));\n });\n });\n });\n\n if (outputs) {\n outputs.forEach((output, index) => output.assign(resolved[index]));\n\n return vec4(0.0);\n }\n\n return resolved[0];\n })();\n }\n}\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K3.6: the three r187 internals the mesh shadows and the emission light rely on (his `FrameVolumeShadows` /
|
|
3
|
+
* `FrameEmissionLight` use them; R1 §3 B bucket, §8), each behind a loud check in the style of `VDBGridNode`'s
|
|
4
|
+
* self-test: a check runs before the first use that could leave three in a bad state, and throws
|
|
5
|
+
* `VDB_ENGINE_MISMATCH` (cached, rethrown on every later use) when three r187's behaviour is not there.
|
|
6
|
+
*
|
|
7
|
+
* 1. `new LightsNode().setLights([light]).setupLightsNode(builder)` returns the light node every material shares
|
|
8
|
+
* for that light (three keeps one per light in a module WeakMap), an `AnalyticLightNode` with a `shadowNode`
|
|
9
|
+
* field and `disposeShadow()`, which drops the shadow node and bumps the node's `version` (the lights cache key
|
|
10
|
+
* includes it, so receivers rebuild). His `resetLightShadow`: a new `shadow.filterNode` only takes effect when
|
|
11
|
+
* the light's shadow node is built again.
|
|
12
|
+
* 2. `ShadowNode` / `PointShadowNode` call `shadow.filterNode(inputs)` at build with `{ depthTexture, shadowCoord,
|
|
13
|
+
* shadow, depthLayer }` (point: `{ depthTexture, bd3D, dp, distance, shadow }`); the default filters are the
|
|
14
|
+
* `three/tsl` exports `BasicShadowFilter`, `PCFShadowFilter`, `VSMShadowFilter` (by `shadowMap.type`; the
|
|
15
|
+
* PCF-soft slot is empty in r187) and `BasicPointShadowFilter` / `PointShadowFilter`. Checked at the filter call.
|
|
16
|
+
* 3. `renderer._nodes.nodeFrame.renderId` is a number that changes once per `render()` (his frame identity; the
|
|
17
|
+
* collector already reads it since K3.1). `NodeUpdateType.RENDER` `updateBefore` runs once per render with
|
|
18
|
+
* `frame.renderer / scene / camera / renderId`.
|
|
19
|
+
* 4. `Light.registerNode(nodeClass)` sets the node class lights of a type are shaded with (`prototype._lightNode`).
|
|
20
|
+
* 5. `renderer._precompilationState` exists (null outside `compileAsync`); light passes skip while it is set, as
|
|
21
|
+
* three's own `ShadowNode.updateBefore`.
|
|
22
|
+
* 6. `RendererUtils.resetRendererState` / `restoreRendererState` save and restore the renderer around nested passes.
|
|
23
|
+
*/
|
|
24
|
+
import * as THREE from "three";
|
|
25
|
+
/** The three revision these checks are written against (the package's three peer range is >=0.187.0 <0.188.0). */
|
|
26
|
+
export declare const VDB_FRAME_THREE_REVISION = "187";
|
|
27
|
+
type LightNodeLike = {
|
|
28
|
+
light?: unknown;
|
|
29
|
+
isAnalyticLightNode?: boolean;
|
|
30
|
+
shadowNode?: unknown;
|
|
31
|
+
disposeShadow?: () => void;
|
|
32
|
+
version?: number;
|
|
33
|
+
};
|
|
34
|
+
/** The shared light node of a light, through LightsNode.setupLightsNode (internal 1). */
|
|
35
|
+
export declare function vdbFrameSharedLightNode(light: THREE.Light): LightNodeLike | null;
|
|
36
|
+
/**
|
|
37
|
+
* Internal 1, self-tested once per page on a throwaway `DirectionalLight` that casts shadows: two `LightsNode`s
|
|
38
|
+
* give the same `AnalyticLightNode` for it; `disposeShadow()` drops a shadow node and bumps `version`.
|
|
39
|
+
* @throws VDBError `VDB_ENGINE_MISMATCH`
|
|
40
|
+
*/
|
|
41
|
+
export declare function vdbFrameCheckLightReset(): void;
|
|
42
|
+
/** The shadow filters of internal 2 (three/tsl exports), checked present. */
|
|
43
|
+
export declare function vdbFrameShadowFilters(): {
|
|
44
|
+
maps: (unknown | null)[];
|
|
45
|
+
basicPoint: (inputs: unknown) => unknown;
|
|
46
|
+
point: (inputs: unknown) => unknown;
|
|
47
|
+
};
|
|
48
|
+
/** Internal 2 at the call: the inputs three passes to `shadow.filterNode`. */
|
|
49
|
+
export declare function vdbFrameCheckFilterInputs(inputs: Record<string, unknown>, point: boolean): void;
|
|
50
|
+
/** Internal 3: the render id of the renderer's node frame. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
51
|
+
export declare function vdbFrameRenderId(renderer: object): number;
|
|
52
|
+
/** Internal 3: `NodeUpdateType.RENDER`. */
|
|
53
|
+
export declare function vdbFrameRenderUpdateType(): string;
|
|
54
|
+
/** Internal 4: registers a light node class. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
55
|
+
export declare function vdbFrameRegisterLightNode(lightClass: typeof THREE.Light, nodeClass: unknown): void;
|
|
56
|
+
/** Internal 5: whether three is precompiling (`compileAsync`). @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
57
|
+
export declare function vdbFramePrecompiling(renderer: object): boolean;
|
|
58
|
+
/** Internal 6. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
59
|
+
export declare function vdbFrameRendererUtils(): {
|
|
60
|
+
resetRendererState(renderer: unknown, state: object): object;
|
|
61
|
+
restoreRendererState(renderer: unknown, state: object): void;
|
|
62
|
+
};
|
|
63
|
+
/** @internal Tests: forget the cached light-reset result. */
|
|
64
|
+
export declare function vdbFrameResetInternalsCache(): void;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K3.6: the three r187 internals the mesh shadows and the emission light rely on (his `FrameVolumeShadows` /
|
|
3
|
+
* `FrameEmissionLight` use them; R1 §3 B bucket, §8), each behind a loud check in the style of `VDBGridNode`'s
|
|
4
|
+
* self-test: a check runs before the first use that could leave three in a bad state, and throws
|
|
5
|
+
* `VDB_ENGINE_MISMATCH` (cached, rethrown on every later use) when three r187's behaviour is not there.
|
|
6
|
+
*
|
|
7
|
+
* 1. `new LightsNode().setLights([light]).setupLightsNode(builder)` returns the light node every material shares
|
|
8
|
+
* for that light (three keeps one per light in a module WeakMap), an `AnalyticLightNode` with a `shadowNode`
|
|
9
|
+
* field and `disposeShadow()`, which drops the shadow node and bumps the node's `version` (the lights cache key
|
|
10
|
+
* includes it, so receivers rebuild). His `resetLightShadow`: a new `shadow.filterNode` only takes effect when
|
|
11
|
+
* the light's shadow node is built again.
|
|
12
|
+
* 2. `ShadowNode` / `PointShadowNode` call `shadow.filterNode(inputs)` at build with `{ depthTexture, shadowCoord,
|
|
13
|
+
* shadow, depthLayer }` (point: `{ depthTexture, bd3D, dp, distance, shadow }`); the default filters are the
|
|
14
|
+
* `three/tsl` exports `BasicShadowFilter`, `PCFShadowFilter`, `VSMShadowFilter` (by `shadowMap.type`; the
|
|
15
|
+
* PCF-soft slot is empty in r187) and `BasicPointShadowFilter` / `PointShadowFilter`. Checked at the filter call.
|
|
16
|
+
* 3. `renderer._nodes.nodeFrame.renderId` is a number that changes once per `render()` (his frame identity; the
|
|
17
|
+
* collector already reads it since K3.1). `NodeUpdateType.RENDER` `updateBefore` runs once per render with
|
|
18
|
+
* `frame.renderer / scene / camera / renderId`.
|
|
19
|
+
* 4. `Light.registerNode(nodeClass)` sets the node class lights of a type are shaded with (`prototype._lightNode`).
|
|
20
|
+
* 5. `renderer._precompilationState` exists (null outside `compileAsync`); light passes skip while it is set, as
|
|
21
|
+
* three's own `ShadowNode.updateBefore`.
|
|
22
|
+
* 6. `RendererUtils.resetRendererState` / `restoreRendererState` save and restore the renderer around nested passes.
|
|
23
|
+
*/
|
|
24
|
+
import * as THREE from "three";
|
|
25
|
+
import { AnalyticLightNode, LightsNode, NodeUpdateType, REVISION, RendererUtils } from "three/webgpu";
|
|
26
|
+
import * as TSL from "three/tsl";
|
|
27
|
+
import { VDBError } from "../../core/errors.js";
|
|
28
|
+
const T = TSL;
|
|
29
|
+
/** The three revision these checks are written against (the package's three peer range is >=0.187.0 <0.188.0). */
|
|
30
|
+
export const VDB_FRAME_THREE_REVISION = "187";
|
|
31
|
+
const mismatch = (what) => new VDBError("VDB_ENGINE_MISMATCH", `three adapter (frame mesh shadows / emission light): three r${REVISION} ${what}. These features use three r187 node-system ` +
|
|
32
|
+
"internals (written against three r187, peer range >=0.187.0 <0.188.0); this three version is unsupported for them.");
|
|
33
|
+
let lightResetResult = null;
|
|
34
|
+
/** The shared light node of a light, through LightsNode.setupLightsNode (internal 1). */
|
|
35
|
+
export function vdbFrameSharedLightNode(light) {
|
|
36
|
+
const nodeData = {};
|
|
37
|
+
const lightsNode = new LightsNode();
|
|
38
|
+
const [node] = lightsNode.setLights([light]).setupLightsNode({ getDataFromNode: () => nodeData, context: { materialLightings: [] } });
|
|
39
|
+
return node ?? null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Internal 1, self-tested once per page on a throwaway `DirectionalLight` that casts shadows: two `LightsNode`s
|
|
43
|
+
* give the same `AnalyticLightNode` for it; `disposeShadow()` drops a shadow node and bumps `version`.
|
|
44
|
+
* @throws VDBError `VDB_ENGINE_MISMATCH`
|
|
45
|
+
*/
|
|
46
|
+
export function vdbFrameCheckLightReset() {
|
|
47
|
+
if (lightResetResult === true)
|
|
48
|
+
return;
|
|
49
|
+
if (lightResetResult)
|
|
50
|
+
throw lightResetResult;
|
|
51
|
+
let error = null;
|
|
52
|
+
const light = new THREE.DirectionalLight();
|
|
53
|
+
light.castShadow = true;
|
|
54
|
+
try {
|
|
55
|
+
if (typeof LightsNode.prototype.setupLightsNode !== "function") {
|
|
56
|
+
error = mismatch("has no LightsNode.setupLightsNode");
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const a = vdbFrameSharedLightNode(light);
|
|
60
|
+
const b = vdbFrameSharedLightNode(light);
|
|
61
|
+
if (!a || !a.isAnalyticLightNode || !(a instanceof AnalyticLightNode) || a.light !== light) {
|
|
62
|
+
error = mismatch("LightsNode.setupLightsNode did not return the light's AnalyticLightNode");
|
|
63
|
+
}
|
|
64
|
+
else if (a !== b) {
|
|
65
|
+
error = mismatch("gave each LightsNode its own node for one light (the shadow reset needs the shared node)");
|
|
66
|
+
}
|
|
67
|
+
else if (!("shadowNode" in a) || a.shadowNode !== null || typeof a.disposeShadow !== "function") {
|
|
68
|
+
error = mismatch("has no AnalyticLightNode.shadowNode / disposeShadow()");
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
let disposed = false;
|
|
72
|
+
const version = a.version ?? 0;
|
|
73
|
+
a.shadowNode = { dispose: () => (disposed = true) };
|
|
74
|
+
a.disposeShadow();
|
|
75
|
+
if (!disposed || a.shadowNode !== null || !((a.version ?? 0) > version)) {
|
|
76
|
+
error = mismatch("AnalyticLightNode.disposeShadow() did not drop the shadow node and bump its version (receivers would keep the old shadow)");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
error = e instanceof VDBError ? e : mismatch(`failed the light-reset self-test (${e instanceof Error ? e.message : String(e)})`);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
light.dispose();
|
|
86
|
+
}
|
|
87
|
+
lightResetResult = error ?? true;
|
|
88
|
+
if (error)
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
/** The shadow filters of internal 2 (three/tsl exports), checked present. */
|
|
92
|
+
export function vdbFrameShadowFilters() {
|
|
93
|
+
const names = ["BasicShadowFilter", "PCFShadowFilter", "VSMShadowFilter", "BasicPointShadowFilter", "PointShadowFilter"];
|
|
94
|
+
for (const name of names)
|
|
95
|
+
if (typeof T[name] !== "function")
|
|
96
|
+
throw mismatch(`has no three/tsl ${name}`);
|
|
97
|
+
return {
|
|
98
|
+
// NOTE In shadow map type order; PCFSoftShadowMap has no filter (three r187 ShadowNode `_shadowFilterLib`)
|
|
99
|
+
maps: [T.BasicShadowFilter, T.PCFShadowFilter, null, T.VSMShadowFilter],
|
|
100
|
+
basicPoint: T.BasicPointShadowFilter,
|
|
101
|
+
point: T.PointShadowFilter,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Internal 2 at the call: the inputs three passes to `shadow.filterNode`. */
|
|
105
|
+
export function vdbFrameCheckFilterInputs(inputs, point) {
|
|
106
|
+
if (!inputs || !inputs.depthTexture || (point ? !inputs.bd3D : !inputs.shadowCoord)) {
|
|
107
|
+
throw mismatch(`called shadow.filterNode without ${point ? "{ depthTexture, bd3D }" : "{ depthTexture, shadowCoord }"}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Internal 3: the render id of the renderer's node frame. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
111
|
+
export function vdbFrameRenderId(renderer) {
|
|
112
|
+
const id = renderer._nodes?.nodeFrame?.renderId;
|
|
113
|
+
if (typeof id !== "number")
|
|
114
|
+
throw mismatch("has no renderer._nodes.nodeFrame.renderId");
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
/** Internal 3: `NodeUpdateType.RENDER`. */
|
|
118
|
+
export function vdbFrameRenderUpdateType() {
|
|
119
|
+
const type = NodeUpdateType.RENDER;
|
|
120
|
+
if (type !== "render")
|
|
121
|
+
throw mismatch("has no NodeUpdateType.RENDER");
|
|
122
|
+
return type;
|
|
123
|
+
}
|
|
124
|
+
/** Internal 4: registers a light node class. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
125
|
+
export function vdbFrameRegisterLightNode(lightClass, nodeClass) {
|
|
126
|
+
const register = lightClass.registerNode;
|
|
127
|
+
if (typeof register !== "function")
|
|
128
|
+
throw mismatch("has no Light.registerNode");
|
|
129
|
+
register.call(lightClass, nodeClass);
|
|
130
|
+
if (lightClass.prototype._lightNode !== nodeClass)
|
|
131
|
+
throw mismatch("Light.registerNode did not set prototype._lightNode");
|
|
132
|
+
}
|
|
133
|
+
/** Internal 5: whether three is precompiling (`compileAsync`). @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
134
|
+
export function vdbFramePrecompiling(renderer) {
|
|
135
|
+
if (!("_precompilationState" in renderer))
|
|
136
|
+
throw mismatch("has no renderer._precompilationState");
|
|
137
|
+
return renderer._precompilationState != null;
|
|
138
|
+
}
|
|
139
|
+
/** Internal 6. @throws VDBError `VDB_ENGINE_MISMATCH` */
|
|
140
|
+
export function vdbFrameRendererUtils() {
|
|
141
|
+
const utils = RendererUtils;
|
|
142
|
+
if (typeof utils.resetRendererState !== "function" || typeof utils.restoreRendererState !== "function")
|
|
143
|
+
throw mismatch("has no RendererUtils.resetRendererState / restoreRendererState");
|
|
144
|
+
return utils;
|
|
145
|
+
}
|
|
146
|
+
/** @internal Tests: forget the cached light-reset result. */
|
|
147
|
+
export function vdbFrameResetInternalsCache() {
|
|
148
|
+
lightResetResult = null;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=three-internals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"three-internals.js","sourceRoot":"","sources":["../../../src/three/frame/three-internals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtG,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,CAAC,GAAG,GAAyC,CAAC;AAEpD,kHAAkH;AAClH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,MAAM,QAAQ,GAAG,CAAC,IAAY,EA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adows` /\n * `FrameEmissionLight` use them; R1 §3 B bucket, §8), each behind a loud check in the style of `VDBGridNode`'s\n * self-test: a check runs before the first use that could leave three in a bad state, and throws\n * `VDB_ENGINE_MISMATCH` (cached, rethrown on every later use) when three r187's behaviour is not there.\n *\n * 1. `new LightsNode().setLights([light]).setupLightsNode(builder)` returns the light node every material shares\n * for that light (three keeps one per light in a module WeakMap), an `AnalyticLightNode` with a `shadowNode`\n * field and `disposeShadow()`, which drops the shadow node and bumps the node's `version` (the lights cache key\n * includes it, so receivers rebuild). His `resetLightShadow`: a new `shadow.filterNode` only takes effect when\n * the light's shadow node is built again.\n * 2. `ShadowNode` / `PointShadowNode` call `shadow.filterNode(inputs)` at build with `{ depthTexture, shadowCoord,\n * shadow, depthLayer }` (point: `{ depthTexture, bd3D, dp, distance, shadow }`); the default filters are the\n * `three/tsl` exports `BasicShadowFilter`, `PCFShadowFilter`, `VSMShadowFilter` (by `shadowMap.type`; the\n * PCF-soft slot is empty in r187) and `BasicPointShadowFilter` / `PointShadowFilter`. Checked at the filter call.\n * 3. `renderer._nodes.nodeFrame.renderId` is a number that changes once per `render()` (his frame identity; the\n * collector already reads it since K3.1). `NodeUpdateType.RENDER` `updateBefore` runs once per render with\n * `frame.renderer / scene / camera / renderId`.\n * 4. `Light.registerNode(nodeClass)` sets the node class lights of a type are shaded with (`prototype._lightNode`).\n * 5. `renderer._precompilationState` exists (null outside `compileAsync`); light passes skip while it is set, as\n * three's own `ShadowNode.updateBefore`.\n * 6. `RendererUtils.resetRendererState` / `restoreRendererState` save and restore the renderer around nested passes.\n */\n\nimport * as THREE from \"three\";\nimport { AnalyticLightNode, LightsNode, NodeUpdateType, REVISION, RendererUtils } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { VDBError } from \"../../core/errors.js\";\n\nconst T = TSL as unknown as Record<string, unknown>;\n\n/** The three revision these checks are written against (the package's three peer range is >=0.187.0 <0.188.0). */\nexport const VDB_FRAME_THREE_REVISION = \"187\";\n\nconst mismatch = (what: string): VDBError =>\n new VDBError(\n \"VDB_ENGINE_MISMATCH\",\n `three adapter (frame mesh shadows / emission light): three r${REVISION} ${what}. These features use three r187 node-system ` +\n \"internals (written against three r187, peer range >=0.187.0 <0.188.0); this three version is unsupported for them.\",\n );\n\nlet lightResetResult: true | VDBError | null = null;\n\ntype LightNodeLike = { light?: unknown; isAnalyticLightNode?: boolean; shadowNode?: unknown; disposeShadow?: () => void; version?: number };\n\n/** The shared light node of a light, through LightsNode.setupLightsNode (internal 1). */\nexport function vdbFrameSharedLightNode(light: THREE.Light): LightNodeLike | null {\n const nodeData = {};\n const lightsNode = new LightsNode() as unknown as { setLights(l: THREE.Light[]): { setupLightsNode(b: unknown): LightNodeLike[] } };\n const [node] = lightsNode.setLights([light]).setupLightsNode({ getDataFromNode: () => nodeData, context: { materialLightings: [] } });\n return node ?? null;\n}\n\n/**\n * Internal 1, self-tested once per page on a throwaway `DirectionalLight` that casts shadows: two `LightsNode`s\n * give the same `AnalyticLightNode` for it; `disposeShadow()` drops a shadow node and bumps `version`.\n * @throws VDBError `VDB_ENGINE_MISMATCH`\n */\nexport function vdbFrameCheckLightReset(): void {\n if (lightResetResult === true) return;\n if (lightResetResult) throw lightResetResult;\n let error: VDBError | null = null;\n const light = new THREE.DirectionalLight();\n light.castShadow = true;\n try {\n if (typeof (LightsNode.prototype as unknown as { setupLightsNode?: unknown }).setupLightsNode !== \"function\") {\n error = mismatch(\"has no LightsNode.setupLightsNode\");\n } else {\n const a = vdbFrameSharedLightNode(light);\n const b = vdbFrameSharedLightNode(light);\n if (!a || !a.isAnalyticLightNode || !(a instanceof AnalyticLightNode) || a.light !== light) {\n error = mismatch(\"LightsNode.setupLightsNode did not return the light's AnalyticLightNode\");\n } else if (a !== b) {\n error = mismatch(\"gave each LightsNode its own node for one light (the shadow reset needs the shared node)\");\n } else if (!(\"shadowNode\" in a) || a.shadowNode !== null || typeof a.disposeShadow !== \"function\") {\n error = mismatch(\"has no AnalyticLightNode.shadowNode / disposeShadow()\");\n } else {\n let disposed = false;\n const version = a.version ?? 0;\n a.shadowNode = { dispose: () => (disposed = true) };\n a.disposeShadow();\n if (!disposed || a.shadowNode !== null || !((a.version ?? 0) > version)) {\n error = mismatch(\"AnalyticLightNode.disposeShadow() did not drop the shadow node and bump its version (receivers would keep the old shadow)\");\n }\n }\n }\n } catch (e) {\n error = e instanceof VDBError ? e : mismatch(`failed the light-reset self-test (${e instanceof Error ? e.message : String(e)})`);\n } finally {\n light.dispose();\n }\n lightResetResult = error ?? true;\n if (error) throw error;\n}\n\n/** The shadow filters of internal 2 (three/tsl exports), checked present. */\nexport function vdbFrameShadowFilters(): { maps: (unknown | null)[]; basicPoint: (inputs: unknown) => unknown; point: (inputs: unknown) => unknown } {\n const names = [\"BasicShadowFilter\", \"PCFShadowFilter\", \"VSMShadowFilter\", \"BasicPointShadowFilter\", \"PointShadowFilter\"];\n for (const name of names) if (typeof T[name] !== \"function\") throw mismatch(`has no three/tsl ${name}`);\n return {\n // NOTE In shadow map type order; PCFSoftShadowMap has no filter (three r187 ShadowNode `_shadowFilterLib`)\n maps: [T.BasicShadowFilter, T.PCFShadowFilter, null, T.VSMShadowFilter],\n basicPoint: T.BasicPointShadowFilter as (inputs: unknown) => unknown,\n point: T.PointShadowFilter as (inputs: unknown) => unknown,\n };\n}\n\n/** Internal 2 at the call: the inputs three passes to `shadow.filterNode`. */\nexport function vdbFrameCheckFilterInputs(inputs: Record<string, unknown>, point: boolean): void {\n if (!inputs || !inputs.depthTexture || (point ? !inputs.bd3D : !inputs.shadowCoord)) {\n throw mismatch(`called shadow.filterNode without ${point ? \"{ depthTexture, bd3D }\" : \"{ depthTexture, shadowCoord }\"}`);\n }\n}\n\n/** Internal 3: the render id of the renderer's node frame. @throws VDBError `VDB_ENGINE_MISMATCH` */\nexport function vdbFrameRenderId(renderer: object): number {\n const id = (renderer as { _nodes?: { nodeFrame?: { renderId?: unknown } } })._nodes?.nodeFrame?.renderId;\n if (typeof id !== \"number\") throw mismatch(\"has no renderer._nodes.nodeFrame.renderId\");\n return id;\n}\n\n/** Internal 3: `NodeUpdateType.RENDER`. */\nexport function vdbFrameRenderUpdateType(): string {\n const type = (NodeUpdateType as unknown as Record<string, string>).RENDER;\n if (type !== \"render\") throw mismatch(\"has no NodeUpdateType.RENDER\");\n return type;\n}\n\n/** Internal 4: registers a light node class. @throws VDBError `VDB_ENGINE_MISMATCH` */\nexport function vdbFrameRegisterLightNode(lightClass: typeof THREE.Light, nodeClass: unknown): void {\n const register = (lightClass as unknown as { registerNode?: (c: unknown) => void }).registerNode;\n if (typeof register !== \"function\") throw mismatch(\"has no Light.registerNode\");\n register.call(lightClass, nodeClass);\n if ((lightClass.prototype as unknown as { _lightNode?: unknown })._lightNode !== nodeClass) throw mismatch(\"Light.registerNode did not set prototype._lightNode\");\n}\n\n/** Internal 5: whether three is precompiling (`compileAsync`). @throws VDBError `VDB_ENGINE_MISMATCH` */\nexport function vdbFramePrecompiling(renderer: object): boolean {\n if (!(\"_precompilationState\" in renderer)) throw mismatch(\"has no renderer._precompilationState\");\n return (renderer as { _precompilationState: unknown })._precompilationState != null;\n}\n\n/** Internal 6. @throws VDBError `VDB_ENGINE_MISMATCH` */\nexport function vdbFrameRendererUtils(): { resetRendererState(renderer: unknown, state: object): object; restoreRendererState(renderer: unknown, state: object): void } {\n const utils = RendererUtils as unknown as Record<string, unknown>;\n if (typeof utils.resetRendererState !== \"function\" || typeof utils.restoreRendererState !== \"function\") throw mismatch(\"has no RendererUtils.resetRendererState / restoreRendererState\");\n return utils as never;\n}\n\n/** @internal Tests: forget the cached light-reset result. */\nexport function vdbFrameResetInternalsCache(): void {\n lightResetResult = null;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NodeMaterial } from "three/webgpu";
|
|
2
|
+
import { type GridUniforms, type LightUniforms } from "./chunks.js";
|
|
3
|
+
import type { VDBFrameNeuralNetwork } from "../../tools/frame/neural.js";
|
|
4
|
+
export declare const frameShadowLightSlots = 6;
|
|
5
|
+
export declare const frameNeuralMipLevels = 5;
|
|
6
|
+
export interface VDBFrameTransmittanceMaterialOptions {
|
|
7
|
+
gridUniforms: GridUniforms;
|
|
8
|
+
lightUniforms: LightUniforms;
|
|
9
|
+
}
|
|
10
|
+
export declare class VDBFrameTransmittanceMaterial extends NodeMaterial {
|
|
11
|
+
readonly frameShadowDensityMap: any;
|
|
12
|
+
readonly frameShadowLightCount: any;
|
|
13
|
+
readonly frameShadowLights: any;
|
|
14
|
+
readonly frameMultipleScattering: any;
|
|
15
|
+
readonly frameScatteringOctaves: any;
|
|
16
|
+
readonly frameTwoSided: any;
|
|
17
|
+
readonly frameShadowAbsorptionMap: any;
|
|
18
|
+
readonly frameSpectralGroup: any;
|
|
19
|
+
readonly frameNeuralMipMaps: any[];
|
|
20
|
+
readonly frameNeuralMipLayouts: any[];
|
|
21
|
+
readonly gridUniforms: GridUniforms;
|
|
22
|
+
readonly lightUniforms: LightUniforms;
|
|
23
|
+
/** The network compiled in (multipleScattering 'neural'), or null. */
|
|
24
|
+
neural: VDBFrameNeuralNetwork | null;
|
|
25
|
+
spectral: boolean;
|
|
26
|
+
constructor(o: VDBFrameTransmittanceMaterialOptions);
|
|
27
|
+
setNeural(neural: VDBFrameNeuralNetwork | null): void;
|
|
28
|
+
setSpectral(spectral: boolean): void;
|
|
29
|
+
buildNodes(): void;
|
|
30
|
+
buildSpectralNodes(): void;
|
|
31
|
+
}
|