@luma.gl/engine 10.0.0-alpha.9 → 10.0.0-beta.1
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/LICENSE +4 -4
- package/THIRD-PARTY-NOTICES.md +185 -0
- package/dist/animation/node-animation-binding.cjs +10 -0
- package/dist/animation/node-animation-binding.d.ts +1 -1
- package/dist/animation/node-animation-binding.d.ts.map +1 -1
- package/dist/animation/node-animation-binding.js +10 -0
- package/dist/animation/node-animation-binding.js.map +1 -1
- package/dist/arrow/index.cjs.map +2 -2
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +12 -13
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.d.ts.map +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js +22 -17
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.js.map +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.cjs +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js +1 -1
- package/dist/arrow/renderers/text/renderers/arrow-text-shaders.js.map +1 -1
- package/dist/compute/computation.cjs +1 -1
- package/dist/compute/computation.js +1 -1
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.d.ts +2 -2
- package/dist/compute/swap.d.ts.map +1 -1
- package/dist/compute/swap.js.map +1 -1
- package/dist/dist.dev.js +887 -381
- package/dist/dist.min.js +74 -67
- package/dist/dynamic-texture/video-texture.cjs +1 -1
- package/dist/dynamic-texture/video-texture.d.ts +3 -3
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/video-texture.js +1 -1
- package/dist/dynamic-texture/video-texture.js.map +1 -1
- package/dist/effects/index.cjs.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js +2 -1
- package/dist/effects/passes/postprocessing/fxaa/fxaa.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/denoise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/huesaturation.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/noise.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/sepia.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/vibrance.js.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.d.ts.map +1 -1
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js +2 -0
- package/dist/effects/passes/postprocessing/image-adjust-filters/vignette.js.map +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts +1 -1
- package/dist/gltf/gltf/animations/animations.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.cjs +3 -0
- package/dist/gltf/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/gltf/create-gltf-model.js +4 -0
- package/dist/gltf/gltf/create-gltf-model.js.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.cjs +80 -12
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts +8 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.d.ts.map +1 -1
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js +82 -14
- package/dist/gltf/gltf/create-scenegraph-from-gltf.js.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.cjs +6 -1
- package/dist/gltf/gltf/gltf-billboard.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-billboard.js +6 -1
- package/dist/gltf/gltf/gltf-billboard.js.map +1 -1
- package/dist/gltf/gltf/gltf-extension-support.cjs +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js +2 -2
- package/dist/gltf/gltf/gltf-extension-support.js.map +1 -1
- package/dist/gltf/index.cjs +2 -0
- package/dist/gltf/index.cjs.map +3 -3
- package/dist/gltf/index.d.ts +1 -1
- package/dist/gltf/index.d.ts.map +1 -1
- package/dist/gltf/index.js +1 -1
- package/dist/gltf/index.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-animations.cjs +8 -5
- package/dist/gltf/parsers/parse-gltf-animations.js +20 -5
- package/dist/gltf/parsers/parse-gltf-animations.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.cjs +36 -72
- package/dist/gltf/parsers/parse-gltf-lights.d.ts +6 -2
- package/dist/gltf/parsers/parse-gltf-lights.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf-lights.js +34 -91
- package/dist/gltf/parsers/parse-gltf-lights.js.map +1 -1
- package/dist/gltf/parsers/parse-gltf-metadata.cjs +60 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts +5 -0
- package/dist/gltf/parsers/parse-gltf-metadata.d.ts.map +1 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js +39 -0
- package/dist/gltf/parsers/parse-gltf-metadata.js.map +1 -0
- package/dist/gltf/parsers/parse-gltf.cjs +4 -1
- package/dist/gltf/parsers/parse-gltf.d.ts +10 -2
- package/dist/gltf/parsers/parse-gltf.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-gltf.js +3 -0
- package/dist/gltf/parsers/parse-gltf.js.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.cjs +13 -3
- package/dist/gltf/parsers/parse-pbr-material.d.ts +7 -2
- package/dist/gltf/parsers/parse-pbr-material.d.ts.map +1 -1
- package/dist/gltf/parsers/parse-pbr-material.js +17 -5
- package/dist/gltf/parsers/parse-pbr-material.js.map +1 -1
- package/dist/gltf/pbr/pbr-environment.cjs +21 -3
- package/dist/gltf/pbr/pbr-environment.d.ts +3 -0
- package/dist/gltf/pbr/pbr-environment.d.ts.map +1 -1
- package/dist/gltf/pbr/pbr-environment.js +19 -1
- package/dist/gltf/pbr/pbr-environment.js.map +1 -1
- package/dist/gltf/pbr/pbr-material.d.ts +3 -3
- package/dist/gltf/pbr/pbr-material.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-json-schema.js +1 -0
- package/dist/gltf/types/gltf-json-schema.js.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.d.ts.map +1 -1
- package/dist/gltf/types/gltf-postprocessed-schema.js +1 -0
- package/dist/gltf/types/gltf-postprocessed-schema.js.map +1 -1
- package/dist/graph/models/index.cjs.map +1 -1
- package/dist/graph/models/path/path-attribute-model.cjs +4 -1
- package/dist/graph/models/path/path-attribute-model.d.ts +3 -1
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-attribute-model.js +6 -1
- package/dist/graph/models/path/path-attribute-model.js.map +1 -1
- package/dist/graph/models/path/path-storage-model.cjs +4 -1
- package/dist/graph/models/path/path-storage-model.d.ts +3 -1
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-storage-model.js +6 -1
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/physics/index.cjs.map +2 -2
- package/dist/graph/physics/physics-controller.cjs +42 -0
- package/dist/graph/physics/physics-controller.d.ts +12 -1
- package/dist/graph/physics/physics-controller.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller.js +41 -0
- package/dist/graph/physics/physics-controller.js.map +1 -1
- package/dist/graph/physics/scenegraph-instance.cjs +7 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +8 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/tables/gpu-table-model.cjs +2 -2
- package/dist/graph/tables/gpu-table-model.d.ts +2 -1
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -1
- package/dist/graph/tables/gpu-table-model.js +2 -2
- package/dist/graph/tables/gpu-table-model.js.map +1 -1
- package/dist/graph/tables/index.cjs.map +1 -1
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lighting/ambient-occlusion-pass.cjs +126 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts +31 -0
- package/dist/lighting/ambient-occlusion-pass.d.ts.map +1 -0
- package/dist/lighting/ambient-occlusion-pass.js +108 -0
- package/dist/lighting/ambient-occlusion-pass.js.map +1 -0
- package/dist/lighting/clustered-light-grid.cjs +378 -0
- package/dist/lighting/clustered-light-grid.d.ts +94 -0
- package/dist/lighting/clustered-light-grid.d.ts.map +1 -0
- package/dist/lighting/clustered-light-grid.js +370 -0
- package/dist/lighting/clustered-light-grid.js.map +1 -0
- package/dist/lighting/contact-shadow-composite.cjs +80 -0
- package/dist/lighting/contact-shadow-composite.d.ts +6 -0
- package/dist/lighting/contact-shadow-composite.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-composite.js +59 -0
- package/dist/lighting/contact-shadow-composite.js.map +1 -0
- package/dist/lighting/contact-shadow-pass.cjs +102 -0
- package/dist/lighting/contact-shadow-pass.d.ts +23 -0
- package/dist/lighting/contact-shadow-pass.d.ts.map +1 -0
- package/dist/lighting/contact-shadow-pass.js +85 -0
- package/dist/lighting/contact-shadow-pass.js.map +1 -0
- package/dist/lighting/index.cjs +128 -0
- package/dist/lighting/index.cjs.map +6 -0
- package/dist/lighting/index.d.ts +35 -0
- package/dist/lighting/index.d.ts.map +1 -0
- package/dist/lighting/index.js +22 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/lighting/lightmap-atlas.cjs +246 -0
- package/dist/lighting/lightmap-atlas.d.ts +53 -0
- package/dist/lighting/lightmap-atlas.d.ts.map +1 -0
- package/dist/lighting/lightmap-atlas.js +279 -0
- package/dist/lighting/lightmap-atlas.js.map +1 -0
- package/dist/lighting/lightmap-baker.cjs +238 -0
- package/dist/lighting/lightmap-baker.d.ts +62 -0
- package/dist/lighting/lightmap-baker.d.ts.map +1 -0
- package/dist/lighting/lightmap-baker.js +236 -0
- package/dist/lighting/lightmap-baker.js.map +1 -0
- package/dist/lighting/lightmap-data.cjs +117 -0
- package/dist/lighting/lightmap-data.d.ts +20 -0
- package/dist/lighting/lightmap-data.d.ts.map +1 -0
- package/dist/lighting/lightmap-data.js +110 -0
- package/dist/lighting/lightmap-data.js.map +1 -0
- package/dist/lighting/lightmap-environment.cjs +61 -0
- package/dist/lighting/lightmap-environment.d.ts +18 -0
- package/dist/lighting/lightmap-environment.d.ts.map +1 -0
- package/dist/lighting/lightmap-environment.js +46 -0
- package/dist/lighting/lightmap-environment.js.map +1 -0
- package/dist/lighting/pbr-environment.cjs +45 -0
- package/dist/lighting/pbr-environment.d.ts +25 -0
- package/dist/lighting/pbr-environment.d.ts.map +1 -0
- package/dist/lighting/pbr-environment.js +30 -0
- package/dist/lighting/pbr-environment.js.map +1 -0
- package/dist/lighting/pbr-material.cjs +75 -0
- package/dist/lighting/pbr-material.d.ts +33 -0
- package/dist/lighting/pbr-material.d.ts.map +1 -0
- package/dist/lighting/pbr-material.js +52 -0
- package/dist/lighting/pbr-material.js.map +1 -0
- package/dist/lighting/pbr-model.cjs +579 -0
- package/dist/lighting/pbr-model.d.ts +45 -0
- package/dist/lighting/pbr-model.d.ts.map +1 -0
- package/dist/lighting/pbr-model.js +545 -0
- package/dist/lighting/pbr-model.js.map +1 -0
- package/dist/lighting/pbr-surface-pass.cjs +116 -0
- package/dist/lighting/pbr-surface-pass.d.ts +35 -0
- package/dist/lighting/pbr-surface-pass.d.ts.map +1 -0
- package/dist/lighting/pbr-surface-pass.js +98 -0
- package/dist/lighting/pbr-surface-pass.js.map +1 -0
- package/dist/lighting/prefiltered-environment.cjs +275 -0
- package/dist/lighting/prefiltered-environment.d.ts +56 -0
- package/dist/lighting/prefiltered-environment.d.ts.map +1 -0
- package/dist/lighting/prefiltered-environment.js +264 -0
- package/dist/lighting/prefiltered-environment.js.map +1 -0
- package/dist/lighting/reflection-probe.cjs +321 -0
- package/dist/lighting/reflection-probe.d.ts +77 -0
- package/dist/lighting/reflection-probe.d.ts.map +1 -0
- package/dist/lighting/reflection-probe.js +298 -0
- package/dist/lighting/reflection-probe.js.map +1 -0
- package/dist/lighting/shadow-map-renderer.cjs +631 -0
- package/dist/lighting/shadow-map-renderer.d.ts +92 -0
- package/dist/lighting/shadow-map-renderer.d.ts.map +1 -0
- package/dist/lighting/shadow-map-renderer.js +622 -0
- package/dist/lighting/shadow-map-renderer.js.map +1 -0
- package/dist/lighting/shadow-quality.cjs +58 -0
- package/dist/lighting/shadow-quality.d.ts +13 -0
- package/dist/lighting/shadow-quality.d.ts.map +1 -0
- package/dist/lighting/shadow-quality.js +37 -0
- package/dist/lighting/shadow-quality.js.map +1 -0
- package/dist/material/material.cjs +3 -0
- package/dist/material/material.d.ts +2 -0
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +3 -0
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-model.cjs +20 -3
- package/dist/model/gpu-vector-model.d.ts +20 -2
- package/dist/model/gpu-vector-model.d.ts.map +1 -1
- package/dist/model/gpu-vector-model.js +21 -3
- package/dist/model/gpu-vector-model.js.map +1 -1
- package/dist/models/light-model-utils.cjs +2 -2
- package/dist/models/light-model-utils.d.ts +2 -1
- package/dist/models/light-model-utils.d.ts.map +1 -1
- package/dist/models/light-model-utils.js +2 -2
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/scenegraph/controllers/punctual-light-controller.cjs +121 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/punctual-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js +117 -0
- package/dist/scenegraph/controllers/punctual-light-controller.js.map +1 -0
- package/dist/scenegraph/scene-metadata.cjs +43 -0
- package/dist/scenegraph/scene-metadata.d.ts +9 -0
- package/dist/scenegraph/scene-metadata.d.ts.map +1 -0
- package/dist/scenegraph/scene-metadata.js +21 -0
- package/dist/scenegraph/scene-metadata.js.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.cjs +99 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts +47 -0
- package/dist/scenegraph/scenegraph-interaction.d.ts.map +1 -0
- package/dist/scenegraph/scenegraph-interaction.js +79 -0
- package/dist/scenegraph/scenegraph-interaction.js.map +1 -0
- package/dist/scenegraph/scenegraph-node.cjs +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts +10 -0
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +10 -0
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/text/experimental.cjs.map +1 -1
- package/dist/text/fonts/atlas/text-utils.cjs +1 -1
- package/dist/text/fonts/atlas/text-utils.js +1 -1
- package/dist/text/fonts/atlas/text-utils.js.map +1 -1
- package/dist/text/fonts/index.cjs.map +1 -1
- package/dist/text/index.cjs +2 -0
- package/dist/text/index.cjs.map +2 -2
- package/dist/text/index.d.ts +1 -1
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.js +1 -1
- package/dist/text/index.js.map +1 -1
- package/dist/text/text-2d/index.cjs +3 -0
- package/dist/text/text-2d/index.d.ts +1 -0
- package/dist/text/text-2d/index.d.ts.map +1 -1
- package/dist/text/text-2d/index.js +1 -0
- package/dist/text/text-2d/index.js.map +1 -1
- package/dist/text/text-2d/model-utils/text-code-point-source.cjs +41 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts +8 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.d.ts.map +1 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js +23 -0
- package/dist/text/text-2d/model-utils/text-code-point-source.js.map +1 -0
- package/dist/text/text-2d/models/text-attribute-model.cjs +4 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-attribute-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-attribute-model.js +6 -1
- package/dist/text/text-2d/models/text-attribute-model.js.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.cjs +4 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-dictionary-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-dictionary-model.js +6 -1
- package/dist/text/text-2d/models/text-dictionary-model.js.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.cjs +4 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts +3 -1
- package/dist/text/text-2d/models/text-storage-model.d.ts.map +1 -1
- package/dist/text/text-2d/models/text-storage-model.js +6 -1
- package/dist/text/text-2d/models/text-storage-model.js.map +1 -1
- package/licenses/cesium.txt +207 -0
- package/licenses/deck-community.txt +19 -0
- package/licenses/deck.txt +19 -0
- package/licenses/glfx.txt +19 -0
- package/licenses/gltf-loader-ts.txt +21 -0
- package/licenses/magenta-font.txt +13 -0
- package/licenses/nvidia-fxaa.txt +25 -0
- package/licenses/philogl.txt +19 -0
- package/licenses/spark.txt +21 -0
- package/licenses/three.txt +21 -0
- package/package.json +17 -9
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +23 -19
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +1 -1
- package/src/compute/computation.ts +1 -1
- package/src/compute/swap.ts +2 -2
- package/src/dynamic-texture/video-texture.ts +9 -3
- package/src/effects/passes/postprocessing/fxaa/fxaa.ts +2 -1
- package/src/effects/passes/postprocessing/image-adjust-filters/brightnesscontrast.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/denoise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/huesaturation.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/noise.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/sepia.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vibrance.ts +2 -0
- package/src/effects/passes/postprocessing/image-adjust-filters/vignette.ts +2 -0
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-gltf-model.ts +4 -0
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/index.ts +1 -0
- package/src/gltf/parsers/parse-gltf-animations.ts +22 -8
- package/src/gltf/parsers/parse-gltf-lights.ts +42 -130
- package/src/gltf/parsers/parse-gltf-metadata.ts +40 -0
- package/src/gltf/parsers/parse-gltf.ts +11 -2
- package/src/gltf/parsers/parse-pbr-material.ts +35 -7
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/gltf/pbr/pbr-material.ts +8 -3
- package/src/gltf/types/gltf-json-schema.ts +1 -0
- package/src/gltf/types/gltf-postprocessed-schema.ts +1 -0
- package/src/graph/models/path/path-attribute-model.ts +10 -1
- package/src/graph/models/path/path-storage-model.ts +10 -1
- package/src/graph/physics/physics-controller.ts +55 -1
- package/src/graph/physics/scenegraph-instance.ts +10 -0
- package/src/graph/tables/gpu-table-model.ts +3 -2
- package/src/index.ts +17 -0
- package/src/lighting/ambient-occlusion-pass.ts +130 -0
- package/src/lighting/clustered-light-grid.ts +481 -0
- package/src/lighting/contact-shadow-composite.ts +67 -0
- package/src/lighting/contact-shadow-pass.ts +107 -0
- package/src/lighting/index.ts +125 -0
- package/src/lighting/lightmap-atlas.ts +348 -0
- package/src/lighting/lightmap-baker.ts +306 -0
- package/src/lighting/lightmap-data.ts +138 -0
- package/src/lighting/lightmap-environment.ts +70 -0
- package/src/lighting/pbr-environment.ts +55 -0
- package/src/lighting/pbr-material.ts +85 -0
- package/src/lighting/pbr-model.ts +608 -0
- package/src/lighting/pbr-surface-pass.ts +122 -0
- package/src/lighting/prefiltered-environment.ts +354 -0
- package/src/lighting/reflection-probe.ts +360 -0
- package/src/lighting/shadow-map-renderer.ts +918 -0
- package/src/lighting/shadow-quality.ts +50 -0
- package/src/material/material.ts +3 -0
- package/src/model/gpu-vector-model.ts +42 -4
- package/src/models/light-model-utils.ts +3 -2
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +12 -0
- package/src/splats/README.md +1 -1
- package/src/text/fonts/atlas/text-utils.ts +1 -1
- package/src/text/index.ts +1 -0
- package/src/text/text-2d/index.ts +1 -0
- package/src/text/text-2d/model-utils/text-code-point-source.ts +34 -0
- package/src/text/text-2d/models/text-attribute-model.ts +10 -1
- package/src/text/text-2d/models/text-dictionary-model.ts +10 -1
- package/src/text/text-2d/models/text-storage-model.ts +10 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, type Device, type Texture} from '@luma.gl/core';
|
|
5
|
+
import type {CompositeShaderPass} from '@luma.gl/shaders';
|
|
6
|
+
import {Matrix4, type NumberArray16} from '@math.gl/core';
|
|
7
|
+
import {ShaderPassRenderer} from '../passes/shader-pass-renderer';
|
|
8
|
+
import {ssaoEvaluate} from '../effects/passes/screen-space/ssao';
|
|
9
|
+
import {gtaoEvaluate} from '../effects/passes/screen-space/gtao';
|
|
10
|
+
import {depthAwareBlur} from '../effects/passes/screen-space/depth-aware-blur';
|
|
11
|
+
|
|
12
|
+
export type AmbientOcclusionMode = 'none' | 'ssao' | 'gtao';
|
|
13
|
+
export type AmbientOcclusionPassProps = {
|
|
14
|
+
mode?: AmbientOcclusionMode;
|
|
15
|
+
resolutionScale?: number;
|
|
16
|
+
};
|
|
17
|
+
export type AmbientOcclusionRenderOptions = {
|
|
18
|
+
depthTexture: Texture;
|
|
19
|
+
normalTexture: Texture;
|
|
20
|
+
projectionMatrix: Readonly<Matrix4 | NumberArray16>;
|
|
21
|
+
near: number;
|
|
22
|
+
far: number;
|
|
23
|
+
/** SSAO uses pixels; GTAO uses view-space scene units. */
|
|
24
|
+
radius?: number;
|
|
25
|
+
bias?: number;
|
|
26
|
+
intensity?: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Reuses the effects evaluators to produce ambient visibility, without color composition or history. */
|
|
30
|
+
export class AmbientOcclusionPass {
|
|
31
|
+
readonly device: Device;
|
|
32
|
+
readonly mode: AmbientOcclusionMode;
|
|
33
|
+
private readonly renderer: ShaderPassRenderer | null;
|
|
34
|
+
private readonly unoccluded: Texture;
|
|
35
|
+
private destroyed = false;
|
|
36
|
+
|
|
37
|
+
constructor(device: Device, props: AmbientOcclusionPassProps = {}) {
|
|
38
|
+
this.device = device;
|
|
39
|
+
this.mode = props.mode ?? 'gtao';
|
|
40
|
+
// Existing SSAO/GTAO evaluators support WebGPU. Callers can explicitly select none elsewhere.
|
|
41
|
+
assert(this.mode === 'none' || device.type === 'webgpu');
|
|
42
|
+
const scale = props.resolutionScale ?? 0.5;
|
|
43
|
+
// Resolution scale must describe a positive fractional input resolution.
|
|
44
|
+
assert(scale > 0 && scale <= 1);
|
|
45
|
+
this.unoccluded = device.createTexture({
|
|
46
|
+
width: 1,
|
|
47
|
+
height: 1,
|
|
48
|
+
data: new Uint8Array([255, 255, 255, 255])
|
|
49
|
+
});
|
|
50
|
+
if (this.mode === 'none') {
|
|
51
|
+
this.renderer = null;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const evaluate = this.mode === 'ssao' ? ssaoEvaluate : gtaoEvaluate;
|
|
55
|
+
const shaderPass: CompositeShaderPass<'ambientOcclusionRaw' | 'ambientOcclusionScratch'> = {
|
|
56
|
+
name: 'ambientOcclusionVisibility',
|
|
57
|
+
renderTargets: {
|
|
58
|
+
ambientOcclusionRaw: {scale: [scale, scale], format: 'rgba8unorm'},
|
|
59
|
+
ambientOcclusionScratch: {scale: [scale, scale], format: 'rgba8unorm'}
|
|
60
|
+
},
|
|
61
|
+
steps: [
|
|
62
|
+
{shaderPass: evaluate, inputs: {sourceTexture: 'original'}, output: 'ambientOcclusionRaw'},
|
|
63
|
+
{
|
|
64
|
+
shaderPass: depthAwareBlur,
|
|
65
|
+
inputs: {sourceTexture: 'ambientOcclusionRaw'},
|
|
66
|
+
output: 'ambientOcclusionScratch',
|
|
67
|
+
uniforms: {direction: [1, 0]}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
shaderPass: depthAwareBlur,
|
|
71
|
+
inputs: {sourceTexture: 'ambientOcclusionScratch'},
|
|
72
|
+
output: 'previous',
|
|
73
|
+
uniforms: {direction: [0, 1]}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
this.renderer = new ShaderPassRenderer(device, {
|
|
78
|
+
shaderPasses: [shaderPass],
|
|
79
|
+
colorFormat: 'rgba8unorm'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Borrows same-camera WebGPU hardware depth and encoded view normals; never submits. */
|
|
84
|
+
render(options: AmbientOcclusionRenderOptions): Texture {
|
|
85
|
+
// Even disabled passes must not be used after destruction.
|
|
86
|
+
assert(!this.destroyed);
|
|
87
|
+
if (!this.renderer) return this.unoccluded;
|
|
88
|
+
const {depthTexture, normalTexture} = options;
|
|
89
|
+
// Inputs must share the device and physical resolution.
|
|
90
|
+
assert(depthTexture.device === this.device && normalTexture.device === this.device);
|
|
91
|
+
assert(
|
|
92
|
+
depthTexture.width === normalTexture.width && depthTexture.height === normalTexture.height
|
|
93
|
+
);
|
|
94
|
+
const projectionMatrix = new Matrix4(options.projectionMatrix);
|
|
95
|
+
this.renderer.resize([normalTexture.width, normalTexture.height]);
|
|
96
|
+
const controls = {
|
|
97
|
+
...(options.radius === undefined ? {} : {radius: options.radius}),
|
|
98
|
+
...(options.bias === undefined ? {} : {bias: options.bias}),
|
|
99
|
+
...(options.intensity === undefined ? {} : {intensity: options.intensity})
|
|
100
|
+
};
|
|
101
|
+
const result = this.renderer.renderToTexture({
|
|
102
|
+
sourceTexture: normalTexture,
|
|
103
|
+
bindings: {depthTexture, normalTexture},
|
|
104
|
+
uniforms: {
|
|
105
|
+
ssaoEvaluate: {
|
|
106
|
+
...controls,
|
|
107
|
+
nearPlane: options.near,
|
|
108
|
+
farPlane: options.far,
|
|
109
|
+
useNormalTexture: 1
|
|
110
|
+
},
|
|
111
|
+
gtaoEvaluate: {
|
|
112
|
+
...controls,
|
|
113
|
+
projectionMatrix,
|
|
114
|
+
inverseProjectionMatrix: new Matrix4(projectionMatrix).invert(),
|
|
115
|
+
frameIndex: 0
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// Concrete inputs always produce a texture; deferred uploads are not accepted.
|
|
120
|
+
assert(result);
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
destroy(): void {
|
|
125
|
+
if (this.destroyed) return;
|
|
126
|
+
this.destroyed = true;
|
|
127
|
+
this.renderer?.destroy();
|
|
128
|
+
this.unoccluded.destroy();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {CommandEncoder, Device} from '@luma.gl/core';
|
|
6
|
+
import {assert, Buffer} from '@luma.gl/core';
|
|
7
|
+
import {Computation} from '../compute/computation';
|
|
8
|
+
import type {Matrix4Like} from '@math.gl/core';
|
|
9
|
+
|
|
10
|
+
/** Byte layout of each point-light record. The grid ignores the consumer payload. */
|
|
11
|
+
export const CLUSTERED_POINT_LIGHT_LAYOUT = Object.freeze({
|
|
12
|
+
byteStride: 32,
|
|
13
|
+
positionByteOffset: 0,
|
|
14
|
+
radiusByteOffset: 12,
|
|
15
|
+
payloadByteOffset: 16
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/** Compatibility name for the renderer-independent uniform snapshot. */
|
|
19
|
+
export type ClusteredLightGridShaderPassUniforms = ClusteredLightGridUniforms;
|
|
20
|
+
|
|
21
|
+
export const MAX_CLUSTERED_POINT_LIGHTS = 512;
|
|
22
|
+
export const DEFAULT_CLUSTER_DIMENSIONS = [16, 9, 24] as const;
|
|
23
|
+
export const DEFAULT_MAX_LIGHTS_PER_CLUSTER = 64;
|
|
24
|
+
|
|
25
|
+
const CLUSTER_WORKGROUP_SIZE = 64;
|
|
26
|
+
const CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH = 80;
|
|
27
|
+
|
|
28
|
+
/** Construction props for the fixed-capacity WebGPU light-cluster grid. */
|
|
29
|
+
export type ClusteredLightGridProps = {
|
|
30
|
+
/** Optional debug-resource prefix. */
|
|
31
|
+
id?: string;
|
|
32
|
+
/** Screen-x, screen-y, and logarithmic depth-slice counts. */
|
|
33
|
+
clusterDimensions?: readonly [number, number, number];
|
|
34
|
+
/** Maximum retained light indices in one cluster. */
|
|
35
|
+
maxLightsPerCluster?: number;
|
|
36
|
+
/** Maximum point-light records accepted by encode(). */
|
|
37
|
+
maxLightCount?: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Per-frame camera and light inputs used to rebuild the cluster lists. */
|
|
41
|
+
export type ClusteredLightGridEncodeOptions = {
|
|
42
|
+
/** View-space point-light records following CLUSTERED_POINT_LIGHT_LAYOUT. */
|
|
43
|
+
pointLights: Buffer;
|
|
44
|
+
/** Active prefix length in pointLights. */
|
|
45
|
+
pointLightCount: number;
|
|
46
|
+
/** Camera projection used to conservatively project light spheres into screen tiles. */
|
|
47
|
+
projectionMatrix: Readonly<Matrix4Like>;
|
|
48
|
+
/** Positive view-space near plane. */
|
|
49
|
+
nearPlane: number;
|
|
50
|
+
/** Positive view-space far plane. */
|
|
51
|
+
farPlane: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** Storage bindings available to lighting consumers. */
|
|
55
|
+
export type ClusteredLightGridBindings = {
|
|
56
|
+
clusterLightCounts: Buffer;
|
|
57
|
+
clusterLightIndices: Buffer;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Uniform values available to lighting consumers to locate one pixel's cluster. */
|
|
61
|
+
export type ClusteredLightGridUniforms = {
|
|
62
|
+
clusterCountX: number;
|
|
63
|
+
clusterCountY: number;
|
|
64
|
+
clusterCountZ: number;
|
|
65
|
+
maxLightsPerCluster: number;
|
|
66
|
+
pointLightCount: number;
|
|
67
|
+
clusterNearPlane: number;
|
|
68
|
+
clusterFarPlane: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Builds fixed-capacity screen/depth light lists entirely on WebGPU.
|
|
73
|
+
*
|
|
74
|
+
* One compute invocation projects each view-space point-light sphere into the overlapping
|
|
75
|
+
* x/y/z cluster range and atomically marks its light bit. A second compute dispatch compacts
|
|
76
|
+
* each bit mask in stable light-index order. Indices beyond maxLightsPerCluster are
|
|
77
|
+
* intentionally dropped so the fullscreen lighting pass has a predictable loop bound without
|
|
78
|
+
* nondeterministic overflow shimmer.
|
|
79
|
+
*/
|
|
80
|
+
export class ClusteredLightGrid {
|
|
81
|
+
readonly device: Device;
|
|
82
|
+
readonly id: string;
|
|
83
|
+
readonly clusterDimensions: readonly [number, number, number];
|
|
84
|
+
readonly maxLightsPerCluster: number;
|
|
85
|
+
readonly maxLightCount: number;
|
|
86
|
+
readonly clusterCount: number;
|
|
87
|
+
readonly clusterLightCounts: Buffer;
|
|
88
|
+
readonly clusterLightIndices: Buffer;
|
|
89
|
+
|
|
90
|
+
private readonly clusterLightBitMask: Buffer;
|
|
91
|
+
private readonly uniformBuffer: Buffer;
|
|
92
|
+
private readonly clearComputation: Computation;
|
|
93
|
+
private readonly binningComputation: Computation;
|
|
94
|
+
private readonly compactComputation: Computation;
|
|
95
|
+
private activePointLightCount = 0;
|
|
96
|
+
private depthRange: readonly [number, number] | null = null;
|
|
97
|
+
private destroyed = false;
|
|
98
|
+
|
|
99
|
+
constructor(device: Device, props: ClusteredLightGridProps = {}) {
|
|
100
|
+
if (device.type !== 'webgpu') {
|
|
101
|
+
throw new Error('ClusteredLightGrid requires WebGPU.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.device = device;
|
|
105
|
+
this.id = props.id || 'clustered-light-grid';
|
|
106
|
+
this.clusterDimensions = props.clusterDimensions ?? DEFAULT_CLUSTER_DIMENSIONS;
|
|
107
|
+
this.maxLightsPerCluster = props.maxLightsPerCluster ?? DEFAULT_MAX_LIGHTS_PER_CLUSTER;
|
|
108
|
+
this.maxLightCount = props.maxLightCount ?? MAX_CLUSTERED_POINT_LIGHTS;
|
|
109
|
+
validateClusteredLightGridProps(
|
|
110
|
+
this.clusterDimensions,
|
|
111
|
+
this.maxLightsPerCluster,
|
|
112
|
+
this.maxLightCount
|
|
113
|
+
);
|
|
114
|
+
this.clusterCount =
|
|
115
|
+
this.clusterDimensions[0] * this.clusterDimensions[1] * this.clusterDimensions[2];
|
|
116
|
+
|
|
117
|
+
this.clusterLightCounts = device.createBuffer({
|
|
118
|
+
id: `${this.id}-counts`,
|
|
119
|
+
byteLength: this.clusterCount * Uint32Array.BYTES_PER_ELEMENT,
|
|
120
|
+
usage: Buffer.STORAGE | Buffer.COPY_SRC
|
|
121
|
+
});
|
|
122
|
+
this.clusterLightIndices = device.createBuffer({
|
|
123
|
+
id: `${this.id}-indices`,
|
|
124
|
+
byteLength: this.clusterCount * this.maxLightsPerCluster * Uint32Array.BYTES_PER_ELEMENT,
|
|
125
|
+
usage: Buffer.STORAGE | Buffer.COPY_SRC
|
|
126
|
+
});
|
|
127
|
+
const lightWordCount = getLightWordCount(this.maxLightCount);
|
|
128
|
+
this.clusterLightBitMask = device.createBuffer({
|
|
129
|
+
id: `${this.id}-light-mask`,
|
|
130
|
+
byteLength: this.clusterCount * lightWordCount * Uint32Array.BYTES_PER_ELEMENT,
|
|
131
|
+
usage: Buffer.STORAGE
|
|
132
|
+
});
|
|
133
|
+
this.uniformBuffer = device.createBuffer({
|
|
134
|
+
id: `${this.id}-uniforms`,
|
|
135
|
+
byteLength: CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH,
|
|
136
|
+
usage: Buffer.UNIFORM | Buffer.COPY_DST
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
this.clearComputation = new Computation(device, {
|
|
140
|
+
id: `${this.id}-clear`,
|
|
141
|
+
source: getClearClusterLightBitMaskSource(this.clusterCount, lightWordCount),
|
|
142
|
+
shaderLayout: {
|
|
143
|
+
bindings: [{name: 'clusterLightBitMask', type: 'storage', group: 0, location: 0}]
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
this.clearComputation.setBindings({clusterLightBitMask: this.clusterLightBitMask});
|
|
147
|
+
|
|
148
|
+
this.binningComputation = new Computation(device, {
|
|
149
|
+
id: `${this.id}-bin`,
|
|
150
|
+
source: getClusterBinningSource(this.clusterDimensions, this.maxLightCount),
|
|
151
|
+
shaderLayout: {
|
|
152
|
+
bindings: [
|
|
153
|
+
{name: 'pointLights', type: 'read-only-storage', group: 0, location: 0},
|
|
154
|
+
{name: 'clusterLightBitMask', type: 'storage', group: 0, location: 1},
|
|
155
|
+
{name: 'clusteredLightGrid', type: 'uniform', group: 0, location: 2}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
this.compactComputation = new Computation(device, {
|
|
160
|
+
id: `${this.id}-compact`,
|
|
161
|
+
source: getCompactClusterLightListsSource(
|
|
162
|
+
this.clusterCount,
|
|
163
|
+
lightWordCount,
|
|
164
|
+
this.maxLightsPerCluster,
|
|
165
|
+
this.maxLightCount
|
|
166
|
+
),
|
|
167
|
+
shaderLayout: {
|
|
168
|
+
bindings: [
|
|
169
|
+
{name: 'clusterLightBitMask', type: 'storage', group: 0, location: 0},
|
|
170
|
+
{name: 'clusterLightCounts', type: 'storage', group: 0, location: 1},
|
|
171
|
+
{name: 'clusterLightIndices', type: 'storage', group: 0, location: 2}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Rebuilds cluster counts and light-index lists on the supplied command encoder. */
|
|
178
|
+
encode(commandEncoder: CommandEncoder, options: ClusteredLightGridEncodeOptions): void {
|
|
179
|
+
// Resources and encoder must be live and belong to this grid's device.
|
|
180
|
+
assert(!this.destroyed && !options.pointLights.destroyed && !commandEncoder.destroyed);
|
|
181
|
+
assert(options.pointLights.device === this.device && commandEncoder.device === this.device);
|
|
182
|
+
validateClusteredLightGridEncodeOptions(options, this.maxLightCount);
|
|
183
|
+
// The active prefix must fit in a storage buffer of complete point-light records.
|
|
184
|
+
assert(Boolean(options.pointLights.usage & Buffer.STORAGE));
|
|
185
|
+
assert(
|
|
186
|
+
options.pointLights.byteLength >=
|
|
187
|
+
Math.max(1, options.pointLightCount) * CLUSTERED_POINT_LIGHT_LAYOUT.byteStride
|
|
188
|
+
);
|
|
189
|
+
this.depthRange = [options.nearPlane, options.farPlane];
|
|
190
|
+
this.activePointLightCount = options.pointLightCount;
|
|
191
|
+
this.uniformBuffer.write(makeClusteredLightGridUniformData(options));
|
|
192
|
+
this.binningComputation.setBindings({
|
|
193
|
+
pointLights: options.pointLights,
|
|
194
|
+
clusterLightBitMask: this.clusterLightBitMask,
|
|
195
|
+
clusteredLightGrid: this.uniformBuffer
|
|
196
|
+
});
|
|
197
|
+
this.compactComputation.setBindings({
|
|
198
|
+
clusterLightBitMask: this.clusterLightBitMask,
|
|
199
|
+
clusterLightCounts: this.clusterLightCounts,
|
|
200
|
+
clusterLightIndices: this.clusterLightIndices
|
|
201
|
+
});
|
|
202
|
+
this.clearComputation.predraw(commandEncoder);
|
|
203
|
+
this.binningComputation.predraw(commandEncoder);
|
|
204
|
+
this.compactComputation.predraw(commandEncoder);
|
|
205
|
+
|
|
206
|
+
const computePass = commandEncoder.beginComputePass({id: `${this.id}-build`});
|
|
207
|
+
this.clearComputation.dispatch(
|
|
208
|
+
computePass,
|
|
209
|
+
Math.ceil(
|
|
210
|
+
(this.clusterCount * getLightWordCount(this.maxLightCount)) / CLUSTER_WORKGROUP_SIZE
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
this.binningComputation.dispatch(
|
|
214
|
+
computePass,
|
|
215
|
+
Math.max(1, Math.ceil(options.pointLightCount / CLUSTER_WORKGROUP_SIZE))
|
|
216
|
+
);
|
|
217
|
+
this.compactComputation.dispatch(
|
|
218
|
+
computePass,
|
|
219
|
+
Math.ceil(this.clusterCount / CLUSTER_WORKGROUP_SIZE)
|
|
220
|
+
);
|
|
221
|
+
computePass.end();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Returns the storage bindings available to lighting consumers. */
|
|
225
|
+
getBindings(): ClusteredLightGridBindings {
|
|
226
|
+
assert(!this.destroyed);
|
|
227
|
+
return {
|
|
228
|
+
clusterLightCounts: this.clusterLightCounts,
|
|
229
|
+
clusterLightIndices: this.clusterLightIndices
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Compatibility accessor for shader-pass consumers. */
|
|
234
|
+
getShaderPassBindings(): ClusteredLightGridBindings {
|
|
235
|
+
return this.getBindings();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Returns a snapshot matching the latest encode. Encode before requesting uniforms. */
|
|
239
|
+
getUniforms(): ClusteredLightGridUniforms {
|
|
240
|
+
// A grid must be encoded before its camera/depth metadata can be consumed.
|
|
241
|
+
assert(!this.destroyed && this.depthRange);
|
|
242
|
+
return this.getShaderPassUniforms(this.depthRange[0], this.depthRange[1]);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** Returns the scalar uniforms available to lighting consumers. */
|
|
246
|
+
getShaderPassUniforms(nearPlane: number, farPlane: number): ClusteredLightGridUniforms {
|
|
247
|
+
assert(!this.destroyed);
|
|
248
|
+
validateDepthRange(nearPlane, farPlane);
|
|
249
|
+
return {
|
|
250
|
+
clusterCountX: this.clusterDimensions[0],
|
|
251
|
+
clusterCountY: this.clusterDimensions[1],
|
|
252
|
+
clusterCountZ: this.clusterDimensions[2],
|
|
253
|
+
maxLightsPerCluster: this.maxLightsPerCluster,
|
|
254
|
+
pointLightCount: this.activePointLightCount,
|
|
255
|
+
clusterNearPlane: nearPlane,
|
|
256
|
+
clusterFarPlane: farPlane
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
destroy(): void {
|
|
261
|
+
if (this.destroyed) return;
|
|
262
|
+
this.destroyed = true;
|
|
263
|
+
this.clearComputation.destroy();
|
|
264
|
+
this.binningComputation.destroy();
|
|
265
|
+
this.compactComputation.destroy();
|
|
266
|
+
this.uniformBuffer.destroy();
|
|
267
|
+
this.clusterLightBitMask.destroy();
|
|
268
|
+
this.clusterLightCounts.destroy();
|
|
269
|
+
this.clusterLightIndices.destroy();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getClearClusterLightBitMaskSource(clusterCount: number, lightWordCount: number): string {
|
|
274
|
+
return `\
|
|
275
|
+
const CLUSTER_LIGHT_MASK_WORD_COUNT: u32 = ${clusterCount * lightWordCount}u;
|
|
276
|
+
@group(0) @binding(0) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
|
|
277
|
+
@compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
|
|
278
|
+
@builtin(global_invocation_id) globalId: vec3<u32>
|
|
279
|
+
) {
|
|
280
|
+
if (globalId.x < CLUSTER_LIGHT_MASK_WORD_COUNT) {
|
|
281
|
+
atomicStore(&clusterLightBitMask[globalId.x], 0u);
|
|
282
|
+
}
|
|
283
|
+
}`;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function getClusterBinningSource(
|
|
287
|
+
clusterDimensions: readonly [number, number, number],
|
|
288
|
+
maxLightCount: number
|
|
289
|
+
): string {
|
|
290
|
+
return `\
|
|
291
|
+
const CLUSTER_COUNT_X: u32 = ${clusterDimensions[0]}u;
|
|
292
|
+
const CLUSTER_COUNT_Y: u32 = ${clusterDimensions[1]}u;
|
|
293
|
+
const CLUSTER_COUNT_Z: u32 = ${clusterDimensions[2]}u;
|
|
294
|
+
const MAX_LIGHT_COUNT: u32 = ${maxLightCount}u;
|
|
295
|
+
const LIGHT_WORD_COUNT: u32 = ${getLightWordCount(maxLightCount)}u;
|
|
296
|
+
|
|
297
|
+
struct ClusteredLightGridUniforms {
|
|
298
|
+
projectionMatrix: mat4x4f,
|
|
299
|
+
depthRange: vec2f,
|
|
300
|
+
lightCount: u32,
|
|
301
|
+
padding: u32,
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
struct ClusteredLightGridPointLight {
|
|
305
|
+
positionRange: vec4f,
|
|
306
|
+
payload: vec4f,
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
@group(0) @binding(0) var<storage, read> pointLights: array<ClusteredLightGridPointLight>;
|
|
310
|
+
@group(0) @binding(1) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
|
|
311
|
+
@group(0) @binding(2) var<uniform> clusteredLightGrid: ClusteredLightGridUniforms;
|
|
312
|
+
|
|
313
|
+
fn clusteredLightGrid_getCoordinate(value: f32, size: u32) -> u32 {
|
|
314
|
+
return min(u32(clamp(value, 0.0, 0.999999) * f32(size)), size - 1u);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
fn clusteredLightGrid_getDepthSlice(distance: f32) -> u32 {
|
|
318
|
+
let normalizedDepth = clamp(
|
|
319
|
+
log(distance / clusteredLightGrid.depthRange.x) /
|
|
320
|
+
log(clusteredLightGrid.depthRange.y / clusteredLightGrid.depthRange.x),
|
|
321
|
+
0.0,
|
|
322
|
+
0.999999
|
|
323
|
+
);
|
|
324
|
+
return min(u32(normalizedDepth * f32(CLUSTER_COUNT_Z)), CLUSTER_COUNT_Z - 1u);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
|
|
328
|
+
@builtin(global_invocation_id) globalId: vec3<u32>
|
|
329
|
+
) {
|
|
330
|
+
let lightIndex = globalId.x;
|
|
331
|
+
let lightCount = min(clusteredLightGrid.lightCount, min(MAX_LIGHT_COUNT, arrayLength(&pointLights)));
|
|
332
|
+
if (lightIndex >= lightCount) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let light = pointLights[lightIndex];
|
|
337
|
+
let viewDepth = -light.positionRange.z;
|
|
338
|
+
let minimumDepth = max(clusteredLightGrid.depthRange.x, viewDepth - light.positionRange.w);
|
|
339
|
+
let maximumDepth = min(clusteredLightGrid.depthRange.y, viewDepth + light.positionRange.w);
|
|
340
|
+
if (maximumDepth < clusteredLightGrid.depthRange.x ||
|
|
341
|
+
minimumDepth > clusteredLightGrid.depthRange.y ||
|
|
342
|
+
maximumDepth < minimumDepth) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let isOrthographicProjection = abs(clusteredLightGrid.projectionMatrix[3][3]) > 0.5;
|
|
347
|
+
var minimumUv = vec2f(0.0);
|
|
348
|
+
var maximumUv = vec2f(0.999999);
|
|
349
|
+
// A sphere crossing the camera plane conservatively covers the viewport.
|
|
350
|
+
if (isOrthographicProjection || viewDepth > light.positionRange.w) {
|
|
351
|
+
let projectionScale = vec2f(clusteredLightGrid.projectionMatrix[0][0], clusteredLightGrid.projectionMatrix[1][1]);
|
|
352
|
+
let lower = projectionScale * (light.positionRange.xy - vec2f(light.positionRange.w));
|
|
353
|
+
let upper = projectionScale * (light.positionRange.xy + vec2f(light.positionRange.w));
|
|
354
|
+
var minimumNdc = min(lower, upper) + clusteredLightGrid.projectionMatrix[3].xy;
|
|
355
|
+
var maximumNdc = max(lower, upper) + clusteredLightGrid.projectionMatrix[3].xy;
|
|
356
|
+
if (!isOrthographicProjection) {
|
|
357
|
+
// Project the enclosing box at both depth extremes, including off-axis centers.
|
|
358
|
+
let nearestDepth = max(minimumDepth, clusteredLightGrid.depthRange.x);
|
|
359
|
+
let farthestDepth = max(maximumDepth, nearestDepth);
|
|
360
|
+
minimumNdc = min(min(lower / nearestDepth, upper / nearestDepth), min(lower / farthestDepth, upper / farthestDepth)) - clusteredLightGrid.projectionMatrix[2].xy;
|
|
361
|
+
maximumNdc = max(max(lower / nearestDepth, upper / nearestDepth), max(lower / farthestDepth, upper / farthestDepth)) - clusteredLightGrid.projectionMatrix[2].xy;
|
|
362
|
+
}
|
|
363
|
+
let unclampedMinimumUv = vec2f(minimumNdc.x * 0.5 + 0.5, 0.5 - maximumNdc.y * 0.5);
|
|
364
|
+
let unclampedMaximumUv = vec2f(maximumNdc.x * 0.5 + 0.5, 0.5 - minimumNdc.y * 0.5);
|
|
365
|
+
if (unclampedMaximumUv.x < 0.0 || unclampedMinimumUv.x > 1.0 ||
|
|
366
|
+
unclampedMaximumUv.y < 0.0 || unclampedMinimumUv.y > 1.0) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
minimumUv = clamp(unclampedMinimumUv, vec2f(0.0), vec2f(0.999999));
|
|
371
|
+
maximumUv = clamp(unclampedMaximumUv, vec2f(0.0), vec2f(0.999999));
|
|
372
|
+
}
|
|
373
|
+
let minimumX = clusteredLightGrid_getCoordinate(minimumUv.x, CLUSTER_COUNT_X);
|
|
374
|
+
let maximumX = clusteredLightGrid_getCoordinate(maximumUv.x, CLUSTER_COUNT_X);
|
|
375
|
+
let minimumY = clusteredLightGrid_getCoordinate(minimumUv.y, CLUSTER_COUNT_Y);
|
|
376
|
+
let maximumY = clusteredLightGrid_getCoordinate(maximumUv.y, CLUSTER_COUNT_Y);
|
|
377
|
+
let minimumZ = clusteredLightGrid_getDepthSlice(minimumDepth);
|
|
378
|
+
let maximumZ = clusteredLightGrid_getDepthSlice(maximumDepth);
|
|
379
|
+
let lightWordIndex = lightIndex / 32u;
|
|
380
|
+
let lightBit = 1u << (lightIndex % 32u);
|
|
381
|
+
|
|
382
|
+
for (var depthSlice = minimumZ; depthSlice <= maximumZ; depthSlice++) {
|
|
383
|
+
for (var tileY = minimumY; tileY <= maximumY; tileY++) {
|
|
384
|
+
for (var tileX = minimumX; tileX <= maximumX; tileX++) {
|
|
385
|
+
let clusterIndex = (depthSlice * CLUSTER_COUNT_Y + tileY) * CLUSTER_COUNT_X + tileX;
|
|
386
|
+
atomicOr(&clusterLightBitMask[clusterIndex * LIGHT_WORD_COUNT + lightWordIndex], lightBit);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}`;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function getCompactClusterLightListsSource(
|
|
394
|
+
clusterCount: number,
|
|
395
|
+
lightWordCount: number,
|
|
396
|
+
maxLightsPerCluster: number,
|
|
397
|
+
maxLightCount: number
|
|
398
|
+
): string {
|
|
399
|
+
return `\
|
|
400
|
+
const CLUSTER_COUNT: u32 = ${clusterCount}u;
|
|
401
|
+
const LIGHT_WORD_COUNT: u32 = ${lightWordCount}u;
|
|
402
|
+
const MAX_LIGHTS_PER_CLUSTER: u32 = ${maxLightsPerCluster}u;
|
|
403
|
+
const MAX_LIGHT_COUNT: u32 = ${maxLightCount}u;
|
|
404
|
+
|
|
405
|
+
@group(0) @binding(0) var<storage, read_write> clusterLightBitMask: array<atomic<u32>>;
|
|
406
|
+
@group(0) @binding(1) var<storage, read_write> clusterLightCounts: array<u32>;
|
|
407
|
+
@group(0) @binding(2) var<storage, read_write> clusterLightIndices: array<u32>;
|
|
408
|
+
|
|
409
|
+
@compute @workgroup_size(${CLUSTER_WORKGROUP_SIZE}) fn main(
|
|
410
|
+
@builtin(global_invocation_id) globalId: vec3<u32>
|
|
411
|
+
) {
|
|
412
|
+
let clusterIndex = globalId.x;
|
|
413
|
+
if (clusterIndex >= CLUSTER_COUNT) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
let maskOffset = clusterIndex * LIGHT_WORD_COUNT;
|
|
418
|
+
let indexOffset = clusterIndex * MAX_LIGHTS_PER_CLUSTER;
|
|
419
|
+
var lightCount = 0u;
|
|
420
|
+
for (var lightIndex = 0u; lightIndex < MAX_LIGHT_COUNT; lightIndex++) {
|
|
421
|
+
let lightWord = atomicLoad(&clusterLightBitMask[maskOffset + lightIndex / 32u]);
|
|
422
|
+
let lightBit = 1u << (lightIndex % 32u);
|
|
423
|
+
if ((lightWord & lightBit) != 0u) {
|
|
424
|
+
if (lightCount < MAX_LIGHTS_PER_CLUSTER) {
|
|
425
|
+
clusterLightIndices[indexOffset + lightCount] = lightIndex;
|
|
426
|
+
}
|
|
427
|
+
lightCount += 1u;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
clusterLightCounts[clusterIndex] = lightCount;
|
|
431
|
+
}`;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function getLightWordCount(maxLightCount: number): number {
|
|
435
|
+
return Math.ceil(maxLightCount / 32);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function makeClusteredLightGridUniformData(options: ClusteredLightGridEncodeOptions): ArrayBuffer {
|
|
439
|
+
const data = new ArrayBuffer(CLUSTERED_LIGHT_GRID_UNIFORM_BYTE_LENGTH);
|
|
440
|
+
const floatValues = new Float32Array(data);
|
|
441
|
+
floatValues.set(options.projectionMatrix, 0);
|
|
442
|
+
floatValues[16] = options.nearPlane;
|
|
443
|
+
floatValues[17] = options.farPlane;
|
|
444
|
+
new Uint32Array(data)[18] = options.pointLightCount;
|
|
445
|
+
return data;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function validateClusteredLightGridProps(
|
|
449
|
+
clusterDimensions: readonly [number, number, number],
|
|
450
|
+
maxLightsPerCluster: number,
|
|
451
|
+
maxLightCount: number
|
|
452
|
+
): void {
|
|
453
|
+
if (
|
|
454
|
+
clusterDimensions.some(dimension => !Number.isSafeInteger(dimension) || dimension < 1) ||
|
|
455
|
+
!Number.isSafeInteger(maxLightsPerCluster) ||
|
|
456
|
+
maxLightsPerCluster < 1 ||
|
|
457
|
+
!Number.isSafeInteger(maxLightCount) ||
|
|
458
|
+
maxLightCount < 1
|
|
459
|
+
) {
|
|
460
|
+
throw new Error('Cluster dimensions and capacities must be positive safe integers.');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function validateClusteredLightGridEncodeOptions(
|
|
465
|
+
options: ClusteredLightGridEncodeOptions,
|
|
466
|
+
maxLightCount: number
|
|
467
|
+
): void {
|
|
468
|
+
if (!Number.isSafeInteger(options.pointLightCount) || options.pointLightCount < 0) {
|
|
469
|
+
throw new Error('Point light count must be a non-negative safe integer.');
|
|
470
|
+
}
|
|
471
|
+
if (options.pointLightCount > maxLightCount) {
|
|
472
|
+
throw new Error('Point light count exceeds ClusteredLightGrid capacity.');
|
|
473
|
+
}
|
|
474
|
+
validateDepthRange(options.nearPlane, options.farPlane);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function validateDepthRange(nearPlane: number, farPlane: number): void {
|
|
478
|
+
if (!(nearPlane > 0) || !(farPlane > nearPlane)) {
|
|
479
|
+
throw new Error('Cluster depth range requires 0 < nearPlane < farPlane.');
|
|
480
|
+
}
|
|
481
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {CompositeShaderPass} from '@luma.gl/shaders';
|
|
6
|
+
import {
|
|
7
|
+
contactShadowTrace,
|
|
8
|
+
contactShadowBilateralBlur,
|
|
9
|
+
contactShadowComposite
|
|
10
|
+
} from '@luma.gl/shaders';
|
|
11
|
+
import {SHADOW_QUALITY_SETTINGS} from './shadow-quality';
|
|
12
|
+
|
|
13
|
+
/** Builds the quality-scaled trace, bilateral cleanup, and direct-light composite pipeline. */
|
|
14
|
+
export function createContactShadowCompositeShaderPass(
|
|
15
|
+
options: {quality?: 'low' | 'balanced' | 'cinematic'} = {}
|
|
16
|
+
): CompositeShaderPass<'contactShadowRaw' | 'contactShadowScratch' | 'contactShadowFiltered'> {
|
|
17
|
+
const quality = options.quality || 'balanced';
|
|
18
|
+
const settings = SHADOW_QUALITY_SETTINGS[quality];
|
|
19
|
+
if (!settings) {
|
|
20
|
+
throw new Error(`Unknown shadow quality: ${String(quality)}.`);
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
name: 'contactShadowCompositeShaderPass',
|
|
24
|
+
renderTargets: {
|
|
25
|
+
contactShadowRaw: {
|
|
26
|
+
scale: [settings.contactScale, settings.contactScale],
|
|
27
|
+
format: 'rgba8unorm'
|
|
28
|
+
},
|
|
29
|
+
contactShadowScratch: {
|
|
30
|
+
scale: [settings.contactScale, settings.contactScale],
|
|
31
|
+
format: 'rgba8unorm'
|
|
32
|
+
},
|
|
33
|
+
contactShadowFiltered: {
|
|
34
|
+
scale: [settings.contactScale, settings.contactScale],
|
|
35
|
+
format: 'rgba8unorm'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
steps: [
|
|
39
|
+
{
|
|
40
|
+
shaderPass: contactShadowTrace,
|
|
41
|
+
inputs: {sourceTexture: 'previous'},
|
|
42
|
+
output: 'contactShadowRaw',
|
|
43
|
+
uniforms: {stepCount: settings.contactStepCount}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
shaderPass: contactShadowBilateralBlur,
|
|
47
|
+
inputs: {sourceTexture: 'contactShadowRaw'},
|
|
48
|
+
output: 'contactShadowScratch',
|
|
49
|
+
uniforms: {direction: [1, 0]}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
shaderPass: contactShadowBilateralBlur,
|
|
53
|
+
inputs: {sourceTexture: 'contactShadowScratch'},
|
|
54
|
+
output: 'contactShadowFiltered',
|
|
55
|
+
uniforms: {direction: [0, 1]}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
shaderPass: contactShadowComposite,
|
|
59
|
+
inputs: {
|
|
60
|
+
sourceTexture: 'previous',
|
|
61
|
+
contactShadowTexture: 'contactShadowFiltered'
|
|
62
|
+
},
|
|
63
|
+
output: 'previous'
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
}
|