@luma.gl/engine 10.0.0-alpha.3 → 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 +11517 -6015
- 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/edge-geometry.d.ts +3 -2
- package/dist/geometry/edge-geometry.d.ts.map +1 -1
- package/dist/geometry/edge-geometry.js.map +1 -1
- package/dist/geometry/geometry-primitives.cjs +189 -0
- package/dist/geometry/geometry-primitives.d.ts +60 -0
- package/dist/geometry/geometry-primitives.d.ts.map +1 -0
- package/dist/geometry/geometry-primitives.js +161 -0
- package/dist/geometry/geometry-primitives.js.map +1 -0
- package/dist/geometry/geometry-table.cjs +15 -0
- package/dist/geometry/geometry-utils.cjs +147 -0
- package/dist/geometry/geometry-utils.d.ts +7 -15
- package/dist/geometry/geometry-utils.d.ts.map +1 -1
- package/dist/geometry/geometry-utils.js +9 -55
- package/dist/geometry/geometry-utils.js.map +1 -1
- package/dist/geometry/geometry.cjs +90 -0
- package/dist/geometry/geometry.d.ts +9 -69
- package/dist/geometry/geometry.d.ts.map +1 -1
- package/dist/geometry/geometry.js +27 -93
- package/dist/geometry/geometry.js.map +1 -1
- package/dist/geometry/gpu-geometry.cjs +130 -0
- package/dist/geometry/gpu-geometry.d.ts +4 -2
- package/dist/geometry/gpu-geometry.d.ts.map +1 -1
- package/dist/geometry/gpu-geometry.js +3 -3
- package/dist/geometry/gpu-geometry.js.map +1 -1
- 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 -10629
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +46 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -10
- 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 +22 -306
- 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/clip-space.d.ts +4 -1
- package/dist/models/clip-space.d.ts.map +1 -1
- package/dist/models/clip-space.js +16 -13
- package/dist/models/clip-space.js.map +1 -1
- package/dist/models/directional-light-model.cjs +45 -0
- package/dist/models/directional-light-model.js +1 -1
- package/dist/models/directional-light-model.js.map +1 -1
- package/dist/models/light-model-utils.cjs +426 -0
- package/dist/models/point-light-model.cjs +44 -0
- package/dist/models/point-light-model.js +1 -1
- package/dist/models/point-light-model.js.map +1 -1
- package/dist/models/spot-light-model.cjs +45 -0
- package/dist/models/spot-light-model.js +1 -1
- package/dist/models/spot-light-model.js.map +1 -1
- 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 +47 -8
- 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/edge-geometry.ts +7 -3
- package/src/geometry/geometry-primitives.ts +226 -0
- package/src/geometry/geometry-utils.ts +16 -71
- package/src/geometry/geometry.ts +36 -163
- package/src/geometry/gpu-geometry.ts +9 -4
- 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 +144 -27
- 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/models/clip-space.ts +21 -14
- package/src/models/directional-light-model.ts +1 -1
- package/src/models/point-light-model.ts +1 -1
- package/src/models/spot-light-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/dist/geometries/cone-geometry.d.ts +0 -12
- package/dist/geometries/cone-geometry.d.ts.map +0 -1
- package/dist/geometries/cone-geometry.js +0 -19
- package/dist/geometries/cone-geometry.js.map +0 -1
- package/dist/geometries/cube-geometry.d.ts +0 -14
- package/dist/geometries/cube-geometry.d.ts.map +0 -1
- package/dist/geometries/cube-geometry.js +0 -222
- package/dist/geometries/cube-geometry.js.map +0 -1
- package/dist/geometries/cylinder-geometry.d.ts +0 -11
- package/dist/geometries/cylinder-geometry.d.ts.map +0 -1
- package/dist/geometries/cylinder-geometry.js +0 -17
- package/dist/geometries/cylinder-geometry.js.map +0 -1
- package/dist/geometries/ico-sphere-geometry.d.ts +0 -11
- package/dist/geometries/ico-sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/ico-sphere-geometry.js +0 -158
- package/dist/geometries/ico-sphere-geometry.js.map +0 -1
- package/dist/geometries/plane-geometry.d.ts +0 -20
- package/dist/geometries/plane-geometry.d.ts.map +0 -1
- package/dist/geometries/plane-geometry.js +0 -106
- package/dist/geometries/plane-geometry.js.map +0 -1
- package/dist/geometries/sphere-geometry.d.ts +0 -12
- package/dist/geometries/sphere-geometry.d.ts.map +0 -1
- package/dist/geometries/sphere-geometry.js +0 -88
- package/dist/geometries/sphere-geometry.js.map +0 -1
- package/dist/geometries/truncated-cone-geometry.d.ts +0 -23
- package/dist/geometries/truncated-cone-geometry.d.ts.map +0 -1
- package/dist/geometries/truncated-cone-geometry.js +0 -112
- package/dist/geometries/truncated-cone-geometry.js.map +0 -1
- package/src/compute/kernel.ts +0 -146
- package/src/compute/render-kernel.ts +0 -192
- package/src/geometries/cone-geometry.ts +0 -31
- package/src/geometries/cube-geometry.ts +0 -258
- package/src/geometries/cylinder-geometry.ts +0 -28
- package/src/geometries/ico-sphere-geometry.ts +0 -193
- package/src/geometries/plane-geometry.ts +0 -142
- package/src/geometries/sphere-geometry.ts +0 -113
- package/src/geometries/truncated-cone-geometry.ts +0 -145
|
@@ -0,0 +1,954 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var glass_transmission_exports = {};
|
|
19
|
+
__export(glass_transmission_exports, {
|
|
20
|
+
glassTransmission: () => glassTransmission,
|
|
21
|
+
glassTransmissionPlugin: () => glassTransmissionPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(glass_transmission_exports);
|
|
24
|
+
var import_glass_material = require("./glass-material.cjs");
|
|
25
|
+
const SHADER_STAGE_FRAGMENT = 2;
|
|
26
|
+
const GLASS_TRANSMISSION_WGSL = (
|
|
27
|
+
/* wgsl */
|
|
28
|
+
`struct glassTransmissionUniforms {
|
|
29
|
+
viewportSize: vec2<f32>,
|
|
30
|
+
depthRange: vec2<f32>,
|
|
31
|
+
environmentIntensity: f32,
|
|
32
|
+
environmentMipLevels: f32,
|
|
33
|
+
environmentPrefilterStrength: f32,
|
|
34
|
+
thicknessStrength: f32,
|
|
35
|
+
roughTransmissionStrength: f32,
|
|
36
|
+
spectralAbsorptionStrength: f32,
|
|
37
|
+
thinFilmThickness: f32,
|
|
38
|
+
thinFilmStrength: f32,
|
|
39
|
+
volumeScatteringStrength: f32,
|
|
40
|
+
contactShadowStrength: f32,
|
|
41
|
+
depthBias: f32,
|
|
42
|
+
dynamicReflectionStrength: f32,
|
|
43
|
+
secondaryBounceStrength: f32,
|
|
44
|
+
faultDistortionStrength: f32,
|
|
45
|
+
time: f32,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
@group(0) @binding(auto) var<uniform> glassTransmission: glassTransmissionUniforms;
|
|
49
|
+
@group(0) @binding(auto) var glassSceneDepthTexture: texture_depth_2d;
|
|
50
|
+
@group(0) @binding(auto) var glassBackfaceTexture: texture_2d<f32>;
|
|
51
|
+
@group(0) @binding(auto) var glassBackfaceTextureSampler: sampler;
|
|
52
|
+
@group(0) @binding(auto) var glassEnvironmentTexture: texture_2d<f32>;
|
|
53
|
+
@group(0) @binding(auto) var glassEnvironmentTextureSampler: sampler;
|
|
54
|
+
|
|
55
|
+
fn glassTransmission_linearizeDepth(depth: f32) -> f32 {
|
|
56
|
+
let nearPlane = glassTransmission.depthRange.x;
|
|
57
|
+
let farPlane = glassTransmission.depthRange.y;
|
|
58
|
+
return nearPlane * farPlane /
|
|
59
|
+
max(farPlane - depth * (farPlane - nearPlane), 0.0001);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn glassTransmission_sampleDepth(screenCoordinate: vec2<f32>) -> f32 {
|
|
63
|
+
let pixelCoordinate = vec2<i32>(clamp(
|
|
64
|
+
screenCoordinate * glassTransmission.viewportSize,
|
|
65
|
+
vec2<f32>(0.0),
|
|
66
|
+
glassTransmission.viewportSize - vec2<f32>(1.0)
|
|
67
|
+
));
|
|
68
|
+
return textureLoad(glassSceneDepthTexture, pixelCoordinate, 0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn glassTransmission_sampleEnvironmentAtRoughness(
|
|
72
|
+
reflectionDirection: vec3<f32>,
|
|
73
|
+
surfaceRoughness: f32
|
|
74
|
+
) -> vec3<f32> {
|
|
75
|
+
let normalizedDirection = normalize(reflectionDirection);
|
|
76
|
+
let environmentCoordinate = vec2<f32>(
|
|
77
|
+
atan2(normalizedDirection.z, normalizedDirection.x) * 0.15915494 + 0.5,
|
|
78
|
+
acos(clamp(normalizedDirection.y, -1.0, 1.0)) * 0.31830989
|
|
79
|
+
);
|
|
80
|
+
let roughness = clamp(surfaceRoughness, 0.0, 1.0);
|
|
81
|
+
let maximumMipLevel = max(glassTransmission.environmentMipLevels - 1.0, 0.0);
|
|
82
|
+
if (glassTransmission.environmentPrefilterStrength > 0.0 && maximumMipLevel > 0.0) {
|
|
83
|
+
let reflectionLevel = clamp(
|
|
84
|
+
roughness * roughness * maximumMipLevel * glassTransmission.environmentPrefilterStrength,
|
|
85
|
+
0.0,
|
|
86
|
+
maximumMipLevel
|
|
87
|
+
);
|
|
88
|
+
let clearcoatLevel = max(reflectionLevel - 0.6, 0.0);
|
|
89
|
+
let filteredEnvironment = textureSampleLevel(
|
|
90
|
+
glassEnvironmentTexture,
|
|
91
|
+
glassEnvironmentTextureSampler,
|
|
92
|
+
environmentCoordinate,
|
|
93
|
+
reflectionLevel
|
|
94
|
+
).rgb;
|
|
95
|
+
let clearcoatEnvironment = textureSampleLevel(
|
|
96
|
+
glassEnvironmentTexture,
|
|
97
|
+
glassEnvironmentTextureSampler,
|
|
98
|
+
environmentCoordinate,
|
|
99
|
+
clearcoatLevel
|
|
100
|
+
).rgb;
|
|
101
|
+
return mix(
|
|
102
|
+
clearcoatEnvironment,
|
|
103
|
+
filteredEnvironment,
|
|
104
|
+
smoothstep(0.045, 0.58, roughness)
|
|
105
|
+
) * glassTransmission.environmentIntensity;
|
|
106
|
+
}
|
|
107
|
+
let blurOffset = vec2<f32>(0.018, 0.011) * roughness;
|
|
108
|
+
let centered = textureSampleLevel(
|
|
109
|
+
glassEnvironmentTexture,
|
|
110
|
+
glassEnvironmentTextureSampler,
|
|
111
|
+
environmentCoordinate,
|
|
112
|
+
0.0
|
|
113
|
+
).rgb;
|
|
114
|
+
let forward = textureSampleLevel(
|
|
115
|
+
glassEnvironmentTexture,
|
|
116
|
+
glassEnvironmentTextureSampler,
|
|
117
|
+
environmentCoordinate + blurOffset,
|
|
118
|
+
0.0
|
|
119
|
+
).rgb;
|
|
120
|
+
let backward = textureSampleLevel(
|
|
121
|
+
glassEnvironmentTexture,
|
|
122
|
+
glassEnvironmentTextureSampler,
|
|
123
|
+
environmentCoordinate - blurOffset,
|
|
124
|
+
0.0
|
|
125
|
+
).rgb;
|
|
126
|
+
let baselineEnvironment = (centered + forward + backward) / 3.0;
|
|
127
|
+
if (glassTransmission.roughTransmissionStrength <= 0.0) {
|
|
128
|
+
return mix(
|
|
129
|
+
centered,
|
|
130
|
+
baselineEnvironment,
|
|
131
|
+
smoothstep(0.08, 0.7, roughness)
|
|
132
|
+
) * glassTransmission.environmentIntensity;
|
|
133
|
+
}
|
|
134
|
+
let crossOffset = vec2<f32>(-blurOffset.y, blurOffset.x);
|
|
135
|
+
let upper = textureSampleLevel(
|
|
136
|
+
glassEnvironmentTexture,
|
|
137
|
+
glassEnvironmentTextureSampler,
|
|
138
|
+
environmentCoordinate + crossOffset,
|
|
139
|
+
0.0
|
|
140
|
+
).rgb;
|
|
141
|
+
let lower = textureSampleLevel(
|
|
142
|
+
glassEnvironmentTexture,
|
|
143
|
+
glassEnvironmentTextureSampler,
|
|
144
|
+
environmentCoordinate - crossOffset,
|
|
145
|
+
0.0
|
|
146
|
+
).rgb;
|
|
147
|
+
let filteredEnvironment = mix(
|
|
148
|
+
baselineEnvironment,
|
|
149
|
+
(centered + forward + backward + upper + lower) / 5.0,
|
|
150
|
+
clamp(glassTransmission.roughTransmissionStrength, 0.0, 1.0)
|
|
151
|
+
);
|
|
152
|
+
return mix(
|
|
153
|
+
centered,
|
|
154
|
+
filteredEnvironment,
|
|
155
|
+
smoothstep(0.08, 0.7, roughness)
|
|
156
|
+
) * glassTransmission.environmentIntensity;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn glassTransmission_sampleEnvironment(reflectionDirection: vec3<f32>) -> vec3<f32> {
|
|
160
|
+
return glassTransmission_sampleEnvironmentAtRoughness(
|
|
161
|
+
reflectionDirection,
|
|
162
|
+
glassMaterial.roughness
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
fn glassTransmission_getContactShadow(
|
|
167
|
+
screenCoordinate: vec2<f32>,
|
|
168
|
+
frontDepth: f32,
|
|
169
|
+
backDepth: f32,
|
|
170
|
+
hasBackface: bool
|
|
171
|
+
) -> f32 {
|
|
172
|
+
if (glassTransmission.contactShadowStrength <= 0.0 || !hasBackface) {
|
|
173
|
+
return 1.0;
|
|
174
|
+
}
|
|
175
|
+
let opaqueDepth = glassTransmission_sampleDepth(screenCoordinate);
|
|
176
|
+
if (opaqueDepth >= 0.99999) {
|
|
177
|
+
return 1.0;
|
|
178
|
+
}
|
|
179
|
+
let receiverDepth = glassTransmission_linearizeDepth(opaqueDepth);
|
|
180
|
+
let receiverIsBehindFront = smoothstep(frontDepth - 0.035, frontDepth + 0.045, receiverDepth);
|
|
181
|
+
let receiverGap = max(receiverDepth - backDepth, 0.0);
|
|
182
|
+
let contact = receiverIsBehindFront * (1.0 - smoothstep(0.035, 0.44, receiverGap));
|
|
183
|
+
return 1.0 - contact * clamp(glassTransmission.contactShadowStrength, 0.0, 1.0) * 0.36;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
fn glassTransmission_sampleRoughTransmission(
|
|
187
|
+
screenCoordinate: vec2<f32>,
|
|
188
|
+
refractionOffset: vec2<f32>,
|
|
189
|
+
dispersionOffset: vec2<f32>,
|
|
190
|
+
measuredThickness: f32
|
|
191
|
+
) -> vec3<f32> {
|
|
192
|
+
let centered = glassMaterial_sampleTransmission(
|
|
193
|
+
screenCoordinate,
|
|
194
|
+
refractionOffset,
|
|
195
|
+
dispersionOffset
|
|
196
|
+
);
|
|
197
|
+
let roughness = glassMaterial.roughness * glassTransmission.roughTransmissionStrength;
|
|
198
|
+
if (roughness <= 0.0001) {
|
|
199
|
+
return centered;
|
|
200
|
+
}
|
|
201
|
+
let pixelSize = vec2<f32>(1.0) / max(glassTransmission.viewportSize, vec2<f32>(1.0));
|
|
202
|
+
let blurOffset = pixelSize * roughness * (2.0 + measuredThickness * 11.0);
|
|
203
|
+
let horizontalOffset = vec2<f32>(blurOffset.x, 0.0);
|
|
204
|
+
let verticalOffset = vec2<f32>(0.0, blurOffset.y);
|
|
205
|
+
let positiveHorizontal = glassMaterial_sampleTransmission(
|
|
206
|
+
screenCoordinate,
|
|
207
|
+
refractionOffset + horizontalOffset,
|
|
208
|
+
dispersionOffset
|
|
209
|
+
);
|
|
210
|
+
let negativeHorizontal = glassMaterial_sampleTransmission(
|
|
211
|
+
screenCoordinate,
|
|
212
|
+
refractionOffset - horizontalOffset,
|
|
213
|
+
dispersionOffset
|
|
214
|
+
);
|
|
215
|
+
let positiveVertical = glassMaterial_sampleTransmission(
|
|
216
|
+
screenCoordinate,
|
|
217
|
+
refractionOffset + verticalOffset,
|
|
218
|
+
dispersionOffset
|
|
219
|
+
);
|
|
220
|
+
let negativeVertical = glassMaterial_sampleTransmission(
|
|
221
|
+
screenCoordinate,
|
|
222
|
+
refractionOffset - verticalOffset,
|
|
223
|
+
dispersionOffset
|
|
224
|
+
);
|
|
225
|
+
let filteredTransmission = (
|
|
226
|
+
centered * 2.0 + positiveHorizontal + negativeHorizontal + positiveVertical + negativeVertical
|
|
227
|
+
) / 6.0;
|
|
228
|
+
return mix(centered, filteredTransmission, smoothstep(0.02, 0.42, roughness));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
fn glassTransmission_getSpectralAbsorption(
|
|
232
|
+
baseColor: vec3<f32>,
|
|
233
|
+
measuredThickness: f32
|
|
234
|
+
) -> vec3<f32> {
|
|
235
|
+
let baselineExtinction = vec3<f32>(0.1, 0.065, 0.032) + (1.0 - baseColor) * 0.22;
|
|
236
|
+
let spectralExtinction = (
|
|
237
|
+
vec3<f32>(0.11, 0.045, 0.022) * 0.35 +
|
|
238
|
+
(1.0 - baseColor) * vec3<f32>(0.46, 0.26, 0.15)
|
|
239
|
+
) * glassTransmission.spectralAbsorptionStrength;
|
|
240
|
+
return exp(-(baselineExtinction + spectralExtinction) * measuredThickness);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
fn glassTransmission_getThinFilm(viewAlignment: f32) -> vec3<f32> {
|
|
244
|
+
let refractiveIndex = max(glassMaterial.indexOfRefraction, 1.001);
|
|
245
|
+
let filmAlignment = sqrt(max(
|
|
246
|
+
1.0 - (1.0 - viewAlignment * viewAlignment) / (refractiveIndex * refractiveIndex),
|
|
247
|
+
0.02
|
|
248
|
+
));
|
|
249
|
+
let wavelengths = vec3<f32>(650.0, 530.0, 460.0);
|
|
250
|
+
let phase = 12.56637061 * glassTransmission.thinFilmThickness *
|
|
251
|
+
refractiveIndex * filmAlignment / wavelengths;
|
|
252
|
+
let spectralInterference = 0.5 + 0.5 * cos(phase);
|
|
253
|
+
let filmPresence = select(0.0, 1.0, glassTransmission.thinFilmThickness > 0.0);
|
|
254
|
+
return spectralInterference * pow(1.0 - viewAlignment, 1.45) *
|
|
255
|
+
glassTransmission.thinFilmStrength * filmPresence * 0.18;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
fn glassTransmission_getColor(
|
|
259
|
+
normal: vec3<f32>,
|
|
260
|
+
worldPosition: vec3<f32>,
|
|
261
|
+
baseColor: vec4<f32>,
|
|
262
|
+
cameraPosition: vec3<f32>,
|
|
263
|
+
fragmentPosition: vec4<f32>
|
|
264
|
+
) -> vec4<f32> {
|
|
265
|
+
let surfaceColor = glassMaterial_getColor(
|
|
266
|
+
normal,
|
|
267
|
+
worldPosition,
|
|
268
|
+
baseColor,
|
|
269
|
+
cameraPosition,
|
|
270
|
+
fragmentPosition
|
|
271
|
+
);
|
|
272
|
+
let viewDirection = normalize(cameraPosition - worldPosition);
|
|
273
|
+
let frontNormal = opticalLighting_faceNormal(normalize(normal), viewDirection);
|
|
274
|
+
let screenCoordinate = fragmentPosition.xy / glassTransmission.viewportSize;
|
|
275
|
+
let backface = textureSampleLevel(
|
|
276
|
+
glassBackfaceTexture,
|
|
277
|
+
glassBackfaceTextureSampler,
|
|
278
|
+
clamp(screenCoordinate, vec2<f32>(0.001), vec2<f32>(0.999)),
|
|
279
|
+
0.0
|
|
280
|
+
);
|
|
281
|
+
let frontDepth = glassTransmission_linearizeDepth(fragmentPosition.z);
|
|
282
|
+
let backDepth = glassTransmission_linearizeDepth(backface.a);
|
|
283
|
+
let hasBackface = backface.a > fragmentPosition.z + 0.00001;
|
|
284
|
+
let measuredThickness = select(
|
|
285
|
+
glassMaterial.thickness * 0.4,
|
|
286
|
+
clamp(backDepth - frontDepth, 0.04, glassMaterial.thickness * 1.65),
|
|
287
|
+
hasBackface
|
|
288
|
+
) * glassTransmission.thicknessStrength;
|
|
289
|
+
let backNormal = select(-frontNormal, normalize(backface.rgb * 2.0 - 1.0), hasBackface);
|
|
290
|
+
let indexOfRefraction = max(glassMaterial.indexOfRefraction, 1.001);
|
|
291
|
+
let entryDirection = refract(
|
|
292
|
+
-viewDirection,
|
|
293
|
+
frontNormal,
|
|
294
|
+
1.0 / indexOfRefraction
|
|
295
|
+
);
|
|
296
|
+
let exitDirection = refract(entryDirection, -backNormal, indexOfRefraction);
|
|
297
|
+
let hasExitRay = dot(exitDirection, exitDirection) > 0.0001;
|
|
298
|
+
let transmittedDirection = select(reflect(entryDirection, -backNormal), exitDirection, hasExitRay);
|
|
299
|
+
let cameraUpAxis = select(
|
|
300
|
+
vec3<f32>(0.0, 1.0, 0.0),
|
|
301
|
+
vec3<f32>(0.0, 0.0, 1.0),
|
|
302
|
+
abs(viewDirection.y) > 0.96
|
|
303
|
+
);
|
|
304
|
+
let cameraRight = normalize(cross(cameraUpAxis, viewDirection));
|
|
305
|
+
let cameraUp = normalize(cross(viewDirection, cameraRight));
|
|
306
|
+
let viewportAspect = glassTransmission.viewportSize.x /
|
|
307
|
+
max(glassTransmission.viewportSize.y, 1.0);
|
|
308
|
+
let combinedDeflection = (entryDirection + viewDirection) * 0.68 +
|
|
309
|
+
(transmittedDirection + viewDirection) * 0.32;
|
|
310
|
+
let projectedDeflection = vec2<f32>(
|
|
311
|
+
dot(combinedDeflection, cameraRight) / viewportAspect,
|
|
312
|
+
-dot(combinedDeflection, cameraUp)
|
|
313
|
+
);
|
|
314
|
+
let projectedNormal = vec2<f32>(
|
|
315
|
+
dot(frontNormal, cameraRight) / viewportAspect,
|
|
316
|
+
-dot(frontNormal, cameraUp)
|
|
317
|
+
);
|
|
318
|
+
let faultStrength = clamp(
|
|
319
|
+
(baseColor.r - max(baseColor.g, baseColor.b)) * 1.55 - 0.16,
|
|
320
|
+
0.0,
|
|
321
|
+
1.0
|
|
322
|
+
);
|
|
323
|
+
let faultRipple = sin(
|
|
324
|
+
dot(worldPosition.xz, vec2<f32>(11.0, 8.0)) +
|
|
325
|
+
glassTransmission.time * 5.5 + measuredThickness * 12.0
|
|
326
|
+
) * faultStrength * glassTransmission.faultDistortionStrength;
|
|
327
|
+
let proposedOffset = projectedDeflection * measuredThickness *
|
|
328
|
+
glassMaterial.refractionStrength * 0.18 + projectedNormal * faultRipple * 0.018;
|
|
329
|
+
let proposedCoordinate = clamp(
|
|
330
|
+
screenCoordinate + proposedOffset,
|
|
331
|
+
vec2<f32>(0.001),
|
|
332
|
+
vec2<f32>(0.999)
|
|
333
|
+
);
|
|
334
|
+
let sampledDepth = glassTransmission_sampleDepth(proposedCoordinate);
|
|
335
|
+
let foregroundOcclusion = sampledDepth + glassTransmission.depthBias < fragmentPosition.z;
|
|
336
|
+
let safeOffset = select(proposedOffset, vec2<f32>(0.0), foregroundOcclusion);
|
|
337
|
+
let dispersionHalfSpread = (indexOfRefraction - 1.0) * 0.025 *
|
|
338
|
+
max(glassMaterial.dispersion, 0.0);
|
|
339
|
+
let redIndexOfRefraction = max(indexOfRefraction - dispersionHalfSpread, 1.001);
|
|
340
|
+
let blueIndexOfRefraction = indexOfRefraction + dispersionHalfSpread;
|
|
341
|
+
let redEntryDirection = refract(-viewDirection, frontNormal, 1.0 / redIndexOfRefraction);
|
|
342
|
+
let blueEntryDirection = refract(-viewDirection, frontNormal, 1.0 / blueIndexOfRefraction);
|
|
343
|
+
let redExitDirection = refract(redEntryDirection, -backNormal, redIndexOfRefraction);
|
|
344
|
+
let blueExitDirection = refract(blueEntryDirection, -backNormal, blueIndexOfRefraction);
|
|
345
|
+
let redTransmittedDirection = select(
|
|
346
|
+
reflect(redEntryDirection, -backNormal),
|
|
347
|
+
redExitDirection,
|
|
348
|
+
dot(redExitDirection, redExitDirection) > 0.0001
|
|
349
|
+
);
|
|
350
|
+
let blueTransmittedDirection = select(
|
|
351
|
+
reflect(blueEntryDirection, -backNormal),
|
|
352
|
+
blueExitDirection,
|
|
353
|
+
dot(blueExitDirection, blueExitDirection) > 0.0001
|
|
354
|
+
);
|
|
355
|
+
let spectralDeflection = (redEntryDirection - blueEntryDirection) * 0.34 +
|
|
356
|
+
(redTransmittedDirection - blueTransmittedDirection) * 0.16;
|
|
357
|
+
let dispersionOffset = vec2<f32>(
|
|
358
|
+
dot(spectralDeflection, cameraRight) / viewportAspect,
|
|
359
|
+
-dot(spectralDeflection, cameraUp)
|
|
360
|
+
) * measuredThickness * glassMaterial.refractionStrength * 0.18;
|
|
361
|
+
let transmittedColor = glassTransmission_sampleRoughTransmission(
|
|
362
|
+
screenCoordinate,
|
|
363
|
+
safeOffset,
|
|
364
|
+
dispersionOffset,
|
|
365
|
+
measuredThickness
|
|
366
|
+
);
|
|
367
|
+
let absorption = glassTransmission_getSpectralAbsorption(baseColor.rgb, measuredThickness);
|
|
368
|
+
let reflectionDirection = reflect(-viewDirection, frontNormal);
|
|
369
|
+
let environmentReflection = glassTransmission_sampleEnvironment(reflectionDirection);
|
|
370
|
+
let viewAlignment = clamp(dot(frontNormal, viewDirection), 0.0, 1.0);
|
|
371
|
+
let baseReflectance = pow((indexOfRefraction - 1.0) / (indexOfRefraction + 1.0), 2.0);
|
|
372
|
+
let fresnel = clamp(
|
|
373
|
+
opticalLighting_getFresnel(viewAlignment, baseReflectance, 5.0) *
|
|
374
|
+
glassMaterial.fresnelStrength,
|
|
375
|
+
0.0,
|
|
376
|
+
0.96
|
|
377
|
+
);
|
|
378
|
+
let transmissionWeight = (1.0 - fresnel) *
|
|
379
|
+
clamp(glassMaterial.transmissionStrength, 0.0, 1.0);
|
|
380
|
+
let reflectionWeight = fresnel * glassMaterial.reflectionStrength;
|
|
381
|
+
let internalReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
382
|
+
reflect(entryDirection, -backNormal),
|
|
383
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.13
|
|
384
|
+
) * select(0.18, 0.42, !hasExitRay);
|
|
385
|
+
let secondaryDirection = reflect(reflect(entryDirection, -backNormal), frontNormal);
|
|
386
|
+
let secondaryReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
387
|
+
secondaryDirection,
|
|
388
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.25
|
|
389
|
+
) *
|
|
390
|
+
glassTransmission.secondaryBounceStrength * pow(1.0 - viewAlignment, 1.45) * 0.24;
|
|
391
|
+
let thinFilmReflection = glassTransmission_getThinFilm(viewAlignment);
|
|
392
|
+
let volumeScattering = baseColor.rgb * (1.0 - exp(-measuredThickness * 1.3)) *
|
|
393
|
+
glassTransmission.volumeScatteringStrength * (0.045 + (1.0 - viewAlignment) * 0.09);
|
|
394
|
+
let reflectionCoordinate = clamp(
|
|
395
|
+
screenCoordinate + vec2<f32>(
|
|
396
|
+
dot(reflectionDirection, cameraRight) / viewportAspect,
|
|
397
|
+
-dot(reflectionDirection, cameraUp)
|
|
398
|
+
) * (0.025 + measuredThickness * 0.018),
|
|
399
|
+
vec2<f32>(0.001),
|
|
400
|
+
vec2<f32>(0.999)
|
|
401
|
+
);
|
|
402
|
+
let reflectedSceneColor = textureSampleLevel(
|
|
403
|
+
glassSceneColorTexture,
|
|
404
|
+
glassSceneColorTextureSampler,
|
|
405
|
+
reflectionCoordinate,
|
|
406
|
+
0.0
|
|
407
|
+
).rgb;
|
|
408
|
+
let reflectedSceneLuminance = dot(reflectedSceneColor, vec3<f32>(0.2126, 0.7152, 0.0722));
|
|
409
|
+
let reflectedSceneResponse = smoothstep(0.42, 1.4, reflectedSceneLuminance);
|
|
410
|
+
let grazingReflection = pow(1.0 - viewAlignment, 1.7);
|
|
411
|
+
let dynamicReflection = reflectedSceneColor * reflectedSceneResponse *
|
|
412
|
+
glassTransmission.dynamicReflectionStrength * grazingReflection * (0.12 + fresnel * 0.34);
|
|
413
|
+
let faultFilament = baseColor.rgb * faultStrength *
|
|
414
|
+
glassTransmission.faultDistortionStrength *
|
|
415
|
+
pow(max(sin(dot(worldPosition, vec3<f32>(14.0, 10.0, 17.0)) +
|
|
416
|
+
glassTransmission.time * 7.0), 0.0), 10.0) * 0.12;
|
|
417
|
+
let contactShadow = glassTransmission_getContactShadow(
|
|
418
|
+
screenCoordinate,
|
|
419
|
+
frontDepth,
|
|
420
|
+
backDepth,
|
|
421
|
+
hasBackface
|
|
422
|
+
);
|
|
423
|
+
let opticalColor = transmittedColor * absorption * transmissionWeight * contactShadow +
|
|
424
|
+
environmentReflection * reflectionWeight +
|
|
425
|
+
internalReflection * pow(1.0 - viewAlignment, 2.0) + secondaryReflection +
|
|
426
|
+
thinFilmReflection + volumeScattering + dynamicReflection + faultFilament;
|
|
427
|
+
return vec4<f32>(mix(surfaceColor.rgb, opticalColor, 0.64), surfaceColor.a);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
#ifdef LUMA_OPTICAL_POINT_LIGHTS
|
|
431
|
+
fn glassTransmission_getIlluminatedColor(
|
|
432
|
+
normal: vec3<f32>,
|
|
433
|
+
worldPosition: vec3<f32>,
|
|
434
|
+
baseColor: vec4<f32>,
|
|
435
|
+
cameraPosition: vec3<f32>,
|
|
436
|
+
fragmentPosition: vec4<f32>
|
|
437
|
+
) -> vec4<f32> {
|
|
438
|
+
let transmittedColor = glassTransmission_getColor(
|
|
439
|
+
normal,
|
|
440
|
+
worldPosition,
|
|
441
|
+
baseColor,
|
|
442
|
+
cameraPosition,
|
|
443
|
+
fragmentPosition
|
|
444
|
+
);
|
|
445
|
+
let pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
|
|
446
|
+
let pointLightReflection = opticalPointLights_getSpecularColor(
|
|
447
|
+
normal,
|
|
448
|
+
worldPosition,
|
|
449
|
+
cameraPosition,
|
|
450
|
+
glassMaterial.roughness
|
|
451
|
+
);
|
|
452
|
+
let volumeLightScattering = pointLightColor *
|
|
453
|
+
glassTransmission.volumeScatteringStrength * 0.11;
|
|
454
|
+
return vec4<f32>(
|
|
455
|
+
transmittedColor.rgb + pointLightReflection * glassMaterial.reflectionStrength +
|
|
456
|
+
volumeLightScattering,
|
|
457
|
+
transmittedColor.a
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
#endif
|
|
461
|
+
`
|
|
462
|
+
);
|
|
463
|
+
const GLASS_TRANSMISSION_GLSL = (
|
|
464
|
+
/* glsl */
|
|
465
|
+
`layout(std140) uniform glassTransmissionUniforms {
|
|
466
|
+
vec2 viewportSize;
|
|
467
|
+
vec2 depthRange;
|
|
468
|
+
float environmentIntensity;
|
|
469
|
+
float environmentMipLevels;
|
|
470
|
+
float environmentPrefilterStrength;
|
|
471
|
+
float thicknessStrength;
|
|
472
|
+
float roughTransmissionStrength;
|
|
473
|
+
float spectralAbsorptionStrength;
|
|
474
|
+
float thinFilmThickness;
|
|
475
|
+
float thinFilmStrength;
|
|
476
|
+
float volumeScatteringStrength;
|
|
477
|
+
float contactShadowStrength;
|
|
478
|
+
float depthBias;
|
|
479
|
+
float dynamicReflectionStrength;
|
|
480
|
+
float secondaryBounceStrength;
|
|
481
|
+
float faultDistortionStrength;
|
|
482
|
+
float time;
|
|
483
|
+
} glassTransmission;
|
|
484
|
+
|
|
485
|
+
uniform sampler2D glassSceneDepthTexture;
|
|
486
|
+
uniform sampler2D glassBackfaceTexture;
|
|
487
|
+
uniform sampler2D glassEnvironmentTexture;
|
|
488
|
+
|
|
489
|
+
float glassTransmission_linearizeDepth(float depth) {
|
|
490
|
+
float nearPlane = glassTransmission.depthRange.x;
|
|
491
|
+
float farPlane = glassTransmission.depthRange.y;
|
|
492
|
+
return nearPlane * farPlane /
|
|
493
|
+
max(farPlane - depth * (farPlane - nearPlane), 0.0001);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
float glassTransmission_sampleDepth(vec2 screenCoordinate) {
|
|
497
|
+
return texture(
|
|
498
|
+
glassSceneDepthTexture,
|
|
499
|
+
clamp(screenCoordinate, vec2(0.001), vec2(0.999))
|
|
500
|
+
).r;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
vec3 glassTransmission_sampleEnvironmentAtRoughness(
|
|
504
|
+
vec3 reflectionDirection,
|
|
505
|
+
float surfaceRoughness
|
|
506
|
+
) {
|
|
507
|
+
vec3 normalizedDirection = normalize(reflectionDirection);
|
|
508
|
+
vec2 environmentCoordinate = vec2(
|
|
509
|
+
atan(normalizedDirection.z, normalizedDirection.x) * 0.15915494 + 0.5,
|
|
510
|
+
acos(clamp(normalizedDirection.y, -1.0, 1.0)) * 0.31830989
|
|
511
|
+
);
|
|
512
|
+
float roughness = clamp(surfaceRoughness, 0.0, 1.0);
|
|
513
|
+
float maximumMipLevel = max(glassTransmission.environmentMipLevels - 1.0, 0.0);
|
|
514
|
+
if (glassTransmission.environmentPrefilterStrength > 0.0 && maximumMipLevel > 0.0) {
|
|
515
|
+
float reflectionLevel = clamp(
|
|
516
|
+
roughness * roughness * maximumMipLevel * glassTransmission.environmentPrefilterStrength,
|
|
517
|
+
0.0,
|
|
518
|
+
maximumMipLevel
|
|
519
|
+
);
|
|
520
|
+
float clearcoatLevel = max(reflectionLevel - 0.6, 0.0);
|
|
521
|
+
vec3 filteredEnvironment = textureLod(
|
|
522
|
+
glassEnvironmentTexture,
|
|
523
|
+
environmentCoordinate,
|
|
524
|
+
reflectionLevel
|
|
525
|
+
).rgb;
|
|
526
|
+
vec3 clearcoatEnvironment = textureLod(
|
|
527
|
+
glassEnvironmentTexture,
|
|
528
|
+
environmentCoordinate,
|
|
529
|
+
clearcoatLevel
|
|
530
|
+
).rgb;
|
|
531
|
+
return mix(
|
|
532
|
+
clearcoatEnvironment,
|
|
533
|
+
filteredEnvironment,
|
|
534
|
+
smoothstep(0.045, 0.58, roughness)
|
|
535
|
+
) * glassTransmission.environmentIntensity;
|
|
536
|
+
}
|
|
537
|
+
vec2 blurOffset = vec2(0.018, 0.011) * roughness;
|
|
538
|
+
vec3 centered = textureLod(glassEnvironmentTexture, environmentCoordinate, 0.0).rgb;
|
|
539
|
+
vec3 forward = textureLod(
|
|
540
|
+
glassEnvironmentTexture,
|
|
541
|
+
environmentCoordinate + blurOffset,
|
|
542
|
+
0.0
|
|
543
|
+
).rgb;
|
|
544
|
+
vec3 backward = textureLod(
|
|
545
|
+
glassEnvironmentTexture,
|
|
546
|
+
environmentCoordinate - blurOffset,
|
|
547
|
+
0.0
|
|
548
|
+
).rgb;
|
|
549
|
+
vec3 baselineEnvironment = (centered + forward + backward) / 3.0;
|
|
550
|
+
if (glassTransmission.roughTransmissionStrength <= 0.0) {
|
|
551
|
+
return mix(
|
|
552
|
+
centered,
|
|
553
|
+
baselineEnvironment,
|
|
554
|
+
smoothstep(0.08, 0.7, roughness)
|
|
555
|
+
) * glassTransmission.environmentIntensity;
|
|
556
|
+
}
|
|
557
|
+
vec2 crossOffset = vec2(-blurOffset.y, blurOffset.x);
|
|
558
|
+
vec3 upper = textureLod(
|
|
559
|
+
glassEnvironmentTexture,
|
|
560
|
+
environmentCoordinate + crossOffset,
|
|
561
|
+
0.0
|
|
562
|
+
).rgb;
|
|
563
|
+
vec3 lower = textureLod(
|
|
564
|
+
glassEnvironmentTexture,
|
|
565
|
+
environmentCoordinate - crossOffset,
|
|
566
|
+
0.0
|
|
567
|
+
).rgb;
|
|
568
|
+
vec3 filteredEnvironment = mix(
|
|
569
|
+
baselineEnvironment,
|
|
570
|
+
(centered + forward + backward + upper + lower) / 5.0,
|
|
571
|
+
clamp(glassTransmission.roughTransmissionStrength, 0.0, 1.0)
|
|
572
|
+
);
|
|
573
|
+
return mix(
|
|
574
|
+
centered,
|
|
575
|
+
filteredEnvironment,
|
|
576
|
+
smoothstep(0.08, 0.7, roughness)
|
|
577
|
+
) * glassTransmission.environmentIntensity;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
vec3 glassTransmission_sampleEnvironment(vec3 reflectionDirection) {
|
|
581
|
+
return glassTransmission_sampleEnvironmentAtRoughness(
|
|
582
|
+
reflectionDirection,
|
|
583
|
+
glassMaterial.roughness
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
float glassTransmission_getContactShadow(
|
|
588
|
+
vec2 screenCoordinate,
|
|
589
|
+
float frontDepth,
|
|
590
|
+
float backDepth,
|
|
591
|
+
bool hasBackface
|
|
592
|
+
) {
|
|
593
|
+
if (glassTransmission.contactShadowStrength <= 0.0 || !hasBackface) {
|
|
594
|
+
return 1.0;
|
|
595
|
+
}
|
|
596
|
+
float opaqueDepth = glassTransmission_sampleDepth(screenCoordinate);
|
|
597
|
+
if (opaqueDepth >= 0.99999) {
|
|
598
|
+
return 1.0;
|
|
599
|
+
}
|
|
600
|
+
float receiverDepth = glassTransmission_linearizeDepth(opaqueDepth);
|
|
601
|
+
float receiverIsBehindFront = smoothstep(frontDepth - 0.035, frontDepth + 0.045, receiverDepth);
|
|
602
|
+
float receiverGap = max(receiverDepth - backDepth, 0.0);
|
|
603
|
+
float contact = receiverIsBehindFront * (1.0 - smoothstep(0.035, 0.44, receiverGap));
|
|
604
|
+
return 1.0 - contact * clamp(glassTransmission.contactShadowStrength, 0.0, 1.0) * 0.36;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
vec3 glassTransmission_sampleRoughTransmission(
|
|
608
|
+
vec2 screenCoordinate,
|
|
609
|
+
vec2 refractionOffset,
|
|
610
|
+
vec2 dispersionOffset,
|
|
611
|
+
float measuredThickness
|
|
612
|
+
) {
|
|
613
|
+
vec3 centered = glassMaterial_sampleTransmission(
|
|
614
|
+
screenCoordinate,
|
|
615
|
+
refractionOffset,
|
|
616
|
+
dispersionOffset
|
|
617
|
+
);
|
|
618
|
+
float roughness = glassMaterial.roughness * glassTransmission.roughTransmissionStrength;
|
|
619
|
+
if (roughness <= 0.0001) {
|
|
620
|
+
return centered;
|
|
621
|
+
}
|
|
622
|
+
vec2 pixelSize = vec2(1.0) / max(glassTransmission.viewportSize, vec2(1.0));
|
|
623
|
+
vec2 blurOffset = pixelSize * roughness * (2.0 + measuredThickness * 11.0);
|
|
624
|
+
vec2 horizontalOffset = vec2(blurOffset.x, 0.0);
|
|
625
|
+
vec2 verticalOffset = vec2(0.0, blurOffset.y);
|
|
626
|
+
vec3 positiveHorizontal = glassMaterial_sampleTransmission(
|
|
627
|
+
screenCoordinate,
|
|
628
|
+
refractionOffset + horizontalOffset,
|
|
629
|
+
dispersionOffset
|
|
630
|
+
);
|
|
631
|
+
vec3 negativeHorizontal = glassMaterial_sampleTransmission(
|
|
632
|
+
screenCoordinate,
|
|
633
|
+
refractionOffset - horizontalOffset,
|
|
634
|
+
dispersionOffset
|
|
635
|
+
);
|
|
636
|
+
vec3 positiveVertical = glassMaterial_sampleTransmission(
|
|
637
|
+
screenCoordinate,
|
|
638
|
+
refractionOffset + verticalOffset,
|
|
639
|
+
dispersionOffset
|
|
640
|
+
);
|
|
641
|
+
vec3 negativeVertical = glassMaterial_sampleTransmission(
|
|
642
|
+
screenCoordinate,
|
|
643
|
+
refractionOffset - verticalOffset,
|
|
644
|
+
dispersionOffset
|
|
645
|
+
);
|
|
646
|
+
vec3 filteredTransmission = (
|
|
647
|
+
centered * 2.0 + positiveHorizontal + negativeHorizontal + positiveVertical + negativeVertical
|
|
648
|
+
) / 6.0;
|
|
649
|
+
return mix(centered, filteredTransmission, smoothstep(0.02, 0.42, roughness));
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
vec3 glassTransmission_getSpectralAbsorption(vec3 baseColor, float measuredThickness) {
|
|
653
|
+
vec3 baselineExtinction = vec3(0.1, 0.065, 0.032) + (1.0 - baseColor) * 0.22;
|
|
654
|
+
vec3 spectralExtinction = (
|
|
655
|
+
vec3(0.11, 0.045, 0.022) * 0.35 +
|
|
656
|
+
(1.0 - baseColor) * vec3(0.46, 0.26, 0.15)
|
|
657
|
+
) * glassTransmission.spectralAbsorptionStrength;
|
|
658
|
+
return exp(-(baselineExtinction + spectralExtinction) * measuredThickness);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
vec3 glassTransmission_getThinFilm(float viewAlignment) {
|
|
662
|
+
float refractiveIndex = max(glassMaterial.indexOfRefraction, 1.001);
|
|
663
|
+
float filmAlignment = sqrt(max(
|
|
664
|
+
1.0 - (1.0 - viewAlignment * viewAlignment) / (refractiveIndex * refractiveIndex),
|
|
665
|
+
0.02
|
|
666
|
+
));
|
|
667
|
+
vec3 wavelengths = vec3(650.0, 530.0, 460.0);
|
|
668
|
+
vec3 phase = 12.56637061 * glassTransmission.thinFilmThickness *
|
|
669
|
+
refractiveIndex * filmAlignment / wavelengths;
|
|
670
|
+
vec3 spectralInterference = 0.5 + 0.5 * cos(phase);
|
|
671
|
+
float filmPresence = glassTransmission.thinFilmThickness > 0.0 ? 1.0 : 0.0;
|
|
672
|
+
return spectralInterference * pow(1.0 - viewAlignment, 1.45) *
|
|
673
|
+
glassTransmission.thinFilmStrength * filmPresence * 0.18;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
vec4 glassTransmission_getColor(
|
|
677
|
+
vec3 normal,
|
|
678
|
+
vec3 worldPosition,
|
|
679
|
+
vec4 baseColor,
|
|
680
|
+
vec3 cameraPosition,
|
|
681
|
+
vec4 fragmentPosition
|
|
682
|
+
) {
|
|
683
|
+
vec4 surfaceColor = glassMaterial_getColor(
|
|
684
|
+
normal,
|
|
685
|
+
worldPosition,
|
|
686
|
+
baseColor,
|
|
687
|
+
cameraPosition,
|
|
688
|
+
fragmentPosition
|
|
689
|
+
);
|
|
690
|
+
vec3 viewDirection = normalize(cameraPosition - worldPosition);
|
|
691
|
+
vec3 frontNormal = opticalLighting_faceNormal(normalize(normal), viewDirection);
|
|
692
|
+
vec2 screenCoordinate = fragmentPosition.xy / glassTransmission.viewportSize;
|
|
693
|
+
vec4 backface = texture(
|
|
694
|
+
glassBackfaceTexture,
|
|
695
|
+
clamp(screenCoordinate, vec2(0.001), vec2(0.999))
|
|
696
|
+
);
|
|
697
|
+
float frontDepth = glassTransmission_linearizeDepth(fragmentPosition.z);
|
|
698
|
+
float backDepth = glassTransmission_linearizeDepth(backface.a);
|
|
699
|
+
bool hasBackface = backface.a > fragmentPosition.z + 0.00001;
|
|
700
|
+
float measuredThickness = (
|
|
701
|
+
hasBackface
|
|
702
|
+
? clamp(backDepth - frontDepth, 0.04, glassMaterial.thickness * 1.65)
|
|
703
|
+
: glassMaterial.thickness * 0.4
|
|
704
|
+
) * glassTransmission.thicknessStrength;
|
|
705
|
+
vec3 backNormal = hasBackface ? normalize(backface.rgb * 2.0 - 1.0) : -frontNormal;
|
|
706
|
+
float indexOfRefraction = max(glassMaterial.indexOfRefraction, 1.001);
|
|
707
|
+
vec3 entryDirection = refract(
|
|
708
|
+
-viewDirection,
|
|
709
|
+
frontNormal,
|
|
710
|
+
1.0 / indexOfRefraction
|
|
711
|
+
);
|
|
712
|
+
vec3 exitDirection = refract(entryDirection, -backNormal, indexOfRefraction);
|
|
713
|
+
bool hasExitRay = dot(exitDirection, exitDirection) > 0.0001;
|
|
714
|
+
vec3 transmittedDirection = hasExitRay
|
|
715
|
+
? exitDirection
|
|
716
|
+
: reflect(entryDirection, -backNormal);
|
|
717
|
+
vec3 cameraUpAxis = abs(viewDirection.y) > 0.96
|
|
718
|
+
? vec3(0.0, 0.0, 1.0)
|
|
719
|
+
: vec3(0.0, 1.0, 0.0);
|
|
720
|
+
vec3 cameraRight = normalize(cross(cameraUpAxis, viewDirection));
|
|
721
|
+
vec3 cameraUp = normalize(cross(viewDirection, cameraRight));
|
|
722
|
+
float viewportAspect = glassTransmission.viewportSize.x /
|
|
723
|
+
max(glassTransmission.viewportSize.y, 1.0);
|
|
724
|
+
vec3 combinedDeflection = (entryDirection + viewDirection) * 0.68 +
|
|
725
|
+
(transmittedDirection + viewDirection) * 0.32;
|
|
726
|
+
vec2 projectedDeflection = vec2(
|
|
727
|
+
dot(combinedDeflection, cameraRight) / viewportAspect,
|
|
728
|
+
dot(combinedDeflection, cameraUp)
|
|
729
|
+
);
|
|
730
|
+
vec2 projectedNormal = vec2(
|
|
731
|
+
dot(frontNormal, cameraRight) / viewportAspect,
|
|
732
|
+
dot(frontNormal, cameraUp)
|
|
733
|
+
);
|
|
734
|
+
float faultStrength = clamp(
|
|
735
|
+
(baseColor.r - max(baseColor.g, baseColor.b)) * 1.55 - 0.16,
|
|
736
|
+
0.0,
|
|
737
|
+
1.0
|
|
738
|
+
);
|
|
739
|
+
float faultRipple = sin(
|
|
740
|
+
dot(worldPosition.xz, vec2(11.0, 8.0)) +
|
|
741
|
+
glassTransmission.time * 5.5 + measuredThickness * 12.0
|
|
742
|
+
) * faultStrength * glassTransmission.faultDistortionStrength;
|
|
743
|
+
vec2 proposedOffset = projectedDeflection * measuredThickness *
|
|
744
|
+
glassMaterial.refractionStrength * 0.18 + projectedNormal * faultRipple * 0.018;
|
|
745
|
+
vec2 proposedCoordinate = clamp(
|
|
746
|
+
screenCoordinate + proposedOffset,
|
|
747
|
+
vec2(0.001),
|
|
748
|
+
vec2(0.999)
|
|
749
|
+
);
|
|
750
|
+
float sampledDepth = glassTransmission_sampleDepth(proposedCoordinate);
|
|
751
|
+
bool foregroundOcclusion = sampledDepth + glassTransmission.depthBias < fragmentPosition.z;
|
|
752
|
+
vec2 safeOffset = foregroundOcclusion ? vec2(0.0) : proposedOffset;
|
|
753
|
+
float dispersionHalfSpread = (indexOfRefraction - 1.0) * 0.025 *
|
|
754
|
+
max(glassMaterial.dispersion, 0.0);
|
|
755
|
+
float redIndexOfRefraction = max(indexOfRefraction - dispersionHalfSpread, 1.001);
|
|
756
|
+
float blueIndexOfRefraction = indexOfRefraction + dispersionHalfSpread;
|
|
757
|
+
vec3 redEntryDirection = refract(-viewDirection, frontNormal, 1.0 / redIndexOfRefraction);
|
|
758
|
+
vec3 blueEntryDirection = refract(-viewDirection, frontNormal, 1.0 / blueIndexOfRefraction);
|
|
759
|
+
vec3 redExitDirection = refract(redEntryDirection, -backNormal, redIndexOfRefraction);
|
|
760
|
+
vec3 blueExitDirection = refract(blueEntryDirection, -backNormal, blueIndexOfRefraction);
|
|
761
|
+
vec3 redTransmittedDirection = dot(redExitDirection, redExitDirection) > 0.0001
|
|
762
|
+
? redExitDirection
|
|
763
|
+
: reflect(redEntryDirection, -backNormal);
|
|
764
|
+
vec3 blueTransmittedDirection = dot(blueExitDirection, blueExitDirection) > 0.0001
|
|
765
|
+
? blueExitDirection
|
|
766
|
+
: reflect(blueEntryDirection, -backNormal);
|
|
767
|
+
vec3 spectralDeflection = (redEntryDirection - blueEntryDirection) * 0.34 +
|
|
768
|
+
(redTransmittedDirection - blueTransmittedDirection) * 0.16;
|
|
769
|
+
vec2 dispersionOffset = vec2(
|
|
770
|
+
dot(spectralDeflection, cameraRight) / viewportAspect,
|
|
771
|
+
dot(spectralDeflection, cameraUp)
|
|
772
|
+
) * measuredThickness * glassMaterial.refractionStrength * 0.18;
|
|
773
|
+
vec3 transmittedColor = glassTransmission_sampleRoughTransmission(
|
|
774
|
+
screenCoordinate,
|
|
775
|
+
safeOffset,
|
|
776
|
+
dispersionOffset,
|
|
777
|
+
measuredThickness
|
|
778
|
+
);
|
|
779
|
+
vec3 absorption = glassTransmission_getSpectralAbsorption(baseColor.rgb, measuredThickness);
|
|
780
|
+
vec3 reflectionDirection = reflect(-viewDirection, frontNormal);
|
|
781
|
+
vec3 environmentReflection = glassTransmission_sampleEnvironment(reflectionDirection);
|
|
782
|
+
float viewAlignment = clamp(dot(frontNormal, viewDirection), 0.0, 1.0);
|
|
783
|
+
float baseReflectance = pow((indexOfRefraction - 1.0) / (indexOfRefraction + 1.0), 2.0);
|
|
784
|
+
float fresnel = clamp(
|
|
785
|
+
opticalLighting_getFresnel(viewAlignment, baseReflectance, 5.0) *
|
|
786
|
+
glassMaterial.fresnelStrength,
|
|
787
|
+
0.0,
|
|
788
|
+
0.96
|
|
789
|
+
);
|
|
790
|
+
float transmissionWeight = (1.0 - fresnel) *
|
|
791
|
+
clamp(glassMaterial.transmissionStrength, 0.0, 1.0);
|
|
792
|
+
float reflectionWeight = fresnel * glassMaterial.reflectionStrength;
|
|
793
|
+
vec3 internalReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
794
|
+
reflect(entryDirection, -backNormal),
|
|
795
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.13
|
|
796
|
+
) * (hasExitRay ? 0.18 : 0.42);
|
|
797
|
+
vec3 secondaryDirection = reflect(reflect(entryDirection, -backNormal), frontNormal);
|
|
798
|
+
vec3 secondaryReflection = glassTransmission_sampleEnvironmentAtRoughness(
|
|
799
|
+
secondaryDirection,
|
|
800
|
+
glassMaterial.roughness + glassTransmission.environmentPrefilterStrength * 0.25
|
|
801
|
+
) *
|
|
802
|
+
glassTransmission.secondaryBounceStrength * pow(1.0 - viewAlignment, 1.45) * 0.24;
|
|
803
|
+
vec3 thinFilmReflection = glassTransmission_getThinFilm(viewAlignment);
|
|
804
|
+
vec3 volumeScattering = baseColor.rgb * (1.0 - exp(-measuredThickness * 1.3)) *
|
|
805
|
+
glassTransmission.volumeScatteringStrength * (0.045 + (1.0 - viewAlignment) * 0.09);
|
|
806
|
+
vec2 reflectionCoordinate = clamp(
|
|
807
|
+
screenCoordinate + vec2(
|
|
808
|
+
dot(reflectionDirection, cameraRight) / viewportAspect,
|
|
809
|
+
dot(reflectionDirection, cameraUp)
|
|
810
|
+
) * (0.025 + measuredThickness * 0.018),
|
|
811
|
+
vec2(0.001),
|
|
812
|
+
vec2(0.999)
|
|
813
|
+
);
|
|
814
|
+
vec3 reflectedSceneColor = texture(glassSceneColorTexture, reflectionCoordinate).rgb;
|
|
815
|
+
float reflectedSceneLuminance = dot(reflectedSceneColor, vec3(0.2126, 0.7152, 0.0722));
|
|
816
|
+
float reflectedSceneResponse = smoothstep(0.42, 1.4, reflectedSceneLuminance);
|
|
817
|
+
float grazingReflection = pow(1.0 - viewAlignment, 1.7);
|
|
818
|
+
vec3 dynamicReflection = reflectedSceneColor * reflectedSceneResponse *
|
|
819
|
+
glassTransmission.dynamicReflectionStrength * grazingReflection * (0.12 + fresnel * 0.34);
|
|
820
|
+
vec3 faultFilament = baseColor.rgb * faultStrength *
|
|
821
|
+
glassTransmission.faultDistortionStrength *
|
|
822
|
+
pow(max(sin(dot(worldPosition, vec3(14.0, 10.0, 17.0)) +
|
|
823
|
+
glassTransmission.time * 7.0), 0.0), 10.0) * 0.12;
|
|
824
|
+
float contactShadow = glassTransmission_getContactShadow(
|
|
825
|
+
screenCoordinate,
|
|
826
|
+
frontDepth,
|
|
827
|
+
backDepth,
|
|
828
|
+
hasBackface
|
|
829
|
+
);
|
|
830
|
+
vec3 opticalColor = transmittedColor * absorption * transmissionWeight * contactShadow +
|
|
831
|
+
environmentReflection * reflectionWeight +
|
|
832
|
+
internalReflection * pow(1.0 - viewAlignment, 2.0) + secondaryReflection +
|
|
833
|
+
thinFilmReflection + volumeScattering + dynamicReflection + faultFilament;
|
|
834
|
+
return vec4(mix(surfaceColor.rgb, opticalColor, 0.64), surfaceColor.a);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
#ifdef LUMA_OPTICAL_POINT_LIGHTS
|
|
838
|
+
vec4 glassTransmission_getIlluminatedColor(
|
|
839
|
+
vec3 normal,
|
|
840
|
+
vec3 worldPosition,
|
|
841
|
+
vec4 baseColor,
|
|
842
|
+
vec3 cameraPosition,
|
|
843
|
+
vec4 fragmentPosition
|
|
844
|
+
) {
|
|
845
|
+
vec4 transmittedColor = glassTransmission_getColor(
|
|
846
|
+
normal,
|
|
847
|
+
worldPosition,
|
|
848
|
+
baseColor,
|
|
849
|
+
cameraPosition,
|
|
850
|
+
fragmentPosition
|
|
851
|
+
);
|
|
852
|
+
vec3 pointLightColor = opticalPointLights_getColor(normal, worldPosition, cameraPosition);
|
|
853
|
+
vec3 pointLightReflection = opticalPointLights_getSpecularColor(
|
|
854
|
+
normal,
|
|
855
|
+
worldPosition,
|
|
856
|
+
cameraPosition,
|
|
857
|
+
glassMaterial.roughness
|
|
858
|
+
);
|
|
859
|
+
vec3 volumeLightScattering = pointLightColor *
|
|
860
|
+
glassTransmission.volumeScatteringStrength * 0.11;
|
|
861
|
+
return vec4(
|
|
862
|
+
transmittedColor.rgb + pointLightReflection * glassMaterial.reflectionStrength +
|
|
863
|
+
volumeLightScattering,
|
|
864
|
+
transmittedColor.a
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
#endif
|
|
868
|
+
`
|
|
869
|
+
);
|
|
870
|
+
function getGlassTransmissionUniforms(props = {}, previousUniforms) {
|
|
871
|
+
return {
|
|
872
|
+
viewportSize: props.viewportSize ?? (previousUniforms == null ? void 0 : previousUniforms.viewportSize) ?? [1, 1],
|
|
873
|
+
depthRange: props.depthRange ?? (previousUniforms == null ? void 0 : previousUniforms.depthRange) ?? [0.1, 100],
|
|
874
|
+
environmentIntensity: props.environmentIntensity ?? (previousUniforms == null ? void 0 : previousUniforms.environmentIntensity) ?? 1,
|
|
875
|
+
environmentMipLevels: props.environmentMipLevels ?? (previousUniforms == null ? void 0 : previousUniforms.environmentMipLevels) ?? 1,
|
|
876
|
+
environmentPrefilterStrength: props.environmentPrefilterStrength ?? (previousUniforms == null ? void 0 : previousUniforms.environmentPrefilterStrength) ?? 0,
|
|
877
|
+
thicknessStrength: props.thicknessStrength ?? (previousUniforms == null ? void 0 : previousUniforms.thicknessStrength) ?? 1,
|
|
878
|
+
roughTransmissionStrength: props.roughTransmissionStrength ?? (previousUniforms == null ? void 0 : previousUniforms.roughTransmissionStrength) ?? 0,
|
|
879
|
+
spectralAbsorptionStrength: props.spectralAbsorptionStrength ?? (previousUniforms == null ? void 0 : previousUniforms.spectralAbsorptionStrength) ?? 0,
|
|
880
|
+
thinFilmThickness: props.thinFilmThickness ?? (previousUniforms == null ? void 0 : previousUniforms.thinFilmThickness) ?? 0,
|
|
881
|
+
thinFilmStrength: props.thinFilmStrength ?? (previousUniforms == null ? void 0 : previousUniforms.thinFilmStrength) ?? 0,
|
|
882
|
+
volumeScatteringStrength: props.volumeScatteringStrength ?? (previousUniforms == null ? void 0 : previousUniforms.volumeScatteringStrength) ?? 0,
|
|
883
|
+
contactShadowStrength: props.contactShadowStrength ?? (previousUniforms == null ? void 0 : previousUniforms.contactShadowStrength) ?? 0,
|
|
884
|
+
depthBias: props.depthBias ?? (previousUniforms == null ? void 0 : previousUniforms.depthBias) ?? 8e-5,
|
|
885
|
+
dynamicReflectionStrength: props.dynamicReflectionStrength ?? (previousUniforms == null ? void 0 : previousUniforms.dynamicReflectionStrength) ?? 0,
|
|
886
|
+
secondaryBounceStrength: props.secondaryBounceStrength ?? (previousUniforms == null ? void 0 : previousUniforms.secondaryBounceStrength) ?? 0,
|
|
887
|
+
faultDistortionStrength: props.faultDistortionStrength ?? (previousUniforms == null ? void 0 : previousUniforms.faultDistortionStrength) ?? 0,
|
|
888
|
+
time: props.time ?? (previousUniforms == null ? void 0 : previousUniforms.time) ?? 0,
|
|
889
|
+
...props.sceneDepthTexture ? { glassSceneDepthTexture: props.sceneDepthTexture } : {},
|
|
890
|
+
...props.backfaceTexture ? { glassBackfaceTexture: props.backfaceTexture } : {},
|
|
891
|
+
...props.environmentTexture ? { glassEnvironmentTexture: props.environmentTexture } : {}
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
const glassTransmission = {
|
|
895
|
+
name: "glassTransmission",
|
|
896
|
+
source: GLASS_TRANSMISSION_WGSL,
|
|
897
|
+
fs: GLASS_TRANSMISSION_GLSL,
|
|
898
|
+
dependencies: [import_glass_material.glassMaterial],
|
|
899
|
+
bindingLayout: [
|
|
900
|
+
{ name: "glassSceneDepthTexture", group: 0, visibility: SHADER_STAGE_FRAGMENT },
|
|
901
|
+
{ name: "glassBackfaceTexture", group: 0, visibility: SHADER_STAGE_FRAGMENT },
|
|
902
|
+
{ name: "glassBackfaceTextureSampler", group: 0, visibility: SHADER_STAGE_FRAGMENT },
|
|
903
|
+
{ name: "glassEnvironmentTexture", group: 0, visibility: SHADER_STAGE_FRAGMENT },
|
|
904
|
+
{ name: "glassEnvironmentTextureSampler", group: 0, visibility: SHADER_STAGE_FRAGMENT }
|
|
905
|
+
],
|
|
906
|
+
uniformTypes: {
|
|
907
|
+
viewportSize: "vec2<f32>",
|
|
908
|
+
depthRange: "vec2<f32>",
|
|
909
|
+
environmentIntensity: "f32",
|
|
910
|
+
environmentMipLevels: "f32",
|
|
911
|
+
environmentPrefilterStrength: "f32",
|
|
912
|
+
thicknessStrength: "f32",
|
|
913
|
+
roughTransmissionStrength: "f32",
|
|
914
|
+
spectralAbsorptionStrength: "f32",
|
|
915
|
+
thinFilmThickness: "f32",
|
|
916
|
+
thinFilmStrength: "f32",
|
|
917
|
+
volumeScatteringStrength: "f32",
|
|
918
|
+
contactShadowStrength: "f32",
|
|
919
|
+
depthBias: "f32",
|
|
920
|
+
dynamicReflectionStrength: "f32",
|
|
921
|
+
secondaryBounceStrength: "f32",
|
|
922
|
+
faultDistortionStrength: "f32",
|
|
923
|
+
time: "f32"
|
|
924
|
+
},
|
|
925
|
+
defaultUniforms: {
|
|
926
|
+
viewportSize: [1, 1],
|
|
927
|
+
depthRange: [0.1, 100],
|
|
928
|
+
environmentIntensity: 1,
|
|
929
|
+
environmentMipLevels: 1,
|
|
930
|
+
environmentPrefilterStrength: 0,
|
|
931
|
+
thicknessStrength: 1,
|
|
932
|
+
roughTransmissionStrength: 0,
|
|
933
|
+
spectralAbsorptionStrength: 0,
|
|
934
|
+
thinFilmThickness: 0,
|
|
935
|
+
thinFilmStrength: 0,
|
|
936
|
+
volumeScatteringStrength: 0,
|
|
937
|
+
contactShadowStrength: 0,
|
|
938
|
+
depthBias: 8e-5,
|
|
939
|
+
dynamicReflectionStrength: 0,
|
|
940
|
+
secondaryBounceStrength: 0,
|
|
941
|
+
faultDistortionStrength: 0,
|
|
942
|
+
time: 0
|
|
943
|
+
},
|
|
944
|
+
getUniforms: getGlassTransmissionUniforms
|
|
945
|
+
};
|
|
946
|
+
const glassTransmissionPlugin = {
|
|
947
|
+
name: "glassTransmission",
|
|
948
|
+
modules: [glassTransmission]
|
|
949
|
+
};
|
|
950
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
951
|
+
0 && (module.exports = {
|
|
952
|
+
glassTransmission,
|
|
953
|
+
glassTransmissionPlugin
|
|
954
|
+
});
|