@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
|
@@ -1,109 +1,52 @@
|
|
|
1
1
|
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
-
// src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L34–1027 (
|
|
3
|
-
//
|
|
4
|
-
// the budgeted map updates, dispose).
|
|
2
|
+
// src/three-openvdb/frame/webgpu/FrameVolumeShadows.js L34–1027 (the light shadow reset, FrameVolumeShadowNode, the
|
|
3
|
+
// filter install, dispose).
|
|
5
4
|
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
5
|
+
// Past the pin (K7.1): his 62a6e3e (lookups from the drawn state) and c13f2d5 (the budget counts only lights of the
|
|
6
|
+
// rendered scene; the core's maps).
|
|
7
|
+
// Changes: TypeScript; K6.8: the maps are the core's (`VDBVolumeShadowMap`, drawn by its kernels), three only receives
|
|
8
|
+
// them; K6.8a: the receivers call the core's WGSL (`vdbVolumeShadowWgsl`) with the core's view buffer bound through a
|
|
9
|
+
// storage stand-in, instead of a TSL port of the lookup; every three r187 internal goes through `three-internals.ts`
|
|
10
|
+
// or the `VDBGridNode` attribute self-test, which throw VDB_ENGINE_MISMATCH. Divergences: DIVERGES.md (K3.6, K6.5 rows).
|
|
9
11
|
/**
|
|
10
|
-
* K3.6: shadows of `VDBFrameVolume`s on meshes (`frameRenderer.settings.castShadows`, his `FrameVolumeShadows`).
|
|
11
|
-
* Each shadow-casting directional, spot or point light gets a Beer shadow map
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* split), tiles of one atlas. Spot: the light's shadow camera. Point: a cube map. A map piece is drawn again only
|
|
15
|
-
* when its camera or the grid changes, at most `castShadowUpdatesPerFrame` pieces per render (oldest first).
|
|
12
|
+
* K3.6 / K6.5: shadows of `VDBFrameVolume`s on meshes (`frameRenderer.settings.castShadows`, his `FrameVolumeShadows`).
|
|
13
|
+
* Each shadow-casting directional, spot or point light gets a Beer shadow map from the core frame renderer (its
|
|
14
|
+
* `outputs.volumeShadows`); the light's `shadow.filterNode` multiplies three's shadow by the volume transmittance at
|
|
15
|
+
* the receiver.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* K6.8a: the receiver is the core's own WGSL (`vdbVolumeShadow`, `…Rgb`, `…Cube`, `…CubeRgb` of `vdbVolumeShadowWgsl()`)
|
|
18
|
+
* through a `wgslFn`. Its inputs are the map texture (a 2d-array: directional cascades or a spot map; a point map through a
|
|
19
|
+
* cube view), the spectral rgb twin, and the map's `view` buffer, the state the map was drawn with (his 62a6e3e), which
|
|
20
|
+
* the core rewrites each update: three binds that buffer itself through a storage stand-in (the `VDBGridNode` pool-buffer
|
|
21
|
+
* pattern), read as `array<vec4u>` and unpacked into `VdbVolumeShadowView`. Each light's texture and storage nodes are
|
|
22
|
+
* made once and only their `value` follows the core (a new stand-in when the core made a new texture or buffer), so a
|
|
23
|
+
* receiver built at any time binds the core's current objects; while a light has no core map they bind a placeholder
|
|
24
|
+
* (a zero view: transmittance 1), never a texture or buffer the core retired (K6.10 finding 8).
|
|
25
|
+
*
|
|
26
|
+
* three: receivers need `receiveShadow`, the light `castShadow`, and `renderer.shadowMap.enabled`. The core update runs
|
|
27
|
+
* before the first receiver of each render (the node's `updateBefore`), so the maps are this render's.
|
|
20
28
|
*/
|
|
21
29
|
import * as THREE from "three";
|
|
22
|
-
import {
|
|
30
|
+
import { Node } from "three/webgpu";
|
|
23
31
|
import * as TSL from "three/tsl";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
32
|
+
import { vdbThreeStorageStandIn } from "../grid-node.js";
|
|
33
|
+
import { getDevice } from "../device.js";
|
|
34
|
+
import { frameShadowCoarseMapSize } from "../../tools/frame/shadows.js";
|
|
26
35
|
import { vdbFrameCheckFilterInputs, vdbFrameCheckLightReset, vdbFrameRenderUpdateType, vdbFrameShadowFilters, vdbFrameSharedLightNode } from "./three-internals.js";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const lightUp = new THREE.Vector3();
|
|
32
|
-
const point = new THREE.Vector3();
|
|
33
|
-
const lightView = new THREE.Matrix4();
|
|
34
|
-
const lightViewInverse = new THREE.Matrix4();
|
|
35
|
-
const casterBox = new THREE.Box3();
|
|
36
|
-
const casterWorldBox = new THREE.Box3();
|
|
37
|
-
const sliceBox = new THREE.Box3();
|
|
38
|
-
const tileViewport = new THREE.Vector4();
|
|
39
|
-
const nearCorners = [0, 1, 2, 3].map(() => new THREE.Vector3());
|
|
40
|
-
const farCorners = [0, 1, 2, 3].map(() => new THREE.Vector3());
|
|
41
|
-
// NOTE Values for change checks. One array, reused for each check.
|
|
42
|
-
const signature = [];
|
|
43
|
-
// NOTE Fullscreen triangle. Positions are clip coordinates.
|
|
44
|
-
const createFullscreenGeometry = () => new THREE.BufferGeometry().setAttribute("position", new THREE.Float32BufferAttribute([-1, -1, 0, 3, -1, 0, -1, 3, 0], 3));
|
|
45
|
-
const targetOptions = {
|
|
46
|
-
type: THREE.HalfFloatType,
|
|
47
|
-
format: THREE.RGBAFormat,
|
|
48
|
-
minFilter: THREE.LinearFilter,
|
|
49
|
-
magFilter: THREE.LinearFilter,
|
|
50
|
-
generateMipmaps: false,
|
|
51
|
-
depthBuffer: false,
|
|
52
|
-
};
|
|
53
|
-
// NOTE Directional lights: an atlas with one tile for each cascade, in a row
|
|
54
|
-
const createTarget = (size, light) => {
|
|
55
|
-
if (light.isPointLight) {
|
|
56
|
-
return new CubeRenderTarget(size, targetOptions);
|
|
57
|
-
}
|
|
58
|
-
const tiles = light.isDirectionalLight ? frameMaxShadowMapCascades : 1;
|
|
59
|
-
return new THREE.RenderTarget(size * tiles, size, targetOptions);
|
|
60
|
-
};
|
|
61
|
-
// NOTE Clears a new map one time. Then three makes its GPU texture as a render target texture now.
|
|
62
|
-
// Else the first render makes a new GPU texture, and receivers that sampled the map before keep the destroyed one.
|
|
63
|
-
const initTarget = (renderer, target, cube) => {
|
|
64
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
65
|
-
const currentActiveCubeFace = renderer.getActiveCubeFace();
|
|
66
|
-
const currentActiveMipmapLevel = renderer.getActiveMipmapLevel();
|
|
67
|
-
const currentClearAlpha = renderer.getClearAlpha();
|
|
68
|
-
renderer.getClearColor(clearColor);
|
|
69
|
-
renderer.setClearColor(0x000000, 0.0);
|
|
70
|
-
for (let face = 0; face < (cube ? 6 : 1); face++) {
|
|
71
|
-
renderer.setRenderTarget(target, face);
|
|
72
|
-
renderer.clear(true, false, false);
|
|
73
|
-
}
|
|
74
|
-
renderer.setClearColor(clearColor, currentClearAlpha);
|
|
75
|
-
renderer.setRenderTarget(currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel);
|
|
76
|
-
return target;
|
|
77
|
-
};
|
|
36
|
+
import { VDBCoreTextureBinding } from "./core-textures.js";
|
|
37
|
+
import { VDBFrameStructLoaderNode, vdbFrameStructLoaderWgsl, vdbFrameStructWords } from "./core-structs.js";
|
|
38
|
+
import { VDB_VOLUME_SHADOW_VIEW, vdbVolumeShadowWgsl } from "../../core/frame/wgsl/shadows.js";
|
|
39
|
+
const { code, cubeTexture, dot, positionView, positionWorld, sampler, storage, texture, vec3, wgslFn } = TSL;
|
|
78
40
|
const isShadowLight = (light) => {
|
|
79
41
|
const l = light;
|
|
80
42
|
return !!(l.isDirectionalLight || l.isSpotLight || l.isPointLight) && l.castShadow;
|
|
81
43
|
};
|
|
82
|
-
// NOTE
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
[-1, 1],
|
|
89
|
-
];
|
|
90
|
-
const perspective = camera.isPerspectiveCamera;
|
|
91
|
-
corners.forEach(([x, y], index) => {
|
|
92
|
-
for (const [target, depth] of [
|
|
93
|
-
[nearCorners[index], near],
|
|
94
|
-
[farCorners[index], far],
|
|
95
|
-
]) {
|
|
96
|
-
// NOTE A point on the corner ray, then moved to the depth (perspective) or set to it (orthographic)
|
|
97
|
-
target.set(x, y, 0.5).applyMatrix4(camera.projectionMatrixInverse);
|
|
98
|
-
if (perspective) {
|
|
99
|
-
target.multiplyScalar(depth / -target.z);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
target.z = -depth;
|
|
103
|
-
}
|
|
104
|
-
target.applyMatrix4(camera.matrixWorld);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
44
|
+
// NOTE The object is in a scene. A removed light is not.
|
|
45
|
+
const isInScene = (object) => {
|
|
46
|
+
let root = object;
|
|
47
|
+
while (root.parent)
|
|
48
|
+
root = root.parent;
|
|
49
|
+
return root.isScene === true;
|
|
107
50
|
};
|
|
108
51
|
// NOTE A light shadow node is built one time; a new filterNode has no effect until it is built again.
|
|
109
52
|
// disposeShadow of the shared light node makes the receivers build a new shadow node (three-internals.ts, internal 1).
|
|
@@ -111,78 +54,31 @@ const getSliceCorners = (camera, near, far) => {
|
|
|
111
54
|
const resetLightShadow = (light) => {
|
|
112
55
|
vdbFrameCheckLightReset();
|
|
113
56
|
const lightNode = vdbFrameSharedLightNode(light);
|
|
114
|
-
if (!lightNode || !lightNode.shadowNode)
|
|
57
|
+
if (!lightNode || !lightNode.shadowNode)
|
|
115
58
|
return null;
|
|
116
|
-
}
|
|
117
59
|
const { shadowNode } = lightNode;
|
|
118
60
|
// NOTE disposeShadow without the GPU dispose
|
|
119
61
|
lightNode.shadowNode = { dispose() { } };
|
|
120
62
|
lightNode.disposeShadow();
|
|
121
63
|
return shadowNode;
|
|
122
64
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
frameShadowPerspective: renderUniform(0, "int", () => drawn.perspective),
|
|
136
|
-
frameShadowFar: renderUniform(1.0, "float", () => drawn.far),
|
|
137
|
-
},
|
|
138
|
-
cascades: cascades
|
|
139
|
-
? {
|
|
140
|
-
count: renderUniform(0, "int", () => drawn.cascadeCount),
|
|
141
|
-
breaks: renderUniform(new THREE.Vector4(), "vec4", () => drawn.cascadeBreaks),
|
|
142
|
-
items: cascades.map((cascade) => ({
|
|
143
|
-
viewProjection: renderUniform(new THREE.Matrix4(), "mat4", () => cascade.drawn.viewProjection),
|
|
144
|
-
origin: renderUniform(new THREE.Vector3(), "vec3", () => cascade.drawn.origin),
|
|
145
|
-
far: renderUniform(1.0, "float", () => cascade.drawn.far),
|
|
146
|
-
})),
|
|
147
|
-
}
|
|
148
|
-
: null,
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
// NOTE Picks the cascade of the receiver by its view depth, as three's CSMShadowNode (twin: vdbFrameShadowCascadeIndex / Uv).
|
|
152
|
-
// Returns the atlas uv, the ray uniforms of the cascade, and whether the receiver is in a cascade.
|
|
153
|
-
const getCascadeLookup = (receiver, size) => {
|
|
154
|
-
const { count, breaks, items } = receiver.cascades;
|
|
155
|
-
const { frameShadowForward } = receiver.rayUniforms;
|
|
156
|
-
const depth = positionView.z.negate();
|
|
157
|
-
const breakList = [breaks.x, breaks.y, breaks.z, breaks.w];
|
|
158
|
-
// NOTE Cascade index: the number of cascade far distances in front of the receiver
|
|
159
|
-
let index = int(0);
|
|
160
|
-
for (let i = 0; i < frameMaxShadowMapCascades - 1; i++) {
|
|
161
|
-
index = index.add(select(depth.greaterThan(breakList[i]).and(int(i + 1).lessThan(count)), int(1), int(0)));
|
|
162
|
-
}
|
|
163
|
-
const pick = (key) => items.reduce((result, item, i) => (i === 0 ? item[key] : select(index.equal(i), item[key], result)), null);
|
|
164
|
-
const viewProjection = pick("viewProjection");
|
|
165
|
-
const clip = viewProjection.mul(vec4(positionWorld, 1.0));
|
|
166
|
-
const tileUv = vec2(clip.x.mul(0.5).add(0.5), float(0.5).sub(clip.y.mul(0.5)));
|
|
167
|
-
const lastBreak = breakList.reduce((result, value, i) => (i === 0 ? value : select(count.equal(i + 1), value, result)), null);
|
|
168
|
-
// NOTE Half a texel in from the tile sides. Then the linear filter does not read the next tile.
|
|
169
|
-
const inset = float(0.5 / size);
|
|
170
|
-
const clampedUv = clamp(tileUv, vec2(inset), vec2(float(1.0).sub(inset)));
|
|
171
|
-
return {
|
|
172
|
-
uv: vec2(clampedUv.x.add(float(index)).div(frameMaxShadowMapCascades), clampedUv.y),
|
|
173
|
-
inside: depth.lessThanEqual(lastBreak).and(tileUv.x.greaterThanEqual(0.0)).and(tileUv.x.lessThanEqual(1.0)).and(tileUv.y.greaterThanEqual(0.0)).and(tileUv.y.lessThanEqual(1.0)),
|
|
174
|
-
rayUniforms: {
|
|
175
|
-
frameShadowOrigin: pick("origin"),
|
|
176
|
-
frameShadowForward,
|
|
177
|
-
frameShadowPerspective: int(0),
|
|
178
|
-
frameShadowFar: pick("far"),
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
};
|
|
65
|
+
/** `vec4u` words of the view struct (every field is 16-byte aligned). */
|
|
66
|
+
const VIEW_WORDS = vdbFrameStructWords(VDB_VOLUME_SHADOW_VIEW);
|
|
67
|
+
/**
|
|
68
|
+
* WGSL that unpacks the view buffer (bound as `array<vec4u>` at `ref`) into the core's `VdbVolumeShadowView`, generated
|
|
69
|
+
* from the struct's layout, so a field the core adds is unpacked too (a type this cannot unpack throws).
|
|
70
|
+
*/
|
|
71
|
+
export function vdbFrameShadowViewLoaderWgsl(fnName, ref) {
|
|
72
|
+
return vdbFrameStructLoaderWgsl(VDB_VOLUME_SHADOW_VIEW, fnName, ref);
|
|
73
|
+
}
|
|
74
|
+
/** The core's receiver functions and the view struct, one code node shared by every receiver (once per shader). */
|
|
75
|
+
let receiverCode = null;
|
|
76
|
+
const receiverCodeNode = () => (receiverCode ??= code(vdbVolumeShadowWgsl()));
|
|
182
77
|
/**
|
|
183
|
-
* Volume transmittance at a receiver from the Beer shadow map
|
|
184
|
-
* `
|
|
185
|
-
* `
|
|
78
|
+
* Volume transmittance at a receiver from the light's core Beer shadow map: the core's `vdbVolumeShadow` /
|
|
79
|
+
* `vdbVolumeShadowCube` (K6.4 spectral maps: `…Rgb` / `…CubeRgb`, the channel mean in a ShadowMaterial, his rule) through
|
|
80
|
+
* a `wgslFn`, with the view the map was drawn with (twin `vdbFrameVolumeShadowLookup`). `updateBefore` runs the core
|
|
81
|
+
* update before the first receiver of each render.
|
|
186
82
|
*/
|
|
187
83
|
export class VDBFrameVolumeShadowNode extends Node {
|
|
188
84
|
static get type() {
|
|
@@ -190,567 +86,318 @@ export class VDBFrameVolumeShadowNode extends Node {
|
|
|
190
86
|
}
|
|
191
87
|
shadows;
|
|
192
88
|
entry;
|
|
193
|
-
|
|
194
|
-
constructor(shadows, entry, uv) {
|
|
89
|
+
constructor(shadows, entry) {
|
|
195
90
|
super("float");
|
|
196
91
|
this.shadows = shadows;
|
|
197
92
|
this.entry = entry;
|
|
198
|
-
this.uv = uv;
|
|
199
93
|
this.updateBeforeType = vdbFrameRenderUpdateType();
|
|
200
94
|
}
|
|
201
95
|
// NOTE Spectral maps: transmittance of each channel. ShadowMaterial has one shadow mask, so it gets the mean.
|
|
202
96
|
isSpectral(builder) {
|
|
203
|
-
return this.entry.
|
|
97
|
+
return this.entry.rgbTexture !== null && builder.material?.isShadowNodeMaterial !== true;
|
|
204
98
|
}
|
|
205
99
|
getNodeType(builder) {
|
|
206
100
|
return this.isSpectral(builder) ? "vec3" : "float";
|
|
207
101
|
}
|
|
208
102
|
updateBefore(frame) {
|
|
209
103
|
const { renderer, scene, camera, renderId } = frame;
|
|
210
|
-
this.shadows.render(renderer, scene, camera, renderId
|
|
104
|
+
this.shadows.render(renderer, scene, camera, renderId);
|
|
211
105
|
return undefined;
|
|
212
106
|
}
|
|
213
107
|
setup(builder) {
|
|
214
108
|
const { entry } = this;
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
else if (!isPoint) {
|
|
227
|
-
inside = inside.and(uv.x.greaterThanEqual(0.0)).and(uv.x.lessThanEqual(1.0)).and(uv.y.greaterThanEqual(0.0)).and(uv.y.lessThanEqual(1.0));
|
|
228
|
-
}
|
|
229
|
-
return Fn(() => {
|
|
230
|
-
const result = (spectral ? vec3(1.0) : float(1.0)).toVar();
|
|
231
|
-
If(inside, () => {
|
|
232
|
-
const texel = map.sample(uv).level(0).toVar();
|
|
233
|
-
const opticalDepth = texel.w;
|
|
234
|
-
If(opticalDepth.greaterThan(frameShadowMinOpticalDepth), () => {
|
|
235
|
-
const far = rayUniforms.frameShadowFar;
|
|
236
|
-
const first = texel.x.div(opticalDepth).mul(far);
|
|
237
|
-
const last = texel.y.div(opticalDepth).mul(far);
|
|
238
|
-
const depth = frameShadowDepth(rayUniforms, positionWorld);
|
|
239
|
-
// NOTE Beer shadow map: optical depth grows linearly from the first to the last density
|
|
240
|
-
const along = clamp(depth.sub(first).div(max(last.sub(first), 1e-4)), 0.0, 1.0);
|
|
241
|
-
if (spectral) {
|
|
242
|
-
result.assign(exp(spectralMap.sample(uv).level(0).rgb.mul(along).negate()));
|
|
243
|
-
}
|
|
244
|
-
else if (spectralMap) {
|
|
245
|
-
// NOTE ShadowMaterial with spectral maps: mean transmittance of the channels
|
|
246
|
-
result.assign(dot(exp(spectralMap.sample(uv).level(0).rgb.mul(along).negate()), vec3(1.0 / 3.0)));
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
result.assign(exp(opticalDepth.mul(along).negate()));
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
return result;
|
|
254
|
-
})();
|
|
109
|
+
const nodes = this.shadows.nodesOf(entry);
|
|
110
|
+
const rgbKind = entry.rgbTexture !== null;
|
|
111
|
+
const fn = this.shadows.receiverFn(entry, rgbKind);
|
|
112
|
+
const inputs = { map: nodes.map, smp: sampler(nodes.map), world: positionWorld };
|
|
113
|
+
if (rgbKind)
|
|
114
|
+
inputs.rgb = nodes.rgb;
|
|
115
|
+
if (!entry.isPoint)
|
|
116
|
+
inputs.viewDepth = positionView.z.negate();
|
|
117
|
+
const value = fn(inputs);
|
|
118
|
+
// NOTE ShadowMaterial with spectral maps: mean transmittance of the channels
|
|
119
|
+
return rgbKind && !this.isSpectral(builder) ? dot(value, vec3(1.0 / 3.0)) : value;
|
|
255
120
|
}
|
|
256
121
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
for (let current = object; current; current = current.parent) {
|
|
260
|
-
if (!current.visible) {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return true;
|
|
265
|
-
};
|
|
266
|
-
// NOTE The object is in a scene. A removed light is not.
|
|
267
|
-
const isInScene = (object) => {
|
|
268
|
-
let root = object;
|
|
269
|
-
while (root.parent) {
|
|
270
|
-
root = root.parent;
|
|
271
|
-
}
|
|
272
|
-
return root.isScene === true;
|
|
273
|
-
};
|
|
274
|
-
// NOTE Compares the signature with the one of the item. Stores it when it is different.
|
|
275
|
-
const changed = (item) => {
|
|
276
|
-
const same = signature.length === item.signature.length && signature.every((value, i) => value === item.signature[i]);
|
|
277
|
-
if (!same) {
|
|
278
|
-
item.signature.length = 0;
|
|
279
|
-
item.signature.push(...signature);
|
|
280
|
-
}
|
|
281
|
-
return !same;
|
|
282
|
-
};
|
|
283
|
-
/** Shadows of `VDBFrameVolume`s on meshes, owned by a {@link VDBFrameRenderer} (`frameRenderer.volumeShadows`). */
|
|
284
|
-
export class VDBFrameVolumeShadows {
|
|
122
|
+
/** The receivers of the core's volume shadow maps, owned by a {@link VDBFrameRenderer} (`frameRenderer.volumeShadows`). */
|
|
123
|
+
export class VDBFrameVolumeShadowReceivers {
|
|
285
124
|
entries = new Map();
|
|
286
|
-
scene = new THREE.Scene();
|
|
287
|
-
rayUniforms = createShadowRayUniforms();
|
|
288
|
-
material;
|
|
289
|
-
mesh;
|
|
290
125
|
frameRenderer;
|
|
291
|
-
// NOTE Replaced
|
|
126
|
+
// NOTE Replaced shadow nodes, stand-ins and attributes. update() runs mid-render, so the next update() disposes them.
|
|
292
127
|
retired = [];
|
|
293
128
|
renderCount = 0;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
129
|
+
#renderId = -1;
|
|
130
|
+
#camera = null;
|
|
131
|
+
#renderer = null;
|
|
132
|
+
#names = 0;
|
|
133
|
+
#placeholders = null;
|
|
134
|
+
/** Map pieces drawn in the last update, and how many waited for the budget (not his; tests and timing). */
|
|
297
135
|
lastUpdate = { drawn: 0, waiting: 0 };
|
|
298
136
|
constructor(frameRenderer) {
|
|
299
137
|
this.frameRenderer = frameRenderer;
|
|
300
|
-
this.material = new VDBFrameVolumeShadowMaterial(frameRenderer, this.rayUniforms);
|
|
301
|
-
this.mesh = new THREE.Mesh(createFullscreenGeometry(), this.material);
|
|
302
|
-
this.mesh.frustumCulled = false;
|
|
303
|
-
this.scene.matrixWorldAutoUpdate = false;
|
|
304
|
-
this.scene.add(this.mesh);
|
|
305
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* The map size of the settings (`castShadowMapSize`, or his coarse size). The core clamps it to the device's limits
|
|
141
|
+
* (K6.10a); `sync` takes the size of the map the core made.
|
|
142
|
+
*/
|
|
306
143
|
getMapSize() {
|
|
307
144
|
const { settings } = this.frameRenderer;
|
|
308
145
|
return settings.castShadowCoarse ? frameShadowCoarseMapSize : Math.max(1, Math.round(settings.castShadowMapSize));
|
|
309
146
|
}
|
|
310
|
-
|
|
311
|
-
return this.frameRenderer.settings.spectral === true;
|
|
312
|
-
}
|
|
313
|
-
getSteps() {
|
|
314
|
-
const { settings } = this.frameRenderer;
|
|
315
|
-
return settings.castShadowCoarse ? frameShadowCoarseSteps : THREE.MathUtils.clamp(Math.round(settings.castShadowSteps), 1, frameMaxCastShadowSteps);
|
|
316
|
-
}
|
|
317
|
-
getEntry(renderer, light) {
|
|
147
|
+
#entry(light) {
|
|
318
148
|
let entry = this.entries.get(light);
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
enabled: uniform(0, "int"),
|
|
338
|
-
// NOTE Current camera values. drawn: the values of the last draw, for the receivers.
|
|
339
|
-
rayUniforms: createShadowRayUniforms(),
|
|
340
|
-
drawn: {
|
|
341
|
-
origin: new THREE.Vector3(),
|
|
342
|
-
forward: new THREE.Vector3(0.0, 0.0, -1.0),
|
|
343
|
-
perspective: 0,
|
|
344
|
-
far: 1.0,
|
|
345
|
-
cascadeCount: 0,
|
|
346
|
-
cascadeBreaks: new THREE.Vector4(),
|
|
347
|
-
},
|
|
348
|
-
// NOTE Spot map or cube map (all faces in one draw), or the split layout of the cascades
|
|
349
|
-
item: { signature: [], lastDraw: -1 },
|
|
350
|
-
cascadeCount: 0,
|
|
351
|
-
cascadeBreaks: new THREE.Vector4(),
|
|
352
|
-
cascades: light.isDirectionalLight
|
|
353
|
-
? Array.from({ length: frameMaxShadowMapCascades }, () => ({
|
|
354
|
-
camera: new THREE.OrthographicCamera(),
|
|
355
|
-
viewProjection: new THREE.Matrix4(),
|
|
356
|
-
origin: new THREE.Vector3(),
|
|
357
|
-
far: 1.0,
|
|
358
|
-
signature: [],
|
|
359
|
-
lastDraw: -1,
|
|
360
|
-
drawn: { viewProjection: new THREE.Matrix4(), origin: new THREE.Vector3(), far: 1.0 },
|
|
361
|
-
}))
|
|
362
|
-
: null,
|
|
363
|
-
receiver: null,
|
|
364
|
-
userFilter: null,
|
|
365
|
-
};
|
|
366
|
-
entry.receiver = createReceiverUniforms(entry);
|
|
367
|
-
this.entries.set(light, entry);
|
|
368
|
-
}
|
|
149
|
+
if (entry)
|
|
150
|
+
return entry;
|
|
151
|
+
const isPoint = light.isPointLight === true;
|
|
152
|
+
entry = {
|
|
153
|
+
light,
|
|
154
|
+
isPoint,
|
|
155
|
+
size: this.getMapSize(),
|
|
156
|
+
coreMap: null,
|
|
157
|
+
lastDraw: -1,
|
|
158
|
+
userFilter: null,
|
|
159
|
+
texture: null,
|
|
160
|
+
binding: new VDBCoreTextureBinding(isPoint ? "cube" : "2d-array"),
|
|
161
|
+
rgbTexture: null,
|
|
162
|
+
rgbBinding: new VDBCoreTextureBinding(isPoint ? "cube" : "2d-array"),
|
|
163
|
+
viewBuffer: null,
|
|
164
|
+
nodes: null,
|
|
165
|
+
};
|
|
166
|
+
this.entries.set(light, entry);
|
|
369
167
|
return entry;
|
|
370
168
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if (
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
169
|
+
#placeholdersOf(device) {
|
|
170
|
+
const p = this.#placeholders;
|
|
171
|
+
if (p && p.device === device)
|
|
172
|
+
return p;
|
|
173
|
+
this.#destroyPlaceholders();
|
|
174
|
+
const make = (layers, what) => device.createTexture({ label: `@pmndrs/vdb/three volume shadow placeholder ${what}`, size: [1, 1, layers], format: "rgba16float", usage: 0x04 /* TEXTURE_BINDING */ });
|
|
175
|
+
// A zero view: info.w (enabled) 0, so every receiver function returns 1 without sampling
|
|
176
|
+
const view = device.createBuffer({ label: "@pmndrs/vdb/three volume shadow placeholder view", size: VDB_VOLUME_SHADOW_VIEW.size, usage: 0x80 /* STORAGE */ });
|
|
177
|
+
return (this.#placeholders = { device, array: make(1, "2d-array"), cube: make(6, "cube"), view });
|
|
178
|
+
}
|
|
179
|
+
#destroyPlaceholders() {
|
|
180
|
+
const p = this.#placeholders;
|
|
181
|
+
if (!p)
|
|
182
|
+
return;
|
|
183
|
+
// NOTE A bind group of this render may still name them: destroy after the task that submits it
|
|
184
|
+
const destroy = () => {
|
|
185
|
+
p.array.destroy();
|
|
186
|
+
p.cube.destroy();
|
|
187
|
+
p.view.destroy();
|
|
188
|
+
};
|
|
189
|
+
setTimeout(destroy, 0);
|
|
190
|
+
this.#placeholders = null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The light's texture and view nodes (made at its first receiver build, bound to placeholders until the core draws a
|
|
194
|
+
* map). @internal
|
|
195
|
+
*/
|
|
196
|
+
nodesOf(entry) {
|
|
197
|
+
if (entry.nodes)
|
|
198
|
+
return entry.nodes;
|
|
199
|
+
const renderer = this.#renderer;
|
|
200
|
+
if (!renderer)
|
|
201
|
+
throw new Error("VDBFrameVolumeShadowReceivers: a receiver was built before update() saw the renderer");
|
|
202
|
+
const p = this.#placeholdersOf(getDevice(renderer));
|
|
203
|
+
entry.binding.set(entry.texture ?? (entry.isPoint ? p.cube : p.array));
|
|
204
|
+
entry.rgbBinding.set(entry.rgbTexture ?? (entry.isPoint ? p.cube : p.array));
|
|
205
|
+
const make = entry.isPoint ? cubeTexture : texture;
|
|
206
|
+
const k = this.#names++;
|
|
207
|
+
const view = storage(this.#viewStandIn(entry.viewBuffer ?? p.view, k), "uvec4", VIEW_WORDS).toReadOnly();
|
|
208
|
+
view.setName(`vdbShadowView${k}`);
|
|
209
|
+
entry.nodes = {
|
|
210
|
+
k,
|
|
211
|
+
map: make(entry.binding.texture),
|
|
212
|
+
rgb: make(entry.rgbBinding.texture),
|
|
213
|
+
view,
|
|
214
|
+
loader: new VDBFrameStructLoaderNode(view, VDB_VOLUME_SHADOW_VIEW, `vdbFrameShadowView${k}`),
|
|
215
|
+
fns: new Map(),
|
|
216
|
+
};
|
|
217
|
+
return entry.nodes;
|
|
218
|
+
}
|
|
219
|
+
#viewStandIn(buffer, k) {
|
|
220
|
+
return vdbThreeStorageStandIn(this.#renderer, buffer, `vdbShadowView${k}`);
|
|
221
|
+
}
|
|
222
|
+
/** The `wgslFn` of a light's receivers (grey or rgb; the point variants take no view depth). @internal */
|
|
223
|
+
receiverFn(entry, rgb) {
|
|
224
|
+
const nodes = this.nodesOf(entry);
|
|
225
|
+
const key = rgb ? "rgb" : "grey";
|
|
226
|
+
let fn = nodes.fns.get(key);
|
|
227
|
+
if (fn)
|
|
228
|
+
return fn;
|
|
229
|
+
const view = `${nodes.loader.fnName}()`;
|
|
230
|
+
const name = `${nodes.loader.fnName.replace("View", "Receiver")}${rgb ? "Rgb" : ""}`;
|
|
231
|
+
const map = entry.isPoint ? "texture_cube<f32>" : "texture_2d_array<f32>";
|
|
232
|
+
const source = entry.isPoint
|
|
233
|
+
? rgb
|
|
234
|
+
? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f) -> vec3f {\n return vdbVolumeShadowCubeRgb(map, rgb, smp, ${view}, world);\n}`
|
|
235
|
+
: `fn ${name}(map: ${map}, smp: sampler, world: vec3f) -> f32 {\n return vdbVolumeShadowCube(map, smp, ${view}, world);\n}`
|
|
236
|
+
: rgb
|
|
237
|
+
? `fn ${name}(map: ${map}, rgb: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> vec3f {\n return vdbVolumeShadowRgb(map, rgb, smp, ${view}, world, viewDepth);\n}`
|
|
238
|
+
: `fn ${name}(map: ${map}, smp: sampler, world: vec3f, viewDepth: f32) -> f32 {\n return vdbVolumeShadow(map, smp, ${view}, world, viewDepth);\n}`;
|
|
239
|
+
fn = wgslFn(source, [receiverCodeNode(), nodes.loader]);
|
|
240
|
+
nodes.fns.set(key, fn);
|
|
241
|
+
return fn;
|
|
242
|
+
}
|
|
243
|
+
// NOTE Frees a light's entry and puts back its own filter. Receivers build again without the volume shadow.
|
|
244
|
+
#free(entry) {
|
|
397
245
|
const { light } = entry;
|
|
398
|
-
const targets = entry.spectralTarget ? [entry.target, entry.spectralTarget] : [entry.target];
|
|
399
246
|
const shadow = light.shadow;
|
|
400
|
-
// NOTE Receivers that still have the volume shadow node until they build again read
|
|
401
|
-
entry
|
|
402
|
-
if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
|
|
247
|
+
// NOTE Receivers that still have the volume shadow node until they build again read the placeholders
|
|
248
|
+
this.#bind(entry, null);
|
|
249
|
+
if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
|
|
403
250
|
shadow.filterNode = entry.userFilter;
|
|
404
|
-
|
|
405
|
-
|
|
251
|
+
const old = resetLightShadow(light);
|
|
252
|
+
if (old)
|
|
253
|
+
this.retired.push(old);
|
|
254
|
+
this.retired.push(entry.binding, entry.rgbBinding);
|
|
255
|
+
if (entry.nodes)
|
|
256
|
+
this.retired.push(entry.nodes.view.value);
|
|
406
257
|
this.entries.delete(light);
|
|
407
258
|
}
|
|
408
|
-
disposeRetired() {
|
|
259
|
+
#disposeRetired() {
|
|
409
260
|
this.retired.forEach((resource) => resource.dispose());
|
|
410
261
|
this.retired.length = 0;
|
|
411
262
|
}
|
|
412
|
-
|
|
413
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Puts the volume filter on each shadow light (new lights and new filters are found each render); frees the entries
|
|
265
|
+
* of lights with no shadow or not in a scene, and all entries when `castShadows` is off.
|
|
266
|
+
*/
|
|
414
267
|
update(renderer, scene) {
|
|
415
|
-
this
|
|
268
|
+
this.#disposeRetired();
|
|
269
|
+
this.#renderer = renderer;
|
|
416
270
|
if (!this.frameRenderer.settings.castShadows) {
|
|
417
|
-
this.entries.forEach((entry) => this
|
|
271
|
+
this.entries.forEach((entry) => this.#free(entry));
|
|
418
272
|
return;
|
|
419
273
|
}
|
|
420
274
|
// NOTE The light-shadow reset (three internal) is self-tested before the first filter goes on a light
|
|
421
275
|
vdbFrameCheckLightReset();
|
|
422
|
-
const size = this.getMapSize();
|
|
423
|
-
const spectral = this.isSpectral();
|
|
424
276
|
this.entries.forEach((entry) => {
|
|
425
|
-
if (!isShadowLight(entry.light) || !isInScene(entry.light))
|
|
426
|
-
this
|
|
427
|
-
}
|
|
428
|
-
else if (entry.size !== size || entry.spectral !== spectral) {
|
|
429
|
-
this.resizeMap(renderer, entry, size, spectral);
|
|
430
|
-
}
|
|
277
|
+
if (!isShadowLight(entry.light) || !isInScene(entry.light))
|
|
278
|
+
this.#free(entry);
|
|
431
279
|
});
|
|
432
280
|
scene.traverse((light) => {
|
|
433
|
-
if (isShadowLight(light))
|
|
434
|
-
this
|
|
435
|
-
}
|
|
281
|
+
if (isShadowLight(light))
|
|
282
|
+
this.#install(renderer, light);
|
|
436
283
|
});
|
|
437
284
|
}
|
|
438
|
-
install(renderer, light) {
|
|
285
|
+
#install(renderer, light) {
|
|
439
286
|
const shadow = light.shadow;
|
|
440
|
-
if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
|
|
287
|
+
if (shadow.filterNode?.isVDBFrameVolumeShadowFilter)
|
|
441
288
|
return;
|
|
442
|
-
|
|
443
|
-
const entry = this.getEntry(renderer, light);
|
|
289
|
+
const entry = this.#entry(light);
|
|
444
290
|
const userFilter = shadow.filterNode ?? null;
|
|
445
291
|
const filters = vdbFrameShadowFilters();
|
|
446
292
|
entry.userFilter = userFilter;
|
|
447
293
|
// NOTE ShadowNode calls the filter when it builds. The base filter is three's or the user's.
|
|
448
|
-
// Point lights give the direction from the light (bd3D), other lights give shadowCoord.
|
|
294
|
+
// Point lights give the direction from the light (bd3D), other lights give shadowCoord. The volume shadow node
|
|
295
|
+
// does not use them: it finds its map coordinate from the drawn state.
|
|
449
296
|
const filter = (inputs) => {
|
|
450
297
|
vdbFrameCheckFilterInputs(inputs, entry.isPoint);
|
|
451
298
|
const type = renderer.shadowMap.type;
|
|
452
299
|
const baseFilter = (userFilter ?? (entry.isPoint ? (type === THREE.BasicShadowMap ? filters.basicPoint : filters.point) : filters.maps[type]));
|
|
453
|
-
if (!baseFilter)
|
|
300
|
+
if (!baseFilter)
|
|
454
301
|
throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");
|
|
455
|
-
}
|
|
456
302
|
// NOTE PointShadowNode calls the filter in a TSL function, and its parameter proxy loses the shadow object.
|
|
457
303
|
// So the base filter gets a plain object with the light shadow.
|
|
458
304
|
const baseInputs = entry.isPoint
|
|
459
305
|
? { depthTexture: inputs.depthTexture, bd3D: inputs.bd3D, dp: inputs.dp, distance: inputs.distance }
|
|
460
306
|
: { depthTexture: inputs.depthTexture, shadowCoord: inputs.shadowCoord, depthLayer: inputs.depthLayer };
|
|
461
307
|
baseInputs.shadow = shadow;
|
|
462
|
-
|
|
463
|
-
return baseFilter(baseInputs).mul(new VDBFrameVolumeShadowNode(this, entry, uv));
|
|
308
|
+
return baseFilter(baseInputs).mul(new VDBFrameVolumeShadowNode(this, entry));
|
|
464
309
|
};
|
|
465
310
|
filter.isVDBFrameVolumeShadowFilter = true;
|
|
466
311
|
shadow.filterNode = filter;
|
|
467
312
|
// NOTE The map exists when the shadow node was built before this filter
|
|
468
313
|
if (shadow.map) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
// NOTE Spot lights: the light shadow camera. Point lights: a cube camera at the light. Sets the ray uniforms.
|
|
473
|
-
prepareCamera(entry) {
|
|
474
|
-
const { light, rayUniforms } = entry;
|
|
475
|
-
const shadowCamera = light.shadow.camera;
|
|
476
|
-
if (!entry.isPoint) {
|
|
477
|
-
light.shadow.updateMatrices(light);
|
|
478
|
-
rayUniforms.frameShadowOrigin.value.setFromMatrixPosition(shadowCamera.matrixWorld);
|
|
479
|
-
shadowCamera.getWorldDirection(rayUniforms.frameShadowForward.value);
|
|
480
|
-
rayUniforms.frameShadowPerspective.value = shadowCamera.isPerspectiveCamera ? 1 : 0;
|
|
481
|
-
rayUniforms.frameShadowFar.value = shadowCamera.far;
|
|
482
|
-
return shadowCamera;
|
|
483
|
-
}
|
|
484
|
-
const cubeCamera = entry.cubeCamera;
|
|
485
|
-
const near = shadowCamera.near;
|
|
486
|
-
const far = light.distance || shadowCamera.far;
|
|
487
|
-
for (const camera of cubeCamera.children) {
|
|
488
|
-
if (camera.near !== near || camera.far !== far) {
|
|
489
|
-
camera.near = near;
|
|
490
|
-
camera.far = far;
|
|
491
|
-
camera.updateProjectionMatrix();
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
cubeCamera.position.setFromMatrixPosition(light.matrixWorld);
|
|
495
|
-
cubeCamera.updateMatrixWorld();
|
|
496
|
-
rayUniforms.frameShadowOrigin.value.copy(cubeCamera.position);
|
|
497
|
-
rayUniforms.frameShadowPerspective.value = 1;
|
|
498
|
-
rayUniforms.frameShadowFar.value = far;
|
|
499
|
-
return cubeCamera.children[0];
|
|
500
|
-
}
|
|
501
|
-
// NOTE Cascade cameras of a directional light, the method of three's CSMShadowNode: practical split of the view
|
|
502
|
-
// depth, a light-aligned orthographic camera for each slice, size from the slice diagonal, position snapped to
|
|
503
|
-
// texels. The depth range of each camera covers the slice and the volume box (the last grid cascade). Cascades end
|
|
504
|
-
// at the far corner of the volume box plus one box diagonal, up to castShadowDistance, rounded to half octaves.
|
|
505
|
-
fitCascades(entry, camera, renderer) {
|
|
506
|
-
const { light, size, rayUniforms } = entry;
|
|
507
|
-
const cascades = entry.cascades;
|
|
508
|
-
const { settings, gridUniforms } = this.frameRenderer;
|
|
509
|
-
const count = THREE.MathUtils.clamp(Math.round(settings.castShadowCascades), 1, frameMaxShadowMapCascades);
|
|
510
|
-
const last = gridUniforms.frameGridCount.value - 1;
|
|
511
|
-
const cam = camera;
|
|
512
|
-
const near = cam.near;
|
|
513
|
-
const gridMin = gridUniforms.frameGridMin.array;
|
|
514
|
-
const gridSize = gridUniforms.frameGridSize.array;
|
|
515
|
-
casterWorldBox.min.copy(gridMin[last]);
|
|
516
|
-
casterWorldBox.max.copy(gridMin[last]).add(gridSize[last]);
|
|
517
|
-
let boxFar = 0.0;
|
|
518
|
-
for (let i = 0; i < 8; i++) {
|
|
519
|
-
point
|
|
520
|
-
.set(i & 1 ? casterWorldBox.max.x : casterWorldBox.min.x, i & 2 ? casterWorldBox.max.y : casterWorldBox.min.y, i & 4 ? casterWorldBox.max.z : casterWorldBox.min.z)
|
|
521
|
-
.applyMatrix4(camera.matrixWorldInverse);
|
|
522
|
-
boxFar = Math.max(boxFar, -point.z);
|
|
523
|
-
}
|
|
524
|
-
const far = vdbFrameShadowCascadeFar(near, cam.far, settings.castShadowDistance, boxFar, casterWorldBox.getSize(point).length());
|
|
525
|
-
const breaks = vdbFrameShadowCascadeBreaks(count, near, far);
|
|
526
|
-
lightDirection.setFromMatrixPosition(light.target.matrixWorld).sub(point.setFromMatrixPosition(light.matrixWorld)).normalize();
|
|
527
|
-
// NOTE Rotation of a camera that looks along the light (Object3D.lookAt of a camera). Up is +z for vertical light.
|
|
528
|
-
lightUp.set(0.0, 1.0, 0.0);
|
|
529
|
-
if (Math.abs(lightDirection.y) > 0.999) {
|
|
530
|
-
lightUp.set(0.0, 0.0, 1.0);
|
|
531
|
-
}
|
|
532
|
-
lightView.lookAt(point.set(0.0, 0.0, 0.0), lightDirection, lightUp);
|
|
533
|
-
lightViewInverse.copy(lightView).invert();
|
|
534
|
-
casterBox.copy(casterWorldBox).applyMatrix4(lightViewInverse);
|
|
535
|
-
entry.cascadeCount = count;
|
|
536
|
-
entry.cascadeBreaks.set(breaks[Math.min(0, count - 1)], breaks[Math.min(1, count - 1)], breaks[Math.min(2, count - 1)], breaks[Math.min(3, count - 1)]);
|
|
537
|
-
for (let i = 0; i < count; i++) {
|
|
538
|
-
const cascade = cascades[i];
|
|
539
|
-
const cascadeCamera = cascade.camera;
|
|
540
|
-
getSliceCorners(camera, i === 0 ? near : breaks[i - 1], breaks[i]);
|
|
541
|
-
const width = Math.max(farCorners[0].distanceTo(farCorners[2]), farCorners[0].distanceTo(nearCorners[2]));
|
|
542
|
-
const texel = width / size;
|
|
543
|
-
sliceBox.makeEmpty();
|
|
544
|
-
for (const corner of [...nearCorners, ...farCorners]) {
|
|
545
|
-
sliceBox.expandByPoint(point.copy(corner).applyMatrix4(lightViewInverse));
|
|
546
|
-
}
|
|
547
|
-
const centerX = Math.floor(((sliceBox.min.x + sliceBox.max.x) * 0.5) / texel) * texel;
|
|
548
|
-
const centerY = Math.floor(((sliceBox.min.y + sliceBox.max.y) * 0.5) / texel) * texel;
|
|
549
|
-
const front = Math.max(sliceBox.max.z, casterBox.max.z) + frameShadowCascadeMargin;
|
|
550
|
-
const back = Math.min(sliceBox.min.z, casterBox.min.z) - frameShadowCascadeMargin;
|
|
551
|
-
cascadeCamera.left = -width * 0.5;
|
|
552
|
-
cascadeCamera.right = width * 0.5;
|
|
553
|
-
cascadeCamera.top = width * 0.5;
|
|
554
|
-
cascadeCamera.bottom = -width * 0.5;
|
|
555
|
-
cascadeCamera.near = 0.0;
|
|
556
|
-
cascadeCamera.far = front - back;
|
|
557
|
-
cascadeCamera.coordinateSystem = renderer.coordinateSystem;
|
|
558
|
-
cascadeCamera.updateProjectionMatrix();
|
|
559
|
-
// NOTE Light view looks along -z, so the camera is at the front (largest z)
|
|
560
|
-
cascadeCamera.position.set(centerX, centerY, front).applyMatrix4(lightView);
|
|
561
|
-
cascadeCamera.quaternion.setFromRotationMatrix(lightView);
|
|
562
|
-
cascadeCamera.updateMatrixWorld();
|
|
563
|
-
cascade.viewProjection.multiplyMatrices(cascadeCamera.projectionMatrix, cascadeCamera.matrixWorldInverse);
|
|
564
|
-
cascade.origin.copy(cascadeCamera.position);
|
|
565
|
-
cascade.far = cascadeCamera.far;
|
|
566
|
-
}
|
|
567
|
-
cascades[0].camera.getWorldDirection(rayUniforms.frameShadowForward.value);
|
|
568
|
-
rayUniforms.frameShadowPerspective.value = 0;
|
|
569
|
-
return count;
|
|
570
|
-
}
|
|
571
|
-
// NOTE Copies ray values to the uniforms of the pass material
|
|
572
|
-
setPassRay(origin, forward, perspective, far) {
|
|
573
|
-
this.rayUniforms.frameShadowOrigin.value.copy(origin);
|
|
574
|
-
this.rayUniforms.frameShadowForward.value.copy(forward);
|
|
575
|
-
this.rayUniforms.frameShadowPerspective.value = perspective;
|
|
576
|
-
this.rayUniforms.frameShadowFar.value = far;
|
|
577
|
-
}
|
|
578
|
-
// NOTE Draws the pass into the map of the entry: one tile of it (viewport), or all cube faces (point lights)
|
|
579
|
-
drawPass(renderer, entry, camera, viewport) {
|
|
580
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
581
|
-
const currentActiveCubeFace = renderer.getActiveCubeFace();
|
|
582
|
-
const currentActiveMipmapLevel = renderer.getActiveMipmapLevel();
|
|
583
|
-
const currentAutoClear = renderer.autoClear;
|
|
584
|
-
const currentClearAlpha = renderer.getClearAlpha();
|
|
585
|
-
const currentScissorTest = renderer.getScissorTest();
|
|
586
|
-
renderer.getClearColor(clearColor);
|
|
587
|
-
renderer.autoClear = false;
|
|
588
|
-
renderer.setScissorTest(false);
|
|
589
|
-
this.mesh.layers.mask = camera.layers.mask;
|
|
590
|
-
// NOTE Spectral: the second draw writes the optical depth of each channel into the second map
|
|
591
|
-
const targets = entry.spectralTarget ? [entry.target, entry.spectralTarget] : [entry.target];
|
|
592
|
-
targets.forEach((target, output) => {
|
|
593
|
-
this.material.frameShadowOutput.value = output;
|
|
594
|
-
if (entry.isPoint) {
|
|
595
|
-
const cubeCamera = entry.cubeCamera;
|
|
596
|
-
cubeCamera.renderTarget = target;
|
|
597
|
-
cubeCamera.update(renderer, this.scene);
|
|
598
|
-
}
|
|
599
|
-
else {
|
|
600
|
-
target.viewport.copy(viewport);
|
|
601
|
-
renderer.setRenderTarget(target);
|
|
602
|
-
renderer.render(this.scene, camera);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
if (entry.isPoint) {
|
|
606
|
-
entry.cubeCamera.renderTarget = entry.target;
|
|
314
|
+
const old = resetLightShadow(light);
|
|
315
|
+
if (old)
|
|
316
|
+
this.retired.push(old);
|
|
607
317
|
}
|
|
608
|
-
renderer.setScissorTest(currentScissorTest);
|
|
609
|
-
renderer.autoClear = currentAutoClear;
|
|
610
|
-
renderer.setClearColor(clearColor, currentClearAlpha);
|
|
611
|
-
renderer.setRenderTarget(currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel);
|
|
612
318
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const steps = this.getSteps();
|
|
617
|
-
const { drawn, rayUniforms } = entry;
|
|
618
|
-
if (entry.cascades) {
|
|
619
|
-
const cascades = entry.cascades;
|
|
620
|
-
const count = this.fitCascades(entry, camera, renderer);
|
|
621
|
-
const forward = rayUniforms.frameShadowForward.value;
|
|
622
|
-
const drawCascade = (i) => {
|
|
623
|
-
const cascade = cascades[i];
|
|
624
|
-
this.setPassRay(cascade.origin, forward, 0, cascade.far);
|
|
625
|
-
this.drawPass(renderer, entry, cascade.camera, tileViewport.set(i * entry.size, 0, entry.size, entry.size));
|
|
626
|
-
cascade.drawn.viewProjection.copy(cascade.viewProjection);
|
|
627
|
-
cascade.drawn.origin.copy(cascade.origin);
|
|
628
|
-
cascade.drawn.far = cascade.far;
|
|
629
|
-
cascade.lastDraw = this.renderCount;
|
|
630
|
-
drawn.forward.copy(forward);
|
|
631
|
-
};
|
|
632
|
-
const cascadeChanged = (i) => {
|
|
633
|
-
const cascade = cascades[i];
|
|
634
|
-
signature.length = 0;
|
|
635
|
-
signature.push(entry.size, castVersion, steps, ...cascade.camera.matrixWorld.elements);
|
|
636
|
-
signature.push(...cascade.camera.projectionMatrix.elements);
|
|
637
|
-
return changed(cascade);
|
|
638
|
-
};
|
|
639
|
-
// NOTE A new split layout: one piece draws all cascades, then the receivers switch to the layout.
|
|
640
|
-
// Receivers never mix tiles of two layouts.
|
|
641
|
-
signature.length = 0;
|
|
642
|
-
signature.push(entry.size, count, ...entry.cascadeBreaks.toArray());
|
|
643
|
-
if (changed(entry.item)) {
|
|
644
|
-
for (let i = 0; i < count; i++) {
|
|
645
|
-
cascadeChanged(i);
|
|
646
|
-
}
|
|
647
|
-
work.push({
|
|
648
|
-
item: entry.item,
|
|
649
|
-
cost: count,
|
|
650
|
-
draw: () => {
|
|
651
|
-
for (let i = 0; i < count; i++) {
|
|
652
|
-
drawCascade(i);
|
|
653
|
-
}
|
|
654
|
-
drawn.cascadeCount = count;
|
|
655
|
-
drawn.cascadeBreaks.copy(entry.cascadeBreaks);
|
|
656
|
-
},
|
|
657
|
-
});
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
for (let i = 0; i < count; i++) {
|
|
661
|
-
if (cascadeChanged(i)) {
|
|
662
|
-
work.push({ item: cascades[i], cost: 1, draw: () => drawCascade(i) });
|
|
663
|
-
}
|
|
664
|
-
}
|
|
319
|
+
/** Called by the receivers of every light: the core update of this render (once per render and camera). */
|
|
320
|
+
render(renderer, scene, camera, renderId) {
|
|
321
|
+
if (this.#renderId === renderId && this.#camera === camera)
|
|
665
322
|
return;
|
|
323
|
+
this.#renderId = renderId;
|
|
324
|
+
this.#camera = camera;
|
|
325
|
+
this.frameRenderer.coreFrame(renderer, scene, camera);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Points a light's nodes at a core map (null: the placeholders). The texture and storage nodes keep their identity;
|
|
329
|
+
* a new core texture or buffer gets a new stand-in as the node's `value`, and the old attribute is disposed at the next
|
|
330
|
+
* update. Returns whether anything changed (the caller rebuilds the receivers: see `sync`).
|
|
331
|
+
*/
|
|
332
|
+
#bind(entry, m) {
|
|
333
|
+
entry.coreMap = m;
|
|
334
|
+
const nodes = entry.nodes;
|
|
335
|
+
const p = nodes ? this.#placeholders : null;
|
|
336
|
+
const texture = m?.texture ?? null;
|
|
337
|
+
const rgb = m?.rgbTexture ?? null;
|
|
338
|
+
const view = m?.view ?? null;
|
|
339
|
+
const changed = texture !== entry.texture || rgb !== entry.rgbTexture || view !== entry.viewBuffer;
|
|
340
|
+
if (texture !== entry.texture) {
|
|
341
|
+
entry.texture = texture;
|
|
342
|
+
if (nodes && p)
|
|
343
|
+
this.#setTexture(entry.binding, nodes.map, texture ?? (entry.isPoint ? p.cube : p.array));
|
|
666
344
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
if (!changed(entry.item)) {
|
|
672
|
-
return;
|
|
345
|
+
if (rgb !== entry.rgbTexture) {
|
|
346
|
+
entry.rgbTexture = rgb;
|
|
347
|
+
if (nodes && p)
|
|
348
|
+
this.#setTexture(entry.rgbBinding, nodes.rgb, rgb ?? (entry.isPoint ? p.cube : p.array));
|
|
673
349
|
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
this.
|
|
680
|
-
|
|
681
|
-
drawn.origin.copy(rayUniforms.frameShadowOrigin.value);
|
|
682
|
-
drawn.forward.copy(rayUniforms.frameShadowForward.value);
|
|
683
|
-
drawn.perspective = rayUniforms.frameShadowPerspective.value;
|
|
684
|
-
drawn.far = rayUniforms.frameShadowFar.value;
|
|
685
|
-
},
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
// NOTE Volume shadow maps of all lights, one time in each render, before the first receiver.
|
|
689
|
-
// Changed pieces are drawn oldest first, up to castShadowUpdatesPerFrame (a tile or spot map costs 1, a cube map 6).
|
|
690
|
-
// The oldest piece is always drawn. Then a large piece does not wait forever.
|
|
691
|
-
updateMaps(renderer, scene, camera, renderId) {
|
|
692
|
-
if (this.mapsRenderId === renderId && this.mapsCamera === camera) {
|
|
693
|
-
return;
|
|
350
|
+
if (view !== entry.viewBuffer) {
|
|
351
|
+
entry.viewBuffer = view;
|
|
352
|
+
if (nodes && p) {
|
|
353
|
+
const old = nodes.view.value;
|
|
354
|
+
nodes.view.value = this.#viewStandIn(view ?? p.view, nodes.k);
|
|
355
|
+
this.retired.push(old);
|
|
356
|
+
}
|
|
694
357
|
}
|
|
695
|
-
|
|
696
|
-
|
|
358
|
+
return changed;
|
|
359
|
+
}
|
|
360
|
+
// NOTE VDBCoreTextureBinding.set disposes the old stand-in at once; three keeps the GPU texture it bound (an
|
|
361
|
+
// ExternalTexture's dispose never destroys it) and rebinds the node's new value at the next draw
|
|
362
|
+
#setTexture(binding, node, gpu) {
|
|
363
|
+
if (binding.set(gpu))
|
|
364
|
+
node.value = binding.texture;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* After a core update, each entry binds its core map (texture, rgb twin, view buffer) and reads the budget counters.
|
|
368
|
+
* The map size, the cascades and the drawn views live in the view buffer, so only a new core object (the first map, a
|
|
369
|
+
* new size, a spectral switch, a map that went away or came back) touches the receivers: their nodes get the new
|
|
370
|
+
* stand-ins and the light's receivers rebuild. The rebuild is needed: three r187 re-reads the object-group bindings
|
|
371
|
+
* (textures, storage buffers) of a plain material only on a full refresh, which a node `value` swap does not cause, so
|
|
372
|
+
* a receiver drawn with a shared refresh would keep the old bind group, and with it a texture the core retires
|
|
373
|
+
* (K6.10 finding 8). They rebuild at their next draw (the next render: this one may still draw with the old objects,
|
|
374
|
+
* which the core keeps alive for two more updates).
|
|
375
|
+
*/
|
|
376
|
+
sync(maps, stats) {
|
|
697
377
|
this.renderCount++;
|
|
698
|
-
this.lastUpdate.drawn =
|
|
699
|
-
this.lastUpdate.waiting =
|
|
700
|
-
const { frameRenderer } = this;
|
|
701
|
-
const ready = frameRenderer.settings.castShadows && !!renderer.isWebGPURenderer && frameRenderer.prepareShadowGrid(renderer, scene, camera, renderId);
|
|
702
|
-
if (!ready) {
|
|
703
|
-
this.entries.forEach((entry) => {
|
|
704
|
-
entry.enabled.value = 0;
|
|
705
|
-
entry.item.signature.length = 0;
|
|
706
|
-
entry.cascades?.forEach((cascade) => (cascade.signature.length = 0));
|
|
707
|
-
});
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
this.material.setSpectral(this.isSpectral());
|
|
711
|
-
this.material.frameShadowDensityMap.value = frameRenderer.shadowDensityTarget.textures[0];
|
|
712
|
-
this.material.frameShadowSteps.value = this.getSteps();
|
|
713
|
-
const work = [];
|
|
378
|
+
this.lastUpdate.drawn = stats.drawn;
|
|
379
|
+
this.lastUpdate.waiting = stats.waiting;
|
|
714
380
|
this.entries.forEach((entry) => {
|
|
715
|
-
const
|
|
716
|
-
entry
|
|
717
|
-
|
|
718
|
-
|
|
381
|
+
const m = maps.get(entry.light.id) ?? null;
|
|
382
|
+
if (this.#bind(entry, m) && entry.nodes) {
|
|
383
|
+
const old = resetLightShadow(entry.light);
|
|
384
|
+
if (old)
|
|
385
|
+
this.retired.push(old);
|
|
719
386
|
}
|
|
720
|
-
|
|
721
|
-
work.sort((a, b) => a.item.lastDraw - b.item.lastDraw);
|
|
722
|
-
let budget = Math.max(1, Math.round(frameRenderer.settings.castShadowUpdatesPerFrame));
|
|
723
|
-
frameRenderer.passHook?.begin?.("volumeShadows");
|
|
724
|
-
work.forEach((piece, index) => {
|
|
725
|
-
if (index > 0 && piece.cost > budget) {
|
|
726
|
-
// NOTE Not drawn: the next check sees the change again
|
|
727
|
-
piece.item.signature.length = 0;
|
|
728
|
-
this.lastUpdate.waiting++;
|
|
387
|
+
if (!m)
|
|
729
388
|
return;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
piece.item.lastDraw = this.renderCount;
|
|
733
|
-
budget -= piece.cost;
|
|
734
|
-
this.lastUpdate.drawn++;
|
|
389
|
+
entry.size = m.size;
|
|
390
|
+
entry.lastDraw = m.lastDraw[0] ?? entry.lastDraw;
|
|
735
391
|
});
|
|
736
|
-
frameRenderer.passHook?.end?.("volumeShadows");
|
|
737
392
|
}
|
|
738
|
-
|
|
739
|
-
render(renderer, scene, camera, renderId, entry) {
|
|
740
|
-
if (entry.renderId === renderId) {
|
|
741
|
-
return;
|
|
742
|
-
}
|
|
743
|
-
entry.renderId = renderId;
|
|
744
|
-
this.updateMaps(renderer, scene, camera, renderId);
|
|
745
|
-
}
|
|
746
|
-
// NOTE Puts back the filter of each light. Then a new VDBFrameVolumeShadows installs again.
|
|
393
|
+
/** Puts back the filter of each light (a later render installs again). */
|
|
747
394
|
dispose() {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
this
|
|
752
|
-
this
|
|
753
|
-
this
|
|
395
|
+
this.entries.forEach((entry) => this.#free(entry));
|
|
396
|
+
this.#disposeRetired();
|
|
397
|
+
this.#destroyPlaceholders();
|
|
398
|
+
this.#renderId = -1;
|
|
399
|
+
this.#camera = null;
|
|
400
|
+
this.#renderer = null;
|
|
754
401
|
}
|
|
755
402
|
}
|
|
756
403
|
//# sourceMappingURL=volume-shadows.js.map
|