@onerjs/core 9.0.1 → 9.0.3
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/Animations/animationGroup.pure.js.map +1 -1
- package/Buffers/buffer.pure.js +4 -0
- package/Buffers/buffer.pure.js.map +1 -1
- package/Cameras/camera.pure.d.ts +14 -0
- package/Cameras/camera.pure.js +15 -0
- package/Cameras/camera.pure.js.map +1 -1
- package/Compute/computeShader.pure.d.ts +2 -1
- package/Compute/computeShader.pure.js +29 -10
- package/Compute/computeShader.pure.js.map +1 -1
- package/Culling/ray.core.js +22 -9
- package/Culling/ray.core.js.map +1 -1
- package/Engines/IDrawContext.d.ts +2 -0
- package/Engines/IDrawContext.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +55 -4
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +1 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +5 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.d.ts +2 -0
- package/Engines/Processors/shaderCodeInliner.js +251 -6
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +10 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js +12 -0
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +0 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +5 -0
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +7 -0
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.js +20 -8
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +2 -0
- package/Engines/WebGPU/webgpuDrawContext.js +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.d.ts +3 -3
- package/Engines/WebGPU/webgpuQuerySet.js +23 -9
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuRenderPassCommandStream.d.ts +156 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js +323 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js.map +1 -0
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -3
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.d.ts +3 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +9 -6
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +14 -5
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +6 -0
- package/Engines/constants.js +6 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +198 -24
- package/Engines/pure.d.ts +1 -0
- package/Engines/pure.js +1 -0
- package/Engines/pure.js.map +1 -1
- package/Engines/renderCommandBatcher.pure.d.ts +16 -0
- package/Engines/renderCommandBatcher.pure.js +24 -0
- package/Engines/renderCommandBatcher.pure.js.map +1 -0
- package/Engines/thinEngine.functions.js +3 -2
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.pure.js +18 -2
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +10 -7
- package/Engines/thinNativeEngine.pure.js +117 -46
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +8 -0
- package/Engines/thinWebGPUEngine.js +11 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +60 -1
- package/Engines/webgpuEngine.pure.js +238 -42
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.d.ts +77 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js +141 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.d.ts +5 -3
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js +38 -7
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/allBlocks.pure.js +2 -0
- package/FlowGraph/Blocks/allBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +12 -1
- package/FlowGraph/flowGraph.js +38 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +44 -0
- package/FlowGraph/flowGraphCoordinator.js +141 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.js +41 -14
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +105 -5
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSoundAssets.d.ts +40 -0
- package/FlowGraph/flowGraphSoundAssets.js +33 -0
- package/FlowGraph/flowGraphSoundAssets.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +1 -0
- package/FlowGraph/pure.js +1 -0
- package/FlowGraph/pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +31 -12
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +25 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js +2 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +1 -0
- package/Instrumentation/engineInstrumentation.js +25 -6
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -0
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +36 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +202 -27
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Lights/directionalLight.pure.d.ts +24 -10
- package/Lights/directionalLight.pure.js +29 -11
- package/Lights/directionalLight.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +4 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.pure.js +4 -0
- package/Materials/Node/Blocks/Input/inputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.d.ts +9 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +23 -3
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +9 -0
- package/Materials/PBR/pbrBaseMaterial.pure.js +60 -1
- package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +11 -0
- package/Materials/PBR/pbrBaseSimpleMaterial.js +21 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.pure.d.ts +12 -0
- package/Materials/PBR/pbrMaterial.pure.js +23 -3
- package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +10 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +5 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +7 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -1
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +9 -3
- package/Materials/Textures/HTML/htmlInteractionManager.js +64 -5
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -1
- package/Materials/Textures/HTML/htmlTexture.d.ts +11 -11
- package/Materials/Textures/HTML/htmlTexture.js +106 -65
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -1
- package/Materials/Textures/Loaders/internalTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/internalTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +4 -50
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +10 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/dynamicTexture.pure.js +6 -0
- package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
- package/Materials/Textures/ktx2encoderTypes.d.ts +51 -0
- package/Materials/Textures/ktx2encoderTypes.js +2 -0
- package/Materials/Textures/ktx2encoderTypes.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.pure.js +10 -2
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/Textures/texture.pure.js +7 -1
- package/Materials/Textures/texture.pure.js.map +1 -1
- package/Materials/Textures/textureMerger.d.ts +11 -0
- package/Materials/Textures/textureMerger.js +34 -19
- package/Materials/Textures/textureMerger.js.map +1 -1
- package/Materials/Textures/textureProcessor.d.ts +145 -0
- package/Materials/Textures/textureProcessor.js +445 -45
- package/Materials/Textures/textureProcessor.js.map +1 -1
- package/Materials/Textures/textureSampling.functions.d.ts +41 -0
- package/Materials/Textures/textureSampling.functions.js +82 -0
- package/Materials/Textures/textureSampling.functions.js.map +1 -0
- package/Materials/drawWrapper.d.ts +8 -0
- package/Materials/drawWrapper.js +19 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.pure.d.ts +6 -0
- package/Materials/effect.pure.js +28 -6
- package/Materials/effect.pure.js.map +1 -1
- package/Materials/effect.webgl.functions.pure.js +1 -1
- package/Materials/effect.webgl.functions.pure.js.map +1 -1
- package/Materials/material.pure.d.ts +5 -0
- package/Materials/material.pure.js +9 -2
- package/Materials/material.pure.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +36 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +19 -16
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/materialPluginManager.pure.js +12 -8
- package/Materials/materialPluginManager.pure.js.map +1 -1
- package/Materials/prePassConfiguration.js +19 -16
- package/Materials/prePassConfiguration.js.map +1 -1
- package/Materials/shaderMaterial.pure.js +19 -6
- package/Materials/shaderMaterial.pure.js.map +1 -1
- package/Materials/shadowDepthWrapper.d.ts +6 -0
- package/Materials/shadowDepthWrapper.js +17 -0
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +14 -0
- package/Meshes/Compression/dracoCodec.js +22 -0
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +1 -0
- package/Meshes/Compression/dracoDecoder.js +27 -0
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.d.ts +1 -0
- package/Meshes/Compression/dracoEncoder.js +8 -0
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.d.ts +1 -0
- package/Meshes/Compression/meshoptCompression.js +9 -0
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.d.ts +415 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js +912 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +40 -9
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +112 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +696 -74
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +12 -4
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/geometry.d.ts +5 -0
- package/Meshes/geometry.js +25 -0
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.pure.d.ts +7 -0
- package/Meshes/mesh.pure.js +18 -13
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Meshes/subMesh.pure.d.ts +3 -0
- package/Meshes/subMesh.pure.js +26 -0
- package/Meshes/subMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +5 -3
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +3 -2
- package/Misc/khronosTextureContainer2.js +24 -6
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Encoder.d.ts +166 -0
- package/Misc/khronosTextureContainer2Encoder.js +556 -0
- package/Misc/khronosTextureContainer2Encoder.js.map +1 -0
- package/Misc/khronosTextureContainer2EncoderWorker.d.ts +61 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js +55 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js.map +1 -0
- package/Misc/pure.d.ts +1 -0
- package/Misc/pure.js +1 -0
- package/Misc/pure.js.map +1 -1
- package/Misc/textureFormat.functions.d.ts +6 -0
- package/Misc/textureFormat.functions.js +54 -0
- package/Misc/textureFormat.functions.js.map +1 -0
- package/Misc/textureTools.d.ts +6 -2
- package/Misc/textureTools.js +100 -42
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.d.ts +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.js +6 -3
- package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
- package/Particles/computeShaderParticleSystem.pure.js +5 -0
- package/Particles/computeShaderParticleSystem.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +25 -1
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/solidParticle.d.ts +5 -0
- package/Particles/solidParticle.js +5 -0
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +10 -0
- package/Particles/solidParticleSystem.js +72 -13
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.pure.js +4 -0
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.d.ts +27 -6
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js +60 -5
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +1 -0
- package/PostProcesses/thinTAAPostProcess.js +17 -1
- package/PostProcesses/thinTAAPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +2 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +6 -5
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -3
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +8 -2
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +1 -0
- package/Rendering/objectRenderer.js +14 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +5 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +7 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrIBLFunctions.js +12 -0
- package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/geometry.vertex.js +6 -6
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/lod.fragment.js +15 -2
- package/Shaders/lod.fragment.js.map +1 -1
- package/Shaders/lod3D.fragment.js +15 -2
- package/Shaders/lod3D.fragment.js.map +1 -1
- package/Shaders/lodCube.fragment.js +15 -2
- package/Shaders/lodCube.fragment.js.map +1 -1
- package/Shaders/openpbr.vertex.js +2 -0
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +12 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/textureMerger.fragment.js +28 -0
- package/Shaders/textureMerger.fragment.js.map +1 -1
- package/Shaders/textureProcessor.fragment.js +26 -4
- package/Shaders/textureProcessor.fragment.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +1 -1
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +44 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +17 -3
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +8 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +2 -2
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +3 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +4 -4
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +1 -1
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/gsSortCount.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortCount.compute.js +19 -0
- package/ShadersWGSL/gsSortCount.compute.js.map +1 -0
- package/ShadersWGSL/gsSortKeys.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortKeys.compute.js +49 -0
- package/ShadersWGSL/gsSortKeys.compute.js.map +1 -0
- package/ShadersWGSL/gsSortOutput.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortOutput.compute.js +28 -0
- package/ShadersWGSL/gsSortOutput.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanLocal.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js +23 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanSums.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanSums.compute.js +19 -0
- package/ShadersWGSL/gsSortScanSums.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScatter.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScatter.compute.js +33 -0
- package/ShadersWGSL/gsSortScatter.compute.js.map +1 -0
- package/ShadersWGSL/lod.fragment.js +14 -2
- package/ShadersWGSL/lod.fragment.js.map +1 -1
- package/ShadersWGSL/lod3D.fragment.js +14 -2
- package/ShadersWGSL/lod3D.fragment.js.map +1 -1
- package/ShadersWGSL/lodCube.fragment.js +14 -2
- package/ShadersWGSL/lodCube.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +3 -1
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +11 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +3 -1
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/textureMerger.fragment.js +40 -4
- package/ShadersWGSL/textureMerger.fragment.js.map +1 -1
- package/ShadersWGSL/textureProcessor.fragment.js +26 -4
- package/ShadersWGSL/textureProcessor.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +15 -5
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -1
- package/scene.pure.js +83 -1
- package/scene.pure.js.map +1 -1
|
@@ -8,6 +8,7 @@ import { DepthReducer } from "../../Misc/depthReducer.js";
|
|
|
8
8
|
import { Logger } from "../../Misc/logger.js";
|
|
9
9
|
import { EngineStore } from "../../Engines/engineStore.js";
|
|
10
10
|
import { FloatingOriginCurrentScene, GetOffsetTransformMatrices } from "../../Materials/floatingOriginMatrixOverrides.js";
|
|
11
|
+
import { UniformBuffer } from "../../Materials/uniformBuffer.js";
|
|
11
12
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
13
|
const UpDir = /*#__PURE__*/ Vector3.Up();
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -15,6 +16,8 @@ const ZeroVec = /*#__PURE__*/ Vector3.Zero();
|
|
|
15
16
|
const Tmpv1 = /*#__PURE__*/ new Vector3();
|
|
16
17
|
const Tmpv2 = /*#__PURE__*/ new Vector3();
|
|
17
18
|
const TmpMatrix = /*#__PURE__*/ new Matrix();
|
|
19
|
+
// The cascades a receiving shader can read (vPositionFromLight{X}_0 to _3): the size of the arrays in the cascades buffer
|
|
20
|
+
const CascadesUboSize = 4;
|
|
18
21
|
/**
|
|
19
22
|
* A CSM implementation allowing casting shadows on large scenes.
|
|
20
23
|
* Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
|
|
@@ -28,6 +31,16 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
28
31
|
Logger.Error('Unsupported filter "' + filter + '"!');
|
|
29
32
|
return ShadowGenerator.FILTER_NONE;
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
|
|
36
|
+
*/
|
|
37
|
+
get penumbraDarkness() {
|
|
38
|
+
return this._penumbraDarkness;
|
|
39
|
+
}
|
|
40
|
+
set penumbraDarkness(value) {
|
|
41
|
+
this._penumbraDarkness = value;
|
|
42
|
+
this._updateCascadesSettings();
|
|
43
|
+
}
|
|
31
44
|
/**
|
|
32
45
|
* Gets or set the number of cascades used by the CSM.
|
|
33
46
|
*/
|
|
@@ -208,6 +221,7 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
208
221
|
set cascadeBlendPercentage(value) {
|
|
209
222
|
this._cascadeBlendPercentage = value;
|
|
210
223
|
this._light._markMeshesAsLightDirty();
|
|
224
|
+
this._updateCascadesSettings();
|
|
211
225
|
}
|
|
212
226
|
/**
|
|
213
227
|
* Gets or set the lambda parameter.
|
|
@@ -530,13 +544,20 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
530
544
|
throw new Error("CascadedShadowMap is not supported by the current engine.");
|
|
531
545
|
}
|
|
532
546
|
super(mapSize, light, usefulFloatFirst, camera, useRedTextureType);
|
|
547
|
+
// WGSL receivers read the cascades from a buffer owned by this generator, one per camera its shadow map renders for, written
|
|
548
|
+
// once each time the cascades are computed: every receiver shares it, and a FAST snapshot replay reads the current values.
|
|
549
|
+
// In floating origin mode the light matrices are also offset by the eye the receivers are rendered for, and a mirror or a
|
|
550
|
+
// reflection probe renders them for another eye than the camera's: each eye gets its own buffer (_getCascadesBufferForEye)
|
|
551
|
+
this._cascadesUbos = null;
|
|
552
|
+
this._cascadesBuffers = null;
|
|
553
|
+
this._cascadesMatrices = new Float32Array(16 * CascadesUboSize);
|
|
533
554
|
// Without comparison samplers, PCF would fall back to Poisson sampling, which CSM does not support.
|
|
534
555
|
if (this._scene.getEngine()._features.supportShadowSamplers) {
|
|
535
556
|
this.usePercentageCloserFiltering = true;
|
|
536
557
|
}
|
|
537
558
|
}
|
|
538
559
|
_initializeGenerator() {
|
|
539
|
-
this.
|
|
560
|
+
this._penumbraDarkness = this._penumbraDarkness ?? 1.0;
|
|
540
561
|
this._numCascades = this._numCascades ?? CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;
|
|
541
562
|
this.stabilizeCascades = this.stabilizeCascades ?? false;
|
|
542
563
|
this._freezeShadowCastersBoundingInfoObservable = this._freezeShadowCastersBoundingInfoObservable ?? null;
|
|
@@ -629,6 +650,9 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
629
650
|
this._splitFrustum();
|
|
630
651
|
}
|
|
631
652
|
this._computeMatrices();
|
|
653
|
+
if (this._cascadesUbos) {
|
|
654
|
+
this._updateCascadesUbo();
|
|
655
|
+
}
|
|
632
656
|
});
|
|
633
657
|
this._splitFrustum();
|
|
634
658
|
}
|
|
@@ -683,40 +707,43 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
683
707
|
return;
|
|
684
708
|
}
|
|
685
709
|
const width = shadowMap.getSize().width;
|
|
686
|
-
|
|
687
|
-
//
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
710
|
+
// WGSL receivers compiled with the cascades buffer (SHADOWCSMUBO{X}, when it fits within the device's uniform buffers
|
|
711
|
+
// per stage); the others get the cascades as effect uniforms
|
|
712
|
+
if (effect.shaderLanguage === 1 /* ShaderLanguage.WGSL */ && effect._uniformBuffersNames["cascades" + lightIndex] !== undefined) {
|
|
713
|
+
if (!this._cascadesBuffers) {
|
|
714
|
+
this._cascadesUbos = this._cascadesUbos || new Map();
|
|
715
|
+
this._updateCascadesUbo();
|
|
716
|
+
}
|
|
717
|
+
const cascades = this._cascadesBuffers;
|
|
718
|
+
const cascadesUbo = (scene.floatingOriginMode ? this._getCascadesBufferForEye(cascades, scene.floatingOriginOffset) : cascades.buffers[0]).ubo;
|
|
719
|
+
cascadesUbo.bindToEffect(effect, "cascades" + lightIndex);
|
|
720
|
+
cascadesUbo.bindUniformBuffer();
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
const transform = this._transformMatricesAsArray;
|
|
724
|
+
// Doing the check for floatingOrigin here to avoid unnecessary matrix operations when offset is 0
|
|
725
|
+
const lightMatrix = scene.floatingOriginMode
|
|
726
|
+
? GetOffsetTransformMatrices(this._scene.floatingOriginOffset, this._viewMatrices, this._projectionMatrices, this._numCascades, this._tempTransformMatricesAsArray)
|
|
727
|
+
: transform;
|
|
728
|
+
effect.setMatrices("lightMatrix" + lightIndex, lightMatrix);
|
|
729
|
+
effect.setArray("viewFrustumZ" + lightIndex, this._viewSpaceFrustumsZ);
|
|
730
|
+
effect.setFloat("cascadeBlendFactor" + lightIndex, this.cascadeBlendPercentage === 0 ? 10000 : 1 / this.cascadeBlendPercentage);
|
|
731
|
+
effect.setArray("frustumLengths" + lightIndex, this._frustumLengths);
|
|
732
|
+
if (this._filter === ShadowGenerator.FILTER_PCSS) {
|
|
733
|
+
this._computePCSSCorrections();
|
|
734
|
+
effect.setArray2("lightSizeUVCorrection" + lightIndex, this._lightSizeUVCorrection);
|
|
735
|
+
effect.setArray("depthCorrection" + lightIndex, this._depthCorrection);
|
|
736
|
+
effect.setFloat("penumbraDarkness" + lightIndex, this.penumbraDarkness);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
695
739
|
// Only PCF uses depth stencil texture.
|
|
696
740
|
if (this._filter === ShadowGenerator.FILTER_PCF) {
|
|
697
741
|
effect.setDepthStencilTexture("shadowTexture" + lightIndex, shadowMap);
|
|
698
742
|
light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), width, 1 / width, this.frustumEdgeFalloff, lightIndex);
|
|
699
743
|
}
|
|
700
744
|
else if (this._filter === ShadowGenerator.FILTER_PCSS) {
|
|
701
|
-
for (let cascadeIndex = 0; cascadeIndex < this._numCascades; ++cascadeIndex) {
|
|
702
|
-
this._lightSizeUVCorrection[cascadeIndex * 2 + 0] =
|
|
703
|
-
cascadeIndex === 0
|
|
704
|
-
? 1
|
|
705
|
-
: (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[cascadeIndex].x - this._cascadeMinExtents[cascadeIndex].x); // x correction
|
|
706
|
-
this._lightSizeUVCorrection[cascadeIndex * 2 + 1] =
|
|
707
|
-
cascadeIndex === 0
|
|
708
|
-
? 1
|
|
709
|
-
: (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[cascadeIndex].y - this._cascadeMinExtents[cascadeIndex].y); // y correction
|
|
710
|
-
this._depthCorrection[cascadeIndex] =
|
|
711
|
-
cascadeIndex === 0
|
|
712
|
-
? 1
|
|
713
|
-
: (this._cascadeMaxExtents[cascadeIndex].z - this._cascadeMinExtents[cascadeIndex].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
|
|
714
|
-
}
|
|
715
745
|
effect.setDepthStencilTexture("shadowTexture" + lightIndex, shadowMap);
|
|
716
746
|
effect.setTexture("depthTexture" + lightIndex, shadowMap);
|
|
717
|
-
effect.setArray2("lightSizeUVCorrection" + lightIndex, this._lightSizeUVCorrection);
|
|
718
|
-
effect.setArray("depthCorrection" + lightIndex, this._depthCorrection);
|
|
719
|
-
effect.setFloat("penumbraDarkness" + lightIndex, this.penumbraDarkness);
|
|
720
747
|
light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / width, this._contactHardeningLightSizeUVRatio * width, this.frustumEdgeFalloff, lightIndex);
|
|
721
748
|
}
|
|
722
749
|
else {
|
|
@@ -725,6 +752,144 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
725
752
|
}
|
|
726
753
|
light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
|
|
727
754
|
}
|
|
755
|
+
_computePCSSCorrections() {
|
|
756
|
+
for (let cascadeIndex = 0; cascadeIndex < this._numCascades; ++cascadeIndex) {
|
|
757
|
+
this._lightSizeUVCorrection[cascadeIndex * 2 + 0] =
|
|
758
|
+
cascadeIndex === 0
|
|
759
|
+
? 1
|
|
760
|
+
: (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[cascadeIndex].x - this._cascadeMinExtents[cascadeIndex].x); // x correction
|
|
761
|
+
this._lightSizeUVCorrection[cascadeIndex * 2 + 1] =
|
|
762
|
+
cascadeIndex === 0
|
|
763
|
+
? 1
|
|
764
|
+
: (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[cascadeIndex].y - this._cascadeMinExtents[cascadeIndex].y); // y correction
|
|
765
|
+
this._depthCorrection[cascadeIndex] =
|
|
766
|
+
cascadeIndex === 0
|
|
767
|
+
? 1
|
|
768
|
+
: (this._cascadeMaxExtents[cascadeIndex].z - this._cascadeMinExtents[cascadeIndex].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Writes the cascades just computed in the buffer of the camera they were computed for, and makes it the one receivers bind
|
|
773
|
+
*/
|
|
774
|
+
_updateCascadesUbo() {
|
|
775
|
+
const scene = this._scene;
|
|
776
|
+
const camera = this._getCamera();
|
|
777
|
+
let cascades = this._cascadesUbos.get(camera);
|
|
778
|
+
if (!cascades) {
|
|
779
|
+
cascades = { buffers: [], computeId: 0, observer: camera ? camera.onDisposeObservable.addOnce(() => this._releaseCascadesUbo(camera)) : null };
|
|
780
|
+
this._cascadesUbos.set(camera, cascades);
|
|
781
|
+
}
|
|
782
|
+
cascades.computeId++;
|
|
783
|
+
if (scene.floatingOriginMode) {
|
|
784
|
+
this._getCascadesBufferForEye(cascades, scene.floatingOriginOffset);
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
this._writeCascades(cascades, cascades.buffers[0] ?? this._createCascadesBuffer(cascades), Vector3.ZeroReadOnly);
|
|
788
|
+
}
|
|
789
|
+
this._cascadesBuffers = cascades;
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* In floating origin mode, the light matrices are offset by the eye the receivers are rendered for, which a mirror or a
|
|
793
|
+
* reflection probe moves (scene._forcedViewPosition). Receivers rendered for the same eye share a buffer. Another eye in the
|
|
794
|
+
* same frame gets another buffer, since the commands of every view run after all the writes of the frame, and a buffer no
|
|
795
|
+
* view bound in this frame is the one rewritten for a new eye.
|
|
796
|
+
* @param cascades the cascades buffers of the camera the cascades were last computed for
|
|
797
|
+
* @param origin the floating origin offset of the eye
|
|
798
|
+
* @returns the buffer holding the last computed cascades for that eye
|
|
799
|
+
*/
|
|
800
|
+
_getCascadesBufferForEye(cascades, origin) {
|
|
801
|
+
const frameId = this._scene.getEngine().frameId;
|
|
802
|
+
let unused = null;
|
|
803
|
+
for (const buffer of cascades.buffers) {
|
|
804
|
+
if (buffer.computeId === cascades.computeId && buffer.origin.equals(origin)) {
|
|
805
|
+
buffer.frameId = frameId;
|
|
806
|
+
return buffer;
|
|
807
|
+
}
|
|
808
|
+
if (!unused && buffer.frameId !== frameId) {
|
|
809
|
+
unused = buffer;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
const buffer = unused ?? this._createCascadesBuffer(cascades);
|
|
813
|
+
this._writeCascades(cascades, buffer, origin);
|
|
814
|
+
return buffer;
|
|
815
|
+
}
|
|
816
|
+
_createCascadesBuffer(cascades) {
|
|
817
|
+
const ubo = new UniformBuffer(this._scene.getEngine(), undefined, false, "CascadedShadowGenerator", false, false);
|
|
818
|
+
ubo.addUniform("viewFrustumZ", 4);
|
|
819
|
+
ubo.addUniform("frustumLengths", 4);
|
|
820
|
+
ubo.addUniform("cascadeBlendFactor", 1);
|
|
821
|
+
ubo.addUniform("penumbraDarkness", 1);
|
|
822
|
+
ubo.addUniform("depthCorrection", 4);
|
|
823
|
+
ubo.addUniform("lightSizeUVCorrection", 2, CascadesUboSize);
|
|
824
|
+
ubo.addUniform("lightMatrix", 16, CascadesUboSize);
|
|
825
|
+
ubo.create();
|
|
826
|
+
const buffer = { ubo, computeId: 0, origin: new Vector3(), frameId: -1 };
|
|
827
|
+
cascades.buffers.push(buffer);
|
|
828
|
+
return buffer;
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Writes the cascades last computed in a buffer, with the light matrices offset by the given floating origin offset
|
|
832
|
+
* @param cascades the cascades buffers the buffer belongs to
|
|
833
|
+
* @param buffer the buffer to write
|
|
834
|
+
* @param origin the floating origin offset of the eye the buffer is for (zero outside of floating origin mode)
|
|
835
|
+
*/
|
|
836
|
+
_writeCascades(cascades, buffer, origin) {
|
|
837
|
+
const ubo = buffer.ubo;
|
|
838
|
+
const z = this._viewSpaceFrustumsZ;
|
|
839
|
+
const lengths = this._frustumLengths;
|
|
840
|
+
this._cascadesMatrices.set(this._scene.floatingOriginMode
|
|
841
|
+
? GetOffsetTransformMatrices(origin, this._viewMatrices, this._projectionMatrices, this._numCascades, this._tempTransformMatricesAsArray)
|
|
842
|
+
: this._transformMatricesAsArray);
|
|
843
|
+
ubo.updateFloat4("viewFrustumZ", z[0] ?? 0, z[1] ?? 0, z[2] ?? 0, z[3] ?? 0);
|
|
844
|
+
ubo.updateFloat4("frustumLengths", lengths[0] ?? 0, lengths[1] ?? 0, lengths[2] ?? 0, lengths[3] ?? 0);
|
|
845
|
+
ubo.updateFloat("cascadeBlendFactor", this._getCascadeBlendFactor());
|
|
846
|
+
// the PCSS values are written whatever the filter, so that switching to PCSS does not wait for the shadow map to render
|
|
847
|
+
this._computePCSSCorrections();
|
|
848
|
+
const depth = this._depthCorrection;
|
|
849
|
+
ubo.updateFloat("penumbraDarkness", this._penumbraDarkness);
|
|
850
|
+
ubo.updateFloat4("depthCorrection", depth[0] ?? 0, depth[1] ?? 0, depth[2] ?? 0, depth[3] ?? 0);
|
|
851
|
+
ubo.updateArray("lightSizeUVCorrection", this._lightSizeUVCorrection);
|
|
852
|
+
ubo.updateMatrices("lightMatrix", this._cascadesMatrices);
|
|
853
|
+
// written outside of any draw: the last receiver bound must not get this buffer bound again
|
|
854
|
+
ubo.unbindEffect();
|
|
855
|
+
ubo.update();
|
|
856
|
+
buffer.computeId = cascades.computeId;
|
|
857
|
+
buffer.origin.copyFrom(origin);
|
|
858
|
+
buffer.frameId = this._scene.getEngine().frameId;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* cascadeBlendPercentage and penumbraDarkness only matter to the receivers, and the shadow map may not render again
|
|
862
|
+
* (refreshRate 0): they are written in the cascades buffers when they change, not for each receiver
|
|
863
|
+
*/
|
|
864
|
+
_updateCascadesSettings() {
|
|
865
|
+
if (!this._cascadesUbos) {
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
for (const cascades of this._cascadesUbos.values()) {
|
|
869
|
+
for (const { ubo } of cascades.buffers) {
|
|
870
|
+
ubo.updateFloat("cascadeBlendFactor", this._getCascadeBlendFactor());
|
|
871
|
+
ubo.updateFloat("penumbraDarkness", this._penumbraDarkness);
|
|
872
|
+
ubo.unbindEffect();
|
|
873
|
+
ubo.update();
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
_getCascadeBlendFactor() {
|
|
878
|
+
return this.cascadeBlendPercentage === 0 ? 10000 : 1 / this.cascadeBlendPercentage;
|
|
879
|
+
}
|
|
880
|
+
_releaseCascadesUbo(camera) {
|
|
881
|
+
const cascades = this._cascadesUbos?.get(camera);
|
|
882
|
+
if (!cascades) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
for (const { ubo } of cascades.buffers) {
|
|
886
|
+
ubo.dispose();
|
|
887
|
+
}
|
|
888
|
+
this._cascadesUbos.delete(camera);
|
|
889
|
+
if (this._cascadesBuffers === cascades) {
|
|
890
|
+
this._cascadesBuffers = null;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
728
893
|
/**
|
|
729
894
|
* Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
|
|
730
895
|
* (eq to view projection * shadow projection matrices)
|
|
@@ -747,6 +912,16 @@ export class CascadedShadowGenerator extends ShadowGenerator {
|
|
|
747
912
|
this._depthReducer.dispose();
|
|
748
913
|
this._depthReducer = null;
|
|
749
914
|
}
|
|
915
|
+
if (this._cascadesUbos) {
|
|
916
|
+
for (const [camera, cascades] of this._cascadesUbos) {
|
|
917
|
+
for (const { ubo } of cascades.buffers) {
|
|
918
|
+
ubo.dispose();
|
|
919
|
+
}
|
|
920
|
+
camera?.onDisposeObservable.remove(cascades.observer);
|
|
921
|
+
}
|
|
922
|
+
this._cascadesUbos = null;
|
|
923
|
+
this._cascadesBuffers = null;
|
|
924
|
+
}
|
|
750
925
|
}
|
|
751
926
|
/**
|
|
752
927
|
* Serializes the shadow generator setup to a json object.
|