@babylonjs/core 7.39.1 → 7.39.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 (159) hide show
  1. package/Cameras/arcRotateCamera.d.ts +1 -1
  2. package/Cameras/arcRotateCamera.js.map +1 -1
  3. package/Debug/directionalLightFrustumViewer.d.ts +2 -1
  4. package/Debug/directionalLightFrustumViewer.js +4 -3
  5. package/Debug/directionalLightFrustumViewer.js.map +1 -1
  6. package/Engines/Extensions/engine.multiRender.js +1 -0
  7. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  8. package/Engines/abstractEngine.js +2 -2
  9. package/Engines/abstractEngine.js.map +1 -1
  10. package/Engines/constants.d.ts +8 -0
  11. package/Engines/constants.js +8 -0
  12. package/Engines/constants.js.map +1 -1
  13. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +3 -9
  14. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
  15. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +3 -9
  16. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  17. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +3 -9
  18. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
  19. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +5 -17
  20. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
  21. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +5 -17
  22. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +3 -9
  24. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
  25. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -1
  26. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +40 -20
  27. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  28. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +77 -0
  29. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +250 -0
  30. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -0
  31. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +57 -0
  32. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +169 -0
  33. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -0
  34. package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js +3 -9
  35. package/FrameGraph/Node/Blocks/Rendering/cullObjectsBlock.js.map +1 -1
  36. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +4 -13
  37. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +6 -0
  39. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +27 -0
  40. package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
  41. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.d.ts +19 -0
  42. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +28 -0
  43. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -0
  44. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -9
  45. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  46. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +3 -9
  47. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  48. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +2 -5
  49. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
  50. package/FrameGraph/Node/Blocks/executeBlock.d.ts +29 -0
  51. package/FrameGraph/Node/Blocks/executeBlock.js +43 -0
  52. package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -0
  53. package/FrameGraph/Node/Blocks/index.d.ts +4 -0
  54. package/FrameGraph/Node/Blocks/index.js +4 -0
  55. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  56. package/FrameGraph/Node/Blocks/inputBlock.d.ts +7 -2
  57. package/FrameGraph/Node/Blocks/inputBlock.js +13 -0
  58. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  59. package/FrameGraph/Node/Blocks/resourceContainerBlock.d.ts +55 -0
  60. package/FrameGraph/Node/Blocks/resourceContainerBlock.js +97 -0
  61. package/FrameGraph/Node/Blocks/resourceContainerBlock.js.map +1 -0
  62. package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +13 -10
  63. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +11 -4
  64. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
  65. package/FrameGraph/Node/nodeRenderGraph.js +32 -4
  66. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  67. package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
  68. package/FrameGraph/Node/nodeRenderGraphBlock.js +11 -0
  69. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  70. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +18 -0
  71. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +24 -0
  72. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  73. package/FrameGraph/Passes/cullPass.d.ts +1 -1
  74. package/FrameGraph/Passes/cullPass.js.map +1 -1
  75. package/FrameGraph/Tasks/Misc/executeTask.d.ts +22 -0
  76. package/FrameGraph/Tasks/Misc/executeTask.js +28 -0
  77. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -0
  78. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +72 -0
  79. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +183 -0
  80. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -0
  81. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +16 -5
  82. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +46 -0
  83. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  84. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +107 -0
  85. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +264 -0
  86. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -0
  87. package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -0
  88. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  89. package/FrameGraph/frameGraph.d.ts +9 -0
  90. package/FrameGraph/frameGraph.js +12 -3
  91. package/FrameGraph/frameGraph.js.map +1 -1
  92. package/FrameGraph/frameGraphTextureManager.js +4 -1
  93. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  94. package/FrameGraph/index.d.ts +5 -0
  95. package/FrameGraph/index.js +5 -0
  96. package/FrameGraph/index.js.map +1 -1
  97. package/Inputs/scene.inputManager.d.ts +1 -1
  98. package/Inputs/scene.inputManager.js +8 -1
  99. package/Inputs/scene.inputManager.js.map +1 -1
  100. package/Lights/Shadows/shadowGenerator.d.ts +1 -1
  101. package/Lights/Shadows/shadowGenerator.js +2 -7
  102. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  103. package/Lights/directionalLight.d.ts +5 -4
  104. package/Lights/directionalLight.js +7 -9
  105. package/Lights/directionalLight.js.map +1 -1
  106. package/Lights/shadowLight.d.ts +4 -4
  107. package/Lights/shadowLight.js +3 -2
  108. package/Lights/shadowLight.js.map +1 -1
  109. package/Lights/spotLight.d.ts +2 -2
  110. package/Lights/spotLight.js +3 -2
  111. package/Lights/spotLight.js.map +1 -1
  112. package/Loading/sceneLoader.d.ts +1 -1
  113. package/Loading/sceneLoader.js.map +1 -1
  114. package/Materials/GreasedLine/greasedLinePluginMaterial.js +1 -1
  115. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  116. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +18 -6
  117. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  118. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +18 -6
  119. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  120. package/Materials/Textures/renderTargetTexture.d.ts +2 -0
  121. package/Materials/Textures/renderTargetTexture.js +18 -8
  122. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  123. package/Materials/material.js +3 -1
  124. package/Materials/material.js.map +1 -1
  125. package/Materials/materialPluginBase.d.ts +4 -0
  126. package/Materials/materialPluginBase.js +4 -0
  127. package/Materials/materialPluginBase.js.map +1 -1
  128. package/Maths/math.color.js.map +1 -1
  129. package/Maths/math.vector.js.map +1 -1
  130. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +1 -1
  131. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  132. package/Meshes/lattice.material.d.ts +3 -8
  133. package/Meshes/lattice.material.js.map +1 -1
  134. package/Misc/copyTextureToTexture.js +1 -1
  135. package/Misc/copyTextureToTexture.js.map +1 -1
  136. package/Misc/filesInput.d.ts +3 -1
  137. package/Misc/filesInput.js +8 -4
  138. package/Misc/filesInput.js.map +1 -1
  139. package/PostProcesses/postProcess.d.ts +2 -2
  140. package/PostProcesses/postProcess.js +4 -4
  141. package/PostProcesses/postProcess.js.map +1 -1
  142. package/PostProcesses/postProcessManager.js +1 -1
  143. package/PostProcesses/postProcessManager.js.map +1 -1
  144. package/Shaders/ShadersInclude/lightsFragmentFunctions.js +1 -1
  145. package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
  146. package/Shaders/default.fragment.js +2 -1
  147. package/Shaders/default.fragment.js.map +1 -1
  148. package/Shaders/default.vertex.js +2 -1
  149. package/Shaders/default.vertex.js.map +1 -1
  150. package/Shaders/pbr.fragment.js +2 -1
  151. package/Shaders/pbr.fragment.js.map +1 -1
  152. package/Shaders/pbr.vertex.js +2 -1
  153. package/Shaders/pbr.vertex.js.map +1 -1
  154. package/XR/webXRCamera.js +3 -0
  155. package/XR/webXRCamera.js.map +1 -1
  156. package/package.json +1 -1
  157. package/scene.d.ts +7 -0
  158. package/scene.js +10 -1
  159. package/scene.js.map +1 -1
@@ -4,7 +4,7 @@ import { FrameGraphPass } from "./pass";
4
4
  * Cull pass used to filter objects that are not visible.
5
5
  */
6
6
  export declare class FrameGraphCullPass extends FrameGraphPass<FrameGraphContext> {
7
- protected _engine: AbstractEngine;
7
+ protected readonly _engine: AbstractEngine;
8
8
  protected _objectList: FrameGraphObjectList;
9
9
  /**
10
10
  * Checks if a pass is a cull pass.
@@ -1 +1 @@
1
- {"version":3,"file":"cullPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/FrameGraph/Passes/cullPass.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAiC;IAIrE;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,IAAqB;QAC1C,OAAQ,IAA2B,CAAC,aAAa,KAAK,SAAS,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAA0B,EAAE,MAAsB;QACpG,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uDAAuD,CAAC;IAC7H,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, IFrameGraphPass, FrameGraphContext, FrameGraphObjectList, FrameGraphTask } from \"core/index\";\r\nimport { FrameGraphPass } from \"./pass\";\r\n\r\n/**\r\n * Cull pass used to filter objects that are not visible.\r\n */\r\nexport class FrameGraphCullPass extends FrameGraphPass<FrameGraphContext> {\r\n protected _engine: AbstractEngine;\r\n protected _objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Checks if a pass is a cull pass.\r\n * @param pass The pass to check.\r\n * @returns True if the pass is a cull pass, else false.\r\n */\r\n public static IsCullPass(pass: IFrameGraphPass): pass is FrameGraphCullPass {\r\n return (pass as FrameGraphCullPass).setObjectList !== undefined;\r\n }\r\n\r\n /**\r\n * Gets the object list used by the cull pass.\r\n */\r\n public get objectList(): FrameGraphObjectList {\r\n return this._objectList;\r\n }\r\n\r\n /**\r\n * Sets the object list to use for culling.\r\n * @param objectList The object list to use for culling.\r\n */\r\n public setObjectList(objectList: FrameGraphObjectList) {\r\n this._objectList = objectList;\r\n }\r\n\r\n /** @internal */\r\n constructor(name: string, parentTask: FrameGraphTask, context: FrameGraphContext, engine: AbstractEngine) {\r\n super(name, parentTask, context);\r\n this._engine = engine;\r\n }\r\n\r\n /** @internal */\r\n public override _isValid(): Nullable<string> {\r\n const errMsg = super._isValid();\r\n return errMsg ? errMsg : this._objectList !== undefined ? null : \"Object list is not set (call setObjectList to set it)\";\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"cullPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/FrameGraph/Passes/cullPass.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAiC;IAIrE;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,IAAqB;QAC1C,OAAQ,IAA2B,CAAC,aAAa,KAAK,SAAS,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,UAAgC;QACjD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAA0B,EAAE,MAAsB;QACpG,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uDAAuD,CAAC;IAC7H,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Nullable, AbstractEngine, IFrameGraphPass, FrameGraphContext, FrameGraphObjectList, FrameGraphTask } from \"core/index\";\r\nimport { FrameGraphPass } from \"./pass\";\r\n\r\n/**\r\n * Cull pass used to filter objects that are not visible.\r\n */\r\nexport class FrameGraphCullPass extends FrameGraphPass<FrameGraphContext> {\r\n protected readonly _engine: AbstractEngine;\r\n protected _objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Checks if a pass is a cull pass.\r\n * @param pass The pass to check.\r\n * @returns True if the pass is a cull pass, else false.\r\n */\r\n public static IsCullPass(pass: IFrameGraphPass): pass is FrameGraphCullPass {\r\n return (pass as FrameGraphCullPass).setObjectList !== undefined;\r\n }\r\n\r\n /**\r\n * Gets the object list used by the cull pass.\r\n */\r\n public get objectList(): FrameGraphObjectList {\r\n return this._objectList;\r\n }\r\n\r\n /**\r\n * Sets the object list to use for culling.\r\n * @param objectList The object list to use for culling.\r\n */\r\n public setObjectList(objectList: FrameGraphObjectList) {\r\n this._objectList = objectList;\r\n }\r\n\r\n /** @internal */\r\n constructor(name: string, parentTask: FrameGraphTask, context: FrameGraphContext, engine: AbstractEngine) {\r\n super(name, parentTask, context);\r\n this._engine = engine;\r\n }\r\n\r\n /** @internal */\r\n public override _isValid(): Nullable<string> {\r\n const errMsg = super._isValid();\r\n return errMsg ? errMsg : this._objectList !== undefined ? null : \"Object list is not set (call setObjectList to set it)\";\r\n }\r\n}\r\n"]}
@@ -0,0 +1,22 @@
1
+ import type { FrameGraph, FrameGraphContext } from "../../../index.js";
2
+ import { FrameGraphTask } from "../../frameGraphTask";
3
+ /**
4
+ * Task used to execute a custom function.
5
+ */
6
+ export declare class FrameGraphExecuteTask extends FrameGraphTask {
7
+ /**
8
+ * The function to execute.
9
+ */
10
+ func: (context: FrameGraphContext) => void;
11
+ /**
12
+ * The function to execute when the task is disabled (optional).
13
+ */
14
+ funcDisabled?: (context: FrameGraphContext) => void;
15
+ /**
16
+ * Creates a new execute task.
17
+ * @param name The name of the task.
18
+ * @param frameGraph The frame graph the task belongs to.
19
+ */
20
+ constructor(name: string, frameGraph: FrameGraph);
21
+ record(): void;
22
+ }
@@ -0,0 +1,28 @@
1
+ import { FrameGraphTask } from "../../frameGraphTask.js";
2
+ /**
3
+ * Task used to execute a custom function.
4
+ */
5
+ export class FrameGraphExecuteTask extends FrameGraphTask {
6
+ /**
7
+ * Creates a new execute task.
8
+ * @param name The name of the task.
9
+ * @param frameGraph The frame graph the task belongs to.
10
+ */
11
+ constructor(name, frameGraph) {
12
+ super(name, frameGraph);
13
+ }
14
+ record() {
15
+ if (!this.func) {
16
+ throw new Error("FrameGraphExecuteTask: Execute task must have a function.");
17
+ }
18
+ const pass = this._frameGraph.addPass(this.name);
19
+ pass.setExecuteFunc((context) => {
20
+ this.func(context);
21
+ });
22
+ const passDisabled = this._frameGraph.addPass(this.name + "_disabled", true);
23
+ passDisabled.setExecuteFunc((context) => {
24
+ this.funcDisabled?.(context);
25
+ });
26
+ }
27
+ }
28
+ //# sourceMappingURL=executeTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAWrD;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphContext } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Creates a new execute task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n }\r\n\r\n public record() {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n }\r\n}\r\n"]}
@@ -0,0 +1,72 @@
1
+ import type { Camera } from "../../../index.js";
2
+ import { CascadedShadowGenerator } from "../../../Lights/Shadows/cascadedShadowGenerator";
3
+ import { FrameGraphShadowGeneratorTask } from "./shadowGeneratorTask";
4
+ /**
5
+ * Task used to generate a cascaded shadow map from a list of objects.
6
+ */
7
+ export declare class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {
8
+ protected _shadowGenerator: CascadedShadowGenerator | undefined;
9
+ /**
10
+ * Checks if a shadow generator task is a cascaded shadow generator task.
11
+ * @param task The task to check.
12
+ * @returns True if the task is a cascaded shadow generator task, else false.
13
+ */
14
+ static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask;
15
+ private _numCascades;
16
+ /**
17
+ * The number of cascades.
18
+ */
19
+ get numCascades(): number;
20
+ set numCascades(value: number);
21
+ private _debug;
22
+ /**
23
+ * Gets or sets a value indicating whether the shadow generator should display the cascades.
24
+ */
25
+ get debug(): boolean;
26
+ set debug(value: boolean);
27
+ private _stabilizeCascades;
28
+ /**
29
+ * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.
30
+ */
31
+ get stabilizeCascades(): boolean;
32
+ set stabilizeCascades(value: boolean);
33
+ private _lambda;
34
+ /**
35
+ * Gets or sets the lambda parameter of the shadow generator.
36
+ */
37
+ get lambda(): number;
38
+ set lambda(value: number);
39
+ private _cascadeBlendPercentage;
40
+ /**
41
+ * Gets or sets the cascade blend percentage.
42
+ */
43
+ get cascadeBlendPercentage(): number;
44
+ set cascadeBlendPercentage(value: number);
45
+ private _depthClamp;
46
+ /**
47
+ * Gets or sets a value indicating whether the shadow generator should use depth clamping.
48
+ */
49
+ get depthClamp(): boolean;
50
+ set depthClamp(value: boolean);
51
+ private _autoCalcDepthBounds;
52
+ /**
53
+ * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.
54
+ */
55
+ get autoCalcDepthBounds(): boolean;
56
+ set autoCalcDepthBounds(value: boolean);
57
+ private _shadowMaxZ;
58
+ /**
59
+ * Gets or sets the maximum shadow Z value.
60
+ */
61
+ get shadowMaxZ(): number;
62
+ set shadowMaxZ(value: number);
63
+ private _camera;
64
+ /**
65
+ * Gets or sets the camera used to generate the shadow generator.
66
+ */
67
+ get camera(): Camera;
68
+ set camera(camera: Camera);
69
+ record(): void;
70
+ protected _createShadowGenerator(): void;
71
+ protected _setupShadowGenerator(): void;
72
+ }
@@ -0,0 +1,183 @@
1
+ import { CascadedShadowGenerator } from "../../../Lights/Shadows/cascadedShadowGenerator.js";
2
+ import { FrameGraphShadowGeneratorTask } from "./shadowGeneratorTask.js";
3
+ import { DirectionalLight } from "../../../Lights/directionalLight.js";
4
+ /**
5
+ * Task used to generate a cascaded shadow map from a list of objects.
6
+ */
7
+ export class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {
8
+ constructor() {
9
+ super(...arguments);
10
+ this._numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;
11
+ this._debug = false;
12
+ this._stabilizeCascades = false;
13
+ this._lambda = 0.5;
14
+ this._cascadeBlendPercentage = 0.1;
15
+ this._depthClamp = true;
16
+ this._autoCalcDepthBounds = false;
17
+ this._shadowMaxZ = 10000;
18
+ }
19
+ /**
20
+ * Checks if a shadow generator task is a cascaded shadow generator task.
21
+ * @param task The task to check.
22
+ * @returns True if the task is a cascaded shadow generator task, else false.
23
+ */
24
+ static IsCascadedShadowGenerator(task) {
25
+ return task.numCascades !== undefined;
26
+ }
27
+ /**
28
+ * The number of cascades.
29
+ */
30
+ get numCascades() {
31
+ return this._numCascades;
32
+ }
33
+ set numCascades(value) {
34
+ if (value === this._numCascades) {
35
+ return;
36
+ }
37
+ this._numCascades = value;
38
+ this._setupShadowGenerator();
39
+ }
40
+ /**
41
+ * Gets or sets a value indicating whether the shadow generator should display the cascades.
42
+ */
43
+ get debug() {
44
+ return this._debug;
45
+ }
46
+ set debug(value) {
47
+ if (value === this._debug) {
48
+ return;
49
+ }
50
+ this._debug = value;
51
+ if (this._shadowGenerator) {
52
+ this._shadowGenerator.debug = value;
53
+ }
54
+ }
55
+ /**
56
+ * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.
57
+ */
58
+ get stabilizeCascades() {
59
+ return this._stabilizeCascades;
60
+ }
61
+ set stabilizeCascades(value) {
62
+ if (value === this._stabilizeCascades) {
63
+ return;
64
+ }
65
+ this._stabilizeCascades = value;
66
+ if (this._shadowGenerator) {
67
+ this._shadowGenerator.stabilizeCascades = value;
68
+ }
69
+ }
70
+ /**
71
+ * Gets or sets the lambda parameter of the shadow generator.
72
+ */
73
+ get lambda() {
74
+ return this._lambda;
75
+ }
76
+ set lambda(value) {
77
+ if (value === this._lambda) {
78
+ return;
79
+ }
80
+ this._lambda = value;
81
+ if (this._shadowGenerator) {
82
+ this._shadowGenerator.lambda = value;
83
+ }
84
+ }
85
+ /**
86
+ * Gets or sets the cascade blend percentage.
87
+ */
88
+ get cascadeBlendPercentage() {
89
+ return this._cascadeBlendPercentage;
90
+ }
91
+ set cascadeBlendPercentage(value) {
92
+ if (value === this._cascadeBlendPercentage) {
93
+ return;
94
+ }
95
+ this._cascadeBlendPercentage = value;
96
+ if (this._shadowGenerator) {
97
+ this._shadowGenerator.cascadeBlendPercentage = value;
98
+ }
99
+ }
100
+ /**
101
+ * Gets or sets a value indicating whether the shadow generator should use depth clamping.
102
+ */
103
+ get depthClamp() {
104
+ return this._depthClamp;
105
+ }
106
+ set depthClamp(value) {
107
+ if (value === this._depthClamp) {
108
+ return;
109
+ }
110
+ this._depthClamp = value;
111
+ if (this._shadowGenerator) {
112
+ this._shadowGenerator.depthClamp = value;
113
+ }
114
+ }
115
+ /**
116
+ * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.
117
+ */
118
+ get autoCalcDepthBounds() {
119
+ return this._autoCalcDepthBounds;
120
+ }
121
+ set autoCalcDepthBounds(value) {
122
+ if (value === this._autoCalcDepthBounds) {
123
+ return;
124
+ }
125
+ this._autoCalcDepthBounds = value;
126
+ if (this._shadowGenerator) {
127
+ this._shadowGenerator.autoCalcDepthBounds = value;
128
+ }
129
+ }
130
+ /**
131
+ * Gets or sets the maximum shadow Z value.
132
+ */
133
+ get shadowMaxZ() {
134
+ return this._shadowMaxZ;
135
+ }
136
+ set shadowMaxZ(value) {
137
+ if (value === this._shadowMaxZ) {
138
+ return;
139
+ }
140
+ this._shadowMaxZ = value;
141
+ if (this._shadowGenerator) {
142
+ this._shadowGenerator.shadowMaxZ = value;
143
+ }
144
+ }
145
+ /**
146
+ * Gets or sets the camera used to generate the shadow generator.
147
+ */
148
+ get camera() {
149
+ return this._camera;
150
+ }
151
+ set camera(camera) {
152
+ this._camera = camera;
153
+ this._setupShadowGenerator();
154
+ }
155
+ record() {
156
+ if (this.camera === undefined) {
157
+ throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: camera is required`);
158
+ }
159
+ super.record();
160
+ }
161
+ _createShadowGenerator() {
162
+ if (!(this.light instanceof DirectionalLight)) {
163
+ throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);
164
+ }
165
+ this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this._camera, this.useRedTextureFormat);
166
+ this._shadowGenerator.numCascades = this._numCascades;
167
+ }
168
+ _setupShadowGenerator() {
169
+ super._setupShadowGenerator();
170
+ const shadowGenerator = this._shadowGenerator;
171
+ if (shadowGenerator === undefined) {
172
+ return;
173
+ }
174
+ shadowGenerator.debug = this._debug;
175
+ shadowGenerator.stabilizeCascades = this._stabilizeCascades;
176
+ shadowGenerator.lambda = this._lambda;
177
+ shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;
178
+ shadowGenerator.depthClamp = this._depthClamp;
179
+ shadowGenerator.autoCalcDepthBounds = this._autoCalcDepthBounds;
180
+ shadowGenerator.shadowMaxZ = this._shadowMaxZ;
181
+ }
182
+ }
183
+ //# sourceMappingURL=csmShadowGeneratorTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csmShadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,qCAAsC,SAAQ,6BAA6B;IAAxF;;QAYY,iBAAY,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AK,CAAC,yCAAyC,IAAI,CAAC,IAAI,8DAA8D,CAAC,CAAC;QACtI,CAAC;QACD,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAClJ,IAAI,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC;IAC1D,CAAC;IAEkB,qBAAqB;QACpC,KAAK,CAAC,qBAAqB,EAAE,CAAC;QAE9B,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAuD,CAAC;QACrF,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO;QACX,CAAC;QAED,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACpC,eAAe,CAAC,iBAAiB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAC5D,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;QACtC,eAAe,CAAC,sBAAsB,GAAG,IAAI,CAAC,uBAAuB,CAAC;QACtE,eAAe,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;QAC9C,eAAe,CAAC,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,CAAC;QAChE,eAAe,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IAClD,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { Camera } from \"core/index\";\r\nimport { CascadedShadowGenerator } from \"../../../Lights/Shadows/cascadedShadowGenerator\";\r\nimport { FrameGraphShadowGeneratorTask } from \"./shadowGeneratorTask\";\r\nimport { DirectionalLight } from \"../../../Lights/directionalLight\";\r\n\r\n/**\r\n * Task used to generate a cascaded shadow map from a list of objects.\r\n */\r\nexport class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {\r\n protected override _shadowGenerator: CascadedShadowGenerator | undefined;\r\n\r\n /**\r\n * Checks if a shadow generator task is a cascaded shadow generator task.\r\n * @param task The task to check.\r\n * @returns True if the task is a cascaded shadow generator task, else false.\r\n */\r\n public static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask {\r\n return (task as FrameGraphCascadedShadowGeneratorTask).numCascades !== undefined;\r\n }\r\n\r\n private _numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;\r\n /**\r\n * The number of cascades.\r\n */\r\n public get numCascades() {\r\n return this._numCascades;\r\n }\r\n\r\n public set numCascades(value: number) {\r\n if (value === this._numCascades) {\r\n return;\r\n }\r\n\r\n this._numCascades = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _debug = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should display the cascades.\r\n */\r\n public get debug() {\r\n return this._debug;\r\n }\r\n\r\n public set debug(value: boolean) {\r\n if (value === this._debug) {\r\n return;\r\n }\r\n\r\n this._debug = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.debug = value;\r\n }\r\n }\r\n\r\n private _stabilizeCascades = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.\r\n */\r\n public get stabilizeCascades() {\r\n return this._stabilizeCascades;\r\n }\r\n\r\n public set stabilizeCascades(value: boolean) {\r\n if (value === this._stabilizeCascades) {\r\n return;\r\n }\r\n\r\n this._stabilizeCascades = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.stabilizeCascades = value;\r\n }\r\n }\r\n\r\n private _lambda = 0.5;\r\n /**\r\n * Gets or sets the lambda parameter of the shadow generator.\r\n */\r\n public get lambda() {\r\n return this._lambda;\r\n }\r\n\r\n public set lambda(value: number) {\r\n if (value === this._lambda) {\r\n return;\r\n }\r\n\r\n this._lambda = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.lambda = value;\r\n }\r\n }\r\n\r\n private _cascadeBlendPercentage = 0.1;\r\n /**\r\n * Gets or sets the cascade blend percentage.\r\n */\r\n public get cascadeBlendPercentage() {\r\n return this._cascadeBlendPercentage;\r\n }\r\n\r\n public set cascadeBlendPercentage(value: number) {\r\n if (value === this._cascadeBlendPercentage) {\r\n return;\r\n }\r\n\r\n this._cascadeBlendPercentage = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.cascadeBlendPercentage = value;\r\n }\r\n }\r\n\r\n private _depthClamp = true;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should use depth clamping.\r\n */\r\n public get depthClamp() {\r\n return this._depthClamp;\r\n }\r\n\r\n public set depthClamp(value: boolean) {\r\n if (value === this._depthClamp) {\r\n return;\r\n }\r\n\r\n this._depthClamp = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.depthClamp = value;\r\n }\r\n }\r\n\r\n private _autoCalcDepthBounds = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.\r\n */\r\n public get autoCalcDepthBounds() {\r\n return this._autoCalcDepthBounds;\r\n }\r\n\r\n public set autoCalcDepthBounds(value: boolean) {\r\n if (value === this._autoCalcDepthBounds) {\r\n return;\r\n }\r\n\r\n this._autoCalcDepthBounds = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.autoCalcDepthBounds = value;\r\n }\r\n }\r\n\r\n private _shadowMaxZ = 10000;\r\n /**\r\n * Gets or sets the maximum shadow Z value.\r\n */\r\n public get shadowMaxZ() {\r\n return this._shadowMaxZ;\r\n }\r\n\r\n public set shadowMaxZ(value: number) {\r\n if (value === this._shadowMaxZ) {\r\n return;\r\n }\r\n\r\n this._shadowMaxZ = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.shadowMaxZ = value;\r\n }\r\n }\r\n\r\n private _camera: Camera;\r\n /**\r\n * Gets or sets the camera used to generate the shadow generator.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n public override record() {\r\n if (this.camera === undefined) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: camera is required`);\r\n }\r\n\r\n super.record();\r\n }\r\n\r\n protected override _createShadowGenerator() {\r\n if (!(this.light instanceof DirectionalLight)) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);\r\n }\r\n this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this._camera, this.useRedTextureFormat);\r\n this._shadowGenerator.numCascades = this._numCascades;\r\n }\r\n\r\n protected override _setupShadowGenerator() {\r\n super._setupShadowGenerator();\r\n\r\n const shadowGenerator = this._shadowGenerator as CascadedShadowGenerator | undefined;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n\r\n shadowGenerator.debug = this._debug;\r\n shadowGenerator.stabilizeCascades = this._stabilizeCascades;\r\n shadowGenerator.lambda = this._lambda;\r\n shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;\r\n shadowGenerator.depthClamp = this._depthClamp;\r\n shadowGenerator.autoCalcDepthBounds = this._autoCalcDepthBounds;\r\n shadowGenerator.shadowMaxZ = this._shadowMaxZ;\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from "../../../index.js";
1
+ import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions, Nullable, Observer, FrameGraphShadowGeneratorTask } from "../../../index.js";
2
2
  import { FrameGraphTask } from "../../frameGraphTask";
3
3
  import { ObjectRenderer } from "../../../Rendering/objectRenderer";
4
4
  /**
@@ -17,6 +17,10 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
17
17
  * The dependencies of the task (optional).
18
18
  */
19
19
  dependencies?: FrameGraphTextureHandle[];
20
+ /**
21
+ * The shadow generators used to render the objects (optional).
22
+ */
23
+ shadowGenerators?: FrameGraphShadowGeneratorTask[];
20
24
  private _camera;
21
25
  /**
22
26
  * Gets or sets the camera used to render the objects.
@@ -35,6 +39,10 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
35
39
  * If depth writing should be enabled (default is true).
36
40
  */
37
41
  depthWrite: boolean;
42
+ /**
43
+ * If shadows should be disabled (default is false).
44
+ */
45
+ disableShadows: boolean;
38
46
  /**
39
47
  * The output texture.
40
48
  * This texture will point to the same texture than the destinationTexture property if it is set.
@@ -47,16 +55,18 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
47
55
  * Note, however, that the handle itself will be different!
48
56
  */
49
57
  readonly outputDepthTexture: FrameGraphTextureHandle;
50
- protected readonly _scene: Scene;
51
- protected readonly _renderer: ObjectRenderer;
52
- protected _textureWidth: number;
53
- protected _textureHeight: number;
54
58
  /**
55
59
  * The object renderer used to render the objects.
56
60
  */
57
61
  get objectRenderer(): ObjectRenderer;
58
62
  get name(): string;
59
63
  set name(value: string);
64
+ protected readonly _scene: Scene;
65
+ protected readonly _renderer: ObjectRenderer;
66
+ protected _textureWidth: number;
67
+ protected _textureHeight: number;
68
+ protected _onBeforeRenderObservable: Nullable<Observer<number>>;
69
+ protected _onAfterRenderObservable: Nullable<Observer<number>>;
60
70
  /**
61
71
  * Constructs a new object renderer task.
62
72
  * @param name The name of the task.
@@ -68,4 +78,5 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
68
78
  isReady(): boolean;
69
79
  record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void): void;
70
80
  dispose(): void;
81
+ private _setLightsForShadow;
71
82
  }
@@ -1,6 +1,7 @@
1
1
  import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from "../../frameGraphTypes.js";
2
2
  import { FrameGraphTask } from "../../frameGraphTask.js";
3
3
  import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
4
+ import { FrameGraphCascadedShadowGeneratorTask } from "./csmShadowGeneratorTask.js";
4
5
  /**
5
6
  * Task used to render objects to a texture.
6
7
  */
@@ -43,6 +44,10 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
43
44
  * The dependencies of the task (optional).
44
45
  */
45
46
  this.dependencies = [];
47
+ /**
48
+ * The shadow generators used to render the objects (optional).
49
+ */
50
+ this.shadowGenerators = [];
46
51
  /**
47
52
  * If depth testing should be enabled (default is true).
48
53
  */
@@ -51,6 +56,12 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
51
56
  * If depth writing should be enabled (default is true).
52
57
  */
53
58
  this.depthWrite = true;
59
+ /**
60
+ * If shadows should be disabled (default is false).
61
+ */
62
+ this.disableShadows = false;
63
+ this._onBeforeRenderObservable = null;
64
+ this._onAfterRenderObservable = null;
54
65
  this._scene = scene;
55
66
  this._renderer = new ObjectRenderer(name, scene, options);
56
67
  this.name = name;
@@ -90,6 +101,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
90
101
  }
91
102
  this._textureWidth = outputTextureDescription.size.width;
92
103
  this._textureHeight = outputTextureDescription.size.height;
104
+ this._setLightsForShadow();
93
105
  const pass = this._frameGraph.addRenderPass(this.name);
94
106
  pass.setRenderTarget(this.destinationTexture);
95
107
  pass.setRenderTargetDepth(this.depthTexture);
@@ -121,5 +133,39 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
121
133
  this._renderer.dispose();
122
134
  super.dispose();
123
135
  }
136
+ _setLightsForShadow() {
137
+ const lightsForShadow = new Set();
138
+ const shadowEnabled = new Map();
139
+ if (this.shadowGenerators) {
140
+ for (const shadowGeneratorTask of this.shadowGenerators) {
141
+ const shadowGenerator = shadowGeneratorTask.shadowGenerator;
142
+ const light = shadowGenerator.getLight();
143
+ if (light.isEnabled() && light.shadowEnabled) {
144
+ lightsForShadow.add(light);
145
+ if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {
146
+ light._shadowGenerators.set(shadowGeneratorTask.camera, shadowGenerator);
147
+ }
148
+ else {
149
+ light._shadowGenerators.set(null, shadowGenerator);
150
+ }
151
+ }
152
+ }
153
+ }
154
+ this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);
155
+ this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {
156
+ for (let i = 0; i < this._scene.lights.length; i++) {
157
+ const light = this._scene.lights[i];
158
+ shadowEnabled.set(light, light.shadowEnabled);
159
+ light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);
160
+ }
161
+ });
162
+ this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);
163
+ this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {
164
+ for (let i = 0; i < this._scene.lights.length; i++) {
165
+ const light = this._scene.lights[i];
166
+ light.shadowEnabled = shadowEnabled.get(light);
167
+ }
168
+ });
169
+ }
124
170
  }
125
171
  //# sourceMappingURL=objectRendererTask.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IAoCD;;OAEG;IACH,I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,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;YAE9C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACrC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,qCAAqC,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAuB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,C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KAAK,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QAC7E,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC5E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACjD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBACpC,KAAK,CAAC,aAAa,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;YACpD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n FrameGraphObjectList,\r\n FrameGraphRenderContext,\r\n ObjectRendererOptions,\r\n Light,\r\n Nullable,\r\n Observer,\r\n FrameGraphShadowGeneratorTask,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\nimport { FrameGraphCascadedShadowGeneratorTask } from \"./csmShadowGeneratorTask\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n /**\r\n * The shadow generators used to render the objects (optional).\r\n */\r\n public shadowGenerators?: FrameGraphShadowGeneratorTask[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * If shadows should be disabled (default is false).\r\n */\r\n public disableShadows = false;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n protected _onBeforeRenderObservable: Nullable<Observer<number>> = null;\r\n protected _onAfterRenderObservable: Nullable<Observer<number>> = null;\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n this._setLightsForShadow();\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _setLightsForShadow() {\r\n const lightsForShadow: Set<Light> = new Set();\r\n const shadowEnabled: Map<Light, boolean> = new Map();\r\n\r\n if (this.shadowGenerators) {\r\n for (const shadowGeneratorTask of this.shadowGenerators) {\r\n const shadowGenerator = shadowGeneratorTask.shadowGenerator;\r\n const light = shadowGenerator.getLight();\r\n if (light.isEnabled() && light.shadowEnabled) {\r\n lightsForShadow.add(light);\r\n if (FrameGraphCascadedShadowGeneratorTask.IsCascadedShadowGenerator(shadowGeneratorTask)) {\r\n light._shadowGenerators!.set(shadowGeneratorTask.camera, shadowGenerator);\r\n } else {\r\n light._shadowGenerators!.set(null, shadowGenerator);\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable);\r\n this._onBeforeRenderObservable = this._renderer.onBeforeRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n shadowEnabled.set(light, light.shadowEnabled);\r\n light.shadowEnabled = !this.disableShadows && lightsForShadow.has(light);\r\n }\r\n });\r\n\r\n this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable);\r\n this._onAfterRenderObservable = this._renderer.onAfterRenderObservable.add(() => {\r\n for (let i = 0; i < this._scene.lights.length; i++) {\r\n const light = this._scene.lights[i];\r\n light.shadowEnabled = shadowEnabled.get(light)!;\r\n }\r\n });\r\n }\r\n}\r\n"]}