@babylonjs/core 9.2.0 → 9.2.1

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.
Files changed (148) hide show
  1. package/Cameras/Inputs/geospatialCameraPointersInput.js +10 -8
  2. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  3. package/Cameras/geospatialCameraMovement.js +2 -2
  4. package/Cameras/geospatialCameraMovement.js.map +1 -1
  5. package/Engines/abstractEngine.js +2 -2
  6. package/Engines/abstractEngine.js.map +1 -1
  7. package/Engines/webgpuEngine.js +2 -0
  8. package/Engines/webgpuEngine.js.map +1 -1
  9. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.d.ts +105 -0
  10. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.js +318 -0
  11. package/FrameGraph/Node/Blocks/Rendering/iblShadowsRendererBlock.js.map +1 -0
  12. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  13. package/FrameGraph/Node/Blocks/index.js +1 -0
  14. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  15. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +34 -0
  16. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +144 -0
  17. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -0
  18. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.d.ts +26 -0
  19. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js +82 -0
  20. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsSpatialBlurTask.js.map +1 -0
  21. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.d.ts +61 -0
  22. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js +207 -0
  23. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsTracingTask.js.map +1 -0
  24. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.d.ts +104 -0
  25. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js +218 -0
  26. package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsVoxelizationTask.js.map +1 -0
  27. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.d.ts +217 -0
  28. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js +640 -0
  29. package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.js.map +1 -0
  30. package/FrameGraph/frameGraph.js +1 -0
  31. package/FrameGraph/frameGraph.js.map +1 -1
  32. package/FrameGraph/index.d.ts +1 -0
  33. package/FrameGraph/index.js +1 -0
  34. package/FrameGraph/index.js.map +1 -1
  35. package/Gizmos/boundingBoxGizmo.js +4 -0
  36. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  37. package/Lights/Clustered/clusteredLightContainer.js +8 -5
  38. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  39. package/Materials/PBR/openpbrMaterial.d.ts +13 -2
  40. package/Materials/PBR/openpbrMaterial.js +47 -16
  41. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  42. package/Materials/PBR/pbrBRDFConfiguration.js +1 -1
  43. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  44. package/Materials/Textures/Filtering/hdrFiltering.js +6 -0
  45. package/Materials/Textures/Filtering/hdrFiltering.js.map +1 -1
  46. package/Materials/Textures/envCubeTexture.js +13 -13
  47. package/Materials/Textures/envCubeTexture.js.map +1 -1
  48. package/Materials/materialHelper.functions.js +1 -1
  49. package/Materials/materialHelper.functions.js.map +1 -1
  50. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +101 -62
  51. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  52. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +39 -25
  53. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
  54. package/Misc/textureTools.d.ts +3 -1
  55. package/Misc/textureTools.js +74 -13
  56. package/Misc/textureTools.js.map +1 -1
  57. package/Misc/tools.js +1 -1
  58. package/Misc/tools.js.map +1 -1
  59. package/Particles/baseParticleSystem.d.ts +33 -1
  60. package/Particles/baseParticleSystem.js +65 -0
  61. package/Particles/baseParticleSystem.js.map +1 -1
  62. package/Particles/computeShaderParticleSystem.js +6 -0
  63. package/Particles/computeShaderParticleSystem.js.map +1 -1
  64. package/Particles/gpuParticleSystem.d.ts +24 -6
  65. package/Particles/gpuParticleSystem.js +85 -36
  66. package/Particles/gpuParticleSystem.js.map +1 -1
  67. package/Particles/particleSystem.d.ts +0 -6
  68. package/Particles/particleSystem.js +3 -14
  69. package/Particles/particleSystem.js.map +1 -1
  70. package/Particles/thinParticleSystem.d.ts +1 -3
  71. package/Particles/thinParticleSystem.js +1 -27
  72. package/Particles/thinParticleSystem.js.map +1 -1
  73. package/Particles/webgl2ParticleSystem.js +7 -0
  74. package/Particles/webgl2ParticleSystem.js.map +1 -1
  75. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +1 -1
  76. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
  77. package/Rendering/IBLShadows/iblShadowsPluginMaterial.d.ts +3 -1
  78. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js +11 -1
  79. package/Rendering/IBLShadows/iblShadowsPluginMaterial.js.map +1 -1
  80. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +0 -19
  81. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +21 -65
  82. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  83. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +15 -52
  84. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +129 -220
  85. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  86. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +3 -0
  87. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
  88. package/Rendering/depthRenderer.js +6 -0
  89. package/Rendering/depthRenderer.js.map +1 -1
  90. package/Rendering/geometryBufferRenderer.d.ts +14 -5
  91. package/Rendering/geometryBufferRenderer.js +6 -2
  92. package/Rendering/geometryBufferRenderer.js.map +1 -1
  93. package/Rendering/geometryBufferRendererSceneComponent.d.ts +4 -6
  94. package/Rendering/geometryBufferRendererSceneComponent.js.map +1 -1
  95. package/Rendering/iblCdfGenerator.d.ts +10 -0
  96. package/Rendering/iblCdfGenerator.js +52 -17
  97. package/Rendering/iblCdfGenerator.js.map +1 -1
  98. package/Rendering/index.d.ts +0 -6
  99. package/Rendering/index.js +0 -6
  100. package/Rendering/index.js.map +1 -1
  101. package/Shaders/ShadersInclude/openpbrDirectLighting.js +6 -1
  102. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  103. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  104. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  105. package/Shaders/gpuUpdateParticles.vertex.js +12 -6
  106. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  107. package/Shaders/iblShadowVoxelTracing.fragment.js +5 -1
  108. package/Shaders/iblShadowVoxelTracing.fragment.js.map +1 -1
  109. package/Shaders/iblVoxelGrid.fragment.d.ts +1 -0
  110. package/Shaders/iblVoxelGrid.fragment.js +33 -5
  111. package/Shaders/iblVoxelGrid.fragment.js.map +1 -1
  112. package/Shaders/{iblVoxelSlabDebug.fragment.d.ts → lod3D.fragment.d.ts} +1 -1
  113. package/Shaders/lod3D.fragment.js +13 -0
  114. package/Shaders/lod3D.fragment.js.map +1 -0
  115. package/Shaders/openpbr.fragment.js +5 -0
  116. package/Shaders/openpbr.fragment.js.map +1 -1
  117. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +6 -1
  118. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  119. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  120. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  121. package/ShadersWGSL/gpuUpdateParticles.compute.js +14 -7
  122. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  123. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js +5 -1
  124. package/ShadersWGSL/iblShadowVoxelTracing.fragment.js.map +1 -1
  125. package/ShadersWGSL/iblVoxelGrid.fragment.js +1 -1
  126. package/ShadersWGSL/iblVoxelGrid.fragment.js.map +1 -1
  127. package/{Shaders/iblVoxelSlabDebug.vertex.d.ts → ShadersWGSL/lod3D.fragment.d.ts} +1 -1
  128. package/ShadersWGSL/lod3D.fragment.js +13 -0
  129. package/ShadersWGSL/lod3D.fragment.js.map +1 -0
  130. package/ShadersWGSL/openpbr.fragment.js +5 -0
  131. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  132. package/package.json +1 -1
  133. package/Shaders/iblVoxelGrid3dDebug.fragment.d.ts +0 -5
  134. package/Shaders/iblVoxelGrid3dDebug.fragment.js +0 -24
  135. package/Shaders/iblVoxelGrid3dDebug.fragment.js.map +0 -1
  136. package/Shaders/iblVoxelSlabDebug.fragment.js +0 -13
  137. package/Shaders/iblVoxelSlabDebug.fragment.js.map +0 -1
  138. package/Shaders/iblVoxelSlabDebug.vertex.js +0 -11
  139. package/Shaders/iblVoxelSlabDebug.vertex.js.map +0 -1
  140. package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.d.ts +0 -5
  141. package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js +0 -23
  142. package/ShadersWGSL/iblVoxelGrid3dDebug.fragment.js.map +0 -1
  143. package/ShadersWGSL/iblVoxelSlabDebug.fragment.d.ts +0 -5
  144. package/ShadersWGSL/iblVoxelSlabDebug.fragment.js +0 -14
  145. package/ShadersWGSL/iblVoxelSlabDebug.fragment.js.map +0 -1
  146. package/ShadersWGSL/iblVoxelSlabDebug.vertex.d.ts +0 -5
  147. package/ShadersWGSL/iblVoxelSlabDebug.vertex.js +0 -12
  148. package/ShadersWGSL/iblVoxelSlabDebug.vertex.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"clusteredLightContainer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/Clustered/clusteredLightContainer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,8BAA8B,CAAC;AAEtC,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACpD,OAAO,GAAG,EAAE,CAAC,IAAI,uBAAuB,CAAC,IAAI,EAAE,E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AK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;gBACxD,IAAI,UAAU,EAAE,CAAC;oBACb,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACvC,CAAC;YACL,CAAC;YAED,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE;oBACtC,KAAK,MAAM,UAAU,IAAI,iBAAiB,EAAE,CAAC;wBACzC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;oBAC9B,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;;AAjiBD,gBAAgB;AACF,qDAA6B,GAA2B,GAAG,EAAE;IACvE,MAAM,WAAW,CAAC,iCAAiC,CAAC,CAAC;AACzD,CAAC,AAF0C,CAEzC;AAsCF;IADC,SAAS,EAAE;8DAGX;AAiBD;IADC,SAAS,EAAE;4DAGX;AAqBD;IADC,SAAS,EAAE;0DAGX;AA6BD;IADC,SAAS,EAAE;uDAGX;AAgbL,sBAAsB;AACtB,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { StorageBuffer } from \"core/Buffers/storageBuffer\";\nimport { type Camera } from \"core/Cameras/camera\";\nimport { type AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { Constants } from \"core/Engines/constants\";\nimport { type WebGPUEngine } from \"core/Engines/webgpuEngine\";\nimport { type Effect } from \"core/Materials/effect\";\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\nimport { TmpColors } from \"core/Maths/math.color\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\nimport { type Mesh } from \"core/Meshes/mesh\";\nimport { serialize } from \"core/Misc/decorators\";\nimport { _WarnImport } from \"core/Misc/devTools\";\nimport { Logger } from \"core/Misc/logger\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { Node } from \"core/node\";\nimport { type Scene } from \"core/scene\";\nimport { type Nullable } from \"core/types\";\n\nimport { Light } from \"../light\";\nimport { LightConstants } from \"../lightConstants\";\nimport { type PointLight } from \"../pointLight\";\nimport { type SpotLight } from \"../spotLight\";\nimport { type RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\n\nimport \"core/Meshes/thinInstanceMesh\";\n\nNode.AddNodeConstructor(\"Light_Type_5\", (name, scene) => {\n return () => new ClusteredLightContainer(name, [], scene);\n});\n\nconst DefaultDepthSlices = 16;\nconst MobileClusteredLightBatchSize = 8;\n\n/**\n * A special light that renders all its associated spot or point lights using a clustered or forward+ system.\n */\nexport class ClusteredLightContainer extends Light {\n private static _GetEngineBatchSize(engine: AbstractEngine): number {\n const caps = engine._caps;\n if (!caps.texelFetch) {\n return 0;\n } else if (engine.isWebGPU) {\n // On WebGPU we use atomic writes to storage textures\n return 32;\n } else if (engine.version > 1) {\n // On WebGL 2 we use additive float blending as the light mask\n if (!caps.colorBufferFloat || !caps.blendFloat) {\n return 0;\n }\n // Due to the use of floats we want to limit lights to the precision of floats\n // The reduced precision for mobiles is because some devices (like Samsung Galaxy) report support for R32F but actually create the texture with less precision.\n return engine.hostInformation.isMobile ? MobileClusteredLightBatchSize : caps.shaderFloatPrecision;\n } else {\n // WebGL 1 is not supported due to lack of dynamic for loops\n return 0;\n }\n }\n\n /**\n * Checks if the clustered lighting system supports the given light with its current parameters.\n * This will also check if the light's associated engine supports clustered lighting.\n *\n * @param light The light to test\n * @returns true if the light and its engine is supported\n */\n public static IsLightSupported(light: Light): boolean {\n if (ClusteredLightContainer._GetEngineBatchSize(light.getEngine()) === 0) {\n return false;\n }\n\n if (light.shadowEnabled && light._scene.shadowsEnabled && light.getShadowGenerators()) {\n // Shadows are not supported\n return false;\n }\n\n if (light.falloffType !== Light.FALLOFF_DEFAULT) {\n // Only the default falloff is supported\n return false;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_POINTLIGHT) {\n return true;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n // Extra texture bindings per light are not supported\n return !(<SpotLight>light).projectionTexture && !(<SpotLight>light).iesProfileTexture;\n }\n\n // Currently only point and spot lights are supported\n return false;\n }\n\n /** @internal */\n public static _SceneComponentInitialization: (scene: Scene) => void = () => {\n throw _WarnImport(\"ClusteredLightingSceneComponent\");\n };\n\n private readonly _batchSize: number;\n\n /**\n * True if clustered lighting is supported.\n */\n public get isSupported(): boolean {\n return this._batchSize > 0;\n }\n\n private readonly _lights: Light[] = [];\n /**\n * Gets the current list of lights added to this clustering system.\n */\n public get lights(): readonly Light[] {\n return this._lights;\n }\n\n private _camera: Nullable<Camera> = null;\n\n // The lights sorted by depth\n private readonly _sortedLights: (PointLight | SpotLight)[] = [];\n\n private _lightDataBuffer: Float32Array;\n private _lightDataTexture: RawTexture;\n private _lightDataRenderId = -1;\n\n private _tileMaskBatches = -1;\n private _tileMaskTexture: RenderTargetTexture;\n private _tileMaskBuffer: Nullable<StorageBuffer>;\n\n private _horizontalTiles = 64;\n /**\n * The number of tiles in the horizontal direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get horizontalTiles(): number {\n return this._horizontalTiles;\n }\n\n public set horizontalTiles(horizontal: number) {\n if (this._horizontalTiles === horizontal) {\n return;\n }\n this._horizontalTiles = horizontal;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _verticalTiles = 64;\n /**\n * The number of tiles in the vertical direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get verticalTiles(): number {\n return this._verticalTiles;\n }\n\n public set verticalTiles(vertical: number) {\n if (this._verticalTiles === vertical) {\n return;\n }\n this._verticalTiles = vertical;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _sliceScale = 0;\n private _sliceBias = 0;\n // List of vec2's that keep track of the min and max index per slice\n private _sliceRanges: Float32Array<ArrayBuffer>;\n\n private _depthSlices = DefaultDepthSlices;\n /**\n * The number of slices to split the depth range by and cluster lights into.\n */\n @serialize()\n public get depthSlices(): number {\n return this._depthSlices;\n }\n\n public set depthSlices(slices: number) {\n if (this._depthSlices === slices) {\n return;\n }\n this._depthSlices = slices;\n this._sliceRanges = new Float32Array(slices * 2);\n\n // UBO size depends on the number of depth slices\n this._uniformBuffer.dispose();\n this._uniformBuffer = new UniformBuffer(this.getEngine(), undefined, undefined, this.name);\n this._buildUniformLayout();\n\n // CLUSTLIGHT_SLICES is a shader define that sizes the vSliceRanges array in the UBO.\n // Materials must recompile when depthSlices changes so the shader layout matches the rebuilt UBO.\n // Otherwise, if depthSlices is reduced, the rebuilt UBO can be smaller than what the previously compiled shader expects, causing rendering to fail.\n this._markMeshesAsLightDirty();\n }\n\n private readonly _proxyMaterial: ShaderMaterial;\n private readonly _proxyMesh: Mesh;\n\n private _maxRange = 16383;\n private _minInverseSquaredRange = 1 / (this._maxRange * this._maxRange);\n /**\n * This limits the range of all the added lights, so even lights with extreme ranges will still have bounds for clustering.\n */\n @serialize()\n public get maxRange(): number {\n return this._maxRange;\n }\n\n public set maxRange(range: number) {\n if (this._maxRange === range) {\n return;\n }\n this._maxRange = range;\n this._minInverseSquaredRange = 1 / (range * range);\n }\n\n /**\n * Creates a new clustered light system with an initial set of lights.\n *\n * @param name The name of the clustered light container\n * @param lights The initial set of lights to add\n * @param scene The scene the clustered light container belongs to\n */\n constructor(name: string, lights: Light[] = [], scene?: Scene) {\n super(name, scene);\n const engine = this.getEngine();\n this._batchSize = ClusteredLightContainer._GetEngineBatchSize(engine);\n\n const proxyShader = { vertex: \"lightProxy\", fragment: \"lightProxy\" };\n const defines = [`CLUSTLIGHT_BATCH ${this._batchSize}`];\n if (this._scene.useRightHandedSystem) {\n defines.push(\"#define RIGHT_HANDED\");\n }\n this._proxyMaterial = new ShaderMaterial(\"ProxyMaterial\", this._scene, proxyShader, {\n attributes: [\"position\"],\n uniforms: [\"view\", \"projection\", \"tileMaskResolution\"],\n samplers: [\"lightDataTexture\"],\n uniformBuffers: [\"Scene\"],\n storageBuffers: [\"tileMaskBuffer\"],\n defines,\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\n extraInitializationsAsync: async () => {\n if (engine.isWebGPU) {\n await Promise.all([import(\"../../ShadersWGSL/lightProxy.vertex\"), import(\"../../ShadersWGSL/lightProxy.fragment\")]);\n } else {\n await Promise.all([import(\"../../Shaders/lightProxy.vertex\"), import(\"../../Shaders/lightProxy.fragment\")]);\n }\n },\n });\n\n // Additive blending is for merging masks on WebGL\n this._proxyMaterial.transparencyMode = ShaderMaterial.MATERIAL_ALPHABLEND;\n this._proxyMaterial.alphaMode = Constants.ALPHA_ADD;\n this._proxyMaterial.sideOrientation = Constants.MATERIAL_CounterClockWiseSideOrientation;\n\n this._proxyMesh = CreatePlane(\"ProxyMesh\", { size: 2 }, this._scene);\n // Make sure it doesn't render for the default scene\n this._scene.removeMesh(this._proxyMesh);\n this._proxyMesh.material = this._proxyMaterial;\n\n this._updateBatches();\n\n this._sliceRanges = new Float32Array(this._depthSlices * 2);\n\n if (this._batchSize > 0) {\n ClusteredLightContainer._SceneComponentInitialization(this._scene);\n for (const light of lights) {\n this.addLight(light);\n }\n }\n }\n\n public override getClassName(): string {\n return \"ClusteredLightContainer\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public override getTypeID(): number {\n return LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER;\n }\n\n /** @internal */\n public _updateBatches(camera: Nullable<Camera> = null): RenderTargetTexture {\n this._camera = camera;\n this._proxyMesh.isVisible = this._sortedLights.length > 0;\n\n // Ensure space for atleast 1 batch\n const batches = Math.max(Math.ceil(this._sortedLights.length / this._batchSize), 1);\n if (this._tileMaskBatches >= batches) {\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n return this._tileMaskTexture;\n }\n const engine = this.getEngine();\n // Round up to a batch size so we don't have to reallocate as often\n const maxLights = batches * this._batchSize;\n\n this._lightDataBuffer = new Float32Array(20 * maxLights);\n this._lightDataTexture?.dispose();\n this._lightDataTexture = new RawTexture(\n this._lightDataBuffer,\n 5,\n maxLights,\n Constants.TEXTUREFORMAT_RGBA,\n this._scene,\n false,\n false,\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\n Constants.TEXTURETYPE_FLOAT\n );\n this._lightDataTexture.name = \"LightDataTexture_clustered_\" + this.name;\n this._proxyMaterial.setTexture(\"lightDataTexture\", this._lightDataTexture);\n\n this._tileMaskTexture?.dispose();\n const textureSize = { width: this._horizontalTiles, height: this._verticalTiles };\n if (!engine.isWebGPU) {\n // In WebGL we shift the light proxy by the batch number\n textureSize.height *= batches;\n }\n this._tileMaskTexture = new RenderTargetTexture(\"TileMaskTexture\", textureSize, this._scene, {\n // We don't write anything on WebGPU so make it as small as possible\n type: engine.isWebGPU ? Constants.TEXTURETYPE_UNSIGNED_BYTE : Constants.TEXTURETYPE_FLOAT,\n format: Constants.TEXTUREFORMAT_RED,\n generateDepthBuffer: false,\n });\n\n this._tileMaskTexture.renderParticles = false;\n this._tileMaskTexture.renderSprites = false;\n this._tileMaskTexture.noPrePassRenderer = true;\n this._tileMaskTexture.renderList = [this._proxyMesh];\n\n let currentRenderTarget: Nullable<RenderTargetWrapper> = null;\n\n this._tileMaskTexture.onBeforeBindObservable.add(() => {\n currentRenderTarget = engine._currentRenderTarget;\n this._updateLightData();\n });\n\n this._tileMaskTexture.onAfterUnbindObservable.add(() => {\n if (engine._currentRenderTarget !== currentRenderTarget) {\n if (!currentRenderTarget) {\n engine.restoreDefaultFramebuffer();\n } else {\n engine.bindFramebuffer(currentRenderTarget);\n }\n }\n });\n\n this._tileMaskTexture.onClearObservable.add(() => {\n if (engine.isWebGPU) {\n // Clear the storage buffer for WebGPU\n this._tileMaskBuffer?.clear();\n } else {\n // Only clear the texture on WebGL\n engine.clear({ r: 0, g: 0, b: 0, a: 1 }, true, false);\n }\n });\n\n if (engine.isWebGPU) {\n // WebGPU also needs a storage buffer to write to\n this._tileMaskBuffer?.dispose();\n const bufferSize = this._horizontalTiles * this._verticalTiles * batches * 4;\n this._tileMaskBuffer = new StorageBuffer(<WebGPUEngine>engine, bufferSize);\n this._proxyMaterial.setStorageBuffer(\"tileMaskBuffer\", this._tileMaskBuffer);\n }\n\n this._proxyMaterial.setVector3(\"tileMaskResolution\", new Vector3(this._horizontalTiles, this.verticalTiles, batches));\n\n // We don't actually use the matrix data but we need enough capacity for the lights\n this._proxyMesh.thinInstanceSetBuffer(\"matrix\", new Float32Array(maxLights * 16));\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n this._tileMaskBatches = batches;\n return this._tileMaskTexture;\n }\n\n private _getSliceIndex(camera: Camera, depth: number): number {\n if (depth < camera.minZ) {\n // Prevent calling log on small or negative values\n return -1;\n }\n return Math.floor(Math.log(depth) * this._sliceScale + this._sliceBias);\n }\n\n private _updateLightData(): void {\n const camera = this._camera || this._scene.activeCamera;\n const renderId = this._scene.getRenderId();\n if (!camera || this._lightDataRenderId === renderId) {\n return;\n }\n this._lightDataRenderId = renderId;\n\n // Resort lights based on distance from camera\n const view = camera.getViewMatrix();\n for (const light of this._sortedLights) {\n const position = light.computeTransformedInformation() ? light.transformedPosition : light.position;\n const viewPosition = Vector3.TransformCoordinatesToRef(position, view, TmpVectors.Vector3[0]);\n light._currentViewDepth = this._scene.useRightHandedSystem ? -viewPosition.z : viewPosition.z;\n }\n this._sortedLights.sort((a, b) => a._currentViewDepth - b._currentViewDepth);\n\n // DOOM 2016 subdivision scheme, copied from: https://www.aortiz.me/2018/12/21/CG.html\n const logFarNear = Math.log(camera.maxZ / camera.minZ);\n this._sliceScale = this._depthSlices / logFarNear;\n this._sliceBias = -(this._depthSlices * Math.log(camera.minZ)) / logFarNear;\n\n this._sliceRanges.fill(0);\n // Last slice which had had its min index updated\n let minSlice = -1;\n\n const buf = this._lightDataBuffer;\n const offset = this._scene.floatingOriginOffset;\n\n for (let i = 0; i < this._sortedLights.length; i += 1) {\n const light = this._sortedLights[i];\n const off = i * 20;\n const computed = light.computeTransformedInformation();\n const scaledIntensity = light.getScaledIntensity();\n\n const position = computed ? light.transformedPosition : light.position;\n const diffuse = light.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\n const specular = light.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\n const range = Math.min(light.range, this.maxRange);\n const inverseSquaredRange = Math.max(light._inverseSquaredRange, this._minInverseSquaredRange);\n\n // vLightData\n buf[off + 0] = position.x - offset.x;\n buf[off + 1] = position.y - offset.y;\n buf[off + 2] = position.z - offset.z;\n buf[off + 3] = 0;\n // vLightDiffuse\n buf[off + 4] = diffuse.r;\n buf[off + 5] = diffuse.g;\n buf[off + 6] = diffuse.b;\n buf[off + 7] = range;\n // vLightSpecular\n buf[off + 8] = specular.r;\n buf[off + 9] = specular.g;\n buf[off + 10] = specular.b;\n buf[off + 11] = light.radius;\n // vLightDirection\n buf[off + 12] = 0;\n buf[off + 13] = 0;\n buf[off + 14] = 0;\n buf[off + 15] = -1;\n // vLightFalloff\n buf[off + 16] = range;\n buf[off + 17] = inverseSquaredRange;\n buf[off + 18] = 0;\n buf[off + 19] = 0;\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n const spotLight = <SpotLight>light;\n const direction = Vector3.NormalizeToRef(computed ? spotLight.transformedDirection : spotLight.direction, TmpVectors.Vector3[0]);\n\n // vLightData.a\n buf[off + 3] = spotLight.exponent;\n // vLightDirection\n buf[off + 12] = direction.x;\n buf[off + 13] = direction.y;\n buf[off + 14] = direction.z;\n buf[off + 15] = spotLight._cosHalfAngle;\n // vLightFalloff.zw\n buf[off + 18] = spotLight._lightAngleScale;\n buf[off + 19] = spotLight._lightAngleOffset;\n }\n\n // Update the depth slices that include this light\n const firstSlice = this._getSliceIndex(camera, light._currentViewDepth - range);\n const lastSlice = this._getSliceIndex(camera, light._currentViewDepth + range);\n for (let j = firstSlice; j <= lastSlice; j += 1) {\n if (j < 0 || j >= this._depthSlices) {\n continue;\n } else if (j > minSlice) {\n // Update min index\n this._sliceRanges[j * 2] = i;\n minSlice = j;\n }\n // Update max index\n this._sliceRanges[j * 2 + 1] = i;\n }\n }\n\n const engine = this.getEngine();\n if (engine.isWebGPU) {\n // Whenever the light data changes we have to flush pending WebGPU command buffers so that\n // previous render passes use the old data and later render passes use the new data.\n engine.flushFramebuffer();\n }\n this._lightDataTexture.update(this._lightDataBuffer);\n }\n\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void {\n for (const light of this._lights) {\n light.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n this._lightDataTexture.dispose();\n this._tileMaskTexture.dispose();\n this._tileMaskBuffer?.dispose();\n this._proxyMesh.dispose(doNotRecurse, disposeMaterialAndTextures);\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n\n /**\n * Adds a light to the clustering system.\n * @param light The light to add\n */\n public addLight(light: Light): void {\n if (!ClusteredLightContainer.IsLightSupported(light)) {\n Logger.Warn(\"Attempting to add a light to cluster that does not support clustering\");\n return;\n }\n this._scene.removeLight(light);\n this._lights.push(light);\n this._sortedLights.push(<PointLight | SpotLight>light);\n\n this._proxyMesh.isVisible = true;\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n }\n\n /**\n * Removes a light from the clustering system.\n * @param light The light to remove\n * @returns the index where the light was in the light list\n */\n public removeLight(light: Light): number {\n // Convert to `Light` array without cast so `indexOf` has correct typing\n const sortedLights: Light[] = this._sortedLights;\n const sortedIndex = sortedLights.indexOf(light);\n if (sortedIndex !== -1) {\n sortedLights.splice(sortedIndex, 1);\n\n this._proxyMesh.thinInstanceCount = sortedLights.length;\n if (sortedLights.length === 0) {\n this._proxyMesh.isVisible = false;\n }\n }\n\n const index = this._lights.indexOf(light);\n if (index !== -1) {\n this._lights.splice(index, 1);\n // We treat the unsorted array as the \"real\" one so only add back to the scene if it was found in that\n this._scene.addLight(light);\n }\n return index;\n }\n\n protected override _buildUniformLayout(): void {\n this._uniformBuffer.addUniform(\"vLightData\", 4);\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\n this._uniformBuffer.addUniform(\"vSliceData\", 2);\n // _depthSlices might not be initialized yet\n this._uniformBuffer.addUniform(\"vSliceRanges\", 2, this._depthSlices ?? DefaultDepthSlices);\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\n this._uniformBuffer.addUniform(\"depthValues\", 2);\n this._uniformBuffer.create();\n }\n\n public override transferToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n const hscale = this._horizontalTiles / engine.getRenderWidth();\n const vscale = this._verticalTiles / engine.getRenderHeight();\n this._uniformBuffer.updateFloat4(\"vLightData\", hscale, vscale, this._verticalTiles, this._tileMaskBatches, lightIndex);\n this._uniformBuffer.updateFloat2(\"vSliceData\", this._sliceScale, this._sliceBias, lightIndex);\n this._uniformBuffer.updateFloatArray(\"vSliceRanges\", this._sliceRanges, lightIndex);\n return this;\n }\n\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n effect.setTexture(\"lightDataTexture\" + lightIndex, this._lightDataTexture);\n if (engine.isWebGPU) {\n (<WebGPUEngine>engine).setStorageBuffer(\"tileMaskBuffer\" + lightIndex, this._tileMaskBuffer);\n } else {\n effect.setTexture(\"tileMaskTexture\" + lightIndex, this._tileMaskTexture);\n }\n return this;\n }\n\n public override transferToNodeMaterialEffect(_effect: Effect): Light {\n return this;\n }\n\n public override prepareLightSpecificDefines(defines: any, lightIndex: number): void {\n defines[\"CLUSTLIGHT\" + lightIndex] = true;\n defines[\"CLUSTLIGHT_BATCH\"] = this._batchSize;\n defines[\"CLUSTLIGHT_SLICES\"] = this._depthSlices;\n }\n\n public override _isReady(): boolean {\n this._updateBatches();\n return this._proxyMesh.isReady(true, true);\n }\n\n /**\n * Serializes the ClusteredLightContainer to a JSON object, including all child lights.\n * @returns the serialized object\n */\n public override serialize(): any {\n const serializationObject = super.serialize();\n\n // Serialize child lights inline so they round-trip with the container.\n // Child lights are removed from scene.lights by addLight(), so the scene\n // serializer would not reach them on its own.\n serializationObject.clusteredLights = [];\n for (const light of this._lights) {\n if (!light.doNotSerialize) {\n serializationObject.clusteredLights.push(light.serialize());\n }\n }\n\n return serializationObject;\n }\n\n protected override _onParsed(parsedLight: any, scene: Scene): void {\n if (parsedLight.clusteredLights) {\n // Parse child lights first, but defer addLight() until after the loader\n // fixup passes (parent resolution, excluded/included mesh resolution)\n // have run on scene.lights. addLight() removes lights from scene.lights,\n // which would cause those fixups to miss the child lights.\n const parsedChildLights: Light[] = [];\n for (const parsedChildLight of parsedLight.clusteredLights) {\n const childLight = Light.Parse(parsedChildLight, scene);\n if (childLight) {\n parsedChildLights.push(childLight);\n }\n }\n\n if (parsedChildLights.length > 0) {\n scene.onDataLoadedObservable.addOnce(() => {\n for (const childLight of parsedChildLights) {\n this.addLight(childLight);\n }\n });\n }\n }\n }\n}\n\n// Register Class Name\nRegisterClass(\"BABYLON.ClusteredLightContainer\", ClusteredLightContainer);\n"]}
1
+ {"version":3,"file":"clusteredLightContainer.js","sourceRoot":"","sources":["../../../../../dev/core/src/Lights/Clustered/clusteredLightContainer.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,oCA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UAAU,CAAC,CAAC;oBAC9B,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;IACL,CAAC;;AAriBD,gBAAgB;AACF,qDAA6B,GAA2B,GAAG,EAAE;IACvE,MAAM,WAAW,CAAC,iCAAiC,CAAC,CAAC;AACzD,CAAC,AAF0C,CAEzC;AAsCF;IADC,SAAS,EAAE;8DAGX;AAiBD;IADC,SAAS,EAAE;4DAGX;AAqBD;IADC,SAAS,EAAE;0DAGX;AA6BD;IADC,SAAS,EAAE;uDAGX;AAobL,sBAAsB;AACtB,aAAa,CAAC,iCAAiC,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import { StorageBuffer } from \"core/Buffers/storageBuffer\";\nimport { type Camera } from \"core/Cameras/camera\";\nimport { type AbstractEngine } from \"core/Engines/abstractEngine\";\nimport { Constants } from \"core/Engines/constants\";\nimport { type WebGPUEngine } from \"core/Engines/webgpuEngine\";\nimport { type Effect } from \"core/Materials/effect\";\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\nimport { ShaderMaterial } from \"core/Materials/shaderMaterial\";\nimport { RawTexture } from \"core/Materials/Textures/rawTexture\";\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\nimport { TmpColors } from \"core/Maths/math.color\";\nimport { TmpVectors, Vector3 } from \"core/Maths/math.vector\";\nimport { CreatePlane } from \"core/Meshes/Builders/planeBuilder\";\nimport { type Mesh } from \"core/Meshes/mesh\";\nimport { serialize } from \"core/Misc/decorators\";\nimport { _WarnImport } from \"core/Misc/devTools\";\nimport { Logger } from \"core/Misc/logger\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { Node } from \"core/node\";\nimport { type Scene } from \"core/scene\";\nimport { type Nullable } from \"core/types\";\n\nimport { Light } from \"../light\";\nimport { LightConstants } from \"../lightConstants\";\nimport { type PointLight } from \"../pointLight\";\nimport { type SpotLight } from \"../spotLight\";\nimport { type RenderTargetWrapper } from \"../../Engines/renderTargetWrapper\";\n\nimport \"core/Meshes/thinInstanceMesh\";\n\nNode.AddNodeConstructor(\"Light_Type_5\", (name, scene) => {\n return () => new ClusteredLightContainer(name, [], scene);\n});\n\nconst DefaultDepthSlices = 16;\nconst MobileClusteredLightBatchSize = 8;\n\n/**\n * A special light that renders all its associated spot or point lights using a clustered or forward+ system.\n */\nexport class ClusteredLightContainer extends Light {\n private static _GetEngineBatchSize(engine: AbstractEngine): number {\n const caps = engine._caps;\n if (!caps.texelFetch) {\n return 0;\n } else if (engine.isWebGPU) {\n // On WebGPU we use atomic writes to storage textures\n return 32;\n } else if (engine.version > 1) {\n // On WebGL 2 we use additive float blending as the light mask\n if (!caps.colorBufferFloat || !caps.blendFloat) {\n return 0;\n }\n // Due to the use of floats we want to limit lights to the precision of floats\n // The reduced precision for mobiles is because some devices (like Samsung Galaxy) report support for R32F but actually create the texture with less precision.\n return engine.hostInformation.isMobile ? MobileClusteredLightBatchSize : caps.shaderFloatPrecision;\n } else {\n // WebGL 1 is not supported due to lack of dynamic for loops\n return 0;\n }\n }\n\n /**\n * Checks if the clustered lighting system supports the given light with its current parameters.\n * This will also check if the light's associated engine supports clustered lighting.\n *\n * @param light The light to test\n * @returns true if the light and its engine is supported\n */\n public static IsLightSupported(light: Light): boolean {\n if (ClusteredLightContainer._GetEngineBatchSize(light.getEngine()) === 0) {\n return false;\n }\n\n if (light.shadowEnabled && light._scene.shadowsEnabled && light.getShadowGenerators()) {\n // Shadows are not supported\n return false;\n }\n\n if (light.falloffType !== Light.FALLOFF_DEFAULT) {\n // Only the default falloff is supported\n return false;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_POINTLIGHT) {\n return true;\n }\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n // Extra texture bindings per light are not supported\n return !(<SpotLight>light).projectionTexture && !(<SpotLight>light).iesProfileTexture;\n }\n\n // Currently only point and spot lights are supported\n return false;\n }\n\n /** @internal */\n public static _SceneComponentInitialization: (scene: Scene) => void = () => {\n throw _WarnImport(\"ClusteredLightingSceneComponent\");\n };\n\n private readonly _batchSize: number;\n\n /**\n * True if clustered lighting is supported.\n */\n public get isSupported(): boolean {\n return this._batchSize > 0;\n }\n\n private readonly _lights: Light[] = [];\n /**\n * Gets the current list of lights added to this clustering system.\n */\n public get lights(): readonly Light[] {\n return this._lights;\n }\n\n private _camera: Nullable<Camera> = null;\n\n // The lights sorted by depth\n private readonly _sortedLights: (PointLight | SpotLight)[] = [];\n\n private _lightDataBuffer: Float32Array;\n private _lightDataTexture: RawTexture;\n private _lightDataRenderId = -1;\n\n private _tileMaskBatches = -1;\n private _tileMaskTexture: RenderTargetTexture;\n private _tileMaskBuffer: Nullable<StorageBuffer>;\n\n private _horizontalTiles = 64;\n /**\n * The number of tiles in the horizontal direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get horizontalTiles(): number {\n return this._horizontalTiles;\n }\n\n public set horizontalTiles(horizontal: number) {\n if (this._horizontalTiles === horizontal) {\n return;\n }\n this._horizontalTiles = horizontal;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _verticalTiles = 64;\n /**\n * The number of tiles in the vertical direction to cluster lights into.\n * A lower value will reduce memory and make the clustering step faster, while a higher value increases memory and makes the rendering step faster.\n */\n @serialize()\n public get verticalTiles(): number {\n return this._verticalTiles;\n }\n\n public set verticalTiles(vertical: number) {\n if (this._verticalTiles === vertical) {\n return;\n }\n this._verticalTiles = vertical;\n // Force the batch data to be recreated\n this._tileMaskBatches = -1;\n }\n\n private _sliceScale = 0;\n private _sliceBias = 0;\n // List of vec2's that keep track of the min and max index per slice\n private _sliceRanges: Float32Array<ArrayBuffer>;\n\n private _depthSlices = DefaultDepthSlices;\n /**\n * The number of slices to split the depth range by and cluster lights into.\n */\n @serialize()\n public get depthSlices(): number {\n return this._depthSlices;\n }\n\n public set depthSlices(slices: number) {\n if (this._depthSlices === slices) {\n return;\n }\n this._depthSlices = slices;\n this._sliceRanges = new Float32Array(slices * 2);\n\n // UBO size depends on the number of depth slices\n this._uniformBuffer.dispose();\n this._uniformBuffer = new UniformBuffer(this.getEngine(), undefined, undefined, this.name);\n this._buildUniformLayout();\n\n // CLUSTLIGHT_SLICES is a shader define that sizes the vSliceRanges array in the UBO.\n // Materials must recompile when depthSlices changes so the shader layout matches the rebuilt UBO.\n // Otherwise, if depthSlices is reduced, the rebuilt UBO can be smaller than what the previously compiled shader expects, causing rendering to fail.\n this._markMeshesAsLightDirty();\n }\n\n private readonly _proxyMaterial: ShaderMaterial;\n private readonly _proxyMesh: Mesh;\n\n private _maxRange = 16383;\n private _minInverseSquaredRange = 1 / (this._maxRange * this._maxRange);\n /**\n * This limits the range of all the added lights, so even lights with extreme ranges will still have bounds for clustering.\n */\n @serialize()\n public get maxRange(): number {\n return this._maxRange;\n }\n\n public set maxRange(range: number) {\n if (this._maxRange === range) {\n return;\n }\n this._maxRange = range;\n this._minInverseSquaredRange = 1 / (range * range);\n }\n\n /**\n * Creates a new clustered light system with an initial set of lights.\n *\n * @param name The name of the clustered light container\n * @param lights The initial set of lights to add\n * @param scene The scene the clustered light container belongs to\n */\n constructor(name: string, lights: Light[] = [], scene?: Scene) {\n super(name, scene);\n const engine = this.getEngine();\n this._batchSize = ClusteredLightContainer._GetEngineBatchSize(engine);\n\n const proxyShader = { vertex: \"lightProxy\", fragment: \"lightProxy\" };\n const defines = [`CLUSTLIGHT_BATCH ${this._batchSize}`];\n if (this._scene.useRightHandedSystem) {\n defines.push(\"#define RIGHT_HANDED\");\n }\n this._proxyMaterial = new ShaderMaterial(\"ProxyMaterial\", this._scene, proxyShader, {\n attributes: [\"position\"],\n uniforms: [\"view\", \"projection\", \"tileMaskResolution\"],\n samplers: [\"lightDataTexture\"],\n uniformBuffers: [\"Scene\"],\n storageBuffers: [\"tileMaskBuffer\"],\n defines,\n shaderLanguage: engine.isWebGPU ? ShaderLanguage.WGSL : ShaderLanguage.GLSL,\n extraInitializationsAsync: async () => {\n if (engine.isWebGPU) {\n await Promise.all([import(\"../../ShadersWGSL/lightProxy.vertex\"), import(\"../../ShadersWGSL/lightProxy.fragment\")]);\n } else {\n await Promise.all([import(\"../../Shaders/lightProxy.vertex\"), import(\"../../Shaders/lightProxy.fragment\")]);\n }\n },\n });\n\n // Additive blending is for merging masks on WebGL\n this._proxyMaterial.transparencyMode = ShaderMaterial.MATERIAL_ALPHABLEND;\n this._proxyMaterial.alphaMode = Constants.ALPHA_ADD;\n this._proxyMaterial.sideOrientation = Constants.MATERIAL_CounterClockWiseSideOrientation;\n\n this._proxyMesh = CreatePlane(\"ProxyMesh\", { size: 2 }, this._scene);\n // Make sure it doesn't render for the default scene\n this._scene.removeMesh(this._proxyMesh);\n this._proxyMesh.material = this._proxyMaterial;\n\n this._updateBatches();\n\n this._sliceRanges = new Float32Array(this._depthSlices * 2);\n\n if (this._batchSize > 0) {\n ClusteredLightContainer._SceneComponentInitialization(this._scene);\n for (const light of lights) {\n this.addLight(light);\n }\n }\n }\n\n public override getClassName(): string {\n return \"ClusteredLightContainer\";\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public override getTypeID(): number {\n return LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER;\n }\n\n /** @internal */\n public _updateBatches(camera: Nullable<Camera> = null): RenderTargetTexture {\n this._camera = camera;\n this._proxyMesh.isVisible = this._sortedLights.length > 0;\n\n // Ensure space for atleast 1 batch\n const batches = Math.max(Math.ceil(this._sortedLights.length / this._batchSize), 1);\n if (this._tileMaskBatches >= batches) {\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n return this._tileMaskTexture;\n }\n const engine = this.getEngine();\n // Round up to a batch size so we don't have to reallocate as often\n const maxLights = batches * this._batchSize;\n\n this._lightDataBuffer = new Float32Array(20 * maxLights);\n this._lightDataTexture?.dispose();\n this._lightDataTexture = new RawTexture(\n this._lightDataBuffer,\n 5,\n maxLights,\n Constants.TEXTUREFORMAT_RGBA,\n this._scene,\n false,\n false,\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\n Constants.TEXTURETYPE_FLOAT\n );\n this._lightDataTexture.name = \"LightDataTexture_clustered_\" + this.name;\n this._proxyMaterial.setTexture(\"lightDataTexture\", this._lightDataTexture);\n\n this._tileMaskTexture?.dispose();\n const textureSize = { width: this._horizontalTiles, height: this._verticalTiles };\n if (!engine.isWebGPU) {\n // In WebGL we shift the light proxy by the batch number\n textureSize.height *= batches;\n }\n this._tileMaskTexture = new RenderTargetTexture(\"TileMaskTexture\", textureSize, this._scene, {\n // We don't write anything on WebGPU so make it as small as possible\n type: engine.isWebGPU ? Constants.TEXTURETYPE_UNSIGNED_BYTE : Constants.TEXTURETYPE_FLOAT,\n format: Constants.TEXTUREFORMAT_RED,\n generateDepthBuffer: false,\n });\n\n this._tileMaskTexture.renderParticles = false;\n this._tileMaskTexture.renderSprites = false;\n this._tileMaskTexture.noPrePassRenderer = true;\n this._tileMaskTexture.renderList = [this._proxyMesh];\n\n let currentRenderTarget: Nullable<RenderTargetWrapper> = null;\n\n this._tileMaskTexture.onBeforeBindObservable.add(() => {\n currentRenderTarget = engine._currentRenderTarget;\n this._updateLightData();\n // On WebGPU, clear the storage buffer here (before bindFramebuffer) because\n // clearBuffer is a command encoder operation that cannot run while a render pass is open.\n // In snapshot rendering mode, bindFramebuffer eagerly creates the render pass, so\n // clearing must happen before that point.\n if (engine.isWebGPU) {\n this._tileMaskBuffer?.clear();\n }\n });\n\n this._tileMaskTexture.onAfterUnbindObservable.add(() => {\n if (engine._currentRenderTarget !== currentRenderTarget) {\n if (!currentRenderTarget) {\n engine.restoreDefaultFramebuffer();\n } else {\n engine.bindFramebuffer(currentRenderTarget);\n }\n }\n });\n\n this._tileMaskTexture.onClearObservable.add(() => {\n if (!engine.isWebGPU) {\n // Only clear the texture on WebGL\n engine.clear({ r: 0, g: 0, b: 0, a: 1 }, true, false);\n }\n });\n\n if (engine.isWebGPU) {\n // WebGPU also needs a storage buffer to write to\n this._tileMaskBuffer?.dispose();\n const bufferSize = this._horizontalTiles * this._verticalTiles * batches * 4;\n this._tileMaskBuffer = new StorageBuffer(<WebGPUEngine>engine, bufferSize);\n this._proxyMaterial.setStorageBuffer(\"tileMaskBuffer\", this._tileMaskBuffer);\n }\n\n this._proxyMaterial.setVector3(\"tileMaskResolution\", new Vector3(this._horizontalTiles, this.verticalTiles, batches));\n\n // We don't actually use the matrix data but we need enough capacity for the lights\n this._proxyMesh.thinInstanceSetBuffer(\"matrix\", new Float32Array(maxLights * 16));\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n this._tileMaskBatches = batches;\n return this._tileMaskTexture;\n }\n\n private _getSliceIndex(camera: Camera, depth: number): number {\n if (depth < camera.minZ) {\n // Prevent calling log on small or negative values\n return -1;\n }\n return Math.floor(Math.log(depth) * this._sliceScale + this._sliceBias);\n }\n\n private _updateLightData(): void {\n const camera = this._camera || this._scene.activeCamera;\n const renderId = this._scene.getRenderId();\n if (!camera || this._lightDataRenderId === renderId) {\n return;\n }\n this._lightDataRenderId = renderId;\n\n // Resort lights based on distance from camera\n const view = camera.getViewMatrix();\n for (const light of this._sortedLights) {\n const position = light.computeTransformedInformation() ? light.transformedPosition : light.position;\n const viewPosition = Vector3.TransformCoordinatesToRef(position, view, TmpVectors.Vector3[0]);\n light._currentViewDepth = this._scene.useRightHandedSystem ? -viewPosition.z : viewPosition.z;\n }\n this._sortedLights.sort((a, b) => a._currentViewDepth - b._currentViewDepth);\n\n // DOOM 2016 subdivision scheme, copied from: https://www.aortiz.me/2018/12/21/CG.html\n const logFarNear = Math.log(camera.maxZ / camera.minZ);\n this._sliceScale = this._depthSlices / logFarNear;\n this._sliceBias = -(this._depthSlices * Math.log(camera.minZ)) / logFarNear;\n\n this._sliceRanges.fill(0);\n // Last slice which had had its min index updated\n let minSlice = -1;\n\n const buf = this._lightDataBuffer;\n const offset = this._scene.floatingOriginOffset;\n\n for (let i = 0; i < this._sortedLights.length; i += 1) {\n const light = this._sortedLights[i];\n const off = i * 20;\n const computed = light.computeTransformedInformation();\n const scaledIntensity = light.getScaledIntensity();\n\n const position = computed ? light.transformedPosition : light.position;\n const diffuse = light.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\n const specular = light.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\n const range = Math.min(light.range, this.maxRange);\n const inverseSquaredRange = Math.max(light._inverseSquaredRange, this._minInverseSquaredRange);\n\n // vLightData\n buf[off + 0] = position.x - offset.x;\n buf[off + 1] = position.y - offset.y;\n buf[off + 2] = position.z - offset.z;\n buf[off + 3] = 0;\n // vLightDiffuse\n buf[off + 4] = diffuse.r;\n buf[off + 5] = diffuse.g;\n buf[off + 6] = diffuse.b;\n buf[off + 7] = range;\n // vLightSpecular\n buf[off + 8] = specular.r;\n buf[off + 9] = specular.g;\n buf[off + 10] = specular.b;\n buf[off + 11] = light.radius;\n // vLightDirection\n buf[off + 12] = 0;\n buf[off + 13] = 0;\n buf[off + 14] = 0;\n buf[off + 15] = -1;\n // vLightFalloff\n buf[off + 16] = range;\n buf[off + 17] = inverseSquaredRange;\n buf[off + 18] = 0;\n buf[off + 19] = 0;\n\n if (light.getTypeID() === LightConstants.LIGHTTYPEID_SPOTLIGHT) {\n const spotLight = <SpotLight>light;\n const direction = Vector3.NormalizeToRef(computed ? spotLight.transformedDirection : spotLight.direction, TmpVectors.Vector3[0]);\n\n // vLightData.a\n buf[off + 3] = spotLight.exponent;\n // vLightDirection\n buf[off + 12] = direction.x;\n buf[off + 13] = direction.y;\n buf[off + 14] = direction.z;\n buf[off + 15] = spotLight._cosHalfAngle;\n // vLightFalloff.zw\n buf[off + 18] = spotLight._lightAngleScale;\n buf[off + 19] = spotLight._lightAngleOffset;\n }\n\n // Update the depth slices that include this light\n const firstSlice = this._getSliceIndex(camera, light._currentViewDepth - range);\n const lastSlice = this._getSliceIndex(camera, light._currentViewDepth + range);\n for (let j = firstSlice; j <= lastSlice; j += 1) {\n if (j < 0 || j >= this._depthSlices) {\n continue;\n } else if (j > minSlice) {\n // Update min index\n this._sliceRanges[j * 2] = i;\n minSlice = j;\n }\n // Update max index\n this._sliceRanges[j * 2 + 1] = i;\n }\n }\n\n const engine = this.getEngine();\n if (engine.isWebGPU) {\n // Whenever the light data changes we have to flush pending WebGPU command buffers so that\n // previous render passes use the old data and later render passes use the new data.\n engine.flushFramebuffer();\n }\n this._lightDataTexture.update(this._lightDataBuffer);\n }\n\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void {\n for (const light of this._lights) {\n light.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n this._lightDataTexture.dispose();\n this._tileMaskTexture.dispose();\n this._tileMaskBuffer?.dispose();\n this._proxyMesh.dispose(doNotRecurse, disposeMaterialAndTextures);\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\n }\n\n /**\n * Adds a light to the clustering system.\n * @param light The light to add\n */\n public addLight(light: Light): void {\n if (!ClusteredLightContainer.IsLightSupported(light)) {\n Logger.Warn(\"Attempting to add a light to cluster that does not support clustering\");\n return;\n }\n this._scene.removeLight(light);\n this._lights.push(light);\n this._sortedLights.push(<PointLight | SpotLight>light);\n\n this._proxyMesh.isVisible = true;\n this._proxyMesh.thinInstanceCount = this._sortedLights.length;\n }\n\n /**\n * Removes a light from the clustering system.\n * @param light The light to remove\n * @returns the index where the light was in the light list\n */\n public removeLight(light: Light): number {\n // Convert to `Light` array without cast so `indexOf` has correct typing\n const sortedLights: Light[] = this._sortedLights;\n const sortedIndex = sortedLights.indexOf(light);\n if (sortedIndex !== -1) {\n sortedLights.splice(sortedIndex, 1);\n\n this._proxyMesh.thinInstanceCount = sortedLights.length;\n if (sortedLights.length === 0) {\n this._proxyMesh.isVisible = false;\n }\n }\n\n const index = this._lights.indexOf(light);\n if (index !== -1) {\n this._lights.splice(index, 1);\n // We treat the unsorted array as the \"real\" one so only add back to the scene if it was found in that\n this._scene.addLight(light);\n }\n return index;\n }\n\n protected override _buildUniformLayout(): void {\n this._uniformBuffer.addUniform(\"vLightData\", 4);\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\n this._uniformBuffer.addUniform(\"vSliceData\", 2);\n // _depthSlices might not be initialized yet\n this._uniformBuffer.addUniform(\"vSliceRanges\", 2, this._depthSlices ?? DefaultDepthSlices);\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\n this._uniformBuffer.addUniform(\"depthValues\", 2);\n this._uniformBuffer.create();\n }\n\n public override transferToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n const hscale = this._horizontalTiles / engine.getRenderWidth();\n const vscale = this._verticalTiles / engine.getRenderHeight();\n this._uniformBuffer.updateFloat4(\"vLightData\", hscale, vscale, this._verticalTiles, this._tileMaskBatches, lightIndex);\n this._uniformBuffer.updateFloat2(\"vSliceData\", this._sliceScale, this._sliceBias, lightIndex);\n this._uniformBuffer.updateFloatArray(\"vSliceRanges\", this._sliceRanges, lightIndex);\n return this;\n }\n\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\n const engine = this.getEngine();\n effect.setTexture(\"lightDataTexture\" + lightIndex, this._lightDataTexture);\n if (engine.isWebGPU) {\n (<WebGPUEngine>engine).setStorageBuffer(\"tileMaskBuffer\" + lightIndex, this._tileMaskBuffer);\n } else {\n effect.setTexture(\"tileMaskTexture\" + lightIndex, this._tileMaskTexture);\n }\n return this;\n }\n\n public override transferToNodeMaterialEffect(_effect: Effect): Light {\n return this;\n }\n\n public override prepareLightSpecificDefines(defines: any, lightIndex: number): void {\n defines[\"CLUSTLIGHT\" + lightIndex] = true;\n defines[\"CLUSTLIGHT_BATCH\"] = this._batchSize;\n defines[\"CLUSTLIGHT_SLICES\"] = this._depthSlices;\n }\n\n public override _isReady(): boolean {\n this._updateBatches();\n return this._proxyMesh.isReady(true, true);\n }\n\n /**\n * Serializes the ClusteredLightContainer to a JSON object, including all child lights.\n * @returns the serialized object\n */\n public override serialize(): any {\n const serializationObject = super.serialize();\n\n // Serialize child lights inline so they round-trip with the container.\n // Child lights are removed from scene.lights by addLight(), so the scene\n // serializer would not reach them on its own.\n serializationObject.clusteredLights = [];\n for (const light of this._lights) {\n if (!light.doNotSerialize) {\n serializationObject.clusteredLights.push(light.serialize());\n }\n }\n\n return serializationObject;\n }\n\n protected override _onParsed(parsedLight: any, scene: Scene): void {\n if (parsedLight.clusteredLights) {\n // Parse child lights first, but defer addLight() until after the loader\n // fixup passes (parent resolution, excluded/included mesh resolution)\n // have run on scene.lights. addLight() removes lights from scene.lights,\n // which would cause those fixups to miss the child lights.\n const parsedChildLights: Light[] = [];\n for (const parsedChildLight of parsedLight.clusteredLights) {\n const childLight = Light.Parse(parsedChildLight, scene);\n if (childLight) {\n parsedChildLights.push(childLight);\n }\n }\n\n if (parsedChildLights.length > 0) {\n scene.onDataLoadedObservable.addOnce(() => {\n for (const childLight of parsedChildLights) {\n this.addLight(childLight);\n }\n });\n }\n }\n }\n}\n\n// Register Class Name\nRegisterClass(\"BABYLON.ClusteredLightContainer\", ClusteredLightContainer);\n"]}
@@ -3,6 +3,7 @@ import { type Scene } from "../../scene.js";
3
3
  import { Color3 } from "../../Maths/math.color.js";
4
4
  import { ImageProcessingConfiguration } from "../imageProcessingConfiguration.js";
5
5
  import { type BaseTexture } from "../../Materials/Textures/baseTexture.js";
6
+ import { type ThinTexture } from "../../Materials/Textures/thinTexture.js";
6
7
  import { Material } from "../material.js";
7
8
  import { type Engine } from "../../Engines/engine.js";
8
9
  import { type AbstractMesh } from "../../Meshes/abstractMesh.js";
@@ -811,16 +812,26 @@ export declare class OpenPBRMaterial extends OpenPBRMaterialBase {
811
812
  */
812
813
  ambientOcclusionTexture: Nullable<BaseTexture>;
813
814
  private _ambientOcclusionTexture;
815
+ private _sssIrradianceTexture;
814
816
  /**
815
817
  * Defines the irradiance texture used for subsurface scattering.
816
818
  * If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
819
+ * Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
820
+ * handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
821
+ * Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
817
822
  */
818
- sssIrradianceTexture: Nullable<BaseTexture>;
823
+ get sssIrradianceTexture(): Nullable<ThinTexture>;
824
+ set sssIrradianceTexture(value: Nullable<ThinTexture>);
825
+ private _sssDepthTexture;
819
826
  /**
820
827
  * Defines the depth texture used for subsurface scattering. This is the depth defined
821
828
  * in screen space. If it's not provided, the depth will be looked for in the scene.geometryBufferRenderer.
829
+ * Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
830
+ * handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
831
+ * Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
822
832
  */
823
- sssDepthTexture: Nullable<BaseTexture>;
833
+ get sssDepthTexture(): Nullable<ThinTexture>;
834
+ set sssDepthTexture(value: Nullable<ThinTexture>);
824
835
  private _propertyList;
825
836
  private _uniformsList;
826
837
  private _samplersList;
@@ -377,6 +377,40 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
377
377
  set geometryCoatTangentAngle(value) {
378
378
  this.geometryCoatTangent = new Vector2(Math.cos(value), Math.sin(value));
379
379
  }
380
+ /**
381
+ * Defines the irradiance texture used for subsurface scattering.
382
+ * If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
383
+ * Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
384
+ * handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
385
+ * Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
386
+ */
387
+ get sssIrradianceTexture() {
388
+ return this._sssIrradianceTexture;
389
+ }
390
+ set sssIrradianceTexture(value) {
391
+ if (this._sssIrradianceTexture === value) {
392
+ return;
393
+ }
394
+ this._sssIrradianceTexture = value;
395
+ this._markAllSubMeshesAsTexturesDirty();
396
+ }
397
+ /**
398
+ * Defines the depth texture used for subsurface scattering. This is the depth defined
399
+ * in screen space. If it's not provided, the depth will be looked for in the scene.geometryBufferRenderer.
400
+ * Accepts a {@link ThinTexture} so that an {@link InternalTexture} obtained from a frame graph
401
+ * handle can be wrapped with `new ThinTexture(internalTexture)` and assigned directly.
402
+ * Setting this property marks all sub-meshes as textures-dirty so the shader recompiles.
403
+ */
404
+ get sssDepthTexture() {
405
+ return this._sssDepthTexture;
406
+ }
407
+ set sssDepthTexture(value) {
408
+ if (this._sssDepthTexture === value) {
409
+ return;
410
+ }
411
+ this._sssDepthTexture = value;
412
+ this._markAllSubMeshesAsTexturesDirty();
413
+ }
380
414
  /**
381
415
  * Specifies if we can see through the surface of the material due to subsurface scattering or transmission.
382
416
  */
@@ -571,16 +605,8 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
571
605
  this._thinFilmThicknessTexture = new Sampler("thin_film_thickness", "thinFilmThickness", "THIN_FILM_THICKNESS");
572
606
  this._thinFilmIor = new Property("thin_film_ior", 1.4, "vThinFilmIor", 1, 0);
573
607
  this._ambientOcclusionTexture = new Sampler("ambient_occlusion", "ambientOcclusion", "AMBIENT_OCCLUSION");
574
- /**
575
- * Defines the irradiance texture used for subsurface scattering.
576
- * If it's not provided, the irradiance will be looked for in the scene.geometryBufferRenderer.
577
- */
578
- this.sssIrradianceTexture = null;
579
- /**
580
- * Defines the depth texture used for subsurface scattering. This is the depth defined
581
- * in screen space. If it's not provided, the depth will be looked for in the scene.geometryBufferRenderer.
582
- */
583
- this.sssDepthTexture = null;
608
+ this._sssIrradianceTexture = null;
609
+ this._sssDepthTexture = null;
584
610
  this._uniformsList = {};
585
611
  this._samplersList = {};
586
612
  this._samplerDefines = {};
@@ -1302,6 +1328,17 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1302
1328
  return false;
1303
1329
  }
1304
1330
  }
1331
+ // When both SSS textures are assigned they will be used for screen-space subsurface
1332
+ // scattering. Block readiness until both underlying textures are loaded so that
1333
+ // scene.onReadyObservable never fires with missing SSS data.
1334
+ if (this._sssIrradianceTexture && this._sssDepthTexture) {
1335
+ if (!this._sssIrradianceTexture.isReady()) {
1336
+ return false;
1337
+ }
1338
+ if (!this._sssDepthTexture.isReady()) {
1339
+ return false;
1340
+ }
1341
+ }
1305
1342
  }
1306
1343
  }
1307
1344
  this._eventInfo.isReadyForSubMesh = true;
@@ -1613,12 +1650,6 @@ export class OpenPBRMaterial extends OpenPBRMaterialBase {
1613
1650
  if (this._radianceTexture) {
1614
1651
  activeTextures.push(this._radianceTexture);
1615
1652
  }
1616
- if (this.sssIrradianceTexture) {
1617
- activeTextures.push(this.sssIrradianceTexture);
1618
- }
1619
- if (this.sssDepthTexture) {
1620
- activeTextures.push(this.sssDepthTexture);
1621
- }
1622
1653
  return activeTextures;
1623
1654
  }
1624
1655
  /**