@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,268 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/frameEnvironment.js (all, 331 lines).
|
|
3
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
4
|
+
// Changes: TypeScript; `isFrameDiffusion` inlined (tools does not import the three adapter);
|
|
5
|
+
// the readback promise may also resolve to a Uint16Array of half floats (decoded here). Same
|
|
6
|
+
// directions, cells, colours and SH quadrature. Divergences: DIVERGES.md (K3.3 rows).
|
|
7
|
+
/**
|
|
8
|
+
* Multi-directional environment light (Disney "Deep Scattering", §4.4 and §7), engine-free (K3.3):
|
|
9
|
+
* the scene environment is read once into a small lat-long map (64 × 32, PMREM roughness 0.4); the
|
|
10
|
+
* CPU turns it into ≤ 12 directional lights. `'directional'`: the brightest texel plus fixed sky
|
|
11
|
+
* directions (zenith, nadir, a horizon ring; opposite pairs with diffusion), each texel to its
|
|
12
|
+
* nearest seed, a light at the energy centroid with energy / 4. `'spherical-harmonics'`: SH L1/L2
|
|
13
|
+
* projection evaluated at quadrature directions. The three adapter draws the map and passes the
|
|
14
|
+
* readback through `extract`.
|
|
15
|
+
*/
|
|
16
|
+
export const frameMaxEnvironmentLights = 12;
|
|
17
|
+
export const frameMaxEnvironmentSamples = 8;
|
|
18
|
+
export const frameEnvironmentMapWidth = 64;
|
|
19
|
+
export const frameEnvironmentMapHeight = 32;
|
|
20
|
+
/** PMREM blur of the map: a small sun covers more than one texel and is not lost between texels. */
|
|
21
|
+
export const frameEnvironmentMapRoughness = 0.4;
|
|
22
|
+
export const frameEnvironmentModes = {
|
|
23
|
+
outward: "outward",
|
|
24
|
+
directional: "directional",
|
|
25
|
+
sphericalHarmonics: "spherical-harmonics",
|
|
26
|
+
};
|
|
27
|
+
// NOTE Retry an empty map (environment or PMREM not ready) after this number of updates
|
|
28
|
+
const retryInterval = 30;
|
|
29
|
+
const normalize = (x, y, z) => {
|
|
30
|
+
const length = Math.hypot(x, y, z) || 1.0;
|
|
31
|
+
return [x / length, y / length, z / length];
|
|
32
|
+
};
|
|
33
|
+
/** His `isFrameDiffusion` (three `frame/phase.ts`): true, 'two-sided' and 'neural'. */
|
|
34
|
+
const isDiffusion = (mode) => !!mode && mode !== "octaves";
|
|
35
|
+
/** The same direction as the map shaders. u and v are 0 to 1; v = 0 is +Y. */
|
|
36
|
+
export const vdbFrameEnvironmentMapDirection = (u, v) => {
|
|
37
|
+
const phi = u * 2.0 * Math.PI;
|
|
38
|
+
const theta = v * Math.PI;
|
|
39
|
+
return [Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi)];
|
|
40
|
+
};
|
|
41
|
+
// NOTE Real SH basis, bands 0 to 2. Same constants as three.js SphericalHarmonics3.
|
|
42
|
+
const getShBasis = ([x, y, z], count) => [0.282095, 0.488603 * y, 0.488603 * z, 0.488603 * x, 1.092548 * x * y, 1.092548 * y * z, 0.315392 * (3.0 * z * z - 1.0), 1.092548 * x * z, 0.546274 * (x * x - y * y)].slice(0, count);
|
|
43
|
+
// NOTE Quadrature directions. Octahedron (spherical 3-design) for L1, icosahedron (5-design) for L2.
|
|
44
|
+
const goldenRatio = (1.0 + Math.sqrt(5.0)) / 2.0;
|
|
45
|
+
const octahedron = [
|
|
46
|
+
[1, 0, 0],
|
|
47
|
+
[-1, 0, 0],
|
|
48
|
+
[0, 1, 0],
|
|
49
|
+
[0, -1, 0],
|
|
50
|
+
[0, 0, 1],
|
|
51
|
+
[0, 0, -1],
|
|
52
|
+
];
|
|
53
|
+
const icosahedron = [
|
|
54
|
+
[0, 1, goldenRatio],
|
|
55
|
+
[0, -1, goldenRatio],
|
|
56
|
+
[0, 1, -goldenRatio],
|
|
57
|
+
[0, -1, -goldenRatio],
|
|
58
|
+
[1, goldenRatio, 0],
|
|
59
|
+
[-1, goldenRatio, 0],
|
|
60
|
+
[1, -goldenRatio, 0],
|
|
61
|
+
[-1, -goldenRatio, 0],
|
|
62
|
+
[goldenRatio, 0, 1],
|
|
63
|
+
[-goldenRatio, 0, 1],
|
|
64
|
+
[goldenRatio, 0, -1],
|
|
65
|
+
[-goldenRatio, 0, -1],
|
|
66
|
+
].map(([x, y, z]) => normalize(x, y, z));
|
|
67
|
+
const luminance = (r, g, b) => 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
68
|
+
export const vdbFrameEnvironmentMode = (settings) => {
|
|
69
|
+
const mode = settings.environmentLighting;
|
|
70
|
+
return mode === frameEnvironmentModes.directional || mode === frameEnvironmentModes.sphericalHarmonics ? mode : frameEnvironmentModes.outward;
|
|
71
|
+
};
|
|
72
|
+
const halfToFloat = (h) => {
|
|
73
|
+
const s = h & 0x8000 ? -1 : 1;
|
|
74
|
+
const e = (h >> 10) & 0x1f;
|
|
75
|
+
const f = h & 0x3ff;
|
|
76
|
+
if (e === 0)
|
|
77
|
+
return s * Math.pow(2, -14) * (f / 1024);
|
|
78
|
+
if (e === 31)
|
|
79
|
+
return f ? NaN : s * Infinity;
|
|
80
|
+
return s * Math.pow(2, e - 15) * (1 + f / 1024);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* His `FrameEnvironmentLights`: holds the lat-long map of the scene environment and the lights made
|
|
84
|
+
* from it. `extract(renderer, scene)` is the engine part: it draws the map (RGB radiance, A the
|
|
85
|
+
* texel's v, so the readback row order does not matter) and resolves RGBA floats.
|
|
86
|
+
*/
|
|
87
|
+
export class VDBFrameEnvironmentLights {
|
|
88
|
+
extract;
|
|
89
|
+
key = null;
|
|
90
|
+
pending = false;
|
|
91
|
+
retryAt = 0;
|
|
92
|
+
updates = 0;
|
|
93
|
+
texels = null;
|
|
94
|
+
texelsVersion = 0;
|
|
95
|
+
warned = false;
|
|
96
|
+
lightsKey = null;
|
|
97
|
+
lights = [];
|
|
98
|
+
result = {
|
|
99
|
+
mode: frameEnvironmentModes.outward,
|
|
100
|
+
count: 0,
|
|
101
|
+
directions: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 1.0, 0.0]),
|
|
102
|
+
colors: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 0.0, 0.0]),
|
|
103
|
+
};
|
|
104
|
+
constructor(extract) {
|
|
105
|
+
this.extract = extract;
|
|
106
|
+
}
|
|
107
|
+
getKey(scene) {
|
|
108
|
+
const { environment, environmentRotation: rotation } = scene;
|
|
109
|
+
return `${environment.uuid}:${environment.version}:${rotation.x}:${rotation.y}:${rotation.z}:${rotation.order}`;
|
|
110
|
+
}
|
|
111
|
+
/** Null when the 'outward' path must be used: another mode, no environment, or no map yet. */
|
|
112
|
+
update(renderer, scene, settings) {
|
|
113
|
+
const mode = vdbFrameEnvironmentMode(settings);
|
|
114
|
+
this.updates++;
|
|
115
|
+
if (mode === frameEnvironmentModes.outward || !scene.environment)
|
|
116
|
+
return null;
|
|
117
|
+
const key = this.getKey(scene);
|
|
118
|
+
if (key !== this.key && !this.pending && this.updates >= this.retryAt)
|
|
119
|
+
this.requestMap(renderer, scene, key);
|
|
120
|
+
if (!this.texels)
|
|
121
|
+
return null;
|
|
122
|
+
// NOTE Diffusion multiple scattering needs the directions in opposite pairs (getDirectionalLights)
|
|
123
|
+
const pairs = isDiffusion(settings.multipleScattering);
|
|
124
|
+
const lightsKey = `${mode}:${settings.environmentSamples}:${settings.environmentShOrder}:${this.texelsVersion}:${pairs}`;
|
|
125
|
+
if (lightsKey !== this.lightsKey) {
|
|
126
|
+
this.lights = mode === frameEnvironmentModes.directional ? this.getDirectionalLights(settings.environmentSamples, pairs) : this.getShLights(settings.environmentShOrder);
|
|
127
|
+
this.lightsKey = lightsKey;
|
|
128
|
+
}
|
|
129
|
+
const { result } = this;
|
|
130
|
+
const intensity = scene.environmentIntensity;
|
|
131
|
+
result.mode = mode;
|
|
132
|
+
result.count = this.lights.length;
|
|
133
|
+
this.lights.forEach(({ direction, color }, index) => {
|
|
134
|
+
result.directions[index] = direction;
|
|
135
|
+
result.colors[index] = color.map((value) => value * intensity);
|
|
136
|
+
});
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
/** Resolves when a pending map readback has settled (tests and harnesses; not his). */
|
|
140
|
+
settled = Promise.resolve();
|
|
141
|
+
requestMap(renderer, scene, key) {
|
|
142
|
+
this.pending = true;
|
|
143
|
+
this.settled = this.extract(renderer, scene)
|
|
144
|
+
.then((pixels) => {
|
|
145
|
+
this.pending = false;
|
|
146
|
+
if (this.setTexels(pixels))
|
|
147
|
+
this.key = key;
|
|
148
|
+
else
|
|
149
|
+
this.retryAt = this.updates + retryInterval;
|
|
150
|
+
})
|
|
151
|
+
.catch((error) => {
|
|
152
|
+
this.pending = false;
|
|
153
|
+
this.retryAt = this.updates + retryInterval;
|
|
154
|
+
if (!this.warned) {
|
|
155
|
+
console.warn("VDBFrameRenderer: could not read the environment map.", error);
|
|
156
|
+
this.warned = true;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** Radiance, direction and solid angle of each texel. Returns false for an empty map. Half floats (Uint16Array) are decoded. */
|
|
161
|
+
setTexels(pixels) {
|
|
162
|
+
const width = frameEnvironmentMapWidth;
|
|
163
|
+
const height = frameEnvironmentMapHeight;
|
|
164
|
+
const half = pixels instanceof Uint16Array;
|
|
165
|
+
const at = (i) => (half ? halfToFloat(pixels[i]) : pixels[i]);
|
|
166
|
+
const texels = [];
|
|
167
|
+
let energy = 0.0;
|
|
168
|
+
for (let i = 0; i < width * height; i++) {
|
|
169
|
+
const r = Math.max(0.0, at(i * 4));
|
|
170
|
+
const g = Math.max(0.0, at(i * 4 + 1));
|
|
171
|
+
const b = Math.max(0.0, at(i * 4 + 2));
|
|
172
|
+
const v = at(i * 4 + 3);
|
|
173
|
+
const u = ((i % width) + 0.5) / width;
|
|
174
|
+
const theta = v * Math.PI;
|
|
175
|
+
const solidAngle = ((2.0 * Math.PI) / width) * (Math.PI / height) * Math.sin(theta);
|
|
176
|
+
if (!Number.isFinite(r + g + b + v))
|
|
177
|
+
return false;
|
|
178
|
+
energy += luminance(r, g, b) * solidAngle;
|
|
179
|
+
texels.push({ radiance: [r, g, b], luminance: luminance(r, g, b), direction: vdbFrameEnvironmentMapDirection(u, v), solidAngle });
|
|
180
|
+
}
|
|
181
|
+
if (energy <= 0.0)
|
|
182
|
+
return false;
|
|
183
|
+
this.texels = texels;
|
|
184
|
+
this.texelsVersion++;
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.
|
|
189
|
+
* Each texel goes to the nearest direction; a light is at the energy centroid of its texels with
|
|
190
|
+
* their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).
|
|
191
|
+
* `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).
|
|
192
|
+
*/
|
|
193
|
+
getDirectionalLights(samples, pairs = false) {
|
|
194
|
+
const texels = this.texels;
|
|
195
|
+
const count = Math.min(frameMaxEnvironmentSamples, Math.max(1, Math.round(samples) || 1));
|
|
196
|
+
const peak = texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));
|
|
197
|
+
const seeds = [peak.direction];
|
|
198
|
+
const ringCount = pairs ? Math.max(0, count - 4) - (Math.max(0, count - 4) % 2) : count - 3;
|
|
199
|
+
if (pairs) {
|
|
200
|
+
if (count >= 2)
|
|
201
|
+
seeds.push(peak.direction.map((value) => -value));
|
|
202
|
+
if (count >= 4)
|
|
203
|
+
seeds.push([0.0, 1.0, 0.0], [0.0, -1.0, 0.0]);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
if (count >= 2)
|
|
207
|
+
seeds.push([0.0, 1.0, 0.0]);
|
|
208
|
+
if (count >= 3)
|
|
209
|
+
seeds.push([0.0, -1.0, 0.0]);
|
|
210
|
+
}
|
|
211
|
+
// NOTE The horizon ring starts opposite the dominant direction
|
|
212
|
+
const peakAzimuth = Math.atan2(peak.direction[2], peak.direction[0]);
|
|
213
|
+
for (let i = 0; i < ringCount; i++) {
|
|
214
|
+
const azimuth = peakAzimuth + Math.PI + (2.0 * Math.PI * i) / ringCount;
|
|
215
|
+
seeds.push([Math.cos(azimuth), 0.0, Math.sin(azimuth)]);
|
|
216
|
+
}
|
|
217
|
+
const cells = seeds.map((seed) => ({ seed, energy: [0.0, 0.0, 0.0], centroid: [0.0, 0.0, 0.0] }));
|
|
218
|
+
for (const { radiance, luminance: texelLuminance, direction, solidAngle } of texels) {
|
|
219
|
+
let nearest = cells[0];
|
|
220
|
+
let nearestDot = -Infinity;
|
|
221
|
+
for (const cell of cells) {
|
|
222
|
+
const dot = cell.seed[0] * direction[0] + cell.seed[1] * direction[1] + cell.seed[2] * direction[2];
|
|
223
|
+
if (dot > nearestDot) {
|
|
224
|
+
nearest = cell;
|
|
225
|
+
nearestDot = dot;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (let c = 0; c < 3; c++) {
|
|
229
|
+
nearest.energy[c] = nearest.energy[c] + radiance[c] * solidAngle;
|
|
230
|
+
nearest.centroid[c] = nearest.centroid[c] + direction[c] * texelLuminance * solidAngle;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return cells
|
|
234
|
+
.filter(({ energy }) => luminance(...energy) > 0.0)
|
|
235
|
+
.map(({ seed, energy, centroid }) => ({
|
|
236
|
+
direction: Math.hypot(...centroid) > 1e-6 ? normalize(...centroid) : seed,
|
|
237
|
+
color: energy.map((value) => value / 4.0),
|
|
238
|
+
power: luminance(...energy),
|
|
239
|
+
}))
|
|
240
|
+
.sort((a, b) => b.power - a.power);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:
|
|
244
|
+
* direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.
|
|
245
|
+
*/
|
|
246
|
+
getShLights(order) {
|
|
247
|
+
const texels = this.texels;
|
|
248
|
+
const coefficientCount = Number(order) === 1 ? 4 : 9;
|
|
249
|
+
const directions = coefficientCount === 4 ? octahedron : icosahedron;
|
|
250
|
+
const coefficients = Array.from({ length: coefficientCount }, () => [0.0, 0.0, 0.0]);
|
|
251
|
+
for (const { radiance, direction, solidAngle } of texels) {
|
|
252
|
+
getShBasis(direction, coefficientCount).forEach((basis, index) => {
|
|
253
|
+
for (let c = 0; c < 3; c++)
|
|
254
|
+
coefficients[index][c] = coefficients[index][c] + radiance[c] * basis * solidAngle;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
const weight = (4.0 * Math.PI) / directions.length / 4.0;
|
|
258
|
+
return directions.map((direction) => {
|
|
259
|
+
const color = [0.0, 0.0, 0.0];
|
|
260
|
+
getShBasis(direction, coefficientCount).forEach((basis, index) => {
|
|
261
|
+
for (let c = 0; c < 3; c++)
|
|
262
|
+
color[c] = color[c] + coefficients[index][c] * basis * weight;
|
|
263
|
+
});
|
|
264
|
+
return { direction, color };
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRo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CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,GAAG,CAAC;QACzD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAClC,MAAM,KAAK,GAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YAClC,UAAU,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC/D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;oBAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,GAAG,YAAY,CAAC,KAAK,CAAE,CAAC,CAAC,CAAE,GAAG,KAAK,GAAG,MAAM,CAAC;YAC/F,CAAC,CAAC,CAAC;YACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameEnvironment.js (all, 331 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; `isFrameDiffusion` inlined (tools does not import the three adapter);\n// the readback promise may also resolve to a Uint16Array of half floats (decoded here). Same\n// directions, cells, colours and SH quadrature. Divergences: DIVERGES.md (K3.3 rows).\n\n/**\n * Multi-directional environment light (Disney \"Deep Scattering\", §4.4 and §7), engine-free (K3.3):\n * the scene environment is read once into a small lat-long map (64 × 32, PMREM roughness 0.4); the\n * CPU turns it into ≤ 12 directional lights. `'directional'`: the brightest texel plus fixed sky\n * directions (zenith, nadir, a horizon ring; opposite pairs with diffusion), each texel to its\n * nearest seed, a light at the energy centroid with energy / 4. `'spherical-harmonics'`: SH L1/L2\n * projection evaluated at quadrature directions. The three adapter draws the map and passes the\n * readback through `extract`.\n */\n\nexport const frameMaxEnvironmentLights = 12;\nexport const frameMaxEnvironmentSamples = 8;\nexport const frameEnvironmentMapWidth = 64;\nexport const frameEnvironmentMapHeight = 32;\n/** PMREM blur of the map: a small sun covers more than one texel and is not lost between texels. */\nexport const frameEnvironmentMapRoughness = 0.4;\n\nexport const frameEnvironmentModes = {\n outward: \"outward\",\n directional: \"directional\",\n sphericalHarmonics: \"spherical-harmonics\",\n} as const;\n\nexport type VDBFrameEnvironmentMode = (typeof frameEnvironmentModes)[keyof typeof frameEnvironmentModes];\n\n/** The renderer settings the environment lights read. */\nexport interface VDBFrameEnvironmentSettings {\n environmentLighting: string;\n environmentSamples: number;\n environmentShOrder: number;\n multipleScattering: boolean | string;\n}\n\n/** The scene fields the environment lights read (three's `Scene` fits). */\nexport interface VDBFrameEnvironmentScene {\n environment: { uuid: string; version: number } | null;\n environmentRotation: { x: number; y: number; z: number; order: string };\n environmentIntensity: number;\n}\n\n// NOTE Retry an empty map (environment or PMREM not ready) after this number of updates\nconst retryInterval = 30;\n\ntype V3 = [number, number, number];\n\nconst normalize = (x: number, y: number, z: number): V3 => {\n const length = Math.hypot(x, y, z) || 1.0;\n return [x / length, y / length, z / length];\n};\n\n/** His `isFrameDiffusion` (three `frame/phase.ts`): true, 'two-sided' and 'neural'. */\nconst isDiffusion = (mode: boolean | string) => !!mode && mode !== \"octaves\";\n\n/** The same direction as the map shaders. u and v are 0 to 1; v = 0 is +Y. */\nexport const vdbFrameEnvironmentMapDirection = (u: number, v: number): V3 => {\n const phi = u * 2.0 * Math.PI;\n const theta = v * Math.PI;\n return [Math.sin(theta) * Math.cos(phi), Math.cos(theta), Math.sin(theta) * Math.sin(phi)];\n};\n\n// NOTE Real SH basis, bands 0 to 2. Same constants as three.js SphericalHarmonics3.\nconst getShBasis = ([x, y, z]: V3, count: number) =>\n [0.282095, 0.488603 * y, 0.488603 * z, 0.488603 * x, 1.092548 * x * y, 1.092548 * y * z, 0.315392 * (3.0 * z * z - 1.0), 1.092548 * x * z, 0.546274 * (x * x - y * y)].slice(0, count);\n\n// NOTE Quadrature directions. Octahedron (spherical 3-design) for L1, icosahedron (5-design) for L2.\nconst goldenRatio = (1.0 + Math.sqrt(5.0)) / 2.0;\nconst octahedron: V3[] = [\n [1, 0, 0],\n [-1, 0, 0],\n [0, 1, 0],\n [0, -1, 0],\n [0, 0, 1],\n [0, 0, -1],\n];\nconst icosahedron: V3[] = (\n [\n [0, 1, goldenRatio],\n [0, -1, goldenRatio],\n [0, 1, -goldenRatio],\n [0, -1, -goldenRatio],\n [1, goldenRatio, 0],\n [-1, goldenRatio, 0],\n [1, -goldenRatio, 0],\n [-1, -goldenRatio, 0],\n [goldenRatio, 0, 1],\n [-goldenRatio, 0, 1],\n [goldenRatio, 0, -1],\n [-goldenRatio, 0, -1],\n ] as V3[]\n).map(([x, y, z]) => normalize(x, y, z));\n\nconst luminance = (r: number, g: number, b: number) => 0.2126 * r + 0.7152 * g + 0.0722 * b;\n\nexport const vdbFrameEnvironmentMode = (settings: Pick<VDBFrameEnvironmentSettings, \"environmentLighting\">): VDBFrameEnvironmentMode => {\n const mode = settings.environmentLighting;\n return mode === frameEnvironmentModes.directional || mode === frameEnvironmentModes.sphericalHarmonics ? mode : frameEnvironmentModes.outward;\n};\n\ninterface Texel {\n radiance: V3;\n luminance: number;\n direction: V3;\n solidAngle: number;\n}\n\n/** One environment light: world direction to the light and its isotropic irradiance colour (energy / 4). */\nexport interface VDBFrameEnvironmentLight {\n direction: V3;\n color: V3;\n power?: number;\n}\n\n/** Output of {@link VDBFrameEnvironmentLights.update}. Colours include `scene.environmentIntensity`. */\nexport interface VDBFrameEnvironmentResult {\n mode: VDBFrameEnvironmentMode;\n count: number;\n directions: V3[];\n colors: V3[];\n}\n\nconst halfToFloat = (h: number): number => {\n const s = h & 0x8000 ? -1 : 1;\n const e = (h >> 10) & 0x1f;\n const f = h & 0x3ff;\n if (e === 0) return s * Math.pow(2, -14) * (f / 1024);\n if (e === 31) return f ? NaN : s * Infinity;\n return s * Math.pow(2, e - 15) * (1 + f / 1024);\n};\n\n/**\n * His `FrameEnvironmentLights`: holds the lat-long map of the scene environment and the lights made\n * from it. `extract(renderer, scene)` is the engine part: it draws the map (RGB radiance, A the\n * texel's v, so the readback row order does not matter) and resolves RGBA floats.\n */\nexport class VDBFrameEnvironmentLights<R = unknown, S extends VDBFrameEnvironmentScene = VDBFrameEnvironmentScene> {\n key: string | null = null;\n pending = false;\n retryAt = 0;\n updates = 0;\n texels: Texel[] | null = null;\n texelsVersion = 0;\n warned = false;\n lightsKey: string | null = null;\n lights: VDBFrameEnvironmentLight[] = [];\n\n readonly result: VDBFrameEnvironmentResult = {\n mode: frameEnvironmentModes.outward,\n count: 0,\n directions: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 1.0, 0.0] as V3),\n colors: Array.from({ length: frameMaxEnvironmentLights }, () => [0.0, 0.0, 0.0] as V3),\n };\n\n constructor(readonly extract: (renderer: R, scene: S) => Promise<ArrayLike<number>>) {}\n\n getKey(scene: S): string {\n const { environment, environmentRotation: rotation } = scene;\n return `${environment!.uuid}:${environment!.version}:${rotation.x}:${rotation.y}:${rotation.z}:${rotation.order}`;\n }\n\n /** Null when the 'outward' path must be used: another mode, no environment, or no map yet. */\n update(renderer: R, scene: S, settings: VDBFrameEnvironmentSettings): VDBFrameEnvironmentResult | null {\n const mode = vdbFrameEnvironmentMode(settings);\n this.updates++;\n if (mode === frameEnvironmentModes.outward || !scene.environment) return null;\n\n const key = this.getKey(scene);\n if (key !== this.key && !this.pending && this.updates >= this.retryAt) this.requestMap(renderer, scene, key);\n if (!this.texels) return null;\n\n // NOTE Diffusion multiple scattering needs the directions in opposite pairs (getDirectionalLights)\n const pairs = isDiffusion(settings.multipleScattering);\n const lightsKey = `${mode}:${settings.environmentSamples}:${settings.environmentShOrder}:${this.texelsVersion}:${pairs}`;\n if (lightsKey !== this.lightsKey) {\n this.lights = mode === frameEnvironmentModes.directional ? this.getDirectionalLights(settings.environmentSamples, pairs) : this.getShLights(settings.environmentShOrder);\n this.lightsKey = lightsKey;\n }\n\n const { result } = this;\n const intensity = scene.environmentIntensity;\n result.mode = mode;\n result.count = this.lights.length;\n this.lights.forEach(({ direction, color }, index) => {\n result.directions[index] = direction;\n result.colors[index] = color.map((value) => value * intensity) as V3;\n });\n return result;\n }\n\n /** Resolves when a pending map readback has settled (tests and harnesses; not his). */\n settled: Promise<void> = Promise.resolve();\n\n requestMap(renderer: R, scene: S, key: string): void {\n this.pending = true;\n this.settled = this.extract(renderer, scene)\n .then((pixels) => {\n this.pending = false;\n if (this.setTexels(pixels)) this.key = key;\n else this.retryAt = this.updates + retryInterval;\n })\n .catch((error: unknown) => {\n this.pending = false;\n this.retryAt = this.updates + retryInterval;\n if (!this.warned) {\n console.warn(\"VDBFrameRenderer: could not read the environment map.\", error);\n this.warned = true;\n }\n });\n }\n\n /** Radiance, direction and solid angle of each texel. Returns false for an empty map. Half floats (Uint16Array) are decoded. */\n setTexels(pixels: ArrayLike<number>): boolean {\n const width = frameEnvironmentMapWidth;\n const height = frameEnvironmentMapHeight;\n const half = pixels instanceof Uint16Array;\n const at = (i: number) => (half ? halfToFloat(pixels[i]!) : pixels[i]!);\n const texels: Texel[] = [];\n let energy = 0.0;\n\n for (let i = 0; i < width * height; i++) {\n const r = Math.max(0.0, at(i * 4));\n const g = Math.max(0.0, at(i * 4 + 1));\n const b = Math.max(0.0, at(i * 4 + 2));\n const v = at(i * 4 + 3);\n const u = ((i % width) + 0.5) / width;\n const theta = v * Math.PI;\n const solidAngle = ((2.0 * Math.PI) / width) * (Math.PI / height) * Math.sin(theta);\n if (!Number.isFinite(r + g + b + v)) return false;\n energy += luminance(r, g, b) * solidAngle;\n texels.push({ radiance: [r, g, b], luminance: luminance(r, g, b), direction: vdbFrameEnvironmentMapDirection(u, v), solidAngle });\n }\n if (energy <= 0.0) return false;\n this.texels = texels;\n this.texelsVersion++;\n return true;\n }\n\n /**\n * Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.\n * Each texel goes to the nearest direction; a light is at the energy centroid of its texels with\n * their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).\n * `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).\n */\n getDirectionalLights(samples: number, pairs = false): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const count = Math.min(frameMaxEnvironmentSamples, Math.max(1, Math.round(samples) || 1));\n const peak = texels.reduce((best, texel) => (texel.luminance > best.luminance ? texel : best));\n const seeds: V3[] = [peak.direction];\n const ringCount = pairs ? Math.max(0, count - 4) - (Math.max(0, count - 4) % 2) : count - 3;\n\n if (pairs) {\n if (count >= 2) seeds.push(peak.direction.map((value) => -value) as V3);\n if (count >= 4) seeds.push([0.0, 1.0, 0.0], [0.0, -1.0, 0.0]);\n } else {\n if (count >= 2) seeds.push([0.0, 1.0, 0.0]);\n if (count >= 3) seeds.push([0.0, -1.0, 0.0]);\n }\n\n // NOTE The horizon ring starts opposite the dominant direction\n const peakAzimuth = Math.atan2(peak.direction[2], peak.direction[0]);\n for (let i = 0; i < ringCount; i++) {\n const azimuth = peakAzimuth + Math.PI + (2.0 * Math.PI * i) / ringCount;\n seeds.push([Math.cos(azimuth), 0.0, Math.sin(azimuth)]);\n }\n\n const cells = seeds.map((seed) => ({ seed, energy: [0.0, 0.0, 0.0] as V3, centroid: [0.0, 0.0, 0.0] as V3 }));\n for (const { radiance, luminance: texelLuminance, direction, solidAngle } of texels) {\n let nearest = cells[0]!;\n let nearestDot = -Infinity;\n for (const cell of cells) {\n const dot = cell.seed[0] * direction[0] + cell.seed[1] * direction[1] + cell.seed[2] * direction[2];\n if (dot > nearestDot) {\n nearest = cell;\n nearestDot = dot;\n }\n }\n for (let c = 0; c < 3; c++) {\n nearest.energy[c] = nearest.energy[c]! + radiance[c]! * solidAngle;\n nearest.centroid[c] = nearest.centroid[c]! + direction[c]! * texelLuminance * solidAngle;\n }\n }\n\n return cells\n .filter(({ energy }) => luminance(...energy) > 0.0)\n .map(({ seed, energy, centroid }) => ({\n direction: Math.hypot(...centroid) > 1e-6 ? normalize(...centroid) : seed,\n color: energy.map((value) => value / 4.0) as V3,\n power: luminance(...energy),\n }))\n .sort((a, b) => b.power - a.power);\n }\n\n /**\n * SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:\n * direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.\n */\n getShLights(order: number): VDBFrameEnvironmentLight[] {\n const texels = this.texels!;\n const coefficientCount = Number(order) === 1 ? 4 : 9;\n const directions = coefficientCount === 4 ? octahedron : icosahedron;\n const coefficients = Array.from({ length: coefficientCount }, () => [0.0, 0.0, 0.0] as V3);\n for (const { radiance, direction, solidAngle } of texels) {\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) coefficients[index]![c] = coefficients[index]![c]! + radiance[c]! * basis * solidAngle;\n });\n }\n const weight = (4.0 * Math.PI) / directions.length / 4.0;\n return directions.map((direction) => {\n const color: V3 = [0.0, 0.0, 0.0];\n getShBasis(direction, coefficientCount).forEach((basis, index) => {\n for (let c = 0; c < 3; c++) color[c] = color[c]! + coefficients[index]![c]! * basis * weight;\n });\n return { direction, color };\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The world shadow grid of mjurczyk's `'frame'` lighting (K3.3, R1 §6 Step 3), engine-free: the
|
|
3
|
+
* cascade layout (power-of-two voxels, snapped bounds, the last cascade fits every caster), each
|
|
4
|
+
* caster's voxel range in a cascade, the change signatures that skip redraws, and CPU twins of the
|
|
5
|
+
* grid shader maths (atlas cell, cascade search, slice-atlas sampling, the transmittance march,
|
|
6
|
+
* isotropic diffusion, the temporal reprojection). `@pmndrs/vdb/three` `frame/grid.ts` and the
|
|
7
|
+
* 'frame' passes use these; the e2e harness checks the GPU passes against them.
|
|
8
|
+
*/
|
|
9
|
+
import { type Vec2, type Vec3, type Vec4 } from "./index.js";
|
|
10
|
+
/** A writable 3-vector (three's `Vector3` fits). */
|
|
11
|
+
export interface VDBVec3Like {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
z: number;
|
|
15
|
+
}
|
|
16
|
+
/** An axis-aligned box (three's `Box3` fits). */
|
|
17
|
+
export interface VDBBox3Like {
|
|
18
|
+
min: VDBVec3Like;
|
|
19
|
+
max: VDBVec3Like;
|
|
20
|
+
}
|
|
21
|
+
/** His `pushVector`: x, y (, z (, w)) of a vector into a signature. */
|
|
22
|
+
export declare function vdbSignaturePushVector(values: number[], v: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
z?: number;
|
|
26
|
+
w?: number;
|
|
27
|
+
}): void;
|
|
28
|
+
/** His `pushElements`. */
|
|
29
|
+
export declare function vdbSignaturePushElements(values: number[], elements: ArrayLike<number>): void;
|
|
30
|
+
/** His `sameValues`: signatures are flat arrays compared value by value. */
|
|
31
|
+
export declare function vdbSameValues(a: ArrayLike<unknown>, b: ArrayLike<unknown>): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* His `updateGridCascades`: the last cascade fits all caster boxes (then far volumes get coarse
|
|
34
|
+
* shadows, not none); finer cascades are around the camera within `shadowDistance`, each half the
|
|
35
|
+
* size of the next; voxels are powers of two and bounds snap to them (shadows stay still while the
|
|
36
|
+
* camera moves). A fine cascade equal to the casters' box is skipped (the last one covers it).
|
|
37
|
+
* Writes `gridMin`, `gridSize`, `gridVoxel` (one entry per cascade); returns the count (0: no casters).
|
|
38
|
+
*/
|
|
39
|
+
export declare function vdbFrameGridCascades(casterBoxes: readonly VDBBox3Like[], cameraPosition: VDBVec3Like, shadowDistance: number, resolution: number, cascades: number, gridMin: VDBVec3Like[], gridSize: VDBVec3Like[], gridVoxel: VDBVec3Like[]): number;
|
|
40
|
+
/**
|
|
41
|
+
* His `getGridRange`: the voxel rectangle (x0, y0, x1, y1) and the atlas slices (first, count) of a
|
|
42
|
+
* world box in one cascade. Writes `target`; returns false when the box is out of the cascade.
|
|
43
|
+
*/
|
|
44
|
+
export declare function vdbFrameGridRange(worldBox: VDBBox3Like, cascade: number, resolution: number, gridMin: readonly VDBVec3Like[], gridVoxel: readonly VDBVec3Like[], target: {
|
|
45
|
+
rect: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
z: number;
|
|
49
|
+
w: number;
|
|
50
|
+
} | Vec4;
|
|
51
|
+
first: number;
|
|
52
|
+
count: number;
|
|
53
|
+
}): boolean;
|
|
54
|
+
/** His `getCascadeCasters`: one item per caster per cascade from `firstCascade`; `pool` is reused. */
|
|
55
|
+
export declare function vdbFrameCascadeCasters<T>(casters: readonly T[], firstCascade: number, count: number, pool: {
|
|
56
|
+
items: {
|
|
57
|
+
caster: T;
|
|
58
|
+
cascade: number;
|
|
59
|
+
}[];
|
|
60
|
+
entries: {
|
|
61
|
+
caster: T;
|
|
62
|
+
cascade: number;
|
|
63
|
+
}[];
|
|
64
|
+
}): {
|
|
65
|
+
caster: T;
|
|
66
|
+
cascade: number;
|
|
67
|
+
}[];
|
|
68
|
+
/** The signature state of {@link vdbFrameUpdateGridSignatures} (his renderer fields of the same names). */
|
|
69
|
+
export interface VDBFrameGridSignatureState {
|
|
70
|
+
gridSignature: number[];
|
|
71
|
+
nextGridSignature: number[];
|
|
72
|
+
castSignature: number[];
|
|
73
|
+
nextCastSignature: number[];
|
|
74
|
+
casterSignature: number[];
|
|
75
|
+
gridVersion: number;
|
|
76
|
+
castVersion: number;
|
|
77
|
+
}
|
|
78
|
+
/** A fresh {@link VDBFrameGridSignatureState}. */
|
|
79
|
+
export declare const vdbFrameGridSignatureState: () => VDBFrameGridSignatureState;
|
|
80
|
+
/**
|
|
81
|
+
* His `updateGridSignatures`: `gridVersion` changes when the cascades, a caster transform, a caster's
|
|
82
|
+
* data or a caster's shadow props change; `castVersion` only for the last cascade. `pushCaster(values, caster)`
|
|
83
|
+
* adds what the shadow density pass reads of one caster (transform, source identity and version, props).
|
|
84
|
+
* Returns true when `castVersion` changed. Arrays are swapped, never reallocated.
|
|
85
|
+
*/
|
|
86
|
+
export declare function vdbFrameUpdateGridSignatures<T>(state: VDBFrameGridSignatureState, casters: readonly T[], count: number, resolution: number, spectral: boolean, gridMin: readonly VDBVec3Like[], gridSize: readonly VDBVec3Like[], pushCaster: (values: number[], caster: T) => void): boolean;
|
|
87
|
+
/** The grid layout the shaders read (`createGridUniforms`), as plain arrays. */
|
|
88
|
+
export interface VDBFrameGridLayout {
|
|
89
|
+
/** Cascades in use (`frameGridCount`). */
|
|
90
|
+
count: number;
|
|
91
|
+
/** Voxels per side (`frameGridResolution`). */
|
|
92
|
+
resolution: number;
|
|
93
|
+
/** Tile columns of the atlas (`frameGridColumns`). */
|
|
94
|
+
columns: number;
|
|
95
|
+
/** Atlas size in texels (`frameGridAtlasSize`). */
|
|
96
|
+
atlasSize: Vec2;
|
|
97
|
+
gridMin: Vec3[];
|
|
98
|
+
gridSize: Vec3[];
|
|
99
|
+
gridVoxel: Vec3[];
|
|
100
|
+
}
|
|
101
|
+
/** gridUvw: world position → [0, 1]³ of a cascade. */
|
|
102
|
+
export declare function vdbFrameGridUvw(grid: VDBFrameGridLayout, cascade: number, world: Vec3): Vec3;
|
|
103
|
+
/** insideGrid: half a voxel inside the cascade (the linear filter then never reads the clamped edge). */
|
|
104
|
+
export declare function vdbFrameInsideGrid(resolution: number, uvw: Vec3): boolean;
|
|
105
|
+
/** findCascade: the finest cascade ≥ `firstCascade` that contains the position, or −1. */
|
|
106
|
+
export declare function vdbFrameFindCascade(grid: VDBFrameGridLayout, world: Vec3, firstCascade?: number, maxCascades?: number): number;
|
|
107
|
+
/** getGridCell: cascade and grid uvw of an atlas pixel (bottom-left `fragCoord`, a pixel centre). */
|
|
108
|
+
export declare function vdbFrameGridCell(resolution: number, columns: number, fragCoord: Vec2): {
|
|
109
|
+
cascade: number;
|
|
110
|
+
gridUvw: Vec3;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* A slice atlas on the CPU: `data` is RGBA (or `channels`) floats, rows **bottom first** (the shaders'
|
|
114
|
+
* `frameFragCoord` convention), `width` × `height` texels. Sampling is the hardware's linear filter
|
|
115
|
+
* with clamp-to-edge, as the render targets are configured (`LinearFilter`).
|
|
116
|
+
*/
|
|
117
|
+
export interface VDBFrameAtlas {
|
|
118
|
+
data: ArrayLike<number>;
|
|
119
|
+
width: number;
|
|
120
|
+
height: number;
|
|
121
|
+
channels: number;
|
|
122
|
+
}
|
|
123
|
+
/** Hardware bilinear (texel centres at i + ½, clamp to edge) of a bottom-first atlas at texel coordinates. */
|
|
124
|
+
export declare function vdbFrameAtlasBilinear(atlas: VDBFrameAtlas, x: number, y: number, out?: number[]): number[];
|
|
125
|
+
/** sampleTiles: hardware bilinear in a slice, linear between slices (z tiles from `tileOffset`). */
|
|
126
|
+
export declare function vdbFrameSampleTiles(atlas: VDBFrameAtlas, resolution: number, tileOffset: number, columns: number, uvw: Vec3): number[];
|
|
127
|
+
/** sampleGrid: {@link vdbFrameSampleTiles} of one cascade of the grid atlas. */
|
|
128
|
+
export declare function vdbFrameSampleGrid(atlas: VDBFrameAtlas, grid: VDBFrameGridLayout, cascade: number, uvw: Vec3): number[];
|
|
129
|
+
/** gridExtinction of the transmittance pass: (extinction, absorption) at a world position, 0 outside the grid. */
|
|
130
|
+
export declare function vdbFrameGridExtinction(atlas: VDBFrameAtlas, grid: VDBFrameGridLayout, world: Vec3): Vec2;
|
|
131
|
+
/**
|
|
132
|
+
* The transmittance pass `march` (grey): one voxel of the finest cascade at the probe per step along the
|
|
133
|
+
* direction's fastest axis, coarser cascades after leaving a fine one, stop outside the grid, at
|
|
134
|
+
* `maxDistance` or past march depth 6 (with octaves, the last octave's). Each step samples `jitter` of the
|
|
135
|
+
* way along it. Returns (direct, total, reduced depth, effective depth); `out.opticalDepth` gets the direct
|
|
136
|
+
* optical depth (the neural input).
|
|
137
|
+
*/
|
|
138
|
+
export declare function vdbFrameGridMarch(extinctionAt: (world: Vec3) => Vec2, grid: VDBFrameGridLayout, origin: Vec3, direction: Vec3, maxDistance: number, jitter: number, multipleScattering: number, octaves?: Vec4, out?: {
|
|
139
|
+
opticalDepth: number;
|
|
140
|
+
}): Vec4;
|
|
141
|
+
/**
|
|
142
|
+
* frameIsotropicDiffusion: total transmittance of isotropic light (sky, environment) with diffusion,
|
|
143
|
+
* the two-sided slab 2 (back + z₀) / (front + back + 2 z₀) of the reduced depths (z₀ = ⅔), times
|
|
144
|
+
* exp(−effective front). Opposite directions sum to 2 in a white medium (white furnace).
|
|
145
|
+
*/
|
|
146
|
+
export declare function vdbFrameIsotropicDiffusion(frontReduced: number, backReduced: number, frontEffective: number): number;
|
|
147
|
+
/** One grid light slot of the transmittance pass: position xyz, w < 1.5 a direction to the light, else a position. */
|
|
148
|
+
export type VDBFrameShadowLight = Vec4;
|
|
149
|
+
/** The multiple scattering modes of the transmittance pass beyond the diffusion value (K3.4). */
|
|
150
|
+
export interface VDBFrameTransmittanceModes {
|
|
151
|
+
/** `getFrameScatteringOctaves` (count 0: off). */
|
|
152
|
+
octaves?: Vec4;
|
|
153
|
+
/** multipleScattering 'two-sided': the light slots also march away from the light (frameTwoSidedDiffusion). */
|
|
154
|
+
twoSided?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* multipleScattering 'neural': the network's scattered light of a slot at a world position, for the unit
|
|
157
|
+
* direction to the light and the slot's direct optical depth (`vdbFrameNeuralLight` bound to its inputs).
|
|
158
|
+
*/
|
|
159
|
+
neural?: ((world: Vec3, direction: Vec3, opticalDepth: number) => number) | null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The transmittance pass (grey) at one grid voxel: the 4 MRT outputs (vec4 each) his `colorNode` writes,
|
|
163
|
+
* for `lights` (≤ 6 slots) and the sky direction. `fragCoord` is the voxel's atlas pixel (for the jitter
|
|
164
|
+
* noise; `jitter` < 0 is off). Voxels with no extinction within half a voxel keep 1.0 everywhere, as his
|
|
165
|
+
* pass. `modes`: octaves, two-sided or neural (K3.4).
|
|
166
|
+
*/
|
|
167
|
+
export declare function vdbFrameTransmittanceVoxel(atlas: VDBFrameAtlas, grid: VDBFrameGridLayout, fragCoord: Vec2, lights: readonly VDBFrameShadowLight[], skyDirection: Vec3, multipleScattering: number, jitterValue: number, modes?: VDBFrameTransmittanceModes): [Vec4, Vec4, Vec4, Vec4];
|
|
168
|
+
/**
|
|
169
|
+
* sampleShadows: the slot atlases at a world position, 1 outside the grid, blended toward the next
|
|
170
|
+
* cascade within 10% of a cascade's sides (no visible cascade borders).
|
|
171
|
+
*/
|
|
172
|
+
export declare function vdbFrameSampleShadows(atlases: readonly VDBFrameAtlas[], grid: VDBFrameGridLayout, world: Vec3): number[][];
|
|
173
|
+
/** The inputs of {@link vdbFrameDensityFroxel}: one volume's uniforms and the renderer's, as the density pass reads them. */
|
|
174
|
+
export interface VDBFrameDensityInputs {
|
|
175
|
+
/** Froxel grid (width, height, slices), atlas tile columns, the log slice range and the inverse projection. */
|
|
176
|
+
froxelGrid: Vec3;
|
|
177
|
+
columns: number;
|
|
178
|
+
range: Vec2;
|
|
179
|
+
projectionInverse: ArrayLike<number>;
|
|
180
|
+
cameraWorld: ArrayLike<number>;
|
|
181
|
+
/** The volume's view → local unit-box matrix (column-major). */
|
|
182
|
+
viewToLocal: ArrayLike<number>;
|
|
183
|
+
/** Largest texel count of the source (getLod) and its density mip levels (0: no mipmaps). */
|
|
184
|
+
maxTexels: number;
|
|
185
|
+
mipLevels: number;
|
|
186
|
+
worldScale: number;
|
|
187
|
+
subSteps: number;
|
|
188
|
+
/** `frameJitter` (< 0: off). */
|
|
189
|
+
jitter: number;
|
|
190
|
+
fadeRadius: number;
|
|
191
|
+
opacity: number;
|
|
192
|
+
baseColor: Vec3;
|
|
193
|
+
scatterColor: Vec3;
|
|
194
|
+
/** The source's `sampleExtinction(local, lod)` (extinction per world unit). */
|
|
195
|
+
extinctionAt: (local: Vec3, lod: number) => number;
|
|
196
|
+
/** The 4 transmittance atlases and their layout, or null without shadows. */
|
|
197
|
+
shadows: {
|
|
198
|
+
atlases: readonly VDBFrameAtlas[];
|
|
199
|
+
grid: VDBFrameGridLayout;
|
|
200
|
+
} | null;
|
|
201
|
+
/** Scene lights with a shadow slot, their positions (slot order) and the renderer phase. */
|
|
202
|
+
sceneLightCount: number;
|
|
203
|
+
lightPositions: readonly Vec4[];
|
|
204
|
+
phase: Vec4;
|
|
205
|
+
/** The renderer's phase spectrum (`getFramePhaseSpectrum`; default (1, 1, 0): one phase) and octaves (K3.4). */
|
|
206
|
+
phaseSpectrum?: Vec3;
|
|
207
|
+
octaves?: Vec4;
|
|
208
|
+
/** Environment mode 'grid': the environment grid atlas (last cascade), its tile columns and the unshadowed light. */
|
|
209
|
+
environmentGrid?: {
|
|
210
|
+
atlas: VDBFrameAtlas;
|
|
211
|
+
columns: number;
|
|
212
|
+
unshadowed: Vec3;
|
|
213
|
+
} | null;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The density pass of 'frame' lighting at one froxel of one volume (FrameDensityMaterial `buildNodes`,
|
|
217
|
+
* grey, octaves off, no environment term): the slice's sub-step pre-integration through the source,
|
|
218
|
+
* the visible position, and the shadow slots there. Returns the 4 MRT outputs (before additive
|
|
219
|
+
* blending), or null when the froxel is discarded. `fragCoord` is the atlas pixel (bottom-left).
|
|
220
|
+
*/
|
|
221
|
+
export declare function vdbFrameDensityFroxel(fragCoord: Vec2, p: VDBFrameDensityInputs): [Vec4, Vec4, Vec4, Vec4] | null;
|
|
222
|
+
/** The froxel geometry of the density pass (and the inject pre-integration): box segment, sub-steps, lods. null: discarded. */
|
|
223
|
+
export declare function vdbFrameDensityFroxelSteps(fragCoord: Vec2, p: Pick<VDBFrameDensityInputs, "froxelGrid" | "columns" | "range" | "projectionInverse" | "viewToLocal" | "maxTexels" | "mipLevels" | "worldScale" | "subSteps" | "jitter">): {
|
|
224
|
+
froxel: {
|
|
225
|
+
tile: Vec2;
|
|
226
|
+
slice: number;
|
|
227
|
+
uv: Vec2;
|
|
228
|
+
sliceNear: number;
|
|
229
|
+
sliceFar: number;
|
|
230
|
+
viewNear: Vec3;
|
|
231
|
+
viewFar: Vec3;
|
|
232
|
+
};
|
|
233
|
+
viewNear: Vec3;
|
|
234
|
+
viewFar: Vec3;
|
|
235
|
+
localNear: Vec3;
|
|
236
|
+
localFar: Vec3;
|
|
237
|
+
t0: number;
|
|
238
|
+
segment: number;
|
|
239
|
+
steps: number;
|
|
240
|
+
subStepLength: number;
|
|
241
|
+
lod: number;
|
|
242
|
+
jitter: number;
|
|
243
|
+
mul: (m: ArrayLike<number>, v: Vec3) => Vec3;
|
|
244
|
+
} | null;
|
|
245
|
+
/**
|
|
246
|
+
* The environment grid pass (FrameEnvironmentGridMaterial, grey) at one voxel of the last
|
|
247
|
+
* cascade: `fragCoord` is the pixel of the environment grid atlas (`envColumns` tile columns), `lights`
|
|
248
|
+
* the environment lights without a shadow slot, `unshadowed` their colour sum (the value outside the
|
|
249
|
+
* casters). One-voxel steps that stay in the last cascade; with diffusion the two-sided total of the
|
|
250
|
+
* march and the opposite march. Returns the RGBA output.
|
|
251
|
+
*/
|
|
252
|
+
export declare function vdbFrameEnvironmentGridVoxel(atlas: VDBFrameAtlas, grid: VDBFrameGridLayout, envColumns: number, fragCoord: Vec2, lights: readonly {
|
|
253
|
+
direction: Vec3;
|
|
254
|
+
color: Vec3;
|
|
255
|
+
}[], unshadowed: Vec3, multipleScattering: number, octaves?: Vec4): Vec4;
|
|
256
|
+
/**
|
|
257
|
+
* The temporal pass reprojection of a froxel centre (FrameTemporalMaterial L123–157): the previous
|
|
258
|
+
* frame's uv and fractional slice of a world position, and the history blend (the motion of a
|
|
259
|
+
* quarter cell or more uses only the current froxel). Returns null when the point is outside the
|
|
260
|
+
* previous froxel grid (or behind its camera).
|
|
261
|
+
*/
|
|
262
|
+
export declare function vdbFrameReproject(world: Vec3, previousView: ArrayLike<number>, previousProjection: ArrayLike<number>, previousRange: Vec2, grid: Vec3, current: {
|
|
263
|
+
uv: Vec2;
|
|
264
|
+
slice: number;
|
|
265
|
+
}, temporalBlend: number): {
|
|
266
|
+
uv: Vec2;
|
|
267
|
+
slice: number;
|
|
268
|
+
blend: number;
|
|
269
|
+
} | null;
|
|
270
|
+
/** The lights {@link vdbFrameLightingFroxel} reads (the renderer's light uniforms; light probe off). */
|
|
271
|
+
export interface VDBFrameLightingInputs {
|
|
272
|
+
ambient: Vec3;
|
|
273
|
+
hemiSky: Vec3;
|
|
274
|
+
hemiGround: Vec3;
|
|
275
|
+
/** Scene lights in slot order: position (w 1 directional, 2 point, 3 spot), colour × intensity; spot (xyz, cos) and penumbra cos; falloff (distance, decay). */
|
|
276
|
+
lights: {
|
|
277
|
+
position: Vec4;
|
|
278
|
+
color: Vec3;
|
|
279
|
+
spot?: Vec4;
|
|
280
|
+
penumbra?: number;
|
|
281
|
+
falloff?: Vec2;
|
|
282
|
+
}[];
|
|
283
|
+
shadowLightCount: number;
|
|
284
|
+
/** The renderer phase (forward g, back g, back weight, Mie mode). */
|
|
285
|
+
phase: Vec4;
|
|
286
|
+
/** `getFrameScatteringOctaves` (K3.4; lights without a shadow slot get the octaves too). */
|
|
287
|
+
octaves?: Vec4;
|
|
288
|
+
/** K3.4 per-channel phases: the renderer's phase spectrum, and the 6 slots' direct transmittance at a world position (sampleShadows of the direct maps). */
|
|
289
|
+
phaseSpectrum?: Vec3;
|
|
290
|
+
directAt?: (world: Vec3) => number[];
|
|
291
|
+
/** Environment lights with a shadow slot (colours), from `environmentShadowSlot`. */
|
|
292
|
+
environmentColors: Vec3[];
|
|
293
|
+
environmentShadowSlot: number;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The lighting pass of 'frame' lighting at one froxel (FrameLightingMaterial `createFragmentNode`,
|
|
297
|
+
* grey, light probe off): from the 4 density targets
|
|
298
|
+
* (albedo·σ, σ), (emission·σ, t·σ), (sky up, sky down, slot 0, slot 1)·σ, (slots 2–5)·σ, the froxel's
|
|
299
|
+
* view segment and the camera matrix (column-major). Returns the premultiplied (radiance·α, α), or
|
|
300
|
+
* zeros when σ ≤ 0 (the pass discards; the target is cleared).
|
|
301
|
+
*/
|
|
302
|
+
export declare function vdbFrameLightingFroxel(density: readonly [Vec4, Vec4, Vec4, Vec4], viewNear: Vec3, viewFar: Vec3, cameraWorld: ArrayLike<number>, inputs: VDBFrameLightingInputs): Vec4;
|