@pmndrs/vdb 0.0.0-stage → 0.2.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 +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -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/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -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 +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -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 +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -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 +198 -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 +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.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 +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -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 +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -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/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -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 +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -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/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.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-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -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 +153 -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 +4 -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/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.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 +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -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 +195 -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 +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -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 +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -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 +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/frameSpectrum.js (all, 42 lines: wavelengths, extinction spectrum, slot groups);
|
|
3
|
+
// src/three-openvdb/frame/webgpu/frameShaderChunks.js L483–622 (frameMeanComponent, frameSpectralShadowUnit,
|
|
4
|
+
// frameSpectralShadowDepths, frameSpectralShadowStep, frameSpectralGridAlbedo, frameSpectralShadowTransmittance,
|
|
5
|
+
// frameSpectralOctaveLight, frameSpectralShadowTotal, frameSpectralShadowedLight, frameUnpackSpectralGroup);
|
|
6
|
+
// src/three-openvdb/frame/webgpu/FrameTransmittanceMaterial.js L278–459 (buildSpectralNodes),
|
|
7
|
+
// FrameEnvironmentGridMaterial.js L104–197 (the spectral branch), FrameDensityMaterial.js L363–537
|
|
8
|
+
// (buildSpectralNodes), FrameLightingMaterial.js L114–275 (createSpectralFragmentNode),
|
|
9
|
+
// FrameInjectMaterial.js L200–532 (the spectral pre-integration and march; the light-probe, environment and
|
|
10
|
+
// hemisphere terms in both modes), as CPU twins;
|
|
11
|
+
// three r187 `getShIrradianceAt` (MIT, three.js authors), the light-probe irradiance the passes call.
|
|
12
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
13
|
+
// Changes: f64 CPU twins of the TSL (test oracles of the `./three` spectral passes and of the 'volume'-lighting
|
|
14
|
+
// environment terms), engine-free (plain arrays). Divergences: DIVERGES.md (K3.5 rows).
|
|
15
|
+
import { vdbFrameDistanceFade, vdbFrameNoise, vdbFrameOctavesOff, vdbFramePhaseColor, vdbFramePhaseWeightScaled, vdbFrameShadowDepth, vdbFrameShadowOpticalDepth, vdbFrameShadowTotal, vdbFrameTwoSidedDiffusion, vdbFrameMaxScatteringOctaves, } from "./index.js";
|
|
16
|
+
import { vdbFrameDensityFroxelSteps, vdbFrameFindCascade, vdbFrameGridCell, vdbFrameGridUvw, vdbFrameInsideGrid, vdbFrameIsotropicDiffusion, vdbFrameSampleGrid, vdbFrameSampleShadows, vdbFrameSampleTiles, } from "./grid.js";
|
|
17
|
+
import { vdbFrameMsExitFactor } from "./ms-exit.js";
|
|
18
|
+
/** Wavelengths in nm of the red, green and blue channels. Green (550 nm) is the reference. */
|
|
19
|
+
export const vdbFrameSpectrumWavelengths = [650.0, 550.0, 450.0];
|
|
20
|
+
/** Spectral slot groups (his `frameSpectralGroupCount`): group 0 is sky up, sky down and slot 0; group g is slots 2g − 1, 2g. */
|
|
21
|
+
export const vdbFrameSpectralGroupCount = 4;
|
|
22
|
+
/** Groups in use for the number of light slots in use (0 to 6): 1 + ⌈(slots − 1) / 2⌉. */
|
|
23
|
+
export const vdbFrameSpectralGroups = (slotCount) => 1 + Math.ceil(Math.max(0, slotCount - 1) / 2);
|
|
24
|
+
/** The extinction scale of each channel: scale × (λ / 550)^−α (his getFrameExtinctionSpectrum, engine-free; α a number). */
|
|
25
|
+
export function vdbFrameExtinctionSpectrum(scale, angstromExponent) {
|
|
26
|
+
const ref = vdbFrameSpectrumWavelengths[1];
|
|
27
|
+
return [0, 1, 2].map((c) => Math.max(0, scale[c]) * Math.pow(vdbFrameSpectrumWavelengths[c] / ref, -angstromExponent));
|
|
28
|
+
}
|
|
29
|
+
const clamp01 = (x) => Math.min(1, Math.max(0, x));
|
|
30
|
+
const map3 = (f) => [f(0), f(1), f(2)];
|
|
31
|
+
/** frameMeanComponent: the mean of the channels. */
|
|
32
|
+
export const vdbFrameMeanComponent = (v) => (v[0] + v[1] + v[2]) / 3;
|
|
33
|
+
/** frameSpectralShadowUnit: the depths of one unit of extinction for a volume's spectrum and albedo (frameShadowStep per channel). */
|
|
34
|
+
export function vdbFrameSpectralShadowUnit(spectrum, albedo, multipleScattering) {
|
|
35
|
+
const absorbed = map3((c) => spectrum[c] * (1 - clamp01(albedo[c])));
|
|
36
|
+
const reduced = map3((c) => (spectrum[c] - absorbed[c]) * multipleScattering);
|
|
37
|
+
return { x: [...spectrum], y: map3((c) => Math.sqrt(absorbed[c] * 3 * (absorbed[c] + reduced[c]))), z: reduced };
|
|
38
|
+
}
|
|
39
|
+
/** frameSpectralShadowDepths: one volume has one spectrum, so the depths are linear in the optical depth. */
|
|
40
|
+
export function vdbFrameSpectralShadowDepths(unit, opticalDepth) {
|
|
41
|
+
return { x: map3((c) => unit.x[c] * opticalDepth), y: map3((c) => unit.y[c] * opticalDepth), z: map3((c) => unit.z[c] * opticalDepth) };
|
|
42
|
+
}
|
|
43
|
+
/** frameSpectralShadowStep: the step depths of each channel from the grid's (extinction, absorption) of each channel. */
|
|
44
|
+
export function vdbFrameSpectralShadowStep(extinction, absorption, multipleScattering) {
|
|
45
|
+
const absorbed = map3((c) => Math.min(absorption[c], extinction[c]));
|
|
46
|
+
const reduced = map3((c) => (extinction[c] - absorbed[c]) * multipleScattering);
|
|
47
|
+
return { x: [...extinction], y: map3((c) => Math.sqrt(absorbed[c] * 3 * (absorbed[c] + reduced[c]))), z: reduced };
|
|
48
|
+
}
|
|
49
|
+
/** frameSpectralGridAlbedo: 1 − absorption / extinction of each channel (clamped), 1 with no extinction. */
|
|
50
|
+
export function vdbFrameSpectralGridAlbedo(extinction, absorption) {
|
|
51
|
+
if (!(Math.max(...extinction) > 0))
|
|
52
|
+
return [1, 1, 1];
|
|
53
|
+
return map3((c) => clamp01(1 - absorption[c] / Math.max(extinction[c], 1e-8)));
|
|
54
|
+
}
|
|
55
|
+
/** frameShadowDepth of each channel. */
|
|
56
|
+
export function vdbFrameSpectralShadowDepth(depths, multipleScattering) {
|
|
57
|
+
return map3((c) => vdbFrameShadowDepth([depths.x[c], depths.y[c], depths.z[c]], multipleScattering));
|
|
58
|
+
}
|
|
59
|
+
/** frameShadowMarchDepth of each channel (the marches stop when the smallest is past the limit). */
|
|
60
|
+
export function vdbFrameSpectralShadowMarchDepth(depths, multipleScattering, octaves = vdbFrameOctavesOff) {
|
|
61
|
+
if (octaves[0] > 0)
|
|
62
|
+
return map3((c) => depths.x[c] * Math.pow(octaves[1], octaves[0]));
|
|
63
|
+
return vdbFrameSpectralShadowDepth(depths, multipleScattering);
|
|
64
|
+
}
|
|
65
|
+
/** frameSpectralShadowTransmittance: (direct, total) of each channel; octaves: total is 1 / (1 + τ). */
|
|
66
|
+
export function vdbFrameSpectralShadowTransmittance(depths, multipleScattering, octaves = vdbFrameOctavesOff) {
|
|
67
|
+
const d = vdbFrameSpectralShadowDepth(depths, multipleScattering);
|
|
68
|
+
return { x: map3((c) => Math.exp(-depths.x[c])), y: map3((c) => (octaves[0] > 0 ? 1 / (depths.x[c] + 1) : Math.exp(-d[c]))) };
|
|
69
|
+
}
|
|
70
|
+
/** frameSpectralOctaveLight: Σₙ albedoⁿ bⁿ phase(g cⁿ) exp(−aⁿ τ) of each channel (each octave is one more scattering). */
|
|
71
|
+
export function vdbFrameSpectralOctaveLight(octaves, opticalDepth, albedo, phase, cosTheta) {
|
|
72
|
+
const light = [0, 0, 0];
|
|
73
|
+
const a = map3((c) => clamp01(albedo[c]));
|
|
74
|
+
const albedoScale = [1, 1, 1];
|
|
75
|
+
let extinctionScale = 1;
|
|
76
|
+
let contribution = 1;
|
|
77
|
+
let gScale = 1;
|
|
78
|
+
for (let i = 0; i < vdbFrameMaxScatteringOctaves; i++) {
|
|
79
|
+
if (i + 1 > octaves[0])
|
|
80
|
+
break;
|
|
81
|
+
extinctionScale *= octaves[1];
|
|
82
|
+
contribution *= octaves[2];
|
|
83
|
+
gScale *= octaves[3];
|
|
84
|
+
for (let c = 0; c < 3; c++)
|
|
85
|
+
albedoScale[c] = albedoScale[c] * a[c];
|
|
86
|
+
const p = phase ? vdbFramePhaseWeightScaled(phase, cosTheta, gScale) : 1;
|
|
87
|
+
for (let c = 0; c < 3; c++)
|
|
88
|
+
light[c] = light[c] + albedoScale[c] * (contribution * p) * Math.exp(-opticalDepth[c] * extinctionScale);
|
|
89
|
+
}
|
|
90
|
+
return light;
|
|
91
|
+
}
|
|
92
|
+
/** frameSpectralShadowTotal: total transmittance of isotropic light of each channel from the y shadow values. */
|
|
93
|
+
export function vdbFrameSpectralShadowTotal(shadowY, octaves, albedo) {
|
|
94
|
+
if (!(octaves[0] > 0))
|
|
95
|
+
return [...shadowY];
|
|
96
|
+
const tau = map3((c) => vdbFrameShadowOpticalDepth(shadowY[c]));
|
|
97
|
+
const octave = vdbFrameSpectralOctaveLight(octaves, tau, albedo, null, 0);
|
|
98
|
+
return map3((c) => Math.exp(-tau[c]) + octave[c]);
|
|
99
|
+
}
|
|
100
|
+
/** frameSpectralShadowedLight: phase × direct + scattered of each channel (octaves: the spectral octave light). */
|
|
101
|
+
export function vdbFrameSpectralShadowedLight(phase, phaseSpectrum, octaves, rayDirection, lightDirection, shadow, albedo) {
|
|
102
|
+
const p = vdbFramePhaseColor(phase, phaseSpectrum, rayDirection, lightDirection);
|
|
103
|
+
const cos = rayDirection[0] * lightDirection[0] + rayDirection[1] * lightDirection[1] + rayDirection[2] * lightDirection[2];
|
|
104
|
+
const scattered = octaves[0] > 0
|
|
105
|
+
? vdbFrameSpectralOctaveLight(octaves, map3((c) => vdbFrameShadowOpticalDepth(shadow.y[c])), albedo, phase, cos)
|
|
106
|
+
: map3((c) => shadow.y[c] - shadow.x[c]);
|
|
107
|
+
return map3((c) => shadow.x[c] * p[c] + scattered[c]);
|
|
108
|
+
}
|
|
109
|
+
/** frameUnpackSpectralGroup: the two entries of a slot group from its 3 RGBA targets. */
|
|
110
|
+
export function vdbFrameUnpackSpectralGroup(map0, map1, map2) {
|
|
111
|
+
return {
|
|
112
|
+
a: { x: [map0[0], map0[1], map0[2]], y: [map0[3], map1[0], map1[1]] },
|
|
113
|
+
b: { x: [map1[2], map1[3], map2[0]], y: [map2[1], map2[2], map2[3]] },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/** The inverse of {@link vdbFrameUnpackSpectralGroup}: the 3 targets of a group. */
|
|
117
|
+
export function vdbFramePackSpectralGroup(a, b) {
|
|
118
|
+
return [
|
|
119
|
+
[a.x[0], a.x[1], a.x[2], a.y[0]],
|
|
120
|
+
[a.y[1], a.y[2], b.x[0], b.x[1]],
|
|
121
|
+
[b.x[2], b.y[0], b.y[1], b.y[2]],
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
/** frameIsotropicDiffusion of each channel. */
|
|
125
|
+
const isotropic3 = (front, back, effective) => map3((c) => vdbFrameIsotropicDiffusion(front[c], back[c], effective[c]));
|
|
126
|
+
/** frameTwoSidedDiffusion of each channel. */
|
|
127
|
+
const twoSided3 = (direct, front, effective, back) => map3((c) => vdbFrameTwoSidedDiffusion(direct[c], front[c], effective[c], back[c]));
|
|
128
|
+
const unmarched = () => ({ x: [1, 1, 1], y: [1, 1, 1], z: [0, 0, 0], w: [0, 0, 0] });
|
|
129
|
+
/** The spectral grid sample of the transmittance pass: (extinction, absorption) of each channel, 0 outside the grid. */
|
|
130
|
+
export function vdbFrameSpectralGridSample(extinction, absorption, grid, world) {
|
|
131
|
+
const found = vdbFrameFindCascade(grid, world, 0);
|
|
132
|
+
if (found < 0)
|
|
133
|
+
return { extinction: [0, 0, 0], absorption: [0, 0, 0] };
|
|
134
|
+
const uvw = vdbFrameGridUvw(grid, found, world);
|
|
135
|
+
const e = vdbFrameSampleGrid(extinction, grid, found, uvw);
|
|
136
|
+
const a = vdbFrameSampleGrid(absorption, grid, found, uvw);
|
|
137
|
+
return { extinction: [e[0], e[1], e[2]], absorption: [a[0], a[1], a[2]] };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The spectral `march` of the transmittance pass: the grey march with the depths of each channel; stops when all channels
|
|
141
|
+
* are past depth 6. K7.4a: `out.opticalDepth` gets the direct optical depth of each channel (the spectral MLP's input).
|
|
142
|
+
*/
|
|
143
|
+
export function vdbFrameSpectralGridMarch(sampleAt, grid, origin, direction, maxDistance, jitter, multipleScattering, octaves = vdbFrameOctavesOff, out) {
|
|
144
|
+
const depths = { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] };
|
|
145
|
+
let traveled = 0;
|
|
146
|
+
const probe = [...origin];
|
|
147
|
+
for (let i = 0; i < 1024; i++) {
|
|
148
|
+
const cascade = vdbFrameFindCascade(grid, probe, 0);
|
|
149
|
+
if (cascade < 0 || traveled >= maxDistance || Math.min(...vdbFrameSpectralShadowMarchDepth(depths, multipleScattering, octaves)) > 6)
|
|
150
|
+
break;
|
|
151
|
+
const voxel = grid.gridVoxel[cascade];
|
|
152
|
+
const perUnit = Math.max(Math.abs(direction[0]) / voxel[0], Math.abs(direction[1]) / voxel[1], Math.abs(direction[2]) / voxel[2]);
|
|
153
|
+
const step = Math.min(1 / perUnit, maxDistance - traveled);
|
|
154
|
+
const s = sampleAt([probe[0] + direction[0] * step * jitter, probe[1] + direction[1] * step * jitter, probe[2] + direction[2] * step * jitter]);
|
|
155
|
+
const d = vdbFrameSpectralShadowStep(s.extinction, s.absorption, multipleScattering);
|
|
156
|
+
for (let c = 0; c < 3; c++) {
|
|
157
|
+
depths.x[c] = depths.x[c] + d.x[c] * step;
|
|
158
|
+
depths.y[c] = depths.y[c] + d.y[c] * step;
|
|
159
|
+
depths.z[c] = depths.z[c] + d.z[c] * step;
|
|
160
|
+
probe[c] = probe[c] + direction[c] * step;
|
|
161
|
+
}
|
|
162
|
+
traveled += step;
|
|
163
|
+
}
|
|
164
|
+
const t = vdbFrameSpectralShadowTransmittance(depths, multipleScattering, octaves);
|
|
165
|
+
if (out)
|
|
166
|
+
out.opticalDepth = [depths.x[0], depths.x[1], depths.x[2]];
|
|
167
|
+
return { x: t.x, y: t.y, z: depths.z, w: depths.y };
|
|
168
|
+
}
|
|
169
|
+
const normalize3 = (v) => {
|
|
170
|
+
const l = Math.hypot(v[0], v[1], v[2]);
|
|
171
|
+
return l > 0 ? [v[0] / l, v[1] / l, v[2] / l] : [0, 0, 0];
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* The spectral transmittance pass at one grid voxel for one slot group (buildSpectralNodes): the 3 MRT outputs.
|
|
175
|
+
* Group 0: (sky up, sky down) and slot 0; group g: slots 2g − 1 and 2g; a slot entry is (total, direct). Voxels
|
|
176
|
+
* with no extinction within half a voxel keep 1.0. `twoSided`: the slot marches get the slab diffusion.
|
|
177
|
+
*/
|
|
178
|
+
export function vdbFrameSpectralTransmittanceVoxel(extinction, absorption, grid, fragCoord, lights, skyDirection, multipleScattering, jitterValue, group, modes = {}) {
|
|
179
|
+
const octaves = modes.octaves ?? vdbFrameOctavesOff;
|
|
180
|
+
const ones = [
|
|
181
|
+
[1, 1, 1, 1],
|
|
182
|
+
[1, 1, 1, 1],
|
|
183
|
+
[1, 1, 1, 1],
|
|
184
|
+
];
|
|
185
|
+
const cell = vdbFrameGridCell(grid.resolution, grid.columns, fragCoord);
|
|
186
|
+
if (cell.cascade >= grid.count)
|
|
187
|
+
return ones;
|
|
188
|
+
const voxel = grid.gridVoxel[cell.cascade];
|
|
189
|
+
const m = grid.gridMin[cell.cascade];
|
|
190
|
+
const s = grid.gridSize[cell.cascade];
|
|
191
|
+
const world = [m[0] + cell.gridUvw[0] * s[0], m[1] + cell.gridUvw[1] * s[1], m[2] + cell.gridUvw[2] * s[2]];
|
|
192
|
+
const sampleAt = (p) => vdbFrameSpectralGridSample(extinction, absorption, grid, p);
|
|
193
|
+
let near = 0;
|
|
194
|
+
for (let i = 0; i < 8; i++) {
|
|
195
|
+
const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
|
|
196
|
+
const e = sampleAt([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]]).extinction;
|
|
197
|
+
near += e[0] + e[1] + e[2];
|
|
198
|
+
}
|
|
199
|
+
if (!(near > 0))
|
|
200
|
+
return ones;
|
|
201
|
+
const jitter = vdbFrameNoise(jitterValue, fragCoord);
|
|
202
|
+
const sky = normalize3(skyDirection);
|
|
203
|
+
const march = (enabled, dir, maxDistance) => (enabled ? vdbFrameSpectralGridMarch(sampleAt, grid, world, dir, maxDistance, jitter, multipleScattering, octaves) : unmarched());
|
|
204
|
+
const marchSlot = (enabled, slot) => {
|
|
205
|
+
const active = enabled && slot < lights.length;
|
|
206
|
+
const l = lights[Math.min(slot, 5)] ?? [0, 1, 0, 1];
|
|
207
|
+
const isDirection = l[3] < 1.5;
|
|
208
|
+
const toLight = [l[0] - world[0], l[1] - world[1], l[2] - world[2]];
|
|
209
|
+
const dir = isDirection ? normalize3([l[0], l[1], l[2]]) : normalize3(toLight);
|
|
210
|
+
const front = march(active, dir, isDirection ? 1e20 : Math.hypot(...toLight));
|
|
211
|
+
if (modes.twoSided) {
|
|
212
|
+
const back = march(active, [-dir[0], -dir[1], -dir[2]], 1e20);
|
|
213
|
+
front.y = twoSided3(front.x, front.z, front.w, back.z);
|
|
214
|
+
}
|
|
215
|
+
return front;
|
|
216
|
+
};
|
|
217
|
+
const isSky = group === 0;
|
|
218
|
+
const slotA = group * 2 - 1;
|
|
219
|
+
const first = march(isSky, sky, 1e20);
|
|
220
|
+
const second = march(isSky, [-sky[0], -sky[1], -sky[2]], 1e20);
|
|
221
|
+
const slotFirst = marchSlot(!isSky, Math.max(slotA, 0));
|
|
222
|
+
const slotSecond = marchSlot(true, isSky ? 0 : slotA + 1);
|
|
223
|
+
const skyTotal = (f, b) => (multipleScattering > 0 ? isotropic3(f.z, b.z, f.w) : f.y);
|
|
224
|
+
const a = isSky ? { x: skyTotal(first, second), y: skyTotal(second, first) } : { x: slotFirst.y, y: slotFirst.x };
|
|
225
|
+
const b = { x: slotSecond.y, y: slotSecond.x };
|
|
226
|
+
return vdbFramePackSpectralGroup(a, b);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The spectral environment grid pass at one voxel of the last cascade (FrameEnvironmentGridMaterial, spectral
|
|
230
|
+
* branch): the march of each channel through the grid's extinction and absorption atlases, the voxel's albedo
|
|
231
|
+
* for the octaves; diffusion: the two-sided total of each channel.
|
|
232
|
+
*/
|
|
233
|
+
export function vdbFrameSpectralEnvironmentGridVoxel(extinction, absorption, grid, envColumns, fragCoord, lights, unshadowed, multipleScattering, octaves = vdbFrameOctavesOff) {
|
|
234
|
+
const cascade = grid.count - 1;
|
|
235
|
+
const res = grid.resolution;
|
|
236
|
+
const tile = [Math.floor(fragCoord[0] / res), Math.floor(fragCoord[1] / res)];
|
|
237
|
+
const z = tile[1] * envColumns + tile[0];
|
|
238
|
+
const uvw0 = [(fragCoord[0] - tile[0] * res) / res, (fragCoord[1] - tile[1] * res) / res, (z + 0.5) / res];
|
|
239
|
+
const voxel = grid.gridVoxel[cascade];
|
|
240
|
+
const m = grid.gridMin[cascade];
|
|
241
|
+
const s = grid.gridSize[cascade];
|
|
242
|
+
const world = [m[0] + uvw0[0] * s[0], m[1] + uvw0[1] * s[1], m[2] + uvw0[2] * s[2]];
|
|
243
|
+
const uvwOf = (p) => [(p[0] - m[0]) / s[0], (p[1] - m[1]) / s[1], (p[2] - m[2]) / s[2]];
|
|
244
|
+
const sampleE = (uvw) => vdbFrameSampleGrid(extinction, grid, cascade, uvw);
|
|
245
|
+
const sampleA = (uvw) => vdbFrameSampleGrid(absorption, grid, cascade, uvw);
|
|
246
|
+
let near = 0;
|
|
247
|
+
for (let i = 0; i < 8; i++) {
|
|
248
|
+
const c = [(i & 1) - 0.5, ((i >> 1) & 1) - 0.5, ((i >> 2) & 1) - 0.5];
|
|
249
|
+
const e = sampleE(uvwOf([world[0] + c[0] * voxel[0], world[1] + c[1] * voxel[1], world[2] + c[2] * voxel[2]]));
|
|
250
|
+
near += e[0] + e[1] + e[2];
|
|
251
|
+
}
|
|
252
|
+
const outside = vdbFrameSpectralShadowTotal([1, 1, 1], octaves, [1, 1, 1]);
|
|
253
|
+
if (!(z < res && near > 0))
|
|
254
|
+
return [unshadowed[0] * outside[0], unshadowed[1] * outside[1], unshadowed[2] * outside[2], 1];
|
|
255
|
+
const e0 = sampleE(uvw0);
|
|
256
|
+
const a0 = sampleA(uvw0);
|
|
257
|
+
const albedo = vdbFrameSpectralGridAlbedo([e0[0], e0[1], e0[2]], [a0[0], a0[1], a0[2]]);
|
|
258
|
+
const marchDepths = (dir) => {
|
|
259
|
+
const perUnit = Math.max(Math.abs(dir[0]) / voxel[0], Math.abs(dir[1]) / voxel[1], Math.abs(dir[2]) / voxel[2]);
|
|
260
|
+
const step = 1 / perUnit;
|
|
261
|
+
const probe = [world[0] + dir[0] * step * 0.5, world[1] + dir[1] * step * 0.5, world[2] + dir[2] * step * 0.5];
|
|
262
|
+
const depths = { x: [0, 0, 0], y: [0, 0, 0], z: [0, 0, 0] };
|
|
263
|
+
for (let i = 0; i < 1024; i++) {
|
|
264
|
+
const uvw = uvwOf(probe);
|
|
265
|
+
if (uvw.some((v) => v < 0 || v > 1) || Math.min(...vdbFrameSpectralShadowMarchDepth(depths, multipleScattering, octaves)) > 6)
|
|
266
|
+
break;
|
|
267
|
+
const e = sampleE(uvw);
|
|
268
|
+
const a = sampleA(uvw);
|
|
269
|
+
const d = vdbFrameSpectralShadowStep([e[0], e[1], e[2]], [a[0], a[1], a[2]], multipleScattering);
|
|
270
|
+
for (let c = 0; c < 3; c++) {
|
|
271
|
+
depths.x[c] = depths.x[c] + d.x[c] * step;
|
|
272
|
+
depths.y[c] = depths.y[c] + d.y[c] * step;
|
|
273
|
+
depths.z[c] = depths.z[c] + d.z[c] * step;
|
|
274
|
+
probe[c] = probe[c] + dir[c] * step;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return depths;
|
|
278
|
+
};
|
|
279
|
+
const irradiance = [0, 0, 0];
|
|
280
|
+
for (const light of lights) {
|
|
281
|
+
const depths = marchDepths(light.direction);
|
|
282
|
+
const total = multipleScattering > 0
|
|
283
|
+
? isotropic3(depths.z, marchDepths([-light.direction[0], -light.direction[1], -light.direction[2]]).z, depths.y)
|
|
284
|
+
: vdbFrameSpectralShadowTotal(vdbFrameSpectralShadowTransmittance(depths, multipleScattering, octaves).y, octaves, albedo);
|
|
285
|
+
for (let c = 0; c < 3; c++)
|
|
286
|
+
irradiance[c] = irradiance[c] + light.color[c] * total[c];
|
|
287
|
+
}
|
|
288
|
+
return [Math.max(irradiance[0], 0), Math.max(irradiance[1], 0), Math.max(irradiance[2], 0), 1];
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* The spectral density pass at one froxel of one volume (buildSpectralNodes, environment 'grid' or none): the
|
|
292
|
+
* pre-integration with the transmittance of each channel (the visible position weighs the channel mean), and
|
|
293
|
+
* the 3 MRT outputs (albedo × extinction, weight), (emission × weight, t × weight), (extinction, 0), or null.
|
|
294
|
+
*/
|
|
295
|
+
export function vdbFrameSpectralDensityFroxel(fragCoord, p) {
|
|
296
|
+
const f = vdbFrameDensityFroxelSteps(fragCoord, p);
|
|
297
|
+
if (!f)
|
|
298
|
+
return null;
|
|
299
|
+
const { viewNear, viewFar, localNear, localFar, t0, segment, steps, subStepLength, lod, jitter, mul } = f;
|
|
300
|
+
const lerp3 = (x, y, t) => [x[0] + (y[0] - x[0]) * t, x[1] + (y[1] - x[1]) * t, x[2] + (y[2] - x[2]) * t];
|
|
301
|
+
const spectrum = p.extinctionSpectrum;
|
|
302
|
+
let extinctionSum = 0;
|
|
303
|
+
const transmittance = [1, 1, 1];
|
|
304
|
+
let visibleWeight = 0;
|
|
305
|
+
let visibleTSum = 0;
|
|
306
|
+
for (let i = 0; i < steps; i++) {
|
|
307
|
+
const t = t0 + segment * ((i + jitter) / steps);
|
|
308
|
+
const e = p.extinctionAt(lerp3(localNear, localFar, t), lod) * p.opacity * vdbFrameDistanceFade(p.fadeRadius, lerp3(viewNear, viewFar, t));
|
|
309
|
+
const stepT = map3((c) => Math.exp(-spectrum[c] * e * subStepLength));
|
|
310
|
+
const w = vdbFrameMeanComponent(map3((c) => transmittance[c] * (1 - stepT[c])));
|
|
311
|
+
visibleWeight += w;
|
|
312
|
+
visibleTSum += w * t;
|
|
313
|
+
extinctionSum += e;
|
|
314
|
+
for (let c = 0; c < 3; c++)
|
|
315
|
+
transmittance[c] = transmittance[c] * stepT[c];
|
|
316
|
+
}
|
|
317
|
+
const extinction = map3((c) => spectrum[c] * ((extinctionSum / steps) * segment));
|
|
318
|
+
const weight = vdbFrameMeanComponent(extinction);
|
|
319
|
+
if (!(weight > 0))
|
|
320
|
+
return null;
|
|
321
|
+
const visibleT = visibleWeight > 0 ? visibleTSum / visibleWeight : 0.5;
|
|
322
|
+
const visibleWorld = mul(p.cameraWorld, lerp3(viewNear, viewFar, visibleT));
|
|
323
|
+
const emission = [...p.scatterColor];
|
|
324
|
+
const albedo = p.baseColor;
|
|
325
|
+
if (p.environmentGrid && p.grid) {
|
|
326
|
+
const g = p.grid;
|
|
327
|
+
const uvw = vdbFrameGridUvw(g, g.count - 1, visibleWorld);
|
|
328
|
+
const outside = vdbFrameSpectralShadowTotal([1, 1, 1], p.octaves ?? vdbFrameOctavesOff, albedo);
|
|
329
|
+
const env = vdbFrameInsideGrid(g.resolution, uvw) ? vdbFrameSampleTiles(p.environmentGrid.atlas, g.resolution, 0, p.environmentGrid.columns, uvw) : map3((c) => p.environmentGrid.unshadowed[c] * outside[c]);
|
|
330
|
+
for (let c = 0; c < 3; c++)
|
|
331
|
+
emission[c] = emission[c] + (albedo[c] * env[c]) / Math.PI;
|
|
332
|
+
}
|
|
333
|
+
return [
|
|
334
|
+
[albedo[0] * extinction[0], albedo[1] * extinction[1], albedo[2] * extinction[2], weight],
|
|
335
|
+
[emission[0] * weight, emission[1] * weight, emission[2] * weight, visibleT * weight],
|
|
336
|
+
[extinction[0], extinction[1], extinction[2], 0],
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
/** three's `getShIrradianceAt` (L2 SH irradiance of a light probe at a unit normal). */
|
|
340
|
+
export function vdbShIrradianceAt(normal, sh) {
|
|
341
|
+
const [x, y, z] = normal;
|
|
342
|
+
const k = [0.886227, 2 * 0.511664 * y, 2 * 0.511664 * z, 2 * 0.511664 * x, 2 * 0.429043 * x * y, 2 * 0.429043 * y * z, z * z * 0.743125 - 0.247708, 2 * 0.429043 * x * z, 0.429043 * (x * x - y * y)];
|
|
343
|
+
return map3((c) => k.reduce((sum, w, i) => sum + (sh[i]?.[c] ?? 0) * w, 0));
|
|
344
|
+
}
|
|
345
|
+
const smoothstep = (e0, e1, x) => {
|
|
346
|
+
const t = Math.min(Math.max((x - e0) / (e1 - e0), 0), 1);
|
|
347
|
+
return t * t * (3 - 2 * t);
|
|
348
|
+
};
|
|
349
|
+
const distanceAttenuation = (d, cutoff, decay) => {
|
|
350
|
+
const falloff = 1 / Math.max(Math.pow(d, decay), 0.01);
|
|
351
|
+
return cutoff > 0 ? falloff * Math.pow(Math.min(Math.max(1 - Math.pow(d / cutoff, 4), 0), 1), 2) : falloff;
|
|
352
|
+
};
|
|
353
|
+
/**
|
|
354
|
+
* The spectral lighting pass at one froxel (createSpectralFragmentNode): from the 3 density targets, the slot
|
|
355
|
+
* groups sampled at the visible position. Returns the two atlas outputs (radiance × α of each channel, green α)
|
|
356
|
+
* and (red α, blue α, 0, green α), or zeros when the weight is ≤ 0 (the pass discards; the target is cleared).
|
|
357
|
+
*/
|
|
358
|
+
export function vdbFrameSpectralLightingFroxel(density, viewNear, viewFar, cameraWorld, inputs) {
|
|
359
|
+
const [albedoT, emissionT, extinctionT] = density;
|
|
360
|
+
const weight = albedoT[3];
|
|
361
|
+
if (!(weight > 0))
|
|
362
|
+
return [
|
|
363
|
+
[0, 0, 0, 0],
|
|
364
|
+
[0, 0, 0, 0],
|
|
365
|
+
];
|
|
366
|
+
const m = cameraWorld;
|
|
367
|
+
const extinction = [extinctionT[0], extinctionT[1], extinctionT[2]];
|
|
368
|
+
const visibleT = Math.min(Math.max(emissionT[3] / weight, 0), 1);
|
|
369
|
+
const view = map3((c) => viewNear[c] + (viewFar[c] - viewNear[c]) * visibleT);
|
|
370
|
+
const world = map3((r) => m[r] * view[0] + m[4 + r] * view[1] + m[8 + r] * view[2] + m[12 + r]);
|
|
371
|
+
const seg = map3((c) => viewFar[c] - viewNear[c]);
|
|
372
|
+
const ray = normalize3(map3((r) => m[r] * seg[0] + m[4 + r] * seg[1] + m[8 + r] * seg[2]));
|
|
373
|
+
const albedo = map3((c) => albedoT[c] / Math.max(extinction[c], 1e-8));
|
|
374
|
+
const emission = map3((c) => emissionT[c] / weight);
|
|
375
|
+
const octaves = inputs.octaves ?? vdbFrameOctavesOff;
|
|
376
|
+
const ones = [1, 1, 1, 1];
|
|
377
|
+
const groupMaps = inputs.groupsAt ? inputs.groupsAt(world) : [];
|
|
378
|
+
const groups = [0, 1, 2, 3].map((g) => {
|
|
379
|
+
const maps = groupMaps[g] ?? [ones, ones, ones];
|
|
380
|
+
return vdbFrameUnpackSpectralGroup(maps[0], maps[1], maps[2]);
|
|
381
|
+
});
|
|
382
|
+
const slotEntry = (slot) => (slot === 0 ? groups[0].b : slot % 2 === 1 ? groups[(slot + 1) / 2].a : groups[slot / 2].b);
|
|
383
|
+
// K6.Q1a: with the shadowed ambient the sky entry holds the visibilities (totals already)
|
|
384
|
+
const ao = !!inputs.ambientOcclusion;
|
|
385
|
+
// K6.Q1d: × the phase weight of the pairs' dipole
|
|
386
|
+
const aoWeight = ao && inputs.ambientWeight ? inputs.ambientWeight(world, ray, groups[0].a.x, groups[0].a.y) : [1, 1, 1];
|
|
387
|
+
const skyUp = (ao ? groups[0].a.x.map((v, c) => v * aoWeight[c]) : vdbFrameSpectralShadowTotal(groups[0].a.x, octaves, albedo)).map((v) => v * 0.5);
|
|
388
|
+
const skyDown = (ao ? groups[0].a.y.map((v, c) => v * aoWeight[c]) : vdbFrameSpectralShadowTotal(groups[0].a.y, octaves, albedo)).map((v) => v * 0.5);
|
|
389
|
+
const sky = normalize3(inputs.skyDirection ?? [0, 1, 0]);
|
|
390
|
+
const probe = (n) => (!inputs.lightProbe ? [0, 0, 0] : vdbShIrradianceAt(n, inputs.lightProbe));
|
|
391
|
+
const probeUp = probe(sky);
|
|
392
|
+
const probeDown = probe([-sky[0], -sky[1], -sky[2]]);
|
|
393
|
+
const irradiance = map3((c) => inputs.ambient[c] * (ao ? skyUp[c] + skyDown[c] : 1) + probeUp[c] * skyUp[c] + probeDown[c] * skyDown[c] + inputs.hemiSky[c] * skyUp[c] + inputs.hemiGround[c] * skyDown[c]);
|
|
394
|
+
const spectrum = inputs.phaseSpectrum ?? [1, 1, 0];
|
|
395
|
+
inputs.lights.forEach((light, i) => {
|
|
396
|
+
const p = light.position;
|
|
397
|
+
const toLight = [p[0] - world[0], p[1] - world[1], p[2] - world[2]];
|
|
398
|
+
const dir = p[3] < 1.5 ? [p[0], p[1], p[2]] : normalize3(toLight);
|
|
399
|
+
const nl = normalize3(toLight);
|
|
400
|
+
const spot = p[3] > 2.5 && light.spot ? smoothstep(light.spot[3], light.penumbra ?? 1, nl[0] * light.spot[0] + nl[1] * light.spot[1] + nl[2] * light.spot[2]) : 1;
|
|
401
|
+
const dist = p[3] > 1.5 ? distanceAttenuation(Math.hypot(...toLight), light.falloff?.[0] ?? 0, light.falloff?.[1] ?? 0) : 1;
|
|
402
|
+
const useSlot = i < 6 && i < inputs.shadowLightCount;
|
|
403
|
+
const entry = useSlot ? slotEntry(i) : null;
|
|
404
|
+
const v = inputs.occluderAt ? inputs.occluderAt(i, world) : 1;
|
|
405
|
+
const shadow = entry ? { x: entry.y, y: entry.x } : { x: [1, 1, 1], y: [1, 1, 1] };
|
|
406
|
+
// K6.5b in the core: direct × v (passed as (direct·v, total − direct·(1 − v))), else the whole light × v
|
|
407
|
+
const occludedSlot = !!entry && !(octaves[0] > 0);
|
|
408
|
+
// K7.4c: the scattered part (total − direct) × its exit factor (code 0: his)
|
|
409
|
+
const exit = occludedSlot && (inputs.msExit ?? 0) > 0.5
|
|
410
|
+
? vdbFrameMsExitFactor(inputs.msExit, inputs.phase, spectrum, ray[0] * dir[0] + ray[1] * dir[1] + ray[2] * dir[2], shadow.x, map3((c) => shadow.y[c] - shadow.x[c]), albedo)
|
|
411
|
+
: null;
|
|
412
|
+
const s2 = occludedSlot
|
|
413
|
+
? { x: map3((c) => shadow.x[c] * v), y: map3((c) => (exit ? shadow.x[c] * v + (shadow.y[c] - shadow.x[c]) * exit[c] : shadow.y[c] - shadow.x[c] * (1 - v))) }
|
|
414
|
+
: shadow;
|
|
415
|
+
const l0 = vdbFrameSpectralShadowedLight(inputs.phase, spectrum, octaves, ray, dir, s2, albedo);
|
|
416
|
+
const l = occludedSlot ? l0 : map3((c) => l0[c] * v);
|
|
417
|
+
for (let c = 0; c < 3; c++)
|
|
418
|
+
irradiance[c] = irradiance[c] + light.color[c] * l[c] * spot * dist;
|
|
419
|
+
});
|
|
420
|
+
inputs.environmentColors.forEach((color, i) => {
|
|
421
|
+
const slot = inputs.environmentShadowSlot + i;
|
|
422
|
+
const total = slot < 6 ? slotEntry(slot).x : [1, 1, 1];
|
|
423
|
+
const t = vdbFrameSpectralShadowTotal(total, octaves, albedo);
|
|
424
|
+
for (let c = 0; c < 3; c++)
|
|
425
|
+
irradiance[c] = irradiance[c] + color[c] * t[c];
|
|
426
|
+
});
|
|
427
|
+
const length = Math.hypot(...seg);
|
|
428
|
+
const alpha = map3((c) => 1 - Math.exp(-extinction[c] * length));
|
|
429
|
+
const radiance = map3((c) => albedo[c] * irradiance[c] * (1 / Math.PI) + emission[c]);
|
|
430
|
+
return [
|
|
431
|
+
[radiance[0] * alpha[0], radiance[1] * alpha[1], radiance[2] * alpha[2], alpha[1]],
|
|
432
|
+
[alpha[0], alpha[2], 0, alpha[1]],
|
|
433
|
+
];
|
|
434
|
+
}
|
|
435
|
+
/** The spectral transmittance group maps at a world position (sampleShadows of each group's 3 targets), for {@link vdbFrameSpectralLightingFroxel}. */
|
|
436
|
+
export function vdbFrameSpectralGroupsAt(groupAtlases, grid) {
|
|
437
|
+
return (world) => groupAtlases.map((atlases) => vdbFrameSampleShadows(atlases, grid, world));
|
|
438
|
+
}
|
|
439
|
+
const lightFlags = { ambient: 0b100000, hemisphere: 0b000010, environment: 0b000001 };
|
|
440
|
+
/**
|
|
441
|
+
* The isotropic light terms of the inject pass ('volume' lighting) at the lit position: ambient + light probe
|
|
442
|
+
* along the outward normal; the environment lights (one march each; with diffusion the two-sided total of the
|
|
443
|
+
* march pair), or the 'outward' IBL irradiance with its march pair; the hemisphere lights (sky up and ground
|
|
444
|
+
* down, a pair). Returns the irradiance before the scene lights. Grey: the march's channels are equal.
|
|
445
|
+
*/
|
|
446
|
+
export function vdbFrameInjectIsotropicIrradiance(p) {
|
|
447
|
+
const octaves = p.octaves ?? vdbFrameOctavesOff;
|
|
448
|
+
const diffusion = p.multipleScattering > 0;
|
|
449
|
+
const m = p.worldToLocal;
|
|
450
|
+
const toLocal = (d) => map3((r) => m[r] * d[0] + m[4 + r] * d[1] + m[8 + r] * d[2]);
|
|
451
|
+
const total = (y) => (p.spectral ? vdbFrameSpectralShadowTotal(y, octaves, p.albedo) : map3((c) => vdbFrameShadowTotal(y[c], octaves)));
|
|
452
|
+
const pair = (localDirection) => {
|
|
453
|
+
const front = p.march(localDirection, 1e6);
|
|
454
|
+
const back = p.march([-localDirection[0], -localDirection[1], -localDirection[2]], 1e6);
|
|
455
|
+
return { x: isotropic3(front.z, back.z, front.w), y: isotropic3(back.z, front.z, back.w) };
|
|
456
|
+
};
|
|
457
|
+
const isotropic = (localDirection) => (diffusion ? pair(localDirection).x : total(p.march(localDirection, 1e6).y));
|
|
458
|
+
const irradiance = [0, 0, 0];
|
|
459
|
+
const add = (v, s = 1) => {
|
|
460
|
+
for (let c = 0; c < 3; c++)
|
|
461
|
+
irradiance[c] = irradiance[c] + v[c] * (typeof s === "number" ? s : s[c]);
|
|
462
|
+
};
|
|
463
|
+
if (p.lights & lightFlags.ambient) {
|
|
464
|
+
add(p.ambient);
|
|
465
|
+
if (p.lightProbe)
|
|
466
|
+
add(vdbShIrradianceAt(p.outwardNormal, p.lightProbe));
|
|
467
|
+
}
|
|
468
|
+
if (p.lights & lightFlags.environment) {
|
|
469
|
+
if (p.environment && p.environment.length > 0) {
|
|
470
|
+
const env = [0, 0, 0];
|
|
471
|
+
for (const light of p.environment) {
|
|
472
|
+
const t = isotropic(toLocal(light.direction));
|
|
473
|
+
for (let c = 0; c < 3; c++)
|
|
474
|
+
env[c] = env[c] + light.color[c] * t[c];
|
|
475
|
+
}
|
|
476
|
+
add(map3((c) => Math.max(env[c], 0)));
|
|
477
|
+
}
|
|
478
|
+
else if (p.environmentIrradiance) {
|
|
479
|
+
const outward = toLocal(p.outwardNormal);
|
|
480
|
+
const n = p.outwardNormal;
|
|
481
|
+
if (diffusion) {
|
|
482
|
+
const pr = pair(outward);
|
|
483
|
+
add(p.environmentIrradiance(n), map3((c) => pr.x[c] * 0.5));
|
|
484
|
+
add(p.environmentIrradiance([-n[0], -n[1], -n[2]]), map3((c) => pr.y[c] * 0.5));
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
add(p.environmentIrradiance(n), total(p.march(outward, 1e6).y));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (p.lights & lightFlags.hemisphere) {
|
|
492
|
+
for (const h of p.hemisphere ?? []) {
|
|
493
|
+
const up = toLocal(h.direction);
|
|
494
|
+
let sky;
|
|
495
|
+
let ground;
|
|
496
|
+
if (diffusion) {
|
|
497
|
+
const pr = pair(up);
|
|
498
|
+
sky = pr.x;
|
|
499
|
+
ground = pr.y;
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
sky = total(p.march(up, 1e6).y);
|
|
503
|
+
ground = total(p.march([-up[0], -up[1], -up[2]], 1e6).y);
|
|
504
|
+
}
|
|
505
|
+
add(h.sky, map3((c) => 0.5 * sky[c]));
|
|
506
|
+
add(h.ground, map3((c) => 0.5 * ground[c]));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return irradiance;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The spectral inject shadow march over given extinction samples (already × world step × absorbance): one optical
|
|
513
|
+
* depth for the volume's spectrum; stops when every channel's march depth is past 8. Returns (direct, total,
|
|
514
|
+
* reduced, effective) of each channel. The grey twin is `vdbFrameShadowMarch`.
|
|
515
|
+
*/
|
|
516
|
+
export function vdbFrameSpectralShadowMarch(scaledExtinctions, spectrum, albedo, multipleScattering, octaves = vdbFrameOctavesOff) {
|
|
517
|
+
const unit = vdbFrameSpectralShadowUnit(spectrum, albedo, multipleScattering);
|
|
518
|
+
let opticalDepth = 0;
|
|
519
|
+
for (const e of scaledExtinctions) {
|
|
520
|
+
opticalDepth += e;
|
|
521
|
+
if (Math.min(...vdbFrameSpectralShadowMarchDepth(vdbFrameSpectralShadowDepths(unit, opticalDepth), multipleScattering, octaves)) > 8)
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
const depths = vdbFrameSpectralShadowDepths(unit, opticalDepth);
|
|
525
|
+
const t = vdbFrameSpectralShadowTransmittance(depths, multipleScattering, octaves);
|
|
526
|
+
return { x: t.x, y: t.y, z: depths.z, w: depths.y };
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* The spectral view-ray pre-integration of one froxel in the inject pass: the alpha of each channel and the
|
|
530
|
+
* lit position t (the channel-mean visibility weight), or null when discarded (the grey twin is
|
|
531
|
+
* `vdbFrameInjectSlice`).
|
|
532
|
+
*/
|
|
533
|
+
export function vdbFrameSpectralInjectSlice(opticalDepths, spectrum, segment, jitter = 0.5) {
|
|
534
|
+
const n = opticalDepths.length;
|
|
535
|
+
const transmittance = [1, 1, 1];
|
|
536
|
+
let visibleWeight = 0;
|
|
537
|
+
let visibleTSum = 0;
|
|
538
|
+
for (let i = 0; i < n; i++) {
|
|
539
|
+
const t = segment[0] + (segment[1] - segment[0]) * ((i + jitter) / n);
|
|
540
|
+
const stepT = map3((c) => Math.exp(-spectrum[c] * opticalDepths[i]));
|
|
541
|
+
const w = vdbFrameMeanComponent(map3((c) => transmittance[c] * (1 - stepT[c])));
|
|
542
|
+
visibleWeight += w;
|
|
543
|
+
visibleTSum += w * t;
|
|
544
|
+
for (let c = 0; c < 3; c++)
|
|
545
|
+
transmittance[c] = transmittance[c] * stepT[c];
|
|
546
|
+
}
|
|
547
|
+
const alpha = map3((c) => 1 - transmittance[c]);
|
|
548
|
+
if (visibleWeight <= 0 || Math.max(...alpha) <= 1e-5)
|
|
549
|
+
return null;
|
|
550
|
+
return { alpha, t: visibleTSum / visibleWeight };
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* The spectral integrate composite of one pixel (createSpectralFragmentNode, linear blending, full slices): the
|
|
554
|
+
* froxels' premultiplied colour and per-channel alpha front to back. Returns (radiance, transmittance of each channel).
|
|
555
|
+
*/
|
|
556
|
+
export function vdbFrameSpectralIntegrate(froxels) {
|
|
557
|
+
const radiance = [0, 0, 0];
|
|
558
|
+
const transmittance = [1, 1, 1];
|
|
559
|
+
for (const f of froxels) {
|
|
560
|
+
if (Math.max(...transmittance) < 0.001)
|
|
561
|
+
break;
|
|
562
|
+
const a = map3((c) => clamp01(f.alpha[c]));
|
|
563
|
+
if (!(Math.max(...a) > 0))
|
|
564
|
+
continue;
|
|
565
|
+
for (let c = 0; c < 3; c++) {
|
|
566
|
+
radiance[c] = radiance[c] + transmittance[c] * f.color[c] * (a[c] / Math.max(a[c], 1e-6));
|
|
567
|
+
transmittance[c] = transmittance[c] * (1 - a[c]);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return { radiance, transmittance };
|
|
571
|
+
}
|
|
572
|
+
//# sourceMappingURL=spectral.js.map
|