@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,257 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/FrameLightingMaterial.js L43–119 (constructor, uniforms),
|
|
3
|
+
// L277–437 (the grey `createFragmentNode`); K3.5: L55–62 (the spectral maps and groups), L86–112
|
|
4
|
+
// (setSpectral, rebuildNodes), L114–275 (createSpectralFragmentNode).
|
|
5
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
6
|
+
// Changes: TypeScript; source-free. K3.4: the octave uniform (L71–72) and the octave light of lights
|
|
7
|
+
// without a shadow slot (L386–397).
|
|
8
|
+
// Divergences: DIVERGES.md (K3.3 rows).
|
|
9
|
+
/**
|
|
10
|
+
* The lighting pass of `'frame'` lighting (R1 §2 step 4): each froxel of the volumes' froxel area is
|
|
11
|
+
* lit once from the combined density targets: ambient, light probe SH and hemisphere light with the
|
|
12
|
+
* sky up / down transmittance, the scene lights (with a shadow slot: the density pass's
|
|
13
|
+
* phase × direct + scattered; else unshadowed), and the dominant directional environment light in
|
|
14
|
+
* its slot. Writes premultiplied (radiance × alpha, alpha) into the froxel atlas, as the inject pass.
|
|
15
|
+
* Spectral (K3.5): the transmittance of each channel is sampled from the slot groups' targets at the
|
|
16
|
+
* froxel's visible position (the density pass has no slots then); two atlas targets, (radiance × alpha
|
|
17
|
+
* of each channel, green alpha) and (red alpha, blue alpha, 0, green alpha).
|
|
18
|
+
*/
|
|
19
|
+
import * as THREE from "three";
|
|
20
|
+
import { NodeMaterial } from "three/webgpu";
|
|
21
|
+
import * as TSL from "three/tsl";
|
|
22
|
+
import { createGridNodes, frameFragCoord, frameGetFroxel, frameLoad, framePhaseColor, frameShadowedLight, frameSpectralShadowTotal, frameSpectralShadowedLight, frameTileVertex, frameUnpackSpectralGroup } from "./chunks.js";
|
|
23
|
+
import { frameSpectralGroupCount } from "./spectrum.js";
|
|
24
|
+
const { Discard, Fn, If, Loop, clamp, dot, exp, float, getDistanceAttenuation, getShIrradianceAt, int, ivec2, length, mat3, max, mix, normalize, outputStruct, property, select, smoothstep, texture, uniform, vec2, vec3, vec4 } = TSL;
|
|
25
|
+
// NOTE Lights each froxel one time from the combined data of all volumes.
|
|
26
|
+
// NOTE The environment is added in the density pass, along the outward direction of each volume.
|
|
27
|
+
export class VDBFrameLightingMaterial extends NodeMaterial {
|
|
28
|
+
frameDensityAlbedoMap = texture(new THREE.Texture());
|
|
29
|
+
frameDensityEmissionMap = texture(new THREE.Texture());
|
|
30
|
+
frameDensityShadowMap0 = texture(new THREE.Texture());
|
|
31
|
+
frameDensityShadowMap1 = texture(new THREE.Texture());
|
|
32
|
+
frameShadowLightCount = uniform(0, "int");
|
|
33
|
+
frameCameraMatrixWorld = uniform(new THREE.Matrix4());
|
|
34
|
+
// NOTE One phase for all volumes, from the renderer settings
|
|
35
|
+
framePhase = uniform(new THREE.Vector4());
|
|
36
|
+
framePhaseSpectrum = uniform(new THREE.Vector3());
|
|
37
|
+
// NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.
|
|
38
|
+
frameScatteringOctaves = uniform(new THREE.Vector4());
|
|
39
|
+
// NOTE Environment lights with a shadow slot (0 or 1). Light i has slot frameEnvironmentShadowSlot + i.
|
|
40
|
+
frameEnvironmentLightCount = uniform(0, "int");
|
|
41
|
+
frameEnvironmentShadowSlot = uniform(0, "int");
|
|
42
|
+
frameUniforms;
|
|
43
|
+
// NOTE Renderer settings.spectral: extinction of each channel (density target 2), and the 3 transmittance
|
|
44
|
+
// targets of each slot group (spectrum.ts), in group order. Groups from frameSpectralGroups on are not read.
|
|
45
|
+
frameDensityExtinctionMap = texture(new THREE.Texture());
|
|
46
|
+
frameSpectralTransmittanceMaps = Array.from({ length: frameSpectralGroupCount * 3 }, () => texture(new THREE.Texture()));
|
|
47
|
+
frameSpectralGroups = uniform(0, "int");
|
|
48
|
+
// NOTE Renderer settings.spectral: two atlas targets
|
|
49
|
+
spectral = false;
|
|
50
|
+
constructor(o) {
|
|
51
|
+
super();
|
|
52
|
+
this.name = "VDBFrameLightingMaterial";
|
|
53
|
+
this.frameUniforms = o;
|
|
54
|
+
// NOTE Only the froxel area of the volumes. Other froxels have no density.
|
|
55
|
+
this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);
|
|
56
|
+
this.rebuildNodes();
|
|
57
|
+
this.side = THREE.DoubleSide;
|
|
58
|
+
this.forceSinglePass = true;
|
|
59
|
+
this.depthTest = false;
|
|
60
|
+
this.depthWrite = false;
|
|
61
|
+
this.blending = THREE.NoBlending;
|
|
62
|
+
}
|
|
63
|
+
setSpectral(spectral) {
|
|
64
|
+
if (spectral !== this.spectral) {
|
|
65
|
+
this.spectral = spectral;
|
|
66
|
+
this.rebuildNodes();
|
|
67
|
+
this.needsUpdate = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// NOTE Spectral: atlas target 0 is (color, green alpha), target 1 is (red alpha, blue alpha, 0, green alpha)
|
|
71
|
+
rebuildNodes() {
|
|
72
|
+
if (!this.spectral) {
|
|
73
|
+
this.colorNode = null;
|
|
74
|
+
this.outputNode = null;
|
|
75
|
+
this.fragmentNode = this.createFragmentNode();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const lightingColor = property("vec4");
|
|
79
|
+
const lightingAlpha = property("vec4");
|
|
80
|
+
this.fragmentNode = null;
|
|
81
|
+
this.colorNode = this.createSpectralFragmentNode({ color: lightingColor, alpha: lightingAlpha });
|
|
82
|
+
this.outputNode = outputStruct(lightingColor, lightingAlpha);
|
|
83
|
+
}
|
|
84
|
+
// NOTE Spectral lighting. The density pass has no light slots, so the slots are sampled here,
|
|
85
|
+
// at the extinction-weighted visible position of all volumes in the froxel. Albedo and extinction are of each channel.
|
|
86
|
+
createSpectralFragmentNode(outputs) {
|
|
87
|
+
const { froxelUniforms, lightUniforms, gridUniforms } = this.frameUniforms;
|
|
88
|
+
const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;
|
|
89
|
+
const grid = createGridNodes(gridUniforms);
|
|
90
|
+
const atlasSize = froxelUniforms.froxelAtlasSize;
|
|
91
|
+
const octaves = this.frameScatteringOctaves;
|
|
92
|
+
return Fn(() => {
|
|
93
|
+
const fragCoord = frameFragCoord(atlasSize).toVar();
|
|
94
|
+
const texel = ivec2(fragCoord).toVar();
|
|
95
|
+
const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();
|
|
96
|
+
const weight = densityAlbedo.a.toVar();
|
|
97
|
+
If(weight.lessThanEqual(0.0), () => {
|
|
98
|
+
Discard();
|
|
99
|
+
});
|
|
100
|
+
const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();
|
|
101
|
+
const extinction = frameLoad(this.frameDensityExtinctionMap, texel, atlasSize).rgb.toVar();
|
|
102
|
+
const froxel = frameGetFroxel(froxelUniforms, fragCoord);
|
|
103
|
+
const viewNear = froxel.viewNear.toVar();
|
|
104
|
+
const viewFar = froxel.viewFar.toVar();
|
|
105
|
+
const visibleT = clamp(densityEmission.a.div(weight), 0.0, 1.0);
|
|
106
|
+
const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();
|
|
107
|
+
const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();
|
|
108
|
+
const albedo = densityAlbedo.rgb.div(max(extinction, vec3(1e-8))).toVar();
|
|
109
|
+
const emission = densityEmission.rgb.div(weight);
|
|
110
|
+
// NOTE Transmittance targets of the slot groups in use. 1.0 outside the grid, with no shadows and for other groups.
|
|
111
|
+
const maps = this.frameSpectralTransmittanceMaps.map(() => vec4(1.0).toVar());
|
|
112
|
+
for (let group = 0; group < frameSpectralGroupCount; group++) {
|
|
113
|
+
const groupMaps = this.frameSpectralTransmittanceMaps.slice(group * 3, group * 3 + 3);
|
|
114
|
+
If(int(group).lessThan(this.frameSpectralGroups), () => {
|
|
115
|
+
const shadows = grid.sampleShadows(groupMaps, worldPosition);
|
|
116
|
+
shadows.forEach((shadow, index) => maps[group * 3 + index].assign(shadow));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// NOTE Group 0: sky (up, down) and slot 0. Group g: slots 2g - 1 and 2g. Slot entries are (total, direct).
|
|
120
|
+
const groups = Array.from({ length: frameSpectralGroupCount }, (_, group) => frameUnpackSpectralGroup(maps[group * 3], maps[group * 3 + 1], maps[group * 3 + 2]));
|
|
121
|
+
const slotEntry = (slot) => (slot === 0 ? groups[0].b : slot % 2 === 1 ? groups[(slot + 1) / 2].a : groups[slot / 2].b);
|
|
122
|
+
const skyDirection = normalize(frameSkyDirection).toVar();
|
|
123
|
+
const skyUp = frameSpectralShadowTotal(groups[0].a.x, octaves, albedo).mul(0.5).toVar();
|
|
124
|
+
const skyDown = frameSpectralShadowTotal(groups[0].a.y, octaves, albedo).mul(0.5).toVar();
|
|
125
|
+
const irradiance = vec3(frameAmbientColor).toVar();
|
|
126
|
+
irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));
|
|
127
|
+
irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));
|
|
128
|
+
irradiance.addAssign(frameHemiSkyColor.mul(skyUp));
|
|
129
|
+
irradiance.addAssign(frameHemiGroundColor.mul(skyDown));
|
|
130
|
+
const slots = Array.from({ length: 6 }, (_, slot) => ({
|
|
131
|
+
total: slotEntry(slot).x.toVar(),
|
|
132
|
+
direct: slotEntry(slot).y.toVar(),
|
|
133
|
+
}));
|
|
134
|
+
Loop(frameLightCount, ({ i }) => {
|
|
135
|
+
const position = frameLightPositions.element(i).toVar();
|
|
136
|
+
const color = frameLightColors.element(i).toVar();
|
|
137
|
+
const spot = frameLightSpots.element(i).toVar();
|
|
138
|
+
const falloff = frameLightFalloffs.element(i).toVar();
|
|
139
|
+
const lightVector = position.xyz.sub(worldPosition).toVar();
|
|
140
|
+
// NOTE A light with no shadow slot: no shadow (1.0), then octaves still add their light
|
|
141
|
+
let total = vec3(1.0);
|
|
142
|
+
let direct = vec3(1.0);
|
|
143
|
+
slots.forEach((slot, index) => {
|
|
144
|
+
const useSlot = i.equal(index).and(i.lessThan(this.frameShadowLightCount));
|
|
145
|
+
total = select(useSlot, slot.total, total);
|
|
146
|
+
direct = select(useSlot, slot.direct, direct);
|
|
147
|
+
});
|
|
148
|
+
const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));
|
|
149
|
+
const distanceAttenuation = select(position.w.greaterThan(1.5), getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }), float(1.0));
|
|
150
|
+
// NOTE Directional position xyz is the direction to the light
|
|
151
|
+
const light = frameSpectralShadowedLight(this.framePhase, this.framePhaseSpectrum, octaves, rayDirection, select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)), { x: direct.toVar(), y: total.toVar() }, albedo);
|
|
152
|
+
irradiance.addAssign(color.rgb.mul(light).mul(spotAttenuation).mul(distanceAttenuation));
|
|
153
|
+
});
|
|
154
|
+
// NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.
|
|
155
|
+
Loop(this.frameEnvironmentLightCount, ({ i }) => {
|
|
156
|
+
const slot = this.frameEnvironmentShadowSlot.add(i).toVar();
|
|
157
|
+
let total = vec3(1.0);
|
|
158
|
+
slots.forEach((value, index) => {
|
|
159
|
+
total = select(slot.equal(index), value.total, total);
|
|
160
|
+
});
|
|
161
|
+
irradiance.addAssign(frameEnvironmentColors.element(i).mul(frameSpectralShadowTotal(total.toVar(), octaves, albedo)));
|
|
162
|
+
});
|
|
163
|
+
const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);
|
|
164
|
+
const alpha = vec3(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear))))).toVar();
|
|
165
|
+
outputs.color.assign(vec4(radiance.mul(alpha), alpha.y));
|
|
166
|
+
outputs.alpha.assign(vec4(alpha.x, alpha.z, 0.0, alpha.y));
|
|
167
|
+
return vec4(0.0);
|
|
168
|
+
})();
|
|
169
|
+
}
|
|
170
|
+
createFragmentNode() {
|
|
171
|
+
const { froxelUniforms, lightUniforms, densityShadowUniforms, gridUniforms } = this.frameUniforms;
|
|
172
|
+
const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;
|
|
173
|
+
const grid = createGridNodes(gridUniforms);
|
|
174
|
+
const atlasSize = froxelUniforms.froxelAtlasSize;
|
|
175
|
+
return Fn(() => {
|
|
176
|
+
const fragCoord = frameFragCoord(atlasSize).toVar();
|
|
177
|
+
const texel = ivec2(fragCoord).toVar();
|
|
178
|
+
const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();
|
|
179
|
+
const extinction = densityAlbedo.a.toVar();
|
|
180
|
+
If(extinction.lessThanEqual(0.0), () => {
|
|
181
|
+
Discard();
|
|
182
|
+
});
|
|
183
|
+
const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();
|
|
184
|
+
const froxel = frameGetFroxel(froxelUniforms, fragCoord);
|
|
185
|
+
const viewNear = froxel.viewNear.toVar();
|
|
186
|
+
const viewFar = froxel.viewFar.toVar();
|
|
187
|
+
// NOTE Spot light angles and light falloff use the extinction-weighted visible position of all volumes
|
|
188
|
+
const visibleT = clamp(densityEmission.a.div(extinction), 0.0, 1.0);
|
|
189
|
+
const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();
|
|
190
|
+
const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();
|
|
191
|
+
// NOTE Extinction-weighted mean transmittance. Each volume sampled its own visible position.
|
|
192
|
+
const shadow0 = frameLoad(this.frameDensityShadowMap0, texel, atlasSize).div(extinction).toVar();
|
|
193
|
+
const shadow1 = frameLoad(this.frameDensityShadowMap1, texel, atlasSize).div(extinction).toVar();
|
|
194
|
+
const shadowSlots = [shadow0.z, shadow0.w, shadow1.x, shadow1.y, shadow1.z, shadow1.w];
|
|
195
|
+
// NOTE Phases of each channel: slots hold the green phase. Direct transmittance from the shadow grid adds the red and blue difference.
|
|
196
|
+
const colorPhase = this.framePhaseSpectrum.z.greaterThan(0.5).toVar();
|
|
197
|
+
const direct0 = vec4(1.0).toVar();
|
|
198
|
+
const direct1 = vec4(1.0).toVar();
|
|
199
|
+
If(colorPhase.and(densityShadowUniforms.frameUseShadows.equal(1)), () => {
|
|
200
|
+
const directs = grid.sampleShadows([densityShadowUniforms.frameTransmittanceMap2, densityShadowUniforms.frameTransmittanceMap3], worldPosition);
|
|
201
|
+
direct0.assign(directs[0]);
|
|
202
|
+
direct1.assign(directs[1]);
|
|
203
|
+
});
|
|
204
|
+
const directSlots = [direct0.x, direct0.y, direct0.z, direct0.w, direct1.x, direct1.y];
|
|
205
|
+
const skyDirection = normalize(frameSkyDirection).toVar();
|
|
206
|
+
const skyUp = shadow0.x.mul(0.5);
|
|
207
|
+
const skyDown = shadow0.y.mul(0.5);
|
|
208
|
+
const irradiance = vec3(frameAmbientColor).toVar();
|
|
209
|
+
irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));
|
|
210
|
+
irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));
|
|
211
|
+
irradiance.addAssign(frameHemiSkyColor.mul(skyUp));
|
|
212
|
+
irradiance.addAssign(frameHemiGroundColor.mul(skyDown));
|
|
213
|
+
Loop(frameLightCount, ({ i }) => {
|
|
214
|
+
const position = frameLightPositions.element(i).toVar();
|
|
215
|
+
const color = frameLightColors.element(i).toVar();
|
|
216
|
+
const spot = frameLightSpots.element(i).toVar();
|
|
217
|
+
const falloff = frameLightFalloffs.element(i).toVar();
|
|
218
|
+
const lightVector = position.xyz.sub(worldPosition).toVar();
|
|
219
|
+
let shadow = float(1.0);
|
|
220
|
+
let direct = float(1.0);
|
|
221
|
+
shadowSlots.forEach((slot, index) => {
|
|
222
|
+
shadow = select(i.equal(index), slot, shadow);
|
|
223
|
+
direct = select(i.equal(index), directSlots[index], direct);
|
|
224
|
+
});
|
|
225
|
+
const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));
|
|
226
|
+
const distanceAttenuation = select(position.w.greaterThan(1.5), getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }), float(1.0));
|
|
227
|
+
// NOTE Directional position xyz is the direction to the light
|
|
228
|
+
const lightDirection = select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)).toVar();
|
|
229
|
+
const unshadowed = frameShadowedLight(this.framePhase, this.framePhaseSpectrum, this.frameScatteringOctaves, rayDirection, lightDirection, vec2(1.0));
|
|
230
|
+
const hasSlot = i.lessThan(this.frameShadowLightCount).toVar();
|
|
231
|
+
// NOTE A light with a shadow slot: the density pass stored phase * direct + scattered light.
|
|
232
|
+
// A light with no shadow slot: no shadow, then octaves still add their light.
|
|
233
|
+
const lightFactor = select(hasSlot, vec3(shadow), unshadowed).toVar();
|
|
234
|
+
If(colorPhase.and(hasSlot), () => {
|
|
235
|
+
const phase = framePhaseColor(this.framePhase, this.framePhaseSpectrum, rayDirection, lightDirection).toVar();
|
|
236
|
+
lightFactor.addAssign(phase.sub(phase.g).mul(direct));
|
|
237
|
+
});
|
|
238
|
+
irradiance.addAssign(color.rgb.mul(lightFactor).mul(spotAttenuation).mul(distanceAttenuation));
|
|
239
|
+
});
|
|
240
|
+
// NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.
|
|
241
|
+
Loop(this.frameEnvironmentLightCount, ({ i }) => {
|
|
242
|
+
const slot = this.frameEnvironmentShadowSlot.add(i).toVar();
|
|
243
|
+
let shadow = float(1.0);
|
|
244
|
+
shadowSlots.forEach((value, index) => {
|
|
245
|
+
shadow = select(slot.equal(index), value, shadow);
|
|
246
|
+
});
|
|
247
|
+
irradiance.addAssign(frameEnvironmentColors.element(i).mul(shadow));
|
|
248
|
+
});
|
|
249
|
+
const albedo = densityAlbedo.rgb.div(extinction);
|
|
250
|
+
const emission = densityEmission.rgb.div(extinction);
|
|
251
|
+
const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);
|
|
252
|
+
const alpha = float(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear)))));
|
|
253
|
+
return vec4(radiance.mul(alpha), alpha);
|
|
254
|
+
})();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=lighting-material.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lighting-material.js","sourceRoot":"","sources":["../../../src/three/frame/lighting-material.ts"],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E,CAAC;gBAC5D,IAAI,MAAM,GAAe,KAAK,CAAC,GAAG,CAAC,CAAC;gBAEpC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBACnC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;gBAEH,UAAU,CAAC,SAAS,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACjD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE1F,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameLightingMaterial.js L43–119 (constructor, uniforms),\n// L277–437 (the grey `createFragmentNode`); K3.5: L55–62 (the spectral maps and groups), L86–112\n// (setSpectral, rebuildNodes), L114–275 (createSpectralFragmentNode).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; source-free. K3.4: the octave uniform (L71–72) and the octave light of lights\n// without a shadow slot (L386–397).\n// Divergences: DIVERGES.md (K3.3 rows).\n\n/**\n * The lighting pass of `'frame'` lighting (R1 §2 step 4): each froxel of the volumes' froxel area is\n * lit once from the combined density targets: ambient, light probe SH and hemisphere light with the\n * sky up / down transmittance, the scene lights (with a shadow slot: the density pass's\n * phase × direct + scattered; else unshadowed), and the dominant directional environment light in\n * its slot. Writes premultiplied (radiance × alpha, alpha) into the froxel atlas, as the inject pass.\n * Spectral (K3.5): the transmittance of each channel is sampled from the slot groups' targets at the\n * froxel's visible position (the density pass has no slots then); two atlas targets, (radiance × alpha\n * of each channel, green alpha) and (red alpha, blue alpha, 0, green alpha).\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { createGridNodes, frameFragCoord, frameGetFroxel, frameLoad, framePhaseColor, frameShadowedLight, frameSpectralShadowTotal, frameSpectralShadowedLight, frameTileVertex, frameUnpackSpectralGroup, type FroxelUniforms, type GridUniforms, type LightUniforms, type TileUniforms } from \"./chunks.js\";\nimport type { DensityShadowUniforms } from \"./density-material.js\";\nimport { frameSpectralGroupCount } from \"./spectrum.js\";\n\nconst { Discard, Fn, If, Loop, clamp, dot, exp, float, getDistanceAttenuation, getShIrradianceAt, int, ivec2, length, mat3, max, mix, normalize, outputStruct, property, select, smoothstep, texture, uniform, vec2, vec3, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\nexport interface VDBFrameLightingMaterialOptions {\n froxelUniforms: FroxelUniforms;\n froxelTileUniforms: TileUniforms;\n froxelAreaUniforms: { frameAreaRect: VDBTslNode; frameAreaSliceStart: VDBTslNode };\n lightUniforms: LightUniforms;\n gridUniforms: GridUniforms;\n densityShadowUniforms: DensityShadowUniforms;\n}\n\n// NOTE Lights each froxel one time from the combined data of all volumes.\n// NOTE The environment is added in the density pass, along the outward direction of each volume.\nexport class VDBFrameLightingMaterial extends NodeMaterial {\n readonly frameDensityAlbedoMap = texture(new THREE.Texture());\n readonly frameDensityEmissionMap = texture(new THREE.Texture());\n readonly frameDensityShadowMap0 = texture(new THREE.Texture());\n readonly frameDensityShadowMap1 = texture(new THREE.Texture());\n readonly frameShadowLightCount = uniform(0, \"int\");\n readonly frameCameraMatrixWorld = uniform(new THREE.Matrix4());\n // NOTE One phase for all volumes, from the renderer settings\n readonly framePhase = uniform(new THREE.Vector4());\n readonly framePhaseSpectrum = uniform(new THREE.Vector3());\n // NOTE Scattering octaves of the renderer settings (phase.ts). Count 0 is off.\n readonly frameScatteringOctaves = uniform(new THREE.Vector4());\n // NOTE Environment lights with a shadow slot (0 or 1). Light i has slot frameEnvironmentShadowSlot + i.\n readonly frameEnvironmentLightCount = uniform(0, \"int\");\n readonly frameEnvironmentShadowSlot = uniform(0, \"int\");\n readonly frameUniforms: VDBFrameLightingMaterialOptions;\n // NOTE Renderer settings.spectral: extinction of each channel (density target 2), and the 3 transmittance\n // targets of each slot group (spectrum.ts), in group order. Groups from frameSpectralGroups on are not read.\n readonly frameDensityExtinctionMap = texture(new THREE.Texture());\n readonly frameSpectralTransmittanceMaps = Array.from({ length: frameSpectralGroupCount * 3 }, () => texture(new THREE.Texture()));\n readonly frameSpectralGroups = uniform(0, \"int\");\n // NOTE Renderer settings.spectral: two atlas targets\n spectral = false;\n\n constructor(o: VDBFrameLightingMaterialOptions) {\n super();\n\n this.name = \"VDBFrameLightingMaterial\";\n this.frameUniforms = o;\n\n // NOTE Only the froxel area of the volumes. Other froxels have no density.\n this.vertexNode = frameTileVertex(o.froxelTileUniforms, o.froxelAreaUniforms.frameAreaRect, o.froxelAreaUniforms.frameAreaSliceStart);\n this.rebuildNodes();\n\n this.side = THREE.DoubleSide;\n this.forceSinglePass = true;\n this.depthTest = false;\n this.depthWrite = false;\n this.blending = THREE.NoBlending;\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.rebuildNodes();\n this.needsUpdate = true;\n }\n }\n\n // NOTE Spectral: atlas target 0 is (color, green alpha), target 1 is (red alpha, blue alpha, 0, green alpha)\n rebuildNodes(): void {\n if (!this.spectral) {\n this.colorNode = null;\n this.outputNode = null;\n this.fragmentNode = this.createFragmentNode();\n\n return;\n }\n\n const lightingColor = property(\"vec4\");\n const lightingAlpha = property(\"vec4\");\n\n this.fragmentNode = null;\n this.colorNode = this.createSpectralFragmentNode({ color: lightingColor, alpha: lightingAlpha });\n this.outputNode = outputStruct(lightingColor, lightingAlpha);\n }\n\n // NOTE Spectral lighting. The density pass has no light slots, so the slots are sampled here,\n // at the extinction-weighted visible position of all volumes in the froxel. Albedo and extinction are of each channel.\n createSpectralFragmentNode(outputs: { color: VDBTslNode; alpha: VDBTslNode }): VDBTslNode {\n const { froxelUniforms, lightUniforms, gridUniforms } = this.frameUniforms;\n const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;\n const grid = createGridNodes(gridUniforms);\n const atlasSize = froxelUniforms.froxelAtlasSize;\n const octaves = this.frameScatteringOctaves;\n\n return Fn(() => {\n const fragCoord = frameFragCoord(atlasSize).toVar();\n const texel = ivec2(fragCoord).toVar();\n const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();\n const weight = densityAlbedo.a.toVar();\n\n If(weight.lessThanEqual(0.0), () => {\n Discard();\n });\n\n const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();\n const extinction = frameLoad(this.frameDensityExtinctionMap, texel, atlasSize).rgb.toVar();\n const froxel = frameGetFroxel(froxelUniforms, fragCoord);\n const viewNear = froxel.viewNear.toVar();\n const viewFar = froxel.viewFar.toVar();\n\n const visibleT = clamp(densityEmission.a.div(weight), 0.0, 1.0);\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();\n const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();\n const albedo = densityAlbedo.rgb.div(max(extinction, vec3(1e-8))).toVar();\n const emission = densityEmission.rgb.div(weight);\n\n // NOTE Transmittance targets of the slot groups in use. 1.0 outside the grid, with no shadows and for other groups.\n const maps = this.frameSpectralTransmittanceMaps.map(() => vec4(1.0).toVar());\n\n for (let group = 0; group < frameSpectralGroupCount; group++) {\n const groupMaps = this.frameSpectralTransmittanceMaps.slice(group * 3, group * 3 + 3);\n\n If(int(group).lessThan(this.frameSpectralGroups), () => {\n const shadows = grid.sampleShadows(groupMaps, worldPosition);\n\n shadows.forEach((shadow, index) => maps[group * 3 + index]!.assign(shadow));\n });\n }\n\n // NOTE Group 0: sky (up, down) and slot 0. Group g: slots 2g - 1 and 2g. Slot entries are (total, direct).\n const groups = Array.from({ length: frameSpectralGroupCount }, (_, group) => frameUnpackSpectralGroup(maps[group * 3]!, maps[group * 3 + 1]!, maps[group * 3 + 2]!));\n const slotEntry = (slot: number) => (slot === 0 ? groups[0]!.b : slot % 2 === 1 ? groups[(slot + 1) / 2]!.a : groups[slot / 2]!.b);\n\n const skyDirection = normalize(frameSkyDirection).toVar();\n const skyUp = frameSpectralShadowTotal(groups[0]!.a.x, octaves, albedo).mul(0.5).toVar();\n const skyDown = frameSpectralShadowTotal(groups[0]!.a.y, octaves, albedo).mul(0.5).toVar();\n\n const irradiance = vec3(frameAmbientColor).toVar();\n\n irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));\n irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));\n irradiance.addAssign(frameHemiSkyColor.mul(skyUp));\n irradiance.addAssign(frameHemiGroundColor.mul(skyDown));\n\n const slots = Array.from({ length: 6 }, (_, slot) => ({\n total: slotEntry(slot).x.toVar(),\n direct: slotEntry(slot).y.toVar(),\n }));\n\n Loop(frameLightCount, ({ i }: { i: VDBTslNode }) => {\n const position = frameLightPositions.element(i).toVar();\n const color = frameLightColors.element(i).toVar();\n const spot = frameLightSpots.element(i).toVar();\n const falloff = frameLightFalloffs.element(i).toVar();\n const lightVector = position.xyz.sub(worldPosition).toVar();\n\n // NOTE A light with no shadow slot: no shadow (1.0), then octaves still add their light\n let total: VDBTslNode = vec3(1.0);\n let direct: VDBTslNode = vec3(1.0);\n\n slots.forEach((slot, index) => {\n const useSlot = i.equal(index).and(i.lessThan(this.frameShadowLightCount));\n\n total = select(useSlot, slot.total, total);\n direct = select(useSlot, slot.direct, direct);\n });\n\n const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));\n\n const distanceAttenuation = select(\n position.w.greaterThan(1.5),\n getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }),\n float(1.0),\n );\n\n // NOTE Directional position xyz is the direction to the light\n const light = frameSpectralShadowedLight(\n this.framePhase,\n this.framePhaseSpectrum,\n octaves,\n rayDirection,\n select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)),\n { x: direct.toVar(), y: total.toVar() },\n albedo,\n );\n\n irradiance.addAssign(color.rgb.mul(light).mul(spotAttenuation).mul(distanceAttenuation));\n });\n\n // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.\n Loop(this.frameEnvironmentLightCount, ({ i }: { i: VDBTslNode }) => {\n const slot = this.frameEnvironmentShadowSlot.add(i).toVar();\n let total: VDBTslNode = vec3(1.0);\n\n slots.forEach((value, index) => {\n total = select(slot.equal(index), value.total, total);\n });\n\n irradiance.addAssign(frameEnvironmentColors.element(i).mul(frameSpectralShadowTotal(total.toVar(), octaves, albedo)));\n });\n\n const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);\n const alpha = vec3(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear))))).toVar();\n\n outputs.color.assign(vec4(radiance.mul(alpha), alpha.y));\n outputs.alpha.assign(vec4(alpha.x, alpha.z, 0.0, alpha.y));\n\n return vec4(0.0);\n })();\n }\n\n createFragmentNode(): VDBTslNode {\n const { froxelUniforms, lightUniforms, densityShadowUniforms, gridUniforms } = this.frameUniforms;\n const { frameAmbientColor, frameLightProbe, frameHemiSkyColor, frameHemiGroundColor, frameSkyDirection, frameLightCount, frameLightPositions, frameLightColors, frameLightSpots, frameLightFalloffs, frameEnvironmentColors } = lightUniforms;\n const grid = createGridNodes(gridUniforms);\n const atlasSize = froxelUniforms.froxelAtlasSize;\n\n return Fn(() => {\n const fragCoord = frameFragCoord(atlasSize).toVar();\n const texel = ivec2(fragCoord).toVar();\n const densityAlbedo = frameLoad(this.frameDensityAlbedoMap, texel, atlasSize).toVar();\n const extinction = densityAlbedo.a.toVar();\n\n If(extinction.lessThanEqual(0.0), () => {\n Discard();\n });\n\n const densityEmission = frameLoad(this.frameDensityEmissionMap, texel, atlasSize).toVar();\n const froxel = frameGetFroxel(froxelUniforms, fragCoord);\n const viewNear = froxel.viewNear.toVar();\n const viewFar = froxel.viewFar.toVar();\n\n // NOTE Spot light angles and light falloff use the extinction-weighted visible position of all volumes\n const visibleT = clamp(densityEmission.a.div(extinction), 0.0, 1.0);\n const worldPosition = this.frameCameraMatrixWorld.mul(vec4(mix(viewNear, viewFar, visibleT), 1.0)).xyz.toVar();\n const rayDirection = normalize(mat3(this.frameCameraMatrixWorld).mul(viewFar.sub(viewNear))).toVar();\n\n // NOTE Extinction-weighted mean transmittance. Each volume sampled its own visible position.\n const shadow0 = frameLoad(this.frameDensityShadowMap0, texel, atlasSize).div(extinction).toVar();\n const shadow1 = frameLoad(this.frameDensityShadowMap1, texel, atlasSize).div(extinction).toVar();\n const shadowSlots = [shadow0.z, shadow0.w, shadow1.x, shadow1.y, shadow1.z, shadow1.w];\n\n // NOTE Phases of each channel: slots hold the green phase. Direct transmittance from the shadow grid adds the red and blue difference.\n const colorPhase = this.framePhaseSpectrum.z.greaterThan(0.5).toVar();\n const direct0 = vec4(1.0).toVar();\n const direct1 = vec4(1.0).toVar();\n\n If(colorPhase.and(densityShadowUniforms.frameUseShadows.equal(1)), () => {\n const directs = grid.sampleShadows([densityShadowUniforms.frameTransmittanceMap2, densityShadowUniforms.frameTransmittanceMap3], worldPosition);\n\n direct0.assign(directs[0]);\n direct1.assign(directs[1]);\n });\n\n const directSlots = [direct0.x, direct0.y, direct0.z, direct0.w, direct1.x, direct1.y];\n\n const skyDirection = normalize(frameSkyDirection).toVar();\n const skyUp = shadow0.x.mul(0.5);\n const skyDown = shadow0.y.mul(0.5);\n\n const irradiance = vec3(frameAmbientColor).toVar();\n\n irradiance.addAssign(getShIrradianceAt(skyDirection, frameLightProbe).mul(skyUp));\n irradiance.addAssign(getShIrradianceAt(skyDirection.negate(), frameLightProbe).mul(skyDown));\n irradiance.addAssign(frameHemiSkyColor.mul(skyUp));\n irradiance.addAssign(frameHemiGroundColor.mul(skyDown));\n\n Loop(frameLightCount, ({ i }: { i: VDBTslNode }) => {\n const position = frameLightPositions.element(i).toVar();\n const color = frameLightColors.element(i).toVar();\n const spot = frameLightSpots.element(i).toVar();\n const falloff = frameLightFalloffs.element(i).toVar();\n const lightVector = position.xyz.sub(worldPosition).toVar();\n\n let shadow: VDBTslNode = float(1.0);\n let direct: VDBTslNode = float(1.0);\n\n shadowSlots.forEach((slot, index) => {\n shadow = select(i.equal(index), slot, shadow);\n direct = select(i.equal(index), directSlots[index], direct);\n });\n\n const spotAttenuation = select(position.w.greaterThan(2.5), smoothstep(spot.w, color.w, dot(normalize(lightVector), spot.xyz)), float(1.0));\n\n const distanceAttenuation = select(\n position.w.greaterThan(1.5),\n getDistanceAttenuation({ lightDistance: length(lightVector), cutoffDistance: falloff.x, decayExponent: falloff.y }),\n float(1.0),\n );\n\n // NOTE Directional position xyz is the direction to the light\n const lightDirection = select(position.w.lessThan(1.5), position.xyz, normalize(lightVector)).toVar();\n const unshadowed = frameShadowedLight(this.framePhase, this.framePhaseSpectrum, this.frameScatteringOctaves, rayDirection, lightDirection, vec2(1.0));\n const hasSlot = i.lessThan(this.frameShadowLightCount).toVar();\n\n // NOTE A light with a shadow slot: the density pass stored phase * direct + scattered light.\n // A light with no shadow slot: no shadow, then octaves still add their light.\n const lightFactor = select(hasSlot, vec3(shadow), unshadowed).toVar();\n\n If(colorPhase.and(hasSlot), () => {\n const phase = framePhaseColor(this.framePhase, this.framePhaseSpectrum, rayDirection, lightDirection).toVar();\n\n lightFactor.addAssign(phase.sub(phase.g).mul(direct));\n });\n\n irradiance.addAssign(color.rgb.mul(lightFactor).mul(spotAttenuation).mul(distanceAttenuation));\n });\n\n // NOTE Dominant directional environment light with a shadow slot. Isotropic, no phase.\n Loop(this.frameEnvironmentLightCount, ({ i }: { i: VDBTslNode }) => {\n const slot = this.frameEnvironmentShadowSlot.add(i).toVar();\n let shadow: VDBTslNode = float(1.0);\n\n shadowSlots.forEach((value, index) => {\n shadow = select(slot.equal(index), value, shadow);\n });\n\n irradiance.addAssign(frameEnvironmentColors.element(i).mul(shadow));\n });\n\n const albedo = densityAlbedo.rgb.div(extinction);\n const emission = densityEmission.rgb.div(extinction);\n const radiance = albedo.mul(irradiance).mul(1.0 / Math.PI).add(emission);\n const alpha = float(1.0).sub(exp(extinction.negate().mul(length(viewFar.sub(viewNear)))));\n\n return vec4(radiance.mul(alpha), alpha);\n })();\n }\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */
|
|
2
|
+
export declare const vdbFrameLights: {
|
|
3
|
+
readonly useAmbientLights: 32;
|
|
4
|
+
readonly usePointLights: 16;
|
|
5
|
+
readonly useDirectionalLights: 8;
|
|
6
|
+
readonly useSpotLights: 4;
|
|
7
|
+
readonly useHemisphereLights: 2;
|
|
8
|
+
readonly useEnvironment: 1;
|
|
9
|
+
};
|
|
10
|
+
/** Every light type (his FrameVolume default `lights`). */
|
|
11
|
+
export declare const vdbFrameAllLights: number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/frameLights.js (all, 9 lines).
|
|
3
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
4
|
+
// Changes: TypeScript. Divergences: none.
|
|
5
|
+
/** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */
|
|
6
|
+
export const vdbFrameLights = {
|
|
7
|
+
useAmbientLights: 0b100000,
|
|
8
|
+
usePointLights: 0b010000,
|
|
9
|
+
useDirectionalLights: 0b001000,
|
|
10
|
+
useSpotLights: 0b000100,
|
|
11
|
+
useHemisphereLights: 0b000010,
|
|
12
|
+
useEnvironment: 0b000001,
|
|
13
|
+
};
|
|
14
|
+
/** Every light type (his FrameVolume default `lights`). */
|
|
15
|
+
export const vdbFrameAllLights = Object.values(vdbFrameLights).reduce((mask, flag) => mask | flag, 0);
|
|
16
|
+
//# sourceMappingURL=lights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lights.js","sourceRoot":"","sources":["../../../src/three/frame/lights.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gEAAgE;AAChE,4GAA4G;AAC5G,0CAA0C;AAE1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB,EAAE,QAAQ;IAC1B,cAAc,EAAE,QAAQ;IACxB,oBAAoB,EAAE,QAAQ;IAC9B,aAAa,EAAE,QAAQ;IACvB,mBAAmB,EAAE,QAAQ;IAC7B,cAAc,EAAE,QAAQ;CAChB,CAAC;AAEX,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameLights.js (all, 9 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript. Divergences: none.\n\n/** Light types of the `VDBFrameVolume` `lights` bitmask (his `frameLights`). */\nexport const vdbFrameLights = {\n useAmbientLights: 0b100000,\n usePointLights: 0b010000,\n useDirectionalLights: 0b001000,\n useSpotLights: 0b000100,\n useHemisphereLights: 0b000010,\n useEnvironment: 0b000001,\n} as const;\n\n/** Every light type (his FrameVolume default `lights`). */\nexport const vdbFrameAllLights = Object.values(vdbFrameLights).reduce((mask, flag) => mask | flag, 0);\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type VDBFrameMediumPreset } from "../../tools/frame/medium.js";
|
|
3
|
+
/** {@link getFrameMediumProps} result: `VDBFrameVolume` props of a measured medium. */
|
|
4
|
+
export interface VDBFrameMediumVolumeProps {
|
|
5
|
+
/** Linear albedo. */
|
|
6
|
+
baseColor: THREE.Color;
|
|
7
|
+
/** (1, 1, 1): extinction depends on the scene scale, so a preset does not set it. */
|
|
8
|
+
extinctionScale: THREE.Vector3;
|
|
9
|
+
angstromExponent: number;
|
|
10
|
+
phase: VDBFrameMediumPreset["phase"];
|
|
11
|
+
phaseG: number;
|
|
12
|
+
phaseGExponent: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `VDBFrameVolume` props of a measured medium (`'cloud'`, `'fog'`, `'ice'`, `'soot'`, `'white-smoke'`,
|
|
16
|
+
* `'dark-smoke'`, `'haze'`, `'dust'`; `@pmndrs/vdb/tools` `vdbFrameMediumPresets`): base colour, extinction
|
|
17
|
+
* scale, Ångström exponent and phase. Use them as constructor props or assign them to a volume, and turn on
|
|
18
|
+
* the renderer's `settings.spectral` (his examples also set the renderer's 'frame' phase to the preset's).
|
|
19
|
+
* Unknown names give null.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getFrameMediumProps: (name: string) => VDBFrameMediumVolumeProps | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/frameMedium.js L78–90 (getFrameMediumProps).
|
|
3
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
4
|
+
// Changes: TypeScript; the preset table is engine-free in `tools/frame/medium.ts` (`vdbFrameMediumPresets`).
|
|
5
|
+
// Divergences: none.
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
import { vdbFrameMediumProps } from "../../tools/frame/medium.js";
|
|
8
|
+
/**
|
|
9
|
+
* `VDBFrameVolume` props of a measured medium (`'cloud'`, `'fog'`, `'ice'`, `'soot'`, `'white-smoke'`,
|
|
10
|
+
* `'dark-smoke'`, `'haze'`, `'dust'`; `@pmndrs/vdb/tools` `vdbFrameMediumPresets`): base colour, extinction
|
|
11
|
+
* scale, Ångström exponent and phase. Use them as constructor props or assign them to a volume, and turn on
|
|
12
|
+
* the renderer's `settings.spectral` (his examples also set the renderer's 'frame' phase to the preset's).
|
|
13
|
+
* Unknown names give null.
|
|
14
|
+
*/
|
|
15
|
+
export const getFrameMediumProps = (name) => {
|
|
16
|
+
const props = vdbFrameMediumProps(name);
|
|
17
|
+
if (!props) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
baseColor: new THREE.Color().setRGB(...props.albedo, THREE.LinearSRGBColorSpace),
|
|
22
|
+
extinctionScale: new THREE.Vector3(...props.extinctionScale),
|
|
23
|
+
angstromExponent: props.angstromExponent,
|
|
24
|
+
phase: props.phase,
|
|
25
|
+
phaseG: props.phaseG,
|
|
26
|
+
phaseGExponent: props.phaseGExponent,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=medium.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"medium.js","sourceRoot":"","sources":["../../../src/three/frame/medium.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,8EAA8E;AAC9E,4GAA4G;AAC5G,6GAA6G;AAC7G,qBAAqB;AAErB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAA6B,MAAM,6BAA6B,CAAC;AAc7F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAoC,EAAE;IACpF,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAExC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,SAAS,EAAE,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC;QAChF,eAAe,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC;QAC5D,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameMedium.js L78–90 (getFrameMediumProps).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the preset table is engine-free in `tools/frame/medium.ts` (`vdbFrameMediumPresets`).\n// Divergences: none.\n\nimport * as THREE from \"three\";\nimport { vdbFrameMediumProps, type VDBFrameMediumPreset } from \"../../tools/frame/medium.js\";\n\n/** {@link getFrameMediumProps} result: `VDBFrameVolume` props of a measured medium. */\nexport interface VDBFrameMediumVolumeProps {\n /** Linear albedo. */\n baseColor: THREE.Color;\n /** (1, 1, 1): extinction depends on the scene scale, so a preset does not set it. */\n extinctionScale: THREE.Vector3;\n angstromExponent: number;\n phase: VDBFrameMediumPreset[\"phase\"];\n phaseG: number;\n phaseGExponent: number;\n}\n\n/**\n * `VDBFrameVolume` props of a measured medium (`'cloud'`, `'fog'`, `'ice'`, `'soot'`, `'white-smoke'`,\n * `'dark-smoke'`, `'haze'`, `'dust'`; `@pmndrs/vdb/tools` `vdbFrameMediumPresets`): base colour, extinction\n * scale, Ångström exponent and phase. Use them as constructor props or assign them to a volume, and turn on\n * the renderer's `settings.spectral` (his examples also set the renderer's 'frame' phase to the preset's).\n * Unknown names give null.\n */\nexport const getFrameMediumProps = (name: string): VDBFrameMediumVolumeProps | null => {\n const props = vdbFrameMediumProps(name);\n\n if (!props) {\n return null;\n }\n\n return {\n baseColor: new THREE.Color().setRGB(...props.albedo, THREE.LinearSRGBColorSpace),\n extinctionScale: new THREE.Vector3(...props.extinctionScale),\n angstromExponent: props.angstromExponent,\n phase: props.phase,\n phaseG: props.phaseG,\n phaseGExponent: props.phaseGExponent,\n };\n};\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { VDBTslNode } from "../grid-node.js";
|
|
2
|
+
import { type VDBFrameNeuralNetwork } from "../../tools/frame/neural.js";
|
|
3
|
+
import { type GridNodes, type GridUniforms } from "./chunks.js";
|
|
4
|
+
type N = VDBTslNode;
|
|
5
|
+
/**
|
|
6
|
+
* Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip
|
|
7
|
+
* texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).
|
|
8
|
+
*/
|
|
9
|
+
export declare const createNeuralNodes: (network: VDBFrameNeuralNetwork, gridUniforms: GridUniforms, grid: GridNodes, densityMap: N, mipMaps: N[], mipLayouts: N[]) => {
|
|
10
|
+
getLocalInputs: (worldPosition: N) => [N, N];
|
|
11
|
+
neuralLight: any;
|
|
12
|
+
sampleLevel: (level: number, worldPosition: N) => N;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/webgpu/frameNeuralChunks.js L1–131 (all: weight layout, dense layers,
|
|
3
|
+
// sampleLevel, getLocalInputs, neuralLight).
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: TypeScript; the network (weights and sizes) is a parameter (VDBFrameNeuralNetwork) instead of
|
|
6
|
+
// a module import, so the weights module can be swapped or left out. CPU twin: tools/frame/neural.ts.
|
|
7
|
+
// Divergences: DIVERGES.md (K3.4 rows).
|
|
8
|
+
/**
|
|
9
|
+
* multipleScattering `'neural'` (K3.4): the scattered light of a shadow slot from a small network
|
|
10
|
+
* (`@pmndrs/vdb/tools` `vdbFrameNeuralWeights`, his `scripts/neural-indirect`). Level 0 is the last
|
|
11
|
+
* cascade of the grid atlas, levels 1 and up are the atlases of {@link VDBFrameGridMipMaterial}. Values
|
|
12
|
+
* outside the last cascade are 0. The weights are constants in the shader (one WGSL function,
|
|
13
|
+
* `frameNeuralLight`, called per slot).
|
|
14
|
+
*/
|
|
15
|
+
import * as TSL from "three/tsl";
|
|
16
|
+
import { vdbFrameNeuralLayout } from "../../tools/frame/neural.js";
|
|
17
|
+
import { maxComponent, minComponent } from "./chunks.js";
|
|
18
|
+
const { Fn, clamp, dot, exp, float, floor, log, max, min, select, sqrt, vec2, vec4 } = TSL;
|
|
19
|
+
/**
|
|
20
|
+
* Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip
|
|
21
|
+
* texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).
|
|
22
|
+
*/
|
|
23
|
+
export const createNeuralNodes = (network, gridUniforms, grid, densityMap, mipMaps, mipLayouts) => {
|
|
24
|
+
const { frameGridCount, frameGridVoxel, frameGridResolution } = gridUniforms;
|
|
25
|
+
const layout = vdbFrameNeuralLayout(network);
|
|
26
|
+
const levels = network.levels;
|
|
27
|
+
const weights = network.weights;
|
|
28
|
+
const weight = (index) => vec4(weights[index * 4], weights[index * 4 + 1], weights[index * 4 + 2], weights[index * 4 + 3]);
|
|
29
|
+
const lastCascade = () => frameGridCount.sub(1);
|
|
30
|
+
// NOTE Dense layer with ReLU. inputs: vec4 nodes. Weights are constants in the shader.
|
|
31
|
+
const dense = (inputs, weightOffset, biasOffset) => {
|
|
32
|
+
const outputs = [];
|
|
33
|
+
for (let group = 0; group < layout.hiddenVectors; group++) {
|
|
34
|
+
const bias = weight(biasOffset + group);
|
|
35
|
+
const values = [0, 1, 2, 3].map((component) => {
|
|
36
|
+
const row = weightOffset + (group * 4 + component) * inputs.length;
|
|
37
|
+
return inputs.reduce((sum, input, i) => sum.add(dot(weight(row + i), input)), bias.element(component));
|
|
38
|
+
});
|
|
39
|
+
outputs.push(max(vec4(...values), vec4(0.0)).toVar());
|
|
40
|
+
}
|
|
41
|
+
return outputs;
|
|
42
|
+
};
|
|
43
|
+
// NOTE (extinction, absorption) of a level at a world position. Linear filter, edge texels clamped.
|
|
44
|
+
const sampleLevel = (level, worldPosition) => {
|
|
45
|
+
const cascade = lastCascade();
|
|
46
|
+
const uvw = grid.gridUvw(cascade, worldPosition).toVar();
|
|
47
|
+
const inside = minComponent(uvw).greaterThanEqual(0.0).and(maxComponent(uvw).lessThanEqual(1.0));
|
|
48
|
+
let value;
|
|
49
|
+
if (level === 0) {
|
|
50
|
+
value = grid.sampleGrid(densityMap, cascade, uvw).rg;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const resolution = max(floor(frameGridResolution.div(2 ** level)), 1.0);
|
|
54
|
+
const mipLayout = mipLayouts[level - 1];
|
|
55
|
+
value = grid.sampleTiles(mipMaps[level - 1], resolution, float(0.0), mipLayout.x, mipLayout.yz, uvw).rg;
|
|
56
|
+
}
|
|
57
|
+
return select(inside, value, vec2(0.0));
|
|
58
|
+
};
|
|
59
|
+
const unit = () => maxComponent(frameGridVoxel.element(lastCascade()));
|
|
60
|
+
// NOTE Inputs that do not depend on the light: (local 0 to 3), (local 4, local 5, albedo input, 0)
|
|
61
|
+
const getLocalInputs = (worldPosition) => {
|
|
62
|
+
const h = unit().toVar();
|
|
63
|
+
const samples = Array.from({ length: levels }, (_, level) => sampleLevel(level, worldPosition).toVar());
|
|
64
|
+
const local = samples.map((value, level) => log(value.x.mul(h.mul(2 ** level)).add(1.0)));
|
|
65
|
+
// NOTE The albedo input uses the level 1 sample
|
|
66
|
+
const albedoSample = samples[1];
|
|
67
|
+
const albedoInput = select(albedoSample.x.greaterThan(0.0), sqrt(clamp(albedoSample.y.div(max(albedoSample.x, 1e-20)), 0.0, 1.0)), float(0.0));
|
|
68
|
+
return [vec4(local[0], local[1], local[2], local[3]).toVar(), vec4(local[4], local[5], albedoInput, 0.0).toVar()];
|
|
69
|
+
};
|
|
70
|
+
// NOTE Scattered light (total - direct) for each unit of light. direction: unit direction to the light,
|
|
71
|
+
// opticalDepth: direct optical depth of the slot march.
|
|
72
|
+
const neuralLight = Fn(([worldPosition, direction, opticalDepth, local0, local1]) => {
|
|
73
|
+
const h = unit().toVar();
|
|
74
|
+
const toward = [];
|
|
75
|
+
const away = [];
|
|
76
|
+
for (let level = 0; level < levels; level++) {
|
|
77
|
+
const length = h.mul(2 ** level).toVar();
|
|
78
|
+
toward.push(log(sampleLevel(level, worldPosition.add(direction.mul(length))).x.mul(length).add(1.0)));
|
|
79
|
+
away.push(log(sampleLevel(level, worldPosition.sub(direction.mul(length))).x.mul(length).add(1.0)));
|
|
80
|
+
}
|
|
81
|
+
const inputs = [
|
|
82
|
+
local0,
|
|
83
|
+
vec4(local1.x, local1.y, toward[0], toward[1]),
|
|
84
|
+
vec4(toward[2], toward[3], toward[4], toward[5]),
|
|
85
|
+
vec4(away[0], away[1], away[2], away[3]),
|
|
86
|
+
vec4(away[4], away[5], log(opticalDepth.add(1.0)), local1.z),
|
|
87
|
+
].map((input) => input.toVar());
|
|
88
|
+
const hidden1 = dense(inputs, layout.w1, layout.b1);
|
|
89
|
+
const hidden2 = dense(hidden1, layout.w2, layout.b2);
|
|
90
|
+
const output = hidden2.reduce((sum, value, i) => sum.add(dot(weight(layout.w3 + i), value)), weight(layout.b3).x);
|
|
91
|
+
return exp(min(output, 4.0));
|
|
92
|
+
}).setLayout({
|
|
93
|
+
name: "frameNeuralLight",
|
|
94
|
+
type: "float",
|
|
95
|
+
inputs: [
|
|
96
|
+
{ name: "worldPosition", type: "vec3" },
|
|
97
|
+
{ name: "direction", type: "vec3" },
|
|
98
|
+
{ name: "opticalDepth", type: "float" },
|
|
99
|
+
{ name: "local0", type: "vec4" },
|
|
100
|
+
{ name: "local1", type: "vec4" },
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
return { getLocalInputs, neuralLight, sampleLevel };
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=neural.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neural.js","sourceRoot":"","sources":["../../../src/three/frame/neural.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,kGAAkG;AAClG,+CAA+C;AAC/C,4GAA4G;AAC5G,yGAAyG;AACzG,sGAAsG;AACtG,wCAAwC;AAExC;;;;;;GAMG;AAEH,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAA8B,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqC,MA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E,MAAM,CAAC,EAAE,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAErH,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC,SAAS,CAAC;QACX,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE;YACvC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE;YACnC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE;YACvC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;YAChC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;SACjC;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACtD,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/frameNeuralChunks.js L1–131 (all: weight layout, dense layers,\n// sampleLevel, getLocalInputs, neuralLight).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the network (weights and sizes) is a parameter (VDBFrameNeuralNetwork) instead of\n// a module import, so the weights module can be swapped or left out. CPU twin: tools/frame/neural.ts.\n// Divergences: DIVERGES.md (K3.4 rows).\n\n/**\n * multipleScattering `'neural'` (K3.4): the scattered light of a shadow slot from a small network\n * (`@pmndrs/vdb/tools` `vdbFrameNeuralWeights`, his `scripts/neural-indirect`). Level 0 is the last\n * cascade of the grid atlas, levels 1 and up are the atlases of {@link VDBFrameGridMipMaterial}. Values\n * outside the last cascade are 0. The weights are constants in the shader (one WGSL function,\n * `frameNeuralLight`, called per slot).\n */\n\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { vdbFrameNeuralLayout, type VDBFrameNeuralNetwork } from \"../../tools/frame/neural.js\";\nimport { maxComponent, minComponent, type GridNodes, type GridUniforms } from \"./chunks.js\";\n\nconst { Fn, clamp, dot, exp, float, floor, log, max, min, select, sqrt, vec2, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\n\n/**\n * Network nodes over the grid uniforms and nodes (createGridNodes), the grid atlas texture node, the mip\n * texture nodes (levels 1 and up) and their atlas layout uniforms (columns, width, height).\n */\nexport const createNeuralNodes = (network: VDBFrameNeuralNetwork, gridUniforms: GridUniforms, grid: GridNodes, densityMap: N, mipMaps: N[], mipLayouts: N[]) => {\n const { frameGridCount, frameGridVoxel, frameGridResolution } = gridUniforms;\n const layout = vdbFrameNeuralLayout(network);\n const levels = network.levels;\n const weights = network.weights;\n const weight = (index: number): N => vec4(weights[index * 4]!, weights[index * 4 + 1]!, weights[index * 4 + 2]!, weights[index * 4 + 3]!);\n const lastCascade = () => frameGridCount.sub(1);\n\n // NOTE Dense layer with ReLU. inputs: vec4 nodes. Weights are constants in the shader.\n const dense = (inputs: N[], weightOffset: number, biasOffset: number): N[] => {\n const outputs: N[] = [];\n\n for (let group = 0; group < layout.hiddenVectors; group++) {\n const bias = weight(biasOffset + group);\n const values = [0, 1, 2, 3].map((component) => {\n const row = weightOffset + (group * 4 + component) * inputs.length;\n\n return inputs.reduce((sum: N, input, i) => sum.add(dot(weight(row + i), input)), bias.element(component));\n });\n\n outputs.push(max(vec4(...values), vec4(0.0)).toVar());\n }\n\n return outputs;\n };\n\n // NOTE (extinction, absorption) of a level at a world position. Linear filter, edge texels clamped.\n const sampleLevel = (level: number, worldPosition: N): N => {\n const cascade = lastCascade();\n const uvw = grid.gridUvw(cascade, worldPosition).toVar();\n const inside = minComponent(uvw).greaterThanEqual(0.0).and(maxComponent(uvw).lessThanEqual(1.0));\n let value: N;\n\n if (level === 0) {\n value = grid.sampleGrid(densityMap, cascade, uvw).rg;\n } else {\n const resolution = max(floor(frameGridResolution.div(2 ** level)), 1.0);\n const mipLayout = mipLayouts[level - 1]!;\n\n value = grid.sampleTiles(mipMaps[level - 1], resolution, float(0.0), mipLayout.x, mipLayout.yz, uvw).rg;\n }\n\n return select(inside, value, vec2(0.0));\n };\n\n const unit = () => maxComponent(frameGridVoxel.element(lastCascade()));\n\n // NOTE Inputs that do not depend on the light: (local 0 to 3), (local 4, local 5, albedo input, 0)\n const getLocalInputs = (worldPosition: N): [N, N] => {\n const h = unit().toVar();\n const samples = Array.from({ length: levels }, (_, level) => sampleLevel(level, worldPosition).toVar());\n const local = samples.map((value, level) => log(value.x.mul(h.mul(2 ** level)).add(1.0)));\n // NOTE The albedo input uses the level 1 sample\n const albedoSample = samples[1]!;\n const albedoInput = select(albedoSample.x.greaterThan(0.0), sqrt(clamp(albedoSample.y.div(max(albedoSample.x, 1e-20)), 0.0, 1.0)), float(0.0));\n\n return [vec4(local[0], local[1], local[2], local[3]).toVar(), vec4(local[4], local[5], albedoInput, 0.0).toVar()];\n };\n\n // NOTE Scattered light (total - direct) for each unit of light. direction: unit direction to the light,\n // opticalDepth: direct optical depth of the slot march.\n const neuralLight = Fn(([worldPosition, direction, opticalDepth, local0, local1]: N[]) => {\n const h = unit().toVar();\n const toward: N[] = [];\n const away: N[] = [];\n\n for (let level = 0; level < levels; level++) {\n const length = h.mul(2 ** level).toVar();\n\n toward.push(log(sampleLevel(level, worldPosition!.add(direction!.mul(length))).x.mul(length).add(1.0)));\n away.push(log(sampleLevel(level, worldPosition!.sub(direction!.mul(length))).x.mul(length).add(1.0)));\n }\n\n const inputs = [\n local0,\n vec4(local1!.x, local1!.y, toward[0], toward[1]),\n vec4(toward[2], toward[3], toward[4], toward[5]),\n vec4(away[0], away[1], away[2], away[3]),\n vec4(away[4], away[5], log(opticalDepth!.add(1.0)), local1!.z),\n ].map((input) => input!.toVar());\n\n const hidden1 = dense(inputs, layout.w1, layout.b1);\n const hidden2 = dense(hidden1, layout.w2, layout.b2);\n const output = hidden2.reduce((sum: N, value, i) => sum.add(dot(weight(layout.w3 + i), value)), weight(layout.b3).x);\n\n return exp(min(output, 4.0));\n }).setLayout({\n name: \"frameNeuralLight\",\n type: \"float\",\n inputs: [\n { name: \"worldPosition\", type: \"vec3\" },\n { name: \"direction\", type: \"vec3\" },\n { name: \"opticalDepth\", type: \"float\" },\n { name: \"local0\", type: \"vec4\" },\n { name: \"local1\", type: \"vec4\" },\n ],\n });\n\n return { getLocalInputs, neuralLight, sampleLevel };\n};\n"]}
|