@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,315 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/FrameTransmittanceMaterial.js L43–276 (light slots, the grey
|
|
3
|
+
// transmittance pass; K3.4: the octave uniform, the two-sided back march and setNeural / the neural
|
|
4
|
+
// slot light); K3.5: L66–70 (absorption map, slot group uniform), L85–91 (setSpectral), L278–459
|
|
5
|
+
// (buildSpectralNodes: one pass per slot group).
|
|
6
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
7
|
+
// Changes: TypeScript; the network is a parameter of setNeural (VDBFrameNeuralNetwork). Source-free: the pass reads only the shadow grid (and its mips).
|
|
8
|
+
// Divergences: DIVERGES.md (K3.3, K3.4 rows).
|
|
9
|
+
/**
|
|
10
|
+
* The transmittance pass of `'frame'` lighting (R1 §2 step 2): from each voxel of every shadow grid
|
|
11
|
+
* cascade, a march through the combined extinction of all volumes toward each light slot (≤ 6) and
|
|
12
|
+
* the sky up and down, one finest-cascade voxel per step. Output: 4 RGBA16F targets, (sky up total,
|
|
13
|
+
* sky down total, slot 0 total, slot 1 total), (slots 2–5 total), (slots 0–3 direct), (slots 4–5
|
|
14
|
+
* direct, 1, 1). Multiple scattering: diffusion (1D), octaves, 'two-sided' (a back march per slot) or
|
|
15
|
+
* 'neural' (the network's scattered light per slot). CPU twin: `@pmndrs/vdb/tools`
|
|
16
|
+
* `vdbFrameTransmittanceVoxel`.
|
|
17
|
+
*
|
|
18
|
+
* Spectral (K3.5, renderer `settings.spectral`): the grid holds the extinction and the absorption of each
|
|
19
|
+
* channel; the pass runs once per slot group (spectrum.ts `getFrameSpectralGroups`) into the 3 RGBA targets
|
|
20
|
+
* of that group, each direction marched once with the depths of all channels. CPU twin:
|
|
21
|
+
* `vdbFrameSpectralTransmittanceVoxel`.
|
|
22
|
+
*/
|
|
23
|
+
import * as THREE from "three";
|
|
24
|
+
import { NodeMaterial } from "three/webgpu";
|
|
25
|
+
import * as TSL from "three/tsl";
|
|
26
|
+
import { createGridNodes, frameSpectralShadowStep, frameSpectralShadowTransmittance, minComponent, frameFragCoord, frameFullscreenVertex, frameIsotropicDiffusion, frameNoise, frameShadowMarchDepth, frameShadowStep, frameShadowTransmittance, frameTwoSidedDiffusion, } from "./chunks.js";
|
|
27
|
+
import { createNeuralNodes } from "./neural.js";
|
|
28
|
+
const { Break, Fn, If, Loop, abs, bool, dot, float, int, length, max, min, normalize, outputStruct, property, select, texture, uniform, uniformArray, vec2, vec3, vec4 } = TSL;
|
|
29
|
+
// NOTE Light slots: sky up, sky down, then 6 lights. Targets 0 and 1: total transmittance of all slots.
|
|
30
|
+
// NOTE Targets 2 and 3: direct transmittance of the 6 lights. Then the lighting gives the phase only to the direct light.
|
|
31
|
+
// NOTE Scene lights take the first slots. The dominant directional environment light takes the next free slot.
|
|
32
|
+
export const frameShadowLightSlots = 6;
|
|
33
|
+
const maxShadowSteps = 1024;
|
|
34
|
+
// NOTE Mip levels 1 and up of the neural inputs (his frameNeuralLevels − 1)
|
|
35
|
+
export const frameNeuralMipLevels = 5;
|
|
36
|
+
// NOTE Transmittance from each grid voxel to each light, through the combined extinction of all volumes
|
|
37
|
+
export class VDBFrameTransmittanceMaterial extends NodeMaterial {
|
|
38
|
+
frameShadowDensityMap = texture(new THREE.Texture());
|
|
39
|
+
frameShadowLightCount = uniform(0, "int");
|
|
40
|
+
frameShadowLights = uniformArray(Array.from({ length: frameShadowLightSlots }, () => new THREE.Vector4()), "vec4");
|
|
41
|
+
// NOTE Multiple scattering of the renderer settings (phase.ts). 0.0 is single scattering.
|
|
42
|
+
frameMultipleScattering = uniform(0.0);
|
|
43
|
+
// NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.
|
|
44
|
+
frameScatteringOctaves = uniform(new THREE.Vector4());
|
|
45
|
+
// NOTE multipleScattering 'two-sided' (phase.ts): light slots also march away from the light
|
|
46
|
+
frameTwoSided = uniform(0.0);
|
|
47
|
+
// NOTE Renderer settings.spectral: the absorption target of the grid, and the slot group of this pass (spectrum.ts).
|
|
48
|
+
// The renderer draws this pass one time for each group in use, into its own targets.
|
|
49
|
+
frameShadowAbsorptionMap = texture(new THREE.Texture());
|
|
50
|
+
frameSpectralGroup = uniform(0, "int");
|
|
51
|
+
// NOTE multipleScattering 'neural': mips of the last cascade (VDBFrameGridMipMaterial), levels 1 and up,
|
|
52
|
+
// and their atlas layouts (columns, width, height). Five levels for his six-level network.
|
|
53
|
+
frameNeuralMipMaps = Array.from({ length: frameNeuralMipLevels }, () => texture(new THREE.Texture()));
|
|
54
|
+
frameNeuralMipLayouts = Array.from({ length: frameNeuralMipLevels }, () => uniform(new THREE.Vector3(1.0, 1.0, 1.0)));
|
|
55
|
+
gridUniforms;
|
|
56
|
+
lightUniforms;
|
|
57
|
+
/** The network compiled in (multipleScattering 'neural'), or null. */
|
|
58
|
+
neural = null;
|
|
59
|
+
spectral = false;
|
|
60
|
+
constructor(o) {
|
|
61
|
+
super();
|
|
62
|
+
this.name = "VDBFrameTransmittanceMaterial";
|
|
63
|
+
this.gridUniforms = o.gridUniforms;
|
|
64
|
+
this.lightUniforms = o.lightUniforms;
|
|
65
|
+
this.buildNodes();
|
|
66
|
+
this.side = THREE.DoubleSide;
|
|
67
|
+
this.forceSinglePass = true;
|
|
68
|
+
this.depthTest = false;
|
|
69
|
+
this.depthWrite = false;
|
|
70
|
+
this.blending = THREE.NoBlending;
|
|
71
|
+
}
|
|
72
|
+
// NOTE multipleScattering 'neural' (not spectral): scattered light of the light slots from the network
|
|
73
|
+
setNeural(neural) {
|
|
74
|
+
if (neural !== this.neural) {
|
|
75
|
+
this.neural = neural;
|
|
76
|
+
this.buildNodes();
|
|
77
|
+
this.needsUpdate = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
setSpectral(spectral) {
|
|
81
|
+
if (spectral !== this.spectral) {
|
|
82
|
+
this.spectral = spectral;
|
|
83
|
+
this.buildNodes();
|
|
84
|
+
this.needsUpdate = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
buildNodes() {
|
|
88
|
+
if (this.spectral) {
|
|
89
|
+
this.buildSpectralNodes();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { gridUniforms, lightUniforms } = this;
|
|
93
|
+
const grid = createGridNodes(gridUniforms);
|
|
94
|
+
const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount, frameGridAtlasSize } = gridUniforms;
|
|
95
|
+
const { frameSkyDirection } = lightUniforms;
|
|
96
|
+
const ms = this.frameMultipleScattering;
|
|
97
|
+
const octaves = this.frameScatteringOctaves;
|
|
98
|
+
const network = this.neural;
|
|
99
|
+
// NOTE K5.9b: the network nodes are made in the colorNode body, once per build. neuralLight is a
|
|
100
|
+
// Fn().setLayout() (one WGSL function) that reads uniforms and textures, and three r187 caches a layout
|
|
101
|
+
// function's code per backend (NodeBuilder.buildFunctionNode). Made once here, a second build of this
|
|
102
|
+
// material (e.g. renderer.shadowMap.enabled toggling rebuilds every render object) reused code naming the
|
|
103
|
+
// first builder's uniforms: "unresolved value 'nodeUniform0'".
|
|
104
|
+
let neural = null;
|
|
105
|
+
const transmittance0 = property("vec4");
|
|
106
|
+
const transmittance1 = property("vec4");
|
|
107
|
+
const transmittance2 = property("vec4");
|
|
108
|
+
const transmittance3 = property("vec4");
|
|
109
|
+
// NOTE (extinction, absorption)
|
|
110
|
+
const gridExtinction = (worldPosition) => {
|
|
111
|
+
const found = grid.findCascade(worldPosition, int(0));
|
|
112
|
+
const cascade = max(found, int(0));
|
|
113
|
+
return select(found.greaterThanEqual(0), grid.sampleGrid(this.frameShadowDensityMap, cascade, grid.gridUvw(cascade, worldPosition)).rg, vec2(0.0));
|
|
114
|
+
};
|
|
115
|
+
// NOTE Each step moves one voxel of the finest cascade at the probe, on the fastest axis of the direction.
|
|
116
|
+
// The march goes to coarser cascades when it leaves a fine cascade.
|
|
117
|
+
// NOTE opticalDepth (optional float variable) gets the direct optical depth
|
|
118
|
+
const march = (origin, direction, maxDistance, jitter, opticalDepth = null) => {
|
|
119
|
+
const depths = vec3(0.0).toVar();
|
|
120
|
+
const traveled = float(0.0).toVar();
|
|
121
|
+
const probe = vec3(origin).toVar();
|
|
122
|
+
Loop(maxShadowSteps, () => {
|
|
123
|
+
const cascade = grid.findCascade(probe, int(0)).toVar();
|
|
124
|
+
If(cascade.lessThan(0).or(traveled.greaterThanEqual(maxDistance)).or(frameShadowMarchDepth(depths, ms, octaves).greaterThan(6.0)), () => {
|
|
125
|
+
Break();
|
|
126
|
+
});
|
|
127
|
+
const voxelsPerUnit = abs(direction).div(frameGridVoxel.element(cascade));
|
|
128
|
+
const stepLength = min(float(1.0).div(max(voxelsPerUnit.x, max(voxelsPerUnit.y, voxelsPerUnit.z))), maxDistance.sub(traveled)).toVar();
|
|
129
|
+
const sample = gridExtinction(probe.add(direction.mul(stepLength).mul(jitter))).toVar();
|
|
130
|
+
depths.addAssign(frameShadowStep(sample.x, sample.y, ms).mul(stepLength));
|
|
131
|
+
probe.addAssign(direction.mul(stepLength));
|
|
132
|
+
traveled.addAssign(stepLength);
|
|
133
|
+
});
|
|
134
|
+
const transmittance = frameShadowTransmittance(depths, ms, octaves);
|
|
135
|
+
if (opticalDepth) {
|
|
136
|
+
opticalDepth.assign(depths.x);
|
|
137
|
+
}
|
|
138
|
+
// NOTE (direct, total, reduced depth, effective depth). Sky up and down use z and w for the diffusion total.
|
|
139
|
+
return vec4(transmittance.x, transmittance.y, depths.z, depths.y);
|
|
140
|
+
};
|
|
141
|
+
// NOTE Sky up and down are isotropic, and opposite. Diffusion: two-sided total (frameIsotropicDiffusion).
|
|
142
|
+
const skyTotal = (front, back) => select(ms.greaterThan(0.0), frameIsotropicDiffusion(front.z, back.z, front.w), front.y);
|
|
143
|
+
// NOTE Light w is 1.0 for a light direction, 2.0 or more for a light position
|
|
144
|
+
// NOTE Neural: total is direct + the network light. local: the light-independent network inputs of the voxel.
|
|
145
|
+
const lightTransmittance = (slot, worldPosition, jitter, local) => {
|
|
146
|
+
const result = vec4(1.0, 1.0, 0.0, 0.0).toVar();
|
|
147
|
+
If(int(slot).lessThan(this.frameShadowLightCount), () => {
|
|
148
|
+
const light = this.frameShadowLights.element(slot).toVar();
|
|
149
|
+
const isDirection = light.w.lessThan(1.5);
|
|
150
|
+
const toLight = light.xyz.sub(worldPosition).toVar();
|
|
151
|
+
const direction = select(isDirection, normalize(light.xyz), normalize(toLight)).toVar();
|
|
152
|
+
const opticalDepth = neural ? float(0.0).toVar() : null;
|
|
153
|
+
result.assign(march(worldPosition, direction, select(isDirection, float(1e20), length(toLight)), jitter, opticalDepth));
|
|
154
|
+
// NOTE Two-sided: diffusion of the slab between the light side and the far side (frameTwoSidedDiffusion)
|
|
155
|
+
If(this.frameTwoSided.greaterThan(0.5), () => {
|
|
156
|
+
const back = march(worldPosition, direction.negate(), float(1e20), jitter).toVar();
|
|
157
|
+
result.y.assign(frameTwoSidedDiffusion(result.x, result.z, result.w, back.z));
|
|
158
|
+
});
|
|
159
|
+
if (neural && local) {
|
|
160
|
+
result.y.assign(result.x.add(neural.neuralLight(worldPosition, direction, opticalDepth, local[0], local[1])));
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return result;
|
|
164
|
+
};
|
|
165
|
+
this.vertexNode = frameFullscreenVertex;
|
|
166
|
+
this.colorNode = Fn(() => {
|
|
167
|
+
neural = network ? createNeuralNodes(network, gridUniforms, grid, this.frameShadowDensityMap, this.frameNeuralMipMaps, this.frameNeuralMipLayouts) : null;
|
|
168
|
+
const fragCoord = frameFragCoord(frameGridAtlasSize).toVar();
|
|
169
|
+
const cell = grid.getGridCell(fragCoord);
|
|
170
|
+
const cascade = cell.cascade.toVar();
|
|
171
|
+
transmittance0.assign(vec4(1.0));
|
|
172
|
+
transmittance1.assign(vec4(1.0));
|
|
173
|
+
transmittance2.assign(vec4(1.0));
|
|
174
|
+
transmittance3.assign(vec4(1.0));
|
|
175
|
+
If(cascade.lessThan(frameGridCount), () => {
|
|
176
|
+
const voxel = frameGridVoxel.element(cascade).toVar();
|
|
177
|
+
const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade))).toVar();
|
|
178
|
+
// NOTE Skip voxels with no extinction near them. The lighting pass does not read them.
|
|
179
|
+
let nearExtinction = float(0.0);
|
|
180
|
+
for (let i = 0; i < 8; i++) {
|
|
181
|
+
const corner = vec3(i & 1, (i >> 1) & 1, (i >> 2) & 1).sub(0.5);
|
|
182
|
+
nearExtinction = nearExtinction.add(gridExtinction(worldPosition.add(corner.mul(voxel))).x);
|
|
183
|
+
}
|
|
184
|
+
If(nearExtinction.greaterThan(0.0), () => {
|
|
185
|
+
const jitter = frameNoise(gridUniforms.frameJitter, fragCoord).toVar();
|
|
186
|
+
const skyDirection = normalize(frameSkyDirection).toVar();
|
|
187
|
+
const local = neural ? neural.getLocalInputs(worldPosition) : null;
|
|
188
|
+
const lights = Array.from({ length: frameShadowLightSlots }, (_, slot) => lightTransmittance(slot, worldPosition, jitter, local).toVar());
|
|
189
|
+
const skyUp = march(worldPosition, skyDirection, float(1e20), jitter).toVar();
|
|
190
|
+
const skyDown = march(worldPosition, skyDirection.negate(), float(1e20), jitter).toVar();
|
|
191
|
+
transmittance0.assign(vec4(skyTotal(skyUp, skyDown), skyTotal(skyDown, skyUp), lights[0].y, lights[1].y));
|
|
192
|
+
transmittance1.assign(vec4(lights[2].y, lights[3].y, lights[4].y, lights[5].y));
|
|
193
|
+
transmittance2.assign(vec4(lights[0].x, lights[1].x, lights[2].x, lights[3].x));
|
|
194
|
+
transmittance3.assign(vec4(lights[4].x, lights[5].x, 1.0, 1.0));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
return vec4(0.0);
|
|
198
|
+
})();
|
|
199
|
+
this.outputNode = outputStruct(transmittance0, transmittance1, transmittance2, transmittance3);
|
|
200
|
+
}
|
|
201
|
+
// NOTE Spectral: transmittance of each channel for the slots of one group (spectrum.ts).
|
|
202
|
+
// One march for each direction: the grid gives the extinction and absorption of all channels at each step.
|
|
203
|
+
buildSpectralNodes() {
|
|
204
|
+
const { gridUniforms, lightUniforms } = this;
|
|
205
|
+
const grid = createGridNodes(gridUniforms);
|
|
206
|
+
const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount, frameGridAtlasSize } = gridUniforms;
|
|
207
|
+
const { frameSkyDirection } = lightUniforms;
|
|
208
|
+
const ms = this.frameMultipleScattering;
|
|
209
|
+
const octaves = this.frameScatteringOctaves;
|
|
210
|
+
const group = this.frameSpectralGroup;
|
|
211
|
+
const outputs = [property("vec4"), property("vec4"), property("vec4")];
|
|
212
|
+
// NOTE (extinction, absorption) of each channel
|
|
213
|
+
const gridSample = (worldPosition) => {
|
|
214
|
+
const found = grid.findCascade(worldPosition, int(0));
|
|
215
|
+
const cascade = max(found, int(0)).toVar();
|
|
216
|
+
const uvw = grid.gridUvw(cascade, worldPosition).toVar();
|
|
217
|
+
const inside = found.greaterThanEqual(0);
|
|
218
|
+
return {
|
|
219
|
+
extinction: select(inside, grid.sampleGrid(this.frameShadowDensityMap, cascade, uvw).rgb, vec3(0.0)),
|
|
220
|
+
absorption: select(inside, grid.sampleGrid(this.frameShadowAbsorptionMap, cascade, uvw).rgb, vec3(0.0)),
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
// NOTE The same march as the grey pass, with the depths of each channel. Stops when all channels are dark.
|
|
224
|
+
// Returns { x: direct, y: total, z: reduced depth, w: effective depth }. enabled false: no march, 1.0 and depths 0.0.
|
|
225
|
+
const march = (enabled, origin, direction, maxDistance, jitter) => {
|
|
226
|
+
const direct = vec3(1.0).toVar();
|
|
227
|
+
const total = vec3(1.0).toVar();
|
|
228
|
+
const reduced = vec3(0.0).toVar();
|
|
229
|
+
const effective = vec3(0.0).toVar();
|
|
230
|
+
If(enabled, () => {
|
|
231
|
+
const depths = { x: vec3(0.0).toVar(), y: vec3(0.0).toVar(), z: vec3(0.0).toVar() };
|
|
232
|
+
const traveled = float(0.0).toVar();
|
|
233
|
+
const probe = vec3(origin).toVar();
|
|
234
|
+
Loop(maxShadowSteps, () => {
|
|
235
|
+
const cascade = grid.findCascade(probe, int(0)).toVar();
|
|
236
|
+
If(cascade.lessThan(0).or(traveled.greaterThanEqual(maxDistance)).or(minComponent(frameShadowMarchDepth(depths, ms, octaves)).greaterThan(6.0)), () => {
|
|
237
|
+
Break();
|
|
238
|
+
});
|
|
239
|
+
const voxelsPerUnit = abs(direction).div(frameGridVoxel.element(cascade));
|
|
240
|
+
const stepLength = min(float(1.0).div(max(voxelsPerUnit.x, max(voxelsPerUnit.y, voxelsPerUnit.z))), maxDistance.sub(traveled)).toVar();
|
|
241
|
+
const sample = gridSample(probe.add(direction.mul(stepLength).mul(jitter)));
|
|
242
|
+
const step = frameSpectralShadowStep(sample.extinction, sample.absorption, ms);
|
|
243
|
+
depths.x.addAssign(step.x.mul(stepLength));
|
|
244
|
+
depths.y.addAssign(step.y.mul(stepLength));
|
|
245
|
+
depths.z.addAssign(step.z.mul(stepLength));
|
|
246
|
+
probe.addAssign(direction.mul(stepLength));
|
|
247
|
+
traveled.addAssign(stepLength);
|
|
248
|
+
});
|
|
249
|
+
const shadow = frameSpectralShadowTransmittance(depths, ms, octaves);
|
|
250
|
+
direct.assign(shadow.x);
|
|
251
|
+
total.assign(shadow.y);
|
|
252
|
+
reduced.assign(depths.z);
|
|
253
|
+
effective.assign(depths.y);
|
|
254
|
+
});
|
|
255
|
+
return { x: direct, y: total, z: reduced, w: effective };
|
|
256
|
+
};
|
|
257
|
+
// NOTE Sky up and down are isotropic, and opposite. Diffusion: two-sided total of each channel (frameIsotropicDiffusion).
|
|
258
|
+
const skyTotal = (front, back) => select(ms.greaterThan(0.0), frameIsotropicDiffusion(front.z, back.z, front.w), front.y);
|
|
259
|
+
// NOTE March of a light slot. Light w is 1.0 for a light direction, 2.0 or more for a light position.
|
|
260
|
+
const marchSlot = (enabled, slot, worldPosition, jitter) => {
|
|
261
|
+
// NOTE Group 3 has no second slot (slot 6). The clamp keeps the read in the array, the march is off.
|
|
262
|
+
const light = this.frameShadowLights.element(min(slot, int(frameShadowLightSlots - 1))).toVar();
|
|
263
|
+
const isDirection = light.w.lessThan(1.5);
|
|
264
|
+
const toLight = light.xyz.sub(worldPosition).toVar();
|
|
265
|
+
const direction = select(isDirection, normalize(light.xyz), normalize(toLight)).toVar();
|
|
266
|
+
const active = enabled.and(slot.lessThan(this.frameShadowLightCount)).toVar();
|
|
267
|
+
const front = march(active, worldPosition, direction, select(isDirection, float(1e20), length(toLight)), jitter);
|
|
268
|
+
// NOTE Two-sided: diffusion of the slab between the light side and the far side, for each channel
|
|
269
|
+
If(this.frameTwoSided.greaterThan(0.5), () => {
|
|
270
|
+
const back = march(active, worldPosition, direction.negate(), float(1e20), jitter);
|
|
271
|
+
front.y.assign(frameTwoSidedDiffusion(front.x, front.z, front.w, back.z));
|
|
272
|
+
});
|
|
273
|
+
return front;
|
|
274
|
+
};
|
|
275
|
+
this.vertexNode = frameFullscreenVertex;
|
|
276
|
+
this.colorNode = Fn(() => {
|
|
277
|
+
const fragCoord = frameFragCoord(frameGridAtlasSize).toVar();
|
|
278
|
+
const cell = grid.getGridCell(fragCoord);
|
|
279
|
+
const cascade = cell.cascade.toVar();
|
|
280
|
+
outputs.forEach((output) => output.assign(vec4(1.0)));
|
|
281
|
+
If(cascade.lessThan(frameGridCount), () => {
|
|
282
|
+
const voxel = frameGridVoxel.element(cascade).toVar();
|
|
283
|
+
const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade))).toVar();
|
|
284
|
+
// NOTE Skip voxels with no extinction near them. The lighting pass does not read them.
|
|
285
|
+
let nearExtinction = float(0.0);
|
|
286
|
+
for (let i = 0; i < 8; i++) {
|
|
287
|
+
const corner = vec3(i & 1, (i >> 1) & 1, (i >> 2) & 1).sub(0.5);
|
|
288
|
+
nearExtinction = nearExtinction.add(dot(gridSample(worldPosition.add(corner.mul(voxel))).extinction, vec3(1.0)));
|
|
289
|
+
}
|
|
290
|
+
If(nearExtinction.greaterThan(0.0), () => {
|
|
291
|
+
const jitter = frameNoise(gridUniforms.frameJitter, fragCoord).toVar();
|
|
292
|
+
const skyDirection = normalize(frameSkyDirection).toVar();
|
|
293
|
+
const isSkyGroup = group.equal(0).toVar();
|
|
294
|
+
const slotA = group.mul(2).sub(1).toVar();
|
|
295
|
+
// NOTE Group 0: sky up, sky down, slot 0. Other groups: slots 2g - 1 and 2g, and no third march.
|
|
296
|
+
const first = march(isSkyGroup, worldPosition, skyDirection, float(1e20), jitter);
|
|
297
|
+
const second = march(isSkyGroup, worldPosition, skyDirection.negate(), float(1e20), jitter);
|
|
298
|
+
const slotFirst = marchSlot(isSkyGroup.not(), max(slotA, int(0)), worldPosition, jitter);
|
|
299
|
+
const slotSecond = marchSlot(bool(true), select(isSkyGroup, int(0), slotA.add(1)), worldPosition, jitter);
|
|
300
|
+
const a = {
|
|
301
|
+
x: select(isSkyGroup, skyTotal(first, second), slotFirst.y).toVar(),
|
|
302
|
+
y: select(isSkyGroup, skyTotal(second, first), slotFirst.x).toVar(),
|
|
303
|
+
};
|
|
304
|
+
const b = { x: slotSecond.y, y: slotSecond.x };
|
|
305
|
+
outputs[0].assign(vec4(a.x, a.y.x));
|
|
306
|
+
outputs[1].assign(vec4(a.y.y, a.y.z, b.x.x, b.x.y));
|
|
307
|
+
outputs[2].assign(vec4(b.x.z, b.y));
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
return vec4(0.0);
|
|
311
|
+
})();
|
|
312
|
+
this.outputNode = outputStruct(...outputs);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=transmittance-material.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transmittance-material.js","sourceRoot":"","sources":["../../../src/three/frame/transmittance-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gGAAgG;AAChG,sGAAsG;AACtG,mGAAmG;AACnG,mDAAmD;AACnD,4GAA4G;AAC5G,yJAAyJ;AACzJ,8CAA8C;AAE9C;;;;;;;;;;;;;GAaG;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,EACL,eAAe,EACf,uBAAuB,EACvB,gCAAgC,EAChC,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,GAGvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI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AAI,CAAC,UAAU,GAAG,YAAY,CAAC,GAAG,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameTransmittanceMaterial.js L43–276 (light slots, the grey\n// transmittance pass; K3.4: the octave uniform, the two-sided back march and setNeural / the neural\n// slot light); K3.5: L66–70 (absorption map, slot group uniform), L85–91 (setSpectral), L278–459\n// (buildSpectralNodes: one pass per slot group).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the network is a parameter of setNeural (VDBFrameNeuralNetwork). Source-free: the pass reads only the shadow grid (and its mips).\n// Divergences: DIVERGES.md (K3.3, K3.4 rows).\n\n/**\n * The transmittance pass of `'frame'` lighting (R1 §2 step 2): from each voxel of every shadow grid\n * cascade, a march through the combined extinction of all volumes toward each light slot (≤ 6) and\n * the sky up and down, one finest-cascade voxel per step. Output: 4 RGBA16F targets, (sky up total,\n * sky down total, slot 0 total, slot 1 total), (slots 2–5 total), (slots 0–3 direct), (slots 4–5\n * direct, 1, 1). Multiple scattering: diffusion (1D), octaves, 'two-sided' (a back march per slot) or\n * 'neural' (the network's scattered light per slot). CPU twin: `@pmndrs/vdb/tools`\n * `vdbFrameTransmittanceVoxel`.\n *\n * Spectral (K3.5, renderer `settings.spectral`): the grid holds the extinction and the absorption of each\n * channel; the pass runs once per slot group (spectrum.ts `getFrameSpectralGroups`) into the 3 RGBA targets\n * of that group, each direction marched once with the depths of all channels. CPU twin:\n * `vdbFrameSpectralTransmittanceVoxel`.\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 {\n createGridNodes,\n frameSpectralShadowStep,\n frameSpectralShadowTransmittance,\n minComponent,\n frameFragCoord,\n frameFullscreenVertex,\n frameIsotropicDiffusion,\n frameNoise,\n frameShadowMarchDepth,\n frameShadowStep,\n frameShadowTransmittance,\n frameTwoSidedDiffusion,\n type GridUniforms,\n type LightUniforms,\n} from \"./chunks.js\";\nimport { createNeuralNodes } from \"./neural.js\";\nimport type { VDBFrameNeuralNetwork } from \"../../tools/frame/neural.js\";\n\nconst { Break, Fn, If, Loop, abs, bool, dot, float, int, length, max, min, normalize, outputStruct, property, select, texture, uniform, uniformArray, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\n// NOTE Light slots: sky up, sky down, then 6 lights. Targets 0 and 1: total transmittance of all slots.\n// NOTE Targets 2 and 3: direct transmittance of the 6 lights. Then the lighting gives the phase only to the direct light.\n// NOTE Scene lights take the first slots. The dominant directional environment light takes the next free slot.\nexport const frameShadowLightSlots = 6;\n\nconst maxShadowSteps = 1024;\n\n// NOTE Mip levels 1 and up of the neural inputs (his frameNeuralLevels − 1)\nexport const frameNeuralMipLevels = 5;\n\nexport interface VDBFrameTransmittanceMaterialOptions {\n gridUniforms: GridUniforms;\n lightUniforms: LightUniforms;\n}\n\n// NOTE Transmittance from each grid voxel to each light, through the combined extinction of all volumes\nexport class VDBFrameTransmittanceMaterial extends NodeMaterial {\n readonly frameShadowDensityMap = texture(new THREE.Texture());\n readonly frameShadowLightCount = uniform(0, \"int\");\n readonly frameShadowLights = uniformArray(\n Array.from({ length: frameShadowLightSlots }, () => new THREE.Vector4()),\n \"vec4\",\n );\n // NOTE Multiple scattering of the renderer settings (phase.ts). 0.0 is single scattering.\n readonly frameMultipleScattering = uniform(0.0);\n // NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.\n readonly frameScatteringOctaves = uniform(new THREE.Vector4());\n // NOTE multipleScattering 'two-sided' (phase.ts): light slots also march away from the light\n readonly frameTwoSided = uniform(0.0);\n // NOTE Renderer settings.spectral: the absorption target of the grid, and the slot group of this pass (spectrum.ts).\n // The renderer draws this pass one time for each group in use, into its own targets.\n readonly frameShadowAbsorptionMap = texture(new THREE.Texture());\n readonly frameSpectralGroup = uniform(0, \"int\");\n // NOTE multipleScattering 'neural': mips of the last cascade (VDBFrameGridMipMaterial), levels 1 and up,\n // and their atlas layouts (columns, width, height). Five levels for his six-level network.\n readonly frameNeuralMipMaps = Array.from({ length: frameNeuralMipLevels }, () => texture(new THREE.Texture()));\n readonly frameNeuralMipLayouts = Array.from({ length: frameNeuralMipLevels }, () => uniform(new THREE.Vector3(1.0, 1.0, 1.0)));\n readonly gridUniforms: GridUniforms;\n readonly lightUniforms: LightUniforms;\n /** The network compiled in (multipleScattering 'neural'), or null. */\n neural: VDBFrameNeuralNetwork | null = null;\n spectral = false;\n\n constructor(o: VDBFrameTransmittanceMaterialOptions) {\n super();\n\n this.name = \"VDBFrameTransmittanceMaterial\";\n this.gridUniforms = o.gridUniforms;\n this.lightUniforms = o.lightUniforms;\n this.buildNodes();\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 // NOTE multipleScattering 'neural' (not spectral): scattered light of the light slots from the network\n setNeural(neural: VDBFrameNeuralNetwork | null): void {\n if (neural !== this.neural) {\n this.neural = neural;\n this.buildNodes();\n this.needsUpdate = true;\n }\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.buildNodes();\n this.needsUpdate = true;\n }\n }\n\n buildNodes(): void {\n if (this.spectral) {\n this.buildSpectralNodes();\n\n return;\n }\n\n const { gridUniforms, lightUniforms } = this;\n const grid = createGridNodes(gridUniforms);\n const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount, frameGridAtlasSize } = gridUniforms;\n const { frameSkyDirection } = lightUniforms;\n const ms = this.frameMultipleScattering;\n const octaves = this.frameScatteringOctaves;\n const network = this.neural;\n // NOTE K5.9b: the network nodes are made in the colorNode body, once per build. neuralLight is a\n // Fn().setLayout() (one WGSL function) that reads uniforms and textures, and three r187 caches a layout\n // function's code per backend (NodeBuilder.buildFunctionNode). Made once here, a second build of this\n // material (e.g. renderer.shadowMap.enabled toggling rebuilds every render object) reused code naming the\n // first builder's uniforms: \"unresolved value 'nodeUniform0'\".\n let neural: ReturnType<typeof createNeuralNodes> | null = null;\n\n const transmittance0 = property(\"vec4\");\n const transmittance1 = property(\"vec4\");\n const transmittance2 = property(\"vec4\");\n const transmittance3 = property(\"vec4\");\n\n // NOTE (extinction, absorption)\n const gridExtinction = (worldPosition: VDBTslNode) => {\n const found = grid.findCascade(worldPosition, int(0));\n const cascade = max(found, int(0));\n\n return select(found.greaterThanEqual(0), grid.sampleGrid(this.frameShadowDensityMap, cascade, grid.gridUvw(cascade, worldPosition)).rg, vec2(0.0));\n };\n\n // NOTE Each step moves one voxel of the finest cascade at the probe, on the fastest axis of the direction.\n // The march goes to coarser cascades when it leaves a fine cascade.\n // NOTE opticalDepth (optional float variable) gets the direct optical depth\n const march = (origin: VDBTslNode, direction: VDBTslNode, maxDistance: VDBTslNode, jitter: VDBTslNode, opticalDepth: VDBTslNode | null = null) => {\n const depths = vec3(0.0).toVar();\n const traveled = float(0.0).toVar();\n const probe = vec3(origin).toVar();\n\n Loop(maxShadowSteps, () => {\n const cascade = grid.findCascade(probe, int(0)).toVar();\n\n If(cascade.lessThan(0).or(traveled.greaterThanEqual(maxDistance)).or(frameShadowMarchDepth(depths, ms, octaves).greaterThan(6.0)), () => {\n Break();\n });\n\n const voxelsPerUnit = abs(direction).div(frameGridVoxel.element(cascade));\n const stepLength = min(float(1.0).div(max(voxelsPerUnit.x, max(voxelsPerUnit.y, voxelsPerUnit.z))), maxDistance.sub(traveled)).toVar();\n\n const sample = gridExtinction(probe.add(direction.mul(stepLength).mul(jitter))).toVar();\n\n depths.addAssign(frameShadowStep(sample.x, sample.y, ms).mul(stepLength));\n probe.addAssign(direction.mul(stepLength));\n traveled.addAssign(stepLength);\n });\n\n const transmittance = frameShadowTransmittance(depths, ms, octaves);\n\n if (opticalDepth) {\n opticalDepth.assign(depths.x);\n }\n\n // NOTE (direct, total, reduced depth, effective depth). Sky up and down use z and w for the diffusion total.\n return vec4(transmittance.x, transmittance.y, depths.z, depths.y);\n };\n\n // NOTE Sky up and down are isotropic, and opposite. Diffusion: two-sided total (frameIsotropicDiffusion).\n const skyTotal = (front: VDBTslNode, back: VDBTslNode) => select(ms.greaterThan(0.0), frameIsotropicDiffusion(front.z, back.z, front.w), front.y);\n\n // NOTE Light w is 1.0 for a light direction, 2.0 or more for a light position\n // NOTE Neural: total is direct + the network light. local: the light-independent network inputs of the voxel.\n const lightTransmittance = (slot: number, worldPosition: VDBTslNode, jitter: VDBTslNode, local: [VDBTslNode, VDBTslNode] | null) => {\n const result = vec4(1.0, 1.0, 0.0, 0.0).toVar();\n\n If(int(slot).lessThan(this.frameShadowLightCount), () => {\n const light = this.frameShadowLights.element(slot).toVar();\n const isDirection = light.w.lessThan(1.5);\n const toLight = light.xyz.sub(worldPosition).toVar();\n const direction = select(isDirection, normalize(light.xyz), normalize(toLight)).toVar();\n const opticalDepth = neural ? float(0.0).toVar() : null;\n\n result.assign(march(worldPosition, direction, select(isDirection, float(1e20), length(toLight)), jitter, opticalDepth));\n\n // NOTE Two-sided: diffusion of the slab between the light side and the far side (frameTwoSidedDiffusion)\n If(this.frameTwoSided.greaterThan(0.5), () => {\n const back = march(worldPosition, direction.negate(), float(1e20), jitter).toVar();\n\n result.y.assign(frameTwoSidedDiffusion(result.x, result.z, result.w, back.z));\n });\n\n if (neural && local) {\n result.y.assign(result.x.add(neural.neuralLight(worldPosition, direction, opticalDepth, local[0], local[1])));\n }\n });\n\n return result;\n };\n\n this.vertexNode = frameFullscreenVertex;\n\n this.colorNode = Fn(() => {\n neural = network ? createNeuralNodes(network, gridUniforms, grid, this.frameShadowDensityMap, this.frameNeuralMipMaps, this.frameNeuralMipLayouts) : null;\n const fragCoord = frameFragCoord(frameGridAtlasSize).toVar();\n const cell = grid.getGridCell(fragCoord);\n const cascade = cell.cascade.toVar();\n\n transmittance0.assign(vec4(1.0));\n transmittance1.assign(vec4(1.0));\n transmittance2.assign(vec4(1.0));\n transmittance3.assign(vec4(1.0));\n\n If(cascade.lessThan(frameGridCount), () => {\n const voxel = frameGridVoxel.element(cascade).toVar();\n const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade))).toVar();\n\n // NOTE Skip voxels with no extinction near them. The lighting pass does not read them.\n let nearExtinction: VDBTslNode = float(0.0);\n\n for (let i = 0; i < 8; i++) {\n const corner = vec3(i & 1, (i >> 1) & 1, (i >> 2) & 1).sub(0.5);\n\n nearExtinction = nearExtinction.add(gridExtinction(worldPosition.add(corner.mul(voxel))).x);\n }\n\n If(nearExtinction.greaterThan(0.0), () => {\n const jitter = frameNoise(gridUniforms.frameJitter, fragCoord).toVar();\n const skyDirection = normalize(frameSkyDirection).toVar();\n const local = neural ? neural.getLocalInputs(worldPosition) : null;\n\n const lights = Array.from({ length: frameShadowLightSlots }, (_, slot) => lightTransmittance(slot, worldPosition, jitter, local).toVar());\n\n const skyUp = march(worldPosition, skyDirection, float(1e20), jitter).toVar();\n const skyDown = march(worldPosition, skyDirection.negate(), float(1e20), jitter).toVar();\n\n transmittance0.assign(vec4(skyTotal(skyUp, skyDown), skyTotal(skyDown, skyUp), lights[0]!.y, lights[1]!.y));\n transmittance1.assign(vec4(lights[2]!.y, lights[3]!.y, lights[4]!.y, lights[5]!.y));\n transmittance2.assign(vec4(lights[0]!.x, lights[1]!.x, lights[2]!.x, lights[3]!.x));\n transmittance3.assign(vec4(lights[4]!.x, lights[5]!.x, 1.0, 1.0));\n });\n });\n\n return vec4(0.0);\n })();\n\n this.outputNode = outputStruct(transmittance0, transmittance1, transmittance2, transmittance3);\n }\n\n // NOTE Spectral: transmittance of each channel for the slots of one group (spectrum.ts).\n // One march for each direction: the grid gives the extinction and absorption of all channels at each step.\n buildSpectralNodes(): void {\n const { gridUniforms, lightUniforms } = this;\n const grid = createGridNodes(gridUniforms);\n const { frameGridMin, frameGridSize, frameGridVoxel, frameGridCount, frameGridAtlasSize } = gridUniforms;\n const { frameSkyDirection } = lightUniforms;\n const ms = this.frameMultipleScattering;\n const octaves = this.frameScatteringOctaves;\n const group = this.frameSpectralGroup;\n\n const outputs = [property(\"vec4\"), property(\"vec4\"), property(\"vec4\")];\n\n // NOTE (extinction, absorption) of each channel\n const gridSample = (worldPosition: VDBTslNode) => {\n const found = grid.findCascade(worldPosition, int(0));\n const cascade = max(found, int(0)).toVar();\n const uvw = grid.gridUvw(cascade, worldPosition).toVar();\n const inside = found.greaterThanEqual(0);\n\n return {\n extinction: select(inside, grid.sampleGrid(this.frameShadowDensityMap, cascade, uvw).rgb, vec3(0.0)),\n absorption: select(inside, grid.sampleGrid(this.frameShadowAbsorptionMap, cascade, uvw).rgb, vec3(0.0)),\n };\n };\n\n // NOTE The same march as the grey pass, with the depths of each channel. Stops when all channels are dark.\n // Returns { x: direct, y: total, z: reduced depth, w: effective depth }. enabled false: no march, 1.0 and depths 0.0.\n const march = (enabled: VDBTslNode, origin: VDBTslNode, direction: VDBTslNode, maxDistance: VDBTslNode, jitter: VDBTslNode) => {\n const direct = vec3(1.0).toVar();\n const total = vec3(1.0).toVar();\n const reduced = vec3(0.0).toVar();\n const effective = vec3(0.0).toVar();\n\n If(enabled, () => {\n const depths = { x: vec3(0.0).toVar(), y: vec3(0.0).toVar(), z: vec3(0.0).toVar() };\n const traveled = float(0.0).toVar();\n const probe = vec3(origin).toVar();\n\n Loop(maxShadowSteps, () => {\n const cascade = grid.findCascade(probe, int(0)).toVar();\n\n If(cascade.lessThan(0).or(traveled.greaterThanEqual(maxDistance)).or(minComponent(frameShadowMarchDepth(depths, ms, octaves)).greaterThan(6.0)), () => {\n Break();\n });\n\n const voxelsPerUnit = abs(direction).div(frameGridVoxel.element(cascade));\n const stepLength = min(float(1.0).div(max(voxelsPerUnit.x, max(voxelsPerUnit.y, voxelsPerUnit.z))), maxDistance.sub(traveled)).toVar();\n\n const sample = gridSample(probe.add(direction.mul(stepLength).mul(jitter)));\n const step = frameSpectralShadowStep(sample.extinction, sample.absorption, ms);\n\n depths.x.addAssign(step.x.mul(stepLength));\n depths.y.addAssign(step.y.mul(stepLength));\n depths.z.addAssign(step.z.mul(stepLength));\n probe.addAssign(direction.mul(stepLength));\n traveled.addAssign(stepLength);\n });\n\n const shadow = frameSpectralShadowTransmittance(depths, ms, octaves);\n\n direct.assign(shadow.x);\n total.assign(shadow.y);\n reduced.assign(depths.z);\n effective.assign(depths.y);\n });\n\n return { x: direct, y: total, z: reduced, w: effective };\n };\n\n // NOTE Sky up and down are isotropic, and opposite. Diffusion: two-sided total of each channel (frameIsotropicDiffusion).\n const skyTotal = (front: { y: VDBTslNode; z: VDBTslNode; w: VDBTslNode }, back: { z: VDBTslNode }) => select(ms.greaterThan(0.0), frameIsotropicDiffusion(front.z, back.z, front.w), front.y);\n\n // NOTE March of a light slot. Light w is 1.0 for a light direction, 2.0 or more for a light position.\n const marchSlot = (enabled: VDBTslNode, slot: VDBTslNode, worldPosition: VDBTslNode, jitter: VDBTslNode) => {\n // NOTE Group 3 has no second slot (slot 6). The clamp keeps the read in the array, the march is off.\n const light = this.frameShadowLights.element(min(slot, int(frameShadowLightSlots - 1))).toVar();\n const isDirection = light.w.lessThan(1.5);\n const toLight = light.xyz.sub(worldPosition).toVar();\n const direction = select(isDirection, normalize(light.xyz), normalize(toLight)).toVar();\n const active = enabled.and(slot.lessThan(this.frameShadowLightCount)).toVar();\n const front = march(active, worldPosition, direction, select(isDirection, float(1e20), length(toLight)), jitter);\n\n // NOTE Two-sided: diffusion of the slab between the light side and the far side, for each channel\n If(this.frameTwoSided.greaterThan(0.5), () => {\n const back = march(active, worldPosition, direction.negate(), float(1e20), jitter);\n\n front.y.assign(frameTwoSidedDiffusion(front.x, front.z, front.w, back.z));\n });\n\n return front;\n };\n\n this.vertexNode = frameFullscreenVertex;\n\n this.colorNode = Fn(() => {\n const fragCoord = frameFragCoord(frameGridAtlasSize).toVar();\n const cell = grid.getGridCell(fragCoord);\n const cascade = cell.cascade.toVar();\n\n outputs.forEach((output) => output.assign(vec4(1.0)));\n\n If(cascade.lessThan(frameGridCount), () => {\n const voxel = frameGridVoxel.element(cascade).toVar();\n const worldPosition = frameGridMin.element(cascade).add(cell.gridUvw.mul(frameGridSize.element(cascade))).toVar();\n\n // NOTE Skip voxels with no extinction near them. The lighting pass does not read them.\n let nearExtinction: VDBTslNode = float(0.0);\n\n for (let i = 0; i < 8; i++) {\n const corner = vec3(i & 1, (i >> 1) & 1, (i >> 2) & 1).sub(0.5);\n\n nearExtinction = nearExtinction.add(dot(gridSample(worldPosition.add(corner.mul(voxel))).extinction, vec3(1.0)));\n }\n\n If(nearExtinction.greaterThan(0.0), () => {\n const jitter = frameNoise(gridUniforms.frameJitter, fragCoord).toVar();\n const skyDirection = normalize(frameSkyDirection).toVar();\n const isSkyGroup = group.equal(0).toVar();\n const slotA = group.mul(2).sub(1).toVar();\n\n // NOTE Group 0: sky up, sky down, slot 0. Other groups: slots 2g - 1 and 2g, and no third march.\n const first = march(isSkyGroup, worldPosition, skyDirection, float(1e20), jitter);\n const second = march(isSkyGroup, worldPosition, skyDirection.negate(), float(1e20), jitter);\n const slotFirst = marchSlot(isSkyGroup.not(), max(slotA, int(0)), worldPosition, jitter);\n const slotSecond = marchSlot(bool(true), select(isSkyGroup, int(0), slotA.add(1)), worldPosition, jitter);\n\n const a = {\n x: select(isSkyGroup, skyTotal(first, second), slotFirst.y).toVar(),\n y: select(isSkyGroup, skyTotal(second, first), slotFirst.x).toVar(),\n };\n const b = { x: slotSecond.y, y: slotSecond.x };\n\n outputs[0]!.assign(vec4(a.x, a.y.x));\n outputs[1]!.assign(vec4(a.y.y, a.y.z, b.x.x, b.x.y));\n outputs[2]!.assign(vec4(b.x.z, b.y));\n });\n });\n\n return vec4(0.0);\n })();\n\n this.outputNode = outputStruct(...outputs);\n }\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View code of the froxel renderer, the same for all backends (R1 bucket A: frustum clip of the
|
|
3
|
+
* volume boxes, log slice ranges, froxel rectangle and area, distance fade radius) plus the scene
|
|
4
|
+
* traversal (`FrameVolumeCollector`, bucket B). It makes no objects per frame. The engine-free part
|
|
5
|
+
* moves to `core` in K3.8.
|
|
6
|
+
*/
|
|
7
|
+
import { Box3, Matrix4, Vector4, type Camera, type Object3D, type Vector2Like } from "three";
|
|
8
|
+
/** One volume of a frame volume: the per-render state his `FrameVolume.volumes[i]` holds. */
|
|
9
|
+
export interface FrameVolumeRecord {
|
|
10
|
+
readonly matrix: Matrix4;
|
|
11
|
+
readonly matrixWorld: Matrix4;
|
|
12
|
+
readonly localToView: Matrix4;
|
|
13
|
+
readonly viewToLocal: Matrix4;
|
|
14
|
+
readonly worldToLocal: Matrix4;
|
|
15
|
+
readonly worldBox: Box3;
|
|
16
|
+
viewNear: number;
|
|
17
|
+
viewFar: number;
|
|
18
|
+
ready: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** What the collector needs of a frame volume. */
|
|
21
|
+
export interface FrameVolumeLike extends Object3D {
|
|
22
|
+
readonly isVDBFrameVolume: true;
|
|
23
|
+
readonly proxy: Object3D;
|
|
24
|
+
readonly volumes: readonly FrameVolumeRecord[];
|
|
25
|
+
readonly mipmaps: boolean;
|
|
26
|
+
/** Re-reads the source (its uniforms and, for a sparse source's box, `volumes[].matrix`) if it changed. */
|
|
27
|
+
syncSource?(): void;
|
|
28
|
+
}
|
|
29
|
+
export interface FrameVolumeEntry<V extends FrameVolumeLike = FrameVolumeLike> {
|
|
30
|
+
frameVolume: V;
|
|
31
|
+
volume: FrameVolumeRecord;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Finds the ready volumes of the visible frame volumes (his `FrameVolumeCollector`). `volumes`: in
|
|
35
|
+
* the view. `casters`: all, when `useGrid` (the 'frame' lighting shadow grid, K3.3). Entries and
|
|
36
|
+
* arrays are reused by the next `collect()`.
|
|
37
|
+
*/
|
|
38
|
+
export declare class FrameVolumeCollector<V extends FrameVolumeLike = FrameVolumeLike> {
|
|
39
|
+
volumes: FrameVolumeEntry<V>[];
|
|
40
|
+
casters: FrameVolumeEntry<V>[];
|
|
41
|
+
near: number;
|
|
42
|
+
far: number;
|
|
43
|
+
entries: FrameVolumeEntry<V>[];
|
|
44
|
+
usedEntries: number;
|
|
45
|
+
camera: Camera | null;
|
|
46
|
+
useGrid: boolean;
|
|
47
|
+
prepareVolume: ((frameVolume: V, volume: FrameVolumeRecord) => void) | null;
|
|
48
|
+
private readonly visitObject;
|
|
49
|
+
constructor();
|
|
50
|
+
getEntry(frameVolume: V, volume: FrameVolumeRecord): FrameVolumeEntry<V>;
|
|
51
|
+
addVolume(frameVolume: V, volume: FrameVolumeRecord): void;
|
|
52
|
+
/** settings: near and far of the renderer settings. Returns this; `volumes` is empty when none is in view. */
|
|
53
|
+
collect(scene: Object3D, camera: Camera & {
|
|
54
|
+
near: number;
|
|
55
|
+
far: number;
|
|
56
|
+
reversedDepth?: boolean;
|
|
57
|
+
}, settings: {
|
|
58
|
+
near: number;
|
|
59
|
+
far: number;
|
|
60
|
+
}, useGrid: boolean, prepareVolume?: ((frameVolume: V, volume: FrameVolumeRecord) => void) | null): this;
|
|
61
|
+
/** True when a volume in the view or a caster uses mipmaps. */
|
|
62
|
+
hasMipmaps(): boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Uniform value of settings.fadeRadius. 0 turns the distance fade off. */
|
|
65
|
+
export declare const getFrameFadeRadius: (settings: {
|
|
66
|
+
fadeRadius: number;
|
|
67
|
+
}) => number;
|
|
68
|
+
/** Fractional slice of a view depth. range: froxelRange (near, far). Slices are logarithmic. */
|
|
69
|
+
export declare const getFroxelSlice: (viewDepth: number, range: Vector2Like, depth: number) => number;
|
|
70
|
+
/** First slice and slice count of a volume. Writes target ({ first, count }) and returns it. */
|
|
71
|
+
export declare const getFroxelSliceRange: (volume: {
|
|
72
|
+
viewNear: number;
|
|
73
|
+
viewFar: number;
|
|
74
|
+
}, range: Vector2Like, depth: number, target: {
|
|
75
|
+
first: number;
|
|
76
|
+
count: number;
|
|
77
|
+
}) => {
|
|
78
|
+
first: number;
|
|
79
|
+
count: number;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Screen rectangle of the volume in froxel cells (x0, y0, x1, y1), with one cell of padding for the
|
|
83
|
+
* linear filter. Writes target. Returns false when the volume covers no cell.
|
|
84
|
+
*/
|
|
85
|
+
export declare const getFroxelRect: (volume: {
|
|
86
|
+
localToView: Matrix4;
|
|
87
|
+
}, camera: Camera, width: number, height: number, target: Vector4) => boolean;
|
|
88
|
+
export interface FroxelArea {
|
|
89
|
+
rect: Vector4;
|
|
90
|
+
first: number;
|
|
91
|
+
count: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Froxel area of all volumes: the union of their rectangles and slices, one cell and one slice
|
|
95
|
+
* larger on each side. Writes area; count is 0 when no volume covers a cell.
|
|
96
|
+
*/
|
|
97
|
+
export declare const getFroxelArea: (volumes: readonly {
|
|
98
|
+
volume: {
|
|
99
|
+
localToView: Matrix4;
|
|
100
|
+
viewNear: number;
|
|
101
|
+
viewFar: number;
|
|
102
|
+
};
|
|
103
|
+
}[], camera: Camera, width: number, height: number, range: Vector2Like, depth: number, area: FroxelArea) => FroxelArea;
|