@pmndrs/vdb 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The opt-in `'levelSet'` helper (K3.7, R1 §6 Step 7): a zero-crossing finder
|
|
3
|
+
* for NanoVDB level sets on the sparse tree, and its gradient normal. Written
|
|
4
|
+
* in the generated module's final names (public `vdb*` API plus the vendored
|
|
5
|
+
* HDDA fields it reads), emitted only when `helpers` lists it.
|
|
6
|
+
*
|
|
7
|
+
* Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
|
|
8
|
+
* (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`: the sphere
|
|
9
|
+
* trace with a minimum step, the secant step between the last outside and the
|
|
10
|
+
* first inside sample, central-difference normals). Copyright (c)
|
|
11
|
+
* mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: traced on
|
|
12
|
+
* the sparse NanoVDB tree (trilinear `vdbSample`, full resolution) instead of
|
|
13
|
+
* his dense 8-bit distance texture; an HDDA walk skips cells whose trilinear
|
|
14
|
+
* support is all tiles or background above zero; bisection before the secant
|
|
15
|
+
* step; normals through the grid's affine. See DIVERGES.md.
|
|
16
|
+
*
|
|
17
|
+
* CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`
|
|
18
|
+
* (`tools/cpu/level-set.ts`), same walk, same sample positions.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The WGSL text of the `'levelSet'` helper (`march` profile).
|
|
22
|
+
*
|
|
23
|
+
* - `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`: the first
|
|
24
|
+
* `t` in `(*t).x .. (*t).y` (clipped to the trilinear support box
|
|
25
|
+
* `[min - 1, max + 1]`) where the trilinear SDF `vdbSample` goes below 0,
|
|
26
|
+
* along `o + d * t` in grid `g`'s index space (`d` need not be unit length).
|
|
27
|
+
* On a hit `(*t).x` is the crossing; a ray whose first sample is already
|
|
28
|
+
* inside hits at that sample. `sdfToIndex` converts SDF values to index
|
|
29
|
+
* voxels (1 / the grid's voxel size for a level set in its own world units);
|
|
30
|
+
* the step is `max(0.95 * v * sdfToIndex, 0.25)` voxels. `maxSamples` caps
|
|
31
|
+
* the samples (a ray that runs out misses).
|
|
32
|
+
* - `vdbLevelSetGradient(acc, xyz, h) -> vec3f`: central differences of
|
|
33
|
+
* `vdbSample` at +/- `h` voxels, in SDF units per index voxel. `h <= 0`
|
|
34
|
+
* (G13c-a): the exact gradient of the trilinear cell holding `xyz` (the
|
|
35
|
+
* surface the trace hits): per axis the difference of `vdbSample` on the
|
|
36
|
+
* cell's two faces through `xyz` (trilinear is linear along each axis), the
|
|
37
|
+
* `h -> 0` limit inside the cell; discontinuous across cell faces.
|
|
38
|
+
* - `vdbLevelSetNormal(g, xyz, h) -> vec3f`: the outward unit normal in world
|
|
39
|
+
* space, `normalize(W^T * gradient)` with `W` the record's world-to-index
|
|
40
|
+
* linear part (correct under rotation and non-uniform scale).
|
|
41
|
+
*
|
|
42
|
+
* The walk: an HDDA over aligned cells of at least 8 voxels, the cell size
|
|
43
|
+
* following `vdbGetDim` at the cell corner (8 inside leaves and lower tiles,
|
|
44
|
+
* larger in upper and root tiles). A cell is skipped when the 2x2x2 block of
|
|
45
|
+
* same-size cells from its corner (every tap a trilinear sample in the cell can
|
|
46
|
+
* read) is all uniform (`vdbGetDim >= dim`) with values above 0: no sample in
|
|
47
|
+
* it can be inside. A larger cell that fails the test is walked again at 8.
|
|
48
|
+
* Other cells are sphere traced; a sample below 0 brackets the crossing with
|
|
49
|
+
* the previous sample, which 8 bisections and a secant step refine.
|
|
50
|
+
*
|
|
51
|
+
* Every `vdbSample` call site inlines the type-dispatched trilinear reader,
|
|
52
|
+
* so the gradient's six taps run in a loop (one site): with six sites a
|
|
53
|
+
* module took 98-168 s to compile on SwiftShader, with one 10-19 s. The hit
|
|
54
|
+
* keeps three sites (march, closing sample, bisection): folding them into one
|
|
55
|
+
* moded loop compiled faster again (6-11 s) but ran 2x slower on Metal
|
|
56
|
+
* (teapot frame 15.7 vs 8.0 ms). The sample sequence is the twin's.
|
|
57
|
+
*/
|
|
58
|
+
export function levelSetWgsl() {
|
|
59
|
+
return [
|
|
60
|
+
`fn vdb_ls_skip(acc: ptr<function, VdbAccessor>, c: vec3i, dim: u32) -> bool {
|
|
61
|
+
for (var k = 0u; k < 8u; k++) {
|
|
62
|
+
let p = c + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, (k >> 2u) & 1u)) * i32(dim);
|
|
63
|
+
if vdbGetDim(acc, p) < dim {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if !(vdbReadValue(acc, p) > 0.0) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}`,
|
|
72
|
+
`fn vdbLevelSetHit(g: u32, o: vec3f, d: vec3f, t: ptr<function, vec2f>, sdfToIndex: f32, maxSamples: u32) -> bool {
|
|
73
|
+
if !vdb_live(g) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
var t0 = (*t).x;
|
|
77
|
+
var t1 = (*t).y;
|
|
78
|
+
let clip = vdb_hdda_ray_clip(vec3f(vdbIndexMin(g)) - vec3f(1.0), vec3f(vdbIndexMax(g)) + vec3f(1.0), o, &t0, d, &t1);
|
|
79
|
+
if !clip || !(t0 <= t1) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
var acc = vdbAccessorInit(g);
|
|
83
|
+
if !acc.ok {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
let inv = 1.0 / max(length(d), 1e-30);
|
|
87
|
+
let minStep = 0.25 * inv;
|
|
88
|
+
let k = 0.95 * sdfToIndex * inv;
|
|
89
|
+
var h: VdbHdda;
|
|
90
|
+
vdbHddaInit(&h, o, t0, d, t1, max(vdbGetDim(&acc, vec3i(floor(o + d * t0))), 8u));
|
|
91
|
+
var tc = t0;
|
|
92
|
+
var tp = t0;
|
|
93
|
+
var vp = 0.0;
|
|
94
|
+
var have = false;
|
|
95
|
+
var n = 0u;
|
|
96
|
+
var updates = 0u;
|
|
97
|
+
var fineUntil = -3.0e38;
|
|
98
|
+
var crossed = false;
|
|
99
|
+
var vc = 0.0;
|
|
100
|
+
for (var it = 0u; it < 8192u; it++) {
|
|
101
|
+
var want = max(vdbGetDim(&acc, h.voxel), 8u);
|
|
102
|
+
if h.tmin < fineUntil {
|
|
103
|
+
want = 8u;
|
|
104
|
+
}
|
|
105
|
+
if want != u32(h.dim) && updates < 2u {
|
|
106
|
+
vdbHddaUpdate(&h, o, d, want);
|
|
107
|
+
updates++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
updates = 0u;
|
|
111
|
+
let te = min(min(h.next.x, h.next.y), min(h.next.z, h.tmax));
|
|
112
|
+
if te >= tc {
|
|
113
|
+
let dim = u32(h.dim);
|
|
114
|
+
if vdb_ls_skip(&acc, h.voxel, dim) {
|
|
115
|
+
tc = te;
|
|
116
|
+
} else if dim > 8u && te > h.tmin {
|
|
117
|
+
fineUntil = te;
|
|
118
|
+
vdbHddaUpdate(&h, o, d, 8u);
|
|
119
|
+
continue;
|
|
120
|
+
} else {
|
|
121
|
+
loop {
|
|
122
|
+
if tc > te || n >= maxSamples {
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
vc = vdbSample(&acc, o + d * tc);
|
|
126
|
+
n++;
|
|
127
|
+
if vc < 0.0 {
|
|
128
|
+
crossed = true;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
tp = tc;
|
|
132
|
+
vp = vc;
|
|
133
|
+
have = true;
|
|
134
|
+
tc += max(vc * k, minStep);
|
|
135
|
+
}
|
|
136
|
+
if crossed || n >= maxSamples {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if !vdbHddaStep(&h) {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if !crossed && have && tp < t1 && n < maxSamples {
|
|
146
|
+
tc = t1;
|
|
147
|
+
vc = vdbSample(&acc, o + d * tc);
|
|
148
|
+
crossed = vc < 0.0;
|
|
149
|
+
}
|
|
150
|
+
if !crossed {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if !have {
|
|
154
|
+
(*t).x = tc;
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
var lo = tp;
|
|
158
|
+
var hi = tc;
|
|
159
|
+
var vlo = vp;
|
|
160
|
+
var vhi = vc;
|
|
161
|
+
for (var i = 0u; i < 8u; i++) {
|
|
162
|
+
let m = 0.5 * (lo + hi);
|
|
163
|
+
let vm = vdbSample(&acc, o + d * m);
|
|
164
|
+
if vm < 0.0 {
|
|
165
|
+
hi = m;
|
|
166
|
+
vhi = vm;
|
|
167
|
+
} else {
|
|
168
|
+
lo = m;
|
|
169
|
+
vlo = vm;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
(*t).x = lo + (hi - lo) * (vlo / (vlo - vhi));
|
|
173
|
+
return true;
|
|
174
|
+
}`,
|
|
175
|
+
`fn vdbLevelSetGradient(acc: ptr<function, VdbAccessor>, xyz: vec3f, h: f32) -> vec3f {
|
|
176
|
+
let cell = !(h > 0.0);
|
|
177
|
+
let lo = floor(xyz);
|
|
178
|
+
var gr = vec3f(0.0);
|
|
179
|
+
for (var i = 0u; i < 6u; i++) {
|
|
180
|
+
let axis = i >> 1u;
|
|
181
|
+
let sgn = select(-1.0, 1.0, (i & 1u) == 0u);
|
|
182
|
+
var p = xyz;
|
|
183
|
+
p[axis] = select(xyz[axis] + sgn * h, lo[axis] + select(0.0, 1.0, sgn > 0.0), cell);
|
|
184
|
+
gr[axis] += sgn * vdbSample(acc, p);
|
|
185
|
+
}
|
|
186
|
+
return gr / select(2.0 * h, 1.0, cell);
|
|
187
|
+
}`,
|
|
188
|
+
`fn vdbLevelSetNormal(g: u32, xyz: vec3f, h: f32) -> vec3f {
|
|
189
|
+
var acc = vdbAccessorInit(g);
|
|
190
|
+
let gi = vdbLevelSetGradient(&acc, xyz, h);
|
|
191
|
+
let n = vec3f(dot(vdbWorldToIndexDir(g, vec3f(1.0, 0.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 1.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 0.0, 1.0)), gi));
|
|
192
|
+
let l = length(n);
|
|
193
|
+
if !(l > 0.0) {
|
|
194
|
+
return vec3f(0.0, 1.0, 0.0);
|
|
195
|
+
}
|
|
196
|
+
return n / l;
|
|
197
|
+
}`,
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=level-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level-set.js","sourceRoot":"","sources":["../../../src/core/wgsl/level-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL;;;;;;;;;;;EAWF;QACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsGF;QACE;;;;;;;;;;;;EAYF;QACE;;;;;;;;;EASF;KACC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The opt-in `'levelSet'` helper (K3.7, R1 §6 Step 7): a zero-crossing finder\n * for NanoVDB level sets on the sparse tree, and its gradient normal. Written\n * in the generated module's final names (public `vdb*` API plus the vendored\n * HDDA fields it reads), emitted only when `helpers` lists it.\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/three-openvdb/levelset/webgpu/LevelSetSurfaceMaterial.js`: the sphere\n * trace with a minimum step, the secant step between the last outside and the\n * first inside sample, central-difference normals). Copyright (c)\n * mjurczyk/openvdb contributors, MIT (see THIRD_PARTY_NOTICES.md). Changes: traced on\n * the sparse NanoVDB tree (trilinear `vdbSample`, full resolution) instead of\n * his dense 8-bit distance texture; an HDDA walk skips cells whose trilinear\n * support is all tiles or background above zero; bisection before the secant\n * step; normals through the grid's affine. See DIVERGES.md.\n *\n * CPU twins: `tools` `levelSetHit`, `levelSetGradient`, `levelSetNormal`\n * (`tools/cpu/level-set.ts`), same walk, same sample positions.\n */\n\n/**\n * The WGSL text of the `'levelSet'` helper (`march` profile).\n *\n * - `vdbLevelSetHit(g, o, d, t, sdfToIndex, maxSamples) -> bool`: the first\n * `t` in `(*t).x .. (*t).y` (clipped to the trilinear support box\n * `[min - 1, max + 1]`) where the trilinear SDF `vdbSample` goes below 0,\n * along `o + d * t` in grid `g`'s index space (`d` need not be unit length).\n * On a hit `(*t).x` is the crossing; a ray whose first sample is already\n * inside hits at that sample. `sdfToIndex` converts SDF values to index\n * voxels (1 / the grid's voxel size for a level set in its own world units);\n * the step is `max(0.95 * v * sdfToIndex, 0.25)` voxels. `maxSamples` caps\n * the samples (a ray that runs out misses).\n * - `vdbLevelSetGradient(acc, xyz, h) -> vec3f`: central differences of\n * `vdbSample` at +/- `h` voxels, in SDF units per index voxel. `h <= 0`\n * (G13c-a): the exact gradient of the trilinear cell holding `xyz` (the\n * surface the trace hits): per axis the difference of `vdbSample` on the\n * cell's two faces through `xyz` (trilinear is linear along each axis), the\n * `h -> 0` limit inside the cell; discontinuous across cell faces.\n * - `vdbLevelSetNormal(g, xyz, h) -> vec3f`: the outward unit normal in world\n * space, `normalize(W^T * gradient)` with `W` the record's world-to-index\n * linear part (correct under rotation and non-uniform scale).\n *\n * The walk: an HDDA over aligned cells of at least 8 voxels, the cell size\n * following `vdbGetDim` at the cell corner (8 inside leaves and lower tiles,\n * larger in upper and root tiles). A cell is skipped when the 2x2x2 block of\n * same-size cells from its corner (every tap a trilinear sample in the cell can\n * read) is all uniform (`vdbGetDim >= dim`) with values above 0: no sample in\n * it can be inside. A larger cell that fails the test is walked again at 8.\n * Other cells are sphere traced; a sample below 0 brackets the crossing with\n * the previous sample, which 8 bisections and a secant step refine.\n *\n * Every `vdbSample` call site inlines the type-dispatched trilinear reader,\n * so the gradient's six taps run in a loop (one site): with six sites a\n * module took 98-168 s to compile on SwiftShader, with one 10-19 s. The hit\n * keeps three sites (march, closing sample, bisection): folding them into one\n * moded loop compiled faster again (6-11 s) but ran 2x slower on Metal\n * (teapot frame 15.7 vs 8.0 ms). The sample sequence is the twin's.\n */\nexport function levelSetWgsl(): string[] {\n return [\n `fn vdb_ls_skip(acc: ptr<function, VdbAccessor>, c: vec3i, dim: u32) -> bool {\n for (var k = 0u; k < 8u; k++) {\n let p = c + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, (k >> 2u) & 1u)) * i32(dim);\n if vdbGetDim(acc, p) < dim {\n return false;\n }\n if !(vdbReadValue(acc, p) > 0.0) {\n return false;\n }\n }\n return true;\n}`,\n `fn vdbLevelSetHit(g: u32, o: vec3f, d: vec3f, t: ptr<function, vec2f>, sdfToIndex: f32, maxSamples: u32) -> bool {\n if !vdb_live(g) {\n return false;\n }\n var t0 = (*t).x;\n var t1 = (*t).y;\n let clip = vdb_hdda_ray_clip(vec3f(vdbIndexMin(g)) - vec3f(1.0), vec3f(vdbIndexMax(g)) + vec3f(1.0), o, &t0, d, &t1);\n if !clip || !(t0 <= t1) {\n return false;\n }\n var acc = vdbAccessorInit(g);\n if !acc.ok {\n return false;\n }\n let inv = 1.0 / max(length(d), 1e-30);\n let minStep = 0.25 * inv;\n let k = 0.95 * sdfToIndex * inv;\n var h: VdbHdda;\n vdbHddaInit(&h, o, t0, d, t1, max(vdbGetDim(&acc, vec3i(floor(o + d * t0))), 8u));\n var tc = t0;\n var tp = t0;\n var vp = 0.0;\n var have = false;\n var n = 0u;\n var updates = 0u;\n var fineUntil = -3.0e38;\n var crossed = false;\n var vc = 0.0;\n for (var it = 0u; it < 8192u; it++) {\n var want = max(vdbGetDim(&acc, h.voxel), 8u);\n if h.tmin < fineUntil {\n want = 8u;\n }\n if want != u32(h.dim) && updates < 2u {\n vdbHddaUpdate(&h, o, d, want);\n updates++;\n continue;\n }\n updates = 0u;\n let te = min(min(h.next.x, h.next.y), min(h.next.z, h.tmax));\n if te >= tc {\n let dim = u32(h.dim);\n if vdb_ls_skip(&acc, h.voxel, dim) {\n tc = te;\n } else if dim > 8u && te > h.tmin {\n fineUntil = te;\n vdbHddaUpdate(&h, o, d, 8u);\n continue;\n } else {\n loop {\n if tc > te || n >= maxSamples {\n break;\n }\n vc = vdbSample(&acc, o + d * tc);\n n++;\n if vc < 0.0 {\n crossed = true;\n break;\n }\n tp = tc;\n vp = vc;\n have = true;\n tc += max(vc * k, minStep);\n }\n if crossed || n >= maxSamples {\n break;\n }\n }\n }\n if !vdbHddaStep(&h) {\n break;\n }\n }\n if !crossed && have && tp < t1 && n < maxSamples {\n tc = t1;\n vc = vdbSample(&acc, o + d * tc);\n crossed = vc < 0.0;\n }\n if !crossed {\n return false;\n }\n if !have {\n (*t).x = tc;\n return true;\n }\n var lo = tp;\n var hi = tc;\n var vlo = vp;\n var vhi = vc;\n for (var i = 0u; i < 8u; i++) {\n let m = 0.5 * (lo + hi);\n let vm = vdbSample(&acc, o + d * m);\n if vm < 0.0 {\n hi = m;\n vhi = vm;\n } else {\n lo = m;\n vlo = vm;\n }\n }\n (*t).x = lo + (hi - lo) * (vlo / (vlo - vhi));\n return true;\n}`,\n `fn vdbLevelSetGradient(acc: ptr<function, VdbAccessor>, xyz: vec3f, h: f32) -> vec3f {\n let cell = !(h > 0.0);\n let lo = floor(xyz);\n var gr = vec3f(0.0);\n for (var i = 0u; i < 6u; i++) {\n let axis = i >> 1u;\n let sgn = select(-1.0, 1.0, (i & 1u) == 0u);\n var p = xyz;\n p[axis] = select(xyz[axis] + sgn * h, lo[axis] + select(0.0, 1.0, sgn > 0.0), cell);\n gr[axis] += sgn * vdbSample(acc, p);\n }\n return gr / select(2.0 * h, 1.0, cell);\n}`,\n `fn vdbLevelSetNormal(g: u32, xyz: vec3f, h: f32) -> vec3f {\n var acc = vdbAccessorInit(g);\n let gi = vdbLevelSetGradient(&acc, xyz, h);\n let n = vec3f(dot(vdbWorldToIndexDir(g, vec3f(1.0, 0.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 1.0, 0.0)), gi), dot(vdbWorldToIndexDir(g, vec3f(0.0, 0.0, 1.0)), gi));\n let l = length(n);\n if !(l > 0.0) {\n return vec3f(0.0, 1.0, 0.0);\n }\n return n / l;\n}`,\n ];\n}\n"]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `majorant` profile's API layer (P1.3, P1.4; docs/dev/design/K1-core.md §3.2, §5): a piecewise-constant
|
|
3
|
+
* bound of the sampled field along an index-space ray, for delta and ratio tracking.
|
|
4
|
+
*
|
|
5
|
+
* ```wgsl
|
|
6
|
+
* var it = vdbMajorantInit(g, oIdx, dIdx, tMin, tMax); // index-space ray, d unnormalized, t the caller's
|
|
7
|
+
* loop { let s = vdbMajorantNext(&it); if s.y <= s.x { break; } } // s.z bounds every sample on [s.x, s.y)
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Segments are contiguous, never of zero length, and cover the walk's box: the brick grid's cells
|
|
11
|
+
* (`'brick'`), else the sampler's support box (`[min - 1, max + 1]` trilinear, `[min - 0.5, max + 0.5]`
|
|
12
|
+
* nearest). Outside it the field is 0 with `outside: 'zero'` (with `'background'` it is the tree's
|
|
13
|
+
* background, which the walk does not cover: use a fog grid with background 0).
|
|
14
|
+
*
|
|
15
|
+
* - `'brick'`: the pathtracer's DDA (`ptDdaInit` / `ptDdaNext`) over the brick cells in cell space
|
|
16
|
+
* `(p - origin) / B`; a grid without a brick range (or a 0.1 pool's range, which has no "VDBM" header)
|
|
17
|
+
* walks as `'global'`.
|
|
18
|
+
* - `'global'`: one segment with the record's `valueMax` (`vdbMajorantGlobal(g)`, the scalar a VSPG or
|
|
19
|
+
* emission estimator needs).
|
|
20
|
+
* - `'nodeMax'` (needs the march layer): the vendored HDDA at leaf size 8 widening over tiles; a cell's
|
|
21
|
+
* bound is the max of `vdbNodeMax` over the 2x2x2 block of cells from its corner (the 8-leaf support of
|
|
22
|
+
* a trilinear sample). Stats bound ACTIVE values: inactive leaf voxels must be <= their leaf's max (fog).
|
|
23
|
+
*
|
|
24
|
+
* With `outside: 'zero'` a bound below 0 becomes 0 (a tap outside the bbox reads 0). With `minima`,
|
|
25
|
+
* `vdbMajorantMinimum(&it)` is the lower bound of the segment the last `vdbMajorantNext` returned: the
|
|
26
|
+
* brick minimum when the range carries minima, else 0 (a minorant of a non-negative field).
|
|
27
|
+
*
|
|
28
|
+
* CPU twin: `tools` `vdbMajorantWalk`. Axis-parallel rays: a direction component below 1e-20 in
|
|
29
|
+
* magnitude never divides (WGSL may assume no infinities; CLAUDE.md Traps).
|
|
30
|
+
*
|
|
31
|
+
* Opt-in helpers (EX1f-b, {@link majorantHelpersWgsl}): `vdbMajorantInitWorld`, `vdbMajorantInitGlobal`,
|
|
32
|
+
* `vdbDeltaTrack`, `vdbRatioTrack`. With a tracker the iterator also keeps the ray (`o`, `d`), so a
|
|
33
|
+
* tracker takes only the iterator and an accessor.
|
|
34
|
+
*/
|
|
35
|
+
import type { ApiOptions } from "./api.js";
|
|
36
|
+
/** The `majorant` module option: which walk the profile compiles. */
|
|
37
|
+
export type VDBMajorantMode = "brick" | "global" | "nodeMax";
|
|
38
|
+
/** The majorant layer for the normalized options (`o.majorant`, `o.minima`, `o.sampler`, `o.outside`). */
|
|
39
|
+
export declare function majorantWgsl(o: ApiOptions): string;
|
|
40
|
+
/**
|
|
41
|
+
* The `majorant` profile's opt-in helpers (EX1f-b), emitted after the layer in this order. None is emitted unless
|
|
42
|
+
* listed, so a module without them keeps its bytes.
|
|
43
|
+
*
|
|
44
|
+
* - `'majorantWorld'`: `vdbMajorantInitWorld(g, o, d, tMin, tMax)`, `vdbMajorantInit` for a world-space ray (the
|
|
45
|
+
* record's world-to-index affine; `d` is not renormalized, so `t` stays the caller's world parameter).
|
|
46
|
+
* - `'majorantGlobal'` (`'brick'` and `'global'`): `vdbMajorantInitGlobal(g, o, d, tMin, tMax)`, the one-segment walk
|
|
47
|
+
* on the grid's global bound whatever brick bounds it has: bricks or the global bound picked per ray at run time
|
|
48
|
+
* in one module.
|
|
49
|
+
* - `'deltaTrack'`: `vdbDeltaTrack(it, acc, sigma, maxLookups) -> VdbCollision`, delta (Woodcock) tracking over the
|
|
50
|
+
* rest of the walk: the next real collision of the medium with extinction `sigma * vdbSample`.
|
|
51
|
+
* - `'ratioTrack'`: `vdbRatioTrack(it, acc, sigma, cutoff, maxLookups) -> VdbTransmittance`, ratio tracking over the
|
|
52
|
+
* rest of the walk: an unbiased transmittance per channel for the extinctions `sigma.rgb * vdbSample`, with the
|
|
53
|
+
* majorant of the largest channel; below `cutoff` (its largest channel) the estimate plays Russian roulette: it
|
|
54
|
+
* survives with probability `w / cutoff` and is scaled so that its largest channel is exactly `cutoff` (assigned,
|
|
55
|
+
* not multiplied: a product one ulp under `cutoff` would play again at the next collision on some GPUs only).
|
|
56
|
+
*
|
|
57
|
+
* The trackers draw uniform numbers in [0, 1) from the host's function `o.random` (the module option `random`: the
|
|
58
|
+
* name of a `fn name() -> f32` the host declares in the same shader), in this order: per tentative collision one for
|
|
59
|
+
* the distance, then (delta) one for the accept test, or (ratio) one when the roulette plays. CPU twins: `tools`
|
|
60
|
+
* `vdbDeltaTrack` / `vdbRatioTrack` (same draws, f32 in this evaluation order).
|
|
61
|
+
*/
|
|
62
|
+
export declare function majorantHelpersWgsl(o: ApiOptions): string[];
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/** `vdb_maj_clip`: slab test with the axis-parallel guard. */
|
|
2
|
+
const CLIP = `fn vdb_maj_clip(lo: vec3f, hi: vec3f, o: vec3f, d: vec3f, t0: f32, t1: f32) -> vec2f {
|
|
3
|
+
var t = vec2f(t0, t1);
|
|
4
|
+
for (var k = 0; k < 3; k++) {
|
|
5
|
+
if abs(d[k]) < 1e-20 {
|
|
6
|
+
if o[k] < lo[k] || o[k] >= hi[k] {
|
|
7
|
+
return vec2f(t0, t0);
|
|
8
|
+
}
|
|
9
|
+
} else {
|
|
10
|
+
let p = (lo[k] - o[k]) / d[k];
|
|
11
|
+
let q = (hi[k] - o[k]) / d[k];
|
|
12
|
+
t = vec2f(max(t.x, min(p, q)), min(t.y, max(p, q)));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}`;
|
|
17
|
+
/** Whether a tracking helper is listed: the iterator then keeps the index-space ray. */
|
|
18
|
+
function tracks(o) {
|
|
19
|
+
return o.helpers.includes("deltaTrack") || o.helpers.includes("ratioTrack");
|
|
20
|
+
}
|
|
21
|
+
/** The record's global bound and the sampler's support clip, as WGSL expressions of `g`, `o`, `d`, `tMin`, `tMax`. */
|
|
22
|
+
function globalParts(o) {
|
|
23
|
+
const pad = o.sampler === "nearest" ? "0.5" : "1.0";
|
|
24
|
+
return {
|
|
25
|
+
vmax: o.outside === "zero" ? "max(bitcast<f32>(vdb_rec(g, VDB_REC_VALUE_MAX)), 0.0)" : "bitcast<f32>(vdb_rec(g, VDB_REC_VALUE_MAX))",
|
|
26
|
+
support: `vdb_maj_clip(vec3f(vdbIndexMin(g)) - vec3f(${pad}), vec3f(vdbIndexMax(g)) + vec3f(${pad}), o, d, tMin, tMax)`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The majorant layer for the normalized options (`o.majorant`, `o.minima`, `o.sampler`, `o.outside`). */
|
|
30
|
+
export function majorantWgsl(o) {
|
|
31
|
+
const zero = o.outside === "zero";
|
|
32
|
+
const { vmax, support } = globalParts(o);
|
|
33
|
+
// EX1f-b: with a tracker the brick / global iterator keeps the ray (the nodeMax one always has it).
|
|
34
|
+
const ray = tracks(o) ? "\n o: vec3f,\n d: vec3f," : "";
|
|
35
|
+
const setRay = tracks(o) ? "\n it.o = o;\n it.d = d;" : "";
|
|
36
|
+
const parts = [
|
|
37
|
+
CLIP,
|
|
38
|
+
`fn vdbMajorantGlobal(g: u32) -> f32 {
|
|
39
|
+
if !vdb_live(g) {
|
|
40
|
+
return 0.0;
|
|
41
|
+
}
|
|
42
|
+
return ${vmax};
|
|
43
|
+
}`,
|
|
44
|
+
];
|
|
45
|
+
const lo = o.minima ? "\n lo: f32," : "";
|
|
46
|
+
if (o.majorant === "nodeMax") {
|
|
47
|
+
parts.push(`struct VdbMajorantIter {
|
|
48
|
+
t: f32,
|
|
49
|
+
te: f32,
|
|
50
|
+
o: vec3f,
|
|
51
|
+
d: vec3f,
|
|
52
|
+
h: VdbHdda,
|
|
53
|
+
acc: VdbAccessor,${lo}
|
|
54
|
+
}`, `fn vdb_maj_bound(acc: ptr<function, VdbAccessor>, ijk: vec3i, dim: u32) -> f32 {
|
|
55
|
+
var m = vdbNodeMax(acc, ijk, dim);
|
|
56
|
+
for (var k = 1u; k < 8u; k++) {
|
|
57
|
+
m = max(m, vdbNodeMax(acc, ijk + vec3i(vec3u(k & 1u, (k >> 1u) & 1u, k >> 2u)) * i32(dim), dim));
|
|
58
|
+
}
|
|
59
|
+
return ${zero ? "max(m, 0.0)" : "m"};
|
|
60
|
+
}`, `fn vdbMajorantInit(g: u32, o: vec3f, d: vec3f, tMin: f32, tMax: f32) -> VdbMajorantIter {
|
|
61
|
+
var it: VdbMajorantIter;
|
|
62
|
+
it.t = tMin;
|
|
63
|
+
it.te = tMin;
|
|
64
|
+
if !vdb_live(g) {
|
|
65
|
+
return it;
|
|
66
|
+
}
|
|
67
|
+
let c = ${support};
|
|
68
|
+
if c.x < c.y {
|
|
69
|
+
it.t = c.x;
|
|
70
|
+
it.te = c.y;
|
|
71
|
+
it.o = o;
|
|
72
|
+
it.d = d;
|
|
73
|
+
var a = vdbAccessorInit(g);
|
|
74
|
+
var h: VdbHdda;
|
|
75
|
+
vdbHddaInit(&h, o, c.x, d, c.y, max(vdbGetDim(&a, vec3i(floor(o + d * c.x))), 8u));
|
|
76
|
+
it.h = h;
|
|
77
|
+
it.acc = a;
|
|
78
|
+
}
|
|
79
|
+
return it;
|
|
80
|
+
}`, `fn vdbMajorantNext(it: ptr<function, VdbMajorantIter>) -> vec3f {
|
|
81
|
+
var h = (*it).h;
|
|
82
|
+
var a = (*it).acc;
|
|
83
|
+
var s = vec3f((*it).t, (*it).t, 0.0);
|
|
84
|
+
for (var i = 0u; i < 16u; i++) {
|
|
85
|
+
let t0 = (*it).t;
|
|
86
|
+
if !(t0 < (*it).te) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
var u = 0u;
|
|
90
|
+
loop {
|
|
91
|
+
let w = max(vdbGetDim(&a, h.voxel), 8u);
|
|
92
|
+
if w == u32(h.dim) || u >= 2u {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
vdbHddaUpdate(&h, (*it).o, (*it).d, w);
|
|
96
|
+
u++;
|
|
97
|
+
}
|
|
98
|
+
var t1 = min(min(min(h.next.x, h.next.y), min(h.next.z, h.tmax)), (*it).te);
|
|
99
|
+
let v = h.voxel;
|
|
100
|
+
let dim = u32(h.dim);
|
|
101
|
+
if !vdbHddaStep(&h) {
|
|
102
|
+
t1 = (*it).te;
|
|
103
|
+
}
|
|
104
|
+
if t1 > t0 {
|
|
105
|
+
(*it).t = t1;
|
|
106
|
+
s = vec3f(t0, t1, vdb_maj_bound(&a, v, dim));
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
(*it).h = h;
|
|
111
|
+
(*it).acc = a;${o.minima ? "\n (*it).lo = 0.0;" : ""}
|
|
112
|
+
return s;
|
|
113
|
+
}`);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const brick = o.majorant === "brick";
|
|
117
|
+
const fields = brick
|
|
118
|
+
? `
|
|
119
|
+
mode: u32,
|
|
120
|
+
cell: vec3i,
|
|
121
|
+
n: vec3i,
|
|
122
|
+
sgn: vec3i,
|
|
123
|
+
tn: vec3f,
|
|
124
|
+
dt: vec3f,
|
|
125
|
+
base: u32,${o.minima ? "\n mn: u32," : ""}`
|
|
126
|
+
: "";
|
|
127
|
+
parts.push(`struct VdbMajorantIter {
|
|
128
|
+
t: f32,
|
|
129
|
+
te: f32,
|
|
130
|
+
vmax: f32,${fields}${ray}${lo}
|
|
131
|
+
}`);
|
|
132
|
+
const brickInit = brick
|
|
133
|
+
? `
|
|
134
|
+
let f = vdb_rec(g, VDB_REC_FLAGS);
|
|
135
|
+
let mb = vdb_rec(g, VDB_REC_MAJORANT_OFFSET) >> 2u;
|
|
136
|
+
if (f & VDB_REC_FLAG_HAS_BRICK_MAJORANT) != 0u && vdb_load(mb + VDB_MAJ_MAGIC) == VDB_MAJORANT_MAGIC {
|
|
137
|
+
let s = 1.0 / f32(1u << ((f >> VDB_REC_BRICK_LOG2_SHIFT) & VDB_REC_BYTE_FIELD_MASK));
|
|
138
|
+
let n = bitcast<vec3i>(vec3u(vdb_rec(g, VDB_REC_MAJORANT_DIMS), vdb_rec(g, VDB_REC_MAJORANT_DIMS + 1u), vdb_rec(g, VDB_REC_MAJORANT_DIMS + 2u)));
|
|
139
|
+
let u = (o - vec3f(bitcast<vec3i>(vec3u(vdb_load(mb + VDB_MAJ_ORIGIN), vdb_load(mb + VDB_MAJ_ORIGIN + 1u), vdb_load(mb + VDB_MAJ_ORIGIN + 2u))))) * s;
|
|
140
|
+
let du = d * s;
|
|
141
|
+
let c = vdb_maj_clip(vec3f(0.0), vec3f(n), u, du, tMin, tMax);
|
|
142
|
+
if c.x < c.y {
|
|
143
|
+
let par = abs(du) < vec3f(1e-20);
|
|
144
|
+
let q = select(du, vec3f(1.0), par);
|
|
145
|
+
it.mode = 2u;
|
|
146
|
+
it.t = c.x;
|
|
147
|
+
it.te = c.y;
|
|
148
|
+
it.n = n;
|
|
149
|
+
it.cell = clamp(vec3i(floor(u + du * c.x)), vec3i(0), n - vec3i(1));
|
|
150
|
+
it.sgn = select(vec3i(-1), vec3i(1), du > vec3f(0.0));
|
|
151
|
+
it.tn = select((vec3f(it.cell + max(it.sgn, vec3i(0))) - u) / q, vec3f(1e30), par);
|
|
152
|
+
it.dt = select(abs(1.0 / q), vec3f(1e30), par);
|
|
153
|
+
it.base = mb + VDB_MAJORANT_HEADER_WORDS;${o.minima
|
|
154
|
+
? `
|
|
155
|
+
if (vdb_load(mb + VDB_MAJ_FLAGS) & VDB_MAJ_FLAG_MINIMA) != 0u {
|
|
156
|
+
it.mn = it.base + u32(n.x * n.y * n.z);
|
|
157
|
+
}`
|
|
158
|
+
: ""}
|
|
159
|
+
}
|
|
160
|
+
return it;
|
|
161
|
+
}`
|
|
162
|
+
: "";
|
|
163
|
+
parts.push(`fn vdbMajorantInit(g: u32, o: vec3f, d: vec3f, tMin: f32, tMax: f32) -> VdbMajorantIter {
|
|
164
|
+
var it: VdbMajorantIter;
|
|
165
|
+
it.t = tMin;
|
|
166
|
+
it.te = tMin;
|
|
167
|
+
if !vdb_live(g) {
|
|
168
|
+
return it;
|
|
169
|
+
}
|
|
170
|
+
it.vmax = ${vmax};${setRay}${brickInit}
|
|
171
|
+
let c = ${support};${brick ? "\n it.mode = 1u;" : ""}
|
|
172
|
+
it.t = c.x;
|
|
173
|
+
it.te = c.y;
|
|
174
|
+
return it;
|
|
175
|
+
}`);
|
|
176
|
+
const global = `(*it).t = (*it).te;${o.minima ? "\n (*it).lo = 0.0;" : ""}
|
|
177
|
+
return vec3f(t0, (*it).te, (*it).vmax);`;
|
|
178
|
+
parts.push(brick
|
|
179
|
+
? `fn vdbMajorantNext(it: ptr<function, VdbMajorantIter>) -> vec3f {
|
|
180
|
+
for (var i = 0u; i < 4u; i++) {
|
|
181
|
+
let t0 = (*it).t;
|
|
182
|
+
if !(t0 < (*it).te) {
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
if (*it).mode == 1u {
|
|
186
|
+
${global.replace(/\n {8}/g, "\n ")}
|
|
187
|
+
}
|
|
188
|
+
let tn = (*it).tn;
|
|
189
|
+
var k = 0;
|
|
190
|
+
if tn.y < tn[k] {
|
|
191
|
+
k = 1;
|
|
192
|
+
}
|
|
193
|
+
if tn.z < tn[k] {
|
|
194
|
+
k = 2;
|
|
195
|
+
}
|
|
196
|
+
let t1 = min(tn[k], (*it).te);
|
|
197
|
+
let c = (*it).cell;
|
|
198
|
+
let n = (*it).n;
|
|
199
|
+
let w = u32(c.x + n.x * (c.y + n.y * c.z));
|
|
200
|
+
(*it).cell[k] = c[k] + (*it).sgn[k];
|
|
201
|
+
(*it).tn[k] = tn[k] + (*it).dt[k];
|
|
202
|
+
if (*it).cell[k] < 0 || (*it).cell[k] >= n[k] {
|
|
203
|
+
(*it).te = t1;
|
|
204
|
+
}
|
|
205
|
+
if t1 > t0 {
|
|
206
|
+
(*it).t = t1;${o.minima
|
|
207
|
+
? `
|
|
208
|
+
(*it).lo = 0.0;
|
|
209
|
+
if (*it).mn != 0u {
|
|
210
|
+
(*it).lo = bitcast<f32>(vdb_load((*it).mn + w));
|
|
211
|
+
}`
|
|
212
|
+
: ""}
|
|
213
|
+
return vec3f(t0, t1, bitcast<f32>(vdb_load((*it).base + w)));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return vec3f((*it).t, (*it).t, 0.0);
|
|
217
|
+
}`
|
|
218
|
+
: `fn vdbMajorantNext(it: ptr<function, VdbMajorantIter>) -> vec3f {
|
|
219
|
+
let t0 = (*it).t;
|
|
220
|
+
if !(t0 < (*it).te) {
|
|
221
|
+
return vec3f(t0, t0, 0.0);
|
|
222
|
+
}
|
|
223
|
+
${global.replace(/\n {8}/g, "\n ")}
|
|
224
|
+
}`);
|
|
225
|
+
}
|
|
226
|
+
if (o.minima) {
|
|
227
|
+
parts.push(`fn vdbMajorantMinimum(it: ptr<function, VdbMajorantIter>) -> f32 {
|
|
228
|
+
return (*it).lo;
|
|
229
|
+
}`);
|
|
230
|
+
}
|
|
231
|
+
return parts.join("\n");
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The `majorant` profile's opt-in helpers (EX1f-b), emitted after the layer in this order. None is emitted unless
|
|
235
|
+
* listed, so a module without them keeps its bytes.
|
|
236
|
+
*
|
|
237
|
+
* - `'majorantWorld'`: `vdbMajorantInitWorld(g, o, d, tMin, tMax)`, `vdbMajorantInit` for a world-space ray (the
|
|
238
|
+
* record's world-to-index affine; `d` is not renormalized, so `t` stays the caller's world parameter).
|
|
239
|
+
* - `'majorantGlobal'` (`'brick'` and `'global'`): `vdbMajorantInitGlobal(g, o, d, tMin, tMax)`, the one-segment walk
|
|
240
|
+
* on the grid's global bound whatever brick bounds it has: bricks or the global bound picked per ray at run time
|
|
241
|
+
* in one module.
|
|
242
|
+
* - `'deltaTrack'`: `vdbDeltaTrack(it, acc, sigma, maxLookups) -> VdbCollision`, delta (Woodcock) tracking over the
|
|
243
|
+
* rest of the walk: the next real collision of the medium with extinction `sigma * vdbSample`.
|
|
244
|
+
* - `'ratioTrack'`: `vdbRatioTrack(it, acc, sigma, cutoff, maxLookups) -> VdbTransmittance`, ratio tracking over the
|
|
245
|
+
* rest of the walk: an unbiased transmittance per channel for the extinctions `sigma.rgb * vdbSample`, with the
|
|
246
|
+
* majorant of the largest channel; below `cutoff` (its largest channel) the estimate plays Russian roulette: it
|
|
247
|
+
* survives with probability `w / cutoff` and is scaled so that its largest channel is exactly `cutoff` (assigned,
|
|
248
|
+
* not multiplied: a product one ulp under `cutoff` would play again at the next collision on some GPUs only).
|
|
249
|
+
*
|
|
250
|
+
* The trackers draw uniform numbers in [0, 1) from the host's function `o.random` (the module option `random`: the
|
|
251
|
+
* name of a `fn name() -> f32` the host declares in the same shader), in this order: per tentative collision one for
|
|
252
|
+
* the distance, then (delta) one for the accept test, or (ratio) one when the roulette plays. CPU twins: `tools`
|
|
253
|
+
* `vdbDeltaTrack` / `vdbRatioTrack` (same draws, f32 in this evaluation order).
|
|
254
|
+
*/
|
|
255
|
+
export function majorantHelpersWgsl(o) {
|
|
256
|
+
const out = [];
|
|
257
|
+
const has = (h) => o.helpers.includes(h);
|
|
258
|
+
if (has("majorantWorld")) {
|
|
259
|
+
out.push(`fn vdbMajorantInitWorld(g: u32, o: vec3f, d: vec3f, tMin: f32, tMax: f32) -> VdbMajorantIter {
|
|
260
|
+
return vdbMajorantInit(g, vdbWorldToIndex(g, o), vdbWorldToIndexDir(g, d), tMin, tMax);
|
|
261
|
+
}`);
|
|
262
|
+
}
|
|
263
|
+
if (has("majorantGlobal")) {
|
|
264
|
+
const { vmax, support } = globalParts(o);
|
|
265
|
+
out.push(o.majorant === "brick"
|
|
266
|
+
? `fn vdbMajorantInitGlobal(g: u32, o: vec3f, d: vec3f, tMin: f32, tMax: f32) -> VdbMajorantIter {
|
|
267
|
+
var it: VdbMajorantIter;
|
|
268
|
+
it.t = tMin;
|
|
269
|
+
it.te = tMin;
|
|
270
|
+
if !vdb_live(g) {
|
|
271
|
+
return it;
|
|
272
|
+
}
|
|
273
|
+
it.vmax = ${vmax};${tracks(o) ? "\n it.o = o;\n it.d = d;" : ""}
|
|
274
|
+
let c = ${support};
|
|
275
|
+
it.mode = 1u;
|
|
276
|
+
it.t = c.x;
|
|
277
|
+
it.te = c.y;
|
|
278
|
+
return it;
|
|
279
|
+
}`
|
|
280
|
+
: `fn vdbMajorantInitGlobal(g: u32, o: vec3f, d: vec3f, tMin: f32, tMax: f32) -> VdbMajorantIter {
|
|
281
|
+
return vdbMajorantInit(g, o, d, tMin, tMax);
|
|
282
|
+
}`);
|
|
283
|
+
}
|
|
284
|
+
const rand = `${o.random ?? "vdbRandomMissing"}()`;
|
|
285
|
+
if (has("deltaTrack")) {
|
|
286
|
+
out.push(`struct VdbCollision {
|
|
287
|
+
t: f32,
|
|
288
|
+
density: f32,
|
|
289
|
+
hit: bool,
|
|
290
|
+
truncated: bool,
|
|
291
|
+
steps: u32,
|
|
292
|
+
lookups: u32,
|
|
293
|
+
}`, `fn vdbDeltaTrack(it: ptr<function, VdbMajorantIter>, acc: ptr<function, VdbAccessor>, sigma: f32, maxLookups: u32) -> VdbCollision {
|
|
294
|
+
var r = VdbCollision((*it).t, 0.0, false, false, 0u, 0u);
|
|
295
|
+
let o = (*it).o;
|
|
296
|
+
let d = (*it).d;
|
|
297
|
+
loop {
|
|
298
|
+
let s = vdbMajorantNext(it);
|
|
299
|
+
if s.y <= s.x {
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
r.steps += 1u;
|
|
303
|
+
r.t = s.y;
|
|
304
|
+
let m = s.z * sigma;
|
|
305
|
+
if m <= 0.0 {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
var t = s.x;
|
|
309
|
+
loop {
|
|
310
|
+
t -= log(1.0 - ${rand}) / m;
|
|
311
|
+
if t >= s.y {
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
if r.lookups >= maxLookups {
|
|
315
|
+
r.t = t;
|
|
316
|
+
r.truncated = true;
|
|
317
|
+
return r;
|
|
318
|
+
}
|
|
319
|
+
r.lookups += 1u;
|
|
320
|
+
let v = vdbSample(acc, o + d * t);
|
|
321
|
+
if ${rand} * m < v * sigma {
|
|
322
|
+
r.t = t;
|
|
323
|
+
r.density = v;
|
|
324
|
+
r.hit = true;
|
|
325
|
+
return r;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return r;
|
|
330
|
+
}`);
|
|
331
|
+
}
|
|
332
|
+
if (has("ratioTrack")) {
|
|
333
|
+
out.push(`struct VdbTransmittance {
|
|
334
|
+
value: vec3f,
|
|
335
|
+
truncated: bool,
|
|
336
|
+
steps: u32,
|
|
337
|
+
lookups: u32,
|
|
338
|
+
}`, `fn vdbRatioTrack(it: ptr<function, VdbMajorantIter>, acc: ptr<function, VdbAccessor>, sigma: vec3f, cutoff: f32, maxLookups: u32) -> VdbTransmittance {
|
|
339
|
+
var r = VdbTransmittance(vec3f(1.0), false, 0u, 0u);
|
|
340
|
+
let o = (*it).o;
|
|
341
|
+
let d = (*it).d;
|
|
342
|
+
let top = max(sigma.x, max(sigma.y, sigma.z));
|
|
343
|
+
loop {
|
|
344
|
+
let s = vdbMajorantNext(it);
|
|
345
|
+
if s.y <= s.x {
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
r.steps += 1u;
|
|
349
|
+
let m = s.z * top;
|
|
350
|
+
if m <= 0.0 {
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
var t = s.x;
|
|
354
|
+
loop {
|
|
355
|
+
t -= log(1.0 - ${rand}) / m;
|
|
356
|
+
if t >= s.y {
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
if r.lookups >= maxLookups {
|
|
360
|
+
r.truncated = true;
|
|
361
|
+
return r;
|
|
362
|
+
}
|
|
363
|
+
r.lookups += 1u;
|
|
364
|
+
let v = vdbSample(acc, o + d * t);
|
|
365
|
+
r.value *= vec3f(1.0) - sigma * (v / m);
|
|
366
|
+
let w = max(r.value.x, max(r.value.y, r.value.z));
|
|
367
|
+
if w < cutoff || w <= 0.0 {
|
|
368
|
+
if ${rand} * cutoff >= w {
|
|
369
|
+
r.value = vec3f(0.0);
|
|
370
|
+
return r;
|
|
371
|
+
}
|
|
372
|
+
r.value = select(r.value * (cutoff / w), vec3f(cutoff), r.value >= vec3f(w));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return r;
|
|
377
|
+
}`);
|
|
378
|
+
}
|
|
379
|
+
return out;
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=majorant.js.map
|