@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,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K3.6: CPU twins of the emission light (his `FrameEmissionLight`): each emissive volume's light along 16
|
|
3
|
+
* Fibonacci directions × 8² parallel rays (direction pass), its mean intensity and luminance-weighted centre
|
|
4
|
+
* (reduce pass), the L1 irradiance probes of all volumes as point lights (probe pass), the probe cascades
|
|
5
|
+
* (power-of-two snapped) and the irradiance a lit surface reads.
|
|
6
|
+
*/
|
|
7
|
+
import type { Vec3, Vec4 } from "./index.js";
|
|
8
|
+
import { type VDBFrameAtlas, type VDBFrameGridLayout } from "./grid.js";
|
|
9
|
+
/** Directions of each volume's emitted light (his `frameEmissionDirections`). */
|
|
10
|
+
export declare const frameEmissionDirections = 16;
|
|
11
|
+
/** Rays on each side of the square that covers the volume (his `frameEmissionRays`). */
|
|
12
|
+
export declare const frameEmissionRays = 8;
|
|
13
|
+
/** Probes per axis, at most (the atlas is made for it; his `frameEmissionMaxResolution`). */
|
|
14
|
+
export declare const frameEmissionMaxResolution = 32;
|
|
15
|
+
export declare const frameEmissionMaxCascades = 4;
|
|
16
|
+
export declare const frameEmissionAtlasColumns: number;
|
|
17
|
+
export declare const frameEmissionAtlasSize: number;
|
|
18
|
+
/** Golden angle in radians: Fibonacci directions turn by it. */
|
|
19
|
+
export declare const frameEmissionGoldenAngle: number;
|
|
20
|
+
/** Linear-sRGB luminance (three's `luminance()` with the working colour space's coefficients). */
|
|
21
|
+
export declare const frameEmissionLuminance: Vec3;
|
|
22
|
+
/** Direction `index` (0–15) of the direction pass: a Fibonacci sphere point, from the volume to the viewer, with its tangent frame. */
|
|
23
|
+
export declare function vdbFrameEmissionDirection(index: number): {
|
|
24
|
+
direction: Vec3;
|
|
25
|
+
tangent: Vec3;
|
|
26
|
+
bitangent: Vec3;
|
|
27
|
+
};
|
|
28
|
+
/** His `boxSegment` of the local unit box ([−½, ½]³): the [t0, t1] ⊂ [0, 1] of the segment inside it. */
|
|
29
|
+
export declare function vdbFrameBoxSegment(start: Vec3, end: Vec3): [number, number];
|
|
30
|
+
/** One emitter as the direction pass reads it. Samplers take local positions (unit box) and a mip lod. */
|
|
31
|
+
export interface VDBFrameEmitter {
|
|
32
|
+
/** Extinction per world unit (the source's `sampleExtinction`). */
|
|
33
|
+
sampleExtinction(local: Vec3, lod: number): number;
|
|
34
|
+
/** Emitted radiance (the source's `sampleEmission`; the pass reads lod 0). */
|
|
35
|
+
sampleEmission(local: Vec3, lod: number): Vec3;
|
|
36
|
+
/** The source's `getLod` of a local size. */
|
|
37
|
+
getLod(localSize: number): number;
|
|
38
|
+
/** World → local unit box, column-major. */
|
|
39
|
+
worldToLocal: ArrayLike<number>;
|
|
40
|
+
center: Vec3;
|
|
41
|
+
radius: number;
|
|
42
|
+
/** World scale of the volume (`matrixWorld.getMaxScaleOnAxis()`). */
|
|
43
|
+
worldScale: number;
|
|
44
|
+
absorbance: number;
|
|
45
|
+
steps: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The emitter centre and bounding radius (FrameEmissionLight core L138–150): the translation of the volume's world
|
|
49
|
+
* matrix (unit box → world) and the largest distance of a box corner from it.
|
|
50
|
+
*/
|
|
51
|
+
export declare function vdbFrameEmitterBounds(matrixWorld: ArrayLike<number>): {
|
|
52
|
+
center: Vec3;
|
|
53
|
+
radius: number;
|
|
54
|
+
min: Vec3;
|
|
55
|
+
max: Vec3;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* One texel of the direction pass (his FrameEmissionDirectionMaterial): the emitted light of the volume toward
|
|
59
|
+
* direction `index`, summed over 8² parallel rays that cover its bounding sphere. Each ray adds emission × α × the
|
|
60
|
+
* transmittance so far (absorbance scales the transmittance, as for scene lights) and stops below 1%. Returns output
|
|
61
|
+
* 0 (intensity × ray area, radius) and output 1 (luminance-weighted world position × ray area, weight × area).
|
|
62
|
+
*/
|
|
63
|
+
export declare function vdbFrameEmissionDirectionTexel(emitter: VDBFrameEmitter, index: number): {
|
|
64
|
+
intensity: Vec4;
|
|
65
|
+
center: Vec4;
|
|
66
|
+
};
|
|
67
|
+
/** The reduce pass: mean intensity of the 16 directions, and the centre of the visible emission ((0,0,0,0) when none). */
|
|
68
|
+
export declare function vdbFrameEmissionReduce(texels: readonly {
|
|
69
|
+
intensity: Vec4;
|
|
70
|
+
center: Vec4;
|
|
71
|
+
}[]): {
|
|
72
|
+
intensity: Vec4;
|
|
73
|
+
center: Vec4;
|
|
74
|
+
};
|
|
75
|
+
/** One emitter of the probe pass: the reduce outputs (intensity rgb + radius, centre + visible flag). */
|
|
76
|
+
export interface VDBFrameEmitterLight {
|
|
77
|
+
intensity: Vec4;
|
|
78
|
+
center: Vec4;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* One probe of the probe pass: the L1 irradiance of every emitter as a point light at its emission centre,
|
|
82
|
+
* E(n) = E/4 + E/2 · dot(l, n), softened near the centre by a quarter of the radius. Returns (red, green, blue),
|
|
83
|
+
* each (constant, direction xyz).
|
|
84
|
+
*/
|
|
85
|
+
export declare function vdbFrameEmissionProbe(probe: Vec3, emitters: readonly VDBFrameEmitterLight[]): [Vec4, Vec4, Vec4];
|
|
86
|
+
/** The light node's irradiance from (filtered) probe values: max(x + dot(yzw, n), 0) per channel, × falloff. */
|
|
87
|
+
export declare function vdbFrameEmissionIrradiance(probe: readonly [Vec4, Vec4, Vec4], normal: Vec3, falloff?: number): Vec3;
|
|
88
|
+
/** Settings of the probe cascades (his `FrameEmissionLight` props). */
|
|
89
|
+
export interface VDBFrameEmissionGridSettings {
|
|
90
|
+
resolution: number;
|
|
91
|
+
range: number;
|
|
92
|
+
cascades: number;
|
|
93
|
+
distance: number;
|
|
94
|
+
}
|
|
95
|
+
/** The probe cascades (cascade 0 finest), the centre of all emitters, and a key that changes with them. */
|
|
96
|
+
export interface VDBFrameEmissionGrid {
|
|
97
|
+
resolution: number;
|
|
98
|
+
count: number;
|
|
99
|
+
min: Vec3[];
|
|
100
|
+
size: Vec3[];
|
|
101
|
+
center: Vec3;
|
|
102
|
+
key: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* updateProbeGrid (FrameEmissionLight core L186–241): the last cascade is the box of all emitters grown by
|
|
106
|
+
* (range − 1)/2 of its longest side on each side; finer cascades are power-of-two-voxel cubes around the camera,
|
|
107
|
+
* each half the next, snapped to their voxel; a fine cascade that is not finer than the last or holds no emitter is
|
|
108
|
+
* skipped.
|
|
109
|
+
*/
|
|
110
|
+
export declare function vdbFrameEmissionProbeGrid(settings: VDBFrameEmissionGridSettings, emitterBoxes: readonly {
|
|
111
|
+
min: Vec3;
|
|
112
|
+
max: Vec3;
|
|
113
|
+
}[], cameraPosition: Vec3): VDBFrameEmissionGrid;
|
|
114
|
+
/**
|
|
115
|
+
* Past the last cascade (the light node, L490–506): the clamped edge probe's light falls off as the squared distance
|
|
116
|
+
* ratio |edge − centre|² / |p − centre|² (≤ 1).
|
|
117
|
+
*/
|
|
118
|
+
export declare function vdbFrameEmissionFalloff(edge: Vec3, position: Vec3, center: Vec3): number;
|
|
119
|
+
/**
|
|
120
|
+
* The light node's probe read (L457–507) on CPU atlases (the probe target's three attachments, rows bottom first):
|
|
121
|
+
* the finest cascade that holds the point (half a probe inside), blended into the next one over the last tenth of
|
|
122
|
+
* each side; outside every cascade, the last cascade's clamped edge with {@link vdbFrameEmissionFalloff}. Returns the
|
|
123
|
+
* (red, green, blue) L1 probe values and the falloff; {@link vdbFrameEmissionIrradiance} then gives E(n).
|
|
124
|
+
*/
|
|
125
|
+
export declare function vdbFrameEmissionLookup(atlases: readonly [VDBFrameAtlas, VDBFrameAtlas, VDBFrameAtlas], grid: VDBFrameGridLayout, center: Vec3, position: Vec3): {
|
|
126
|
+
probe: [Vec4, Vec4, Vec4];
|
|
127
|
+
falloff: number;
|
|
128
|
+
};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/FrameEmissionLight.js L3–15 (constants), L138–150 (emitter centre and radius),
|
|
3
|
+
// L182–241 (updateProbeGrid); src/three-openvdb/frame/webgpu/FrameEmissionLight.js L59–60 (golden angle),
|
|
4
|
+
// L168–237 (the direction pass), L259–279 (the reduce pass), L310–364 (the probe pass), L457–519 (the light
|
|
5
|
+
// node's irradiance).
|
|
6
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
7
|
+
// Changes: engine-free TypeScript CPU twins (f64) of his emission-light maths; boxes and matrices are plain
|
|
8
|
+
// arrays (column-major). Divergences: none (twins of the ported TSL).
|
|
9
|
+
import { vdbFrameFindCascade, vdbFrameGridUvw, vdbFrameSampleGrid } from "./grid.js";
|
|
10
|
+
/** Directions of each volume's emitted light (his `frameEmissionDirections`). */
|
|
11
|
+
export const frameEmissionDirections = 16;
|
|
12
|
+
/** Rays on each side of the square that covers the volume (his `frameEmissionRays`). */
|
|
13
|
+
export const frameEmissionRays = 8;
|
|
14
|
+
/** Probes per axis, at most (the atlas is made for it; his `frameEmissionMaxResolution`). */
|
|
15
|
+
export const frameEmissionMaxResolution = 32;
|
|
16
|
+
export const frameEmissionMaxCascades = 4;
|
|
17
|
+
export const frameEmissionAtlasColumns = Math.ceil(Math.sqrt(frameEmissionMaxResolution * frameEmissionMaxCascades));
|
|
18
|
+
export const frameEmissionAtlasSize = frameEmissionMaxResolution * frameEmissionAtlasColumns;
|
|
19
|
+
/** Golden angle in radians: Fibonacci directions turn by it. */
|
|
20
|
+
export const frameEmissionGoldenAngle = Math.PI * (3.0 - Math.sqrt(5.0));
|
|
21
|
+
/** Linear-sRGB luminance (three's `luminance()` with the working colour space's coefficients). */
|
|
22
|
+
export const frameEmissionLuminance = [0.2126, 0.7152, 0.0722];
|
|
23
|
+
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
24
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
25
|
+
const normalize = (a) => {
|
|
26
|
+
const l = Math.sqrt(dot(a, a));
|
|
27
|
+
return [a[0] / l, a[1] / l, a[2] / l];
|
|
28
|
+
};
|
|
29
|
+
const apply = (m, p) => [
|
|
30
|
+
m[0] * p[0] + m[4] * p[1] + m[8] * p[2] + m[12],
|
|
31
|
+
m[1] * p[0] + m[5] * p[1] + m[9] * p[2] + m[13],
|
|
32
|
+
m[2] * p[0] + m[6] * p[1] + m[10] * p[2] + m[14],
|
|
33
|
+
];
|
|
34
|
+
/** Direction `index` (0–15) of the direction pass: a Fibonacci sphere point, from the volume to the viewer, with its tangent frame. */
|
|
35
|
+
export function vdbFrameEmissionDirection(index) {
|
|
36
|
+
const y = 1 - (index * 2 + 1) / frameEmissionDirections;
|
|
37
|
+
const ring = Math.sqrt(Math.max(0, 1 - y * y));
|
|
38
|
+
const phi = index * frameEmissionGoldenAngle;
|
|
39
|
+
const direction = [Math.cos(phi) * ring, y, Math.sin(phi) * ring];
|
|
40
|
+
const helper = Math.abs(direction[1]) < 0.999 ? [0, 1, 0] : [1, 0, 0];
|
|
41
|
+
const tangent = normalize(cross(helper, direction));
|
|
42
|
+
return { direction, tangent, bitangent: cross(direction, tangent) };
|
|
43
|
+
}
|
|
44
|
+
/** His `boxSegment` of the local unit box ([−½, ½]³): the [t0, t1] ⊂ [0, 1] of the segment inside it. */
|
|
45
|
+
export function vdbFrameBoxSegment(start, end) {
|
|
46
|
+
let t0 = -Infinity;
|
|
47
|
+
let t1 = Infinity;
|
|
48
|
+
for (let c = 0; c < 3; c++) {
|
|
49
|
+
const inv = 1 / (end[c] - start[c]);
|
|
50
|
+
const a = (-0.5 - start[c]) * inv;
|
|
51
|
+
const b = (0.5 - start[c]) * inv;
|
|
52
|
+
t0 = Math.max(t0, Math.min(a, b));
|
|
53
|
+
t1 = Math.min(t1, Math.max(a, b));
|
|
54
|
+
}
|
|
55
|
+
return [Math.max(0, t0), Math.min(1, t1)];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The emitter centre and bounding radius (FrameEmissionLight core L138–150): the translation of the volume's world
|
|
59
|
+
* matrix (unit box → world) and the largest distance of a box corner from it.
|
|
60
|
+
*/
|
|
61
|
+
export function vdbFrameEmitterBounds(matrixWorld) {
|
|
62
|
+
const center = [matrixWorld[12], matrixWorld[13], matrixWorld[14]];
|
|
63
|
+
let radius = 0;
|
|
64
|
+
const min = [Infinity, Infinity, Infinity];
|
|
65
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
66
|
+
for (let i = 0; i < 8; i++) {
|
|
67
|
+
const corner = apply(matrixWorld, [i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5]);
|
|
68
|
+
radius = Math.max(radius, Math.hypot(corner[0] - center[0], corner[1] - center[1], corner[2] - center[2]));
|
|
69
|
+
for (let c = 0; c < 3; c++) {
|
|
70
|
+
min[c] = Math.min(min[c], corner[c]);
|
|
71
|
+
max[c] = Math.max(max[c], corner[c]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return { center, radius, min, max };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One texel of the direction pass (his FrameEmissionDirectionMaterial): the emitted light of the volume toward
|
|
78
|
+
* direction `index`, summed over 8² parallel rays that cover its bounding sphere. Each ray adds emission × α × the
|
|
79
|
+
* transmittance so far (absorbance scales the transmittance, as for scene lights) and stops below 1%. Returns output
|
|
80
|
+
* 0 (intensity × ray area, radius) and output 1 (luminance-weighted world position × ray area, weight × area).
|
|
81
|
+
*/
|
|
82
|
+
export function vdbFrameEmissionDirectionTexel(emitter, index) {
|
|
83
|
+
const { direction, tangent, bitangent } = vdbFrameEmissionDirection(index);
|
|
84
|
+
const { center: c, radius, steps } = emitter;
|
|
85
|
+
const diameter = radius * 2;
|
|
86
|
+
const spacing = diameter / frameEmissionRays;
|
|
87
|
+
const intensity = [0, 0, 0];
|
|
88
|
+
const center = [0, 0, 0, 0];
|
|
89
|
+
for (let r = 0; r < frameEmissionRays * frameEmissionRays; r++) {
|
|
90
|
+
const u = (((r % frameEmissionRays) + 0.5) / frameEmissionRays) * 2 - 1;
|
|
91
|
+
const v = ((Math.floor(r / frameEmissionRays) + 0.5) / frameEmissionRays) * 2 - 1;
|
|
92
|
+
const worldStart = [0, 1, 2].map((k) => c[k] + direction[k] * radius + tangent[k] * u * radius + bitangent[k] * v * radius);
|
|
93
|
+
const worldEnd = [0, 1, 2].map((k) => worldStart[k] - direction[k] * diameter);
|
|
94
|
+
const localStart = apply(emitter.worldToLocal, worldStart);
|
|
95
|
+
const localEnd = apply(emitter.worldToLocal, worldEnd);
|
|
96
|
+
const segment = vdbFrameBoxSegment(localStart, localEnd);
|
|
97
|
+
if (!(segment[0] < segment[1]))
|
|
98
|
+
continue;
|
|
99
|
+
const segmentLength = segment[1] - segment[0];
|
|
100
|
+
const stepLength = (segmentLength * diameter) / steps;
|
|
101
|
+
const lod = emitter.getLod(stepLength / emitter.worldScale);
|
|
102
|
+
let transmittance = 1;
|
|
103
|
+
for (let s = 0; s < steps; s++) {
|
|
104
|
+
const t = segment[0] + segmentLength * ((s + 0.5) / steps);
|
|
105
|
+
const local = [0, 1, 2].map((k) => localStart[k] + (localEnd[k] - localStart[k]) * t);
|
|
106
|
+
const extinction = emitter.sampleExtinction(local, lod);
|
|
107
|
+
if (extinction > 0) {
|
|
108
|
+
const alpha = 1 - Math.exp(-extinction * stepLength);
|
|
109
|
+
const e = emitter.sampleEmission(local, 0);
|
|
110
|
+
const radiance = [e[0] * transmittance * alpha, e[1] * transmittance * alpha, e[2] * transmittance * alpha];
|
|
111
|
+
const weight = dot(radiance, frameEmissionLuminance);
|
|
112
|
+
for (let k = 0; k < 3; k++) {
|
|
113
|
+
intensity[k] = intensity[k] + radiance[k];
|
|
114
|
+
center[k] = center[k] + (worldStart[k] + (worldEnd[k] - worldStart[k]) * t) * weight;
|
|
115
|
+
}
|
|
116
|
+
center[3] += weight;
|
|
117
|
+
transmittance *= Math.exp(-extinction * emitter.absorbance * stepLength);
|
|
118
|
+
if (transmittance < 0.01)
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const area = spacing * spacing;
|
|
124
|
+
return { intensity: [intensity[0] * area, intensity[1] * area, intensity[2] * area, radius], center: [center[0] * area, center[1] * area, center[2] * area, center[3] * area] };
|
|
125
|
+
}
|
|
126
|
+
/** The reduce pass: mean intensity of the 16 directions, and the centre of the visible emission ((0,0,0,0) when none). */
|
|
127
|
+
export function vdbFrameEmissionReduce(texels) {
|
|
128
|
+
const intensity = [0, 0, 0, 0];
|
|
129
|
+
const center = [0, 0, 0, 0];
|
|
130
|
+
for (const t of texels) {
|
|
131
|
+
for (let k = 0; k < 4; k++) {
|
|
132
|
+
intensity[k] = intensity[k] + t.intensity[k];
|
|
133
|
+
center[k] = center[k] + t.center[k];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (let k = 0; k < 4; k++)
|
|
137
|
+
intensity[k] = intensity[k] / frameEmissionDirections;
|
|
138
|
+
const visible = center[3] > 0;
|
|
139
|
+
const w = Math.max(center[3], 1e-12);
|
|
140
|
+
return { intensity, center: visible ? [center[0] / w, center[1] / w, center[2] / w, 1] : [0, 0, 0, 0] };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* One probe of the probe pass: the L1 irradiance of every emitter as a point light at its emission centre,
|
|
144
|
+
* E(n) = E/4 + E/2 · dot(l, n), softened near the centre by a quarter of the radius. Returns (red, green, blue),
|
|
145
|
+
* each (constant, direction xyz).
|
|
146
|
+
*/
|
|
147
|
+
export function vdbFrameEmissionProbe(probe, emitters) {
|
|
148
|
+
const constant = [0, 0, 0];
|
|
149
|
+
const dirs = [
|
|
150
|
+
[0, 0, 0],
|
|
151
|
+
[0, 0, 0],
|
|
152
|
+
[0, 0, 0],
|
|
153
|
+
];
|
|
154
|
+
for (const e of emitters) {
|
|
155
|
+
if (!(e.center[3] > 0))
|
|
156
|
+
continue;
|
|
157
|
+
const toProbe = [probe[0] - e.center[0], probe[1] - e.center[1], probe[2] - e.center[2]];
|
|
158
|
+
const d2 = dot(toProbe, toProbe);
|
|
159
|
+
const soft = e.intensity[3] * 0.25;
|
|
160
|
+
const sd2 = d2 + soft * soft;
|
|
161
|
+
const irradiance = [e.intensity[0] / sd2, e.intensity[1] / sd2, e.intensity[2] / sd2];
|
|
162
|
+
const scale = (1 / Math.sqrt(Math.max(d2, 1e-12))) * (d2 / sd2) * -0.5;
|
|
163
|
+
const toLight = [toProbe[0] * scale, toProbe[1] * scale, toProbe[2] * scale];
|
|
164
|
+
for (let k = 0; k < 3; k++) {
|
|
165
|
+
constant[k] = constant[k] + irradiance[k] * 0.25;
|
|
166
|
+
for (let a = 0; a < 3; a++)
|
|
167
|
+
dirs[k][a] = dirs[k][a] + toLight[a] * irradiance[k];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return [
|
|
171
|
+
[constant[0], ...dirs[0]],
|
|
172
|
+
[constant[1], ...dirs[1]],
|
|
173
|
+
[constant[2], ...dirs[2]],
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
/** The light node's irradiance from (filtered) probe values: max(x + dot(yzw, n), 0) per channel, × falloff. */
|
|
177
|
+
export function vdbFrameEmissionIrradiance(probe, normal, falloff = 1) {
|
|
178
|
+
return probe.map((p) => Math.max(0, p[0] + p[1] * normal[0] + p[2] * normal[1] + p[3] * normal[2]) * falloff);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* updateProbeGrid (FrameEmissionLight core L186–241): the last cascade is the box of all emitters grown by
|
|
182
|
+
* (range − 1)/2 of its longest side on each side; finer cascades are power-of-two-voxel cubes around the camera,
|
|
183
|
+
* each half the next, snapped to their voxel; a fine cascade that is not finer than the last or holds no emitter is
|
|
184
|
+
* skipped.
|
|
185
|
+
*/
|
|
186
|
+
export function vdbFrameEmissionProbeGrid(settings, emitterBoxes, cameraPosition) {
|
|
187
|
+
const resolution = Math.min(frameEmissionMaxResolution, Math.max(2, Math.round(settings.resolution)));
|
|
188
|
+
const cascades = Math.min(frameEmissionMaxCascades, Math.max(1, Math.round(settings.cascades)));
|
|
189
|
+
const gMin = [Infinity, Infinity, Infinity];
|
|
190
|
+
const gMax = [-Infinity, -Infinity, -Infinity];
|
|
191
|
+
for (const b of emitterBoxes) {
|
|
192
|
+
for (let k = 0; k < 3; k++) {
|
|
193
|
+
gMin[k] = Math.min(gMin[k], b.min[k]);
|
|
194
|
+
gMax[k] = Math.max(gMax[k], b.max[k]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const center = [(gMin[0] + gMax[0]) / 2, (gMin[1] + gMax[1]) / 2, (gMin[2] + gMax[2]) / 2];
|
|
198
|
+
let size = [gMax[0] - gMin[0], gMax[1] - gMin[1], gMax[2] - gMin[2]];
|
|
199
|
+
const grow = (Math.max(size[0], size[1], size[2]) * Math.max(0, settings.range - 1)) / 2;
|
|
200
|
+
for (let k = 0; k < 3; k++) {
|
|
201
|
+
gMin[k] = gMin[k] - grow;
|
|
202
|
+
gMax[k] = gMax[k] + grow;
|
|
203
|
+
}
|
|
204
|
+
size = [Math.max(gMax[0] - gMin[0], 1e-6), Math.max(gMax[1] - gMin[1], 1e-6), Math.max(gMax[2] - gMin[2], 1e-6)];
|
|
205
|
+
const lastSize = Math.max(size[0], size[1], size[2]);
|
|
206
|
+
const fineHalfSize = Math.min(settings.distance, lastSize / 2);
|
|
207
|
+
const min = [];
|
|
208
|
+
const sizes = [];
|
|
209
|
+
for (let cascade = 0; cascade < cascades - 1; cascade++) {
|
|
210
|
+
const halfSize = fineHalfSize / Math.pow(2, cascades - 1 - cascade);
|
|
211
|
+
const voxel = Math.pow(2, Math.ceil(Math.log2((halfSize * 2) / (resolution - 1))));
|
|
212
|
+
const s = voxel * resolution;
|
|
213
|
+
const bMin = [0, 1, 2].map((k) => Math.floor((cameraPosition[k] - halfSize) / voxel) * voxel);
|
|
214
|
+
const bMax = [bMin[0] + s, bMin[1] + s, bMin[2] + s];
|
|
215
|
+
const intersects = bMax[0] >= gMin[0] && bMin[0] <= gMax[0] && bMax[1] >= gMin[1] && bMin[1] <= gMax[1] && bMax[2] >= gMin[2] && bMin[2] <= gMax[2];
|
|
216
|
+
if (s >= lastSize || !intersects)
|
|
217
|
+
continue;
|
|
218
|
+
min.push(bMin);
|
|
219
|
+
sizes.push([s, s, s]);
|
|
220
|
+
}
|
|
221
|
+
min.push([gMin[0], gMin[1], gMin[2]]);
|
|
222
|
+
sizes.push(size);
|
|
223
|
+
const key = [resolution];
|
|
224
|
+
for (let i = 0; i < min.length; i++)
|
|
225
|
+
key.push(...min[i], ...sizes[i]);
|
|
226
|
+
return { resolution, count: min.length, min, size: sizes, center, key: key.join(",") };
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Past the last cascade (the light node, L490–506): the clamped edge probe's light falls off as the squared distance
|
|
230
|
+
* ratio |edge − centre|² / |p − centre|² (≤ 1).
|
|
231
|
+
*/
|
|
232
|
+
export function vdbFrameEmissionFalloff(edge, position, center) {
|
|
233
|
+
const a = [edge[0] - center[0], edge[1] - center[1], edge[2] - center[2]];
|
|
234
|
+
const b = [position[0] - center[0], position[1] - center[1], position[2] - center[2]];
|
|
235
|
+
return Math.min(1, dot(a, a) / Math.max(dot(b, b), 1e-6));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The light node's probe read (L457–507) on CPU atlases (the probe target's three attachments, rows bottom first):
|
|
239
|
+
* the finest cascade that holds the point (half a probe inside), blended into the next one over the last tenth of
|
|
240
|
+
* each side; outside every cascade, the last cascade's clamped edge with {@link vdbFrameEmissionFalloff}. Returns the
|
|
241
|
+
* (red, green, blue) L1 probe values and the falloff; {@link vdbFrameEmissionIrradiance} then gives E(n).
|
|
242
|
+
*/
|
|
243
|
+
export function vdbFrameEmissionLookup(atlases, grid, center, position) {
|
|
244
|
+
let probe = [
|
|
245
|
+
[0, 0, 0, 0],
|
|
246
|
+
[0, 0, 0, 0],
|
|
247
|
+
[0, 0, 0, 0],
|
|
248
|
+
];
|
|
249
|
+
let falloff = 1;
|
|
250
|
+
const sample = (cascade, uvw, weight) => {
|
|
251
|
+
probe = probe.map((p, k) => {
|
|
252
|
+
const s = vdbFrameSampleGrid(atlases[k], grid, cascade, uvw);
|
|
253
|
+
return p.map((v, c) => v + (s[c] - v) * weight);
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
if (grid.count > 0) {
|
|
257
|
+
const cascade = vdbFrameFindCascade(grid, position, 0);
|
|
258
|
+
if (cascade >= 0) {
|
|
259
|
+
const uvw = vdbFrameGridUvw(grid, cascade, position);
|
|
260
|
+
sample(cascade, uvw, 1);
|
|
261
|
+
const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);
|
|
262
|
+
const t = Math.min(1, Math.max(0, side / 0.1));
|
|
263
|
+
const blend = 1 - t * t * (3 - 2 * t);
|
|
264
|
+
if (blend > 0) {
|
|
265
|
+
const next = vdbFrameFindCascade(grid, position, cascade + 1);
|
|
266
|
+
if (next >= 0)
|
|
267
|
+
sample(next, vdbFrameGridUvw(grid, next, position), blend);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
const last = grid.count - 1;
|
|
272
|
+
const inset = 0.5 / grid.resolution;
|
|
273
|
+
const uvw = vdbFrameGridUvw(grid, last, position).map((v) => Math.min(1 - inset, Math.max(inset, v)));
|
|
274
|
+
const m = grid.gridMin[last];
|
|
275
|
+
const s = grid.gridSize[last];
|
|
276
|
+
sample(last, uvw, 1);
|
|
277
|
+
falloff = vdbFrameEmissionFalloff([m[0] + uvw[0] * s[0], m[1] + uvw[1] * s[1], m[2] + uvw[2] * s[2]], position, center);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return { probe, falloff };
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=emission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emission.js","sourceRoot":"","sources":["../../../src/tools/frame/emission.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gHAAgH;AAChH,4GAA4G;AAC5G,8GAA8G;AAC9G,wBAAwB;AACxB,4GAA4G;AAC5G,4GAA4G;AAC5G,sEAAsE;AAUtE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAA+C,MAAM,WAAW,CAAC;AAElI,iFAAiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,wFAAwF;AACxF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AACnC,6FAA6F;AAC7F,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B,GAAG,wBAAwB,CAAC,CAAC,CAAC;AACrH,MAAM,CAAC,MAAM,sBAAsB,GA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AAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAS,CAAC;YAC9G,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YACrB,OAAO,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/FrameEmissionLight.js L3–15 (constants), L138–150 (emitter centre and radius),\n// L182–241 (updateProbeGrid); src/three-openvdb/frame/webgpu/FrameEmissionLight.js L59–60 (golden angle),\n// L168–237 (the direction pass), L259–279 (the reduce pass), L310–364 (the probe pass), L457–519 (the light\n// node's irradiance).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free TypeScript CPU twins (f64) of his emission-light maths; boxes and matrices are plain\n// arrays (column-major). Divergences: none (twins of the ported TSL).\n\n/**\n * K3.6: CPU twins of the emission light (his `FrameEmissionLight`): each emissive volume's light along 16\n * Fibonacci directions × 8² parallel rays (direction pass), its mean intensity and luminance-weighted centre\n * (reduce pass), the L1 irradiance probes of all volumes as point lights (probe pass), the probe cascades\n * (power-of-two snapped) and the irradiance a lit surface reads.\n */\n\nimport type { Vec3, Vec4 } from \"./index.js\";\nimport { vdbFrameFindCascade, vdbFrameGridUvw, vdbFrameSampleGrid, type VDBFrameAtlas, type VDBFrameGridLayout } from \"./grid.js\";\n\n/** Directions of each volume's emitted light (his `frameEmissionDirections`). */\nexport const frameEmissionDirections = 16;\n/** Rays on each side of the square that covers the volume (his `frameEmissionRays`). */\nexport const frameEmissionRays = 8;\n/** Probes per axis, at most (the atlas is made for it; his `frameEmissionMaxResolution`). */\nexport const frameEmissionMaxResolution = 32;\nexport const frameEmissionMaxCascades = 4;\nexport const frameEmissionAtlasColumns = Math.ceil(Math.sqrt(frameEmissionMaxResolution * frameEmissionMaxCascades));\nexport const frameEmissionAtlasSize = frameEmissionMaxResolution * frameEmissionAtlasColumns;\n/** Golden angle in radians: Fibonacci directions turn by it. */\nexport const frameEmissionGoldenAngle = Math.PI * (3.0 - Math.sqrt(5.0));\n/** Linear-sRGB luminance (three's `luminance()` with the working colour space's coefficients). */\nexport const frameEmissionLuminance: Vec3 = [0.2126, 0.7152, 0.0722];\n\nconst cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\nconst dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\nconst normalize = (a: Vec3): Vec3 => {\n const l = Math.sqrt(dot(a, a));\n return [a[0] / l, a[1] / l, a[2] / l];\n};\nconst apply = (m: ArrayLike<number>, p: Vec3): Vec3 => [\n m[0]! * p[0] + m[4]! * p[1] + m[8]! * p[2] + m[12]!,\n m[1]! * p[0] + m[5]! * p[1] + m[9]! * p[2] + m[13]!,\n m[2]! * p[0] + m[6]! * p[1] + m[10]! * p[2] + m[14]!,\n];\n\n/** Direction `index` (0–15) of the direction pass: a Fibonacci sphere point, from the volume to the viewer, with its tangent frame. */\nexport function vdbFrameEmissionDirection(index: number): { direction: Vec3; tangent: Vec3; bitangent: Vec3 } {\n const y = 1 - (index * 2 + 1) / frameEmissionDirections;\n const ring = Math.sqrt(Math.max(0, 1 - y * y));\n const phi = index * frameEmissionGoldenAngle;\n const direction: Vec3 = [Math.cos(phi) * ring, y, Math.sin(phi) * ring];\n const helper: Vec3 = Math.abs(direction[1]) < 0.999 ? [0, 1, 0] : [1, 0, 0];\n const tangent = normalize(cross(helper, direction));\n return { direction, tangent, bitangent: cross(direction, tangent) };\n}\n\n/** His `boxSegment` of the local unit box ([−½, ½]³): the [t0, t1] ⊂ [0, 1] of the segment inside it. */\nexport function vdbFrameBoxSegment(start: Vec3, end: Vec3): [number, number] {\n let t0 = -Infinity;\n let t1 = Infinity;\n for (let c = 0; c < 3; c++) {\n const inv = 1 / (end[c]! - start[c]!);\n const a = (-0.5 - start[c]!) * inv;\n const b = (0.5 - start[c]!) * inv;\n t0 = Math.max(t0, Math.min(a, b));\n t1 = Math.min(t1, Math.max(a, b));\n }\n return [Math.max(0, t0), Math.min(1, t1)];\n}\n\n/** One emitter as the direction pass reads it. Samplers take local positions (unit box) and a mip lod. */\nexport interface VDBFrameEmitter {\n /** Extinction per world unit (the source's `sampleExtinction`). */\n sampleExtinction(local: Vec3, lod: number): number;\n /** Emitted radiance (the source's `sampleEmission`; the pass reads lod 0). */\n sampleEmission(local: Vec3, lod: number): Vec3;\n /** The source's `getLod` of a local size. */\n getLod(localSize: number): number;\n /** World → local unit box, column-major. */\n worldToLocal: ArrayLike<number>;\n center: Vec3;\n radius: number;\n /** World scale of the volume (`matrixWorld.getMaxScaleOnAxis()`). */\n worldScale: number;\n absorbance: number;\n steps: number;\n}\n\n/**\n * The emitter centre and bounding radius (FrameEmissionLight core L138–150): the translation of the volume's world\n * matrix (unit box → world) and the largest distance of a box corner from it.\n */\nexport function vdbFrameEmitterBounds(matrixWorld: ArrayLike<number>): { center: Vec3; radius: number; min: Vec3; max: Vec3 } {\n const center: Vec3 = [matrixWorld[12]!, matrixWorld[13]!, matrixWorld[14]!];\n let radius = 0;\n const min: Vec3 = [Infinity, Infinity, Infinity];\n const max: Vec3 = [-Infinity, -Infinity, -Infinity];\n for (let i = 0; i < 8; i++) {\n const corner = apply(matrixWorld, [i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5]);\n radius = Math.max(radius, Math.hypot(corner[0] - center[0], corner[1] - center[1], corner[2] - center[2]));\n for (let c = 0; c < 3; c++) {\n min[c] = Math.min(min[c]!, corner[c]!);\n max[c] = Math.max(max[c]!, corner[c]!);\n }\n }\n return { center, radius, min, max };\n}\n\n/**\n * One texel of the direction pass (his FrameEmissionDirectionMaterial): the emitted light of the volume toward\n * direction `index`, summed over 8² parallel rays that cover its bounding sphere. Each ray adds emission × α × the\n * transmittance so far (absorbance scales the transmittance, as for scene lights) and stops below 1%. Returns output\n * 0 (intensity × ray area, radius) and output 1 (luminance-weighted world position × ray area, weight × area).\n */\nexport function vdbFrameEmissionDirectionTexel(emitter: VDBFrameEmitter, index: number): { intensity: Vec4; center: Vec4 } {\n const { direction, tangent, bitangent } = vdbFrameEmissionDirection(index);\n const { center: c, radius, steps } = emitter;\n const diameter = radius * 2;\n const spacing = diameter / frameEmissionRays;\n const intensity: Vec3 = [0, 0, 0];\n const center: Vec4 = [0, 0, 0, 0];\n for (let r = 0; r < frameEmissionRays * frameEmissionRays; r++) {\n const u = (((r % frameEmissionRays) + 0.5) / frameEmissionRays) * 2 - 1;\n const v = ((Math.floor(r / frameEmissionRays) + 0.5) / frameEmissionRays) * 2 - 1;\n const worldStart: Vec3 = [0, 1, 2].map((k) => c[k]! + direction[k]! * radius + tangent[k]! * u * radius + bitangent[k]! * v * radius) as Vec3;\n const worldEnd: Vec3 = [0, 1, 2].map((k) => worldStart[k]! - direction[k]! * diameter) as Vec3;\n const localStart = apply(emitter.worldToLocal, worldStart);\n const localEnd = apply(emitter.worldToLocal, worldEnd);\n const segment = vdbFrameBoxSegment(localStart, localEnd);\n if (!(segment[0] < segment[1])) continue;\n const segmentLength = segment[1] - segment[0];\n const stepLength = (segmentLength * diameter) / steps;\n const lod = emitter.getLod(stepLength / emitter.worldScale);\n let transmittance = 1;\n for (let s = 0; s < steps; s++) {\n const t = segment[0] + segmentLength * ((s + 0.5) / steps);\n const local: Vec3 = [0, 1, 2].map((k) => localStart[k]! + (localEnd[k]! - localStart[k]!) * t) as Vec3;\n const extinction = emitter.sampleExtinction(local, lod);\n if (extinction > 0) {\n const alpha = 1 - Math.exp(-extinction * stepLength);\n const e = emitter.sampleEmission(local, 0);\n const radiance: Vec3 = [e[0] * transmittance * alpha, e[1] * transmittance * alpha, e[2] * transmittance * alpha];\n const weight = dot(radiance, frameEmissionLuminance);\n for (let k = 0; k < 3; k++) {\n intensity[k] = intensity[k]! + radiance[k]!;\n center[k] = center[k]! + (worldStart[k]! + (worldEnd[k]! - worldStart[k]!) * t) * weight;\n }\n center[3] += weight;\n transmittance *= Math.exp(-extinction * emitter.absorbance * stepLength);\n if (transmittance < 0.01) break;\n }\n }\n }\n const area = spacing * spacing;\n return { intensity: [intensity[0] * area, intensity[1] * area, intensity[2] * area, radius], center: [center[0] * area, center[1] * area, center[2] * area, center[3] * area] };\n}\n\n/** The reduce pass: mean intensity of the 16 directions, and the centre of the visible emission ((0,0,0,0) when none). */\nexport function vdbFrameEmissionReduce(texels: readonly { intensity: Vec4; center: Vec4 }[]): { intensity: Vec4; center: Vec4 } {\n const intensity: Vec4 = [0, 0, 0, 0];\n const center: Vec4 = [0, 0, 0, 0];\n for (const t of texels) {\n for (let k = 0; k < 4; k++) {\n intensity[k] = intensity[k]! + t.intensity[k]!;\n center[k] = center[k]! + t.center[k]!;\n }\n }\n for (let k = 0; k < 4; k++) intensity[k] = intensity[k]! / frameEmissionDirections;\n const visible = center[3] > 0;\n const w = Math.max(center[3], 1e-12);\n return { intensity, center: visible ? [center[0] / w, center[1] / w, center[2] / w, 1] : [0, 0, 0, 0] };\n}\n\n/** One emitter of the probe pass: the reduce outputs (intensity rgb + radius, centre + visible flag). */\nexport interface VDBFrameEmitterLight {\n intensity: Vec4;\n center: Vec4;\n}\n\n/**\n * One probe of the probe pass: the L1 irradiance of every emitter as a point light at its emission centre,\n * E(n) = E/4 + E/2 · dot(l, n), softened near the centre by a quarter of the radius. Returns (red, green, blue),\n * each (constant, direction xyz).\n */\nexport function vdbFrameEmissionProbe(probe: Vec3, emitters: readonly VDBFrameEmitterLight[]): [Vec4, Vec4, Vec4] {\n const constant: Vec3 = [0, 0, 0];\n const dirs: [Vec3, Vec3, Vec3] = [\n [0, 0, 0],\n [0, 0, 0],\n [0, 0, 0],\n ];\n for (const e of emitters) {\n if (!(e.center[3] > 0)) continue;\n const toProbe: Vec3 = [probe[0] - e.center[0], probe[1] - e.center[1], probe[2] - e.center[2]];\n const d2 = dot(toProbe, toProbe);\n const soft = e.intensity[3] * 0.25;\n const sd2 = d2 + soft * soft;\n const irradiance: Vec3 = [e.intensity[0] / sd2, e.intensity[1] / sd2, e.intensity[2] / sd2];\n const scale = (1 / Math.sqrt(Math.max(d2, 1e-12))) * (d2 / sd2) * -0.5;\n const toLight: Vec3 = [toProbe[0] * scale, toProbe[1] * scale, toProbe[2] * scale];\n for (let k = 0; k < 3; k++) {\n constant[k] = constant[k]! + irradiance[k]! * 0.25;\n for (let a = 0; a < 3; a++) dirs[k]![a] = dirs[k]![a]! + toLight[a]! * irradiance[k]!;\n }\n }\n return [\n [constant[0], ...dirs[0]],\n [constant[1], ...dirs[1]],\n [constant[2], ...dirs[2]],\n ];\n}\n\n/** The light node's irradiance from (filtered) probe values: max(x + dot(yzw, n), 0) per channel, × falloff. */\nexport function vdbFrameEmissionIrradiance(probe: readonly [Vec4, Vec4, Vec4], normal: Vec3, falloff = 1): Vec3 {\n return probe.map((p) => Math.max(0, p[0] + p[1] * normal[0] + p[2] * normal[1] + p[3] * normal[2]) * falloff) as Vec3;\n}\n\n/** Settings of the probe cascades (his `FrameEmissionLight` props). */\nexport interface VDBFrameEmissionGridSettings {\n resolution: number;\n range: number;\n cascades: number;\n distance: number;\n}\n\n/** The probe cascades (cascade 0 finest), the centre of all emitters, and a key that changes with them. */\nexport interface VDBFrameEmissionGrid {\n resolution: number;\n count: number;\n min: Vec3[];\n size: Vec3[];\n center: Vec3;\n key: string;\n}\n\n/**\n * updateProbeGrid (FrameEmissionLight core L186–241): the last cascade is the box of all emitters grown by\n * (range − 1)/2 of its longest side on each side; finer cascades are power-of-two-voxel cubes around the camera,\n * each half the next, snapped to their voxel; a fine cascade that is not finer than the last or holds no emitter is\n * skipped.\n */\nexport function vdbFrameEmissionProbeGrid(settings: VDBFrameEmissionGridSettings, emitterBoxes: readonly { min: Vec3; max: Vec3 }[], cameraPosition: Vec3): VDBFrameEmissionGrid {\n const resolution = Math.min(frameEmissionMaxResolution, Math.max(2, Math.round(settings.resolution)));\n const cascades = Math.min(frameEmissionMaxCascades, Math.max(1, Math.round(settings.cascades)));\n const gMin: Vec3 = [Infinity, Infinity, Infinity];\n const gMax: Vec3 = [-Infinity, -Infinity, -Infinity];\n for (const b of emitterBoxes) {\n for (let k = 0; k < 3; k++) {\n gMin[k] = Math.min(gMin[k]!, b.min[k]!);\n gMax[k] = Math.max(gMax[k]!, b.max[k]!);\n }\n }\n const center: Vec3 = [(gMin[0] + gMax[0]) / 2, (gMin[1] + gMax[1]) / 2, (gMin[2] + gMax[2]) / 2];\n let size: Vec3 = [gMax[0] - gMin[0], gMax[1] - gMin[1], gMax[2] - gMin[2]];\n const grow = (Math.max(size[0], size[1], size[2]) * Math.max(0, settings.range - 1)) / 2;\n for (let k = 0; k < 3; k++) {\n gMin[k] = gMin[k]! - grow;\n gMax[k] = gMax[k]! + grow;\n }\n size = [Math.max(gMax[0] - gMin[0], 1e-6), Math.max(gMax[1] - gMin[1], 1e-6), Math.max(gMax[2] - gMin[2], 1e-6)];\n const lastSize = Math.max(size[0], size[1], size[2]);\n const fineHalfSize = Math.min(settings.distance, lastSize / 2);\n const min: Vec3[] = [];\n const sizes: Vec3[] = [];\n for (let cascade = 0; cascade < cascades - 1; cascade++) {\n const halfSize = fineHalfSize / Math.pow(2, cascades - 1 - cascade);\n const voxel = Math.pow(2, Math.ceil(Math.log2((halfSize * 2) / (resolution - 1))));\n const s = voxel * resolution;\n const bMin = [0, 1, 2].map((k) => Math.floor((cameraPosition[k]! - halfSize) / voxel) * voxel) as Vec3;\n const bMax = [bMin[0] + s, bMin[1] + s, bMin[2] + s] as Vec3;\n const intersects = bMax[0] >= gMin[0] && bMin[0] <= gMax[0] && bMax[1] >= gMin[1] && bMin[1] <= gMax[1] && bMax[2] >= gMin[2] && bMin[2] <= gMax[2];\n if (s >= lastSize || !intersects) continue;\n min.push(bMin);\n sizes.push([s, s, s]);\n }\n min.push([gMin[0], gMin[1], gMin[2]]);\n sizes.push(size);\n const key = [resolution];\n for (let i = 0; i < min.length; i++) key.push(...min[i]!, ...sizes[i]!);\n return { resolution, count: min.length, min, size: sizes, center, key: key.join(\",\") };\n}\n\n/**\n * Past the last cascade (the light node, L490–506): the clamped edge probe's light falls off as the squared distance\n * ratio |edge − centre|² / |p − centre|² (≤ 1).\n */\nexport function vdbFrameEmissionFalloff(edge: Vec3, position: Vec3, center: Vec3): number {\n const a: Vec3 = [edge[0] - center[0], edge[1] - center[1], edge[2] - center[2]];\n const b: Vec3 = [position[0] - center[0], position[1] - center[1], position[2] - center[2]];\n return Math.min(1, dot(a, a) / Math.max(dot(b, b), 1e-6));\n}\n\n/**\n * The light node's probe read (L457–507) on CPU atlases (the probe target's three attachments, rows bottom first):\n * the finest cascade that holds the point (half a probe inside), blended into the next one over the last tenth of\n * each side; outside every cascade, the last cascade's clamped edge with {@link vdbFrameEmissionFalloff}. Returns the\n * (red, green, blue) L1 probe values and the falloff; {@link vdbFrameEmissionIrradiance} then gives E(n).\n */\nexport function vdbFrameEmissionLookup(atlases: readonly [VDBFrameAtlas, VDBFrameAtlas, VDBFrameAtlas], grid: VDBFrameGridLayout, center: Vec3, position: Vec3): { probe: [Vec4, Vec4, Vec4]; falloff: number } {\n let probe: [Vec4, Vec4, Vec4] = [\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0],\n ];\n let falloff = 1;\n const sample = (cascade: number, uvw: Vec3, weight: number) => {\n probe = probe.map((p, k) => {\n const s = vdbFrameSampleGrid(atlases[k]!, grid, cascade, uvw);\n return p.map((v, c) => v + (s[c]! - v) * weight) as Vec4;\n }) as [Vec4, Vec4, Vec4];\n };\n if (grid.count > 0) {\n const cascade = vdbFrameFindCascade(grid, position, 0);\n if (cascade >= 0) {\n const uvw = vdbFrameGridUvw(grid, cascade, position);\n sample(cascade, uvw, 1);\n const side = Math.min(uvw[0], uvw[1], uvw[2], 1 - uvw[0], 1 - uvw[1], 1 - uvw[2]);\n const t = Math.min(1, Math.max(0, side / 0.1));\n const blend = 1 - t * t * (3 - 2 * t);\n if (blend > 0) {\n const next = vdbFrameFindCascade(grid, position, cascade + 1);\n if (next >= 0) sample(next, vdbFrameGridUvw(grid, next, position), blend);\n }\n } else {\n const last = grid.count - 1;\n const inset = 0.5 / grid.resolution;\n const uvw = vdbFrameGridUvw(grid, last, position).map((v) => Math.min(1 - inset, Math.max(inset, v))) as Vec3;\n const m = grid.gridMin[last]!;\n const s = grid.gridSize[last]!;\n sample(last, uvw, 1);\n falloff = vdbFrameEmissionFalloff([m[0] + uvw[0] * s[0], m[1] + uvw[1] * s[1], m[2] + uvw[2] * s[2]], position, center);\n }\n }\n return { probe, falloff };\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-directional environment light (Disney "Deep Scattering", §4.4 and §7), engine-free (K3.3):
|
|
3
|
+
* the scene environment is read once into a small lat-long map (64 × 32, PMREM roughness 0.4); the
|
|
4
|
+
* CPU turns it into ≤ 12 directional lights. `'directional'`: the brightest texel plus fixed sky
|
|
5
|
+
* directions (zenith, nadir, a horizon ring; opposite pairs with diffusion), each texel to its
|
|
6
|
+
* nearest seed, a light at the energy centroid with energy / 4. `'spherical-harmonics'`: SH L1/L2
|
|
7
|
+
* projection evaluated at quadrature directions. The three adapter draws the map and passes the
|
|
8
|
+
* readback through `extract`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const frameMaxEnvironmentLights = 12;
|
|
11
|
+
export declare const frameMaxEnvironmentSamples = 8;
|
|
12
|
+
export declare const frameEnvironmentMapWidth = 64;
|
|
13
|
+
export declare const frameEnvironmentMapHeight = 32;
|
|
14
|
+
/** PMREM blur of the map: a small sun covers more than one texel and is not lost between texels. */
|
|
15
|
+
export declare const frameEnvironmentMapRoughness = 0.4;
|
|
16
|
+
export declare const frameEnvironmentModes: {
|
|
17
|
+
readonly outward: "outward";
|
|
18
|
+
readonly directional: "directional";
|
|
19
|
+
readonly sphericalHarmonics: "spherical-harmonics";
|
|
20
|
+
};
|
|
21
|
+
export type VDBFrameEnvironmentMode = (typeof frameEnvironmentModes)[keyof typeof frameEnvironmentModes];
|
|
22
|
+
/** The renderer settings the environment lights read. */
|
|
23
|
+
export interface VDBFrameEnvironmentSettings {
|
|
24
|
+
environmentLighting: string;
|
|
25
|
+
environmentSamples: number;
|
|
26
|
+
environmentShOrder: number;
|
|
27
|
+
multipleScattering: boolean | string;
|
|
28
|
+
}
|
|
29
|
+
/** The scene fields the environment lights read (three's `Scene` fits). */
|
|
30
|
+
export interface VDBFrameEnvironmentScene {
|
|
31
|
+
environment: {
|
|
32
|
+
uuid: string;
|
|
33
|
+
version: number;
|
|
34
|
+
} | null;
|
|
35
|
+
environmentRotation: {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
z: number;
|
|
39
|
+
order: string;
|
|
40
|
+
};
|
|
41
|
+
environmentIntensity: number;
|
|
42
|
+
}
|
|
43
|
+
type V3 = [number, number, number];
|
|
44
|
+
/** The same direction as the map shaders. u and v are 0 to 1; v = 0 is +Y. */
|
|
45
|
+
export declare const vdbFrameEnvironmentMapDirection: (u: number, v: number) => V3;
|
|
46
|
+
export declare const vdbFrameEnvironmentMode: (settings: Pick<VDBFrameEnvironmentSettings, "environmentLighting">) => VDBFrameEnvironmentMode;
|
|
47
|
+
interface Texel {
|
|
48
|
+
radiance: V3;
|
|
49
|
+
luminance: number;
|
|
50
|
+
direction: V3;
|
|
51
|
+
solidAngle: number;
|
|
52
|
+
}
|
|
53
|
+
/** One environment light: world direction to the light and its isotropic irradiance colour (energy / 4). */
|
|
54
|
+
export interface VDBFrameEnvironmentLight {
|
|
55
|
+
direction: V3;
|
|
56
|
+
color: V3;
|
|
57
|
+
power?: number;
|
|
58
|
+
}
|
|
59
|
+
/** Output of {@link VDBFrameEnvironmentLights.update}. Colours include `scene.environmentIntensity`. */
|
|
60
|
+
export interface VDBFrameEnvironmentResult {
|
|
61
|
+
mode: VDBFrameEnvironmentMode;
|
|
62
|
+
count: number;
|
|
63
|
+
directions: V3[];
|
|
64
|
+
colors: V3[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* His `FrameEnvironmentLights`: holds the lat-long map of the scene environment and the lights made
|
|
68
|
+
* from it. `extract(renderer, scene)` is the engine part: it draws the map (RGB radiance, A the
|
|
69
|
+
* texel's v, so the readback row order does not matter) and resolves RGBA floats.
|
|
70
|
+
*/
|
|
71
|
+
export declare class VDBFrameEnvironmentLights<R = unknown, S extends VDBFrameEnvironmentScene = VDBFrameEnvironmentScene> {
|
|
72
|
+
readonly extract: (renderer: R, scene: S) => Promise<ArrayLike<number>>;
|
|
73
|
+
key: string | null;
|
|
74
|
+
pending: boolean;
|
|
75
|
+
retryAt: number;
|
|
76
|
+
updates: number;
|
|
77
|
+
texels: Texel[] | null;
|
|
78
|
+
texelsVersion: number;
|
|
79
|
+
warned: boolean;
|
|
80
|
+
lightsKey: string | null;
|
|
81
|
+
lights: VDBFrameEnvironmentLight[];
|
|
82
|
+
readonly result: VDBFrameEnvironmentResult;
|
|
83
|
+
constructor(extract: (renderer: R, scene: S) => Promise<ArrayLike<number>>);
|
|
84
|
+
getKey(scene: S): string;
|
|
85
|
+
/** Null when the 'outward' path must be used: another mode, no environment, or no map yet. */
|
|
86
|
+
update(renderer: R, scene: S, settings: VDBFrameEnvironmentSettings): VDBFrameEnvironmentResult | null;
|
|
87
|
+
/** Resolves when a pending map readback has settled (tests and harnesses; not his). */
|
|
88
|
+
settled: Promise<void>;
|
|
89
|
+
requestMap(renderer: R, scene: S, key: string): void;
|
|
90
|
+
/** Radiance, direction and solid angle of each texel. Returns false for an empty map. Half floats (Uint16Array) are decoded. */
|
|
91
|
+
setTexels(pixels: ArrayLike<number>): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Dominant direction (brightest texel) and fixed sky directions: zenith, nadir, then a horizon ring.
|
|
94
|
+
* Each texel goes to the nearest direction; a light is at the energy centroid of its texels with
|
|
95
|
+
* their energy; colour is energy / 4 (a uniform environment then gives the 'outward' light).
|
|
96
|
+
* `pairs`: seeds in opposite pairs (diffusion weights of a pair sum to 2).
|
|
97
|
+
*/
|
|
98
|
+
getDirectionalLights(samples: number, pairs?: boolean): VDBFrameEnvironmentLight[];
|
|
99
|
+
/**
|
|
100
|
+
* SH projection of the environment (L1: 4, L2: 9 coefficients) evaluated at quadrature directions:
|
|
101
|
+
* direction m gets the colour (4π / M) L_sh(w_m) / 4. The shaders clamp the sum to ≥ 0.
|
|
102
|
+
*/
|
|
103
|
+
getShLights(order: number): VDBFrameEnvironmentLight[];
|
|
104
|
+
}
|
|
105
|
+
export {};
|