@pmndrs/vdb 0.1.0 → 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 +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- 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 +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- 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 +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- 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/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- 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 +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- 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 +59 -2
- package/dist/core/source/types.js.map +1 -1
- 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 +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- 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 +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- 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 +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- 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 +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- 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 +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- 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 +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- 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 +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- 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 +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- 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/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- 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 +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- 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 +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- 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 +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- 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 +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- 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 +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- 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 +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- 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 +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- 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 +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- 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 +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- 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 +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- 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/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 +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- 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 +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- 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.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- 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 +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
|
@@ -69,6 +69,15 @@ export declare function vdbFrameShadowCascadeBreaks(count: number, near: number,
|
|
|
69
69
|
export declare function vdbFrameShadowCascadeFar(near: number, cameraFar: number, castShadowDistance: number, boxFar: number, boxDiagonal: number): number;
|
|
70
70
|
/** The cascade of a receiver (getCascadeLookup L253–261): the number of cascade far distances in front of it. */
|
|
71
71
|
export declare function vdbFrameShadowCascadeIndex(viewDepth: number, breaks: readonly number[], count: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* The spot map uv of a receiver (FrameVolumeShadowNode, his 62a6e3e): `clip` is its clip position in the camera that
|
|
74
|
+
* drew the map (the drawn view-projection, not three's current shadow matrix), with three's ShadowNode y flip.
|
|
75
|
+
* Outside when behind that camera (w ≤ 0) or off the map.
|
|
76
|
+
*/
|
|
77
|
+
export declare function vdbFrameShadowSpotUv(clip: Vec4): {
|
|
78
|
+
uv: Vec2;
|
|
79
|
+
inside: boolean;
|
|
80
|
+
};
|
|
72
81
|
/**
|
|
73
82
|
* The atlas uv of a receiver in cascade `index` (getCascadeLookup L266–282): `clip` is its clip position in the
|
|
74
83
|
* cascade camera (x, y after the divide; orthographic, so w = 1). Half a texel in from each tile side. `inside`
|
|
@@ -78,3 +87,104 @@ export declare function vdbFrameShadowCascadeUv(clip: Vec2, index: number, size:
|
|
|
78
87
|
uv: Vec2;
|
|
79
88
|
insideTile: boolean;
|
|
80
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* The map ray of one texel from the drawing camera's inverse view-projection (the core's `vdbFrameVolumeShadowCs`;
|
|
92
|
+
* the same construction as {@link vdbFrameShadowPassRay}: two unprojected points at NDC depth 0.25 and 0.75 give the
|
|
93
|
+
* direction; perspective rays start at the camera, orthographic ones on the camera plane). `ndc`: the texel centre,
|
|
94
|
+
* x right, y up (texel row r ↔ ndc.y = 1 − 2 (r + ½) / size).
|
|
95
|
+
*/
|
|
96
|
+
export declare function vdbFrameShadowMapRay(inverseViewProjection: ArrayLike<number>, cameraPosition: Vec3, perspective: boolean, ndc: Vec2): {
|
|
97
|
+
origin: Vec3;
|
|
98
|
+
direction: Vec3;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The (unnormalized) direction of a cube map texel: face 0–5 (+x, −x, +y, −y, +z, −z), `a`, `b` in [−1, 1] the
|
|
102
|
+
* face coordinates (s, t) × 2 − 1 with t down the rows. WebGPU's cube face selection (the Vulkan table): a cube view
|
|
103
|
+
* sampled with this direction reads this texel.
|
|
104
|
+
*/
|
|
105
|
+
export declare function vdbFrameCubeFaceDirection(face: number, a: number, b: number): Vec3;
|
|
106
|
+
/** The inverse of {@link vdbFrameCubeFaceDirection}: the face and its (s, t) in [0, 1] (t down the rows) of a direction. */
|
|
107
|
+
export declare function vdbFrameCubeFaceUv(d: Vec3): {
|
|
108
|
+
face: number;
|
|
109
|
+
s: number;
|
|
110
|
+
t: number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* The drawing camera of a view-projection (spot lights, explicit cascades): its position and forward axis, and the
|
|
114
|
+
* inverse. Perspective: the centre is VP⁻¹ (0, 0, 1, 0) (clip w = 0 on the camera); orthographic: the near plane centre
|
|
115
|
+
* moved back by `near` along the forward axis. Forward: from the near plane centre to the far plane centre.
|
|
116
|
+
*/
|
|
117
|
+
export declare function vdbFrameShadowViewCamera(viewProjection: ArrayLike<number>, near: number, orthographic: boolean): {
|
|
118
|
+
inverse: Float64Array;
|
|
119
|
+
position: Vec3;
|
|
120
|
+
forward: Vec3;
|
|
121
|
+
};
|
|
122
|
+
/** Inputs of {@link vdbFrameShadowFitCascades}: the view camera, the light and the casters (the last grid cascade). */
|
|
123
|
+
export interface VDBFrameShadowFitInputs {
|
|
124
|
+
/** View → world of the camera (three's `camera.matrixWorld`). */
|
|
125
|
+
cameraWorld: ArrayLike<number>;
|
|
126
|
+
/** Clip → view of the camera (three's `camera.projectionMatrixInverse`). */
|
|
127
|
+
projectionInverse: ArrayLike<number>;
|
|
128
|
+
near: number;
|
|
129
|
+
far: number;
|
|
130
|
+
orthographic: boolean;
|
|
131
|
+
castShadowDistance: number;
|
|
132
|
+
/** Cascades (clamped to 1..4). */
|
|
133
|
+
count: number;
|
|
134
|
+
/** Map texels per side (the snap). */
|
|
135
|
+
size: number;
|
|
136
|
+
/** The way the light travels (normalized here). */
|
|
137
|
+
lightDirection: Vec3;
|
|
138
|
+
/** The box of all casters (the last grid cascade). */
|
|
139
|
+
casterBox: {
|
|
140
|
+
min: Vec3;
|
|
141
|
+
max: Vec3;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** One fitted cascade camera: its view-projection (WebGPU depth 0..1), position (the ray origin) and far plane. */
|
|
145
|
+
export interface VDBFrameShadowCascadeCamera {
|
|
146
|
+
viewProjection: Float64Array;
|
|
147
|
+
origin: Vec3;
|
|
148
|
+
far: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* His `fitCascades` (FrameVolumeShadows L692–778; three's CSMShadowNode method), engine-free: the practical split of
|
|
152
|
+
* the view depth up to {@link vdbFrameShadowCascadeFar}; per slice a light-aligned orthographic camera sized from the
|
|
153
|
+
* slice diagonal, its centre snapped to texels, its depth range over the slice and the casters (± 1). Returns the
|
|
154
|
+
* cascades, the breaks (padded to 4 with the last ones, as his `cascadeBreaks`) and the light's forward axis.
|
|
155
|
+
*/
|
|
156
|
+
export declare function vdbFrameShadowFitCascades(o: VDBFrameShadowFitInputs): {
|
|
157
|
+
count: number;
|
|
158
|
+
breaks: [number, number, number, number];
|
|
159
|
+
forward: Vec3;
|
|
160
|
+
cascades: VDBFrameShadowCascadeCamera[];
|
|
161
|
+
};
|
|
162
|
+
/** The drawn view of a core volume shadow map, as `VdbVolumeShadowView` holds it (core/frame/wgsl/shadows.ts). */
|
|
163
|
+
export interface VDBFrameVolumeShadowViewCpu {
|
|
164
|
+
/** 0: directional cascades, 1: spot, 2: point (cube). */
|
|
165
|
+
kind: number;
|
|
166
|
+
/** One per layer (cascades); spot: [0]. */
|
|
167
|
+
viewProjection: readonly ArrayLike<number>[];
|
|
168
|
+
/** Ray origin per layer (cascades) or [0]. */
|
|
169
|
+
origin: readonly Vec3[];
|
|
170
|
+
/** Far plane per layer (map depths ÷ far). */
|
|
171
|
+
far: readonly number[];
|
|
172
|
+
forward: Vec3;
|
|
173
|
+
perspective: boolean;
|
|
174
|
+
breaks: readonly number[];
|
|
175
|
+
cascadeCount: number;
|
|
176
|
+
size: number;
|
|
177
|
+
enabled: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The core receiver (`vdbVolumeShadow` / `vdbVolumeShadowCube`), CPU: picks the layer and uv from the drawn view
|
|
181
|
+
* (cascade by view depth, spot by the drawn view-projection, point by the cube face of the direction from the drawn
|
|
182
|
+
* light position), reads the map with `sample(layer, s, t)` (filtered; s, t in [0, 1], t down the rows) and applies
|
|
183
|
+
* {@link vdbFrameShadowReceiver}. 1 outside the map or when disabled.
|
|
184
|
+
*/
|
|
185
|
+
export declare function vdbFrameVolumeShadowLookup(view: VDBFrameVolumeShadowViewCpu, world: Vec3, viewDepth: number, sample: (layer: number, s: number, t: number) => Vec4): number;
|
|
186
|
+
/**
|
|
187
|
+
* K6.4: the spectral receivers (`vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb`): each channel's transmittance from the
|
|
188
|
+
* map's rgb twin (`sampleRgb`, the same layer and uv), along the grey texel's first-to-last span.
|
|
189
|
+
*/
|
|
190
|
+
export declare function vdbFrameVolumeShadowLookupRgb(view: VDBFrameVolumeShadowViewCpu, world: Vec3, viewDepth: number, sample: (layer: number, s: number, t: number) => Vec4, sampleRgb: (layer: number, s: number, t: number) => Vec4): Vec3;
|
|
@@ -164,6 +164,15 @@ export function vdbFrameShadowCascadeIndex(viewDepth, breaks, count) {
|
|
|
164
164
|
index++;
|
|
165
165
|
return index;
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* The spot map uv of a receiver (FrameVolumeShadowNode, his 62a6e3e): `clip` is its clip position in the camera that
|
|
169
|
+
* drew the map (the drawn view-projection, not three's current shadow matrix), with three's ShadowNode y flip.
|
|
170
|
+
* Outside when behind that camera (w ≤ 0) or off the map.
|
|
171
|
+
*/
|
|
172
|
+
export function vdbFrameShadowSpotUv(clip) {
|
|
173
|
+
const uv = [(clip[0] / clip[3]) * 0.5 + 0.5, 0.5 - (clip[1] / clip[3]) * 0.5];
|
|
174
|
+
return { uv, inside: clip[3] > 0 && uv[0] >= 0 && uv[0] <= 1 && uv[1] >= 0 && uv[1] <= 1 };
|
|
175
|
+
}
|
|
167
176
|
/**
|
|
168
177
|
* The atlas uv of a receiver in cascade `index` (getCascadeLookup L266–282): `clip` is its clip position in the
|
|
169
178
|
* cascade camera (x, y after the divide; orthographic, so w = 1). Half a texel in from each tile side. `inside`
|
|
@@ -179,4 +188,281 @@ export function vdbFrameShadowCascadeUv(clip, index, size) {
|
|
|
179
188
|
insideTile: tileUv[0] >= 0 && tileUv[0] <= 1 && tileUv[1] >= 0 && tileUv[1] <= 1,
|
|
180
189
|
};
|
|
181
190
|
}
|
|
191
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
192
|
+
// K6.5: twins of the core volume shadow kernels (core/frame/wgsl/shadows.ts). The core draws each map texel from the
|
|
193
|
+
// inverse view-projection of the camera that drew it (spot, cascades) or from the cube face table (point); receivers
|
|
194
|
+
// read the map with that drawn view. Plain arrays, column-major.
|
|
195
|
+
/** Column-major 4×4 × (x, y, z, w). */
|
|
196
|
+
function apply4(m, x, y, z, w) {
|
|
197
|
+
return [m[0] * x + m[4] * y + m[8] * z + m[12] * w, m[1] * x + m[5] * y + m[9] * z + m[13] * w, m[2] * x + m[6] * y + m[10] * z + m[14] * w, m[3] * x + m[7] * y + m[11] * z + m[15] * w];
|
|
198
|
+
}
|
|
199
|
+
const normalize3 = (v) => {
|
|
200
|
+
const l = len(v);
|
|
201
|
+
return [v[0] / l, v[1] / l, v[2] / l];
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* The map ray of one texel from the drawing camera's inverse view-projection (the core's `vdbFrameVolumeShadowCs`;
|
|
205
|
+
* the same construction as {@link vdbFrameShadowPassRay}: two unprojected points at NDC depth 0.25 and 0.75 give the
|
|
206
|
+
* direction; perspective rays start at the camera, orthographic ones on the camera plane). `ndc`: the texel centre,
|
|
207
|
+
* x right, y up (texel row r ↔ ndc.y = 1 − 2 (r + ½) / size).
|
|
208
|
+
*/
|
|
209
|
+
export function vdbFrameShadowMapRay(inverseViewProjection, cameraPosition, perspective, ndc) {
|
|
210
|
+
const unproject = (z) => {
|
|
211
|
+
const p = apply4(inverseViewProjection, ndc[0], ndc[1], z, 1);
|
|
212
|
+
return [p[0] / p[3], p[1] / p[3], p[2] / p[3]];
|
|
213
|
+
};
|
|
214
|
+
const near = unproject(0.25);
|
|
215
|
+
const direction = normalize3(sub(unproject(0.75), near));
|
|
216
|
+
if (perspective)
|
|
217
|
+
return { origin: [...cameraPosition], direction };
|
|
218
|
+
const along = dot(sub(near, cameraPosition), direction);
|
|
219
|
+
return { origin: [near[0] - direction[0] * along, near[1] - direction[1] * along, near[2] - direction[2] * along], direction };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The (unnormalized) direction of a cube map texel: face 0–5 (+x, −x, +y, −y, +z, −z), `a`, `b` in [−1, 1] the
|
|
223
|
+
* face coordinates (s, t) × 2 − 1 with t down the rows. WebGPU's cube face selection (the Vulkan table): a cube view
|
|
224
|
+
* sampled with this direction reads this texel.
|
|
225
|
+
*/
|
|
226
|
+
export function vdbFrameCubeFaceDirection(face, a, b) {
|
|
227
|
+
switch (face) {
|
|
228
|
+
case 0:
|
|
229
|
+
return [1, -b, -a];
|
|
230
|
+
case 1:
|
|
231
|
+
return [-1, -b, a];
|
|
232
|
+
case 2:
|
|
233
|
+
return [a, 1, b];
|
|
234
|
+
case 3:
|
|
235
|
+
return [a, -1, -b];
|
|
236
|
+
case 4:
|
|
237
|
+
return [a, -b, 1];
|
|
238
|
+
default:
|
|
239
|
+
return [-a, -b, -1];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** The inverse of {@link vdbFrameCubeFaceDirection}: the face and its (s, t) in [0, 1] (t down the rows) of a direction. */
|
|
243
|
+
export function vdbFrameCubeFaceUv(d) {
|
|
244
|
+
const ax = Math.abs(d[0]);
|
|
245
|
+
const ay = Math.abs(d[1]);
|
|
246
|
+
const az = Math.abs(d[2]);
|
|
247
|
+
let face;
|
|
248
|
+
let sc;
|
|
249
|
+
let tc;
|
|
250
|
+
let ma;
|
|
251
|
+
if (ax >= ay && ax >= az) {
|
|
252
|
+
ma = ax;
|
|
253
|
+
face = d[0] >= 0 ? 0 : 1;
|
|
254
|
+
sc = d[0] >= 0 ? -d[2] : d[2];
|
|
255
|
+
tc = -d[1];
|
|
256
|
+
}
|
|
257
|
+
else if (ay >= az) {
|
|
258
|
+
ma = ay;
|
|
259
|
+
face = d[1] >= 0 ? 2 : 3;
|
|
260
|
+
sc = d[0];
|
|
261
|
+
tc = d[1] >= 0 ? d[2] : -d[2];
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
ma = az;
|
|
265
|
+
face = d[2] >= 0 ? 4 : 5;
|
|
266
|
+
sc = d[2] >= 0 ? d[0] : -d[0];
|
|
267
|
+
tc = -d[1];
|
|
268
|
+
}
|
|
269
|
+
return { face, s: (sc / ma + 1) / 2, t: (tc / ma + 1) / 2 };
|
|
270
|
+
}
|
|
271
|
+
/** General 4×4 inverse (f64; column-major). */
|
|
272
|
+
function invert4(m) {
|
|
273
|
+
const [a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33] = Array.from({ length: 16 }, (_, i) => m[i]);
|
|
274
|
+
const b00 = a00 * a11 - a01 * a10;
|
|
275
|
+
const b01 = a00 * a12 - a02 * a10;
|
|
276
|
+
const b02 = a00 * a13 - a03 * a10;
|
|
277
|
+
const b03 = a01 * a12 - a02 * a11;
|
|
278
|
+
const b04 = a01 * a13 - a03 * a11;
|
|
279
|
+
const b05 = a02 * a13 - a03 * a12;
|
|
280
|
+
const b06 = a20 * a31 - a21 * a30;
|
|
281
|
+
const b07 = a20 * a32 - a22 * a30;
|
|
282
|
+
const b08 = a20 * a33 - a23 * a30;
|
|
283
|
+
const b09 = a21 * a32 - a22 * a31;
|
|
284
|
+
const b10 = a21 * a33 - a23 * a31;
|
|
285
|
+
const b11 = a22 * a33 - a23 * a32;
|
|
286
|
+
const det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
287
|
+
const inv = det !== 0 ? 1 / det : 0;
|
|
288
|
+
return Float64Array.from([
|
|
289
|
+
(a11 * b11 - a12 * b10 + a13 * b09) * inv,
|
|
290
|
+
(a02 * b10 - a01 * b11 - a03 * b09) * inv,
|
|
291
|
+
(a31 * b05 - a32 * b04 + a33 * b03) * inv,
|
|
292
|
+
(a22 * b04 - a21 * b05 - a23 * b03) * inv,
|
|
293
|
+
(a12 * b08 - a10 * b11 - a13 * b07) * inv,
|
|
294
|
+
(a00 * b11 - a02 * b08 + a03 * b07) * inv,
|
|
295
|
+
(a32 * b02 - a30 * b05 - a33 * b01) * inv,
|
|
296
|
+
(a20 * b05 - a22 * b02 + a23 * b01) * inv,
|
|
297
|
+
(a10 * b10 - a11 * b08 + a13 * b06) * inv,
|
|
298
|
+
(a01 * b08 - a00 * b10 - a03 * b06) * inv,
|
|
299
|
+
(a30 * b04 - a31 * b02 + a33 * b00) * inv,
|
|
300
|
+
(a21 * b02 - a20 * b04 - a23 * b00) * inv,
|
|
301
|
+
(a11 * b07 - a10 * b09 - a12 * b06) * inv,
|
|
302
|
+
(a00 * b09 - a01 * b07 + a02 * b06) * inv,
|
|
303
|
+
(a31 * b01 - a30 * b03 - a32 * b00) * inv,
|
|
304
|
+
(a20 * b03 - a21 * b01 + a22 * b00) * inv,
|
|
305
|
+
]);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* The drawing camera of a view-projection (spot lights, explicit cascades): its position and forward axis, and the
|
|
309
|
+
* inverse. Perspective: the centre is VP⁻¹ (0, 0, 1, 0) (clip w = 0 on the camera); orthographic: the near plane centre
|
|
310
|
+
* moved back by `near` along the forward axis. Forward: from the near plane centre to the far plane centre.
|
|
311
|
+
*/
|
|
312
|
+
export function vdbFrameShadowViewCamera(viewProjection, near, orthographic) {
|
|
313
|
+
const inverse = invert4(viewProjection);
|
|
314
|
+
const at = (x, y, z, w) => {
|
|
315
|
+
const p = apply4(inverse, x, y, z, w);
|
|
316
|
+
return [p[0] / p[3], p[1] / p[3], p[2] / p[3]];
|
|
317
|
+
};
|
|
318
|
+
const nearCenter = at(0, 0, 0, 1);
|
|
319
|
+
const forward = normalize3(sub(at(0, 0, 1, 1), nearCenter));
|
|
320
|
+
const position = orthographic ? [nearCenter[0] - forward[0] * near, nearCenter[1] - forward[1] * near, nearCenter[2] - forward[2] * near] : at(0, 0, 1, 0);
|
|
321
|
+
return { inverse, position, forward };
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* His `fitCascades` (FrameVolumeShadows L692–778; three's CSMShadowNode method), engine-free: the practical split of
|
|
325
|
+
* the view depth up to {@link vdbFrameShadowCascadeFar}; per slice a light-aligned orthographic camera sized from the
|
|
326
|
+
* slice diagonal, its centre snapped to texels, its depth range over the slice and the casters (± 1). Returns the
|
|
327
|
+
* cascades, the breaks (padded to 4 with the last ones, as his `cascadeBreaks`) and the light's forward axis.
|
|
328
|
+
*/
|
|
329
|
+
export function vdbFrameShadowFitCascades(o) {
|
|
330
|
+
const count = Math.min(frameMaxShadowMapCascades, Math.max(1, Math.round(o.count)));
|
|
331
|
+
const view = invert4(o.cameraWorld);
|
|
332
|
+
const box = o.casterBox;
|
|
333
|
+
let boxFar = 0;
|
|
334
|
+
for (let i = 0; i < 8; i++) {
|
|
335
|
+
const p = apply4(view, i & 1 ? box.max[0] : box.min[0], i & 2 ? box.max[1] : box.min[1], i & 4 ? box.max[2] : box.min[2], 1);
|
|
336
|
+
boxFar = Math.max(boxFar, -p[2]);
|
|
337
|
+
}
|
|
338
|
+
const far = vdbFrameShadowCascadeFar(o.near, o.far, o.castShadowDistance, boxFar, len(sub(box.max, box.min)));
|
|
339
|
+
const breaks = vdbFrameShadowCascadeBreaks(count, o.near, far);
|
|
340
|
+
// Light view: three's Matrix4.lookAt(origin, lightDirection, up): z = −direction, x = up × z, y = z × x
|
|
341
|
+
const direction = normalize3(o.lightDirection);
|
|
342
|
+
const up = Math.abs(direction[1]) > 0.999 ? [0, 0, 1] : [0, 1, 0];
|
|
343
|
+
const zAxis = [-direction[0], -direction[1], -direction[2]];
|
|
344
|
+
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
345
|
+
const xAxis = normalize3(cross(up, zAxis));
|
|
346
|
+
const yAxis = cross(zAxis, xAxis);
|
|
347
|
+
// world → light (the transpose of the rotation) and back
|
|
348
|
+
const toLight = (p) => [dot(p, xAxis), dot(p, yAxis), dot(p, zAxis)];
|
|
349
|
+
const fromLight = (p) => [xAxis[0] * p[0] + yAxis[0] * p[1] + zAxis[0] * p[2], xAxis[1] * p[0] + yAxis[1] * p[1] + zAxis[1] * p[2], xAxis[2] * p[0] + yAxis[2] * p[1] + zAxis[2] * p[2]];
|
|
350
|
+
const bounds = (points) => {
|
|
351
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
352
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
353
|
+
for (const q of points) {
|
|
354
|
+
const p = toLight(q);
|
|
355
|
+
for (let k = 0; k < 3; k++) {
|
|
356
|
+
lo[k] = Math.min(lo[k], p[k]);
|
|
357
|
+
hi[k] = Math.max(hi[k], p[k]);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return { lo, hi };
|
|
361
|
+
};
|
|
362
|
+
const caster = bounds(Array.from({ length: 8 }, (_, i) => [i & 1 ? box.max[0] : box.min[0], i & 2 ? box.max[1] : box.min[1], i & 4 ? box.max[2] : box.min[2]]));
|
|
363
|
+
// getSliceCorners: corners of the view at a depth, in world space (corners 0 and 2 are diagonal)
|
|
364
|
+
const corners = (depth) => [
|
|
365
|
+
[-1, -1],
|
|
366
|
+
[1, -1],
|
|
367
|
+
[1, 1],
|
|
368
|
+
[-1, 1],
|
|
369
|
+
].map(([x, y]) => {
|
|
370
|
+
const q = apply4(o.projectionInverse, x, y, 0.5, 1);
|
|
371
|
+
let p = [q[0] / q[3], q[1] / q[3], q[2] / q[3]];
|
|
372
|
+
if (!o.orthographic) {
|
|
373
|
+
const s = depth / -p[2];
|
|
374
|
+
p = [p[0] * s, p[1] * s, p[2] * s];
|
|
375
|
+
}
|
|
376
|
+
else
|
|
377
|
+
p = [p[0], p[1], -depth];
|
|
378
|
+
const w = apply4(o.cameraWorld, p[0], p[1], p[2], 1);
|
|
379
|
+
return [w[0], w[1], w[2]];
|
|
380
|
+
});
|
|
381
|
+
const cascades = [];
|
|
382
|
+
for (let i = 0; i < count; i++) {
|
|
383
|
+
const nearCorners = corners(i === 0 ? o.near : breaks[i - 1]);
|
|
384
|
+
const farCorners = corners(breaks[i]);
|
|
385
|
+
const width = Math.max(len(sub(farCorners[0], farCorners[2])), len(sub(farCorners[0], nearCorners[2])));
|
|
386
|
+
const texel = width / o.size;
|
|
387
|
+
const slice = bounds([...nearCorners, ...farCorners]);
|
|
388
|
+
const centerX = Math.floor((slice.lo[0] + slice.hi[0]) * 0.5 / texel) * texel;
|
|
389
|
+
const centerY = Math.floor((slice.lo[1] + slice.hi[1]) * 0.5 / texel) * texel;
|
|
390
|
+
const front = Math.max(slice.hi[2], caster.hi[2]) + frameShadowCascadeMargin;
|
|
391
|
+
const back = Math.min(slice.lo[2], caster.lo[2]) - frameShadowCascadeMargin;
|
|
392
|
+
const depth = front - back;
|
|
393
|
+
const position = fromLight([centerX, centerY, front]);
|
|
394
|
+
// camera world = [R | position]; its inverse: [Rᵀ | −Rᵀ position]
|
|
395
|
+
const viewMatrix = [xAxis[0], yAxis[0], zAxis[0], 0, xAxis[1], yAxis[1], zAxis[1], 0, xAxis[2], yAxis[2], zAxis[2], 0, -dot(xAxis, position), -dot(yAxis, position), -dot(zAxis, position), 1];
|
|
396
|
+
// three's makeOrthographic (WebGPU: depth 0..1): left/right/top/bottom ±width/2, near 0, far = depth
|
|
397
|
+
const sx = 2 / width;
|
|
398
|
+
const projection = [sx, 0, 0, 0, 0, sx, 0, 0, 0, 0, -1 / depth, 0, 0, 0, 0, 1];
|
|
399
|
+
const vp = new Float64Array(16);
|
|
400
|
+
for (let col = 0; col < 4; col++)
|
|
401
|
+
for (let row = 0; row < 4; row++) {
|
|
402
|
+
let s = 0;
|
|
403
|
+
for (let k = 0; k < 4; k++)
|
|
404
|
+
s += projection[k * 4 + row] * viewMatrix[col * 4 + k];
|
|
405
|
+
vp[col * 4 + row] = s;
|
|
406
|
+
}
|
|
407
|
+
cascades.push({ viewProjection: vp, origin: position, far: depth });
|
|
408
|
+
}
|
|
409
|
+
return {
|
|
410
|
+
count,
|
|
411
|
+
breaks: [breaks[Math.min(0, count - 1)], breaks[Math.min(1, count - 1)], breaks[Math.min(2, count - 1)], breaks[Math.min(3, count - 1)]],
|
|
412
|
+
forward: direction,
|
|
413
|
+
cascades,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* The core receiver (`vdbVolumeShadow` / `vdbVolumeShadowCube`), CPU: picks the layer and uv from the drawn view
|
|
418
|
+
* (cascade by view depth, spot by the drawn view-projection, point by the cube face of the direction from the drawn
|
|
419
|
+
* light position), reads the map with `sample(layer, s, t)` (filtered; s, t in [0, 1], t down the rows) and applies
|
|
420
|
+
* {@link vdbFrameShadowReceiver}. 1 outside the map or when disabled.
|
|
421
|
+
*/
|
|
422
|
+
export function vdbFrameVolumeShadowLookup(view, world, viewDepth, sample) {
|
|
423
|
+
return vdbFrameVolumeShadowLookupWith(view, world, viewDepth, sample, null);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* K6.4: the spectral receivers (`vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb`): each channel's transmittance from the
|
|
427
|
+
* map's rgb twin (`sampleRgb`, the same layer and uv), along the grey texel's first-to-last span.
|
|
428
|
+
*/
|
|
429
|
+
export function vdbFrameVolumeShadowLookupRgb(view, world, viewDepth, sample, sampleRgb) {
|
|
430
|
+
return vdbFrameVolumeShadowLookupWith(view, world, viewDepth, sample, sampleRgb);
|
|
431
|
+
}
|
|
432
|
+
function vdbFrameVolumeShadowLookupWith(view, world, viewDepth, sample, sampleRgb) {
|
|
433
|
+
const none = sampleRgb ? [1, 1, 1] : 1;
|
|
434
|
+
const rgbAt = (layer, s, t) => {
|
|
435
|
+
if (!sampleRgb)
|
|
436
|
+
return null;
|
|
437
|
+
const v = sampleRgb(layer, s, t);
|
|
438
|
+
return [v[0], v[1], v[2]];
|
|
439
|
+
};
|
|
440
|
+
if (!view.enabled)
|
|
441
|
+
return none;
|
|
442
|
+
if (view.kind === 2) {
|
|
443
|
+
const offset = sub(world, view.origin[0]);
|
|
444
|
+
const f = vdbFrameCubeFaceUv(offset);
|
|
445
|
+
return vdbFrameShadowReceiver(sample(f.face, f.s, f.t), len(offset), view.far[0], rgbAt(f.face, f.s, f.t));
|
|
446
|
+
}
|
|
447
|
+
let layer = 0;
|
|
448
|
+
let uv;
|
|
449
|
+
if (view.kind === 0) {
|
|
450
|
+
layer = vdbFrameShadowCascadeIndex(viewDepth, view.breaks, view.cascadeCount);
|
|
451
|
+
const clip = mul4(view.viewProjection[layer], [world[0], world[1], world[2], 1]);
|
|
452
|
+
const tile = [clip[0] * 0.5 + 0.5, 0.5 - clip[1] * 0.5];
|
|
453
|
+
const lastBreak = view.breaks[Math.max(0, Math.min(3, view.cascadeCount - 1))];
|
|
454
|
+
if (!(viewDepth <= lastBreak && tile[0] >= 0 && tile[0] <= 1 && tile[1] >= 0 && tile[1] <= 1))
|
|
455
|
+
return none;
|
|
456
|
+
const inset = 0.5 / view.size;
|
|
457
|
+
uv = [clamp(tile[0], inset, 1 - inset), clamp(tile[1], inset, 1 - inset)];
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
const spot = vdbFrameShadowSpotUv(mul4(view.viewProjection[0], [world[0], world[1], world[2], 1]));
|
|
461
|
+
if (!spot.inside)
|
|
462
|
+
return none;
|
|
463
|
+
uv = spot.uv;
|
|
464
|
+
}
|
|
465
|
+
const depth = vdbFrameShadowDepth({ origin: view.origin[layer], forward: view.forward, perspective: view.perspective ? 1 : 0 }, world);
|
|
466
|
+
return vdbFrameShadowReceiver(sample(layer, uv[0], uv[1]), depth, view.far[layer], rgbAt(layer, uv[0], uv[1]));
|
|
467
|
+
}
|
|
182
468
|
//# sourceMappingURL=shadows.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadows.js","sourceRoot":"","sources":["../../../src/tools/frame/shadows.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0GAA0G;AAC1G,8GAA8G;AAC9G,iGAAiG;AACjG,2DAA2D;AAC3D,4GAA4G;AAC5G,sGAAsG;AACtG,4EAA4E;AAU5E,wEAAwE;AACxE,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAC/C,gGAAgG;AAChG,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,oEAAoE;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,sGAAsG;AACtG,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,yGAAyG;AACzG,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,qFAAqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAYxC,MAAM,GAAG,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,CAAC,C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CAAC,GAAG,KAAK,CAAC,CAAC;IAC7C,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,yBAAyB,EAAE,CAAC,CAAC;QAChD,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;KACjF,CAAC;AACJ,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L42–53 (constants), L130–143 (getCascadeBreaks),\n// L248–290 (getCascadeLookup), L344–372 (the receiver transmittance), L704–731 (the cascade far distance of\n// fitCascades); src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–48 (constants,\n// frameShadowDepth), L90–172 (the Beer shadow map pass).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free TypeScript CPU twins (f64) of his mesh-shadow maths; matrices are column-major\n// arrays (three's `elements`). Divergences: none (twins of the ported TSL).\n\n/**\n * K3.6: CPU twins of the volume shadows on meshes (his `FrameVolumeShadows` / `FrameVolumeShadowMaterial`):\n * the Beer shadow map pass (one texel: a light ray marched through the last grid cascade), the receiver\n * lookup (transmittance at a mesh point from the map), the directional-light cascade split and its lookup.\n */\n\nimport type { Vec2, Vec3, Vec4 } from \"./index.js\";\n\n/** Optical depth below this casts no shadow (his `minOpticalDepth`). */\nexport const frameShadowMinOpticalDepth = 1e-4;\n/** The march stops past this optical depth (transmittance below e⁻⁸; his `maxOpticalDepth`). */\nexport const frameShadowMaxOpticalDepth = 8.0;\n/** Upper limit of `castShadowSteps` (his `frameMaxShadowSteps`). */\nexport const frameMaxCastShadowSteps = 256;\n/** Directional lights: cascades of the view, tiles of one atlas (his `frameMaxShadowMapCascades`). */\nexport const frameMaxShadowMapCascades = 4;\n/** Distance in front of the cascade bounds and the volume box, along the light (his `cascadeMargin`). */\nexport const frameShadowCascadeMargin = 1.0;\n/** `castShadowCoarse`: map size and samples (his `coarseMapSize`, `coarseSteps`). */\nexport const frameShadowCoarseMapSize = 64;\nexport const frameShadowCoarseSteps = 8;\n\n/** The ray uniforms of one shadow camera (his `createShadowRayUniforms`). */\nexport interface VDBFrameShadowRay {\n origin: Vec3;\n forward: Vec3;\n /** 1: depth is the distance from the origin (perspective). 0: along `forward` (orthographic). */\n perspective: number;\n /** Far plane of the shadow camera; map depths are divided by it. */\n far: number;\n}\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];\nconst dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\nconst len = (a: Vec3): number => Math.sqrt(dot(a, a));\nconst clamp = (v: number, lo: number, hi: number): number => Math.min(hi, Math.max(lo, v));\n\n/** frameShadowDepth: depth of a world point for a shadow camera (distance, or along the forward axis). */\nexport function vdbFrameShadowDepth(ray: Pick<VDBFrameShadowRay, \"origin\" | \"forward\" | \"perspective\">, world: Vec3): number {\n const offset = sub(world, ray.origin);\n return ray.perspective === 1 ? len(offset) : dot(offset, ray.forward);\n}\n\n/** Column-major 4×4 times (x, y, z, w). */\nfunction mul4(m: ArrayLike<number>, v: Vec4): Vec4 {\n const out: Vec4 = [0, 0, 0, 0];\n for (let r = 0; r < 4; r++) out[r] = m[r]! * v[0] + m[4 + r]! * v[1] + m[8 + r]! * v[2] + m[12 + r]! * v[3];\n return out;\n}\n\n/**\n * The pass ray of one map texel (FrameVolumeShadowMaterial L90–109): two unprojected points of the pixel ray at\n * NDC depth 0.25 and 0.75 give the direction; perspective rays start at the camera, orthographic ones on the camera\n * plane. `ndc` is the pixel centre in [−1, 1]² (y up); matrices are the shadow camera's, column-major.\n */\nexport function vdbFrameShadowPassRay(projection: ArrayLike<number>, projectionInverse: ArrayLike<number>, cameraWorld: ArrayLike<number>, ndc: Vec2): { origin: Vec3; direction: Vec3 } {\n const unproject = (z: number): Vec3 => {\n const view = mul4(projectionInverse, [ndc[0], ndc[1], z, 1]);\n const world = mul4(cameraWorld, [view[0] / view[3], view[1] / view[3], view[2] / view[3], 1]);\n return [world[0], world[1], world[2]];\n };\n const near = unproject(0.25);\n const far = unproject(0.75);\n const d = sub(far, near);\n const l = len(d);\n const direction: Vec3 = [d[0] / l, d[1] / l, d[2] / l];\n const cameraPosition: Vec3 = [cameraWorld[12]!, cameraWorld[13]!, cameraWorld[14]!];\n const perspective = projection[15]! < 0.5;\n if (perspective) return { origin: cameraPosition, direction };\n const along = dot(sub(near, cameraPosition), direction);\n return { origin: [near[0] - direction[0] * along, near[1] - direction[1] * along, near[2] - direction[2] * along], direction };\n}\n\n/**\n * One texel of the Beer shadow map (FrameVolumeShadowMaterial L111–172): `steps` samples of the light ray through\n * `box` (the last grid cascade), each at the middle of its step; the march stops past optical depth 8. Returns\n * (τ·first, τ·last, 0, τ) with first / last the depths (÷ `ray.far`) of the first and last non-empty steps; empty\n * texels are 0. `extinctionAt` is the grid extinction (red channel of the shadow density grid) at a world point.\n * Spectral (`extinctionAt` returns rgb): output 0 is (τ̄·first, τ̄·last, 0, τ̄) with τ̄ the channel mean, output 1\n * is (τ rgb, 0).\n */\nexport function vdbFrameShadowMapTexel(\n extinctionAt: (world: Vec3) => number | Vec3,\n origin: Vec3,\n direction: Vec3,\n box: { min: Vec3; max: Vec3 } | null,\n steps: number,\n ray: VDBFrameShadowRay,\n spectral = false,\n): { map: Vec4; spectral: Vec4 | null } {\n const depth: Vec3 = [0, 0, 0];\n const total = () => (spectral ? Math.min(depth[0], depth[1], depth[2]) : depth[0]);\n let first = 0;\n let last = 0;\n if (box) {\n const tMin: number[] = [];\n const tMax: number[] = [];\n for (let c = 0; c < 3; c++) {\n const inv = 1 / direction[c]!;\n const a = (box.min[c]! - origin[c]!) * inv;\n const b = (box.max[c]! - origin[c]!) * inv;\n tMin.push(Math.min(a, b));\n tMax.push(Math.max(a, b));\n }\n const tStart = Math.max(0, Math.max(tMin[0]!, Math.max(tMin[1]!, tMin[2]!)));\n const tEnd = Math.min(tMax[0]!, Math.min(tMax[1]!, tMax[2]!));\n if (tEnd > tStart) {\n const n = Math.max(steps, 1);\n const stepLength = (tEnd - tStart) / n;\n let firstT = -1;\n let lastT = -1;\n for (let i = 0; i < n; i++) {\n if (total() > frameShadowMaxOpticalDepth) break;\n const t = tStart + i * stepLength;\n const s = t + stepLength * 0.5;\n const e = extinctionAt([origin[0] + direction[0] * s, origin[1] + direction[1] * s, origin[2] + direction[2] * s]);\n const ext: Vec3 = typeof e === \"number\" ? [e, e, e] : e;\n const any = spectral ? ext[0] + ext[1] + ext[2] : ext[0];\n if (any > 0) {\n if (firstT < 0) firstT = t;\n lastT = t + stepLength;\n for (let c = 0; c < 3; c++) depth[c] = depth[c]! + ext[c]! * stepLength;\n }\n }\n if ((spectral ? depth[0] + depth[1] + depth[2] : depth[0]) > 0) {\n const at = (t: number): Vec3 => [origin[0] + direction[0] * t, origin[1] + direction[1] * t, origin[2] + direction[2] * t];\n first = vdbFrameShadowDepth(ray, at(firstT)) / ray.far;\n last = vdbFrameShadowDepth(ray, at(lastT)) / ray.far;\n }\n }\n }\n if (spectral) {\n const mean = (depth[0] + depth[1] + depth[2]) / 3;\n return { map: [first * mean, last * mean, 0, mean], spectral: [depth[0], depth[1], depth[2], 0] };\n }\n return { map: [first * depth[0], last * depth[0], 0, depth[0]], spectral: null };\n}\n\n/**\n * The receiver transmittance (FrameVolumeShadows L344–372): the optical depth grows linearly from the first to the\n * last non-empty depth of the (filtered) texel. `depth` is the receiver's {@link vdbFrameShadowDepth}, `far` the\n * drawn shadow camera's far. `spectralTexel` (rgb optical depth): per-channel transmittance; with `mean`, their mean\n * (a `ShadowMaterial` receiver). Returns 1 for an empty texel.\n */\nexport function vdbFrameShadowReceiver(texel: Vec4, depth: number, far: number, spectralTexel: Vec3 | null = null, mean = false): number | Vec3 {\n const opticalDepth = texel[3];\n if (!(opticalDepth > frameShadowMinOpticalDepth)) return spectralTexel && !mean ? [1, 1, 1] : 1;\n const first = (texel[0] / opticalDepth) * far;\n const last = (texel[1] / opticalDepth) * far;\n const along = clamp((depth - first) / Math.max(last - first, 1e-4), 0, 1);\n if (spectralTexel) {\n const t: Vec3 = [Math.exp(-spectralTexel[0] * along), Math.exp(-spectralTexel[1] * along), Math.exp(-spectralTexel[2] * along)];\n return mean ? (t[0] + t[1] + t[2]) / 3 : t;\n }\n return Math.exp(-opticalDepth * along);\n}\n\n/** getCascadeBreaks: far distance of each cascade, the practical split of three's CSMShadowNode (λ = 0.5). */\nexport function vdbFrameShadowCascadeBreaks(count: number, near: number, far: number): number[] {\n const breaks: number[] = [];\n for (let i = 1; i <= count; i++) {\n const uniformSplit = near + ((far - near) * i) / count;\n const logSplit = near * Math.pow(far / near, i / count);\n breaks.push(i === count ? far : uniformSplit + (logSplit - uniformSplit) * 0.5);\n }\n return breaks;\n}\n\n/**\n * The view distance the cascades cover (fitCascades L714–730): the far corner of the volume box plus one box\n * diagonal, rounded up to half octaves (so the splits move only at those steps), within [near·1.0001,\n * min(camera far, castShadowDistance)]. `boxFar` is the largest view depth of the box's corners.\n */\nexport function vdbFrameShadowCascadeFar(near: number, cameraFar: number, castShadowDistance: number, boxFar: number, boxDiagonal: number): number {\n const sceneFar = Math.max(near * 2.0, boxFar + boxDiagonal);\n const steppedFar = Math.pow(2.0, Math.ceil(Math.log2(sceneFar) * 2.0) / 2.0);\n return Math.max(near * 1.0001, Math.min(cameraFar, castShadowDistance, steppedFar));\n}\n\n/** The cascade of a receiver (getCascadeLookup L253–261): the number of cascade far distances in front of it. */\nexport function vdbFrameShadowCascadeIndex(viewDepth: number, breaks: readonly number[], count: number): number {\n let index = 0;\n for (let i = 0; i < frameMaxShadowMapCascades - 1; i++) if (viewDepth > breaks[i]! && i + 1 < count) index++;\n return index;\n}\n\n/**\n * The atlas uv of a receiver in cascade `index` (getCascadeLookup L266–282): `clip` is its clip position in the\n * cascade camera (x, y after the divide; orthographic, so w = 1). Half a texel in from each tile side. `inside`\n * also needs the view depth within the last break (checked by the caller).\n */\nexport function vdbFrameShadowCascadeUv(clip: Vec2, index: number, size: number): { uv: Vec2; insideTile: boolean } {\n const tileUv: Vec2 = [clip[0] * 0.5 + 0.5, 0.5 - clip[1] * 0.5];\n const inset = 0.5 / size;\n const u = clamp(tileUv[0], inset, 1 - inset);\n const v = clamp(tileUv[1], inset, 1 - inset);\n return {\n uv: [(u + index) / frameMaxShadowMapCascades, v],\n insideTile: tileUv[0] >= 0 && tileUv[0] <= 1 && tileUv[1] >= 0 && tileUv[1] <= 1,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shadows.js","sourceRoot":"","sources":["../../../src/tools/frame/shadows.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0GAA0G;AAC1G,8GAA8G;AAC9G,iGAAiG;AACjG,2DAA2D;AAC3D,4GAA4G;AAC5G,sGAAsG;AACtG,4EAA4E;AAU5E,wEAAwE;AACxE,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAC/C,gGAAgG;AAChG,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,oEAAoE;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,sGAAsG;AACtG,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,yGAAyG;AACzG,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,qFAAqF;AACrF,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAYxC,MAAM,GAAG,GAAG,CAAC,CAAO,EAAE,CAAO,EAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,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CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACpG,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC9B,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACxI,OAAO,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAE,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClH,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L42–53 (constants), L130–143 (getCascadeBreaks),\n// L248–290 (getCascadeLookup), L344–372 (the receiver transmittance), L704–731 (the cascade far distance of\n// fitCascades); src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–48 (constants,\n// frameShadowDepth), L90–172 (the Beer shadow map pass).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: engine-free TypeScript CPU twins (f64) of his mesh-shadow maths; matrices are column-major\n// arrays (three's `elements`). Divergences: none (twins of the ported TSL).\n\n/**\n * K3.6: CPU twins of the volume shadows on meshes (his `FrameVolumeShadows` / `FrameVolumeShadowMaterial`):\n * the Beer shadow map pass (one texel: a light ray marched through the last grid cascade), the receiver\n * lookup (transmittance at a mesh point from the map), the directional-light cascade split and its lookup.\n */\n\nimport type { Vec2, Vec3, Vec4 } from \"./index.js\";\n\n/** Optical depth below this casts no shadow (his `minOpticalDepth`). */\nexport const frameShadowMinOpticalDepth = 1e-4;\n/** The march stops past this optical depth (transmittance below e⁻⁸; his `maxOpticalDepth`). */\nexport const frameShadowMaxOpticalDepth = 8.0;\n/** Upper limit of `castShadowSteps` (his `frameMaxShadowSteps`). */\nexport const frameMaxCastShadowSteps = 256;\n/** Directional lights: cascades of the view, tiles of one atlas (his `frameMaxShadowMapCascades`). */\nexport const frameMaxShadowMapCascades = 4;\n/** Distance in front of the cascade bounds and the volume box, along the light (his `cascadeMargin`). */\nexport const frameShadowCascadeMargin = 1.0;\n/** `castShadowCoarse`: map size and samples (his `coarseMapSize`, `coarseSteps`). */\nexport const frameShadowCoarseMapSize = 64;\nexport const frameShadowCoarseSteps = 8;\n\n/** The ray uniforms of one shadow camera (his `createShadowRayUniforms`). */\nexport interface VDBFrameShadowRay {\n origin: Vec3;\n forward: Vec3;\n /** 1: depth is the distance from the origin (perspective). 0: along `forward` (orthographic). */\n perspective: number;\n /** Far plane of the shadow camera; map depths are divided by it. */\n far: number;\n}\n\nconst sub = (a: Vec3, b: Vec3): Vec3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];\nconst dot = (a: Vec3, b: Vec3): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\nconst len = (a: Vec3): number => Math.sqrt(dot(a, a));\nconst clamp = (v: number, lo: number, hi: number): number => Math.min(hi, Math.max(lo, v));\n\n/** frameShadowDepth: depth of a world point for a shadow camera (distance, or along the forward axis). */\nexport function vdbFrameShadowDepth(ray: Pick<VDBFrameShadowRay, \"origin\" | \"forward\" | \"perspective\">, world: Vec3): number {\n const offset = sub(world, ray.origin);\n return ray.perspective === 1 ? len(offset) : dot(offset, ray.forward);\n}\n\n/** Column-major 4×4 times (x, y, z, w). */\nfunction mul4(m: ArrayLike<number>, v: Vec4): Vec4 {\n const out: Vec4 = [0, 0, 0, 0];\n for (let r = 0; r < 4; r++) out[r] = m[r]! * v[0] + m[4 + r]! * v[1] + m[8 + r]! * v[2] + m[12 + r]! * v[3];\n return out;\n}\n\n/**\n * The pass ray of one map texel (FrameVolumeShadowMaterial L90–109): two unprojected points of the pixel ray at\n * NDC depth 0.25 and 0.75 give the direction; perspective rays start at the camera, orthographic ones on the camera\n * plane. `ndc` is the pixel centre in [−1, 1]² (y up); matrices are the shadow camera's, column-major.\n */\nexport function vdbFrameShadowPassRay(projection: ArrayLike<number>, projectionInverse: ArrayLike<number>, cameraWorld: ArrayLike<number>, ndc: Vec2): { origin: Vec3; direction: Vec3 } {\n const unproject = (z: number): Vec3 => {\n const view = mul4(projectionInverse, [ndc[0], ndc[1], z, 1]);\n const world = mul4(cameraWorld, [view[0] / view[3], view[1] / view[3], view[2] / view[3], 1]);\n return [world[0], world[1], world[2]];\n };\n const near = unproject(0.25);\n const far = unproject(0.75);\n const d = sub(far, near);\n const l = len(d);\n const direction: Vec3 = [d[0] / l, d[1] / l, d[2] / l];\n const cameraPosition: Vec3 = [cameraWorld[12]!, cameraWorld[13]!, cameraWorld[14]!];\n const perspective = projection[15]! < 0.5;\n if (perspective) return { origin: cameraPosition, direction };\n const along = dot(sub(near, cameraPosition), direction);\n return { origin: [near[0] - direction[0] * along, near[1] - direction[1] * along, near[2] - direction[2] * along], direction };\n}\n\n/**\n * One texel of the Beer shadow map (FrameVolumeShadowMaterial L111–172): `steps` samples of the light ray through\n * `box` (the last grid cascade), each at the middle of its step; the march stops past optical depth 8. Returns\n * (τ·first, τ·last, 0, τ) with first / last the depths (÷ `ray.far`) of the first and last non-empty steps; empty\n * texels are 0. `extinctionAt` is the grid extinction (red channel of the shadow density grid) at a world point.\n * Spectral (`extinctionAt` returns rgb): output 0 is (τ̄·first, τ̄·last, 0, τ̄) with τ̄ the channel mean, output 1\n * is (τ rgb, 0).\n */\nexport function vdbFrameShadowMapTexel(\n extinctionAt: (world: Vec3) => number | Vec3,\n origin: Vec3,\n direction: Vec3,\n box: { min: Vec3; max: Vec3 } | null,\n steps: number,\n ray: VDBFrameShadowRay,\n spectral = false,\n): { map: Vec4; spectral: Vec4 | null } {\n const depth: Vec3 = [0, 0, 0];\n const total = () => (spectral ? Math.min(depth[0], depth[1], depth[2]) : depth[0]);\n let first = 0;\n let last = 0;\n if (box) {\n const tMin: number[] = [];\n const tMax: number[] = [];\n for (let c = 0; c < 3; c++) {\n const inv = 1 / direction[c]!;\n const a = (box.min[c]! - origin[c]!) * inv;\n const b = (box.max[c]! - origin[c]!) * inv;\n tMin.push(Math.min(a, b));\n tMax.push(Math.max(a, b));\n }\n const tStart = Math.max(0, Math.max(tMin[0]!, Math.max(tMin[1]!, tMin[2]!)));\n const tEnd = Math.min(tMax[0]!, Math.min(tMax[1]!, tMax[2]!));\n if (tEnd > tStart) {\n const n = Math.max(steps, 1);\n const stepLength = (tEnd - tStart) / n;\n let firstT = -1;\n let lastT = -1;\n for (let i = 0; i < n; i++) {\n if (total() > frameShadowMaxOpticalDepth) break;\n const t = tStart + i * stepLength;\n const s = t + stepLength * 0.5;\n const e = extinctionAt([origin[0] + direction[0] * s, origin[1] + direction[1] * s, origin[2] + direction[2] * s]);\n const ext: Vec3 = typeof e === \"number\" ? [e, e, e] : e;\n const any = spectral ? ext[0] + ext[1] + ext[2] : ext[0];\n if (any > 0) {\n if (firstT < 0) firstT = t;\n lastT = t + stepLength;\n for (let c = 0; c < 3; c++) depth[c] = depth[c]! + ext[c]! * stepLength;\n }\n }\n if ((spectral ? depth[0] + depth[1] + depth[2] : depth[0]) > 0) {\n const at = (t: number): Vec3 => [origin[0] + direction[0] * t, origin[1] + direction[1] * t, origin[2] + direction[2] * t];\n first = vdbFrameShadowDepth(ray, at(firstT)) / ray.far;\n last = vdbFrameShadowDepth(ray, at(lastT)) / ray.far;\n }\n }\n }\n if (spectral) {\n const mean = (depth[0] + depth[1] + depth[2]) / 3;\n return { map: [first * mean, last * mean, 0, mean], spectral: [depth[0], depth[1], depth[2], 0] };\n }\n return { map: [first * depth[0], last * depth[0], 0, depth[0]], spectral: null };\n}\n\n/**\n * The receiver transmittance (FrameVolumeShadows L344–372): the optical depth grows linearly from the first to the\n * last non-empty depth of the (filtered) texel. `depth` is the receiver's {@link vdbFrameShadowDepth}, `far` the\n * drawn shadow camera's far. `spectralTexel` (rgb optical depth): per-channel transmittance; with `mean`, their mean\n * (a `ShadowMaterial` receiver). Returns 1 for an empty texel.\n */\nexport function vdbFrameShadowReceiver(texel: Vec4, depth: number, far: number, spectralTexel: Vec3 | null = null, mean = false): number | Vec3 {\n const opticalDepth = texel[3];\n if (!(opticalDepth > frameShadowMinOpticalDepth)) return spectralTexel && !mean ? [1, 1, 1] : 1;\n const first = (texel[0] / opticalDepth) * far;\n const last = (texel[1] / opticalDepth) * far;\n const along = clamp((depth - first) / Math.max(last - first, 1e-4), 0, 1);\n if (spectralTexel) {\n const t: Vec3 = [Math.exp(-spectralTexel[0] * along), Math.exp(-spectralTexel[1] * along), Math.exp(-spectralTexel[2] * along)];\n return mean ? (t[0] + t[1] + t[2]) / 3 : t;\n }\n return Math.exp(-opticalDepth * along);\n}\n\n/** getCascadeBreaks: far distance of each cascade, the practical split of three's CSMShadowNode (λ = 0.5). */\nexport function vdbFrameShadowCascadeBreaks(count: number, near: number, far: number): number[] {\n const breaks: number[] = [];\n for (let i = 1; i <= count; i++) {\n const uniformSplit = near + ((far - near) * i) / count;\n const logSplit = near * Math.pow(far / near, i / count);\n breaks.push(i === count ? far : uniformSplit + (logSplit - uniformSplit) * 0.5);\n }\n return breaks;\n}\n\n/**\n * The view distance the cascades cover (fitCascades L714–730): the far corner of the volume box plus one box\n * diagonal, rounded up to half octaves (so the splits move only at those steps), within [near·1.0001,\n * min(camera far, castShadowDistance)]. `boxFar` is the largest view depth of the box's corners.\n */\nexport function vdbFrameShadowCascadeFar(near: number, cameraFar: number, castShadowDistance: number, boxFar: number, boxDiagonal: number): number {\n const sceneFar = Math.max(near * 2.0, boxFar + boxDiagonal);\n const steppedFar = Math.pow(2.0, Math.ceil(Math.log2(sceneFar) * 2.0) / 2.0);\n return Math.max(near * 1.0001, Math.min(cameraFar, castShadowDistance, steppedFar));\n}\n\n/** The cascade of a receiver (getCascadeLookup L253–261): the number of cascade far distances in front of it. */\nexport function vdbFrameShadowCascadeIndex(viewDepth: number, breaks: readonly number[], count: number): number {\n let index = 0;\n for (let i = 0; i < frameMaxShadowMapCascades - 1; i++) if (viewDepth > breaks[i]! && i + 1 < count) index++;\n return index;\n}\n\n/**\n * The spot map uv of a receiver (FrameVolumeShadowNode, his 62a6e3e): `clip` is its clip position in the camera that\n * drew the map (the drawn view-projection, not three's current shadow matrix), with three's ShadowNode y flip.\n * Outside when behind that camera (w ≤ 0) or off the map.\n */\nexport function vdbFrameShadowSpotUv(clip: Vec4): { uv: Vec2; inside: boolean } {\n const uv: Vec2 = [(clip[0] / clip[3]) * 0.5 + 0.5, 0.5 - (clip[1] / clip[3]) * 0.5];\n return { uv, inside: clip[3] > 0 && uv[0] >= 0 && uv[0] <= 1 && uv[1] >= 0 && uv[1] <= 1 };\n}\n\n/**\n * The atlas uv of a receiver in cascade `index` (getCascadeLookup L266–282): `clip` is its clip position in the\n * cascade camera (x, y after the divide; orthographic, so w = 1). Half a texel in from each tile side. `inside`\n * also needs the view depth within the last break (checked by the caller).\n */\nexport function vdbFrameShadowCascadeUv(clip: Vec2, index: number, size: number): { uv: Vec2; insideTile: boolean } {\n const tileUv: Vec2 = [clip[0] * 0.5 + 0.5, 0.5 - clip[1] * 0.5];\n const inset = 0.5 / size;\n const u = clamp(tileUv[0], inset, 1 - inset);\n const v = clamp(tileUv[1], inset, 1 - inset);\n return {\n uv: [(u + index) / frameMaxShadowMapCascades, v],\n insideTile: tileUv[0] >= 0 && tileUv[0] <= 1 && tileUv[1] >= 0 && tileUv[1] <= 1,\n };\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// K6.5: twins of the core volume shadow kernels (core/frame/wgsl/shadows.ts). The core draws each map texel from the\n// inverse view-projection of the camera that drew it (spot, cascades) or from the cube face table (point); receivers\n// read the map with that drawn view. Plain arrays, column-major.\n\n/** Column-major 4×4 × (x, y, z, w). */\nfunction apply4(m: ArrayLike<number>, x: number, y: number, z: number, w: number): Vec4 {\n return [m[0]! * x + m[4]! * y + m[8]! * z + m[12]! * w, m[1]! * x + m[5]! * y + m[9]! * z + m[13]! * w, m[2]! * x + m[6]! * y + m[10]! * z + m[14]! * w, m[3]! * x + m[7]! * y + m[11]! * z + m[15]! * w];\n}\n\nconst normalize3 = (v: Vec3): Vec3 => {\n const l = len(v);\n return [v[0] / l, v[1] / l, v[2] / l];\n};\n\n/**\n * The map ray of one texel from the drawing camera's inverse view-projection (the core's `vdbFrameVolumeShadowCs`;\n * the same construction as {@link vdbFrameShadowPassRay}: two unprojected points at NDC depth 0.25 and 0.75 give the\n * direction; perspective rays start at the camera, orthographic ones on the camera plane). `ndc`: the texel centre,\n * x right, y up (texel row r ↔ ndc.y = 1 − 2 (r + ½) / size).\n */\nexport function vdbFrameShadowMapRay(inverseViewProjection: ArrayLike<number>, cameraPosition: Vec3, perspective: boolean, ndc: Vec2): { origin: Vec3; direction: Vec3 } {\n const unproject = (z: number): Vec3 => {\n const p = apply4(inverseViewProjection, ndc[0], ndc[1], z, 1);\n return [p[0] / p[3], p[1] / p[3], p[2] / p[3]];\n };\n const near = unproject(0.25);\n const direction = normalize3(sub(unproject(0.75), near));\n if (perspective) return { origin: [...cameraPosition], direction };\n const along = dot(sub(near, cameraPosition), direction);\n return { origin: [near[0] - direction[0] * along, near[1] - direction[1] * along, near[2] - direction[2] * along], direction };\n}\n\n/**\n * The (unnormalized) direction of a cube map texel: face 0–5 (+x, −x, +y, −y, +z, −z), `a`, `b` in [−1, 1] the\n * face coordinates (s, t) × 2 − 1 with t down the rows. WebGPU's cube face selection (the Vulkan table): a cube view\n * sampled with this direction reads this texel.\n */\nexport function vdbFrameCubeFaceDirection(face: number, a: number, b: number): Vec3 {\n switch (face) {\n case 0:\n return [1, -b, -a];\n case 1:\n return [-1, -b, a];\n case 2:\n return [a, 1, b];\n case 3:\n return [a, -1, -b];\n case 4:\n return [a, -b, 1];\n default:\n return [-a, -b, -1];\n }\n}\n\n/** The inverse of {@link vdbFrameCubeFaceDirection}: the face and its (s, t) in [0, 1] (t down the rows) of a direction. */\nexport function vdbFrameCubeFaceUv(d: Vec3): { face: number; s: number; t: number } {\n const ax = Math.abs(d[0]);\n const ay = Math.abs(d[1]);\n const az = Math.abs(d[2]);\n let face: number;\n let sc: number;\n let tc: number;\n let ma: number;\n if (ax >= ay && ax >= az) {\n ma = ax;\n face = d[0] >= 0 ? 0 : 1;\n sc = d[0] >= 0 ? -d[2] : d[2];\n tc = -d[1];\n } else if (ay >= az) {\n ma = ay;\n face = d[1] >= 0 ? 2 : 3;\n sc = d[0];\n tc = d[1] >= 0 ? d[2] : -d[2];\n } else {\n ma = az;\n face = d[2] >= 0 ? 4 : 5;\n sc = d[2] >= 0 ? d[0] : -d[0];\n tc = -d[1];\n }\n return { face, s: (sc / ma + 1) / 2, t: (tc / ma + 1) / 2 };\n}\n\n/** General 4×4 inverse (f64; column-major). */\nfunction invert4(m: ArrayLike<number>): Float64Array {\n const [a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33] = Array.from({ length: 16 }, (_, i) => m[i]!) as [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number];\n const b00 = a00 * a11 - a01 * a10;\n const b01 = a00 * a12 - a02 * a10;\n const b02 = a00 * a13 - a03 * a10;\n const b03 = a01 * a12 - a02 * a11;\n const b04 = a01 * a13 - a03 * a11;\n const b05 = a02 * a13 - a03 * a12;\n const b06 = a20 * a31 - a21 * a30;\n const b07 = a20 * a32 - a22 * a30;\n const b08 = a20 * a33 - a23 * a30;\n const b09 = a21 * a32 - a22 * a31;\n const b10 = a21 * a33 - a23 * a31;\n const b11 = a22 * a33 - a23 * a32;\n const det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n const inv = det !== 0 ? 1 / det : 0;\n return Float64Array.from([\n (a11 * b11 - a12 * b10 + a13 * b09) * inv,\n (a02 * b10 - a01 * b11 - a03 * b09) * inv,\n (a31 * b05 - a32 * b04 + a33 * b03) * inv,\n (a22 * b04 - a21 * b05 - a23 * b03) * inv,\n (a12 * b08 - a10 * b11 - a13 * b07) * inv,\n (a00 * b11 - a02 * b08 + a03 * b07) * inv,\n (a32 * b02 - a30 * b05 - a33 * b01) * inv,\n (a20 * b05 - a22 * b02 + a23 * b01) * inv,\n (a10 * b10 - a11 * b08 + a13 * b06) * inv,\n (a01 * b08 - a00 * b10 - a03 * b06) * inv,\n (a30 * b04 - a31 * b02 + a33 * b00) * inv,\n (a21 * b02 - a20 * b04 - a23 * b00) * inv,\n (a11 * b07 - a10 * b09 - a12 * b06) * inv,\n (a00 * b09 - a01 * b07 + a02 * b06) * inv,\n (a31 * b01 - a30 * b03 - a32 * b00) * inv,\n (a20 * b03 - a21 * b01 + a22 * b00) * inv,\n ]);\n}\n\n/**\n * The drawing camera of a view-projection (spot lights, explicit cascades): its position and forward axis, and the\n * inverse. Perspective: the centre is VP⁻¹ (0, 0, 1, 0) (clip w = 0 on the camera); orthographic: the near plane centre\n * moved back by `near` along the forward axis. Forward: from the near plane centre to the far plane centre.\n */\nexport function vdbFrameShadowViewCamera(viewProjection: ArrayLike<number>, near: number, orthographic: boolean): { inverse: Float64Array; position: Vec3; forward: Vec3 } {\n const inverse = invert4(viewProjection);\n const at = (x: number, y: number, z: number, w: number): Vec3 => {\n const p = apply4(inverse, x, y, z, w);\n return [p[0] / p[3], p[1] / p[3], p[2] / p[3]];\n };\n const nearCenter = at(0, 0, 0, 1);\n const forward = normalize3(sub(at(0, 0, 1, 1), nearCenter));\n const position: Vec3 = orthographic ? [nearCenter[0] - forward[0] * near, nearCenter[1] - forward[1] * near, nearCenter[2] - forward[2] * near] : at(0, 0, 1, 0);\n return { inverse, position, forward };\n}\n\n/** Inputs of {@link vdbFrameShadowFitCascades}: the view camera, the light and the casters (the last grid cascade). */\nexport interface VDBFrameShadowFitInputs {\n /** View → world of the camera (three's `camera.matrixWorld`). */\n cameraWorld: ArrayLike<number>;\n /** Clip → view of the camera (three's `camera.projectionMatrixInverse`). */\n projectionInverse: ArrayLike<number>;\n near: number;\n far: number;\n orthographic: boolean;\n castShadowDistance: number;\n /** Cascades (clamped to 1..4). */\n count: number;\n /** Map texels per side (the snap). */\n size: number;\n /** The way the light travels (normalized here). */\n lightDirection: Vec3;\n /** The box of all casters (the last grid cascade). */\n casterBox: { min: Vec3; max: Vec3 };\n}\n\n/** One fitted cascade camera: its view-projection (WebGPU depth 0..1), position (the ray origin) and far plane. */\nexport interface VDBFrameShadowCascadeCamera {\n viewProjection: Float64Array;\n origin: Vec3;\n far: number;\n}\n\n/**\n * His `fitCascades` (FrameVolumeShadows L692–778; three's CSMShadowNode method), engine-free: the practical split of\n * the view depth up to {@link vdbFrameShadowCascadeFar}; per slice a light-aligned orthographic camera sized from the\n * slice diagonal, its centre snapped to texels, its depth range over the slice and the casters (± 1). Returns the\n * cascades, the breaks (padded to 4 with the last ones, as his `cascadeBreaks`) and the light's forward axis.\n */\nexport function vdbFrameShadowFitCascades(o: VDBFrameShadowFitInputs): { count: number; breaks: [number, number, number, number]; forward: Vec3; cascades: VDBFrameShadowCascadeCamera[] } {\n const count = Math.min(frameMaxShadowMapCascades, Math.max(1, Math.round(o.count)));\n const view = invert4(o.cameraWorld);\n const box = o.casterBox;\n let boxFar = 0;\n for (let i = 0; i < 8; i++) {\n const p = apply4(view, i & 1 ? box.max[0] : box.min[0], i & 2 ? box.max[1] : box.min[1], i & 4 ? box.max[2] : box.min[2], 1);\n boxFar = Math.max(boxFar, -p[2]);\n }\n const far = vdbFrameShadowCascadeFar(o.near, o.far, o.castShadowDistance, boxFar, len(sub(box.max, box.min)));\n const breaks = vdbFrameShadowCascadeBreaks(count, o.near, far);\n\n // Light view: three's Matrix4.lookAt(origin, lightDirection, up): z = −direction, x = up × z, y = z × x\n const direction = normalize3(o.lightDirection);\n const up: Vec3 = Math.abs(direction[1]) > 0.999 ? [0, 0, 1] : [0, 1, 0];\n const zAxis: Vec3 = [-direction[0], -direction[1], -direction[2]];\n const cross = (a: Vec3, b: Vec3): Vec3 => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];\n const xAxis = normalize3(cross(up, zAxis));\n const yAxis = cross(zAxis, xAxis);\n // world → light (the transpose of the rotation) and back\n const toLight = (p: Vec3): Vec3 => [dot(p, xAxis), dot(p, yAxis), dot(p, zAxis)];\n const fromLight = (p: Vec3): Vec3 => [xAxis[0] * p[0] + yAxis[0] * p[1] + zAxis[0] * p[2], xAxis[1] * p[0] + yAxis[1] * p[1] + zAxis[1] * p[2], xAxis[2] * p[0] + yAxis[2] * p[1] + zAxis[2] * p[2]];\n const bounds = (points: Vec3[]) => {\n const lo: Vec3 = [Infinity, Infinity, Infinity];\n const hi: Vec3 = [-Infinity, -Infinity, -Infinity];\n for (const q of points) {\n const p = toLight(q);\n for (let k = 0; k < 3; k++) {\n lo[k] = Math.min(lo[k]!, p[k]!);\n hi[k] = Math.max(hi[k]!, p[k]!);\n }\n }\n return { lo, hi };\n };\n const caster = bounds(Array.from({ length: 8 }, (_, i) => [i & 1 ? box.max[0] : box.min[0], i & 2 ? box.max[1] : box.min[1], i & 4 ? box.max[2] : box.min[2]] as Vec3));\n\n // getSliceCorners: corners of the view at a depth, in world space (corners 0 and 2 are diagonal)\n const corners = (depth: number): Vec3[] =>\n (\n [\n [-1, -1],\n [1, -1],\n [1, 1],\n [-1, 1],\n ] as const\n ).map(([x, y]) => {\n const q = apply4(o.projectionInverse, x, y, 0.5, 1);\n let p: Vec3 = [q[0] / q[3], q[1] / q[3], q[2] / q[3]];\n if (!o.orthographic) {\n const s = depth / -p[2];\n p = [p[0] * s, p[1] * s, p[2] * s];\n } else p = [p[0], p[1], -depth];\n const w = apply4(o.cameraWorld, p[0], p[1], p[2], 1);\n return [w[0], w[1], w[2]] as Vec3;\n });\n\n const cascades: VDBFrameShadowCascadeCamera[] = [];\n for (let i = 0; i < count; i++) {\n const nearCorners = corners(i === 0 ? o.near : breaks[i - 1]!);\n const farCorners = corners(breaks[i]!);\n const width = Math.max(len(sub(farCorners[0]!, farCorners[2]!)), len(sub(farCorners[0]!, nearCorners[2]!)));\n const texel = width / o.size;\n const slice = bounds([...nearCorners, ...farCorners]);\n const centerX = Math.floor((slice.lo[0] + slice.hi[0]) * 0.5 / texel) * texel;\n const centerY = Math.floor((slice.lo[1] + slice.hi[1]) * 0.5 / texel) * texel;\n const front = Math.max(slice.hi[2], caster.hi[2]) + frameShadowCascadeMargin;\n const back = Math.min(slice.lo[2], caster.lo[2]) - frameShadowCascadeMargin;\n const depth = front - back;\n const position = fromLight([centerX, centerY, front]);\n // camera world = [R | position]; its inverse: [Rᵀ | −Rᵀ position]\n const viewMatrix = [xAxis[0], yAxis[0], zAxis[0], 0, xAxis[1], yAxis[1], zAxis[1], 0, xAxis[2], yAxis[2], zAxis[2], 0, -dot(xAxis, position), -dot(yAxis, position), -dot(zAxis, position), 1];\n // three's makeOrthographic (WebGPU: depth 0..1): left/right/top/bottom ±width/2, near 0, far = depth\n const sx = 2 / width;\n const projection = [sx, 0, 0, 0, 0, sx, 0, 0, 0, 0, -1 / depth, 0, 0, 0, 0, 1];\n const vp = new Float64Array(16);\n for (let col = 0; col < 4; col++)\n for (let row = 0; row < 4; row++) {\n let s = 0;\n for (let k = 0; k < 4; k++) s += projection[k * 4 + row]! * viewMatrix[col * 4 + k]!;\n vp[col * 4 + row] = s;\n }\n cascades.push({ viewProjection: vp, origin: position, far: depth });\n }\n return {\n count,\n breaks: [breaks[Math.min(0, count - 1)]!, breaks[Math.min(1, count - 1)]!, breaks[Math.min(2, count - 1)]!, breaks[Math.min(3, count - 1)]!],\n forward: direction,\n cascades,\n };\n}\n\n/** The drawn view of a core volume shadow map, as `VdbVolumeShadowView` holds it (core/frame/wgsl/shadows.ts). */\nexport interface VDBFrameVolumeShadowViewCpu {\n /** 0: directional cascades, 1: spot, 2: point (cube). */\n kind: number;\n /** One per layer (cascades); spot: [0]. */\n viewProjection: readonly ArrayLike<number>[];\n /** Ray origin per layer (cascades) or [0]. */\n origin: readonly Vec3[];\n /** Far plane per layer (map depths ÷ far). */\n far: readonly number[];\n forward: Vec3;\n perspective: boolean;\n breaks: readonly number[];\n cascadeCount: number;\n size: number;\n enabled: boolean;\n}\n\n/**\n * The core receiver (`vdbVolumeShadow` / `vdbVolumeShadowCube`), CPU: picks the layer and uv from the drawn view\n * (cascade by view depth, spot by the drawn view-projection, point by the cube face of the direction from the drawn\n * light position), reads the map with `sample(layer, s, t)` (filtered; s, t in [0, 1], t down the rows) and applies\n * {@link vdbFrameShadowReceiver}. 1 outside the map or when disabled.\n */\nexport function vdbFrameVolumeShadowLookup(view: VDBFrameVolumeShadowViewCpu, world: Vec3, viewDepth: number, sample: (layer: number, s: number, t: number) => Vec4): number {\n return vdbFrameVolumeShadowLookupWith(view, world, viewDepth, sample, null) as number;\n}\n\n/**\n * K6.4: the spectral receivers (`vdbVolumeShadowRgb` / `vdbVolumeShadowCubeRgb`): each channel's transmittance from the\n * map's rgb twin (`sampleRgb`, the same layer and uv), along the grey texel's first-to-last span.\n */\nexport function vdbFrameVolumeShadowLookupRgb(view: VDBFrameVolumeShadowViewCpu, world: Vec3, viewDepth: number, sample: (layer: number, s: number, t: number) => Vec4, sampleRgb: (layer: number, s: number, t: number) => Vec4): Vec3 {\n return vdbFrameVolumeShadowLookupWith(view, world, viewDepth, sample, sampleRgb) as Vec3;\n}\n\nfunction vdbFrameVolumeShadowLookupWith(view: VDBFrameVolumeShadowViewCpu, world: Vec3, viewDepth: number, sample: (layer: number, s: number, t: number) => Vec4, sampleRgb: ((layer: number, s: number, t: number) => Vec4) | null): number | Vec3 {\n const none = sampleRgb ? ([1, 1, 1] as Vec3) : 1;\n const rgbAt = (layer: number, s: number, t: number): Vec3 | null => {\n if (!sampleRgb) return null;\n const v = sampleRgb(layer, s, t);\n return [v[0], v[1], v[2]];\n };\n if (!view.enabled) return none;\n if (view.kind === 2) {\n const offset = sub(world, view.origin[0]!);\n const f = vdbFrameCubeFaceUv(offset);\n return vdbFrameShadowReceiver(sample(f.face, f.s, f.t), len(offset), view.far[0]!, rgbAt(f.face, f.s, f.t));\n }\n let layer = 0;\n let uv: Vec2;\n if (view.kind === 0) {\n layer = vdbFrameShadowCascadeIndex(viewDepth, view.breaks, view.cascadeCount);\n const clip = mul4(view.viewProjection[layer]!, [world[0], world[1], world[2], 1]);\n const tile: Vec2 = [clip[0] * 0.5 + 0.5, 0.5 - clip[1] * 0.5];\n const lastBreak = view.breaks[Math.max(0, Math.min(3, view.cascadeCount - 1))]!;\n if (!(viewDepth <= lastBreak && tile[0] >= 0 && tile[0] <= 1 && tile[1] >= 0 && tile[1] <= 1)) return none;\n const inset = 0.5 / view.size;\n uv = [clamp(tile[0], inset, 1 - inset), clamp(tile[1], inset, 1 - inset)];\n } else {\n const spot = vdbFrameShadowSpotUv(mul4(view.viewProjection[0]!, [world[0], world[1], world[2], 1]));\n if (!spot.inside) return none;\n uv = spot.uv;\n }\n const depth = vdbFrameShadowDepth({ origin: view.origin[layer]!, forward: view.forward, perspective: view.perspective ? 1 : 0 }, world);\n return vdbFrameShadowReceiver(sample(layer, uv[0], uv[1]), depth, view.far[layer]!, rgbAt(layer, uv[0], uv[1]));\n}\n"]}
|