@babylonjs/core 8.45.0 → 8.45.2

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 (58) hide show
  1. package/Cameras/Inputs/index.d.ts +1 -0
  2. package/Cameras/Inputs/index.js +1 -0
  3. package/Cameras/Inputs/index.js.map +1 -1
  4. package/Engines/Extensions/engine.debugging.d.ts +4 -0
  5. package/Engines/Extensions/engine.debugging.js.map +1 -1
  6. package/Engines/abstractEngine.js +2 -2
  7. package/Engines/abstractEngine.js.map +1 -1
  8. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.d.ts +1 -1
  9. package/FrameGraph/Tasks/PostProcesses/volumetricLightingTask.js.map +1 -1
  10. package/FrameGraph/frameGraphContext.js +3 -3
  11. package/FrameGraph/frameGraphContext.js.map +1 -1
  12. package/FrameGraph/frameGraphTask.js +4 -4
  13. package/FrameGraph/frameGraphTask.js.map +1 -1
  14. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  15. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  16. package/Lights/Shadows/shadowGenerator.js +3 -3
  17. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  18. package/Lights/lightingVolume.js +6 -6
  19. package/Lights/lightingVolume.js.map +1 -1
  20. package/Loading/Plugins/babylonFileLoader.js +17 -0
  21. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  22. package/Materials/PBR/pbrBaseMaterial.d.ts +2 -1
  23. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  24. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  25. package/Materials/PBR/pbrSubSurfaceConfiguration.d.ts +2 -0
  26. package/Materials/PBR/pbrSubSurfaceConfiguration.js +8 -4
  27. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  28. package/Materials/Textures/Procedurals/proceduralTexture.js +2 -2
  29. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  30. package/Materials/Textures/renderTargetTexture.js +2 -2
  31. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  32. package/Misc/minMaxReducer.js +2 -2
  33. package/Misc/minMaxReducer.js.map +1 -1
  34. package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +2 -0
  35. package/Particles/Node/Blocks/Conditions/particleConditionBlock.js.map +1 -1
  36. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.d.ts +4 -0
  37. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js +10 -0
  38. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js.map +1 -1
  39. package/Particles/Node/Blocks/Update/updateRemapBlock.d.ts +39 -0
  40. package/Particles/Node/Blocks/Update/updateRemapBlock.js +93 -0
  41. package/Particles/Node/Blocks/Update/updateRemapBlock.js.map +1 -0
  42. package/Particles/Node/Blocks/systemBlock.d.ts +4 -0
  43. package/Particles/Node/Blocks/systemBlock.js +32 -1
  44. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  45. package/Particles/Node/nodeParticleSystemSet.helper.js +88 -0
  46. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  47. package/Particles/thinParticleSystem.js +10 -6
  48. package/Particles/thinParticleSystem.js.map +1 -1
  49. package/Probes/reflectionProbe.js +2 -2
  50. package/Probes/reflectionProbe.js.map +1 -1
  51. package/Rendering/depthRenderer.js +2 -2
  52. package/Rendering/depthRenderer.js.map +1 -1
  53. package/XR/features/WebXRControllerPhysics.d.ts +30 -1
  54. package/XR/features/WebXRControllerPhysics.js +269 -16
  55. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  56. package/XR/features/WebXRHandTracking.js +36 -2
  57. package/XR/features/WebXRHandTracking.js.map +1 -1
  58. package/package.json +1 -1
@@ -170,24 +170,24 @@ export class LightingVolume {
170
170
  this._uBuffer.updateMatrix("invViewProjMatrix", this._shadowGenerator.getTransformMatrix().invertToRef(TmpVectors.Matrix[0]));
171
171
  if (this._engine._enableGPUDebugMarkers) {
172
172
  this._engine.restoreDefaultFramebuffer();
173
- this._engine._debugPushGroup(`Update lighting volume (${this._name})`);
173
+ this._engine._debugPushGroup?.(`Update lighting volume (${this._name})`);
174
174
  }
175
175
  if (this._needUpdateGeometry()) {
176
176
  this._fullUpdateUBO(true);
177
177
  const dispatchSize = Math.ceil((this._tesselation + 1) / 32);
178
- this._engine._debugPushGroup(`Update vertices of other planes`);
178
+ this._engine._debugPushGroup?.(`Update vertices of other planes`);
179
179
  this._cs2.dispatch(dispatchSize, 1, 1);
180
- this._engine._debugPopGroup();
180
+ this._engine._debugPopGroup?.();
181
181
  }
182
182
  else {
183
183
  this._fullUpdateUBO();
184
184
  }
185
185
  const dispatchSize = Math.ceil((this._tesselation + 1) / 8);
186
- this._engine._debugPushGroup(`Update vertices of far plane`);
186
+ this._engine._debugPushGroup?.(`Update vertices of far plane`);
187
187
  this._cs.dispatch(dispatchSize, dispatchSize, 1);
188
- this._engine._debugPopGroup();
188
+ this._engine._debugPopGroup?.();
189
189
  if (this._engine._enableGPUDebugMarkers) {
190
- this._engine._debugPopGroup();
190
+ this._engine._debugPopGroup?.();
191
191
  }
192
192
  this._firstUpdate = false;
193
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lightingVolume.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/lightingVolume.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,yBAAwB;AAC7C,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,gCAA+B;AACrE,OAAO,EAAE,gBAAgB,EAAE,8BAAqC;AAChE,OAAO,EAAE,IAAI,EAAE,0BAAyB;AACxC,OAAO,EAAE,aAAa,EAAE,oCAAmC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,wCAAuC;AACtE,OAAO,EAAE,aAAa,EAAE,sCAAqC;AAC7D,OAAO,EAAE,aAAa,EAAE,oCAAmC;AAC3D,OAAO,EAAE,WAAW,EAAE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G,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CAC7D,CAAC;oBACF,IAAI,CAAC,QAAQ,CAAC,IAAI,CACd,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,EAChD,eAAe,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,EAC1D,eAAe,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,CAAC,CACzD,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { AbstractEngine, Engine, Nullable, RenderTargetWrapper, Scene, ShadowGenerator, WebGPUEngine } from \"core/index\";\r\nimport { AbortError } from \"core/Misc/error\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Matrix, Vector3, TmpVectors } from \"core/Maths/math.vector\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { ComputeShader } from \"core/Compute/computeShader\";\r\nimport { CopyTextureToTexture } from \"core/Misc/copyTextureToTexture\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { StorageBuffer } from \"core/Buffers/storageBuffer\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\n\r\nimport \"core/ShadersWGSL/lightingVolume.compute\";\r\n\r\nconst TmpVec3 = new Vector3();\r\n\r\n/**\r\n * Class used to create a lighting volume from a directional light's shadow generator.\r\n */\r\nexport class LightingVolume {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _mesh: Mesh;\r\n private readonly _copyTexture?: CopyTextureToTexture;\r\n private readonly _uBuffer?: UniformBuffer;\r\n private readonly _buildFullVolume = true;\r\n private _name: string;\r\n private _cs?: ComputeShader;\r\n private _cs2?: ComputeShader;\r\n private _light?: DirectionalLight;\r\n private _fallbackTexture?: BaseTexture;\r\n private _storageBuffer?: StorageBuffer;\r\n private _depthCopy?: RenderTargetWrapper;\r\n private _readPixelPromise: Nullable<Promise<ArrayBufferView>> = null;\r\n private _readPixelAbortController: Nullable<AbortController> = null;\r\n private _numFrames = 0;\r\n private _firstUpdate = true;\r\n private _currentLightDirection = new Vector3();\r\n private _positions: Float32Array;\r\n private _indices: number[];\r\n private _needFullUpdateUBO = true;\r\n\r\n private _shadowGenerator?: ShadowGenerator;\r\n /**\r\n * The shadow generator used to create the lighting volume.\r\n */\r\n public get shadowGenerator() {\r\n return this._shadowGenerator!;\r\n }\r\n\r\n public set shadowGenerator(sg: ShadowGenerator) {\r\n const light = sg.getLight();\r\n\r\n if (!(light instanceof DirectionalLight)) {\r\n throw new Error(`LightingVolumeMesh ${this._name}: light must be a directional light`);\r\n }\r\n\r\n this._shadowGenerator = sg;\r\n this._light = light;\r\n\r\n this._updateGeometry();\r\n\r\n if (!this._engine.isWebGPU) {\r\n this._createFallbackTextures();\r\n }\r\n\r\n this._setComputeShaderInputs();\r\n }\r\n\r\n private _tesselation = 0;\r\n /**\r\n * The tesselation level of the lighting volume.\r\n */\r\n public get tesselation() {\r\n return this._tesselation;\r\n }\r\n\r\n public set tesselation(n: number) {\r\n this._tesselation = n;\r\n this._createGeometry();\r\n }\r\n\r\n /**\r\n * The mesh used as a support for the lighting volume.\r\n * Note that this mesh is not automatically added to the scene's mesh array.\r\n * If you want to render it, you need to add it manually.\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n private _frequency = 1;\r\n\r\n /**\r\n * The frequency (in number of times you call updateMesh) at which the lighting volume is updated.\r\n */\r\n public get frequency() {\r\n return this._frequency;\r\n }\r\n\r\n public set frequency(value: number) {\r\n this._frequency = value;\r\n this._firstUpdate = true;\r\n }\r\n\r\n /**\r\n * The name of the lighting volume.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(name: string) {\r\n this._name = name;\r\n if (this._mesh) {\r\n this._mesh.name = name;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates whether this is the first update of the lighting volume.\r\n * If true, the volume has not yet been updated for the first time.\r\n */\r\n public get firstUpdate() {\r\n return this._firstUpdate;\r\n }\r\n\r\n /** @internal */\r\n public _setComputeShaderFastMode(enabled: boolean) {\r\n if (this._cs) {\r\n this._cs.fastMode = enabled;\r\n this._cs.triggerContextRebuild = enabled;\r\n }\r\n if (this._cs2) {\r\n this._cs2.fastMode = enabled;\r\n this._cs2.triggerContextRebuild = enabled;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new LightingVolume.\r\n * @param name The name of the lighting volume.\r\n * @param scene The scene the lighting volume belongs to.\r\n * @param shadowGenerator The shadow generator used to create the lighting volume. This is optional in the constructor, but must be set before calling updateMesh.\r\n * @param tesselation The tesselation level of the lighting volume (default: 64).\r\n */\r\n constructor(name: string, scene: Scene, shadowGenerator?: ShadowGenerator, tesselation = 64) {\r\n const light = shadowGenerator ? shadowGenerator.getLight() : undefined;\r\n\r\n if (light && !(light instanceof DirectionalLight)) {\r\n throw new Error(`LightingVolumeMesh ${name}: light must be a directional light`);\r\n }\r\n\r\n this._name = name;\r\n this._shadowGenerator = shadowGenerator;\r\n this._light = light as DirectionalLight;\r\n this._indices = [];\r\n\r\n this._engine = scene.getEngine();\r\n this._scene = scene;\r\n\r\n this._mesh = new Mesh(name, this._scene);\r\n scene.meshes.splice(scene.meshes.indexOf(this._mesh), 1);\r\n\r\n if (this._engine.isWebGPU) {\r\n this._uBuffer = new UniformBuffer(this._engine);\r\n\r\n this._uBuffer.addUniform(\"invViewProjMatrix\", 16);\r\n this._uBuffer.addUniform(\"invViewMatrix\", 16);\r\n this._uBuffer.addUniform(\"startVertexIndex\", 1);\r\n this._uBuffer.addUniform(\"step\", 1);\r\n this._uBuffer.addUniform(\"tesselation\", 1);\r\n this._uBuffer.addUniform(\"orthoMin\", 3);\r\n this._uBuffer.addUniform(\"orthoMax\", 3);\r\n this._uBuffer.update();\r\n\r\n this._createComputeShader();\r\n } else {\r\n this._copyTexture = new CopyTextureToTexture(this._engine, false, true);\r\n this._createFallbackTextures();\r\n }\r\n\r\n this._tesselation = tesselation;\r\n this._createGeometry();\r\n }\r\n\r\n /**\r\n * Checks if the lighting volume is ready to be updated.\r\n * @returns True if the volume is ready to be updated.\r\n */\r\n public isReady() {\r\n let isReady = this._mesh.isReady(true);\r\n if (this._cs) {\r\n isReady = this._cs.isReady() && isReady;\r\n }\r\n if (this._cs2) {\r\n isReady = this._cs2.isReady() && isReady;\r\n }\r\n return isReady;\r\n }\r\n\r\n /**\r\n * Updates the lighting volume mesh.\r\n * @param forceUpdate If true, forces the update even if the frequency condition is not met.\r\n */\r\n public update(forceUpdate = false) {\r\n if (this._tesselation === 0 || !this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n if (!forceUpdate && !this._firstUpdate && (this.frequency === 0 || ++this._numFrames < this.frequency)) {\r\n return;\r\n }\r\n\r\n this._numFrames = 0;\r\n\r\n if (this._engine.isWebGPU) {\r\n this._uBuffer!.updateMatrix(\"invViewProjMatrix\", this._shadowGenerator.getTransformMatrix().invertToRef(TmpVectors.Matrix[0]));\r\n\r\n if (this._engine._enableGPUDebugMarkers) {\r\n this._engine.restoreDefaultFramebuffer();\r\n this._engine._debugPushGroup(`Update lighting volume (${this._name})`);\r\n }\r\n\r\n if (this._needUpdateGeometry()) {\r\n this._fullUpdateUBO(true);\r\n\r\n const dispatchSize = Math.ceil((this._tesselation + 1) / 32);\r\n\r\n this._engine._debugPushGroup(`Update vertices of other planes`);\r\n this._cs2!.dispatch(dispatchSize, 1, 1);\r\n this._engine._debugPopGroup();\r\n } else {\r\n this._fullUpdateUBO();\r\n }\r\n\r\n const dispatchSize = Math.ceil((this._tesselation + 1) / 8);\r\n\r\n this._engine._debugPushGroup(`Update vertices of far plane`);\r\n this._cs!.dispatch(dispatchSize, dispatchSize, 1);\r\n this._engine._debugPopGroup();\r\n\r\n if (this._engine._enableGPUDebugMarkers) {\r\n this._engine._debugPopGroup();\r\n }\r\n\r\n this._firstUpdate = false;\r\n } else {\r\n try {\r\n void this._fallbackReadPixelAsync();\r\n } catch {\r\n this._readPixelPromise = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the lighting volume and associated resources.\r\n */\r\n public dispose() {\r\n this._readPixelAbortController?.abort(new AbortError(\"LightingVolume is disposed\"));\r\n this._readPixelAbortController = null;\r\n this._mesh.dispose();\r\n if (this._fallbackTexture) {\r\n this._fallbackTexture._texture = null;\r\n }\r\n this._fallbackTexture?.dispose();\r\n this._copyTexture?.dispose();\r\n this._storageBuffer?.dispose();\r\n this._uBuffer?.dispose();\r\n this._depthCopy?.dispose();\r\n }\r\n\r\n private _needUpdateGeometry() {\r\n if (this._cs?.triggerContextRebuild || (this._light && !this._currentLightDirection.equals(this._light.direction))) {\r\n this._currentLightDirection.copyFrom(this._light!.direction);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _createComputeShader() {\r\n this._cs = new ComputeShader(\"updateFarPlaneVertices\", this._engine, \"lightingVolume\", {\r\n bindingsMapping: {\r\n shadowMap: { group: 0, binding: 0 },\r\n params: { group: 0, binding: 1 },\r\n positions: { group: 0, binding: 2 },\r\n },\r\n defines: !this._buildFullVolume ? [\"#define KEEP_EDGES\", \"#define MOVE_FAR_DEPTH_TO_NEAR\"] : undefined,\r\n entryPoint: \"updateFarPlaneVertices\",\r\n });\r\n\r\n this._cs2 = new ComputeShader(\"updatePlaneVertices\", this._engine, \"lightingVolume\", {\r\n bindingsMapping: {\r\n shadowMap: { group: 0, binding: 0 },\r\n params: { group: 0, binding: 1 },\r\n positions: { group: 0, binding: 2 },\r\n },\r\n entryPoint: \"updatePlaneVertices\",\r\n });\r\n\r\n this._setComputeShaderInputs();\r\n }\r\n\r\n private _setComputeShaderInputs() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (this._shadowGenerator) {\r\n const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;\r\n if (depthTexture) {\r\n this._cs?.setInternalTexture(\"shadowMap\", depthTexture);\r\n this._cs2?.setInternalTexture(\"shadowMap\", depthTexture);\r\n }\r\n }\r\n\r\n if (this._uBuffer) {\r\n this._cs?.setUniformBuffer(\"params\", this._uBuffer);\r\n this._cs2?.setUniformBuffer(\"params\", this._uBuffer);\r\n }\r\n if (this._storageBuffer) {\r\n this._cs?.setStorageBuffer(\"positions\", this._storageBuffer);\r\n this._cs2?.setStorageBuffer(\"positions\", this._storageBuffer);\r\n }\r\n }\r\n\r\n private _createFallbackTextures() {\r\n if (!this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n this._readPixelAbortController?.abort(new AbortError(\"Fallback textures are being (re)created\"));\r\n this._readPixelAbortController = new AbortController();\r\n\r\n const mapSize = this._shadowGenerator.mapSize;\r\n\r\n this._depthCopy?.dispose();\r\n this._depthCopy = this._engine.createRenderTargetTexture(\r\n { width: mapSize, height: mapSize },\r\n {\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RED,\r\n samples: 1,\r\n label: `${this._name} - fallback internal texture`,\r\n generateDepthBuffer: false,\r\n }\r\n );\r\n\r\n this._fallbackTexture?.dispose();\r\n this._fallbackTexture = new BaseTexture(this._scene, this._depthCopy.texture);\r\n this._fallbackTexture.name = `${this._name} - fallback texture`;\r\n }\r\n\r\n private async _fallbackReadPixelAsync() {\r\n if (this._readPixelPromise || !this._fallbackTexture || !this._copyTexture) {\r\n return;\r\n }\r\n\r\n const abortController = this._readPixelAbortController;\r\n\r\n abortController?.signal.throwIfAborted();\r\n\r\n const engine = this._engine as Engine;\r\n\r\n const shadowGenerator = this._shadowGenerator;\r\n const shadowMapDepthTexture = shadowGenerator?.getShadowMap()?.depthStencilTexture;\r\n\r\n if (!shadowMapDepthTexture) {\r\n return;\r\n }\r\n\r\n // Copies the shadow map of the shadow generator into _depthCopy\r\n // That's because we can't read from a depth attachment texture in WebGL. We must first copy it to a regular texture.\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_NEAREST_SAMPLINGMODE, shadowMapDepthTexture);\r\n engine.updateTextureComparisonFunction(shadowMapDepthTexture, 0);\r\n\r\n this._copyTexture.copy(shadowMapDepthTexture, this._depthCopy);\r\n\r\n engine.updateTextureComparisonFunction(shadowMapDepthTexture, Constants.LESS);\r\n\r\n // Gets the texture from GPU to CPU\r\n this._readPixelPromise = this._fallbackTexture.readPixels(0, 0, undefined, true, false);\r\n if (!this._readPixelPromise) {\r\n return;\r\n }\r\n\r\n const buffer = await this._readPixelPromise;\r\n\r\n abortController?.signal.throwIfAborted();\r\n\r\n const depthValues = buffer as Float32Array;\r\n const positions = this._mesh.getVerticesData(\"position\");\r\n const numTesselation = this._tesselation;\r\n const startPos = this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3;\r\n const mapSize = shadowGenerator.mapSize;\r\n const step = (mapSize - 1) / numTesselation;\r\n\r\n if (!positions) {\r\n this._readPixelPromise = null;\r\n return;\r\n }\r\n\r\n const halfTesselation = numTesselation / 2;\r\n\r\n const invViewProjMatrix = shadowGenerator.getTransformMatrix().clone();\r\n invViewProjMatrix.invertToRef(invViewProjMatrix);\r\n\r\n const factor = 4;\r\n\r\n if (this._needUpdateGeometry()) {\r\n this._updateGeometry();\r\n }\r\n\r\n let posIndex = startPos;\r\n let stepY = 0;\r\n for (let y = 0; y < numTesselation + 1; ++y) {\r\n for (let x = 0; x < numTesselation + 1; ++x) {\r\n let depth = depthValues[Math.floor(mapSize * Math.floor(stepY) + x * step) * factor];\r\n if (!this._buildFullVolume) {\r\n if (y === 0 || x === 0 || y === numTesselation || x === numTesselation) {\r\n posIndex += 3;\r\n continue;\r\n }\r\n if (depth === 1) {\r\n depth = 0;\r\n }\r\n }\r\n\r\n TmpVec3.set((x - halfTesselation) / halfTesselation, (y - halfTesselation) / halfTesselation, -1 + 2 * depth);\r\n\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewProjMatrix, TmpVec3);\r\n\r\n positions[posIndex] = TmpVec3.x;\r\n positions[posIndex + 1] = TmpVec3.y;\r\n positions[posIndex + 2] = TmpVec3.z;\r\n posIndex += 3;\r\n }\r\n stepY += step;\r\n }\r\n\r\n this._mesh.setVerticesData(\"position\", positions);\r\n\r\n this._readPixelPromise = null;\r\n this._firstUpdate = false;\r\n }\r\n\r\n private _fullUpdateUBO(force = false) {\r\n const light = this._light;\r\n\r\n if ((!force && !this._needFullUpdateUBO) || !light || !this._shadowGenerator) {\r\n this._uBuffer!.update();\r\n return;\r\n }\r\n\r\n this._needFullUpdateUBO = false;\r\n\r\n const numTesselation = this._tesselation;\r\n const min = TmpVectors.Vector3[0].set(light.orthoLeft, light.orthoBottom, light.shadowMinZ ?? Constants.ShadowMinZ);\r\n const max = TmpVectors.Vector3[1].set(light.orthoRight, light.orthoTop, light.shadowMaxZ ?? Constants.ShadowMaxZ);\r\n\r\n const invViewMatrix = this._shadowGenerator.viewMatrix.invertToRef(TmpVectors.Matrix[1]);\r\n\r\n this._uBuffer!.updateUInt(\"startVertexIndex\", this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3);\r\n this._uBuffer!.updateFloat(\"step\", ((this._shadowGenerator?.mapSize ?? 128) - 1) / numTesselation);\r\n this._uBuffer!.updateUInt(\"tesselation\", numTesselation);\r\n this._uBuffer!.updateVector3(\"orthoMin\", min);\r\n this._uBuffer!.updateVector3(\"orthoMax\", max);\r\n this._uBuffer!.updateMatrix(\"invViewMatrix\", invViewMatrix);\r\n this._uBuffer!.update();\r\n }\r\n\r\n private _createGeometry() {\r\n const light = this._light;\r\n\r\n if (!light) {\r\n return;\r\n }\r\n\r\n this._tesselation = Math.max(Math.ceil(this._tesselation) & ~1, 2);\r\n\r\n const numTesselation = this._tesselation;\r\n const vertexNumber = (numTesselation + 1) * (numTesselation + 1) + (this._buildFullVolume ? (numTesselation + 1) * 4 : 4);\r\n\r\n this._positions = new Float32Array(vertexNumber * 3);\r\n this._indices.length = 0;\r\n\r\n this._createIndices(light);\r\n\r\n this._mesh.setIndices(this._indices, vertexNumber);\r\n\r\n if (this._engine.isWebGPU) {\r\n const webGPUEngine = this._engine as WebGPUEngine;\r\n\r\n this._storageBuffer?.dispose();\r\n this._storageBuffer = new StorageBuffer(webGPUEngine, vertexNumber * 3 * 4, Constants.BUFFER_CREATIONFLAG_VERTEX | Constants.BUFFER_CREATIONFLAG_READWRITE);\r\n\r\n this._mesh.setVerticesBuffer(new VertexBuffer(webGPUEngine, this._storageBuffer.getBuffer(), \"position\", { takeBufferOwnership: false }), true, vertexNumber);\r\n\r\n this._setComputeShaderInputs();\r\n\r\n this._cs!.triggerContextRebuild = true;\r\n this._cs2!.triggerContextRebuild = true;\r\n\r\n this._needFullUpdateUBO = true;\r\n }\r\n\r\n this._updateGeometry();\r\n }\r\n\r\n private _updateGeometry() {\r\n const light = this._light;\r\n\r\n if (!light || !this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n if (this._indices.length === 0) {\r\n this._createGeometry();\r\n return;\r\n }\r\n\r\n if (this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const numTesselation = this._tesselation;\r\n\r\n const min = TmpVectors.Vector3[0].set(light.orthoLeft, light.orthoBottom, light.shadowMinZ ?? Constants.ShadowMinZ);\r\n const max = TmpVectors.Vector3[1].set(light.orthoRight, light.orthoTop, light.shadowMaxZ ?? Constants.ShadowMaxZ);\r\n\r\n const invViewMatrix = this._shadowGenerator.viewMatrix.invertToRef(TmpVectors.Matrix[1]);\r\n\r\n const stepX = (max.x - min.x) / numTesselation;\r\n const stepY = (max.y - min.y) / numTesselation;\r\n\r\n let vIndex = 0;\r\n\r\n if (this._buildFullVolume) {\r\n // Right faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(max.x, min.y + i * stepY, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Left faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x, min.y + i * stepY, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Bottom faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x + i * stepX, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Top faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x + i * stepX, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n } else {\r\n // Closes the volume with two near triangles\r\n TmpVec3.set(max.x, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(max.x, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(min.x, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(min.x, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n this._mesh.setVerticesData(\"position\", this._positions);\r\n }\r\n\r\n private _createIndices(light: DirectionalLight) {\r\n const invViewMatrix = Matrix.LookAtLH(light.position, light.position.add(light.direction), Vector3.UpReadOnly);\r\n invViewMatrix.invertToRef(invViewMatrix);\r\n\r\n const numTesselation = this._tesselation;\r\n\r\n const startFarIndices = this._buildFullVolume ? (numTesselation + 1) * 4 : 4;\r\n\r\n if (this._buildFullVolume) {\r\n const rightFaceStartIndex = 0;\r\n\r\n // Right faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(\r\n rightFaceStartIndex + i,\r\n startFarIndices + numTesselation + (i + 1) * (numTesselation + 1),\r\n startFarIndices + numTesselation + i * (numTesselation + 1)\r\n );\r\n this._indices.push(rightFaceStartIndex + i, rightFaceStartIndex + i + 1, startFarIndices + numTesselation + (i + 1) * (numTesselation + 1));\r\n }\r\n }\r\n\r\n const leftFaceStartIndex = rightFaceStartIndex + numTesselation + 1;\r\n\r\n // Left faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(leftFaceStartIndex + i, startFarIndices + 0 + i * (numTesselation + 1), startFarIndices + 0 + (i + 1) * (numTesselation + 1));\r\n this._indices.push(leftFaceStartIndex + i, startFarIndices + 0 + (i + 1) * (numTesselation + 1), leftFaceStartIndex + i + 1);\r\n }\r\n }\r\n\r\n const bottomFaceStartIndex = leftFaceStartIndex + numTesselation + 1;\r\n\r\n // Bottom faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(bottomFaceStartIndex + i, bottomFaceStartIndex + i + 1, startFarIndices + i + 0 * (numTesselation + 1));\r\n this._indices.push(bottomFaceStartIndex + i + 1, startFarIndices + i + 1 + 0 * (numTesselation + 1), startFarIndices + i + 0 * (numTesselation + 1));\r\n }\r\n }\r\n\r\n const topFaceStartIndex = bottomFaceStartIndex + numTesselation + 1;\r\n\r\n // Top faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(topFaceStartIndex + i, startFarIndices + i + numTesselation * (numTesselation + 1), topFaceStartIndex + i + 1);\r\n this._indices.push(\r\n topFaceStartIndex + i + 1,\r\n startFarIndices + i + numTesselation * (numTesselation + 1),\r\n startFarIndices + i + 1 + numTesselation * (numTesselation + 1)\r\n );\r\n }\r\n }\r\n\r\n // Near faces of the frustum\r\n for (let i = 0; i < numTesselation; ++i) {\r\n this._indices.push(leftFaceStartIndex + i, leftFaceStartIndex + i + 1, topFaceStartIndex + numTesselation - i);\r\n if (i < numTesselation - 1) {\r\n this._indices.push(leftFaceStartIndex + i + 1, topFaceStartIndex + numTesselation - i - 1, topFaceStartIndex + numTesselation - i);\r\n }\r\n }\r\n\r\n for (let i = 0; i < numTesselation; ++i) {\r\n this._indices.push(bottomFaceStartIndex + i, rightFaceStartIndex + numTesselation - i, rightFaceStartIndex + numTesselation - i - 1);\r\n if (i < numTesselation - 1) {\r\n this._indices.push(bottomFaceStartIndex + i, rightFaceStartIndex + numTesselation - i - 1, bottomFaceStartIndex + i + 1);\r\n }\r\n }\r\n } else {\r\n this._indices.push(0, 2, 1);\r\n this._indices.push(2, 3, 1);\r\n }\r\n\r\n // Tesselate the far plane\r\n for (let iy = 0; iy <= numTesselation; ++iy) {\r\n for (let ix = 0; ix <= numTesselation; ++ix) {\r\n if (ix < numTesselation && iy < numTesselation) {\r\n this._indices.push(\r\n startFarIndices + ix + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1)\r\n );\r\n this._indices.push(\r\n startFarIndices + ix + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1),\r\n startFarIndices + ix + (iy + 1) * (numTesselation + 1)\r\n );\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"lightingVolume.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/lightingVolume.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,yBAAwB;AAC7C,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,gCAA+B;AACrE,OAAO,EAAE,gBAAgB,EAAE,8BAAqC;AAChE,OAAO,EAAE,IAAI,EAAE,0BAAyB;AACxC,OAAO,EAAE,aAAa,EAAE,oCAAmC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,wCAAuC;AACtE,OAAO,EAAE,aAAa,EAAE,sCAAqC;AAC7D,OAAO,EAAE,aAAa,EAAE,oCAAmC;AAC3D,OAAO,EAAE,WAAW,EAAE,6CAA4C;AAClE,OAAO,EAAE,YAAY,EAAE,6BAA4B;AAEnD,kDAAiD;AAEjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B;;GAEG;AACH,MAAM,OAAO,cAAc;IAwBvB;;OAEG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC,gBAAiB,CAAC;IAClC,CAAC;IAED,IAAW,eAAe,CAAC,EAAmB;QAC1C,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAE5B,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC,EAAE,CAAC;YACvC,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cAAc,GAAG,CAAC,CAAC,CACzD,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { AbstractEngine, Engine, Nullable, RenderTargetWrapper, Scene, ShadowGenerator, WebGPUEngine } from \"core/index\";\r\nimport { AbortError } from \"core/Misc/error\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Matrix, Vector3, TmpVectors } from \"core/Maths/math.vector\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { ComputeShader } from \"core/Compute/computeShader\";\r\nimport { CopyTextureToTexture } from \"core/Misc/copyTextureToTexture\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { StorageBuffer } from \"core/Buffers/storageBuffer\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\n\r\nimport \"core/ShadersWGSL/lightingVolume.compute\";\r\n\r\nconst TmpVec3 = new Vector3();\r\n\r\n/**\r\n * Class used to create a lighting volume from a directional light's shadow generator.\r\n */\r\nexport class LightingVolume {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _mesh: Mesh;\r\n private readonly _copyTexture?: CopyTextureToTexture;\r\n private readonly _uBuffer?: UniformBuffer;\r\n private readonly _buildFullVolume = true;\r\n private _name: string;\r\n private _cs?: ComputeShader;\r\n private _cs2?: ComputeShader;\r\n private _light?: DirectionalLight;\r\n private _fallbackTexture?: BaseTexture;\r\n private _storageBuffer?: StorageBuffer;\r\n private _depthCopy?: RenderTargetWrapper;\r\n private _readPixelPromise: Nullable<Promise<ArrayBufferView>> = null;\r\n private _readPixelAbortController: Nullable<AbortController> = null;\r\n private _numFrames = 0;\r\n private _firstUpdate = true;\r\n private _currentLightDirection = new Vector3();\r\n private _positions: Float32Array;\r\n private _indices: number[];\r\n private _needFullUpdateUBO = true;\r\n\r\n private _shadowGenerator?: ShadowGenerator;\r\n /**\r\n * The shadow generator used to create the lighting volume.\r\n */\r\n public get shadowGenerator() {\r\n return this._shadowGenerator!;\r\n }\r\n\r\n public set shadowGenerator(sg: ShadowGenerator) {\r\n const light = sg.getLight();\r\n\r\n if (!(light instanceof DirectionalLight)) {\r\n throw new Error(`LightingVolumeMesh ${this._name}: light must be a directional light`);\r\n }\r\n\r\n this._shadowGenerator = sg;\r\n this._light = light;\r\n\r\n this._updateGeometry();\r\n\r\n if (!this._engine.isWebGPU) {\r\n this._createFallbackTextures();\r\n }\r\n\r\n this._setComputeShaderInputs();\r\n }\r\n\r\n private _tesselation = 0;\r\n /**\r\n * The tesselation level of the lighting volume.\r\n */\r\n public get tesselation() {\r\n return this._tesselation;\r\n }\r\n\r\n public set tesselation(n: number) {\r\n this._tesselation = n;\r\n this._createGeometry();\r\n }\r\n\r\n /**\r\n * The mesh used as a support for the lighting volume.\r\n * Note that this mesh is not automatically added to the scene's mesh array.\r\n * If you want to render it, you need to add it manually.\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n private _frequency = 1;\r\n\r\n /**\r\n * The frequency (in number of times you call updateMesh) at which the lighting volume is updated.\r\n */\r\n public get frequency() {\r\n return this._frequency;\r\n }\r\n\r\n public set frequency(value: number) {\r\n this._frequency = value;\r\n this._firstUpdate = true;\r\n }\r\n\r\n /**\r\n * The name of the lighting volume.\r\n */\r\n public get name() {\r\n return this._name;\r\n }\r\n\r\n public set name(name: string) {\r\n this._name = name;\r\n if (this._mesh) {\r\n this._mesh.name = name;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates whether this is the first update of the lighting volume.\r\n * If true, the volume has not yet been updated for the first time.\r\n */\r\n public get firstUpdate() {\r\n return this._firstUpdate;\r\n }\r\n\r\n /** @internal */\r\n public _setComputeShaderFastMode(enabled: boolean) {\r\n if (this._cs) {\r\n this._cs.fastMode = enabled;\r\n this._cs.triggerContextRebuild = enabled;\r\n }\r\n if (this._cs2) {\r\n this._cs2.fastMode = enabled;\r\n this._cs2.triggerContextRebuild = enabled;\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new LightingVolume.\r\n * @param name The name of the lighting volume.\r\n * @param scene The scene the lighting volume belongs to.\r\n * @param shadowGenerator The shadow generator used to create the lighting volume. This is optional in the constructor, but must be set before calling updateMesh.\r\n * @param tesselation The tesselation level of the lighting volume (default: 64).\r\n */\r\n constructor(name: string, scene: Scene, shadowGenerator?: ShadowGenerator, tesselation = 64) {\r\n const light = shadowGenerator ? shadowGenerator.getLight() : undefined;\r\n\r\n if (light && !(light instanceof DirectionalLight)) {\r\n throw new Error(`LightingVolumeMesh ${name}: light must be a directional light`);\r\n }\r\n\r\n this._name = name;\r\n this._shadowGenerator = shadowGenerator;\r\n this._light = light as DirectionalLight;\r\n this._indices = [];\r\n\r\n this._engine = scene.getEngine();\r\n this._scene = scene;\r\n\r\n this._mesh = new Mesh(name, this._scene);\r\n scene.meshes.splice(scene.meshes.indexOf(this._mesh), 1);\r\n\r\n if (this._engine.isWebGPU) {\r\n this._uBuffer = new UniformBuffer(this._engine);\r\n\r\n this._uBuffer.addUniform(\"invViewProjMatrix\", 16);\r\n this._uBuffer.addUniform(\"invViewMatrix\", 16);\r\n this._uBuffer.addUniform(\"startVertexIndex\", 1);\r\n this._uBuffer.addUniform(\"step\", 1);\r\n this._uBuffer.addUniform(\"tesselation\", 1);\r\n this._uBuffer.addUniform(\"orthoMin\", 3);\r\n this._uBuffer.addUniform(\"orthoMax\", 3);\r\n this._uBuffer.update();\r\n\r\n this._createComputeShader();\r\n } else {\r\n this._copyTexture = new CopyTextureToTexture(this._engine, false, true);\r\n this._createFallbackTextures();\r\n }\r\n\r\n this._tesselation = tesselation;\r\n this._createGeometry();\r\n }\r\n\r\n /**\r\n * Checks if the lighting volume is ready to be updated.\r\n * @returns True if the volume is ready to be updated.\r\n */\r\n public isReady() {\r\n let isReady = this._mesh.isReady(true);\r\n if (this._cs) {\r\n isReady = this._cs.isReady() && isReady;\r\n }\r\n if (this._cs2) {\r\n isReady = this._cs2.isReady() && isReady;\r\n }\r\n return isReady;\r\n }\r\n\r\n /**\r\n * Updates the lighting volume mesh.\r\n * @param forceUpdate If true, forces the update even if the frequency condition is not met.\r\n */\r\n public update(forceUpdate = false) {\r\n if (this._tesselation === 0 || !this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n if (!forceUpdate && !this._firstUpdate && (this.frequency === 0 || ++this._numFrames < this.frequency)) {\r\n return;\r\n }\r\n\r\n this._numFrames = 0;\r\n\r\n if (this._engine.isWebGPU) {\r\n this._uBuffer!.updateMatrix(\"invViewProjMatrix\", this._shadowGenerator.getTransformMatrix().invertToRef(TmpVectors.Matrix[0]));\r\n\r\n if (this._engine._enableGPUDebugMarkers) {\r\n this._engine.restoreDefaultFramebuffer();\r\n this._engine._debugPushGroup?.(`Update lighting volume (${this._name})`);\r\n }\r\n\r\n if (this._needUpdateGeometry()) {\r\n this._fullUpdateUBO(true);\r\n\r\n const dispatchSize = Math.ceil((this._tesselation + 1) / 32);\r\n\r\n this._engine._debugPushGroup?.(`Update vertices of other planes`);\r\n this._cs2!.dispatch(dispatchSize, 1, 1);\r\n this._engine._debugPopGroup?.();\r\n } else {\r\n this._fullUpdateUBO();\r\n }\r\n\r\n const dispatchSize = Math.ceil((this._tesselation + 1) / 8);\r\n\r\n this._engine._debugPushGroup?.(`Update vertices of far plane`);\r\n this._cs!.dispatch(dispatchSize, dispatchSize, 1);\r\n this._engine._debugPopGroup?.();\r\n\r\n if (this._engine._enableGPUDebugMarkers) {\r\n this._engine._debugPopGroup?.();\r\n }\r\n\r\n this._firstUpdate = false;\r\n } else {\r\n try {\r\n void this._fallbackReadPixelAsync();\r\n } catch {\r\n this._readPixelPromise = null;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the lighting volume and associated resources.\r\n */\r\n public dispose() {\r\n this._readPixelAbortController?.abort(new AbortError(\"LightingVolume is disposed\"));\r\n this._readPixelAbortController = null;\r\n this._mesh.dispose();\r\n if (this._fallbackTexture) {\r\n this._fallbackTexture._texture = null;\r\n }\r\n this._fallbackTexture?.dispose();\r\n this._copyTexture?.dispose();\r\n this._storageBuffer?.dispose();\r\n this._uBuffer?.dispose();\r\n this._depthCopy?.dispose();\r\n }\r\n\r\n private _needUpdateGeometry() {\r\n if (this._cs?.triggerContextRebuild || (this._light && !this._currentLightDirection.equals(this._light.direction))) {\r\n this._currentLightDirection.copyFrom(this._light!.direction);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _createComputeShader() {\r\n this._cs = new ComputeShader(\"updateFarPlaneVertices\", this._engine, \"lightingVolume\", {\r\n bindingsMapping: {\r\n shadowMap: { group: 0, binding: 0 },\r\n params: { group: 0, binding: 1 },\r\n positions: { group: 0, binding: 2 },\r\n },\r\n defines: !this._buildFullVolume ? [\"#define KEEP_EDGES\", \"#define MOVE_FAR_DEPTH_TO_NEAR\"] : undefined,\r\n entryPoint: \"updateFarPlaneVertices\",\r\n });\r\n\r\n this._cs2 = new ComputeShader(\"updatePlaneVertices\", this._engine, \"lightingVolume\", {\r\n bindingsMapping: {\r\n shadowMap: { group: 0, binding: 0 },\r\n params: { group: 0, binding: 1 },\r\n positions: { group: 0, binding: 2 },\r\n },\r\n entryPoint: \"updatePlaneVertices\",\r\n });\r\n\r\n this._setComputeShaderInputs();\r\n }\r\n\r\n private _setComputeShaderInputs() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (this._shadowGenerator) {\r\n const depthTexture = this._shadowGenerator.getShadowMap()?.depthStencilTexture;\r\n if (depthTexture) {\r\n this._cs?.setInternalTexture(\"shadowMap\", depthTexture);\r\n this._cs2?.setInternalTexture(\"shadowMap\", depthTexture);\r\n }\r\n }\r\n\r\n if (this._uBuffer) {\r\n this._cs?.setUniformBuffer(\"params\", this._uBuffer);\r\n this._cs2?.setUniformBuffer(\"params\", this._uBuffer);\r\n }\r\n if (this._storageBuffer) {\r\n this._cs?.setStorageBuffer(\"positions\", this._storageBuffer);\r\n this._cs2?.setStorageBuffer(\"positions\", this._storageBuffer);\r\n }\r\n }\r\n\r\n private _createFallbackTextures() {\r\n if (!this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n this._readPixelAbortController?.abort(new AbortError(\"Fallback textures are being (re)created\"));\r\n this._readPixelAbortController = new AbortController();\r\n\r\n const mapSize = this._shadowGenerator.mapSize;\r\n\r\n this._depthCopy?.dispose();\r\n this._depthCopy = this._engine.createRenderTargetTexture(\r\n { width: mapSize, height: mapSize },\r\n {\r\n type: Constants.TEXTURETYPE_FLOAT,\r\n format: Constants.TEXTUREFORMAT_RED,\r\n samples: 1,\r\n label: `${this._name} - fallback internal texture`,\r\n generateDepthBuffer: false,\r\n }\r\n );\r\n\r\n this._fallbackTexture?.dispose();\r\n this._fallbackTexture = new BaseTexture(this._scene, this._depthCopy.texture);\r\n this._fallbackTexture.name = `${this._name} - fallback texture`;\r\n }\r\n\r\n private async _fallbackReadPixelAsync() {\r\n if (this._readPixelPromise || !this._fallbackTexture || !this._copyTexture) {\r\n return;\r\n }\r\n\r\n const abortController = this._readPixelAbortController;\r\n\r\n abortController?.signal.throwIfAborted();\r\n\r\n const engine = this._engine as Engine;\r\n\r\n const shadowGenerator = this._shadowGenerator;\r\n const shadowMapDepthTexture = shadowGenerator?.getShadowMap()?.depthStencilTexture;\r\n\r\n if (!shadowMapDepthTexture) {\r\n return;\r\n }\r\n\r\n // Copies the shadow map of the shadow generator into _depthCopy\r\n // That's because we can't read from a depth attachment texture in WebGL. We must first copy it to a regular texture.\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_NEAREST_SAMPLINGMODE, shadowMapDepthTexture);\r\n engine.updateTextureComparisonFunction(shadowMapDepthTexture, 0);\r\n\r\n this._copyTexture.copy(shadowMapDepthTexture, this._depthCopy);\r\n\r\n engine.updateTextureComparisonFunction(shadowMapDepthTexture, Constants.LESS);\r\n\r\n // Gets the texture from GPU to CPU\r\n this._readPixelPromise = this._fallbackTexture.readPixels(0, 0, undefined, true, false);\r\n if (!this._readPixelPromise) {\r\n return;\r\n }\r\n\r\n const buffer = await this._readPixelPromise;\r\n\r\n abortController?.signal.throwIfAborted();\r\n\r\n const depthValues = buffer as Float32Array;\r\n const positions = this._mesh.getVerticesData(\"position\");\r\n const numTesselation = this._tesselation;\r\n const startPos = this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3;\r\n const mapSize = shadowGenerator.mapSize;\r\n const step = (mapSize - 1) / numTesselation;\r\n\r\n if (!positions) {\r\n this._readPixelPromise = null;\r\n return;\r\n }\r\n\r\n const halfTesselation = numTesselation / 2;\r\n\r\n const invViewProjMatrix = shadowGenerator.getTransformMatrix().clone();\r\n invViewProjMatrix.invertToRef(invViewProjMatrix);\r\n\r\n const factor = 4;\r\n\r\n if (this._needUpdateGeometry()) {\r\n this._updateGeometry();\r\n }\r\n\r\n let posIndex = startPos;\r\n let stepY = 0;\r\n for (let y = 0; y < numTesselation + 1; ++y) {\r\n for (let x = 0; x < numTesselation + 1; ++x) {\r\n let depth = depthValues[Math.floor(mapSize * Math.floor(stepY) + x * step) * factor];\r\n if (!this._buildFullVolume) {\r\n if (y === 0 || x === 0 || y === numTesselation || x === numTesselation) {\r\n posIndex += 3;\r\n continue;\r\n }\r\n if (depth === 1) {\r\n depth = 0;\r\n }\r\n }\r\n\r\n TmpVec3.set((x - halfTesselation) / halfTesselation, (y - halfTesselation) / halfTesselation, -1 + 2 * depth);\r\n\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewProjMatrix, TmpVec3);\r\n\r\n positions[posIndex] = TmpVec3.x;\r\n positions[posIndex + 1] = TmpVec3.y;\r\n positions[posIndex + 2] = TmpVec3.z;\r\n posIndex += 3;\r\n }\r\n stepY += step;\r\n }\r\n\r\n this._mesh.setVerticesData(\"position\", positions);\r\n\r\n this._readPixelPromise = null;\r\n this._firstUpdate = false;\r\n }\r\n\r\n private _fullUpdateUBO(force = false) {\r\n const light = this._light;\r\n\r\n if ((!force && !this._needFullUpdateUBO) || !light || !this._shadowGenerator) {\r\n this._uBuffer!.update();\r\n return;\r\n }\r\n\r\n this._needFullUpdateUBO = false;\r\n\r\n const numTesselation = this._tesselation;\r\n const min = TmpVectors.Vector3[0].set(light.orthoLeft, light.orthoBottom, light.shadowMinZ ?? Constants.ShadowMinZ);\r\n const max = TmpVectors.Vector3[1].set(light.orthoRight, light.orthoTop, light.shadowMaxZ ?? Constants.ShadowMaxZ);\r\n\r\n const invViewMatrix = this._shadowGenerator.viewMatrix.invertToRef(TmpVectors.Matrix[1]);\r\n\r\n this._uBuffer!.updateUInt(\"startVertexIndex\", this._buildFullVolume ? (numTesselation + 1) * 4 * 3 : 4 * 3);\r\n this._uBuffer!.updateFloat(\"step\", ((this._shadowGenerator?.mapSize ?? 128) - 1) / numTesselation);\r\n this._uBuffer!.updateUInt(\"tesselation\", numTesselation);\r\n this._uBuffer!.updateVector3(\"orthoMin\", min);\r\n this._uBuffer!.updateVector3(\"orthoMax\", max);\r\n this._uBuffer!.updateMatrix(\"invViewMatrix\", invViewMatrix);\r\n this._uBuffer!.update();\r\n }\r\n\r\n private _createGeometry() {\r\n const light = this._light;\r\n\r\n if (!light) {\r\n return;\r\n }\r\n\r\n this._tesselation = Math.max(Math.ceil(this._tesselation) & ~1, 2);\r\n\r\n const numTesselation = this._tesselation;\r\n const vertexNumber = (numTesselation + 1) * (numTesselation + 1) + (this._buildFullVolume ? (numTesselation + 1) * 4 : 4);\r\n\r\n this._positions = new Float32Array(vertexNumber * 3);\r\n this._indices.length = 0;\r\n\r\n this._createIndices(light);\r\n\r\n this._mesh.setIndices(this._indices, vertexNumber);\r\n\r\n if (this._engine.isWebGPU) {\r\n const webGPUEngine = this._engine as WebGPUEngine;\r\n\r\n this._storageBuffer?.dispose();\r\n this._storageBuffer = new StorageBuffer(webGPUEngine, vertexNumber * 3 * 4, Constants.BUFFER_CREATIONFLAG_VERTEX | Constants.BUFFER_CREATIONFLAG_READWRITE);\r\n\r\n this._mesh.setVerticesBuffer(new VertexBuffer(webGPUEngine, this._storageBuffer.getBuffer(), \"position\", { takeBufferOwnership: false }), true, vertexNumber);\r\n\r\n this._setComputeShaderInputs();\r\n\r\n this._cs!.triggerContextRebuild = true;\r\n this._cs2!.triggerContextRebuild = true;\r\n\r\n this._needFullUpdateUBO = true;\r\n }\r\n\r\n this._updateGeometry();\r\n }\r\n\r\n private _updateGeometry() {\r\n const light = this._light;\r\n\r\n if (!light || !this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n if (this._indices.length === 0) {\r\n this._createGeometry();\r\n return;\r\n }\r\n\r\n if (this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const numTesselation = this._tesselation;\r\n\r\n const min = TmpVectors.Vector3[0].set(light.orthoLeft, light.orthoBottom, light.shadowMinZ ?? Constants.ShadowMinZ);\r\n const max = TmpVectors.Vector3[1].set(light.orthoRight, light.orthoTop, light.shadowMaxZ ?? Constants.ShadowMaxZ);\r\n\r\n const invViewMatrix = this._shadowGenerator.viewMatrix.invertToRef(TmpVectors.Matrix[1]);\r\n\r\n const stepX = (max.x - min.x) / numTesselation;\r\n const stepY = (max.y - min.y) / numTesselation;\r\n\r\n let vIndex = 0;\r\n\r\n if (this._buildFullVolume) {\r\n // Right faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(max.x, min.y + i * stepY, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Left faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x, min.y + i * stepY, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Bottom faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x + i * stepX, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n // Top faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n TmpVec3.set(min.x + i * stepX, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n } else {\r\n // Closes the volume with two near triangles\r\n TmpVec3.set(max.x, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(max.x, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(min.x, min.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n\r\n TmpVec3.set(min.x, max.y, min.z);\r\n Vector3.TransformCoordinatesToRef(TmpVec3, invViewMatrix, TmpVec3);\r\n this._positions[vIndex++] = TmpVec3.x;\r\n this._positions[vIndex++] = TmpVec3.y;\r\n this._positions[vIndex++] = TmpVec3.z;\r\n }\r\n\r\n this._mesh.setVerticesData(\"position\", this._positions);\r\n }\r\n\r\n private _createIndices(light: DirectionalLight) {\r\n const invViewMatrix = Matrix.LookAtLH(light.position, light.position.add(light.direction), Vector3.UpReadOnly);\r\n invViewMatrix.invertToRef(invViewMatrix);\r\n\r\n const numTesselation = this._tesselation;\r\n\r\n const startFarIndices = this._buildFullVolume ? (numTesselation + 1) * 4 : 4;\r\n\r\n if (this._buildFullVolume) {\r\n const rightFaceStartIndex = 0;\r\n\r\n // Right faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(\r\n rightFaceStartIndex + i,\r\n startFarIndices + numTesselation + (i + 1) * (numTesselation + 1),\r\n startFarIndices + numTesselation + i * (numTesselation + 1)\r\n );\r\n this._indices.push(rightFaceStartIndex + i, rightFaceStartIndex + i + 1, startFarIndices + numTesselation + (i + 1) * (numTesselation + 1));\r\n }\r\n }\r\n\r\n const leftFaceStartIndex = rightFaceStartIndex + numTesselation + 1;\r\n\r\n // Left faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(leftFaceStartIndex + i, startFarIndices + 0 + i * (numTesselation + 1), startFarIndices + 0 + (i + 1) * (numTesselation + 1));\r\n this._indices.push(leftFaceStartIndex + i, startFarIndices + 0 + (i + 1) * (numTesselation + 1), leftFaceStartIndex + i + 1);\r\n }\r\n }\r\n\r\n const bottomFaceStartIndex = leftFaceStartIndex + numTesselation + 1;\r\n\r\n // Bottom faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(bottomFaceStartIndex + i, bottomFaceStartIndex + i + 1, startFarIndices + i + 0 * (numTesselation + 1));\r\n this._indices.push(bottomFaceStartIndex + i + 1, startFarIndices + i + 1 + 0 * (numTesselation + 1), startFarIndices + i + 0 * (numTesselation + 1));\r\n }\r\n }\r\n\r\n const topFaceStartIndex = bottomFaceStartIndex + numTesselation + 1;\r\n\r\n // Top faces of the frustum\r\n for (let i = 0; i <= numTesselation; ++i) {\r\n if (i < numTesselation) {\r\n this._indices.push(topFaceStartIndex + i, startFarIndices + i + numTesselation * (numTesselation + 1), topFaceStartIndex + i + 1);\r\n this._indices.push(\r\n topFaceStartIndex + i + 1,\r\n startFarIndices + i + numTesselation * (numTesselation + 1),\r\n startFarIndices + i + 1 + numTesselation * (numTesselation + 1)\r\n );\r\n }\r\n }\r\n\r\n // Near faces of the frustum\r\n for (let i = 0; i < numTesselation; ++i) {\r\n this._indices.push(leftFaceStartIndex + i, leftFaceStartIndex + i + 1, topFaceStartIndex + numTesselation - i);\r\n if (i < numTesselation - 1) {\r\n this._indices.push(leftFaceStartIndex + i + 1, topFaceStartIndex + numTesselation - i - 1, topFaceStartIndex + numTesselation - i);\r\n }\r\n }\r\n\r\n for (let i = 0; i < numTesselation; ++i) {\r\n this._indices.push(bottomFaceStartIndex + i, rightFaceStartIndex + numTesselation - i, rightFaceStartIndex + numTesselation - i - 1);\r\n if (i < numTesselation - 1) {\r\n this._indices.push(bottomFaceStartIndex + i, rightFaceStartIndex + numTesselation - i - 1, bottomFaceStartIndex + i + 1);\r\n }\r\n }\r\n } else {\r\n this._indices.push(0, 2, 1);\r\n this._indices.push(2, 3, 1);\r\n }\r\n\r\n // Tesselate the far plane\r\n for (let iy = 0; iy <= numTesselation; ++iy) {\r\n for (let ix = 0; ix <= numTesselation; ++ix) {\r\n if (ix < numTesselation && iy < numTesselation) {\r\n this._indices.push(\r\n startFarIndices + ix + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1)\r\n );\r\n this._indices.push(\r\n startFarIndices + ix + iy * (numTesselation + 1),\r\n startFarIndices + ix + 1 + (iy + 1) * (numTesselation + 1),\r\n startFarIndices + ix + (iy + 1) * (numTesselation + 1)\r\n );\r\n }\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -28,6 +28,7 @@ import { Tools } from "../../Misc/tools.js";
28
28
  import { PostProcess } from "../../PostProcesses/postProcess.js";
29
29
  import { SpriteManager } from "../../Sprites/spriteManager.js";
30
30
  import { GetIndividualParser, Parse } from "./babylonFileParser.function.js";
31
+ import { Observable } from "../../Misc/observable.js";
31
32
  /** @internal */
32
33
  // eslint-disable-next-line @typescript-eslint/naming-convention, no-var
33
34
  export var _BabylonLoaderRegistered = true;
@@ -146,6 +147,9 @@ export function LoadAssetContainerFromSerializedScene(scene, serializedScene, ro
146
147
  }
147
148
  const LoadAssetContainer = (scene, data, rootUrl, onError, addToScene = false) => {
148
149
  const container = new AssetContainer(scene);
150
+ if (!addToScene) {
151
+ scene._blockEntityCollection = true;
152
+ }
149
153
  // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
150
154
  // when SceneLoader.debugLogging = true (default), or exception encountered.
151
155
  // Everything stored in var log instead of writing separate lines to support only writing in exception,
@@ -316,7 +320,17 @@ const LoadAssetContainer = (scene, data, rootUrl, onError, addToScene = false) =
316
320
  if (vertexData !== undefined && vertexData !== null) {
317
321
  for (index = 0, cache = vertexData.length; index < cache; index++) {
318
322
  const parsedVertexData = vertexData[index];
323
+ // Geometies are found by loadedUniqueId when imported
324
+ // So we need to temporarily unblock the entity collection to add them to the scene
325
+ scene._blockEntityCollection = false;
326
+ // Temporarily replace the onNewGeometryAddedObservable to avoid multiple notifications
327
+ const onNewGeometryAddedObservable = scene.onNewGeometryAddedObservable;
328
+ scene.onNewGeometryAddedObservable = new Observable();
319
329
  addedGeometry.push(Geometry.Parse(parsedVertexData, scene, rootUrl));
330
+ // Restore the onNewGeometryAddedObservable
331
+ scene.onNewGeometryAddedObservable = onNewGeometryAddedObservable;
332
+ // Restore the previous state of entity collection blocking
333
+ scene._blockEntityCollection = !addToScene;
320
334
  }
321
335
  }
322
336
  for (const g of addedGeometry) {
@@ -573,7 +587,10 @@ const LoadAssetContainer = (scene, data, rootUrl, onError, addToScene = false) =
573
587
  TempMaterialIndexContainer = {};
574
588
  TempMorphTargetManagerIndexContainer = {};
575
589
  if (!addToScene) {
590
+ // Removes any breadcrumb left during the loading like geometries
576
591
  container.removeAllFromScene();
592
+ // Unblock entity collection
593
+ scene._blockEntityCollection = false;
577
594
  }
578
595
  if (log !== null && SceneLoaderFlags.loggingLevel !== 0) {
579
596
  Logger.Log(logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + (SceneLoaderFlags.loggingLevel !== 1 ? log : ""));