@babylonjs/core 7.23.1 → 7.25.0
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/animation.js +3 -3
- package/Animations/animation.js.map +1 -1
- package/Audio/sound.js +15 -7
- package/Audio/sound.js.map +1 -1
- package/Behaviors/Meshes/followBehavior.js +3 -3
- package/Behaviors/Meshes/followBehavior.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +2 -2
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Compute/computeEffect.js +4 -4
- package/Compute/computeEffect.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +2 -3
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/Processors/Expressions/shaderDefineExpression.js +1 -1
- package/Engines/Processors/Expressions/shaderDefineExpression.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +2 -2
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js +2 -2
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +12 -10
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nativeEngine.js +3 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/LensFlares/lensFlareSystem.js +2 -2
- package/LensFlares/lensFlareSystem.js.map +1 -1
- package/Loading/sceneLoader.js +3 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +17 -8
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +1 -2
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/Filtering/hdrFiltering.d.ts +0 -2
- package/Materials/Textures/Filtering/hdrFiltering.js +12 -4
- package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
- package/Materials/Textures/Loaders/textureLoaderManager.d.ts +14 -1
- package/Materials/Textures/Loaders/textureLoaderManager.js +50 -21
- package/Materials/Textures/Loaders/textureLoaderManager.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +15 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +24 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/index.d.ts +6 -0
- package/Materials/Textures/index.js +8 -0
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/texture.js +2 -2
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/effect.functions.js +4 -4
- package/Materials/effect.functions.js.map +1 -1
- package/Maths/math.color.js +6 -7
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.path.js +5 -5
- package/Maths/math.path.js.map +1 -1
- package/Maths/math.scalar.d.ts +33 -191
- package/Maths/math.scalar.functions.d.ts +147 -0
- package/Maths/math.scalar.functions.js +247 -0
- package/Maths/math.scalar.functions.js.map +1 -1
- package/Maths/math.scalar.js +15 -303
- package/Maths/math.scalar.js.map +1 -1
- package/Meshes/Builders/decalBuilder.js +3 -3
- package/Meshes/Builders/decalBuilder.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +8 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +30 -13
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +2 -2
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +4 -4
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.js +3 -3
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- package/Meshes/geodesicMesh.js +3 -3
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/trailMesh.js +4 -4
- package/Meshes/trailMesh.js.map +1 -1
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +7 -7
- package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js +2 -1
- package/Misc/PerformanceViewer/performanceViewerCollector.js.map +1 -1
- package/Misc/basis.js +2 -3
- package/Misc/basis.js.map +1 -1
- package/Misc/dds.js +9 -9
- package/Misc/dds.js.map +1 -1
- package/Misc/dumpTools.js +2 -2
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/environmentTextureTools.js +4 -4
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/reflector.js +3 -3
- package/Misc/reflector.js.map +1 -1
- package/Misc/screenshotTools.d.ts +2 -1
- package/Misc/screenshotTools.js +3 -2
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/tools.d.ts +6 -3
- package/Misc/tools.js +5 -3
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +10 -10
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js +9 -9
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js +7 -7
- package/Particles/EmitterTypes/hemisphericParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/meshParticleEmitter.js +4 -4
- package/Particles/EmitterTypes/meshParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/pointParticleEmitter.js +4 -4
- package/Particles/EmitterTypes/pointParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +10 -10
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/gpuParticleSystem.js +2 -2
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/pointsCloudSystem.js +8 -8
- package/Particles/pointsCloudSystem.js.map +1 -1
- package/Physics/v1/Plugins/ammoJSPlugin.js +2 -2
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/v2/physicsAggregate.js +2 -2
- package/Physics/v2/physicsAggregate.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +4 -4
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js +2 -2
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.d.ts +4 -0
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js +6 -0
- package/PostProcesses/RenderPipeline/postProcessRenderPipeline.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +4 -0
- package/PostProcesses/postProcess.js +1 -0
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +46 -3
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.d.ts +0 -5
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js +33 -5
- package/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +8 -3
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +56 -18
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +20 -2
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +2 -14
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +108 -36
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +0 -2
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +23 -11
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +7 -3
- package/Rendering/depthPeelingRenderer.js +38 -3
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/index.d.ts +44 -0
- package/Rendering/index.js +46 -0
- package/Rendering/index.js.map +1 -1
- package/Shaders/iblCombineVoxelGrids.fragment.d.ts +5 -0
- package/Shaders/{combineVoxelGrids.fragment.js → iblCombineVoxelGrids.fragment.js} +3 -3
- package/Shaders/iblCombineVoxelGrids.fragment.js.map +1 -0
- package/Shaders/iblGenerateVoxelMip.fragment.d.ts +5 -0
- package/Shaders/{generateVoxelMip.fragment.js → iblGenerateVoxelMip.fragment.js} +3 -3
- package/Shaders/iblGenerateVoxelMip.fragment.js.map +1 -0
- package/Shaders/iblShadowVoxelTracing.fragment.js +18 -10
- package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js +2 -1
- package/Shaders/iblShadowsImportanceSamplingDebug.fragment.js.map +1 -1
- package/Shaders/{voxelGrid.fragment.d.ts → iblVoxelGrid.fragment.d.ts} +1 -1
- package/Shaders/{voxelGrid.fragment.js → iblVoxelGrid.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid.fragment.js.map +1 -0
- package/Shaders/{voxelSlabDebug.fragment.d.ts → iblVoxelGrid.vertex.d.ts} +1 -1
- package/Shaders/{voxelGrid.vertex.js → iblVoxelGrid.vertex.js} +8 -4
- package/Shaders/iblVoxelGrid.vertex.js.map +1 -0
- package/Shaders/iblVoxelGrid2dArrayDebug.fragment.d.ts +5 -0
- package/Shaders/{voxelGrid2dArrayDebug.fragment.js → iblVoxelGrid2dArrayDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid2dArrayDebug.fragment.js.map +1 -0
- package/Shaders/iblVoxelGrid3dDebug.fragment.d.ts +5 -0
- package/Shaders/{voxelGrid3dDebug.fragment.js → iblVoxelGrid3dDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelGrid3dDebug.fragment.js.map +1 -0
- package/Shaders/{combineVoxelGrids.fragment.d.ts → iblVoxelSlabDebug.fragment.d.ts} +1 -1
- package/Shaders/{voxelSlabDebug.fragment.js → iblVoxelSlabDebug.fragment.js} +3 -3
- package/Shaders/iblVoxelSlabDebug.fragment.js.map +1 -0
- package/Shaders/iblVoxelSlabDebug.vertex.d.ts +5 -0
- package/Shaders/{voxelSlabDebug.vertex.js → iblVoxelSlabDebug.vertex.js} +3 -3
- package/Shaders/iblVoxelSlabDebug.vertex.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +7 -7
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.d.ts +5 -0
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.js +10 -0
- package/ShadersWGSL/copyTexture3DLayerToTexture.fragment.js.map +1 -0
- package/ShadersWGSL/default.fragment.js +4 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/hdrFiltering.fragment.d.ts +9 -0
- package/ShadersWGSL/hdrFiltering.fragment.js +18 -0
- package/ShadersWGSL/hdrFiltering.fragment.js.map +1 -0
- package/ShadersWGSL/hdrFiltering.vertex.d.ts +5 -0
- package/ShadersWGSL/hdrFiltering.vertex.js +16 -0
- package/ShadersWGSL/hdrFiltering.vertex.js.map +1 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.d.ts +5 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js +10 -0
- package/ShadersWGSL/iblCombineVoxelGrids.fragment.js.map +1 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.d.ts +5 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.js +26 -0
- package/ShadersWGSL/iblGenerateVoxelMip.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.js +24 -0
- package/ShadersWGSL/iblShadowAccumulation.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowDebug.fragment.js +16 -0
- package/ShadersWGSL/iblShadowDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js +17 -0
- package/ShadersWGSL/iblShadowGBufferDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js +20 -0
- package/ShadersWGSL/iblShadowSpatialBlur.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +163 -0
- package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.js +12 -0
- package/ShadersWGSL/iblShadowsCdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.js +33 -0
- package/ShadersWGSL/iblShadowsCdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.js +10 -0
- package/ShadersWGSL/iblShadowsCombine.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js +18 -0
- package/ShadersWGSL/iblShadowsIcdfx.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js +17 -0
- package/ShadersWGSL/iblShadowsIcdfy.fragment.js.map +1 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js +41 -0
- package/ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js.map +1 -0
- package/{Shaders/voxelGrid3dDebug.fragment.d.ts → ShadersWGSL/iblVoxelGrid.fragment.d.ts} +1 -1
- package/ShadersWGSL/iblVoxelGrid.fragment.js +15 -0
- package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js +14 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.js +10 -0
- package/ShadersWGSL/iblVoxelGrid2dArrayDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js +22 -0
- package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.d.ts +5 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js +12 -0
- package/ShadersWGSL/iblVoxelSlabDebug.fragment.js.map +1 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.d.ts +5 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +10 -0
- package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +1 -0
- package/{Shaders/generateVoxelMip.fragment.d.ts → ShadersWGSL/oitBackBlend.fragment.d.ts} +1 -1
- package/ShadersWGSL/oitBackBlend.fragment.js +11 -0
- package/ShadersWGSL/oitBackBlend.fragment.js.map +1 -0
- package/{Shaders/voxelGrid.vertex.d.ts → ShadersWGSL/oitFinal.fragment.d.ts} +1 -1
- package/ShadersWGSL/oitFinal.fragment.js +14 -0
- package/ShadersWGSL/oitFinal.fragment.js.map +1 -0
- package/ShadersWGSL/pbr.fragment.js +17 -8
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/{Shaders/voxelSlabDebug.vertex.d.ts → ShadersWGSL/procedural.vertex.d.ts} +1 -1
- package/ShadersWGSL/procedural.vertex.js +16 -0
- package/ShadersWGSL/procedural.vertex.js.map +1 -0
- package/XR/features/WebXRHandTracking.d.ts +5 -0
- package/XR/features/WebXRHandTracking.js +34 -12
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +2 -2
- package/Shaders/combineVoxelGrids.fragment.js.map +0 -1
- package/Shaders/generateVoxelMip.fragment.js.map +0 -1
- package/Shaders/voxelGrid.fragment.js.map +0 -1
- package/Shaders/voxelGrid.vertex.js.map +0 -1
- package/Shaders/voxelGrid2dArrayDebug.fragment.d.ts +0 -5
- package/Shaders/voxelGrid2dArrayDebug.fragment.js.map +0 -1
- package/Shaders/voxelGrid3dDebug.fragment.js.map +0 -1
- package/Shaders/voxelSlabDebug.fragment.js.map +0 -1
- package/Shaders/voxelSlabDebug.vertex.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblShadowsAccumulationPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsAccumulationPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,8CAA8C,CAAC;AACtD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAGnF;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAYpC;;;OAGG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;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,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE;YAC7C,IAAI,CAAC,mBAAmB;YACxB,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE;YAC9C,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;YACxB,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CACvD,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;SAC/B;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Vector4 } from \"../../Maths/math.vector\";\r\nimport \"../../Shaders/iblShadowAccumulation.fragment\";\r\nimport \"../../Shaders/iblShadowDebug.fragment\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport type { Effect } from \"../../Materials/effect\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetCreationOptions } from \"../../Materials/Textures/textureCreationOptions\";\r\n\r\n/**\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsAccumulationPass {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n // First, render the accumulation pass with both position buffers, motion buffer, shadow buffer, and the previous accumulation buffer\r\n private _outputPP: PostProcess;\r\n private _oldAccumulationRT: RenderTargetTexture;\r\n private _oldLocalPositionRT: RenderTargetTexture;\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n\r\n /**\r\n * Gets the pass post process\r\n * @returns The post process\r\n */\r\n public getPassPP(): PostProcess {\r\n return this._outputPP;\r\n }\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPassPP) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPassPP;\r\n }\r\n\r\n private _debugPassName: string = \"Shadow Accumulation Debug Pass\";\r\n\r\n /**\r\n * Gets the name of the debug pass\r\n * @returns The name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * A value that controls how much of the previous frame's accumulation to keep.\r\n * The higher the value, the faster the shadows accumulate but the more potential ghosting you'll see.\r\n */\r\n public get remenance(): number {\r\n return this._remenance;\r\n }\r\n\r\n /**\r\n * A value that controls how much of the previous frame's accumulation to keep.\r\n * The higher the value, the faster the shadows accumulate but the more potential ghosting you'll see.\r\n */\r\n public set remenance(value: number) {\r\n this._remenance = value;\r\n }\r\n private _remenance: number = 0.9;\r\n\r\n /**\r\n * Reset the accumulation.\r\n */\r\n public get reset(): boolean {\r\n return this._reset;\r\n }\r\n /**\r\n * Reset the accumulation.\r\n */\r\n public set reset(value: boolean) {\r\n this._reset = value;\r\n }\r\n private _reset: boolean = true;\r\n private _debugPassPP: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n if (!this._debugPassPP) {\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"debugSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n };\r\n this._debugPassPP = new PostProcess(this.debugPassName, \"iblShadowDebug\", debugOptions);\r\n this._debugPassPP.autoClear = false;\r\n this._debugPassPP.onApplyObservable.add((effect) => {\r\n // update the caustic texture with what we just rendered.\r\n effect.setTextureFromPostProcessOutput(\"debugSampler\", this._outputPP);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates the accumulation pass\r\n * @param scene Scene to attach to\r\n * @returns The accumulation pass\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._createTextures();\r\n }\r\n\r\n private _createTextures() {\r\n // Create the local position texture for the previous frame.\r\n // We'll copy the previous local position texture to this texture at the start of every frame.\r\n const localPositionOptions: RenderTargetCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n };\r\n\r\n this._oldLocalPositionRT = new RenderTargetTexture(\r\n \"oldLocalPositionRT\",\r\n { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() },\r\n this._scene,\r\n localPositionOptions\r\n );\r\n\r\n const localPositionCopyOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine: this._engine,\r\n reusable: false,\r\n defines: \"#define PASS_SAMPLER sampler\",\r\n };\r\n const localPositionCopyPP = new PostProcess(\"Copy Local Position Texture\", \"pass\", localPositionCopyOptions);\r\n localPositionCopyPP.autoClear = false;\r\n localPositionCopyPP.onApplyObservable.add((effect) => {\r\n const prePassRenderer = this._scene!.prePassRenderer;\r\n const index = prePassRenderer!.getIndex(Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE);\r\n if (index >= 0) effect.setTexture(\"textureSampler\", prePassRenderer!.getRenderTarget().textures[index]);\r\n });\r\n this._oldLocalPositionRT.addPostProcess(localPositionCopyPP);\r\n this._oldLocalPositionRT.skipInitialClear = true;\r\n this._oldLocalPositionRT.noPrePassRenderer = true;\r\n\r\n this._scene.customRenderTargets.push(this._oldLocalPositionRT);\r\n\r\n // Create the accumulation texture for the previous frame.\r\n // We'll copy the output of the accumulation pass to this texture at the start of every frame.\r\n const accumulationOptions: RenderTargetCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RG,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n this._oldAccumulationRT = new RenderTargetTexture(\r\n \"oldAccumulationRT\",\r\n { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() },\r\n this._scene,\r\n accumulationOptions\r\n );\r\n const accumulationCopyOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine: this._engine,\r\n reusable: false,\r\n defines: \"#define PASS_SAMPLER sampler\",\r\n };\r\n const accumulationCopyPP = new PostProcess(\"Copy Accumulation Texture\", \"pass\", accumulationCopyOptions);\r\n accumulationCopyPP.autoClear = false;\r\n accumulationCopyPP.onApplyObservable.add((effect) => {\r\n effect.setTextureFromPostProcessOutput(\"textureSampler\", this._outputPP);\r\n });\r\n this._oldAccumulationRT.addPostProcess(accumulationCopyPP);\r\n this._oldAccumulationRT.skipInitialClear = true;\r\n this._oldAccumulationRT.noPrePassRenderer = true;\r\n this._scene.customRenderTargets.push(this._oldAccumulationRT);\r\n\r\n // Now, create the accumulation pass\r\n const ppOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"accumulationParameters\"],\r\n samplers: [\"oldAccumulationSampler\", \"prevLocalPositionSampler\", \"localPositionSampler\", \"motionSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n };\r\n this._outputPP = new PostProcess(\"accumulationPassPP\", \"iblShadowAccumulation\", ppOptions);\r\n this._outputPP.autoClear = false;\r\n this._outputPP.onApplyObservable.add((effect) => {\r\n this._updatePostProcess(effect);\r\n });\r\n }\r\n\r\n public _updatePostProcess(effect: Effect) {\r\n effect.setVector4(\"accumulationParameters\", new Vector4(this.remenance, this.reset ? 1.0 : 0.0, 0.0, 0.0));\r\n effect.setTexture(\"oldAccumulationSampler\", this._oldAccumulationRT);\r\n effect.setTexture(\"prevLocalPositionSampler\", this._oldLocalPositionRT);\r\n\r\n const prePassRenderer = this._scene.prePassRenderer;\r\n if (prePassRenderer) {\r\n const localPositionIndex = prePassRenderer.getIndex(Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE);\r\n if (localPositionIndex >= 0) effect.setTexture(\"localPositionSampler\", prePassRenderer.getRenderTarget().textures[localPositionIndex]);\r\n const velocityIndex = prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE);\r\n if (velocityIndex >= 0) effect.setTexture(\"motionSampler\", prePassRenderer.getRenderTarget().textures[velocityIndex]);\r\n }\r\n\r\n this.reset = false;\r\n }\r\n\r\n /** Called by render pipeline when canvas resized. */\r\n public resize() {\r\n this._oldAccumulationRT.resize({ width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() });\r\n this._oldLocalPositionRT.resize({ width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() });\r\n }\r\n\r\n private _disposeTextures() {\r\n this._oldAccumulationRT.dispose();\r\n this._oldLocalPositionRT.dispose();\r\n }\r\n\r\n /**\r\n * Checks if the pass is ready\r\n * @returns true if the pass is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._oldAccumulationRT &&\r\n this._oldAccumulationRT.isReadyForRendering() &&\r\n this._oldLocalPositionRT &&\r\n this._oldLocalPositionRT.isReadyForRendering() &&\r\n this._outputPP.isReady() &&\r\n !(this._debugPassPP && !this._debugPassPP.isReady())\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._outputPP.dispose();\r\n if (this._debugPassPP) {\r\n this._debugPassPP.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iblShadowsAccumulationPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsAccumulationPass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAInF;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAYpC;;;OAGG;IACI,SAAS;QACZ,OAAO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AC;SACzH;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED,qDAAqD;IAC9C,MAAM;QACT,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QACjH,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IACtH,CAAC;IAEO,gBAAgB;QACpB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,kBAAkB;YACvB,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,EAAE;YAC7C,IAAI,CAAC,mBAAmB;YACxB,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,EAAE;YAC9C,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;YACxB,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,CACvD,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;SAC/B;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Vector4 } from \"../../Maths/math.vector\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport type { Effect } from \"../../Materials/effect\";\r\nimport { RenderTargetTexture } from \"../../Materials/Textures/renderTargetTexture\";\r\nimport type { RenderTargetCreationOptions } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsAccumulationPass {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n // First, render the accumulation pass with both position buffers, motion buffer, shadow buffer, and the previous accumulation buffer\r\n private _outputPP: PostProcess;\r\n private _oldAccumulationRT: RenderTargetTexture;\r\n private _oldLocalPositionRT: RenderTargetTexture;\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n\r\n /**\r\n * Gets the pass post process\r\n * @returns The post process\r\n */\r\n public getPassPP(): PostProcess {\r\n return this._outputPP;\r\n }\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPassPP) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPassPP;\r\n }\r\n\r\n private _debugPassName: string = \"Shadow Accumulation Debug Pass\";\r\n\r\n /**\r\n * Gets the name of the debug pass\r\n * @returns The name of the debug pass\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n\r\n /**\r\n * A value that controls how much of the previous frame's accumulation to keep.\r\n * The higher the value, the faster the shadows accumulate but the more potential ghosting you'll see.\r\n */\r\n public get remenance(): number {\r\n return this._remenance;\r\n }\r\n\r\n /**\r\n * A value that controls how much of the previous frame's accumulation to keep.\r\n * The higher the value, the faster the shadows accumulate but the more potential ghosting you'll see.\r\n */\r\n public set remenance(value: number) {\r\n this._remenance = value;\r\n }\r\n private _remenance: number = 0.9;\r\n\r\n /**\r\n * Reset the accumulation.\r\n */\r\n public get reset(): boolean {\r\n return this._reset;\r\n }\r\n /**\r\n * Reset the accumulation.\r\n */\r\n public set reset(value: boolean) {\r\n this._reset = value;\r\n }\r\n private _reset: boolean = true;\r\n private _debugPassPP: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * Creates the debug post process effect for this pass\r\n */\r\n private _createDebugPass() {\r\n if (!this._debugPassPP) {\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"debugSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblShadowDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPassPP = new PostProcess(this.debugPassName, \"iblShadowDebug\", debugOptions);\r\n this._debugPassPP.autoClear = false;\r\n this._debugPassPP.onApplyObservable.add((effect) => {\r\n // update the caustic texture with what we just rendered.\r\n effect.setTextureFromPostProcessOutput(\"debugSampler\", this._outputPP);\r\n effect.setVector4(\"sizeParams\", this._debugSizeParams);\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Instantiates the accumulation pass\r\n * @param scene Scene to attach to\r\n * @returns The accumulation pass\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._createTextures();\r\n }\r\n\r\n private _createTextures() {\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create the local position texture for the previous frame.\r\n // We'll copy the previous local position texture to this texture at the start of every frame.\r\n const localPositionOptions: RenderTargetCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\r\n };\r\n\r\n this._oldLocalPositionRT = new RenderTargetTexture(\r\n \"oldLocalPositionRT\",\r\n { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() },\r\n this._scene,\r\n localPositionOptions\r\n );\r\n\r\n const localPositionCopyOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RGBA,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine: this._engine,\r\n reusable: false,\r\n defines: \"#define PASS_SAMPLER sampler\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/pass.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/pass.fragment\"));\r\n }\r\n },\r\n };\r\n const localPositionCopyPP = new PostProcess(\"Copy Local Position Texture\", \"pass\", localPositionCopyOptions);\r\n localPositionCopyPP.autoClear = false;\r\n localPositionCopyPP.onApplyObservable.add((effect) => {\r\n const prePassRenderer = this._scene!.prePassRenderer;\r\n const index = prePassRenderer!.getIndex(Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE);\r\n if (index >= 0) effect.setTexture(\"textureSampler\", prePassRenderer!.getRenderTarget().textures[index]);\r\n });\r\n this._oldLocalPositionRT.addPostProcess(localPositionCopyPP);\r\n this._oldLocalPositionRT.skipInitialClear = true;\r\n this._oldLocalPositionRT.noPrePassRenderer = true;\r\n\r\n this._scene.customRenderTargets.push(this._oldLocalPositionRT);\r\n\r\n // Create the accumulation texture for the previous frame.\r\n // We'll copy the output of the accumulation pass to this texture at the start of every frame.\r\n const accumulationOptions: RenderTargetCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_RG,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n\r\n this._oldAccumulationRT = new RenderTargetTexture(\r\n \"oldAccumulationRT\",\r\n { width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() },\r\n this._scene,\r\n accumulationOptions\r\n );\r\n const accumulationCopyOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n engine: this._engine,\r\n reusable: false,\r\n defines: \"#define PASS_SAMPLER sampler\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/pass.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/pass.fragment\"));\r\n }\r\n },\r\n };\r\n const accumulationCopyPP = new PostProcess(\"Copy Accumulation Texture\", \"pass\", accumulationCopyOptions);\r\n accumulationCopyPP.autoClear = false;\r\n accumulationCopyPP.onApplyObservable.add((effect) => {\r\n if (this._outputPP._outputTexture?.texture) {\r\n effect.setTextureFromPostProcessOutput(\"textureSampler\", this._outputPP);\r\n } else {\r\n // We must set a texture. It's not the right one, but we must set something before the right one is available (see above), probably on next frame.\r\n effect._bindTexture(\"textureSampler\", this._outputPP.inputTexture.texture);\r\n }\r\n });\r\n this._oldAccumulationRT.addPostProcess(accumulationCopyPP);\r\n this._oldAccumulationRT.skipInitialClear = true;\r\n this._oldAccumulationRT.noPrePassRenderer = true;\r\n this._scene.customRenderTargets.push(this._oldAccumulationRT);\r\n\r\n // Now, create the accumulation pass\r\n const ppOptions: PostProcessOptions = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n textureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n uniforms: [\"accumulationParameters\"],\r\n samplers: [\"oldAccumulationSampler\", \"prevLocalPositionSampler\", \"localPositionSampler\", \"motionSampler\"],\r\n engine: this._engine,\r\n reusable: false,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblShadowAccumulation.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowAccumulation.fragment\"));\r\n }\r\n },\r\n };\r\n this._outputPP = new PostProcess(\"accumulationPassPP\", \"iblShadowAccumulation\", ppOptions);\r\n this._outputPP.autoClear = false;\r\n this._outputPP.resize(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // make sure that _outputPP.inputTexture.texture is created right away\r\n this._outputPP.onApplyObservable.add((effect) => {\r\n this._updatePostProcess(effect);\r\n });\r\n }\r\n\r\n public _updatePostProcess(effect: Effect) {\r\n effect.setVector4(\"accumulationParameters\", new Vector4(this.remenance, this.reset ? 1.0 : 0.0, 0.0, 0.0));\r\n effect.setTexture(\"oldAccumulationSampler\", this._oldAccumulationRT);\r\n effect.setTexture(\"prevLocalPositionSampler\", this._oldLocalPositionRT);\r\n\r\n const prePassRenderer = this._scene.prePassRenderer;\r\n if (prePassRenderer) {\r\n const localPositionIndex = prePassRenderer.getIndex(Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE);\r\n if (localPositionIndex >= 0) effect.setTexture(\"localPositionSampler\", prePassRenderer.getRenderTarget().textures[localPositionIndex]);\r\n const velocityIndex = prePassRenderer.getIndex(Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE);\r\n if (velocityIndex >= 0) effect.setTexture(\"motionSampler\", prePassRenderer.getRenderTarget().textures[velocityIndex]);\r\n }\r\n\r\n this.reset = false;\r\n }\r\n\r\n /** Called by render pipeline when canvas resized. */\r\n public resize() {\r\n this._oldAccumulationRT.resize({ width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() });\r\n this._oldLocalPositionRT.resize({ width: this._engine.getRenderWidth(), height: this._engine.getRenderHeight() });\r\n }\r\n\r\n private _disposeTextures() {\r\n this._oldAccumulationRT.dispose();\r\n this._oldLocalPositionRT.dispose();\r\n }\r\n\r\n /**\r\n * Checks if the pass is ready\r\n * @returns true if the pass is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._oldAccumulationRT &&\r\n this._oldAccumulationRT.isReadyForRendering() &&\r\n this._oldLocalPositionRT &&\r\n this._oldLocalPositionRT.isReadyForRendering() &&\r\n this._outputPP.isReady() &&\r\n !(this._debugPassPP && !this._debugPassPP.isReady())\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._outputPP.dispose();\r\n if (this._debugPassPP) {\r\n this._debugPassPP.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Scene } from "../../scene";
|
|
2
2
|
import { ProceduralTexture } from "../../Materials/Textures/Procedurals/proceduralTexture";
|
|
3
|
-
import "../../Shaders/iblShadowsImportanceSamplingDebug.fragment";
|
|
4
|
-
import "../../Shaders/iblShadowsCdfx.fragment";
|
|
5
|
-
import "../../Shaders/iblShadowsIcdfx.fragment";
|
|
6
|
-
import "../../Shaders/iblShadowsCdfy.fragment";
|
|
7
|
-
import "../../Shaders/iblShadowsIcdfy.fragment";
|
|
8
3
|
import { PostProcess } from "../../PostProcesses/postProcess";
|
|
9
4
|
import type { BaseTexture } from "../../Materials/Textures/baseTexture";
|
|
10
5
|
import { Observable } from "../../Misc/observable";
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Texture } from "../../Materials/Textures/texture.js";
|
|
3
3
|
import { ProceduralTexture } from "../../Materials/Textures/Procedurals/proceduralTexture.js";
|
|
4
|
-
import "../../Shaders/iblShadowsImportanceSamplingDebug.fragment.js";
|
|
5
|
-
import "../../Shaders/iblShadowsCdfx.fragment.js";
|
|
6
|
-
import "../../Shaders/iblShadowsIcdfx.fragment.js";
|
|
7
|
-
import "../../Shaders/iblShadowsCdfy.fragment.js";
|
|
8
|
-
import "../../Shaders/iblShadowsIcdfy.fragment.js";
|
|
9
4
|
import { PostProcess } from "../../PostProcesses/postProcess.js";
|
|
10
5
|
import { Vector4 } from "../../Maths/math.vector.js";
|
|
11
6
|
import { RawTexture } from "../../Materials/Textures/rawTexture.js";
|
|
@@ -130,6 +125,7 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
130
125
|
size.width *= 4;
|
|
131
126
|
size.height *= 2;
|
|
132
127
|
}
|
|
128
|
+
const isWebGPU = this._engine.isWebGPU;
|
|
133
129
|
// Create CDF maps (Cumulative Distribution Function) to assist in importance sampling
|
|
134
130
|
const cdfOptions = {
|
|
135
131
|
generateDepthBuffer: false,
|
|
@@ -137,6 +133,15 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
137
133
|
format: 6,
|
|
138
134
|
type: 1,
|
|
139
135
|
samplingMode: 1,
|
|
136
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
137
|
+
extraInitializationsAsync: async () => {
|
|
138
|
+
if (isWebGPU) {
|
|
139
|
+
await Promise.all([import("../../ShadersWGSL/iblShadowsCdfx.fragment.js"), import("../../ShadersWGSL/iblShadowsCdfy.fragment.js")]);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
await Promise.all([import("../../Shaders/iblShadowsCdfx.fragment.js"), import("../../Shaders/iblShadowsCdfy.fragment.js")]);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
140
145
|
};
|
|
141
146
|
const icdfOptions = {
|
|
142
147
|
generateDepthBuffer: false,
|
|
@@ -144,6 +149,15 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
144
149
|
format: 6,
|
|
145
150
|
type: 2,
|
|
146
151
|
samplingMode: 1,
|
|
152
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
153
|
+
extraInitializationsAsync: async () => {
|
|
154
|
+
if (isWebGPU) {
|
|
155
|
+
await Promise.all([import("../../ShadersWGSL/iblShadowsIcdfx.fragment.js"), import("../../ShadersWGSL/iblShadowsIcdfy.fragment.js")]);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
await Promise.all([import("../../Shaders/iblShadowsIcdfx.fragment.js"), import("../../Shaders/iblShadowsIcdfy.fragment.js")]);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
147
161
|
};
|
|
148
162
|
this._cdfyPT = new ProceduralTexture("cdfyTexture", { width: size.width, height: size.height + 1 }, "iblShadowsCdfy", this._scene, cdfOptions, false, false);
|
|
149
163
|
this._cdfyPT.autoClear = false;
|
|
@@ -177,6 +191,7 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
177
191
|
if (this._debugPass) {
|
|
178
192
|
this._debugPass.dispose();
|
|
179
193
|
}
|
|
194
|
+
const isWebGPU = this._engine.isWebGPU;
|
|
180
195
|
const debugOptions = {
|
|
181
196
|
width: this._scene.getEngine().getRenderWidth(),
|
|
182
197
|
height: this._scene.getEngine().getRenderHeight(),
|
|
@@ -186,6 +201,15 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
186
201
|
uniforms: ["sizeParams"],
|
|
187
202
|
samplers: ["cdfy", "icdfy", "cdfx", "icdfx", "iblSource"],
|
|
188
203
|
defines: this._iblSource?.isCube ? "#define IBL_USE_CUBE_MAP\n" : "",
|
|
204
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
205
|
+
extraInitializations: (useWebGPU, list) => {
|
|
206
|
+
if (useWebGPU) {
|
|
207
|
+
list.push(import("../../ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment.js"));
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
list.push(import("../../Shaders/iblShadowsImportanceSamplingDebug.fragment.js"));
|
|
211
|
+
}
|
|
212
|
+
},
|
|
189
213
|
};
|
|
190
214
|
this._debugPass = new PostProcess(this._debugPassName, "iblShadowsImportanceSamplingDebug", debugOptions);
|
|
191
215
|
const debugEffect = this._debugPass.getEffect();
|
|
@@ -212,9 +236,13 @@ export class _IblShadowsImportanceSamplingRenderer {
|
|
|
212
236
|
return (this._iblSource &&
|
|
213
237
|
this._iblSource.name !== "Placeholder IBL Source" &&
|
|
214
238
|
this._iblSource.isReady() &&
|
|
239
|
+
this._cdfyPT &&
|
|
215
240
|
this._cdfyPT.isReady() &&
|
|
241
|
+
this._icdfyPT &&
|
|
216
242
|
this._icdfyPT.isReady() &&
|
|
243
|
+
this._cdfxPT &&
|
|
217
244
|
this._cdfxPT.isReady() &&
|
|
245
|
+
this._icdfxPT &&
|
|
218
246
|
this._icdfxPT.isReady());
|
|
219
247
|
}
|
|
220
248
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iblShadowsImportanceSamplingRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE3F,OAAO,0DAA0D,CAAC;AAClE,OAAO,uCAAuC,CAAC;AAC/C,OAAO,wCAAwC,CAAC;AAChD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;;;GAIG;AACH,MAAM,OAAO,qCAAqC;IAU9C;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS,CAAC,MAAmB;QACpC,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,EAAE;YAC5B,OAAO;SACV;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,MAAM,CAAC,oBAAoB,EAAE,EAAE;gBAC/B,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;aAC1C;iBAAM;gBACF,MAAsB,CAAC,gBAAgB,CAAC,OAAO,CAA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AAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1C,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1C,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACvI,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,wBAAwB;YACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAC1B,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport \"../../Shaders/iblShadowsImportanceSamplingDebug.fragment\";\r\nimport \"../../Shaders/iblShadowsCdfx.fragment\";\r\nimport \"../../Shaders/iblShadowsIcdfx.fragment\";\r\nimport \"../../Shaders/iblShadowsCdfy.fragment\";\r\nimport \"../../Shaders/iblShadowsIcdfy.fragment\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { Vector4 } from \"../../Maths/math.vector\";\r\nimport { RawTexture } from \"../../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { CubeTexture } from \"../../Materials/Textures/cubeTexture\";\r\n\r\n/**\r\n * Build cdf maps for IBL importance sampling during IBL shadow computation.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsImportanceSamplingRenderer {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _icdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfxPT: ProceduralTexture;\r\n private _iblSource: BaseTexture;\r\n\r\n /**\r\n * Gets the IBL source texture being used by the importance sampling renderer\r\n */\r\n public get iblSource(): BaseTexture {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the importance sampling renderer.\r\n * This will trigger recreation of the importance sampling assets.\r\n */\r\n public set iblSource(source: BaseTexture) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl(source: BaseTexture) {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfxPT.onGeneratedObservable.addOnce(() => {\r\n this.onReadyObservable.notifyObservers();\r\n });\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) Y texture\r\n * @returns Return the cumulative distribution function (CDF) Y texture\r\n */\r\n public getIcdfyTexture(): ProceduralTexture {\r\n return this._icdfyPT;\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) X texture\r\n * @returns Return the cumulative distribution function (CDF) X texture\r\n */\r\n public getIcdfxTexture(): ProceduralTexture {\r\n return this._icdfxPT;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"Importance Sample Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * Instanciates the importance sampling renderer\r\n * @param scene Scene to attach to\r\n * @returns The importance sampling renderer\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n }\r\n\r\n /**\r\n * Observable that triggers when the importance sampling renderer is ready\r\n */\r\n public onReadyObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? this._iblSource.getSize() : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource!.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n }\r\n\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblShadowsCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource as Texture);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._cdfyPT.refreshRate = 0;\r\n this._icdfyPT = new ProceduralTexture(\"icdfyTexture\", { width: size.width, height: size.height }, \"iblShadowsIcdfy\", this._scene, icdfOptions, false, false);\r\n this._icdfyPT.autoClear = false;\r\n this._icdfyPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfyPT.refreshRate = 0;\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblShadowsCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._icdfxPT = new ProceduralTexture(\"icdfxTexture\", { width: size.width, height: 1 }, \"iblShadowsIcdfx\", this._scene, icdfOptions, false, false);\r\n this._icdfxPT.autoClear = false;\r\n this._icdfxPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfxPT.refreshRate = 0;\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._icdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfxPT?.dispose();\r\n this._iblSource?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const debugOptions: PostProcessOptions = {\r\n width: this._scene.getEngine().getRenderWidth(),\r\n height: this._scene.getEngine().getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdfy\", \"cdfx\", \"icdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblShadowsImportanceSamplingDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdfy\", this._icdfyPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"icdfx\", this._icdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the importance sampling renderer is ready\r\n * @returns true if the importance sampling renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfyPT.isReady() &&\r\n this._cdfxPT.isReady() &&\r\n this._icdfxPT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the importance sampling renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"iblShadowsImportanceSamplingRenderer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Rendering/IBLShadows/iblShadowsImportanceSamplingRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yB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C,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACvI,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,OAAO;QACV,OAAO,CACH,IAAI,CAAC,UAAU;YACf,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,wBAAwB;YACjD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YACzB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACvB,IAAI,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACtB,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAC1B,CAAC;IACN,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;SAC7B;IACL,CAAC;CACJ","sourcesContent":["import { Constants } from \"../../Engines/constants\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport type { TextureSize } from \"../../Materials/Textures/textureCreationOptions\";\r\nimport { ProceduralTexture } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { IProceduralTextureCreationOptions } from \"../../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport { PostProcess } from \"../../PostProcesses/postProcess\";\r\nimport type { PostProcessOptions } from \"../../PostProcesses/postProcess\";\r\nimport { Vector4 } from \"../../Maths/math.vector\";\r\nimport { RawTexture } from \"../../Materials/Textures/rawTexture\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { CubeTexture } from \"../../Materials/Textures/cubeTexture\";\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Build cdf maps for IBL importance sampling during IBL shadow computation.\r\n * This should not be instanciated directly, as it is part of a scene component\r\n * @internal\r\n */\r\nexport class _IblShadowsImportanceSamplingRenderer {\r\n private _scene: Scene;\r\n private _engine: AbstractEngine;\r\n\r\n private _cdfyPT: ProceduralTexture;\r\n private _icdfyPT: ProceduralTexture;\r\n private _cdfxPT: ProceduralTexture;\r\n private _icdfxPT: ProceduralTexture;\r\n private _iblSource: BaseTexture;\r\n\r\n /**\r\n * Gets the IBL source texture being used by the importance sampling renderer\r\n */\r\n public get iblSource(): BaseTexture {\r\n return this._iblSource;\r\n }\r\n\r\n /**\r\n * Sets the IBL source texture to be used by the importance sampling renderer.\r\n * This will trigger recreation of the importance sampling assets.\r\n */\r\n public set iblSource(source: BaseTexture) {\r\n if (this._iblSource === source) {\r\n return;\r\n }\r\n this._disposeTextures();\r\n this._iblSource = source;\r\n if (source.isCube) {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as CubeTexture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n } else {\r\n if (source.isReadyOrNotBlocking()) {\r\n this._recreateAssetsFromNewIbl(source);\r\n } else {\r\n (source as Texture).onLoadObservable.addOnce(this._recreateAssetsFromNewIbl.bind(this, source));\r\n }\r\n }\r\n }\r\n\r\n private _recreateAssetsFromNewIbl(source: BaseTexture) {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n\r\n this._createTextures();\r\n\r\n if (this._debugPass) {\r\n // Recreate the debug pass because of the new textures\r\n this._createDebugPass();\r\n }\r\n\r\n // Once the textures are generated, notify that they are ready to use.\r\n this._icdfxPT.onGeneratedObservable.addOnce(() => {\r\n this.onReadyObservable.notifyObservers();\r\n });\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) Y texture\r\n * @returns Return the cumulative distribution function (CDF) Y texture\r\n */\r\n public getIcdfyTexture(): ProceduralTexture {\r\n return this._icdfyPT;\r\n }\r\n\r\n /**\r\n * Return the cumulative distribution function (CDF) X texture\r\n * @returns Return the cumulative distribution function (CDF) X texture\r\n */\r\n public getIcdfxTexture(): ProceduralTexture {\r\n return this._icdfxPT;\r\n }\r\n\r\n /** Enable the debug view for this pass */\r\n public debugEnabled: boolean = false;\r\n private _debugPass: PostProcess;\r\n private _debugSizeParams: Vector4 = new Vector4(0.0, 0.0, 0.0, 0.0);\r\n\r\n /**\r\n * Sets params that control the position and scaling of the debug display on the screen.\r\n * @param x Screen X offset of the debug display (0-1)\r\n * @param y Screen Y offset of the debug display (0-1)\r\n * @param widthScale X scale of the debug display (0-1)\r\n * @param heightScale Y scale of the debug display (0-1)\r\n */\r\n public setDebugDisplayParams(x: number, y: number, widthScale: number, heightScale: number) {\r\n this._debugSizeParams.set(x, y, widthScale, heightScale);\r\n }\r\n\r\n /**\r\n * The name of the debug pass post process\r\n */\r\n public get debugPassName(): string {\r\n return this._debugPassName;\r\n }\r\n private _debugPassName: string = \"Importance Sample Debug\";\r\n\r\n /**\r\n * Gets the debug pass post process\r\n * @returns The post process\r\n */\r\n public getDebugPassPP(): PostProcess {\r\n if (!this._debugPass) {\r\n this._createDebugPass();\r\n }\r\n return this._debugPass;\r\n }\r\n\r\n /**\r\n * Instanciates the importance sampling renderer\r\n * @param scene Scene to attach to\r\n * @returns The importance sampling renderer\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n }\r\n\r\n /**\r\n * Observable that triggers when the importance sampling renderer is ready\r\n */\r\n public onReadyObservable: Observable<void> = new Observable<void>();\r\n\r\n private _createTextures() {\r\n const size: TextureSize = this._iblSource ? this._iblSource.getSize() : { width: 1, height: 1 };\r\n if (!this._iblSource) {\r\n this._iblSource = RawTexture.CreateRTexture(\r\n new Uint8Array([255]),\r\n 1,\r\n 1,\r\n this._scene,\r\n false,\r\n false,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n this._iblSource.name = \"Placeholder IBL Source\";\r\n }\r\n\r\n if (this._iblSource!.isCube) {\r\n size.width *= 4;\r\n size.height *= 2;\r\n }\r\n\r\n const isWebGPU = this._engine.isWebGPU;\r\n // Create CDF maps (Cumulative Distribution Function) to assist in importance sampling\r\n const cdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowsCdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsCdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsCdfx.fragment\"), import(\"../../Shaders/iblShadowsCdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n const icdfOptions: IProceduralTextureCreationOptions = {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n format: Constants.TEXTUREFORMAT_R,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializationsAsync: async () => {\r\n if (isWebGPU) {\r\n await Promise.all([import(\"../../ShadersWGSL/iblShadowsIcdfx.fragment\"), import(\"../../ShadersWGSL/iblShadowsIcdfy.fragment\")]);\r\n } else {\r\n await Promise.all([import(\"../../Shaders/iblShadowsIcdfx.fragment\"), import(\"../../Shaders/iblShadowsIcdfy.fragment\")]);\r\n }\r\n },\r\n };\r\n this._cdfyPT = new ProceduralTexture(\"cdfyTexture\", { width: size.width, height: size.height + 1 }, \"iblShadowsCdfy\", this._scene, cdfOptions, false, false);\r\n this._cdfyPT.autoClear = false;\r\n this._cdfyPT.setTexture(\"iblSource\", this._iblSource as Texture);\r\n this._cdfyPT.setInt(\"iblHeight\", size.height);\r\n if (this._iblSource.isCube) {\r\n this._cdfyPT.defines = \"#define IBL_USE_CUBE_MAP\\n\";\r\n }\r\n this._cdfyPT.refreshRate = 0;\r\n this._icdfyPT = new ProceduralTexture(\"icdfyTexture\", { width: size.width, height: size.height }, \"iblShadowsIcdfy\", this._scene, icdfOptions, false, false);\r\n this._icdfyPT.autoClear = false;\r\n this._icdfyPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._icdfyPT.refreshRate = 0;\r\n this._cdfxPT = new ProceduralTexture(\"cdfxTexture\", { width: size.width + 1, height: 1 }, \"iblShadowsCdfx\", this._scene, cdfOptions, false, false);\r\n this._cdfxPT.autoClear = false;\r\n this._cdfxPT.setTexture(\"cdfy\", this._cdfyPT);\r\n this._cdfxPT.refreshRate = 0;\r\n this._icdfxPT = new ProceduralTexture(\"icdfxTexture\", { width: size.width, height: 1 }, \"iblShadowsIcdfx\", this._scene, icdfOptions, false, false);\r\n this._icdfxPT.autoClear = false;\r\n this._icdfxPT.setTexture(\"cdfx\", this._cdfxPT);\r\n this._icdfxPT.refreshRate = 0;\r\n }\r\n\r\n private _disposeTextures() {\r\n this._cdfyPT?.dispose();\r\n this._icdfyPT?.dispose();\r\n this._cdfxPT?.dispose();\r\n this._icdfxPT?.dispose();\r\n this._iblSource?.dispose();\r\n }\r\n\r\n private _createDebugPass() {\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n const isWebGPU = this._engine.isWebGPU;\r\n const debugOptions: PostProcessOptions = {\r\n width: this._scene.getEngine().getRenderWidth(),\r\n height: this._scene.getEngine().getRenderHeight(),\r\n samplingMode: Texture.BILINEAR_SAMPLINGMODE,\r\n engine: this._engine,\r\n textureType: Constants.TEXTURETYPE_UNSIGNED_INT,\r\n uniforms: [\"sizeParams\"],\r\n samplers: [\"cdfy\", \"icdfy\", \"cdfx\", \"icdfx\", \"iblSource\"],\r\n defines: this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\",\r\n shaderLanguage: isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\r\n extraInitializations: (useWebGPU: boolean, list: Promise<any>[]) => {\r\n if (useWebGPU) {\r\n list.push(import(\"../../ShadersWGSL/iblShadowsImportanceSamplingDebug.fragment\"));\r\n } else {\r\n list.push(import(\"../../Shaders/iblShadowsImportanceSamplingDebug.fragment\"));\r\n }\r\n },\r\n };\r\n this._debugPass = new PostProcess(this._debugPassName, \"iblShadowsImportanceSamplingDebug\", debugOptions);\r\n const debugEffect = this._debugPass.getEffect();\r\n if (debugEffect) {\r\n debugEffect.defines = this._iblSource?.isCube ? \"#define IBL_USE_CUBE_MAP\\n\" : \"\";\r\n }\r\n if (this._iblSource?.isCube) {\r\n this._debugPass.updateEffect(\"#define IBL_USE_CUBE_MAP\\n\");\r\n }\r\n this._debugPass.onApplyObservable.add((effect) => {\r\n effect.setTexture(\"cdfy\", this._cdfyPT);\r\n effect.setTexture(\"icdfy\", this._icdfyPT);\r\n effect.setTexture(\"cdfx\", this._cdfxPT);\r\n effect.setTexture(\"icdfx\", this._icdfxPT);\r\n effect.setTexture(\"iblSource\", this._iblSource);\r\n effect.setFloat4(\"sizeParams\", this._debugSizeParams.x, this._debugSizeParams.y, this._debugSizeParams.z, this._debugSizeParams.w);\r\n });\r\n }\r\n\r\n /**\r\n * Checks if the importance sampling renderer is ready\r\n * @returns true if the importance sampling renderer is ready\r\n */\r\n public isReady() {\r\n return (\r\n this._iblSource &&\r\n this._iblSource.name !== \"Placeholder IBL Source\" &&\r\n this._iblSource.isReady() &&\r\n this._cdfyPT &&\r\n this._cdfyPT.isReady() &&\r\n this._icdfyPT &&\r\n this._icdfyPT.isReady() &&\r\n this._cdfxPT &&\r\n this._cdfxPT.isReady() &&\r\n this._icdfxPT &&\r\n this._icdfxPT.isReady()\r\n );\r\n }\r\n\r\n /**\r\n * Disposes the importance sampling renderer and associated resources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n if (this._debugPass) {\r\n this._debugPass.dispose();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -3,9 +3,6 @@ import type { Scene } from "../../scene";
|
|
|
3
3
|
import type { BaseTexture } from "../../Materials/Textures/baseTexture";
|
|
4
4
|
import { Texture } from "../../Materials/Textures/texture";
|
|
5
5
|
import { PrePassRenderer } from "../prePassRenderer";
|
|
6
|
-
import "../../Shaders/postprocess.vertex";
|
|
7
|
-
import "../../Shaders/iblShadowGBufferDebug.fragment";
|
|
8
|
-
import "../../Shaders/iblShadowsCombine.fragment";
|
|
9
6
|
import { PostProcessRenderPipeline } from "../../PostProcesses/RenderPipeline/postProcessRenderPipeline";
|
|
10
7
|
import type { Camera } from "../../Cameras/camera.js";
|
|
11
8
|
interface IblShadowsSettings {
|
|
@@ -33,6 +30,10 @@ interface IblShadowsSettings {
|
|
|
33
30
|
* bits of missing geometry.
|
|
34
31
|
*/
|
|
35
32
|
triPlanarVoxelization: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Separate control for the opacity of the voxel shadows.
|
|
35
|
+
*/
|
|
36
|
+
voxelShadowOpacity: number;
|
|
36
37
|
/**
|
|
37
38
|
* Include screen-space shadows in the IBL shadow pipeline. This adds sharp shadows to small details
|
|
38
39
|
* but only applies close to a shadow-casting object.
|
|
@@ -80,6 +81,10 @@ export declare class IblShadowsRenderPipeline extends PostProcessRenderPipeline
|
|
|
80
81
|
private _noiseTexture;
|
|
81
82
|
private _shadowOpacity;
|
|
82
83
|
private _enabled;
|
|
84
|
+
/**
|
|
85
|
+
* The current world-space size of that the voxel grid covers in the scene.
|
|
86
|
+
*/
|
|
87
|
+
voxelGridSize: number;
|
|
83
88
|
/**
|
|
84
89
|
* How dark the shadows appear. 1.0 is full opacity, 0.0 is no shadows.
|
|
85
90
|
*/
|
|
@@ -7,9 +7,6 @@ import { PrePassRenderer } from "../prePassRenderer.js";
|
|
|
7
7
|
import { Logger } from "../../Misc/logger.js";
|
|
8
8
|
import { _IblShadowsVoxelRenderer } from "./iblShadowsVoxelRenderer.js";
|
|
9
9
|
import { _IblShadowsVoxelTracingPass } from "./iblShadowsVoxelTracingPass.js";
|
|
10
|
-
import "../../Shaders/postprocess.vertex.js";
|
|
11
|
-
import "../../Shaders/iblShadowGBufferDebug.fragment.js";
|
|
12
|
-
import "../../Shaders/iblShadowsCombine.fragment.js";
|
|
13
10
|
import { PostProcess } from "../../PostProcesses/postProcess.js";
|
|
14
11
|
import { _IblShadowsImportanceSamplingRenderer } from "./iblShadowsImportanceSamplingRenderer.js";
|
|
15
12
|
import { _IblShadowsSpatialBlurPass } from "./iblShadowsSpatialBlurPass.js";
|
|
@@ -486,8 +483,12 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
486
483
|
this._allowDebugPasses = false;
|
|
487
484
|
this._debugPasses = [];
|
|
488
485
|
this._excludedMeshes = [];
|
|
489
|
-
this._shadowOpacity =
|
|
486
|
+
this._shadowOpacity = 0.75;
|
|
490
487
|
this._enabled = true;
|
|
488
|
+
/**
|
|
489
|
+
* The current world-space size of that the voxel grid covers in the scene.
|
|
490
|
+
*/
|
|
491
|
+
this.voxelGridSize = 1.0;
|
|
491
492
|
this._gbufferDebugEnabled = false;
|
|
492
493
|
this._gBufferDebugSizeParams = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
493
494
|
this.scene = scene;
|
|
@@ -496,17 +497,18 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
496
497
|
Logger.Warn("IBL Shadows Render Pipeline could not enable PrePass, aborting.");
|
|
497
498
|
return;
|
|
498
499
|
}
|
|
499
|
-
this.shadowOpacity = options.shadowOpacity ||
|
|
500
|
+
this.shadowOpacity = options.shadowOpacity || 0.75;
|
|
500
501
|
this._prePassEffectConfiguration = new IblShadowsPrepassConfiguration();
|
|
501
502
|
this._voxelRenderer = new _IblShadowsVoxelRenderer(this.scene, this, options ? options.resolutionExp : 6, options.triPlanarVoxelization !== undefined ? options.triPlanarVoxelization : true);
|
|
502
503
|
this._importanceSamplingRenderer = new _IblShadowsImportanceSamplingRenderer(this.scene);
|
|
503
504
|
this._voxelTracingPass = new _IblShadowsVoxelTracingPass(this.scene, this);
|
|
504
505
|
this.sampleDirections = options.sampleDirections || 2;
|
|
506
|
+
this.voxelShadowOpacity = options.voxelShadowOpacity || 1.0;
|
|
505
507
|
this.ssShadowOpacity = options.ssShadowsEnabled === undefined || options.ssShadowsEnabled ? 1.0 : 0.0;
|
|
506
508
|
this.ssShadowMaxDist = options.ssShadowMaxDist || 0.05;
|
|
507
509
|
this.ssShadowSamples = options.ssShadowSampleCount || 16;
|
|
508
510
|
this.ssShadowStride = options.ssShadowStride || 8;
|
|
509
|
-
this.ssShadowThickness = options.ssShadowThickness || 0.
|
|
511
|
+
this.ssShadowThickness = options.ssShadowThickness || 0.5;
|
|
510
512
|
this._spatialBlurPass = new _IblShadowsSpatialBlurPass(this.scene);
|
|
511
513
|
this._accumulationPass = new _IblShadowsAccumulationPass(this.scene);
|
|
512
514
|
this.shadowRemenance = options.shadowRemenance || 0.75;
|
|
@@ -517,7 +519,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
517
519
|
// Create post process that applies the shadows to the scene
|
|
518
520
|
this._createShadowCombinePostProcess();
|
|
519
521
|
scene.postProcessRenderPipelineManager.addPipeline(this);
|
|
520
|
-
this._createEffectPasses(cameras);
|
|
521
522
|
this.scene.onNewMeshAddedObservable.add(this.updateSceneBounds.bind(this));
|
|
522
523
|
this.scene.onMeshRemovedObservable.add(this.updateSceneBounds.bind(this));
|
|
523
524
|
this.scene.onActiveCameraChanged.add(this._listenForCameraChanges.bind(this));
|
|
@@ -526,14 +527,21 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
526
527
|
this.scene.getEngine().onResizeObservable.add(this._handleResize.bind(this));
|
|
527
528
|
// Only turn on the pipeline if the importance sampling RT's are ready
|
|
528
529
|
this._importanceSamplingRenderer.onReadyObservable.add(() => {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
else {
|
|
533
|
-
this._voxelRenderer.onReadyObservable.addOnce(() => {
|
|
530
|
+
this._createEffectPasses(cameras);
|
|
531
|
+
const checkVoxelRendererReady = () => {
|
|
532
|
+
if (this._voxelRenderer.isReady()) {
|
|
534
533
|
this.toggleShadow(this._enabled);
|
|
535
|
-
|
|
536
|
-
|
|
534
|
+
if (this._enabled) {
|
|
535
|
+
this._voxelizationDirty = true;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
setTimeout(() => {
|
|
540
|
+
checkVoxelRendererReady();
|
|
541
|
+
}, 16);
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
checkVoxelRendererReady();
|
|
537
545
|
});
|
|
538
546
|
}
|
|
539
547
|
/**
|
|
@@ -560,6 +568,7 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
560
568
|
this._accumulationPass?.resize();
|
|
561
569
|
}
|
|
562
570
|
_createShadowCombinePostProcess() {
|
|
571
|
+
const isWebGPU = this.engine.isWebGPU;
|
|
563
572
|
const compositeOptions = {
|
|
564
573
|
width: this.scene.getEngine().getRenderWidth(),
|
|
565
574
|
height: this.scene.getEngine().getRenderHeight(),
|
|
@@ -569,6 +578,15 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
569
578
|
engine: this.scene.getEngine(),
|
|
570
579
|
textureType: 0,
|
|
571
580
|
reusable: false,
|
|
581
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
582
|
+
extraInitializations: (useWebGPU, list) => {
|
|
583
|
+
if (useWebGPU) {
|
|
584
|
+
list.push(import("../../ShadersWGSL/iblShadowsCombine.fragment.js"));
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
list.push(import("../../Shaders/iblShadowsCombine.fragment.js"));
|
|
588
|
+
}
|
|
589
|
+
},
|
|
572
590
|
};
|
|
573
591
|
this._shadowCompositePP = new PostProcess("iblShadowsCombine", "iblShadowsCombine", compositeOptions);
|
|
574
592
|
this._shadowCompositePP.autoClear = false;
|
|
@@ -585,9 +603,6 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
585
603
|
}
|
|
586
604
|
});
|
|
587
605
|
this._shadowCompositePP._prePassEffectConfiguration = this._prePassEffectConfiguration;
|
|
588
|
-
setTimeout(() => {
|
|
589
|
-
this._voxelizationDirty = true;
|
|
590
|
-
}, 500);
|
|
591
606
|
}
|
|
592
607
|
_createEffectPasses(cameras) {
|
|
593
608
|
this.addEffect(new PostProcessRenderEffect(this.scene.getEngine(), "IBLShadowVoxelTracingPass", () => {
|
|
@@ -612,6 +627,7 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
612
627
|
if (this._gbufferDebugPass) {
|
|
613
628
|
return this._gbufferDebugPass;
|
|
614
629
|
}
|
|
630
|
+
const isWebGPU = this.engine.isWebGPU;
|
|
615
631
|
const textureNames = this._prePassEffectConfiguration.texturesRequired.map((type) => PrePassRenderer.TextureFormats[type].name.toString());
|
|
616
632
|
const options = {
|
|
617
633
|
width: this.scene.getEngine().getRenderWidth(),
|
|
@@ -623,6 +639,15 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
623
639
|
uniforms: ["sizeParams"],
|
|
624
640
|
samplers: textureNames,
|
|
625
641
|
reusable: false,
|
|
642
|
+
shaderLanguage: isWebGPU ? 1 /* ShaderLanguage.WGSL */ : 0 /* ShaderLanguage.GLSL */,
|
|
643
|
+
extraInitializations: (useWebGPU, list) => {
|
|
644
|
+
if (useWebGPU) {
|
|
645
|
+
list.push(import("../../ShadersWGSL/iblShadowGBufferDebug.fragment.js"));
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
list.push(import("../../Shaders/iblShadowGBufferDebug.fragment.js"));
|
|
649
|
+
}
|
|
650
|
+
},
|
|
626
651
|
};
|
|
627
652
|
this._gbufferDebugPass = new PostProcess("iblShadowGBufferDebug", "iblShadowGBufferDebug", options);
|
|
628
653
|
this._gbufferDebugPass.autoClear = false;
|
|
@@ -850,7 +875,14 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
850
875
|
return mesh instanceof Mesh && this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
|
|
851
876
|
});
|
|
852
877
|
const size = bounds.max.subtract(bounds.min);
|
|
853
|
-
|
|
878
|
+
this.voxelGridSize = Math.max(size.x, Math.max(size.y, size.z));
|
|
879
|
+
if (!isFinite(this.voxelGridSize) || this.voxelGridSize === 0) {
|
|
880
|
+
Logger.Warn("IBL Shadows: Scene size is invalid. Can't update bounds.");
|
|
881
|
+
this._boundsNeedUpdate = false;
|
|
882
|
+
this.voxelGridSize = 1.0;
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const halfSize = this.voxelGridSize / 2.0;
|
|
854
886
|
const centre = bounds.max.add(bounds.min).multiplyByFloats(-0.5, -0.5, -0.5);
|
|
855
887
|
const invWorldScaleMatrix = Matrix.Compose(new Vector3(1.0 / halfSize, 1.0 / halfSize, 1.0 / halfSize), new Quaternion(), new Vector3(0, 0, 0));
|
|
856
888
|
const invTranslationMatrix = Matrix.Compose(new Vector3(1.0, 1.0, 1.0), new Quaternion(), centre);
|
|
@@ -863,11 +895,17 @@ export class IblShadowsRenderPipeline extends PostProcessRenderPipeline {
|
|
|
863
895
|
// Logger.Log("IBL Shadows: Scene size: " + size);
|
|
864
896
|
// Logger.Log("Half size: " + halfSize);
|
|
865
897
|
// Logger.Log("Centre translation: " + centre);
|
|
898
|
+
// Update the SS shadow max distance based on the voxel grid size and resolution.
|
|
899
|
+
// The max distance should be just a little larger than the world size of a single voxel.
|
|
900
|
+
this.ssShadowMaxDist = (1.1 * this.voxelGridSize) / (1 << this.resolutionExp);
|
|
866
901
|
}
|
|
867
902
|
// If update is needed, render voxels
|
|
868
903
|
if (this._voxelizationDirty) {
|
|
869
904
|
this._voxelRenderer.updateVoxelGrid(this._excludedMeshes);
|
|
870
905
|
this._voxelizationDirty = false;
|
|
906
|
+
// Update the SS shadow max distance based on the voxel grid size and resolution.
|
|
907
|
+
// The max distance should be just a little larger than the world size of a single voxel.
|
|
908
|
+
this.ssShadowMaxDist = (1.1 * this.voxelGridSize) / (1 << this.resolutionExp);
|
|
871
909
|
}
|
|
872
910
|
}
|
|
873
911
|
/**
|