@luma.gl/engine 10.0.0-alpha.9 → 10.0.0-beta.2
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/deform-positions.d.ts +1 -1
- package/dist/animation/deform-positions.d.ts.map +1 -1
- 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/animation/skin.cjs +4 -4
- package/dist/animation/skin.d.ts +1 -1
- package/dist/animation/skin.d.ts.map +1 -1
- package/dist/animation/skin.js +1 -1
- package/dist/animation/skin.js.map +1 -1
- package/dist/animation/texture-transform.cjs +7 -7
- package/dist/animation/texture-transform.js +1 -1
- package/dist/animation/texture-transform.js.map +1 -1
- package/dist/arrow/arrow-mesh-types.d.ts +1 -1
- package/dist/arrow/arrow-mesh-types.d.ts.map +1 -1
- package/dist/arrow/index.cjs.map +2 -2
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.cjs +2 -2
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.d.ts +1 -1
- package/dist/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.js +1 -1
- package/dist/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.cjs +14 -15
- 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 +23 -18
- 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/audio/audio-controller.cjs +6 -6
- package/dist/audio/audio-controller.d.ts +1 -1
- package/dist/audio/audio-controller.d.ts.map +1 -1
- package/dist/audio/audio-controller.js +1 -1
- package/dist/audio/audio-controller.js.map +1 -1
- package/dist/audio/audio-environment.cjs +6 -6
- package/dist/audio/audio-environment.d.ts +1 -1
- package/dist/audio/audio-environment.d.ts.map +1 -1
- package/dist/audio/audio-environment.js +1 -1
- package/dist/audio/audio-environment.js.map +1 -1
- package/dist/compute/computation.cjs +1 -1
- package/dist/compute/computation.d.ts +1 -1
- package/dist/compute/computation.d.ts.map +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/debug/pixel-data-utils.d.ts +1 -1
- package/dist/debug/pixel-data-utils.d.ts.map +1 -1
- package/dist/dist.dev.js +1087 -570
- 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/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts +1 -1
- package/dist/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts +1 -1
- package/dist/effects/passes/screen-space/clustered-volumetric-lighting.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.cjs +4 -4
- package/dist/effects/passes/screen-space/gtao.d.ts +1 -1
- package/dist/effects/passes/screen-space/gtao.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/gtao.js +1 -1
- package/dist/effects/passes/screen-space/gtao.js.map +1 -1
- package/dist/effects/passes/screen-space/height-fog.d.ts +1 -1
- package/dist/effects/passes/screen-space/height-fog.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts +1 -1
- package/dist/effects/passes/screen-space/screen-space-global-illumination.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts +1 -1
- package/dist/effects/passes/screen-space/screen-space-reflections.d.ts.map +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.d.ts +1 -1
- package/dist/effects/passes/screen-space/ssr-camera-temporal.d.ts.map +1 -1
- package/dist/experimental/controls/index.cjs +0 -3
- package/dist/experimental/controls/index.cjs.map +2 -2
- package/dist/experimental/controls/index.d.ts +0 -2
- package/dist/experimental/controls/index.d.ts.map +1 -1
- package/dist/experimental/controls/index.js +0 -1
- package/dist/experimental/controls/index.js.map +1 -1
- package/dist/experimental/webxr/webxr-input.d.ts +1 -1
- package/dist/experimental/webxr/webxr-input.d.ts.map +1 -1
- package/dist/experimental-controls.cjs +21 -0
- package/dist/experimental-controls.d.ts +2 -0
- package/dist/experimental-controls.d.ts.map +1 -0
- package/dist/experimental-controls.js +5 -0
- package/dist/experimental-controls.js.map +1 -0
- package/dist/experimental-materials.cjs +21 -0
- package/dist/experimental-materials.d.ts +2 -0
- package/dist/experimental-materials.d.ts.map +1 -0
- package/dist/experimental-materials.js +5 -0
- package/dist/experimental-materials.js.map +1 -0
- package/dist/experimental-textures.cjs +21 -0
- package/dist/experimental-textures.d.ts +2 -0
- package/dist/experimental-textures.d.ts.map +1 -0
- package/dist/experimental-textures.js +5 -0
- package/dist/experimental-textures.js.map +1 -0
- package/dist/{experimental/controls/orbit-controls.cjs → experimental-webxr.cjs} +5 -11
- package/dist/experimental-webxr.d.ts +2 -0
- package/dist/experimental-webxr.d.ts.map +1 -0
- package/dist/experimental-webxr.js +5 -0
- package/dist/experimental-webxr.js.map +1 -0
- package/dist/geometry/edge-geometry.d.ts +1 -1
- package/dist/geometry/edge-geometry.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.cjs +18 -17
- package/dist/geometry/geometry-primitives.d.ts +2 -2
- package/dist/geometry/geometry-primitives.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.js +3 -2
- package/dist/geometry/geometry-primitives.js.map +1 -1
- package/dist/geometry/geometry-table.d.ts +1 -1
- package/dist/geometry/geometry-table.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.cjs +6 -6
- package/dist/geometry/geometry-utils.d.ts +2 -2
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +1 -1
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.cjs +2 -2
- package/dist/geometry/geometry.d.ts +4 -3
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +1 -1
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.d.ts +1 -1
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +1 -1
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -1
- package/dist/geometry/ring-geometry.cjs +6 -6
- package/dist/geometry/ring-geometry.d.ts +1 -1
- package/dist/geometry/ring-geometry.d.ts.map +1 -1
- package/dist/geometry/ring-geometry.js +2 -2
- package/dist/geometry/ring-geometry.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 +1 -1
- 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-animated-crowd.d.ts +2 -1
- package/dist/gltf/gltf/gltf-animated-crowd.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-animated-crowd.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/gltf/gltf-instancing.cjs +2 -2
- package/dist/gltf/gltf/gltf-instancing.d.ts +1 -1
- package/dist/gltf/gltf/gltf-instancing.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-instancing.js +1 -1
- package/dist/gltf/gltf/gltf-instancing.js.map +1 -1
- package/dist/gltf/gltf/gltf-lightmap.cjs +2 -2
- package/dist/gltf/gltf/gltf-lightmap.d.ts +1 -1
- package/dist/gltf/gltf/gltf-lightmap.d.ts.map +1 -1
- package/dist/gltf/gltf/gltf-lightmap.js +1 -1
- package/dist/gltf/gltf/gltf-lightmap.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 +41 -77
- 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 +35 -92
- 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 +40 -30
- 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 +18 -6
- 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/physics/export-state.cjs +8 -8
- package/dist/gltf/physics/export-state.js +1 -1
- package/dist/gltf/physics/export-state.js.map +1 -1
- package/dist/gltf/physics/index.cjs.map +2 -2
- package/dist/gltf/physics/mesh-snapshot.cjs +3 -3
- package/dist/gltf/physics/mesh-snapshot.js +1 -1
- package/dist/gltf/physics/mesh-snapshot.js.map +1 -1
- package/dist/gltf/physics/node-collision-geometry.cjs +3 -3
- package/dist/gltf/physics/node-collision-geometry.js +1 -1
- package/dist/gltf/physics/node-collision-geometry.js.map +1 -1
- package/dist/gltf/physics/parse-gltf-physics.cjs +10 -10
- package/dist/gltf/physics/parse-gltf-physics.js +1 -1
- package/dist/gltf/physics/parse-gltf-physics.js.map +1 -1
- package/dist/gltf/physics/parse-physics-joints.cjs +3 -3
- package/dist/gltf/physics/parse-physics-joints.d.ts +1 -1
- package/dist/gltf/physics/parse-physics-joints.d.ts.map +1 -1
- package/dist/gltf/physics/parse-physics-joints.js +1 -1
- package/dist/gltf/physics/parse-physics-joints.js.map +1 -1
- package/dist/gltf/physics/property-bindings.cjs +4 -4
- package/dist/gltf/physics/property-bindings.js +1 -1
- package/dist/gltf/physics/property-bindings.js.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 +2 -2
- 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 +12 -9
- package/dist/graph/models/path/path-storage-model.d.ts +4 -2
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -1
- package/dist/graph/models/path/path-storage-model.js +8 -3
- package/dist/graph/models/path/path-storage-model.js.map +1 -1
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +4 -4
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-attribute-model.js +1 -1
- package/dist/graph/models/polygon/polygon-shaders.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-storage-model.cjs +4 -4
- package/dist/graph/models/polygon/polygon-storage-model.d.ts +1 -1
- package/dist/graph/models/polygon/polygon-storage-model.js +1 -1
- package/dist/graph/physics/index.cjs.map +2 -2
- package/dist/graph/physics/index.d.ts +1 -1
- package/dist/graph/physics/index.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller-geometry.cjs +8 -8
- package/dist/graph/physics/physics-controller-geometry.js +2 -2
- package/dist/graph/physics/physics-controller-geometry.js.map +1 -1
- package/dist/graph/physics/physics-controller.cjs +106 -0
- package/dist/graph/physics/physics-controller.d.ts +41 -3
- package/dist/graph/physics/physics-controller.d.ts.map +1 -1
- package/dist/graph/physics/physics-controller.js +106 -0
- package/dist/graph/physics/physics-controller.js.map +1 -1
- package/dist/graph/physics/physics-scenegraph.cjs +4 -4
- package/dist/graph/physics/physics-scenegraph.d.ts +1 -1
- package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -1
- package/dist/graph/physics/physics-scenegraph.js +1 -1
- package/dist/graph/physics/physics-scenegraph.js.map +1 -1
- package/dist/graph/physics/scenegraph-instance.cjs +16 -2
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-instance.js +17 -1
- package/dist/graph/physics/scenegraph-instance.js.map +1 -1
- package/dist/graph/physics/scenegraph-motion.cjs +7 -7
- package/dist/graph/physics/scenegraph-motion.d.ts +1 -1
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-motion.js +1 -1
- package/dist/graph/physics/scenegraph-motion.js.map +1 -1
- package/dist/graph/physics/scenegraph-properties.cjs +3 -3
- package/dist/graph/physics/scenegraph-properties.js +1 -1
- package/dist/graph/physics/scenegraph-properties.js.map +1 -1
- package/dist/graph/physics/scenegraph-publication.cjs +5 -5
- package/dist/graph/physics/scenegraph-publication.d.ts +1 -1
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -1
- package/dist/graph/physics/scenegraph-publication.js +1 -1
- package/dist/graph/physics/scenegraph-publication.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 +2 -2
- 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 +32 -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 +24 -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 +78 -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/model/model.d.ts +1 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/models/light-model-utils.cjs +4 -4
- package/dist/models/light-model-utils.d.ts +3 -2
- package/dist/models/light-model-utils.d.ts.map +1 -1
- package/dist/models/light-model-utils.js +3 -3
- package/dist/models/light-model-utils.js.map +1 -1
- package/dist/modules/picking/color-picking.d.ts +1 -1
- package/dist/modules/picking/index-color-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts +1 -1
- package/dist/modules/picking/picking-uniforms.d.ts.map +1 -1
- package/dist/modules/picking/picking.d.ts +1 -1
- package/dist/scenegraph/controllers/area-light-controller.cjs +11 -11
- package/dist/scenegraph/controllers/area-light-controller.js +1 -1
- package/dist/scenegraph/controllers/area-light-controller.js.map +1 -1
- package/dist/scenegraph/controllers/billboard-controller.cjs +28 -28
- package/dist/scenegraph/controllers/billboard-controller.d.ts +2 -1
- package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -1
- package/dist/scenegraph/controllers/billboard-controller.js +1 -1
- package/dist/scenegraph/controllers/billboard-controller.js.map +1 -1
- package/dist/scenegraph/controllers/joint-controller.cjs +5 -5
- package/dist/scenegraph/controllers/joint-controller.js +1 -1
- package/dist/scenegraph/controllers/joint-controller.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/controllers/skin-controller.cjs +2 -2
- package/dist/scenegraph/controllers/skin-controller.js +1 -1
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -1
- package/dist/scenegraph/group-node.cjs +14 -14
- package/dist/scenegraph/group-node.d.ts +2 -2
- package/dist/scenegraph/group-node.d.ts.map +1 -1
- package/dist/scenegraph/group-node.js +1 -1
- package/dist/scenegraph/group-node.js.map +1 -1
- package/dist/scenegraph/model-node.d.ts +1 -1
- package/dist/scenegraph/model-node.d.ts.map +1 -1
- package/dist/scenegraph/physics-transforms.cjs +2 -2
- package/dist/scenegraph/physics-transforms.d.ts +1 -1
- package/dist/scenegraph/physics-transforms.d.ts.map +1 -1
- package/dist/scenegraph/physics-transforms.js +1 -1
- package/dist/scenegraph/physics-transforms.js.map +1 -1
- 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-bounds.cjs +3 -3
- package/dist/scenegraph/scenegraph-bounds.d.ts +1 -1
- package/dist/scenegraph/scenegraph-bounds.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-bounds.js +1 -1
- package/dist/scenegraph/scenegraph-bounds.js.map +1 -1
- 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 +17 -7
- package/dist/scenegraph/scenegraph-node.d.ts +12 -1
- package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
- package/dist/scenegraph/scenegraph-node.js +11 -1
- package/dist/scenegraph/scenegraph-node.js.map +1 -1
- package/dist/scenegraph/transform-source.d.ts +1 -1
- package/dist/scenegraph/transform-source.d.ts.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/dist/text/text-3d/extrude.cjs +15 -15
- package/dist/text/text-3d/extrude.js +1 -1
- package/dist/text/text-3d/extrude.js.map +1 -1
- package/dist/text/text-3d/index.cjs.map +2 -2
- package/dist/text/text-3d/paths/curves.cjs +5 -5
- package/dist/text/text-3d/paths/curves.d.ts +1 -1
- package/dist/text/text-3d/paths/curves.d.ts.map +1 -1
- package/dist/text/text-3d/paths/curves.js +1 -1
- package/dist/text/text-3d/paths/curves.js.map +1 -1
- package/dist/text/text-3d/paths/path.cjs +5 -5
- package/dist/text/text-3d/paths/path.d.ts +1 -1
- package/dist/text/text-3d/paths/path.d.ts.map +1 -1
- package/dist/text/text-3d/paths/path.js +1 -1
- package/dist/text/text-3d/paths/path.js.map +1 -1
- package/dist/text/text-3d/paths/shape-path.d.ts +1 -1
- package/dist/text/text-3d/paths/shape-path.d.ts.map +1 -1
- package/dist/text/text-3d/paths/shape-utils.cjs +2 -2
- package/dist/text/text-3d/paths/shape-utils.d.ts +1 -1
- package/dist/text/text-3d/paths/shape-utils.d.ts.map +1 -1
- package/dist/text/text-3d/paths/shape-utils.js +1 -1
- package/dist/text/text-3d/paths/shape-utils.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 +21 -13
- package/src/animation/deform-positions.ts +1 -1
- package/src/animation/node-animation-binding.ts +18 -1
- package/src/animation/skin.ts +2 -1
- package/src/animation/texture-transform.ts +1 -1
- package/src/arrow/arrow-geometry.ts +1 -1
- package/src/arrow/arrow-mesh-types.ts +1 -1
- package/src/arrow/renderers/path/conversion/arrow-path-storage-gpu-vectors.ts +1 -1
- package/src/arrow/renderers/polygon/renderers/arrow-polygon-renderer.ts +1 -1
- package/src/arrow/renderers/splats/conversion/make-gpu-splat-data-from-gltf.ts +24 -20
- package/src/arrow/renderers/text/renderers/arrow-text-shaders.ts +1 -1
- package/src/audio/audio-controller.ts +1 -1
- package/src/audio/audio-environment.ts +1 -1
- package/src/compute/computation.ts +2 -2
- package/src/compute/swap.ts +2 -2
- package/src/debug/pixel-data-utils.ts +1 -1
- 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/effects/passes/screen-space/camera-reprojection-temporal-antialiasing.ts +1 -1
- package/src/effects/passes/screen-space/clustered-volumetric-lighting.ts +1 -1
- package/src/effects/passes/screen-space/gtao.ts +1 -1
- package/src/effects/passes/screen-space/height-fog.ts +1 -1
- package/src/effects/passes/screen-space/screen-space-global-illumination.ts +1 -1
- package/src/effects/passes/screen-space/screen-space-reflections.ts +1 -1
- package/src/effects/passes/screen-space/ssr-camera-temporal.ts +1 -1
- package/src/experimental/controls/index.ts +0 -2
- package/src/experimental/webxr/webxr-input.ts +1 -1
- package/{dist/experimental/controls/orbit-controls.js → src/experimental-controls.ts} +2 -2
- package/src/experimental-materials.ts +5 -0
- package/src/experimental-textures.ts +5 -0
- package/src/experimental-webxr.ts +5 -0
- package/src/geometry/edge-geometry.ts +2 -2
- package/src/geometry/geometry-primitives.ts +6 -3
- package/src/geometry/geometry-table.ts +1 -1
- package/src/geometry/geometry-utils.ts +3 -3
- package/src/geometry/geometry.ts +7 -7
- package/src/geometry/gpu-geometry.ts +1 -1
- package/src/geometry/gpu-vector-geometry-adapter.ts +1 -1
- package/src/geometry/ring-geometry.ts +2 -2
- package/src/gltf/gltf/animations/animations.ts +8 -1
- package/src/gltf/gltf/create-gltf-model.ts +5 -1
- package/src/gltf/gltf/create-scenegraph-from-gltf.ts +98 -17
- package/src/gltf/gltf/gltf-animated-crowd.ts +2 -1
- package/src/gltf/gltf/gltf-billboard.ts +6 -1
- package/src/gltf/gltf/gltf-extension-support.ts +2 -2
- package/src/gltf/gltf/gltf-instancing.ts +1 -1
- package/src/gltf/gltf/gltf-lightmap.ts +1 -1
- 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 +43 -131
- 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 +36 -8
- package/src/gltf/pbr/pbr-environment.ts +27 -1
- package/src/gltf/pbr/pbr-material.ts +8 -3
- package/src/gltf/physics/export-state.ts +1 -1
- package/src/gltf/physics/mesh-snapshot.ts +1 -1
- package/src/gltf/physics/node-collision-geometry.ts +1 -1
- package/src/gltf/physics/parse-gltf-physics.ts +1 -1
- package/src/gltf/physics/parse-physics-joints.ts +1 -1
- package/src/gltf/physics/property-bindings.ts +1 -1
- 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 +13 -4
- package/src/graph/models/polygon/polygon-attribute-model.ts +1 -1
- package/src/graph/models/polygon/polygon-storage-model.ts +1 -1
- package/src/graph/physics/index.ts +1 -0
- package/src/graph/physics/physics-controller-geometry.ts +2 -2
- package/src/graph/physics/physics-controller.ts +155 -2
- package/src/graph/physics/physics-scenegraph.ts +1 -1
- package/src/graph/physics/scenegraph-instance.ts +27 -1
- package/src/graph/physics/scenegraph-motion.ts +1 -1
- package/src/graph/physics/scenegraph-properties.ts +1 -1
- package/src/graph/physics/scenegraph-publication.ts +1 -1
- package/src/graph/tables/gpu-table-model.ts +3 -2
- package/src/index.ts +17 -0
- package/src/lighting/ambient-occlusion-pass.ts +131 -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 +108 -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 +361 -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/model/model.ts +1 -1
- package/src/models/light-model-utils.ts +5 -3
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/scenegraph/controllers/area-light-controller.ts +1 -1
- package/src/scenegraph/controllers/billboard-controller.ts +2 -1
- package/src/scenegraph/controllers/joint-controller.ts +1 -1
- package/src/scenegraph/controllers/punctual-light-controller.ts +172 -0
- package/src/scenegraph/controllers/skin-controller.ts +1 -1
- package/src/scenegraph/group-node.ts +2 -2
- package/src/scenegraph/model-node.ts +1 -1
- package/src/scenegraph/physics-transforms.ts +1 -1
- package/src/scenegraph/scene-metadata.ts +23 -0
- package/src/scenegraph/scenegraph-bounds.ts +2 -2
- package/src/scenegraph/scenegraph-interaction.ts +131 -0
- package/src/scenegraph/scenegraph-node.ts +14 -1
- package/src/scenegraph/transform-source.ts +1 -1
- 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
- package/src/text/text-3d/extrude.ts +1 -1
- package/src/text/text-3d/font.ts +1 -1
- package/src/text/text-3d/paths/curves.ts +1 -1
- package/src/text/text-3d/paths/path.ts +1 -1
- package/src/text/text-3d/paths/shape-path.ts +1 -1
- package/src/text/text-3d/paths/shape-utils.ts +2 -2
- package/dist/experimental/controls/orbit-controls.d.ts +0 -3
- package/dist/experimental/controls/orbit-controls.d.ts.map +0 -1
- package/dist/experimental/controls/orbit-controls.js.map +0 -1
- package/src/experimental/controls/orbit-controls.ts +0 -6
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
assert,
|
|
6
|
+
Texture,
|
|
7
|
+
type Device,
|
|
8
|
+
type Framebuffer,
|
|
9
|
+
type RenderPass,
|
|
10
|
+
type TextureFormatColor
|
|
11
|
+
} from '@luma.gl/core';
|
|
12
|
+
import {lightmapFilter} from '@luma.gl/shaders';
|
|
13
|
+
import {ClipSpace} from '../models/clip-space';
|
|
14
|
+
|
|
15
|
+
export type LightmapBakerProps = {width: number; height: number; format?: TextureFormatColor};
|
|
16
|
+
export type LightmapTextures = {lightmapTexture: Texture};
|
|
17
|
+
export type LightmapBakeView = {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
sampleIndex: number;
|
|
21
|
+
framebuffer: Framebuffer;
|
|
22
|
+
renderPass: RenderPass;
|
|
23
|
+
};
|
|
24
|
+
export type LightmapBakeOptions = {
|
|
25
|
+
/** Upload model uniforms and prepare shadow maps before the atlas pass starts. */
|
|
26
|
+
prepareSample?: (view: Omit<LightmapBakeView, 'renderPass'>) => void;
|
|
27
|
+
/** Draw caller-selected UV-space models. Alpha must contain positive chart IDs. */
|
|
28
|
+
drawSample: (view: LightmapBakeView) => void;
|
|
29
|
+
/** Borrowed same-size linear texture: red contains the permitted chart ID for each gutter texel. */
|
|
30
|
+
chartTexture?: Texture;
|
|
31
|
+
/** Number of one-texel dilation steps, from zero to sixteen. Requires chartTexture. */
|
|
32
|
+
dilationSteps?: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type Target = {texture: Texture; framebuffer: Framebuffer; format: TextureFormatColor};
|
|
36
|
+
|
|
37
|
+
/** Owns an independent linear irradiance texture, including alpha chart coverage. */
|
|
38
|
+
export class LightmapBakeResult {
|
|
39
|
+
readonly textures: LightmapTextures;
|
|
40
|
+
private destroyed = false;
|
|
41
|
+
constructor(texture: Texture) {
|
|
42
|
+
this.textures = {lightmapTexture: texture};
|
|
43
|
+
}
|
|
44
|
+
destroy(): void {
|
|
45
|
+
if (!this.destroyed) {
|
|
46
|
+
this.destroyed = true;
|
|
47
|
+
this.textures.lightmapTexture.destroy();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Records UV-space samples and arithmetic-mean accumulation without traversal or submission. */
|
|
53
|
+
export class LightmapBaker {
|
|
54
|
+
readonly device: Device;
|
|
55
|
+
readonly format: TextureFormatColor;
|
|
56
|
+
private targets: Target[] = [];
|
|
57
|
+
private filters = new Map<number, ClipSpace>();
|
|
58
|
+
private activeIndex = 1;
|
|
59
|
+
private previewIndex = 3;
|
|
60
|
+
private destroyed = false;
|
|
61
|
+
private needsClear = true;
|
|
62
|
+
private samples = 0;
|
|
63
|
+
|
|
64
|
+
constructor(device: Device, props: LightmapBakerProps) {
|
|
65
|
+
this.device = device;
|
|
66
|
+
this.format = props.format ?? 'rgba16float';
|
|
67
|
+
const capabilities = device.getTextureFormatCapabilities(this.format);
|
|
68
|
+
// Require explicit linear floating-point storage; never silently clip irradiance.
|
|
69
|
+
assert(
|
|
70
|
+
(this.format === 'rgba16float' || this.format === 'rgba32float') &&
|
|
71
|
+
capabilities.render &&
|
|
72
|
+
capabilities.filter
|
|
73
|
+
);
|
|
74
|
+
// Accumulation uses unfiltered float32 history so small late samples survive rounding.
|
|
75
|
+
assert(device.getTextureFormatCapabilities('rgba32float').render);
|
|
76
|
+
this.resize(props);
|
|
77
|
+
}
|
|
78
|
+
get width(): number {
|
|
79
|
+
return this.targets[0].texture.width;
|
|
80
|
+
}
|
|
81
|
+
get height(): number {
|
|
82
|
+
return this.targets[0].texture.height;
|
|
83
|
+
}
|
|
84
|
+
get sampleCount(): number {
|
|
85
|
+
return this.samples;
|
|
86
|
+
}
|
|
87
|
+
/** Borrowed current preview. Reacquire after every update or resize. */
|
|
88
|
+
get textures(): LightmapTextures {
|
|
89
|
+
assert(!this.destroyed);
|
|
90
|
+
return {lightmapTexture: this.targets[this.previewIndex].texture};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
reset(): void {
|
|
94
|
+
assert(!this.destroyed);
|
|
95
|
+
this.samples = 0;
|
|
96
|
+
this.needsClear = true;
|
|
97
|
+
}
|
|
98
|
+
resize(props: Pick<LightmapBakerProps, 'width' | 'height'>): void {
|
|
99
|
+
assert(!this.destroyed);
|
|
100
|
+
assert(
|
|
101
|
+
Number.isInteger(props.width) &&
|
|
102
|
+
props.width > 0 &&
|
|
103
|
+
Number.isInteger(props.height) &&
|
|
104
|
+
props.height > 0
|
|
105
|
+
);
|
|
106
|
+
if (this.targets.length && props.width === this.width && props.height === this.height) return;
|
|
107
|
+
const targets: Target[] = [];
|
|
108
|
+
try {
|
|
109
|
+
for (let index = 0; index < 5; index++)
|
|
110
|
+
targets.push(
|
|
111
|
+
this.createTarget(
|
|
112
|
+
props.width,
|
|
113
|
+
props.height,
|
|
114
|
+
index === 1 || index === 2 ? 'rgba32float' : this.format
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
for (const target of targets) this.destroyTarget(target);
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
for (const target of this.targets) this.destroyTarget(target);
|
|
122
|
+
this.targets = targets;
|
|
123
|
+
this.activeIndex = 1;
|
|
124
|
+
this.previewIndex = 3;
|
|
125
|
+
this.reset();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Record one update per submission. Failed draw callbacks leave accumulation/sample count unchanged. */
|
|
129
|
+
update(options: LightmapBakeOptions): LightmapTextures {
|
|
130
|
+
assert(!this.destroyed);
|
|
131
|
+
const steps = options.dilationSteps ?? 0;
|
|
132
|
+
assert(Number.isInteger(steps) && steps >= 0 && steps <= 16);
|
|
133
|
+
const chartTexture = options.chartTexture;
|
|
134
|
+
if (steps) {
|
|
135
|
+
// Chart ownership is explicit, preventing dilation between adjacent islands.
|
|
136
|
+
assert(
|
|
137
|
+
chartTexture &&
|
|
138
|
+
!chartTexture.destroyed &&
|
|
139
|
+
chartTexture.device === this.device &&
|
|
140
|
+
chartTexture.width === this.width &&
|
|
141
|
+
chartTexture.height === this.height &&
|
|
142
|
+
chartTexture.dimension === '2d'
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
if (this.needsClear) {
|
|
146
|
+
for (const target of this.targets) {
|
|
147
|
+
const pass = this.device.beginRenderPass({
|
|
148
|
+
framebuffer: target.framebuffer,
|
|
149
|
+
clearColor: [0, 0, 0, 0]
|
|
150
|
+
});
|
|
151
|
+
pass.end();
|
|
152
|
+
}
|
|
153
|
+
this.needsClear = false;
|
|
154
|
+
}
|
|
155
|
+
const target = this.targets[0];
|
|
156
|
+
const view = {
|
|
157
|
+
width: this.width,
|
|
158
|
+
height: this.height,
|
|
159
|
+
sampleIndex: this.samples,
|
|
160
|
+
framebuffer: target.framebuffer
|
|
161
|
+
};
|
|
162
|
+
options.prepareSample?.(view);
|
|
163
|
+
const renderPass = this.device.beginRenderPass({
|
|
164
|
+
framebuffer: target.framebuffer,
|
|
165
|
+
clearColor: [0, 0, 0, 0]
|
|
166
|
+
});
|
|
167
|
+
try {
|
|
168
|
+
renderPass.setParameters({viewport: [0, 0, this.width, this.height]});
|
|
169
|
+
options.drawSample({...view, renderPass});
|
|
170
|
+
} finally {
|
|
171
|
+
renderPass.end();
|
|
172
|
+
}
|
|
173
|
+
const nextIndex = this.activeIndex === 1 ? 2 : 1;
|
|
174
|
+
this.filter(
|
|
175
|
+
0,
|
|
176
|
+
0,
|
|
177
|
+
this.targets[this.activeIndex].texture,
|
|
178
|
+
this.targets[0].texture,
|
|
179
|
+
this.targets[nextIndex],
|
|
180
|
+
1 / (this.samples + 1)
|
|
181
|
+
);
|
|
182
|
+
this.activeIndex = nextIndex;
|
|
183
|
+
this.samples++;
|
|
184
|
+
this.filter(
|
|
185
|
+
17,
|
|
186
|
+
2,
|
|
187
|
+
this.targets[nextIndex].texture,
|
|
188
|
+
this.targets[nextIndex].texture,
|
|
189
|
+
this.targets[3],
|
|
190
|
+
1
|
|
191
|
+
);
|
|
192
|
+
this.previewIndex = 3;
|
|
193
|
+
for (let step = 0; step < steps; step++) {
|
|
194
|
+
const destinationIndex = step % 2 === 0 ? 4 : 3;
|
|
195
|
+
this.filter(
|
|
196
|
+
step + 1,
|
|
197
|
+
1,
|
|
198
|
+
chartTexture!,
|
|
199
|
+
this.targets[this.previewIndex].texture,
|
|
200
|
+
this.targets[destinationIndex],
|
|
201
|
+
1
|
|
202
|
+
);
|
|
203
|
+
this.previewIndex = destinationIndex;
|
|
204
|
+
}
|
|
205
|
+
return this.textures;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Records a copy into independent storage. Submit before releasing referenced resources. */
|
|
209
|
+
createResult(): LightmapBakeResult {
|
|
210
|
+
assert(!this.destroyed && this.samples > 0);
|
|
211
|
+
const target = this.createTarget(this.width, this.height);
|
|
212
|
+
try {
|
|
213
|
+
this.device.commandEncoder.copyTextureToTexture({
|
|
214
|
+
sourceTexture: this.textures.lightmapTexture,
|
|
215
|
+
destinationTexture: target.texture,
|
|
216
|
+
width: this.width,
|
|
217
|
+
height: this.height
|
|
218
|
+
});
|
|
219
|
+
return new LightmapBakeResult(target.texture);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
target.texture.destroy();
|
|
222
|
+
throw error;
|
|
223
|
+
} finally {
|
|
224
|
+
target.framebuffer.destroy();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
destroy(): void {
|
|
229
|
+
if (this.destroyed) return;
|
|
230
|
+
this.destroyed = true;
|
|
231
|
+
for (const filter of this.filters.values()) filter.destroy();
|
|
232
|
+
for (const target of this.targets) this.destroyTarget(target);
|
|
233
|
+
}
|
|
234
|
+
private createTarget(
|
|
235
|
+
width: number,
|
|
236
|
+
height: number,
|
|
237
|
+
format: TextureFormatColor = this.format
|
|
238
|
+
): Target {
|
|
239
|
+
const texture = this.device.createTexture({
|
|
240
|
+
width,
|
|
241
|
+
height,
|
|
242
|
+
format,
|
|
243
|
+
usage: Texture.RENDER_ATTACHMENT | Texture.SAMPLE | Texture.COPY_SRC | Texture.COPY_DST,
|
|
244
|
+
sampler:
|
|
245
|
+
format === 'rgba32float'
|
|
246
|
+
? {minFilter: 'nearest', magFilter: 'nearest'}
|
|
247
|
+
: {minFilter: 'linear', magFilter: 'linear'}
|
|
248
|
+
});
|
|
249
|
+
try {
|
|
250
|
+
return {
|
|
251
|
+
texture,
|
|
252
|
+
format,
|
|
253
|
+
framebuffer: this.device.createFramebuffer({width, height, colorAttachments: [texture]})
|
|
254
|
+
};
|
|
255
|
+
} catch (error) {
|
|
256
|
+
texture.destroy();
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
private destroyTarget(target: Target): void {
|
|
261
|
+
target.framebuffer.destroy();
|
|
262
|
+
target.texture.destroy();
|
|
263
|
+
}
|
|
264
|
+
private filter(
|
|
265
|
+
index: number,
|
|
266
|
+
mode: number,
|
|
267
|
+
previous: Texture,
|
|
268
|
+
current: Texture,
|
|
269
|
+
target: Target,
|
|
270
|
+
weight: number
|
|
271
|
+
): void {
|
|
272
|
+
let model = this.filters.get(index);
|
|
273
|
+
if (!model) {
|
|
274
|
+
model = new ClipSpace(this.device, {
|
|
275
|
+
modules: [lightmapFilter],
|
|
276
|
+
shaderLayout: {
|
|
277
|
+
attributes: [],
|
|
278
|
+
bindings: ['currentTexture', 'previousTexture', 'chartTexture'].map((name, index) => ({
|
|
279
|
+
name,
|
|
280
|
+
type: 'texture',
|
|
281
|
+
group: 0,
|
|
282
|
+
location: index + 101,
|
|
283
|
+
sampleType: 'unfilterable-float'
|
|
284
|
+
}))
|
|
285
|
+
},
|
|
286
|
+
source:
|
|
287
|
+
'@fragment fn fragmentMain(inputs: FragmentInputs) -> @location(0) vec4f {return lightmapFilter_getColor(vec2i(inputs.Position.xy));}',
|
|
288
|
+
fs: '#version 300 es\nout vec4 fragmentColor;\nvoid main() {fragmentColor = lightmapFilter_getColor(ivec2(gl_FragCoord.xy));}',
|
|
289
|
+
colorAttachmentFormats: [target.format],
|
|
290
|
+
parameters: {depthWriteEnabled: false}
|
|
291
|
+
});
|
|
292
|
+
this.filters.set(index, model);
|
|
293
|
+
}
|
|
294
|
+
model.setBindings({currentTexture: current, previousTexture: previous, chartTexture: previous});
|
|
295
|
+
model.shaderInputs.setProps({lightmapFilter: {weight, mode}});
|
|
296
|
+
// Uniform preparation must precede the render pass.
|
|
297
|
+
model.predraw(this.device.commandEncoder);
|
|
298
|
+
const pass = this.device.beginRenderPass({framebuffer: target.framebuffer});
|
|
299
|
+
try {
|
|
300
|
+
pass.setParameters({viewport: [0, 0, this.width, this.height]});
|
|
301
|
+
model.draw(pass);
|
|
302
|
+
} finally {
|
|
303
|
+
pass.end();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, Buffer, Texture, type Device} from '@luma.gl/core';
|
|
5
|
+
import {fromHalfFloat, toHalfFloat} from '@luma.gl/shaders';
|
|
6
|
+
import {LightmapBakeResult} from './lightmap-baker';
|
|
7
|
+
|
|
8
|
+
/** Portable linear irradiance E, with chart coverage in alpha. Rows follow texture upload order. */
|
|
9
|
+
export type LightmapData = {
|
|
10
|
+
version: 1;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
encoding: 'linear-irradiance';
|
|
14
|
+
uvSet: 0 | 1;
|
|
15
|
+
data: Float32Array;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Explicit asynchronous readback. Submits pending work, including result copies. */
|
|
19
|
+
export async function readLightmapData(texture: Texture, uvSet: 0 | 1 = 1): Promise<LightmapData> {
|
|
20
|
+
assert(
|
|
21
|
+
!texture.destroyed &&
|
|
22
|
+
texture.dimension === '2d' &&
|
|
23
|
+
texture.samples === 1 &&
|
|
24
|
+
(uvSet === 0 || uvSet === 1) &&
|
|
25
|
+
(texture.format === 'rgba16float' || texture.format === 'rgba32float')
|
|
26
|
+
);
|
|
27
|
+
const bytesPerPixel = texture.format === 'rgba16float' ? 8 : 16;
|
|
28
|
+
const rowBytes = texture.computeMemoryLayout().bytesPerRow;
|
|
29
|
+
const buffer = texture.device.createBuffer({
|
|
30
|
+
byteLength: rowBytes * texture.height,
|
|
31
|
+
usage: Buffer.COPY_DST | Buffer.MAP_READ
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
texture.device.submit();
|
|
35
|
+
texture.readBuffer({x: 0, y: 0, width: texture.width, height: texture.height}, buffer);
|
|
36
|
+
texture.device.submit();
|
|
37
|
+
const bytes = await buffer.readAsync();
|
|
38
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
39
|
+
const data = new Float32Array(texture.width * texture.height * 4);
|
|
40
|
+
for (let row = 0; row < texture.height; row++) {
|
|
41
|
+
for (let component = 0; component < texture.width * 4; component++) {
|
|
42
|
+
const offset = row * rowBytes + (component * bytesPerPixel) / 4;
|
|
43
|
+
if (bytesPerPixel === 16)
|
|
44
|
+
data[row * texture.width * 4 + component] = view.getFloat32(offset, true);
|
|
45
|
+
else {
|
|
46
|
+
data[row * texture.width * 4 + component] = fromHalfFloat(view.getUint16(offset, true));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
version: 1,
|
|
52
|
+
width: texture.width,
|
|
53
|
+
height: texture.height,
|
|
54
|
+
encoding: 'linear-irradiance',
|
|
55
|
+
uvSet,
|
|
56
|
+
data
|
|
57
|
+
};
|
|
58
|
+
} finally {
|
|
59
|
+
buffer.destroy();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Uploads an independent owned texture. Input CPU data remains caller-owned. */
|
|
64
|
+
export function createLightmapFromData(
|
|
65
|
+
device: Device,
|
|
66
|
+
lightmap: LightmapData,
|
|
67
|
+
format: 'rgba16float' | 'rgba32float' = 'rgba16float'
|
|
68
|
+
): LightmapBakeResult {
|
|
69
|
+
assert(lightmap.version === 1 && lightmap.encoding === 'linear-irradiance');
|
|
70
|
+
assert(
|
|
71
|
+
Number.isInteger(lightmap.width) &&
|
|
72
|
+
lightmap.width > 0 &&
|
|
73
|
+
lightmap.width <= 0xffffffff &&
|
|
74
|
+
Number.isInteger(lightmap.height) &&
|
|
75
|
+
lightmap.height > 0 &&
|
|
76
|
+
lightmap.height <= 0xffffffff
|
|
77
|
+
);
|
|
78
|
+
assert(lightmap.data.length === lightmap.width * lightmap.height * 4);
|
|
79
|
+
assert(lightmap.uvSet === 0 || lightmap.uvSet === 1);
|
|
80
|
+
assert(device.getTextureFormatCapabilities(format).filter);
|
|
81
|
+
// Half-float uploads round explicitly but must not silently saturate HDR values.
|
|
82
|
+
for (const value of lightmap.data)
|
|
83
|
+
assert(Number.isFinite(value) && (format !== 'rgba16float' || Math.abs(value) <= 65504));
|
|
84
|
+
const data =
|
|
85
|
+
format === 'rgba16float' ? Uint16Array.from(lightmap.data, toHalfFloat) : lightmap.data;
|
|
86
|
+
return new LightmapBakeResult(
|
|
87
|
+
device.createTexture({
|
|
88
|
+
width: lightmap.width,
|
|
89
|
+
height: lightmap.height,
|
|
90
|
+
format,
|
|
91
|
+
data,
|
|
92
|
+
sampler:
|
|
93
|
+
format === 'rgba16float'
|
|
94
|
+
? {minFilter: 'linear', magFilter: 'linear'}
|
|
95
|
+
: {minFilter: 'nearest', magFilter: 'nearest'},
|
|
96
|
+
usage: Texture.SAMPLE | Texture.COPY_DST | Texture.COPY_SRC
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Encodes LML1: four little-endian uint32 header words followed by linear float32 RGBA. */
|
|
102
|
+
export function encodeLightmapData(lightmap: LightmapData): ArrayBuffer {
|
|
103
|
+
assert(lightmap.version === 1 && lightmap.encoding === 'linear-irradiance');
|
|
104
|
+
assert(
|
|
105
|
+
Number.isInteger(lightmap.width) &&
|
|
106
|
+
lightmap.width > 0 &&
|
|
107
|
+
lightmap.width <= 0xffffffff &&
|
|
108
|
+
Number.isInteger(lightmap.height) &&
|
|
109
|
+
lightmap.height > 0 &&
|
|
110
|
+
lightmap.height <= 0xffffffff
|
|
111
|
+
);
|
|
112
|
+
assert(lightmap.uvSet === 0 || lightmap.uvSet === 1);
|
|
113
|
+
assert(lightmap.data.length === lightmap.width * lightmap.height * 4);
|
|
114
|
+
const buffer = new ArrayBuffer(16 + lightmap.data.length * 4);
|
|
115
|
+
const view = new DataView(buffer);
|
|
116
|
+
view.setUint32(0, 0x314c4d4c, true);
|
|
117
|
+
view.setUint32(4, lightmap.width, true);
|
|
118
|
+
view.setUint32(8, lightmap.height, true);
|
|
119
|
+
view.setUint32(12, lightmap.uvSet, true);
|
|
120
|
+
lightmap.data.forEach((value, index) => view.setFloat32(16 + index * 4, value, true));
|
|
121
|
+
return buffer;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Decodes an independently owned CPU copy; no image decoding, fetching or GPU allocation. */
|
|
125
|
+
export function decodeLightmapData(buffer: ArrayBuffer): LightmapData {
|
|
126
|
+
assert(buffer.byteLength >= 16);
|
|
127
|
+
const view = new DataView(buffer);
|
|
128
|
+
assert(view.getUint32(0, true) === 0x314c4d4c);
|
|
129
|
+
const width = view.getUint32(4, true),
|
|
130
|
+
height = view.getUint32(8, true),
|
|
131
|
+
uvSet = view.getUint32(12, true);
|
|
132
|
+
assert(width > 0 && height > 0 && (uvSet === 0 || uvSet === 1));
|
|
133
|
+
const length = width * height * 4;
|
|
134
|
+
assert(Number.isSafeInteger(length) && buffer.byteLength === 16 + length * 4);
|
|
135
|
+
const data = new Float32Array(length);
|
|
136
|
+
for (let index = 0; index < length; index++) data[index] = view.getFloat32(16 + index * 4, true);
|
|
137
|
+
return {version: 1, width, height, encoding: 'linear-irradiance', uvSet, data};
|
|
138
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert} from '@luma.gl/core';
|
|
5
|
+
|
|
6
|
+
/** Linear RGB equirectangular radiance. Row zero is the north pole; longitude zero points +X. */
|
|
7
|
+
export type LightmapEnvironment = {width: number; height: number; data: Float32Array};
|
|
8
|
+
export type LightmapEnvironmentSample = {
|
|
9
|
+
/** Direction from the surface toward the sampled environment, usable by shadow preparation. */
|
|
10
|
+
directionToLight: [number, number, number];
|
|
11
|
+
light: {
|
|
12
|
+
type: 'directional';
|
|
13
|
+
direction: [number, number, number];
|
|
14
|
+
color: [number, number, number];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Uniform solid-angle quadrature for a fixed sample budget. Use lighting.useByteColors=false. */
|
|
19
|
+
export function sampleLightmapEnvironment(
|
|
20
|
+
environment: LightmapEnvironment,
|
|
21
|
+
sampleIndex: number,
|
|
22
|
+
sampleCount: number
|
|
23
|
+
): LightmapEnvironmentSample {
|
|
24
|
+
assert(
|
|
25
|
+
Number.isInteger(environment.width) &&
|
|
26
|
+
environment.width > 0 &&
|
|
27
|
+
Number.isInteger(environment.height) &&
|
|
28
|
+
environment.height > 0
|
|
29
|
+
);
|
|
30
|
+
assert(environment.data.length === environment.width * environment.height * 3);
|
|
31
|
+
assert(
|
|
32
|
+
Number.isInteger(sampleCount) &&
|
|
33
|
+
sampleCount > 0 &&
|
|
34
|
+
Number.isInteger(sampleIndex) &&
|
|
35
|
+
sampleIndex >= 0 &&
|
|
36
|
+
sampleIndex < sampleCount
|
|
37
|
+
);
|
|
38
|
+
let reversed = 0;
|
|
39
|
+
let fraction = 0.5;
|
|
40
|
+
for (let remaining = sampleIndex; remaining > 0; remaining = Math.floor(remaining / 2)) {
|
|
41
|
+
reversed += (remaining % 2) * fraction;
|
|
42
|
+
fraction *= 0.5;
|
|
43
|
+
}
|
|
44
|
+
const vertical = 1 - (2 * (sampleIndex + 0.5)) / sampleCount;
|
|
45
|
+
const longitude = 2 * Math.PI * reversed;
|
|
46
|
+
const radius = Math.sqrt(Math.max(0, 1 - vertical * vertical));
|
|
47
|
+
const directionToLight: [number, number, number] = [
|
|
48
|
+
radius * Math.cos(longitude),
|
|
49
|
+
vertical,
|
|
50
|
+
radius * Math.sin(longitude)
|
|
51
|
+
];
|
|
52
|
+
const column = Math.min(environment.width - 1, Math.floor(reversed * environment.width));
|
|
53
|
+
const row = Math.min(
|
|
54
|
+
environment.height - 1,
|
|
55
|
+
Math.floor((Math.acos(vertical) / Math.PI) * environment.height)
|
|
56
|
+
);
|
|
57
|
+
const offset = (row * environment.width + column) * 3;
|
|
58
|
+
return {
|
|
59
|
+
directionToLight,
|
|
60
|
+
light: {
|
|
61
|
+
type: 'directional',
|
|
62
|
+
direction: [-directionToLight[0], -directionToLight[1], -directionToLight[2]],
|
|
63
|
+
color: [
|
|
64
|
+
environment.data[offset] * 4 * Math.PI,
|
|
65
|
+
environment.data[offset + 1] * 4 * Math.PI,
|
|
66
|
+
environment.data[offset + 2] * 4 * Math.PI
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
3
|
+
|
|
4
|
+
import {assert, type Texture} from '@luma.gl/core';
|
|
5
|
+
import type {PBRSceneUniforms} from '@luma.gl/shaders';
|
|
6
|
+
|
|
7
|
+
/** Scene-level lighting controls; rotation is around the vertical axis in radians. */
|
|
8
|
+
export type PBRLightingEnvironmentOptions = {
|
|
9
|
+
intensity?: number;
|
|
10
|
+
rotation?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** Complete, borrowed linear-light environment resources for PBR rendering. */
|
|
14
|
+
export type PBRLightingEnvironment = PBRLightingEnvironmentOptions & {
|
|
15
|
+
/** Normalized diffuse irradiance (E / pi). */
|
|
16
|
+
diffuseTexture: Texture;
|
|
17
|
+
/** GGX-prefiltered cubemap with the consumer's roughness-to-mip convention. */
|
|
18
|
+
specularTexture: Texture;
|
|
19
|
+
/** Split-sum BRDF integration lookup matching the consumer's convention. */
|
|
20
|
+
brdfLUTTexture: Texture;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Returns shared IBL bindings without copying textures or transferring ownership. */
|
|
24
|
+
export function getPBREnvironmentBindings(environment: PBRLightingEnvironment) {
|
|
25
|
+
const {diffuseTexture, specularTexture, brdfLUTTexture} = environment;
|
|
26
|
+
// Environment resources must be live, on one device, with cube/cube/2D dimensions.
|
|
27
|
+
assert(
|
|
28
|
+
!diffuseTexture.destroyed &&
|
|
29
|
+
!specularTexture.destroyed &&
|
|
30
|
+
!brdfLUTTexture.destroyed &&
|
|
31
|
+
diffuseTexture.device === specularTexture.device &&
|
|
32
|
+
diffuseTexture.device === brdfLUTTexture.device &&
|
|
33
|
+
diffuseTexture.dimension === 'cube' &&
|
|
34
|
+
specularTexture.dimension === 'cube' &&
|
|
35
|
+
brdfLUTTexture.dimension === '2d'
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
pbr_diffuseEnvSampler: diffuseTexture,
|
|
39
|
+
pbr_specularEnvSampler: specularTexture,
|
|
40
|
+
pbr_brdfLUT: brdfLUTTexture
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Returns scene uniforms. Call again after replacing a texture or changing lighting controls. */
|
|
45
|
+
export function getPBREnvironmentUniforms(
|
|
46
|
+
environment: PBRLightingEnvironment
|
|
47
|
+
): Required<
|
|
48
|
+
Pick<PBRSceneUniforms, 'environmentIntensity' | 'environmentRotation' | 'environmentMipCount'>
|
|
49
|
+
> {
|
|
50
|
+
return {
|
|
51
|
+
environmentIntensity: environment.intensity ?? 1,
|
|
52
|
+
environmentRotation: environment.rotation ?? 0,
|
|
53
|
+
environmentMipCount: environment.specularTexture.mipLevels
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Binding, Device, Texture} from '@luma.gl/core';
|
|
6
|
+
import type {Material} from '../material/material';
|
|
7
|
+
import {MaterialFactory} from '../material/material-factory';
|
|
8
|
+
import {type TextureBindingSource} from '@luma.gl/core/dynamic';
|
|
9
|
+
import {type PBRMaterialBindings, type PBRMaterialUniforms, pbrMaterial} from '@luma.gl/shaders';
|
|
10
|
+
|
|
11
|
+
/** Concrete or deferred texture resources accepted by the shared PBR material factory. */
|
|
12
|
+
export type PBRMaterialResources = Record<string, Binding | TextureBindingSource>;
|
|
13
|
+
|
|
14
|
+
/** Typed material instance backed by the canonical shaders PBR module. */
|
|
15
|
+
export type PBRMaterial = Material<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources>;
|
|
16
|
+
|
|
17
|
+
/** Options used to create a reusable physically based material. */
|
|
18
|
+
export type CreatePBRMaterialOptions = {
|
|
19
|
+
/** Optional application-provided material identifier. */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** Canonical glTF-compatible physically based material uniforms. */
|
|
22
|
+
uniforms?: PBRMaterialUniforms;
|
|
23
|
+
/** Material-scoped borrowed texture bindings; absent maps do not allocate fallback resources. */
|
|
24
|
+
bindings?: Partial<PBRMaterialBindings<Texture>> | PBRMaterialResources;
|
|
25
|
+
/** Existing compatible factory reused across materials in the same scene. */
|
|
26
|
+
factory?: MaterialFactory<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Creates a material factory that owns the canonical PBR group-3 binding schema. */
|
|
30
|
+
export function createPBRMaterialFactory(
|
|
31
|
+
device: Device
|
|
32
|
+
): MaterialFactory<{pbrMaterial: PBRMaterialUniforms}, PBRMaterialResources> {
|
|
33
|
+
return new MaterialFactory(device, {modules: [pbrMaterial]});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Creates a typed shared PBR material without introducing a format-specific material runtime. */
|
|
37
|
+
export function createPBRMaterial(
|
|
38
|
+
device: Device,
|
|
39
|
+
options: CreatePBRMaterialOptions = {}
|
|
40
|
+
): PBRMaterial {
|
|
41
|
+
const materialFactory = options.factory || createPBRMaterialFactory(device);
|
|
42
|
+
const bindings: PBRMaterialResources = {};
|
|
43
|
+
|
|
44
|
+
for (const [bindingName, binding] of Object.entries(options.bindings || {})) {
|
|
45
|
+
if (binding && materialFactory.ownsBinding(bindingName)) {
|
|
46
|
+
bindings[bindingName] = binding;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const material = materialFactory.createMaterial({id: options.id, bindings});
|
|
51
|
+
material.setProps({
|
|
52
|
+
pbrMaterial: {
|
|
53
|
+
...getPBRMaterialMapUniforms(bindings),
|
|
54
|
+
...options.uniforms
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return material;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Returns texture-presence flags matching the canonical PBR shader bindings. */
|
|
61
|
+
export function getPBRMaterialMapUniforms(
|
|
62
|
+
bindings: Partial<PBRMaterialBindings<Texture>> | PBRMaterialResources
|
|
63
|
+
): Partial<PBRMaterialUniforms> {
|
|
64
|
+
return {
|
|
65
|
+
baseColorMapEnabled: Boolean(bindings.pbr_baseColorSampler),
|
|
66
|
+
normalMapEnabled: Boolean(bindings.pbr_normalSampler),
|
|
67
|
+
lightmapMapEnabled: Boolean(bindings.pbr_lightmapSampler),
|
|
68
|
+
emissiveMapEnabled: Boolean(bindings.pbr_emissiveSampler),
|
|
69
|
+
metallicRoughnessMapEnabled: Boolean(bindings.pbr_metallicRoughnessSampler),
|
|
70
|
+
occlusionMapEnabled: Boolean(bindings.pbr_occlusionSampler),
|
|
71
|
+
specularColorMapEnabled: Boolean(bindings.pbr_specularColorSampler),
|
|
72
|
+
specularIntensityMapEnabled: Boolean(bindings.pbr_specularIntensitySampler),
|
|
73
|
+
transmissionMapEnabled: Boolean(bindings.pbr_transmissionSampler),
|
|
74
|
+
clearcoatMapEnabled: Boolean(bindings.pbr_clearcoatSampler),
|
|
75
|
+
clearcoatRoughnessMapEnabled: Boolean(bindings.pbr_clearcoatRoughnessSampler),
|
|
76
|
+
sheenColorMapEnabled: Boolean(bindings.pbr_sheenColorSampler),
|
|
77
|
+
sheenRoughnessMapEnabled: Boolean(bindings.pbr_sheenRoughnessSampler),
|
|
78
|
+
iridescenceMapEnabled: Boolean(bindings.pbr_iridescenceSampler),
|
|
79
|
+
anisotropyMapEnabled: Boolean(bindings.pbr_anisotropySampler),
|
|
80
|
+
bumpMapEnabled: Boolean(bindings.pbr_bumpSampler),
|
|
81
|
+
diffuseTransmissionMapEnabled: Boolean(bindings.pbr_diffuseTransmissionSampler),
|
|
82
|
+
diffuseTransmissionColorMapEnabled: Boolean(bindings.pbr_diffuseTransmissionColorSampler),
|
|
83
|
+
multiscatterColorMapEnabled: Boolean(bindings.pbr_multiscatterColorSampler)
|
|
84
|
+
};
|
|
85
|
+
}
|