@luma.gl/engine 10.0.0-alpha.4 → 10.0.0-alpha.5
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/README.md +9 -0
- package/dist/animation/animation-clip.cjs +36 -0
- package/dist/animation/animation-interpolation.cjs +115 -0
- package/dist/animation/animation-mixer.cjs +302 -0
- package/dist/animation/animation-track.cjs +55 -0
- package/dist/animation/animator.cjs +75 -0
- package/dist/animation/deform-positions.cjs +69 -0
- package/dist/animation/deform-positions.d.ts +13 -0
- package/dist/animation/deform-positions.d.ts.map +1 -0
- package/dist/animation/deform-positions.js +49 -0
- package/dist/animation/deform-positions.js.map +1 -0
- package/dist/animation/key-frames.cjs +81 -0
- package/dist/animation/morph-targets.cjs +162 -0
- package/dist/animation/node-animation-binding.cjs +67 -0
- package/dist/animation/node-animation-binding.d.ts +9 -0
- package/dist/animation/node-animation-binding.d.ts.map +1 -0
- package/dist/animation/node-animation-binding.js +45 -0
- package/dist/animation/node-animation-binding.js.map +1 -0
- package/dist/animation/property-animation-binding.cjs +159 -0
- package/dist/animation/property-animation-binding.d.ts +29 -0
- package/dist/animation/property-animation-binding.d.ts.map +1 -0
- package/dist/animation/property-animation-binding.js +138 -0
- package/dist/animation/property-animation-binding.js.map +1 -0
- package/dist/animation/scenegraph-animator.cjs +122 -0
- package/dist/animation/scenegraph-animator.d.ts +37 -0
- package/dist/animation/scenegraph-animator.d.ts.map +1 -0
- package/dist/animation/scenegraph-animator.js +99 -0
- package/dist/animation/scenegraph-animator.js.map +1 -0
- package/dist/animation/skin.cjs +49 -0
- package/dist/animation/texture-transform.cjs +41 -0
- package/dist/animation/texture-transform.d.ts +8 -0
- package/dist/animation/texture-transform.d.ts.map +1 -0
- package/dist/animation/texture-transform.js +17 -0
- package/dist/animation/texture-transform.js.map +1 -0
- package/dist/animation/timeline.cjs +129 -0
- package/dist/animation-loop/animation-loop-template.cjs +33 -0
- package/dist/animation-loop/animation-loop.cjs +498 -0
- package/dist/animation-loop/animation-loop.d.ts +2 -1
- package/dist/animation-loop/animation-loop.d.ts.map +1 -1
- package/dist/animation-loop/animation-loop.js +9 -3
- package/dist/animation-loop/animation-loop.js.map +1 -1
- package/dist/animation-loop/animation-props.cjs +15 -0
- package/dist/animation-loop/make-animation-loop.cjs +104 -0
- package/dist/animation-loop/request-animation-frame.cjs +43 -0
- package/dist/application-utils/load-file.cjs +77 -0
- package/dist/application-utils/random.cjs +38 -0
- package/dist/audio/audio-controller.cjs +429 -0
- package/dist/audio/audio-controller.d.ts +146 -0
- package/dist/audio/audio-controller.d.ts.map +1 -0
- package/dist/audio/audio-controller.js +445 -0
- package/dist/audio/audio-controller.js.map +1 -0
- package/dist/audio/audio-environment.cjs +157 -0
- package/dist/audio/audio-environment.d.ts +49 -0
- package/dist/audio/audio-environment.d.ts.map +1 -0
- package/dist/audio/audio-environment.js +148 -0
- package/dist/audio/audio-environment.js.map +1 -0
- package/dist/audio/audio-graph.cjs +182 -0
- package/dist/audio/audio-graph.d.ts +58 -0
- package/dist/audio/audio-graph.d.ts.map +1 -0
- package/dist/audio/audio-graph.js +181 -0
- package/dist/audio/audio-graph.js.map +1 -0
- package/dist/compute/buffer-transform.cjs +146 -0
- package/dist/compute/buffer-transform.d.ts +15 -5
- package/dist/compute/buffer-transform.d.ts.map +1 -1
- package/dist/compute/buffer-transform.js +56 -12
- package/dist/compute/buffer-transform.js.map +1 -1
- package/dist/compute/computation.cjs +331 -0
- package/dist/compute/computation.d.ts +2 -4
- package/dist/compute/computation.d.ts.map +1 -1
- package/dist/compute/computation.js +3 -14
- package/dist/compute/computation.js.map +1 -1
- package/dist/compute/swap.cjs +132 -0
- package/dist/compute/texture-transform.cjs +142 -0
- package/dist/compute/texture-transform.d.ts +11 -7
- package/dist/compute/texture-transform.d.ts.map +1 -1
- package/dist/compute/texture-transform.js +16 -6
- package/dist/compute/texture-transform.js.map +1 -1
- package/dist/controls/orbit-controls.cjs +283 -0
- package/dist/controls/orbit-controls.d.ts +2 -0
- package/dist/controls/orbit-controls.d.ts.map +1 -1
- package/dist/controls/orbit-controls.js +2 -1
- package/dist/controls/orbit-controls.js.map +1 -1
- package/dist/debug/copy-texture-to-image.cjs +84 -0
- package/dist/debug/debug-framebuffer.cjs +113 -0
- package/dist/debug/debug-shader-layout.cjs +45 -0
- package/dist/debug/pixel-data-utils.cjs +54 -0
- package/dist/dist.dev.js +11756 -5632
- package/dist/dist.min.js +39 -35
- package/dist/dynamic-buffer/dynamic-buffer.cjs +39 -0
- package/dist/dynamic-buffer/dynamic-buffer.d.ts +1 -170
- package/dist/dynamic-buffer/dynamic-buffer.d.ts.map +1 -1
- package/dist/dynamic-buffer/dynamic-buffer.js +2 -312
- package/dist/dynamic-buffer/dynamic-buffer.js.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.cjs +27 -0
- package/dist/dynamic-texture/dynamic-texture.d.ts +1 -114
- package/dist/dynamic-texture/dynamic-texture.d.ts.map +1 -1
- package/dist/dynamic-texture/dynamic-texture.js +2 -584
- package/dist/dynamic-texture/dynamic-texture.js.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.cjs +31 -0
- package/dist/dynamic-texture/texture-binding-source.d.ts +1 -54
- package/dist/dynamic-texture/texture-binding-source.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-binding-source.js +2 -51
- package/dist/dynamic-texture/texture-binding-source.js.map +1 -1
- package/dist/dynamic-texture/texture-data.cjs +53 -0
- package/dist/dynamic-texture/texture-data.d.ts +1 -145
- package/dist/dynamic-texture/texture-data.d.ts.map +1 -1
- package/dist/dynamic-texture/texture-data.js +2 -209
- package/dist/dynamic-texture/texture-data.js.map +1 -1
- package/dist/dynamic-texture/video-texture.cjs +269 -0
- package/dist/dynamic-texture/video-texture.d.ts +1 -1
- package/dist/dynamic-texture/video-texture.d.ts.map +1 -1
- package/dist/experimental/controls/comparison-splitter.cjs +231 -0
- package/dist/experimental/controls/comparison-splitter.d.ts +54 -0
- package/dist/experimental/controls/comparison-splitter.d.ts.map +1 -0
- package/dist/experimental/controls/comparison-splitter.js +215 -0
- package/dist/experimental/controls/comparison-splitter.js.map +1 -0
- package/dist/experimental/controls/flat-controller.cjs +301 -0
- package/dist/experimental/controls/flat-controller.d.ts +80 -0
- package/dist/experimental/controls/flat-controller.d.ts.map +1 -0
- package/dist/experimental/controls/flat-controller.js +295 -0
- package/dist/experimental/controls/flat-controller.js.map +1 -0
- package/dist/experimental/controls/index.cjs +35 -0
- package/dist/experimental/controls/index.cjs.map +6 -0
- package/dist/experimental/controls/index.d.ts +7 -0
- package/dist/experimental/controls/index.d.ts.map +1 -0
- package/dist/experimental/controls/index.js +7 -0
- package/dist/experimental/controls/index.js.map +1 -0
- package/dist/experimental/controls/orbit-controls.cjs +27 -0
- package/dist/experimental/controls/orbit-controls.d.ts +3 -0
- package/dist/experimental/controls/orbit-controls.d.ts.map +1 -0
- package/dist/experimental/controls/orbit-controls.js +5 -0
- package/dist/experimental/controls/orbit-controls.js.map +1 -0
- package/dist/experimental/materials/emissive-material.cjs +126 -0
- package/dist/experimental/materials/emissive-material.d.ts +38 -0
- package/dist/experimental/materials/emissive-material.d.ts.map +1 -0
- package/dist/experimental/materials/emissive-material.js +100 -0
- package/dist/experimental/materials/emissive-material.js.map +1 -0
- package/dist/experimental/materials/glass-material.cjs +570 -0
- package/dist/experimental/materials/glass-material.d.ts +107 -0
- package/dist/experimental/materials/glass-material.d.ts.map +1 -0
- package/dist/experimental/materials/glass-material.js +544 -0
- package/dist/experimental/materials/glass-material.js.map +1 -0
- package/dist/experimental/materials/glass-transmission.cjs +954 -0
- package/dist/experimental/materials/glass-transmission.d.ts +193 -0
- package/dist/experimental/materials/glass-transmission.d.ts.map +1 -0
- package/dist/experimental/materials/glass-transmission.js +928 -0
- package/dist/experimental/materials/glass-transmission.js.map +1 -0
- package/dist/experimental/materials/index.cjs +61 -0
- package/dist/experimental/materials/index.cjs.map +6 -0
- package/dist/experimental/materials/index.d.ts +14 -0
- package/dist/experimental/materials/index.d.ts.map +1 -0
- package/dist/experimental/materials/index.js +11 -0
- package/dist/experimental/materials/index.js.map +1 -0
- package/dist/experimental/materials/optical-caustics.cjs +201 -0
- package/dist/experimental/materials/optical-caustics.d.ts +69 -0
- package/dist/experimental/materials/optical-caustics.d.ts.map +1 -0
- package/dist/experimental/materials/optical-caustics.js +180 -0
- package/dist/experimental/materials/optical-caustics.js.map +1 -0
- package/dist/experimental/materials/optical-lighting.cjs +169 -0
- package/dist/experimental/materials/optical-lighting.d.ts +7 -0
- package/dist/experimental/materials/optical-lighting.d.ts.map +1 -0
- package/dist/experimental/materials/optical-lighting.js +144 -0
- package/dist/experimental/materials/optical-lighting.js.map +1 -0
- package/dist/experimental/materials/optical-point-lights.cjs +258 -0
- package/dist/experimental/materials/optical-point-lights.d.ts +68 -0
- package/dist/experimental/materials/optical-point-lights.d.ts.map +1 -0
- package/dist/experimental/materials/optical-point-lights.js +237 -0
- package/dist/experimental/materials/optical-point-lights.js.map +1 -0
- package/dist/experimental/materials/reflective-material.cjs +216 -0
- package/dist/experimental/materials/reflective-material.d.ts +46 -0
- package/dist/experimental/materials/reflective-material.d.ts.map +1 -0
- package/dist/experimental/materials/reflective-material.js +190 -0
- package/dist/experimental/materials/reflective-material.js.map +1 -0
- package/dist/experimental/textures/html-texture.cjs +221 -0
- package/dist/experimental/textures/html-texture.d.ts +85 -0
- package/dist/experimental/textures/html-texture.d.ts.map +1 -0
- package/dist/experimental/textures/html-texture.js +206 -0
- package/dist/experimental/textures/html-texture.js.map +1 -0
- package/dist/experimental/textures/index.cjs +33 -0
- package/dist/experimental/textures/index.cjs.map +6 -0
- package/dist/experimental/textures/index.d.ts +5 -0
- package/dist/experimental/textures/index.d.ts.map +1 -0
- package/dist/experimental/textures/index.js +7 -0
- package/dist/experimental/textures/index.js.map +1 -0
- package/dist/experimental/textures/packed-pixels.cjs +248 -0
- package/dist/experimental/textures/packed-pixels.d.ts +17 -0
- package/dist/experimental/textures/packed-pixels.d.ts.map +1 -0
- package/dist/experimental/textures/packed-pixels.js +237 -0
- package/dist/experimental/textures/packed-pixels.js.map +1 -0
- package/dist/experimental/textures/rgba-decoder.cjs +60 -0
- package/dist/experimental/textures/rgba-decoder.d.ts +29 -0
- package/dist/experimental/textures/rgba-decoder.d.ts.map +1 -0
- package/dist/experimental/textures/rgba-decoder.js +43 -0
- package/dist/experimental/textures/rgba-decoder.js.map +1 -0
- package/dist/experimental/webxr/index.cjs +38 -0
- package/dist/experimental/webxr/index.cjs.map +6 -0
- package/dist/experimental/webxr/index.d.ts +9 -0
- package/dist/experimental/webxr/index.d.ts.map +1 -0
- package/dist/experimental/webxr/index.js +8 -0
- package/dist/experimental/webxr/index.js.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.cjs +38 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts +9 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js +17 -0
- package/dist/experimental/webxr/webxr-animation-frame-provider.js.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.cjs +157 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts +48 -0
- package/dist/experimental/webxr/webxr-camera-texture.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-camera-texture.js +144 -0
- package/dist/experimental/webxr/webxr-camera-texture.js.map +1 -0
- package/dist/experimental/webxr/webxr-input.cjs +93 -0
- package/dist/experimental/webxr/webxr-input.d.ts +24 -0
- package/dist/experimental/webxr/webxr-input.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-input.js +70 -0
- package/dist/experimental/webxr/webxr-input.js.map +1 -0
- package/dist/experimental/webxr/webxr-manager.cjs +356 -0
- package/dist/experimental/webxr/webxr-manager.d.ts +91 -0
- package/dist/experimental/webxr/webxr-manager.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-manager.js +354 -0
- package/dist/experimental/webxr/webxr-manager.js.map +1 -0
- package/dist/experimental/webxr/webxr-types.cjs +15 -0
- package/dist/experimental/webxr/webxr-types.d.ts +152 -0
- package/dist/experimental/webxr/webxr-types.d.ts.map +1 -0
- package/dist/experimental/webxr/webxr-types.js +5 -0
- package/dist/experimental/webxr/webxr-types.js.map +1 -0
- package/dist/geometry/edge-geometry.cjs +171 -0
- package/dist/geometry/geometry-primitives.cjs +189 -0
- package/dist/geometry/geometry-primitives.d.ts +6 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -1
- package/dist/geometry/geometry-primitives.js +8 -0
- package/dist/geometry/geometry-primitives.js.map +1 -1
- package/dist/geometry/geometry-table.cjs +15 -0
- package/dist/geometry/geometry-utils.cjs +147 -0
- package/dist/geometry/geometry.cjs +90 -0
- package/dist/geometry/gpu-geometry.cjs +130 -0
- package/dist/geometry/gpu-vector-geometry-adapter.cjs +88 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts +5 -0
- package/dist/geometry/gpu-vector-geometry-adapter.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js +73 -0
- package/dist/geometry/gpu-vector-geometry-adapter.js.map +1 -0
- package/dist/geometry/gpu-vector-geometry.cjs +40 -0
- package/dist/geometry/gpu-vector-geometry.d.ts +21 -0
- package/dist/geometry/gpu-vector-geometry.d.ts.map +1 -0
- package/dist/geometry/gpu-vector-geometry.js +19 -0
- package/dist/geometry/gpu-vector-geometry.js.map +1 -0
- package/dist/geometry/mesh-simplification.cjs +385 -0
- package/dist/geometry/ring-geometry.cjs +104 -0
- package/dist/geometry/ring-geometry.d.ts +17 -0
- package/dist/geometry/ring-geometry.d.ts.map +1 -0
- package/dist/geometry/ring-geometry.js +94 -0
- package/dist/geometry/ring-geometry.js.map +1 -0
- package/dist/geometry/stroke-geometry.cjs +171 -0
- package/dist/graph/models/index.cjs +66 -0
- package/dist/graph/models/index.cjs.map +6 -0
- package/dist/graph/models/index.d.ts +7 -0
- package/dist/graph/models/index.d.ts.map +1 -0
- package/dist/graph/models/index.js +10 -0
- package/dist/graph/models/index.js.map +1 -0
- package/dist/graph/models/path/path-attribute-model.cjs +421 -0
- package/dist/graph/models/path/path-attribute-model.d.ts +142 -0
- package/dist/graph/models/path/path-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-attribute-model.js +409 -0
- package/dist/graph/models/path/path-attribute-model.js.map +1 -0
- package/dist/graph/models/path/path-storage-model.cjs +711 -0
- package/dist/graph/models/path/path-storage-model.d.ts +174 -0
- package/dist/graph/models/path/path-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-storage-model.js +720 -0
- package/dist/graph/models/path/path-storage-model.js.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.cjs +271 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts +58 -0
- package/dist/graph/models/path/path-trips-storage-model.d.ts.map +1 -0
- package/dist/graph/models/path/path-trips-storage-model.js +248 -0
- package/dist/graph/models/path/path-trips-storage-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.cjs +117 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-attribute-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js +101 -0
- package/dist/graph/models/polygon/polygon-attribute-model.js.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.cjs +283 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts +77 -0
- package/dist/graph/models/polygon/polygon-shaders.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-shaders.js +242 -0
- package/dist/graph/models/polygon/polygon-shaders.js.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.cjs +111 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts +53 -0
- package/dist/graph/models/polygon/polygon-storage-model.d.ts.map +1 -0
- package/dist/graph/models/polygon/polygon-storage-model.js +92 -0
- package/dist/graph/models/polygon/polygon-storage-model.js.map +1 -0
- package/dist/graph/physics/index.cjs +50 -0
- package/dist/graph/physics/index.cjs.map +6 -0
- package/dist/graph/physics/index.d.ts +12 -0
- package/dist/graph/physics/index.d.ts.map +1 -0
- package/dist/graph/physics/index.js +12 -0
- package/dist/graph/physics/index.js.map +1 -0
- package/dist/graph/physics/physics-scenegraph.cjs +92 -0
- package/dist/graph/physics/physics-scenegraph.d.ts +35 -0
- package/dist/graph/physics/physics-scenegraph.d.ts.map +1 -0
- package/dist/graph/physics/physics-scenegraph.js +80 -0
- package/dist/graph/physics/physics-scenegraph.js.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.cjs +164 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts +37 -0
- package/dist/graph/physics/scenegraph-behaviors.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-behaviors.js +145 -0
- package/dist/graph/physics/scenegraph-behaviors.js.map +1 -0
- package/dist/graph/physics/scenegraph-instance.cjs +246 -0
- package/dist/graph/physics/scenegraph-instance.d.ts +59 -0
- package/dist/graph/physics/scenegraph-instance.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-instance.js +241 -0
- package/dist/graph/physics/scenegraph-instance.js.map +1 -0
- package/dist/graph/physics/scenegraph-joints.cjs +51 -0
- package/dist/graph/physics/scenegraph-joints.d.ts +5 -0
- package/dist/graph/physics/scenegraph-joints.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-joints.js +31 -0
- package/dist/graph/physics/scenegraph-joints.js.map +1 -0
- package/dist/graph/physics/scenegraph-motion.cjs +177 -0
- package/dist/graph/physics/scenegraph-motion.d.ts +37 -0
- package/dist/graph/physics/scenegraph-motion.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-motion.js +168 -0
- package/dist/graph/physics/scenegraph-motion.js.map +1 -0
- package/dist/graph/physics/scenegraph-properties.cjs +170 -0
- package/dist/graph/physics/scenegraph-properties.d.ts +37 -0
- package/dist/graph/physics/scenegraph-properties.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-properties.js +186 -0
- package/dist/graph/physics/scenegraph-properties.js.map +1 -0
- package/dist/graph/physics/scenegraph-publication.cjs +112 -0
- package/dist/graph/physics/scenegraph-publication.d.ts +23 -0
- package/dist/graph/physics/scenegraph-publication.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-publication.js +99 -0
- package/dist/graph/physics/scenegraph-publication.js.map +1 -0
- package/dist/graph/physics/scenegraph-session.cjs +256 -0
- package/dist/graph/physics/scenegraph-session.d.ts +68 -0
- package/dist/graph/physics/scenegraph-session.d.ts.map +1 -0
- package/dist/graph/physics/scenegraph-session.js +249 -0
- package/dist/graph/physics/scenegraph-session.js.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.cjs +84 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts +32 -0
- package/dist/graph/tables/gpu-table-geometry.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-geometry.js +67 -0
- package/dist/graph/tables/gpu-table-geometry.js.map +1 -0
- package/dist/graph/tables/gpu-table-model.cjs +459 -0
- package/dist/graph/tables/gpu-table-model.d.ts +67 -0
- package/dist/graph/tables/gpu-table-model.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-model.js +457 -0
- package/dist/graph/tables/gpu-table-model.js.map +1 -0
- package/dist/graph/tables/gpu-table-transform.cjs +341 -0
- package/dist/graph/tables/gpu-table-transform.d.ts +61 -0
- package/dist/graph/tables/gpu-table-transform.d.ts.map +1 -0
- package/dist/graph/tables/gpu-table-transform.js +333 -0
- package/dist/graph/tables/gpu-table-transform.js.map +1 -0
- package/dist/graph/tables/index.cjs +33 -0
- package/dist/graph/tables/index.cjs.map +6 -0
- package/dist/graph/tables/index.d.ts +4 -0
- package/dist/graph/tables/index.d.ts.map +1 -0
- package/dist/graph/tables/index.js +7 -0
- package/dist/graph/tables/index.js.map +1 -0
- package/dist/index.cjs +303 -9569
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +32 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/interactivity/interactivity.cjs +570 -0
- package/dist/interactivity/interactivity.d.ts +107 -0
- package/dist/interactivity/interactivity.d.ts.map +1 -0
- package/dist/interactivity/interactivity.js +575 -0
- package/dist/interactivity/interactivity.js.map +1 -0
- package/dist/interactivity/physics.cjs +15 -0
- package/dist/interactivity/physics.d.ts +12 -0
- package/dist/interactivity/physics.d.ts.map +1 -0
- package/dist/interactivity/physics.js +5 -0
- package/dist/interactivity/physics.js.map +1 -0
- package/dist/material/material-factory.cjs +99 -0
- package/dist/material/material-factory.d.ts +1 -1
- package/dist/material/material-factory.d.ts.map +1 -1
- package/dist/material/material.cjs +239 -0
- package/dist/material/material.d.ts +2 -2
- package/dist/material/material.d.ts.map +1 -1
- package/dist/material/material.js +2 -2
- package/dist/material/material.js.map +1 -1
- package/dist/model/gpu-vector-bindings.cjs +226 -0
- package/dist/model/gpu-vector-bindings.d.ts +36 -0
- package/dist/model/gpu-vector-bindings.d.ts.map +1 -0
- package/dist/model/gpu-vector-bindings.js +217 -0
- package/dist/model/gpu-vector-bindings.js.map +1 -0
- package/dist/model/gpu-vector-draw-batches.cjs +82 -0
- package/dist/model/gpu-vector-draw-batches.d.ts +5 -0
- package/dist/model/gpu-vector-draw-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-draw-batches.js +73 -0
- package/dist/model/gpu-vector-draw-batches.js.map +1 -0
- package/dist/model/gpu-vector-model-batches.cjs +94 -0
- package/dist/model/gpu-vector-model-batches.d.ts +41 -0
- package/dist/model/gpu-vector-model-batches.d.ts.map +1 -0
- package/dist/model/gpu-vector-model-batches.js +77 -0
- package/dist/model/gpu-vector-model-batches.js.map +1 -0
- package/dist/model/gpu-vector-model.cjs +1264 -0
- package/dist/model/gpu-vector-model.d.ts +352 -0
- package/dist/model/gpu-vector-model.d.ts.map +1 -0
- package/dist/model/gpu-vector-model.js +1375 -0
- package/dist/model/gpu-vector-model.js.map +1 -0
- package/dist/model/model.cjs +134 -0
- package/dist/model/model.d.ts +21 -305
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +68 -1092
- package/dist/model/model.js.map +1 -1
- package/dist/model/split-uniforms-and-bindings.cjs +44 -0
- package/dist/model/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/model/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/model/split-uniforms-and-bindings.js +5 -2
- package/dist/model/split-uniforms-and-bindings.js.map +1 -1
- package/dist/models/billboard-texture-model.cjs +167 -0
- package/dist/models/billboard-texture-model.d.ts +1 -1
- package/dist/models/billboard-texture-model.d.ts.map +1 -1
- package/dist/models/billboard-texture-model.js +1 -1
- package/dist/models/billboard-texture-model.js.map +1 -1
- package/dist/models/billboard-texture-module.cjs +61 -0
- package/dist/models/clip-space.cjs +103 -0
- package/dist/models/directional-light-model.cjs +45 -0
- package/dist/models/light-model-utils.cjs +426 -0
- package/dist/models/point-light-model.cjs +44 -0
- package/dist/models/spot-light-model.cjs +45 -0
- package/dist/modules/picking/color-picking.cjs +209 -0
- package/dist/modules/picking/color-picking.d.ts +1 -1
- package/dist/modules/picking/index-color-picking.cjs +230 -0
- package/dist/modules/picking/index-color-picking.d.ts +1 -1
- package/dist/modules/picking/index-picking.cjs +201 -0
- package/dist/modules/picking/index-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-color-picking.cjs +28 -0
- package/dist/modules/picking/legacy-color-picking.d.ts +1 -1
- package/dist/modules/picking/legacy-picking-manager.cjs +92 -0
- package/dist/modules/picking/picking-manager.cjs +360 -0
- package/dist/modules/picking/picking-uniforms.cjs +140 -0
- 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.cjs +43 -0
- package/dist/modules/picking/picking.d.ts +1 -1
- package/dist/passes/get-fragment-shader.cjs +119 -0
- package/dist/passes/shader-pass-renderer.cjs +722 -0
- package/dist/passes/shader-pass-renderer.d.ts +2 -2
- package/dist/passes/shader-pass-renderer.d.ts.map +1 -1
- package/dist/passes/shader-pass-renderer.js +1 -1
- package/dist/passes/shader-pass-renderer.js.map +1 -1
- package/dist/passes/texture-transform-module.cjs +78 -0
- package/dist/scenegraph/controllers/area-light-controller.cjs +143 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts +31 -0
- package/dist/scenegraph/controllers/area-light-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/area-light-controller.js +130 -0
- package/dist/scenegraph/controllers/area-light-controller.js.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.cjs +156 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts +45 -0
- package/dist/scenegraph/controllers/billboard-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/billboard-controller.js +156 -0
- package/dist/scenegraph/controllers/billboard-controller.js.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.cjs +71 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts +30 -0
- package/dist/scenegraph/controllers/joint-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/joint-controller.js +53 -0
- package/dist/scenegraph/controllers/joint-controller.js.map +1 -0
- package/dist/scenegraph/controllers/material-variants.cjs +61 -0
- package/dist/scenegraph/controllers/material-variants.d.ts +42 -0
- package/dist/scenegraph/controllers/material-variants.d.ts.map +1 -0
- package/dist/scenegraph/controllers/material-variants.js +40 -0
- package/dist/scenegraph/controllers/material-variants.js.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.cjs +61 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts +19 -0
- package/dist/scenegraph/controllers/morph-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/morph-controller.js +41 -0
- package/dist/scenegraph/controllers/morph-controller.js.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.cjs +111 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts +36 -0
- package/dist/scenegraph/controllers/skin-controller.d.ts.map +1 -0
- package/dist/scenegraph/controllers/skin-controller.js +90 -0
- package/dist/scenegraph/controllers/skin-controller.js.map +1 -0
- package/dist/scenegraph/group-node.cjs +129 -0
- package/dist/scenegraph/model-node.cjs +68 -0
- package/dist/scenegraph/physics-transforms.cjs +95 -0
- package/dist/scenegraph/physics-transforms.d.ts +13 -0
- package/dist/scenegraph/physics-transforms.d.ts.map +1 -0
- package/dist/scenegraph/physics-transforms.js +72 -0
- package/dist/scenegraph/physics-transforms.js.map +1 -0
- package/dist/scenegraph/published-transforms.cjs +37 -0
- package/dist/scenegraph/published-transforms.d.ts +17 -0
- package/dist/scenegraph/published-transforms.d.ts.map +1 -0
- package/dist/scenegraph/published-transforms.js +16 -0
- package/dist/scenegraph/published-transforms.js.map +1 -0
- package/dist/scenegraph/scenegraph-bounds.cjs +51 -0
- package/dist/scenegraph/scenegraph-node.cjs +182 -0
- package/dist/shader-inputs.cjs +231 -0
- package/dist/shader-inputs.d.ts +1 -1
- package/dist/shader-inputs.d.ts.map +1 -1
- package/dist/utils/buffer-layout-helper.cjs +52 -0
- package/dist/utils/buffer-layout-order.cjs +37 -0
- package/dist/utils/deep-equal.cjs +65 -0
- package/dist/utils/get-platform-info.cjs +21 -0
- package/dist/utils/get-platform-info.d.ts +2 -0
- package/dist/utils/get-platform-info.d.ts.map +1 -0
- package/dist/utils/get-platform-info.js +5 -0
- package/dist/utils/get-platform-info.js.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.cjs +45 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts +12 -0
- package/dist/utils/gpu-vector-batch-structure.d.ts.map +1 -0
- package/dist/utils/gpu-vector-batch-structure.js +27 -0
- package/dist/utils/gpu-vector-batch-structure.js.map +1 -0
- package/dist/utils/shader-module-utils.cjs +148 -0
- package/dist/utils/uid.cjs +32 -0
- package/package.json +45 -7
- package/src/animation/deform-positions.ts +62 -0
- package/src/animation/node-animation-binding.ts +54 -0
- package/src/animation/property-animation-binding.ts +212 -0
- package/src/animation/scenegraph-animator.ts +117 -0
- package/src/animation/texture-transform.ts +59 -0
- package/src/animation-loop/animation-loop.ts +10 -3
- package/src/audio/audio-controller.ts +583 -0
- package/src/audio/audio-environment.ts +202 -0
- package/src/audio/audio-graph.ts +253 -0
- package/src/compute/buffer-transform.ts +71 -16
- package/src/compute/computation.ts +4 -19
- package/src/compute/texture-transform.ts +25 -12
- package/src/controls/orbit-controls.ts +4 -1
- package/src/dynamic-buffer/dynamic-buffer.ts +15 -449
- package/src/dynamic-texture/dynamic-texture.ts +5 -760
- package/src/dynamic-texture/texture-binding-source.ts +8 -90
- package/src/dynamic-texture/texture-data.ts +31 -340
- package/src/dynamic-texture/video-texture.ts +1 -1
- package/src/experimental/controls/comparison-splitter.ts +269 -0
- package/src/experimental/controls/flat-controller.ts +403 -0
- package/src/experimental/controls/index.ts +16 -0
- package/src/experimental/controls/orbit-controls.ts +6 -0
- package/src/experimental/materials/emissive-material.ts +120 -0
- package/src/experimental/materials/glass-material.ts +607 -0
- package/src/experimental/materials/glass-transmission.ts +1023 -0
- package/src/experimental/materials/index.ts +49 -0
- package/src/experimental/materials/optical-caustics.ts +234 -0
- package/src/experimental/materials/optical-lighting.ts +148 -0
- package/src/experimental/materials/optical-point-lights.ts +288 -0
- package/src/experimental/materials/reflective-material.ts +214 -0
- package/src/experimental/textures/html-texture.ts +285 -0
- package/src/experimental/textures/index.ts +8 -0
- package/src/experimental/textures/packed-pixels.ts +351 -0
- package/src/experimental/textures/rgba-decoder.ts +79 -0
- package/src/experimental/webxr/index.ts +21 -0
- package/src/experimental/webxr/webxr-animation-frame-provider.ts +22 -0
- package/src/experimental/webxr/webxr-camera-texture.ts +195 -0
- package/src/experimental/webxr/webxr-input.ts +117 -0
- package/src/experimental/webxr/webxr-manager.ts +524 -0
- package/src/experimental/webxr/webxr-types.ts +192 -0
- package/src/geometry/geometry-primitives.ts +11 -0
- package/src/geometry/gpu-vector-geometry-adapter.ts +78 -0
- package/src/geometry/gpu-vector-geometry.ts +33 -0
- package/src/geometry/ring-geometry.ts +117 -0
- package/src/graph/models/index.ts +45 -0
- package/src/graph/models/path/path-attribute-model.ts +563 -0
- package/src/graph/models/path/path-storage-model.ts +996 -0
- package/src/graph/models/path/path-trips-storage-model.ts +286 -0
- package/src/graph/models/polygon/polygon-attribute-model.ts +165 -0
- package/src/graph/models/polygon/polygon-shaders.ts +279 -0
- package/src/graph/models/polygon/polygon-storage-model.ts +146 -0
- package/src/graph/physics/index.ts +24 -0
- package/src/graph/physics/physics-scenegraph.ts +112 -0
- package/src/graph/physics/scenegraph-behaviors.ts +169 -0
- package/src/graph/physics/scenegraph-instance.ts +296 -0
- package/src/graph/physics/scenegraph-joints.ts +37 -0
- package/src/graph/physics/scenegraph-motion.ts +175 -0
- package/src/graph/physics/scenegraph-properties.ts +241 -0
- package/src/graph/physics/scenegraph-publication.ts +116 -0
- package/src/graph/physics/scenegraph-session.ts +317 -0
- package/src/graph/tables/gpu-table-geometry.ts +88 -0
- package/src/graph/tables/gpu-table-model.ts +661 -0
- package/src/graph/tables/gpu-table-transform.ts +497 -0
- package/src/graph/tables/index.ts +18 -0
- package/src/index.ts +130 -13
- package/src/interactivity/interactivity.ts +670 -0
- package/src/interactivity/physics.ts +19 -0
- package/src/material/material-factory.ts +1 -1
- package/src/material/material.ts +2 -2
- package/src/model/gpu-vector-bindings.ts +276 -0
- package/src/model/gpu-vector-draw-batches.ts +116 -0
- package/src/model/gpu-vector-model-batches.ts +142 -0
- package/src/model/gpu-vector-model.ts +1819 -0
- package/src/model/model.ts +91 -1444
- package/src/model/split-uniforms-and-bindings.ts +6 -3
- package/src/models/billboard-texture-model.ts +1 -1
- package/src/modules/picking/legacy-picking-manager.ts +1 -1
- package/src/modules/picking/picking-uniforms.ts +1 -1
- package/src/passes/shader-pass-renderer.ts +2 -2
- package/src/scenegraph/controllers/area-light-controller.ts +152 -0
- package/src/scenegraph/controllers/billboard-controller.ts +204 -0
- package/src/scenegraph/controllers/joint-controller.ts +81 -0
- package/src/scenegraph/controllers/material-variants.ts +70 -0
- package/src/scenegraph/controllers/morph-controller.ts +61 -0
- package/src/scenegraph/controllers/skin-controller.ts +125 -0
- package/src/scenegraph/physics-transforms.ts +82 -0
- package/src/scenegraph/published-transforms.ts +18 -0
- package/src/shader-inputs.ts +1 -1
- package/src/utils/get-platform-info.ts +5 -0
- package/src/utils/gpu-vector-batch-structure.ts +36 -0
- package/dist/compute/kernel.d.ts +0 -54
- package/dist/compute/kernel.d.ts.map +0 -1
- package/dist/compute/kernel.js +0 -103
- package/dist/compute/kernel.js.map +0 -1
- package/dist/compute/render-kernel.d.ts +0 -65
- package/dist/compute/render-kernel.d.ts.map +0 -1
- package/dist/compute/render-kernel.js +0 -129
- package/dist/compute/render-kernel.js.map +0 -1
- package/src/compute/kernel.ts +0 -146
- package/src/compute/render-kernel.ts +0 -192
|
@@ -0,0 +1,1023 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Texture} from '@luma.gl/core';
|
|
6
|
+
import type {ShaderModule, ShaderPlugin} from '@luma.gl/shadertools';
|
|
7
|
+
import {glassMaterial} from './glass-material';
|
|
8
|
+
|
|
9
|
+
/** Optional rasterized volume inputs layered on top of {@link glassMaterial}. */
|
|
10
|
+
export type GlassTransmissionProps = {
|
|
11
|
+
/** Dimensions shared by opaque scene color, opaque depth, and glass backfaces. */
|
|
12
|
+
viewportSize?: [number, number];
|
|
13
|
+
/** Near and far perspective clip planes used to recover linear optical thickness. */
|
|
14
|
+
depthRange?: [number, number];
|
|
15
|
+
/** Sampleable depth attachment from the opaque scene pass. */
|
|
16
|
+
sceneDepthTexture?: Texture;
|
|
17
|
+
/** Encoded backface world normals and normalized framebuffer depth. */
|
|
18
|
+
backfaceTexture?: Texture;
|
|
19
|
+
/** Equirectangular studio or HDR environment map. */
|
|
20
|
+
environmentTexture?: Texture;
|
|
21
|
+
/** Multiplier applied to sampled environment reflections. */
|
|
22
|
+
environmentIntensity?: number;
|
|
23
|
+
/** Number of initialized levels in the optional prefiltered environment texture. */
|
|
24
|
+
environmentMipLevels?: number;
|
|
25
|
+
/** Strength of roughness-selected environment mip sampling; zero preserves legacy filtering. */
|
|
26
|
+
environmentPrefilterStrength?: number;
|
|
27
|
+
/** Multiplier applied to the measured front-to-back optical path. */
|
|
28
|
+
thicknessStrength?: number;
|
|
29
|
+
/** Strength of thickness-aware multisample transmission blur. */
|
|
30
|
+
roughTransmissionStrength?: number;
|
|
31
|
+
/** Strength of wavelength-dependent absorption through the measured glass volume. */
|
|
32
|
+
spectralAbsorptionStrength?: number;
|
|
33
|
+
/** Thickness in nanometers of an optional thin-film surface coating. */
|
|
34
|
+
thinFilmThickness?: number;
|
|
35
|
+
/** Strength of angular spectral interference from the thin-film coating. */
|
|
36
|
+
thinFilmStrength?: number;
|
|
37
|
+
/** Strength of colored in-volume scattering around nearby optical point lights. */
|
|
38
|
+
volumeScatteringStrength?: number;
|
|
39
|
+
/** Strength of depth-aware localized darkening where opaque geometry touches the glass. */
|
|
40
|
+
contactShadowStrength?: number;
|
|
41
|
+
/** Normalized-depth tolerance used to preserve foreground geometry. */
|
|
42
|
+
depthBias?: number;
|
|
43
|
+
/** Strength of nearby opaque-scene reflections sampled from captured scene color. */
|
|
44
|
+
dynamicReflectionStrength?: number;
|
|
45
|
+
/** Strength of an additional environment bounce inside the glass shell. */
|
|
46
|
+
secondaryBounceStrength?: number;
|
|
47
|
+
/** Strength of animated lens distortion on warm-tinted fault surfaces. */
|
|
48
|
+
faultDistortionStrength?: number;
|
|
49
|
+
/** Animation clock used by optional fault-driven surface distortion. */
|
|
50
|
+
time?: number;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Uniform values consumed by {@link glassTransmission}. */
|
|
54
|
+
export type GlassTransmissionUniforms = {
|
|
55
|
+
viewportSize: [number, number];
|
|
56
|
+
depthRange: [number, number];
|
|
57
|
+
environmentIntensity: number;
|
|
58
|
+
environmentMipLevels: number;
|
|
59
|
+
environmentPrefilterStrength: number;
|
|
60
|
+
thicknessStrength: number;
|
|
61
|
+
roughTransmissionStrength: number;
|
|
62
|
+
spectralAbsorptionStrength: number;
|
|
63
|
+
thinFilmThickness: number;
|
|
64
|
+
thinFilmStrength: number;
|
|
65
|
+
volumeScatteringStrength: number;
|
|
66
|
+
contactShadowStrength: number;
|
|
67
|
+
depthBias: number;
|
|
68
|
+
dynamicReflectionStrength: number;
|
|
69
|
+
secondaryBounceStrength: number;
|
|
70
|
+
faultDistortionStrength: number;
|
|
71
|
+
time: number;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Rasterized volume textures consumed by {@link glassTransmission}. */
|
|
75
|
+
export type GlassTransmissionBindings = {
|
|
76
|
+
glassSceneDepthTexture?: Texture;
|
|
77
|
+
glassBackfaceTexture?: Texture;
|
|
78
|
+
glassEnvironmentTexture?: Texture;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const SHADER_STAGE_FRAGMENT = 0x2;
|
|
82
|
+
|
|
83
|
+
const GLASS_TRANSMISSION_WGSL = /* wgsl */ `\
|
|
84
|
+
struct glassTransmissionUniforms {
|
|
85
|
+
viewportSize: vec2<f32>,
|
|
86
|
+
depthRange: vec2<f32>,
|
|
87
|
+
environmentIntensity: f32,
|
|
88
|
+
environmentMipLevels: f32,
|
|
89
|
+
environmentPrefilterStrength: f32,
|
|
90
|
+
thicknessStrength: f32,
|
|
91
|
+
roughTransmissionStrength: f32,
|
|
92
|
+
spectralAbsorptionStrength: f32,
|
|
93
|
+
thinFilmThickness: f32,
|
|
94
|
+
thinFilmStrength: f32,
|
|
95
|
+
volumeScatteringStrength: f32,
|
|
96
|
+
contactShadowStrength: f32,
|
|
97
|
+
depthBias: f32,
|
|
98
|
+
dynamicReflectionStrength: f32,
|
|
99
|
+
secondaryBounceStrength: f32,
|
|
100
|
+
faultDistortionStrength: f32,
|
|
101
|
+
time: f32,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
@group(0) @binding(auto) var<uniform> glassTransmission: glassTransmissionUniforms;
|
|
105
|
+
@group(0) @binding(auto) var glassSceneDepthTexture: texture_depth_2d;
|
|
106
|
+
@group(0) @binding(auto) var glassBackfaceTexture: texture_2d<f32>;
|
|
107
|
+
@group(0) @binding(auto) var glassBackfaceTextureSampler: sampler;
|
|
108
|
+
@group(0) @binding(auto) var glassEnvironmentTexture: texture_2d<f32>;
|
|
109
|
+
@group(0) @binding(auto) var glassEnvironmentTextureSampler: sampler;
|
|
110
|
+
|
|
111
|
+
fn glassTransmission_linearizeDepth(depth: f32) -> f32 {
|
|
112
|
+
let nearPlane = glassTransmission.depthRange.x;
|
|
113
|
+
let farPlane = glassTransmission.depthRange.y;
|
|
114
|
+
return nearPlane * farPlane /
|
|
115
|
+
max(farPlane - depth * (farPlane - nearPlane), 0.0001);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn glassTransmission_sampleDepth(screenCoordinate: vec2<f32>) -> f32 {
|
|
119
|
+
let pixelCoordinate = vec2<i32>(clamp(
|
|
120
|
+
screenCoordinate * glassTransmission.viewportSize,
|
|
121
|
+
vec2<f32>(0.0),
|
|
122
|
+
glassTransmission.viewportSize - vec2<f32>(1.0)
|
|
123
|
+
));
|
|
124
|
+
return textureLoad(glassSceneDepthTexture, pixelCoordinate, 0);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fn glassTransmission_sampleEnvironmentAtRoughness(
|
|
128
|
+
reflectionDirection: vec3<f32>,
|
|
129
|
+
surfaceRoughness: f32
|
|
130
|
+
) -> vec3<f32> {
|
|
131
|
+
let normalizedDirection = normalize(reflectionDirection);
|
|
132
|
+
let environmentCoordinate = vec2<f32>(
|
|
133
|
+
atan2(normalizedDirection.z, normalizedDirection.x) * 0.15915494 + 0.5,
|
|
134
|
+
acos(clamp(normalizedDirection.y, -1.0, 1.0)) * 0.31830989
|
|
135
|
+
);
|
|
136
|
+
let roughness = clamp(surfaceRoughness, 0.0, 1.0);
|
|
137
|
+
let maximumMipLevel = max(glassTransmission.environmentMipLevels - 1.0, 0.0);
|
|
138
|
+
if (glassTransmission.environmentPrefilterStrength > 0.0 && maximumMipLevel > 0.0) {
|
|
139
|
+
let reflectionLevel = clamp(
|
|
140
|
+
roughness * roughness * maximumMipLevel * glassTransmission.environmentPrefilterStrength,
|
|
141
|
+
0.0,
|
|
142
|
+
maximumMipLevel
|
|
143
|
+
);
|
|
144
|
+
let clearcoatLevel = max(reflectionLevel - 0.6, 0.0);
|
|
145
|
+
let filteredEnvironment = textureSampleLevel(
|
|
146
|
+
glassEnvironmentTexture,
|
|
147
|
+
glassEnvironmentTextureSampler,
|
|
148
|
+
environmentCoordinate,
|
|
149
|
+
reflectionLevel
|
|
150
|
+
).rgb;
|
|
151
|
+
let clearcoatEnvironment = textureSampleLevel(
|
|
152
|
+
glassEnvironmentTexture,
|
|
153
|
+
glassEnvironmentTextureSampler,
|
|
154
|
+
environmentCoordinate,
|
|
155
|
+
clearcoatLevel
|
|
156
|
+
).rgb;
|
|
157
|
+
return mix(
|
|
158
|
+
clearcoatEnvironment,
|
|
159
|
+
filteredEnvironment,
|
|
160
|
+
smoothstep(0.045, 0.58, roughness)
|
|
161
|
+
) * glassTransmission.environmentIntensity;
|
|
162
|
+
}
|
|
163
|
+
let blurOffset = vec2<f32>(0.018, 0.011) * roughness;
|
|
164
|
+
let centered = textureSampleLevel(
|
|
165
|
+
glassEnvironmentTexture,
|
|
166
|
+
glassEnvironmentTextureSampler,
|
|
167
|
+
environmentCoordinate,
|
|
168
|
+
0.0
|
|
169
|
+
).rgb;
|
|
170
|
+
let forward = textureSampleLevel(
|
|
171
|
+
glassEnvironmentTexture,
|
|
172
|
+
glassEnvironmentTextureSampler,
|
|
173
|
+
environmentCoordinate + blurOffset,
|
|
174
|
+
0.0
|
|
175
|
+
).rgb;
|
|
176
|
+
let backward = textureSampleLevel(
|
|
177
|
+
glassEnvironmentTexture,
|
|
178
|
+
glassEnvironmentTextureSampler,
|
|
179
|
+
environmentCoordinate - blurOffset,
|
|
180
|
+
0.0
|
|
181
|
+
).rgb;
|
|
182
|
+
let baselineEnvironment = (centered + forward + backward) / 3.0;
|
|
183
|
+
if (glassTransmission.roughTransmissionStrength <= 0.0) {
|
|
184
|
+
return mix(
|
|
185
|
+
centered,
|
|
186
|
+
baselineEnvironment,
|
|
187
|
+
smoothstep(0.08, 0.7, roughness)
|
|
188
|
+
) * glassTransmission.environmentIntensity;
|
|
189
|
+
}
|
|
190
|
+
let crossOffset = vec2<f32>(-blurOffset.y, blurOffset.x);
|
|
191
|
+
let upper = textureSampleLevel(
|
|
192
|
+
glassEnvironmentTexture,
|
|
193
|
+
glassEnvironmentTextureSampler,
|
|
194
|
+
environmentCoordinate + crossOffset,
|
|
195
|
+
0.0
|
|
196
|
+
).rgb;
|
|
197
|
+
let lower = textureSampleLevel(
|
|
198
|
+
glassEnvironmentTexture,
|
|
199
|
+
glassEnvironmentTextureSampler,
|
|
200
|
+
environmentCoordinate - crossOffset,
|
|
201
|
+
0.0
|
|
202
|
+
).rgb;
|
|
203
|
+
let filteredEnvironment = mix(
|
|
204
|
+
baselineEnvironment,
|
|
205
|
+
(centered + forward + backward + upper + lower) / 5.0,
|
|
206
|
+
clamp(glassTransmission.roughTransmissionStrength, 0.0, 1.0)
|
|
207
|
+
);
|
|
208
|
+
return mix(
|
|
209
|
+
centered,
|
|
210
|
+
filteredEnvironment,
|
|
211
|
+
smoothstep(0.08, 0.7, roughness)
|
|
212
|
+
) * glassTransmission.environmentIntensity;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fn glassTransmission_sampleEnvironment(reflectionDirection: vec3<f32>) -> vec3<f32> {
|
|
216
|
+
return glassTransmission_sampleEnvironmentAtRoughness(
|
|
217
|
+
reflectionDirection,
|
|
218
|
+
glassMaterial.roughness
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
fn glassTransmission_getContactShadow(
|
|
223
|
+
screenCoordinate: vec2<f32>,
|
|
224
|
+
frontDepth: f32,
|
|
225
|
+
backDepth: f32,
|
|
226
|
+
hasBackface: bool
|
|
227
|
+
) -> f32 {
|
|
228
|
+
if (glassTransmission.contactShadowStrength <= 0.0 || !hasBackface) {
|
|
229
|
+
return 1.0;
|
|
230
|
+
}
|
|
231
|
+
let opaqueDepth = glassTransmission_sampleDepth(screenCoordinate);
|
|
232
|
+
if (opaqueDepth >= 0.99999) {
|
|
233
|
+
return 1.0;
|
|
234
|
+
}
|
|
235
|
+
let receiverDepth = glassTransmission_linearizeDepth(opaqueDepth);
|
|
236
|
+
let receiverIsBehindFront = smoothstep(frontDepth - 0.035, frontDepth + 0.045, receiverDepth);
|
|
237
|
+
let receiverGap = max(receiverDepth - backDepth, 0.0);
|
|
238
|
+
let contact = receiverIsBehindFront * (1.0 - smoothstep(0.035, 0.44, receiverGap));
|
|
239
|
+
return 1.0 - contact * clamp(glassTransmission.contactShadowStrength, 0.0, 1.0) * 0.36;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
fn glassTransmission_sampleRoughTransmission(
|
|
243
|
+
screenCoordinate: vec2<f32>,
|
|
244
|
+
refractionOffset: vec2<f32>,
|
|
245
|
+
dispersionOffset: vec2<f32>,
|
|
246
|
+
measuredThickness: f32
|
|
247
|
+
) -> vec3<f32> {
|
|
248
|
+
let centered = glassMaterial_sampleTransmission(
|
|
249
|
+
screenCoordinate,
|
|
250
|
+
refractionOffset,
|
|
251
|
+
dispersionOffset
|
|
252
|
+
);
|
|
253
|
+
let roughness = glassMaterial.roughness * glassTransmission.roughTransmissionStrength;
|
|
254
|
+
if (roughness <= 0.0001) {
|
|
255
|
+
return centered;
|
|
256
|
+
}
|
|
257
|
+
let pixelSize = vec2<f32>(1.0) / max(glassTransmission.viewportSize, vec2<f32>(1.0));
|
|
258
|
+
let blurOffset = pixelSize * roughness * (2.0 + measuredThickness * 11.0);
|
|
259
|
+
let horizontalOffset = vec2<f32>(blurOffset.x, 0.0);
|
|
260
|
+
let verticalOffset = vec2<f32>(0.0, blurOffset.y);
|
|
261
|
+
let positiveHorizontal = glassMaterial_sampleTransmission(
|
|
262
|
+
screenCoordinate,
|
|
263
|
+
refractionOffset + horizontalOffset,
|
|
264
|
+
dispersionOffset
|
|
265
|
+
);
|
|
266
|
+
let negativeHorizontal = glassMaterial_sampleTransmission(
|
|
267
|
+
screenCoordinate,
|
|
268
|
+
refractionOffset - horizontalOffset,
|
|
269
|
+
dispersionOffset
|
|
270
|
+
);
|
|
271
|
+
let positiveVertical = glassMaterial_sampleTransmission(
|
|
272
|
+
screenCoordinate,
|
|
273
|
+
refractionOffset + verticalOffset,
|
|
274
|
+
dispersionOffset
|
|
275
|
+
);
|
|
276
|
+
let negativeVertical = glassMaterial_sampleTransmission(
|
|
277
|
+
screenCoordinate,
|
|
278
|
+
refractionOffset - verticalOffset,
|
|
279
|
+
dispersionOffset
|
|
280
|
+
);
|
|
281
|
+
let filteredTransmission = (
|
|
282
|
+
centered * 2.0 + positiveHorizontal + negativeHorizontal + positiveVertical + negativeVertical
|
|
283
|
+
) / 6.0;
|
|
284
|
+
return mix(centered, filteredTransmission, smoothstep(0.02, 0.42, roughness));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
fn glassTransmission_getSpectralAbsorption(
|
|
288
|
+
baseColor: vec3<f32>,
|
|
289
|
+
measuredThickness: f32
|
|
290
|
+
) -> vec3<f32> {
|
|
291
|
+
let baselineExtinction = vec3<f32>(0.1, 0.065, 0.032) + (1.0 - baseColor) * 0.22;
|
|
292
|
+
let spectralExtinction = (
|
|
293
|
+
vec3<f32>(0.11, 0.045, 0.022) * 0.35 +
|
|
294
|
+
(1.0 - baseColor) * vec3<f32>(0.46, 0.26, 0.15)
|
|
295
|
+
) * glassTransmission.spectralAbsorptionStrength;
|
|
296
|
+
return exp(-(baselineExtinction + spectralExtinction) * measuredThickness);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
fn glassTransmission_getThinFilm(viewAlignment: f32) -> vec3<f32> {
|
|
300
|
+
let refractiveIndex = max(glassMaterial.indexOfRefraction, 1.001);
|
|
301
|
+
let filmAlignment = sqrt(max(
|
|
302
|
+
1.0 - (1.0 - viewAlignment * viewAlignment) / (refractiveIndex * refractiveIndex),
|
|
303
|
+
0.02
|
|
304
|
+
));
|
|
305
|
+
let wavelengths = vec3<f32>(650.0, 530.0, 460.0);
|
|
306
|
+
let phase = 12.56637061 * glassTransmission.thinFilmThickness *
|
|
307
|
+
refractiveIndex * filmAlignment / wavelengths;
|
|
308
|
+
let spectralInterference = 0.5 + 0.5 * cos(phase);
|
|
309
|
+
let filmPresence = select(0.0, 1.0, glassTransmission.thinFilmThickness > 0.0);
|
|
310
|
+
return spectralInterference * pow(1.0 - viewAlignment, 1.45) *
|
|
311
|
+
glassTransmission.thinFilmStrength * filmPresence * 0.18;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
fn glassTransmission_getColor(
|
|
315
|
+
normal: vec3<f32>,
|
|
316
|
+
worldPosition: vec3<f32>,
|
|
317
|
+
baseColor: vec4<f32>,
|
|
318
|
+
cameraPosition: vec3<f32>,
|
|
319
|
+
fragmentPosition: vec4<f32>
|
|
320
|
+
) -> vec4<f32> {
|
|
321
|
+
let surfaceColor = glassMaterial_getColor(
|
|
322
|
+
normal,
|
|
323
|
+
worldPosition,
|
|
324
|
+
baseColor,
|
|
325
|
+
cameraPosition,
|
|
326
|
+
fragmentPosition
|
|
327
|
+
);
|
|
328
|
+
let viewDirection = normalize(cameraPosition - worldPosition);
|
|
329
|
+
let frontNormal = opticalLighting_faceNormal(normalize(normal), viewDirection);
|
|
330
|
+
let screenCoordinate = fragmentPosition.xy / glassTransmission.viewportSize;
|
|
331
|
+
let backface = textureSampleLevel(
|
|
332
|
+
glassBackfaceTexture,
|
|
333
|
+
glassBackfaceTextureSampler,
|
|
334
|
+
clamp(screenCoordinate, vec2<f32>(0.001), vec2<f32>(0.999)),
|
|
335
|
+
0.0
|
|
336
|
+
);
|
|
337
|
+
let frontDepth = glassTransmission_linearizeDepth(fragmentPosition.z);
|
|
338
|
+
let backDepth = glassTransmission_linearizeDepth(backface.a);
|
|
339
|
+
let hasBackface = backface.a > fragmentPosition.z + 0.00001;
|
|
340
|
+
let measuredThickness = select(
|
|
341
|
+
glassMaterial.thickness * 0.4,
|
|
342
|
+
clamp(backDepth - frontDepth, 0.04, glassMaterial.thickness * 1.65),
|
|
343
|
+
hasBackface
|
|
344
|
+
) * glassTransmission.thicknessStrength;
|
|
345
|
+
let backNormal = select(-frontNormal, normalize(backface.rgb * 2.0 - 1.0), hasBackface);
|
|
346
|
+
let indexOfRefraction = max(glassMaterial.indexOfRefraction, 1.001);
|
|
347
|
+
let entryDirection = refract(
|
|
348
|
+
-viewDirection,
|
|
349
|
+
frontNormal,
|
|
350
|
+
1.0 / indexOfRefraction
|
|
351
|
+
);
|
|
352
|
+
let exitDirection = refract(entryDirection, -backNormal, indexOfRefraction);
|
|
353
|
+
let hasExitRay = dot(exitDirection, exitDirection) > 0.0001;
|
|
354
|
+
let transmittedDirection = select(reflect(entryDirection, -backNormal), exitDirection, hasExitRay);
|
|
355
|
+
let cameraUpAxis = select(
|
|
356
|
+
vec3<f32>(0.0, 1.0, 0.0),
|
|
357
|
+
vec3<f32>(0.0, 0.0, 1.0),
|
|
358
|
+
abs(viewDirection.y) > 0.96
|
|
359
|
+
);
|
|
360
|
+
let cameraRight = normalize(cross(cameraUpAxis, viewDirection));
|
|
361
|
+
let cameraUp = normalize(cross(viewDirection, cameraRight));
|
|
362
|
+
let viewportAspect = glassTransmission.viewportSize.x /
|
|
363
|
+
max(glassTransmission.viewportSize.y, 1.0);
|
|
364
|
+
let combinedDeflection = (entryDirection + viewDirection) * 0.68 +
|
|
365
|
+
(transmittedDirection + viewDirection) * 0.32;
|
|
366
|
+
let projectedDeflection = vec2<f32>(
|
|
367
|
+
dot(combinedDeflection, cameraRight) / viewportAspect,
|
|
368
|
+
-dot(combinedDeflection, cameraUp)
|
|
369
|
+
);
|
|
370
|
+
let projectedNormal = vec2<f32>(
|
|
371
|
+
dot(frontNormal, cameraRight) / viewportAspect,
|
|
372
|
+
-dot(frontNormal, cameraUp)
|
|
373
|
+
);
|
|
374
|
+
let faultStrength = clamp(
|
|
375
|
+
(baseColor.r - max(baseColor.g, baseColor.b)) * 1.55 - 0.16,
|
|
376
|
+
0.0,
|
|
377
|
+
1.0
|
|
378
|
+
);
|
|
379
|
+
let faultRipple = sin(
|
|
380
|
+
dot(worldPosition.xz, vec2<f32>(11.0, 8.0)) +
|
|
381
|
+
glassTransmission.time * 5.5 + measuredThickness * 12.0
|
|
382
|
+
) * faultStrength * glassTransmission.faultDistortionStrength;
|
|
383
|
+
let proposedOffset = projectedDeflection * measuredThickness *
|
|
384
|
+
glassMaterial.refractionStrength * 0.18 + projectedNormal * faultRipple * 0.018;
|
|
385
|
+
let proposedCoordinate = clamp(
|
|
386
|
+
screenCoordinate + proposedOffset,
|
|
387
|
+
vec2<f32>(0.001),
|
|
388
|
+
vec2<f32>(0.999)
|
|
389
|
+
);
|
|
390
|
+
let sampledDepth = glassTransmission_sampleDepth(proposedCoordinate);
|
|
391
|
+
let foregroundOcclusion = sampledDepth + glassTransmission.depthBias < fragmentPosition.z;
|
|
392
|
+
let safeOffset = select(proposedOffset, vec2<f32>(0.0), foregroundOcclusion);
|
|
393
|
+
let dispersionHalfSpread = (indexOfRefraction - 1.0) * 0.025 *
|
|
394
|
+
max(glassMaterial.dispersion, 0.0);
|
|
395
|
+
let redIndexOfRefraction = max(indexOfRefraction - dispersionHalfSpread, 1.001);
|
|
396
|
+
let blueIndexOfRefraction = indexOfRefraction + dispersionHalfSpread;
|
|
397
|
+
let redEntryDirection = refract(-viewDirection, frontNormal, 1.0 / redIndexOfRefraction);
|
|
398
|
+
let blueEntryDirection = refract(-viewDirection, frontNormal, 1.0 / blueIndexOfRefraction);
|
|
399
|
+
let redExitDirection = refract(redEntryDirection, -backNormal, redIndexOfRefraction);
|
|
400
|
+
let blueExitDirection = refract(blueEntryDirection, -backNormal, blueIndexOfRefraction);
|
|
401
|
+
let redTransmittedDirection = select(
|
|
402
|
+
reflect(redEntryDirection, -backNormal),
|
|
403
|
+
redExitDirection,
|
|
404
|
+
dot(redExitDirection, redExitDirection) > 0.0001
|
|
405
|
+
);
|
|
406
|
+
let blueTransmittedDirection = select(
|
|
407
|
+
reflect(blueEntryDirection, -backNormal),
|
|
408
|
+
blueExitDirection,
|
|
409
|
+
dot(blueExitDirection, blueExitDirection) > 0.0001
|
|
410
|
+
);
|
|
411
|
+
let spectralDeflection = (redEntryDirection - blueEntryDirection) * 0.34 +
|
|
412
|
+
(redTransmittedDirection - blueTransmittedDirection) * 0.16;
|
|
413
|
+
let dispersionOffset = vec2<f32>(
|
|
414
|
+
dot(spectralDeflection, cameraRight) / viewportAspect,
|
|
415
|
+
-dot(spectralDeflection, cameraUp)
|
|
416
|
+
) * measuredThickness * glassMaterial.refractionStrength * 0.18;
|
|
417
|
+
let transmittedColor = glassTransmission_sampleRoughTransmission(
|
|
418
|
+
screenCoordinate,
|
|
419
|
+
safeOffset,
|
|
420
|
+
dispersionOffset,
|
|
421
|
+
measuredThickness
|
|
422
|
+
);
|
|
423
|
+
let absorption = glassTransmission_getSpectralAbsorption(baseColor.rgb, measuredThickness);
|
|
424
|
+
let reflectionDirection = reflect(-viewDirection, frontNormal);
|
|
425
|
+
let environmentReflection = glassTransmission_sampleEnvironment(reflectionDirection);
|
|
426
|
+
let viewAlignment = clamp(dot(frontNormal, viewDirection), 0.0, 1.0);
|
|
427
|
+
let baseReflectance = pow((indexOfRefraction - 1.0) / (indexOfRefraction + 1.0), 2.0);
|
|
428
|
+
let fresnel = clamp(
|
|
429
|
+
opticalLighting_getFresnel(viewAlignment, baseReflectance, 5.0) *
|
|
430
|
+
glassMaterial.fresnelStrength,
|
|
431
|
+
0.0,
|
|
432
|
+
0.96
|
|
433
|
+
);
|
|
434
|
+
let transmissionWeight = (1.0 - fresnel) *
|
|
435
|
+
clamp(glassMaterial.transmissionStrength, 0.0, 1.0);
|
|
436
|
+
let reflectionWeight = fresnel * glassMaterial.reflectionStrength;
|
|
437
|
+
let internalReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
438
|
+
reflect(entryDirection, -backNormal),
|
|
439
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.13
|
|
440
|
+
) * select(0.18, 0.42, !hasExitRay);
|
|
441
|
+
let secondaryDirection = reflect(reflect(entryDirection, -backNormal), frontNormal);
|
|
442
|
+
let secondaryReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
443
|
+
secondaryDirection,
|
|
444
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.25
|
|
445
|
+
) *
|
|
446
|
+
glassTransmission.secondaryBounceStrength * pow(1.0 - viewAlignment, 1.45) * 0.24;
|
|
447
|
+
let thinFilmReflection = glassTransmission_getThinFilm(viewAlignment);
|
|
448
|
+
let volumeScattering = baseColor.rgb * (1.0 - exp(-measuredThickness * 1.3)) *
|
|
449
|
+
glassTransmission.volumeScatteringStrength * (0.045 + (1.0 - viewAlignment) * 0.09);
|
|
450
|
+
let reflectionCoordinate = clamp(
|
|
451
|
+
screenCoordinate + vec2<f32>(
|
|
452
|
+
dot(reflectionDirection, cameraRight) / viewportAspect,
|
|
453
|
+
-dot(reflectionDirection, cameraUp)
|
|
454
|
+
) * (0.025 + measuredThickness * 0.018),
|
|
455
|
+
vec2<f32>(0.001),
|
|
456
|
+
vec2<f32>(0.999)
|
|
457
|
+
);
|
|
458
|
+
let reflectedSceneColor = textureSampleLevel(
|
|
459
|
+
glassSceneColorTexture,
|
|
460
|
+
glassSceneColorTextureSampler,
|
|
461
|
+
reflectionCoordinate,
|
|
462
|
+
0.0
|
|
463
|
+
).rgb;
|
|
464
|
+
let reflectedSceneLuminance = dot(reflectedSceneColor, vec3<f32>(0.2126, 0.7152, 0.0722));
|
|
465
|
+
let reflectedSceneResponse = smoothstep(0.42, 1.4, reflectedSceneLuminance);
|
|
466
|
+
let grazingReflection = pow(1.0 - viewAlignment, 1.7);
|
|
467
|
+
let dynamicReflection = reflectedSceneColor * reflectedSceneResponse *
|
|
468
|
+
glassTransmission.dynamicReflectionStrength * grazingReflection * (0.12 + fresnel * 0.34);
|
|
469
|
+
let faultFilament = baseColor.rgb * faultStrength *
|
|
470
|
+
glassTransmission.faultDistortionStrength *
|
|
471
|
+
pow(max(sin(dot(worldPosition, vec3<f32>(14.0, 10.0, 17.0)) +
|
|
472
|
+
glassTransmission.time * 7.0), 0.0), 10.0) * 0.12;
|
|
473
|
+
let contactShadow = glassTransmission_getContactShadow(
|
|
474
|
+
screenCoordinate,
|
|
475
|
+
frontDepth,
|
|
476
|
+
backDepth,
|
|
477
|
+
hasBackface
|
|
478
|
+
);
|
|
479
|
+
let opticalColor = transmittedColor * absorption * transmissionWeight * contactShadow +
|
|
480
|
+
environmentReflection * reflectionWeight +
|
|
481
|
+
internalReflection * pow(1.0 - viewAlignment, 2.0) + secondaryReflection +
|
|
482
|
+
thinFilmReflection + volumeScattering + dynamicReflection + faultFilament;
|
|
483
|
+
return vec4<f32>(mix(surfaceColor.rgb, opticalColor, 0.64), surfaceColor.a);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
#ifdef LUMA_OPTICAL_POINT_LIGHTS
|
|
487
|
+
fn glassTransmission_getIlluminatedColor(
|
|
488
|
+
normal: vec3<f32>,
|
|
489
|
+
worldPosition: vec3<f32>,
|
|
490
|
+
baseColor: vec4<f32>,
|
|
491
|
+
cameraPosition: vec3<f32>,
|
|
492
|
+
fragmentPosition: vec4<f32>
|
|
493
|
+
) -> vec4<f32> {
|
|
494
|
+
let transmittedColor = glassTransmission_getColor(
|
|
495
|
+
normal,
|
|
496
|
+
worldPosition,
|
|
497
|
+
baseColor,
|
|
498
|
+
cameraPosition,
|
|
499
|
+
fragmentPosition
|
|
500
|
+
);
|
|
501
|
+
let pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
|
|
502
|
+
let pointLightReflection = opticalPointLights_getSpecularColor(
|
|
503
|
+
normal,
|
|
504
|
+
worldPosition,
|
|
505
|
+
cameraPosition,
|
|
506
|
+
glassMaterial.roughness
|
|
507
|
+
);
|
|
508
|
+
let volumeLightScattering = pointLightColor *
|
|
509
|
+
glassTransmission.volumeScatteringStrength * 0.11;
|
|
510
|
+
return vec4<f32>(
|
|
511
|
+
transmittedColor.rgb + pointLightReflection * glassMaterial.reflectionStrength +
|
|
512
|
+
volumeLightScattering,
|
|
513
|
+
transmittedColor.a
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
#endif
|
|
517
|
+
`;
|
|
518
|
+
|
|
519
|
+
const GLASS_TRANSMISSION_GLSL = /* glsl */ `\
|
|
520
|
+
layout(std140) uniform glassTransmissionUniforms {
|
|
521
|
+
vec2 viewportSize;
|
|
522
|
+
vec2 depthRange;
|
|
523
|
+
float environmentIntensity;
|
|
524
|
+
float environmentMipLevels;
|
|
525
|
+
float environmentPrefilterStrength;
|
|
526
|
+
float thicknessStrength;
|
|
527
|
+
float roughTransmissionStrength;
|
|
528
|
+
float spectralAbsorptionStrength;
|
|
529
|
+
float thinFilmThickness;
|
|
530
|
+
float thinFilmStrength;
|
|
531
|
+
float volumeScatteringStrength;
|
|
532
|
+
float contactShadowStrength;
|
|
533
|
+
float depthBias;
|
|
534
|
+
float dynamicReflectionStrength;
|
|
535
|
+
float secondaryBounceStrength;
|
|
536
|
+
float faultDistortionStrength;
|
|
537
|
+
float time;
|
|
538
|
+
} glassTransmission;
|
|
539
|
+
|
|
540
|
+
uniform sampler2D glassSceneDepthTexture;
|
|
541
|
+
uniform sampler2D glassBackfaceTexture;
|
|
542
|
+
uniform sampler2D glassEnvironmentTexture;
|
|
543
|
+
|
|
544
|
+
float glassTransmission_linearizeDepth(float depth) {
|
|
545
|
+
float nearPlane = glassTransmission.depthRange.x;
|
|
546
|
+
float farPlane = glassTransmission.depthRange.y;
|
|
547
|
+
return nearPlane * farPlane /
|
|
548
|
+
max(farPlane - depth * (farPlane - nearPlane), 0.0001);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
float glassTransmission_sampleDepth(vec2 screenCoordinate) {
|
|
552
|
+
return texture(
|
|
553
|
+
glassSceneDepthTexture,
|
|
554
|
+
clamp(screenCoordinate, vec2(0.001), vec2(0.999))
|
|
555
|
+
).r;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
vec3 glassTransmission_sampleEnvironmentAtRoughness(
|
|
559
|
+
vec3 reflectionDirection,
|
|
560
|
+
float surfaceRoughness
|
|
561
|
+
) {
|
|
562
|
+
vec3 normalizedDirection = normalize(reflectionDirection);
|
|
563
|
+
vec2 environmentCoordinate = vec2(
|
|
564
|
+
atan(normalizedDirection.z, normalizedDirection.x) * 0.15915494 + 0.5,
|
|
565
|
+
acos(clamp(normalizedDirection.y, -1.0, 1.0)) * 0.31830989
|
|
566
|
+
);
|
|
567
|
+
float roughness = clamp(surfaceRoughness, 0.0, 1.0);
|
|
568
|
+
float maximumMipLevel = max(glassTransmission.environmentMipLevels - 1.0, 0.0);
|
|
569
|
+
if (glassTransmission.environmentPrefilterStrength > 0.0 && maximumMipLevel > 0.0) {
|
|
570
|
+
float reflectionLevel = clamp(
|
|
571
|
+
roughness * roughness * maximumMipLevel * glassTransmission.environmentPrefilterStrength,
|
|
572
|
+
0.0,
|
|
573
|
+
maximumMipLevel
|
|
574
|
+
);
|
|
575
|
+
float clearcoatLevel = max(reflectionLevel - 0.6, 0.0);
|
|
576
|
+
vec3 filteredEnvironment = textureLod(
|
|
577
|
+
glassEnvironmentTexture,
|
|
578
|
+
environmentCoordinate,
|
|
579
|
+
reflectionLevel
|
|
580
|
+
).rgb;
|
|
581
|
+
vec3 clearcoatEnvironment = textureLod(
|
|
582
|
+
glassEnvironmentTexture,
|
|
583
|
+
environmentCoordinate,
|
|
584
|
+
clearcoatLevel
|
|
585
|
+
).rgb;
|
|
586
|
+
return mix(
|
|
587
|
+
clearcoatEnvironment,
|
|
588
|
+
filteredEnvironment,
|
|
589
|
+
smoothstep(0.045, 0.58, roughness)
|
|
590
|
+
) * glassTransmission.environmentIntensity;
|
|
591
|
+
}
|
|
592
|
+
vec2 blurOffset = vec2(0.018, 0.011) * roughness;
|
|
593
|
+
vec3 centered = textureLod(glassEnvironmentTexture, environmentCoordinate, 0.0).rgb;
|
|
594
|
+
vec3 forward = textureLod(
|
|
595
|
+
glassEnvironmentTexture,
|
|
596
|
+
environmentCoordinate + blurOffset,
|
|
597
|
+
0.0
|
|
598
|
+
).rgb;
|
|
599
|
+
vec3 backward = textureLod(
|
|
600
|
+
glassEnvironmentTexture,
|
|
601
|
+
environmentCoordinate - blurOffset,
|
|
602
|
+
0.0
|
|
603
|
+
).rgb;
|
|
604
|
+
vec3 baselineEnvironment = (centered + forward + backward) / 3.0;
|
|
605
|
+
if (glassTransmission.roughTransmissionStrength <= 0.0) {
|
|
606
|
+
return mix(
|
|
607
|
+
centered,
|
|
608
|
+
baselineEnvironment,
|
|
609
|
+
smoothstep(0.08, 0.7, roughness)
|
|
610
|
+
) * glassTransmission.environmentIntensity;
|
|
611
|
+
}
|
|
612
|
+
vec2 crossOffset = vec2(-blurOffset.y, blurOffset.x);
|
|
613
|
+
vec3 upper = textureLod(
|
|
614
|
+
glassEnvironmentTexture,
|
|
615
|
+
environmentCoordinate + crossOffset,
|
|
616
|
+
0.0
|
|
617
|
+
).rgb;
|
|
618
|
+
vec3 lower = textureLod(
|
|
619
|
+
glassEnvironmentTexture,
|
|
620
|
+
environmentCoordinate - crossOffset,
|
|
621
|
+
0.0
|
|
622
|
+
).rgb;
|
|
623
|
+
vec3 filteredEnvironment = mix(
|
|
624
|
+
baselineEnvironment,
|
|
625
|
+
(centered + forward + backward + upper + lower) / 5.0,
|
|
626
|
+
clamp(glassTransmission.roughTransmissionStrength, 0.0, 1.0)
|
|
627
|
+
);
|
|
628
|
+
return mix(
|
|
629
|
+
centered,
|
|
630
|
+
filteredEnvironment,
|
|
631
|
+
smoothstep(0.08, 0.7, roughness)
|
|
632
|
+
) * glassTransmission.environmentIntensity;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
vec3 glassTransmission_sampleEnvironment(vec3 reflectionDirection) {
|
|
636
|
+
return glassTransmission_sampleEnvironmentAtRoughness(
|
|
637
|
+
reflectionDirection,
|
|
638
|
+
glassMaterial.roughness
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
float glassTransmission_getContactShadow(
|
|
643
|
+
vec2 screenCoordinate,
|
|
644
|
+
float frontDepth,
|
|
645
|
+
float backDepth,
|
|
646
|
+
bool hasBackface
|
|
647
|
+
) {
|
|
648
|
+
if (glassTransmission.contactShadowStrength <= 0.0 || !hasBackface) {
|
|
649
|
+
return 1.0;
|
|
650
|
+
}
|
|
651
|
+
float opaqueDepth = glassTransmission_sampleDepth(screenCoordinate);
|
|
652
|
+
if (opaqueDepth >= 0.99999) {
|
|
653
|
+
return 1.0;
|
|
654
|
+
}
|
|
655
|
+
float receiverDepth = glassTransmission_linearizeDepth(opaqueDepth);
|
|
656
|
+
float receiverIsBehindFront = smoothstep(frontDepth - 0.035, frontDepth + 0.045, receiverDepth);
|
|
657
|
+
float receiverGap = max(receiverDepth - backDepth, 0.0);
|
|
658
|
+
float contact = receiverIsBehindFront * (1.0 - smoothstep(0.035, 0.44, receiverGap));
|
|
659
|
+
return 1.0 - contact * clamp(glassTransmission.contactShadowStrength, 0.0, 1.0) * 0.36;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
vec3 glassTransmission_sampleRoughTransmission(
|
|
663
|
+
vec2 screenCoordinate,
|
|
664
|
+
vec2 refractionOffset,
|
|
665
|
+
vec2 dispersionOffset,
|
|
666
|
+
float measuredThickness
|
|
667
|
+
) {
|
|
668
|
+
vec3 centered = glassMaterial_sampleTransmission(
|
|
669
|
+
screenCoordinate,
|
|
670
|
+
refractionOffset,
|
|
671
|
+
dispersionOffset
|
|
672
|
+
);
|
|
673
|
+
float roughness = glassMaterial.roughness * glassTransmission.roughTransmissionStrength;
|
|
674
|
+
if (roughness <= 0.0001) {
|
|
675
|
+
return centered;
|
|
676
|
+
}
|
|
677
|
+
vec2 pixelSize = vec2(1.0) / max(glassTransmission.viewportSize, vec2(1.0));
|
|
678
|
+
vec2 blurOffset = pixelSize * roughness * (2.0 + measuredThickness * 11.0);
|
|
679
|
+
vec2 horizontalOffset = vec2(blurOffset.x, 0.0);
|
|
680
|
+
vec2 verticalOffset = vec2(0.0, blurOffset.y);
|
|
681
|
+
vec3 positiveHorizontal = glassMaterial_sampleTransmission(
|
|
682
|
+
screenCoordinate,
|
|
683
|
+
refractionOffset + horizontalOffset,
|
|
684
|
+
dispersionOffset
|
|
685
|
+
);
|
|
686
|
+
vec3 negativeHorizontal = glassMaterial_sampleTransmission(
|
|
687
|
+
screenCoordinate,
|
|
688
|
+
refractionOffset - horizontalOffset,
|
|
689
|
+
dispersionOffset
|
|
690
|
+
);
|
|
691
|
+
vec3 positiveVertical = glassMaterial_sampleTransmission(
|
|
692
|
+
screenCoordinate,
|
|
693
|
+
refractionOffset + verticalOffset,
|
|
694
|
+
dispersionOffset
|
|
695
|
+
);
|
|
696
|
+
vec3 negativeVertical = glassMaterial_sampleTransmission(
|
|
697
|
+
screenCoordinate,
|
|
698
|
+
refractionOffset - verticalOffset,
|
|
699
|
+
dispersionOffset
|
|
700
|
+
);
|
|
701
|
+
vec3 filteredTransmission = (
|
|
702
|
+
centered * 2.0 + positiveHorizontal + negativeHorizontal + positiveVertical + negativeVertical
|
|
703
|
+
) / 6.0;
|
|
704
|
+
return mix(centered, filteredTransmission, smoothstep(0.02, 0.42, roughness));
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
vec3 glassTransmission_getSpectralAbsorption(vec3 baseColor, float measuredThickness) {
|
|
708
|
+
vec3 baselineExtinction = vec3(0.1, 0.065, 0.032) + (1.0 - baseColor) * 0.22;
|
|
709
|
+
vec3 spectralExtinction = (
|
|
710
|
+
vec3(0.11, 0.045, 0.022) * 0.35 +
|
|
711
|
+
(1.0 - baseColor) * vec3(0.46, 0.26, 0.15)
|
|
712
|
+
) * glassTransmission.spectralAbsorptionStrength;
|
|
713
|
+
return exp(-(baselineExtinction + spectralExtinction) * measuredThickness);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
vec3 glassTransmission_getThinFilm(float viewAlignment) {
|
|
717
|
+
float refractiveIndex = max(glassMaterial.indexOfRefraction, 1.001);
|
|
718
|
+
float filmAlignment = sqrt(max(
|
|
719
|
+
1.0 - (1.0 - viewAlignment * viewAlignment) / (refractiveIndex * refractiveIndex),
|
|
720
|
+
0.02
|
|
721
|
+
));
|
|
722
|
+
vec3 wavelengths = vec3(650.0, 530.0, 460.0);
|
|
723
|
+
vec3 phase = 12.56637061 * glassTransmission.thinFilmThickness *
|
|
724
|
+
refractiveIndex * filmAlignment / wavelengths;
|
|
725
|
+
vec3 spectralInterference = 0.5 + 0.5 * cos(phase);
|
|
726
|
+
float filmPresence = glassTransmission.thinFilmThickness > 0.0 ? 1.0 : 0.0;
|
|
727
|
+
return spectralInterference * pow(1.0 - viewAlignment, 1.45) *
|
|
728
|
+
glassTransmission.thinFilmStrength * filmPresence * 0.18;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
vec4 glassTransmission_getColor(
|
|
732
|
+
vec3 normal,
|
|
733
|
+
vec3 worldPosition,
|
|
734
|
+
vec4 baseColor,
|
|
735
|
+
vec3 cameraPosition,
|
|
736
|
+
vec4 fragmentPosition
|
|
737
|
+
) {
|
|
738
|
+
vec4 surfaceColor = glassMaterial_getColor(
|
|
739
|
+
normal,
|
|
740
|
+
worldPosition,
|
|
741
|
+
baseColor,
|
|
742
|
+
cameraPosition,
|
|
743
|
+
fragmentPosition
|
|
744
|
+
);
|
|
745
|
+
vec3 viewDirection = normalize(cameraPosition - worldPosition);
|
|
746
|
+
vec3 frontNormal = opticalLighting_faceNormal(normalize(normal), viewDirection);
|
|
747
|
+
vec2 screenCoordinate = fragmentPosition.xy / glassTransmission.viewportSize;
|
|
748
|
+
vec4 backface = texture(
|
|
749
|
+
glassBackfaceTexture,
|
|
750
|
+
clamp(screenCoordinate, vec2(0.001), vec2(0.999))
|
|
751
|
+
);
|
|
752
|
+
float frontDepth = glassTransmission_linearizeDepth(fragmentPosition.z);
|
|
753
|
+
float backDepth = glassTransmission_linearizeDepth(backface.a);
|
|
754
|
+
bool hasBackface = backface.a > fragmentPosition.z + 0.00001;
|
|
755
|
+
float measuredThickness = (
|
|
756
|
+
hasBackface
|
|
757
|
+
? clamp(backDepth - frontDepth, 0.04, glassMaterial.thickness * 1.65)
|
|
758
|
+
: glassMaterial.thickness * 0.4
|
|
759
|
+
) * glassTransmission.thicknessStrength;
|
|
760
|
+
vec3 backNormal = hasBackface ? normalize(backface.rgb * 2.0 - 1.0) : -frontNormal;
|
|
761
|
+
float indexOfRefraction = max(glassMaterial.indexOfRefraction, 1.001);
|
|
762
|
+
vec3 entryDirection = refract(
|
|
763
|
+
-viewDirection,
|
|
764
|
+
frontNormal,
|
|
765
|
+
1.0 / indexOfRefraction
|
|
766
|
+
);
|
|
767
|
+
vec3 exitDirection = refract(entryDirection, -backNormal, indexOfRefraction);
|
|
768
|
+
bool hasExitRay = dot(exitDirection, exitDirection) > 0.0001;
|
|
769
|
+
vec3 transmittedDirection = hasExitRay
|
|
770
|
+
? exitDirection
|
|
771
|
+
: reflect(entryDirection, -backNormal);
|
|
772
|
+
vec3 cameraUpAxis = abs(viewDirection.y) > 0.96
|
|
773
|
+
? vec3(0.0, 0.0, 1.0)
|
|
774
|
+
: vec3(0.0, 1.0, 0.0);
|
|
775
|
+
vec3 cameraRight = normalize(cross(cameraUpAxis, viewDirection));
|
|
776
|
+
vec3 cameraUp = normalize(cross(viewDirection, cameraRight));
|
|
777
|
+
float viewportAspect = glassTransmission.viewportSize.x /
|
|
778
|
+
max(glassTransmission.viewportSize.y, 1.0);
|
|
779
|
+
vec3 combinedDeflection = (entryDirection + viewDirection) * 0.68 +
|
|
780
|
+
(transmittedDirection + viewDirection) * 0.32;
|
|
781
|
+
vec2 projectedDeflection = vec2(
|
|
782
|
+
dot(combinedDeflection, cameraRight) / viewportAspect,
|
|
783
|
+
dot(combinedDeflection, cameraUp)
|
|
784
|
+
);
|
|
785
|
+
vec2 projectedNormal = vec2(
|
|
786
|
+
dot(frontNormal, cameraRight) / viewportAspect,
|
|
787
|
+
dot(frontNormal, cameraUp)
|
|
788
|
+
);
|
|
789
|
+
float faultStrength = clamp(
|
|
790
|
+
(baseColor.r - max(baseColor.g, baseColor.b)) * 1.55 - 0.16,
|
|
791
|
+
0.0,
|
|
792
|
+
1.0
|
|
793
|
+
);
|
|
794
|
+
float faultRipple = sin(
|
|
795
|
+
dot(worldPosition.xz, vec2(11.0, 8.0)) +
|
|
796
|
+
glassTransmission.time * 5.5 + measuredThickness * 12.0
|
|
797
|
+
) * faultStrength * glassTransmission.faultDistortionStrength;
|
|
798
|
+
vec2 proposedOffset = projectedDeflection * measuredThickness *
|
|
799
|
+
glassMaterial.refractionStrength * 0.18 + projectedNormal * faultRipple * 0.018;
|
|
800
|
+
vec2 proposedCoordinate = clamp(
|
|
801
|
+
screenCoordinate + proposedOffset,
|
|
802
|
+
vec2(0.001),
|
|
803
|
+
vec2(0.999)
|
|
804
|
+
);
|
|
805
|
+
float sampledDepth = glassTransmission_sampleDepth(proposedCoordinate);
|
|
806
|
+
bool foregroundOcclusion = sampledDepth + glassTransmission.depthBias < fragmentPosition.z;
|
|
807
|
+
vec2 safeOffset = foregroundOcclusion ? vec2(0.0) : proposedOffset;
|
|
808
|
+
float dispersionHalfSpread = (indexOfRefraction - 1.0) * 0.025 *
|
|
809
|
+
max(glassMaterial.dispersion, 0.0);
|
|
810
|
+
float redIndexOfRefraction = max(indexOfRefraction - dispersionHalfSpread, 1.001);
|
|
811
|
+
float blueIndexOfRefraction = indexOfRefraction + dispersionHalfSpread;
|
|
812
|
+
vec3 redEntryDirection = refract(-viewDirection, frontNormal, 1.0 / redIndexOfRefraction);
|
|
813
|
+
vec3 blueEntryDirection = refract(-viewDirection, frontNormal, 1.0 / blueIndexOfRefraction);
|
|
814
|
+
vec3 redExitDirection = refract(redEntryDirection, -backNormal, redIndexOfRefraction);
|
|
815
|
+
vec3 blueExitDirection = refract(blueEntryDirection, -backNormal, blueIndexOfRefraction);
|
|
816
|
+
vec3 redTransmittedDirection = dot(redExitDirection, redExitDirection) > 0.0001
|
|
817
|
+
? redExitDirection
|
|
818
|
+
: reflect(redEntryDirection, -backNormal);
|
|
819
|
+
vec3 blueTransmittedDirection = dot(blueExitDirection, blueExitDirection) > 0.0001
|
|
820
|
+
? blueExitDirection
|
|
821
|
+
: reflect(blueEntryDirection, -backNormal);
|
|
822
|
+
vec3 spectralDeflection = (redEntryDirection - blueEntryDirection) * 0.34 +
|
|
823
|
+
(redTransmittedDirection - blueTransmittedDirection) * 0.16;
|
|
824
|
+
vec2 dispersionOffset = vec2(
|
|
825
|
+
dot(spectralDeflection, cameraRight) / viewportAspect,
|
|
826
|
+
dot(spectralDeflection, cameraUp)
|
|
827
|
+
) * measuredThickness * glassMaterial.refractionStrength * 0.18;
|
|
828
|
+
vec3 transmittedColor = glassTransmission_sampleRoughTransmission(
|
|
829
|
+
screenCoordinate,
|
|
830
|
+
safeOffset,
|
|
831
|
+
dispersionOffset,
|
|
832
|
+
measuredThickness
|
|
833
|
+
);
|
|
834
|
+
vec3 absorption = glassTransmission_getSpectralAbsorption(baseColor.rgb, measuredThickness);
|
|
835
|
+
vec3 reflectionDirection = reflect(-viewDirection, frontNormal);
|
|
836
|
+
vec3 environmentReflection = glassTransmission_sampleEnvironment(reflectionDirection);
|
|
837
|
+
float viewAlignment = clamp(dot(frontNormal, viewDirection), 0.0, 1.0);
|
|
838
|
+
float baseReflectance = pow((indexOfRefraction - 1.0) / (indexOfRefraction + 1.0), 2.0);
|
|
839
|
+
float fresnel = clamp(
|
|
840
|
+
opticalLighting_getFresnel(viewAlignment, baseReflectance, 5.0) *
|
|
841
|
+
glassMaterial.fresnelStrength,
|
|
842
|
+
0.0,
|
|
843
|
+
0.96
|
|
844
|
+
);
|
|
845
|
+
float transmissionWeight = (1.0 - fresnel) *
|
|
846
|
+
clamp(glassMaterial.transmissionStrength, 0.0, 1.0);
|
|
847
|
+
float reflectionWeight = fresnel * glassMaterial.reflectionStrength;
|
|
848
|
+
vec3 internalReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
849
|
+
reflect(entryDirection, -backNormal),
|
|
850
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.13
|
|
851
|
+
) * (hasExitRay ? 0.18 : 0.42);
|
|
852
|
+
vec3 secondaryDirection = reflect(reflect(entryDirection, -backNormal), frontNormal);
|
|
853
|
+
vec3 secondaryReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
854
|
+
secondaryDirection,
|
|
855
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.25
|
|
856
|
+
) *
|
|
857
|
+
glassTransmission.secondaryBounceStrength * pow(1.0 - viewAlignment, 1.45) * 0.24;
|
|
858
|
+
vec3 thinFilmReflection = glassTransmission_getThinFilm(viewAlignment);
|
|
859
|
+
vec3 volumeScattering = baseColor.rgb * (1.0 - exp(-measuredThickness * 1.3)) *
|
|
860
|
+
glassTransmission.volumeScatteringStrength * (0.045 + (1.0 - viewAlignment) * 0.09);
|
|
861
|
+
vec2 reflectionCoordinate = clamp(
|
|
862
|
+
screenCoordinate + vec2(
|
|
863
|
+
dot(reflectionDirection, cameraRight) / viewportAspect,
|
|
864
|
+
dot(reflectionDirection, cameraUp)
|
|
865
|
+
) * (0.025 + measuredThickness * 0.018),
|
|
866
|
+
vec2(0.001),
|
|
867
|
+
vec2(0.999)
|
|
868
|
+
);
|
|
869
|
+
vec3 reflectedSceneColor = texture(glassSceneColorTexture, reflectionCoordinate).rgb;
|
|
870
|
+
float reflectedSceneLuminance = dot(reflectedSceneColor, vec3(0.2126, 0.7152, 0.0722));
|
|
871
|
+
float reflectedSceneResponse = smoothstep(0.42, 1.4, reflectedSceneLuminance);
|
|
872
|
+
float grazingReflection = pow(1.0 - viewAlignment, 1.7);
|
|
873
|
+
vec3 dynamicReflection = reflectedSceneColor * reflectedSceneResponse *
|
|
874
|
+
glassTransmission.dynamicReflectionStrength * grazingReflection * (0.12 + fresnel * 0.34);
|
|
875
|
+
vec3 faultFilament = baseColor.rgb * faultStrength *
|
|
876
|
+
glassTransmission.faultDistortionStrength *
|
|
877
|
+
pow(max(sin(dot(worldPosition, vec3(14.0, 10.0, 17.0)) +
|
|
878
|
+
glassTransmission.time * 7.0), 0.0), 10.0) * 0.12;
|
|
879
|
+
float contactShadow = glassTransmission_getContactShadow(
|
|
880
|
+
screenCoordinate,
|
|
881
|
+
frontDepth,
|
|
882
|
+
backDepth,
|
|
883
|
+
hasBackface
|
|
884
|
+
);
|
|
885
|
+
vec3 opticalColor = transmittedColor * absorption * transmissionWeight * contactShadow +
|
|
886
|
+
environmentReflection * reflectionWeight +
|
|
887
|
+
internalReflection * pow(1.0 - viewAlignment, 2.0) + secondaryReflection +
|
|
888
|
+
thinFilmReflection + volumeScattering + dynamicReflection + faultFilament;
|
|
889
|
+
return vec4(mix(surfaceColor.rgb, opticalColor, 0.64), surfaceColor.a);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
#ifdef LUMA_OPTICAL_POINT_LIGHTS
|
|
893
|
+
vec4 glassTransmission_getIlluminatedColor(
|
|
894
|
+
vec3 normal,
|
|
895
|
+
vec3 worldPosition,
|
|
896
|
+
vec4 baseColor,
|
|
897
|
+
vec3 cameraPosition,
|
|
898
|
+
vec4 fragmentPosition
|
|
899
|
+
) {
|
|
900
|
+
vec4 transmittedColor = glassTransmission_getColor(
|
|
901
|
+
normal,
|
|
902
|
+
worldPosition,
|
|
903
|
+
baseColor,
|
|
904
|
+
cameraPosition,
|
|
905
|
+
fragmentPosition
|
|
906
|
+
);
|
|
907
|
+
vec3 pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
|
|
908
|
+
vec3 pointLightReflection = opticalPointLights_getSpecularColor(
|
|
909
|
+
normal,
|
|
910
|
+
worldPosition,
|
|
911
|
+
cameraPosition,
|
|
912
|
+
glassMaterial.roughness
|
|
913
|
+
);
|
|
914
|
+
vec3 volumeLightScattering = pointLightColor *
|
|
915
|
+
glassTransmission.volumeScatteringStrength * 0.11;
|
|
916
|
+
return vec4(
|
|
917
|
+
transmittedColor.rgb + pointLightReflection * glassMaterial.reflectionStrength +
|
|
918
|
+
volumeLightScattering,
|
|
919
|
+
transmittedColor.a
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
#endif
|
|
923
|
+
`;
|
|
924
|
+
|
|
925
|
+
function getGlassTransmissionUniforms(
|
|
926
|
+
props: Partial<GlassTransmissionProps> = {},
|
|
927
|
+
previousUniforms?: GlassTransmissionUniforms
|
|
928
|
+
): Partial<GlassTransmissionUniforms & GlassTransmissionBindings> {
|
|
929
|
+
return {
|
|
930
|
+
viewportSize: props.viewportSize ?? previousUniforms?.viewportSize ?? [1, 1],
|
|
931
|
+
depthRange: props.depthRange ?? previousUniforms?.depthRange ?? [0.1, 100],
|
|
932
|
+
environmentIntensity: props.environmentIntensity ?? previousUniforms?.environmentIntensity ?? 1,
|
|
933
|
+
environmentMipLevels: props.environmentMipLevels ?? previousUniforms?.environmentMipLevels ?? 1,
|
|
934
|
+
environmentPrefilterStrength:
|
|
935
|
+
props.environmentPrefilterStrength ?? previousUniforms?.environmentPrefilterStrength ?? 0,
|
|
936
|
+
thicknessStrength: props.thicknessStrength ?? previousUniforms?.thicknessStrength ?? 1,
|
|
937
|
+
roughTransmissionStrength:
|
|
938
|
+
props.roughTransmissionStrength ?? previousUniforms?.roughTransmissionStrength ?? 0,
|
|
939
|
+
spectralAbsorptionStrength:
|
|
940
|
+
props.spectralAbsorptionStrength ?? previousUniforms?.spectralAbsorptionStrength ?? 0,
|
|
941
|
+
thinFilmThickness: props.thinFilmThickness ?? previousUniforms?.thinFilmThickness ?? 0,
|
|
942
|
+
thinFilmStrength: props.thinFilmStrength ?? previousUniforms?.thinFilmStrength ?? 0,
|
|
943
|
+
volumeScatteringStrength:
|
|
944
|
+
props.volumeScatteringStrength ?? previousUniforms?.volumeScatteringStrength ?? 0,
|
|
945
|
+
contactShadowStrength:
|
|
946
|
+
props.contactShadowStrength ?? previousUniforms?.contactShadowStrength ?? 0,
|
|
947
|
+
depthBias: props.depthBias ?? previousUniforms?.depthBias ?? 0.00008,
|
|
948
|
+
dynamicReflectionStrength:
|
|
949
|
+
props.dynamicReflectionStrength ?? previousUniforms?.dynamicReflectionStrength ?? 0,
|
|
950
|
+
secondaryBounceStrength:
|
|
951
|
+
props.secondaryBounceStrength ?? previousUniforms?.secondaryBounceStrength ?? 0,
|
|
952
|
+
faultDistortionStrength:
|
|
953
|
+
props.faultDistortionStrength ?? previousUniforms?.faultDistortionStrength ?? 0,
|
|
954
|
+
time: props.time ?? previousUniforms?.time ?? 0,
|
|
955
|
+
...(props.sceneDepthTexture ? {glassSceneDepthTexture: props.sceneDepthTexture} : {}),
|
|
956
|
+
...(props.backfaceTexture ? {glassBackfaceTexture: props.backfaceTexture} : {}),
|
|
957
|
+
...(props.environmentTexture ? {glassEnvironmentTexture: props.environmentTexture} : {})
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/** Optional backface-thickness, depth-aware transmission, and environment-map glass extension. */
|
|
962
|
+
export const glassTransmission = {
|
|
963
|
+
name: 'glassTransmission',
|
|
964
|
+
source: GLASS_TRANSMISSION_WGSL,
|
|
965
|
+
fs: GLASS_TRANSMISSION_GLSL,
|
|
966
|
+
dependencies: [glassMaterial],
|
|
967
|
+
bindingLayout: [
|
|
968
|
+
{name: 'glassSceneDepthTexture', group: 0, visibility: SHADER_STAGE_FRAGMENT},
|
|
969
|
+
{name: 'glassBackfaceTexture', group: 0, visibility: SHADER_STAGE_FRAGMENT},
|
|
970
|
+
{name: 'glassBackfaceTextureSampler', group: 0, visibility: SHADER_STAGE_FRAGMENT},
|
|
971
|
+
{name: 'glassEnvironmentTexture', group: 0, visibility: SHADER_STAGE_FRAGMENT},
|
|
972
|
+
{name: 'glassEnvironmentTextureSampler', group: 0, visibility: SHADER_STAGE_FRAGMENT}
|
|
973
|
+
],
|
|
974
|
+
uniformTypes: {
|
|
975
|
+
viewportSize: 'vec2<f32>',
|
|
976
|
+
depthRange: 'vec2<f32>',
|
|
977
|
+
environmentIntensity: 'f32',
|
|
978
|
+
environmentMipLevels: 'f32',
|
|
979
|
+
environmentPrefilterStrength: 'f32',
|
|
980
|
+
thicknessStrength: 'f32',
|
|
981
|
+
roughTransmissionStrength: 'f32',
|
|
982
|
+
spectralAbsorptionStrength: 'f32',
|
|
983
|
+
thinFilmThickness: 'f32',
|
|
984
|
+
thinFilmStrength: 'f32',
|
|
985
|
+
volumeScatteringStrength: 'f32',
|
|
986
|
+
contactShadowStrength: 'f32',
|
|
987
|
+
depthBias: 'f32',
|
|
988
|
+
dynamicReflectionStrength: 'f32',
|
|
989
|
+
secondaryBounceStrength: 'f32',
|
|
990
|
+
faultDistortionStrength: 'f32',
|
|
991
|
+
time: 'f32'
|
|
992
|
+
},
|
|
993
|
+
defaultUniforms: {
|
|
994
|
+
viewportSize: [1, 1],
|
|
995
|
+
depthRange: [0.1, 100],
|
|
996
|
+
environmentIntensity: 1,
|
|
997
|
+
environmentMipLevels: 1,
|
|
998
|
+
environmentPrefilterStrength: 0,
|
|
999
|
+
thicknessStrength: 1,
|
|
1000
|
+
roughTransmissionStrength: 0,
|
|
1001
|
+
spectralAbsorptionStrength: 0,
|
|
1002
|
+
thinFilmThickness: 0,
|
|
1003
|
+
thinFilmStrength: 0,
|
|
1004
|
+
volumeScatteringStrength: 0,
|
|
1005
|
+
contactShadowStrength: 0,
|
|
1006
|
+
depthBias: 0.00008,
|
|
1007
|
+
dynamicReflectionStrength: 0,
|
|
1008
|
+
secondaryBounceStrength: 0,
|
|
1009
|
+
faultDistortionStrength: 0,
|
|
1010
|
+
time: 0
|
|
1011
|
+
},
|
|
1012
|
+
getUniforms: getGlassTransmissionUniforms
|
|
1013
|
+
} as const satisfies ShaderModule<
|
|
1014
|
+
GlassTransmissionProps,
|
|
1015
|
+
GlassTransmissionUniforms,
|
|
1016
|
+
GlassTransmissionBindings
|
|
1017
|
+
>;
|
|
1018
|
+
|
|
1019
|
+
/** Installs the optional rasterized transmission extension and its glass-material dependency. */
|
|
1020
|
+
export const glassTransmissionPlugin = {
|
|
1021
|
+
name: 'glassTransmission',
|
|
1022
|
+
modules: [glassTransmission as ShaderModule]
|
|
1023
|
+
} as const satisfies ShaderPlugin;
|