@babylonjs/core 8.44.1 → 8.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +6 -10
  2. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
  3. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
  4. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  5. package/Cameras/Limits/geospatialLimits.d.ts +4 -22
  6. package/Cameras/Limits/geospatialLimits.js +4 -36
  7. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  8. package/Cameras/geospatialCamera.d.ts +15 -4
  9. package/Cameras/geospatialCamera.js +90 -37
  10. package/Cameras/geospatialCamera.js.map +1 -1
  11. package/Cameras/geospatialCameraMovement.d.ts +1 -3
  12. package/Cameras/geospatialCameraMovement.js +15 -51
  13. package/Cameras/geospatialCameraMovement.js.map +1 -1
  14. package/Collisions/collisionCoordinator.d.ts +2 -2
  15. package/Collisions/collisionCoordinator.js +1 -0
  16. package/Collisions/collisionCoordinator.js.map +1 -1
  17. package/Engines/Extensions/engine.debugging.d.ts +3 -5
  18. package/Engines/Extensions/engine.debugging.js +3 -4
  19. package/Engines/Extensions/engine.debugging.js.map +1 -1
  20. package/Engines/WebGPU/Extensions/engine.debugging.js +15 -65
  21. package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureManager.js +9 -9
  23. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  24. package/Engines/abstractEngine.d.ts +2 -0
  25. package/Engines/abstractEngine.js +4 -2
  26. package/Engines/abstractEngine.js.map +1 -1
  27. package/Engines/thinWebGPUEngine.d.ts +0 -2
  28. package/Engines/thinWebGPUEngine.js +0 -8
  29. package/Engines/thinWebGPUEngine.js.map +1 -1
  30. package/Engines/webgpuEngine.d.ts +1 -3
  31. package/Engines/webgpuEngine.js +4 -10
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/FrameGraph/Passes/renderPass.js +4 -9
  34. package/FrameGraph/Passes/renderPass.js.map +1 -1
  35. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +3 -0
  36. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  37. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +1 -1
  38. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -1
  39. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  40. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -1
  41. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +31 -7
  42. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  43. package/FrameGraph/frameGraph.js +2 -2
  44. package/FrameGraph/frameGraph.js.map +1 -1
  45. package/FrameGraph/frameGraphContext.d.ts +9 -0
  46. package/FrameGraph/frameGraphContext.js +13 -2
  47. package/FrameGraph/frameGraphContext.js.map +1 -1
  48. package/FrameGraph/frameGraphObjectList.js.map +1 -1
  49. package/FrameGraph/frameGraphRenderContext.d.ts +9 -8
  50. package/FrameGraph/frameGraphRenderContext.js +23 -20
  51. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  52. package/FrameGraph/frameGraphTask.d.ts +2 -0
  53. package/FrameGraph/frameGraphTask.js +14 -4
  54. package/FrameGraph/frameGraphTask.js.map +1 -1
  55. package/Lights/Shadows/cascadedShadowGenerator.js +4 -1
  56. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  57. package/Lights/Shadows/shadowGenerator.js +8 -3
  58. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  59. package/Lights/areaLight.d.ts +2 -1
  60. package/Lights/areaLight.js +3 -2
  61. package/Lights/areaLight.js.map +1 -1
  62. package/Lights/directionalLight.d.ts +2 -1
  63. package/Lights/directionalLight.js +3 -2
  64. package/Lights/directionalLight.js.map +1 -1
  65. package/Lights/hemisphericLight.d.ts +2 -1
  66. package/Lights/hemisphericLight.js +3 -2
  67. package/Lights/hemisphericLight.js.map +1 -1
  68. package/Lights/light.d.ts +2 -1
  69. package/Lights/light.js +8 -3
  70. package/Lights/light.js.map +1 -1
  71. package/Lights/lightingVolume.js +11 -6
  72. package/Lights/lightingVolume.js.map +1 -1
  73. package/Lights/pointLight.d.ts +2 -1
  74. package/Lights/pointLight.js +3 -2
  75. package/Lights/pointLight.js.map +1 -1
  76. package/Lights/rectAreaLight.d.ts +2 -1
  77. package/Lights/rectAreaLight.js +3 -2
  78. package/Lights/rectAreaLight.js.map +1 -1
  79. package/Lights/spotLight.d.ts +2 -1
  80. package/Lights/spotLight.js +3 -2
  81. package/Lights/spotLight.js.map +1 -1
  82. package/Materials/Node/Blocks/Input/inputBlock.js +3 -0
  83. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  84. package/Materials/Node/nodeMaterial.d.ts +1 -0
  85. package/Materials/Node/nodeMaterial.js +4 -0
  86. package/Materials/Node/nodeMaterial.js.map +1 -1
  87. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +6 -0
  88. package/Materials/Node/nodeMaterialBuildStateSharedData.js +4 -0
  89. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  90. package/Materials/Textures/Loaders/iesTextureLoader.js +1 -1
  91. package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -1
  92. package/Materials/Textures/Procedurals/proceduralTexture.js +7 -2
  93. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  94. package/Materials/Textures/internalTexture.d.ts +6 -4
  95. package/Materials/Textures/internalTexture.js +6 -4
  96. package/Materials/Textures/internalTexture.js.map +1 -1
  97. package/Materials/Textures/renderTargetTexture.js +2 -2
  98. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  99. package/Materials/Textures/textureSampler.d.ts +3 -3
  100. package/Materials/Textures/textureSampler.js.map +1 -1
  101. package/Misc/minMaxReducer.js +2 -2
  102. package/Misc/minMaxReducer.js.map +1 -1
  103. package/Misc/screenshotTools.d.ts +3 -1
  104. package/Misc/screenshotTools.js +5 -2
  105. package/Misc/screenshotTools.js.map +1 -1
  106. package/Particles/Node/nodeParticleSystemSet.helper.js +47 -46
  107. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  108. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js +4 -1
  109. package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js.map +1 -1
  110. package/Probes/reflectionProbe.js +9 -2
  111. package/Probes/reflectionProbe.js.map +1 -1
  112. package/Rendering/depthRenderer.js +7 -2
  113. package/Rendering/depthRenderer.js.map +1 -1
  114. package/Shaders/particles.vertex.js +8 -1
  115. package/Shaders/particles.vertex.js.map +1 -1
  116. package/ShadersWGSL/particles.vertex.js +6 -0
  117. package/ShadersWGSL/particles.vertex.js.map +1 -1
  118. package/package.json +1 -1
  119. package/scene.d.ts +10 -0
  120. package/scene.js +30 -5
  121. package/scene.js.map +1 -1
@@ -118,17 +118,12 @@ export class FrameGraphRenderPass extends FrameGraphPass {
118
118
  }
119
119
  /** @internal */
120
120
  _execute() {
121
+ const currentDebugMarkers = this._context.enableDebugMarkers;
122
+ this._context.enableDebugMarkers = !this._parentTask._disableDebugMarkers;
121
123
  this._context.bindRenderTarget(this._frameGraphRenderTarget);
122
124
  super._execute();
123
- this._context._flushDebugMessages();
124
- const renderTargetWrapper = this._frameGraphRenderTarget.renderTargetWrapper;
125
- if (renderTargetWrapper &&
126
- renderTargetWrapper.samples > 1 &&
127
- (renderTargetWrapper.resolveMSAAColors || renderTargetWrapper.resolveMSAADepth || renderTargetWrapper.resolveMSAAStencil)) {
128
- // Unbinding the render target will trigger resolving MSAA textures.
129
- this._context.bindRenderTarget(undefined, `Resolve MSAA${this.name ? " (" + this.name + ")" : ""}`, true);
130
- this._context._flushDebugMessages();
131
- }
125
+ this._context.restoreDefaultFramebuffer();
126
+ this._context.enableDebugMarkers = currentDebugMarkers;
132
127
  }
133
128
  /** @internal */
134
129
  _isValid() {
@@ -1 +1 @@
1
- {"version":3,"file":"renderPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/FrameGraph/Passes/renderPass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAgBxC;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAuC;IAO7E;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,IAAqB;QAC5C,OAAQ,IAA6B,CAAC,eAAe,KAAK,SAAS,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,sBAAsB;QAC7B,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAYD,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAAgC,EAAE,MAAsB;QAC1G,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QA5C3B,kBAAa,GAAiC,IAAI,GAAG,EAAE,CAAC;QAgClE;;WAEG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;WAEG;QACI,oBAAe,GAAG,KAAK,CAAC;QAK3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,kBAAwE;QAC3F,IAAI,CAAC,aAAa,GAAG,kBAAkB,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,oBAAoB,CAAC,kBAA4C;QACpE,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IACjD,CAAC;IAED;;;OAGG;IACI,eAAe,CAAC,YAAkE;QACrF,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7B,O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AAQ,CAAC,mBAAmB,EAAE,CAAC;QACxC,CAAC;IACL,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM;YACT,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;gBACxE,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,iEAAiE,CAAC;IAC9E,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { Nullable, FrameGraphRenderContext, AbstractEngine, IFrameGraphPass, FrameGraphTextureHandle, FrameGraphTask, FrameGraphRenderTarget } from \"core/index\";\r\nimport { FrameGraphPass } from \"./pass\";\r\n\r\n/**\r\n * Type used to define layer and face indices for multi-render target rendering scenarios.\r\n */\r\nexport type LayerAndFaceIndex = {\r\n /** Index of the texture to update */\r\n targetIndex: number;\r\n\r\n /** Index of the layer to set (optional - not used if the texture is not an array or a 3D texture) */\r\n layerIndex?: number;\r\n\r\n /** Index of the cube face to set (optional - not used if the texture is not a cube texture) */\r\n faceIndex?: number;\r\n};\r\n\r\n/**\r\n * Render pass used to render objects.\r\n */\r\nexport class FrameGraphRenderPass extends FrameGraphPass<FrameGraphRenderContext> {\r\n protected readonly _engine: AbstractEngine;\r\n protected _renderTarget: FrameGraphTextureHandle | FrameGraphTextureHandle[] | undefined;\r\n protected _renderTargetDepth: FrameGraphTextureHandle | undefined;\r\n protected _frameGraphRenderTarget: FrameGraphRenderTarget;\r\n protected _dependencies: Set<FrameGraphTextureHandle> = new Set();\r\n\r\n /**\r\n * Checks if a pass is a render pass.\r\n * @param pass The pass to check.\r\n * @returns True if the pass is a render pass, else false.\r\n */\r\n public static IsRenderPass(pass: IFrameGraphPass): pass is FrameGraphRenderPass {\r\n return (pass as FrameGraphRenderPass).setRenderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * Gets the handle(s) of the render target(s) used by the render pass.\r\n */\r\n public get renderTarget(): FrameGraphTextureHandle | FrameGraphTextureHandle[] | undefined {\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Gets the handle of the render target depth used by the render pass.\r\n */\r\n public get renderTargetDepth(): FrameGraphTextureHandle | undefined {\r\n return this._renderTargetDepth;\r\n }\r\n\r\n /**\r\n * Gets the frame graph render target used by the render pass.\r\n */\r\n public get frameGraphRenderTarget(): FrameGraphRenderTarget {\r\n return this._frameGraphRenderTarget;\r\n }\r\n\r\n /**\r\n * If true, the depth attachment will be read-only (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /** @internal */\r\n constructor(name: string, parentTask: FrameGraphTask, context: FrameGraphRenderContext, engine: AbstractEngine) {\r\n super(name, parentTask, context);\r\n this._engine = engine;\r\n }\r\n\r\n /**\r\n * Sets the render target(s) to use for rendering.\r\n * @param renderTargetHandle The render target to use for rendering, or an array of render targets to use for multi render target rendering.\r\n */\r\n public setRenderTarget(renderTargetHandle?: FrameGraphTextureHandle | FrameGraphTextureHandle[]) {\r\n this._renderTarget = renderTargetHandle;\r\n }\r\n\r\n /**\r\n * Sets the render target depth to use for rendering.\r\n * @param renderTargetHandle The render target depth to use for rendering.\r\n */\r\n public setRenderTargetDepth(renderTargetHandle?: FrameGraphTextureHandle) {\r\n this._renderTargetDepth = renderTargetHandle;\r\n }\r\n\r\n /**\r\n * Adds dependencies to the render pass.\r\n * @param dependencies The dependencies to add.\r\n */\r\n public addDependencies(dependencies?: FrameGraphTextureHandle | FrameGraphTextureHandle[]) {\r\n if (dependencies === undefined) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(dependencies)) {\r\n for (const dependency of dependencies) {\r\n this._dependencies.add(dependency);\r\n }\r\n } else {\r\n this._dependencies.add(dependencies);\r\n }\r\n }\r\n\r\n /**\r\n * Collects the dependencies of the render pass.\r\n * @param dependencies The set of dependencies to update.\r\n */\r\n public collectDependencies(dependencies: Set<FrameGraphTextureHandle>): void {\r\n const iterator = this._dependencies.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n dependencies.add(key.value);\r\n }\r\n\r\n if (this._renderTarget !== undefined) {\r\n if (Array.isArray(this._renderTarget)) {\r\n for (const handle of this._renderTarget) {\r\n if (handle !== undefined) {\r\n dependencies.add(handle);\r\n }\r\n }\r\n } else {\r\n dependencies.add(this._renderTarget);\r\n }\r\n }\r\n\r\n if (this._renderTargetDepth !== undefined) {\r\n dependencies.add(this._renderTargetDepth);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the output layer and face indices for multi-render target rendering.\r\n * @param indices The array of layer and face indices.\r\n */\r\n public setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]): void {\r\n const renderTargetWrapper = this.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n for (const index of indices) {\r\n renderTargetWrapper.setLayerAndFaceIndex(index.targetIndex, index.layerIndex, index.faceIndex);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _initialize() {\r\n this._frameGraphRenderTarget = this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth, this.depthReadOnly, this.stencilReadOnly);\r\n super._initialize();\r\n }\r\n\r\n /** @internal */\r\n public override _execute() {\r\n this._context.bindRenderTarget(this._frameGraphRenderTarget);\r\n\r\n super._execute();\r\n\r\n this._context._flushDebugMessages();\r\n\r\n const renderTargetWrapper = this._frameGraphRenderTarget.renderTargetWrapper;\r\n if (\r\n renderTargetWrapper &&\r\n renderTargetWrapper.samples > 1 &&\r\n (renderTargetWrapper.resolveMSAAColors || renderTargetWrapper.resolveMSAADepth || renderTargetWrapper.resolveMSAAStencil)\r\n ) {\r\n // Unbinding the render target will trigger resolving MSAA textures.\r\n this._context.bindRenderTarget(undefined, `Resolve MSAA${this.name ? \" (\" + this.name + \")\" : \"\"}`, true);\r\n this._context._flushDebugMessages();\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _isValid(): Nullable<string> {\r\n const errMsg = super._isValid();\r\n return errMsg\r\n ? errMsg\r\n : this._renderTarget !== undefined || this.renderTargetDepth !== undefined\r\n ? null\r\n : \"Render target and render target depth cannot both be undefined.\";\r\n }\r\n\r\n /** @internal */\r\n public override _dispose() {\r\n this._frameGraphRenderTarget?.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"renderPass.js","sourceRoot":"","sources":["../../../../../dev/core/src/FrameGraph/Passes/renderPass.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAgBxC;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAuC;IAO7E;;;;OAIG;IACI,MAAM,CAAC,YAAY,CAAC,IAAqB;QAC5C,OAAQ,IAA6B,CAAC,eAAe,KAAK,SAAS,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB;QACxB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,sBAAsB;QAC7B,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAYD,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAAgC,EAAE,MAAsB;QAC1G,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QA5C3B,kBAAa,GAAiC,IAAI,GAAG,EAAE,CAAC;QAgClE;;WAEG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;WAEG;QACI,oBAAe,GAAG,KAAK,CAAC;QAK3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;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CAAC,QAAQ,CAAC,kBAAkB,GAAG,mBAAmB,CAAC;IAC3D,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,MAAM;YACT,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;gBACxE,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,iEAAiE,CAAC;IAC9E,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { Nullable, FrameGraphRenderContext, AbstractEngine, IFrameGraphPass, FrameGraphTextureHandle, FrameGraphTask, FrameGraphRenderTarget } from \"core/index\";\r\nimport { FrameGraphPass } from \"./pass\";\r\n\r\n/**\r\n * Type used to define layer and face indices for multi-render target rendering scenarios.\r\n */\r\nexport type LayerAndFaceIndex = {\r\n /** Index of the texture to update */\r\n targetIndex: number;\r\n\r\n /** Index of the layer to set (optional - not used if the texture is not an array or a 3D texture) */\r\n layerIndex?: number;\r\n\r\n /** Index of the cube face to set (optional - not used if the texture is not a cube texture) */\r\n faceIndex?: number;\r\n};\r\n\r\n/**\r\n * Render pass used to render objects.\r\n */\r\nexport class FrameGraphRenderPass extends FrameGraphPass<FrameGraphRenderContext> {\r\n protected readonly _engine: AbstractEngine;\r\n protected _renderTarget: FrameGraphTextureHandle | FrameGraphTextureHandle[] | undefined;\r\n protected _renderTargetDepth: FrameGraphTextureHandle | undefined;\r\n protected _frameGraphRenderTarget: FrameGraphRenderTarget;\r\n protected _dependencies: Set<FrameGraphTextureHandle> = new Set();\r\n\r\n /**\r\n * Checks if a pass is a render pass.\r\n * @param pass The pass to check.\r\n * @returns True if the pass is a render pass, else false.\r\n */\r\n public static IsRenderPass(pass: IFrameGraphPass): pass is FrameGraphRenderPass {\r\n return (pass as FrameGraphRenderPass).setRenderTarget !== undefined;\r\n }\r\n\r\n /**\r\n * Gets the handle(s) of the render target(s) used by the render pass.\r\n */\r\n public get renderTarget(): FrameGraphTextureHandle | FrameGraphTextureHandle[] | undefined {\r\n return this._renderTarget;\r\n }\r\n\r\n /**\r\n * Gets the handle of the render target depth used by the render pass.\r\n */\r\n public get renderTargetDepth(): FrameGraphTextureHandle | undefined {\r\n return this._renderTargetDepth;\r\n }\r\n\r\n /**\r\n * Gets the frame graph render target used by the render pass.\r\n */\r\n public get frameGraphRenderTarget(): FrameGraphRenderTarget {\r\n return this._frameGraphRenderTarget;\r\n }\r\n\r\n /**\r\n * If true, the depth attachment will be read-only (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /** @internal */\r\n constructor(name: string, parentTask: FrameGraphTask, context: FrameGraphRenderContext, engine: AbstractEngine) {\r\n super(name, parentTask, context);\r\n this._engine = engine;\r\n }\r\n\r\n /**\r\n * Sets the render target(s) to use for rendering.\r\n * @param renderTargetHandle The render target to use for rendering, or an array of render targets to use for multi render target rendering.\r\n */\r\n public setRenderTarget(renderTargetHandle?: FrameGraphTextureHandle | FrameGraphTextureHandle[]) {\r\n this._renderTarget = renderTargetHandle;\r\n }\r\n\r\n /**\r\n * Sets the render target depth to use for rendering.\r\n * @param renderTargetHandle The render target depth to use for rendering.\r\n */\r\n public setRenderTargetDepth(renderTargetHandle?: FrameGraphTextureHandle) {\r\n this._renderTargetDepth = renderTargetHandle;\r\n }\r\n\r\n /**\r\n * Adds dependencies to the render pass.\r\n * @param dependencies The dependencies to add.\r\n */\r\n public addDependencies(dependencies?: FrameGraphTextureHandle | FrameGraphTextureHandle[]) {\r\n if (dependencies === undefined) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(dependencies)) {\r\n for (const dependency of dependencies) {\r\n this._dependencies.add(dependency);\r\n }\r\n } else {\r\n this._dependencies.add(dependencies);\r\n }\r\n }\r\n\r\n /**\r\n * Collects the dependencies of the render pass.\r\n * @param dependencies The set of dependencies to update.\r\n */\r\n public collectDependencies(dependencies: Set<FrameGraphTextureHandle>): void {\r\n const iterator = this._dependencies.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n dependencies.add(key.value);\r\n }\r\n\r\n if (this._renderTarget !== undefined) {\r\n if (Array.isArray(this._renderTarget)) {\r\n for (const handle of this._renderTarget) {\r\n if (handle !== undefined) {\r\n dependencies.add(handle);\r\n }\r\n }\r\n } else {\r\n dependencies.add(this._renderTarget);\r\n }\r\n }\r\n\r\n if (this._renderTargetDepth !== undefined) {\r\n dependencies.add(this._renderTargetDepth);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the output layer and face indices for multi-render target rendering.\r\n * @param indices The array of layer and face indices.\r\n */\r\n public setOutputLayerAndFaceIndices(indices: LayerAndFaceIndex[]): void {\r\n const renderTargetWrapper = this.frameGraphRenderTarget.renderTargetWrapper;\r\n if (renderTargetWrapper) {\r\n for (const index of indices) {\r\n renderTargetWrapper.setLayerAndFaceIndex(index.targetIndex, index.layerIndex, index.faceIndex);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _initialize() {\r\n this._frameGraphRenderTarget = this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth, this.depthReadOnly, this.stencilReadOnly);\r\n super._initialize();\r\n }\r\n\r\n /** @internal */\r\n public override _execute() {\r\n const currentDebugMarkers = this._context.enableDebugMarkers;\r\n\r\n this._context.enableDebugMarkers = !this._parentTask._disableDebugMarkers;\r\n this._context.bindRenderTarget(this._frameGraphRenderTarget);\r\n\r\n super._execute();\r\n\r\n this._context.restoreDefaultFramebuffer();\r\n this._context.enableDebugMarkers = currentDebugMarkers;\r\n }\r\n\r\n /** @internal */\r\n public override _isValid(): Nullable<string> {\r\n const errMsg = super._isValid();\r\n return errMsg\r\n ? errMsg\r\n : this._renderTarget !== undefined || this.renderTargetDepth !== undefined\r\n ? null\r\n : \"Render target and render target depth cannot both be undefined.\";\r\n }\r\n\r\n /** @internal */\r\n public override _dispose() {\r\n this._frameGraphRenderTarget?.dispose();\r\n }\r\n}\r\n"]}
@@ -87,6 +87,7 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
87
87
  pass.setRenderTarget(this.outputTexture);
88
88
  pass.setRenderTargetDepth(this.depthAttachmentTexture);
89
89
  pass.setExecuteFunc((context) => {
90
+ context.pushDebugGroup(`Apply post-process (${this.name})`);
90
91
  if (this.sourceTexture !== undefined) {
91
92
  context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);
92
93
  }
@@ -101,6 +102,8 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
101
102
  additionalBindings?.(context);
102
103
  this.postProcess.bind();
103
104
  }, this.stencilState, this.disableColorWrite, this.drawBackFace, this.depthTest, this.viewport !== undefined);
105
+ context.restoreDefaultFramebuffer();
106
+ context.popDebugGroup();
104
107
  });
105
108
  if (!skipCreationOfDisabledPasses) {
106
109
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
@@ -1 +1 @@
1
- {"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAsFzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAlG5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B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aAAa,CAAC,CAAC;YACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YAC/D,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpC,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;oBACnC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAChB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACvC,CAAC;oBACD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;gBACpF,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n IViewportLike,\r\n Nullable,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilStateProperties;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\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 * The viewport to use when applying the post process.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture of the post process.\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 depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphPostProcessTask\";\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest,\r\n this.viewport !== undefined\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.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAsFzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAlG5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAmBpE;;;;;WAKG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;;;;WAKG;QACI,oBAAe,GAAG,KAAK,CAAC;QAE/B;;;WAGG;QACI,sBAAiB,GAAG,KAAK,CAAC;QAEjC;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QAgDpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC;QAE5D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC5E,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IAC/F,CAAC;IA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Q,KAAK,SAAS,CAAC,CAAC;gBACpF,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n IViewportLike,\r\n Nullable,\r\n IStencilStateProperties,\r\n} from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilStateProperties;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\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 * The viewport to use when applying the post process.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture of the post process.\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 depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphPostProcessTask\";\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n context.pushDebugGroup(`Apply post-process (${this.name})`);\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest,\r\n this.viewport !== undefined\r\n );\r\n context.restoreDefaultFramebuffer();\r\n context.popDebugGroup();\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -143,7 +143,7 @@ export declare class FrameGraphGeometryRendererTask extends FrameGraphObjectRend
143
143
  protected _checkParameters(): void;
144
144
  protected _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean;
145
145
  protected _getTargetHandles(): FrameGraphTextureHandle[];
146
- protected _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean): void;
146
+ protected _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean): number[];
147
147
  private _buildClearAttachmentsLayout;
148
148
  private _registerForRenderPassId;
149
149
  }
@@ -285,10 +285,13 @@ export class FrameGraphGeometryRendererTask extends FrameGraphObjectRendererTask
285
285
  }
286
286
  _prepareRendering(context, depthEnabled) {
287
287
  context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
288
+ context.pushDebugGroup(`Clear attachments`);
288
289
  this._clearAttachmentsLayout.forEach((layout, clearType) => {
289
290
  context.clearColorAttachments(ClearColors[clearType], layout);
290
291
  });
291
- context.bindAttachments(this._allAttachmentsLayout);
292
+ context.restoreDefaultFramebuffer();
293
+ context.popDebugGroup();
294
+ return this._allAttachmentsLayout;
292
295
  }
293
296
  _buildClearAttachmentsLayout() {
294
297
  const clearAttachmentsLayout = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAqC,+DAAwD;AACrI,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAuBpE,MAAM,WAAW,GAAa,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvG;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,4BAA4B;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AAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;QACnF,CAAC;QAED,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, Scene, FrameGraph, AbstractMesh, ObjectRendererOptions, FrameGraphRenderContext, FrameGraphRenderPass, ObjectRenderer } from \"core/index\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering, GeometryRenderingTextureClearType } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst ClearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(0, 0, 0, 0)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n private _reverseCulling = false;\r\n\r\n /**\r\n * Whether to reverse culling (default is false).\r\n */\r\n public get reverseCulling() {\r\n return this._reverseCulling;\r\n }\r\n\r\n public set reverseCulling(value: boolean) {\r\n this._reverseCulling = value;\r\n\r\n const configuration = MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId);\r\n if (configuration) {\r\n configuration.reverseCulling = value;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if a mesh shouldn't be rendered when its material has depth write disabled (default is true).\r\n */\r\n public dontRenderWhenMaterialDepthWriteIsDisabled = true;\r\n\r\n private _disableDepthPrePass = true;\r\n /**\r\n * Indicates whether the depth pre-pass is disabled (default is true).\r\n * Materials that require depth pre-pass (Material.needDepthPrePass == true) don't work with the geometry renderer, that's why this setting is true by default.\r\n * However, if the geometry renderer doesn't generate any geometry textures but only renders to the main target texture, then depth pre-pass can be enabled.\r\n */\r\n public get disableDepthPrePass() {\r\n return this._disableDepthPrePass;\r\n }\r\n\r\n public set disableDepthPrePass(value: boolean) {\r\n this._disableDepthPrePass = value;\r\n this._renderer.disableDepthPrePass = value;\r\n }\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normalized depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n * The normalization is (d - near) / (far - near), where d is the depth value in view space and near and far are the near and far planes of the camera.\r\n */\r\n public readonly geometryNormViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Gets or sets the name of the task.\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 private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry 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 * @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions, existingObjectRenderer?: ObjectRenderer) {\r\n super(name, frameGraph, scene, options, existingObjectRenderer);\r\n\r\n this.renderSprites = false;\r\n this.renderParticles = false;\r\n this.enableBoundingBoxRendering = false;\r\n this.enableOutlineRendering = false;\r\n this._renderer.disableDepthPrePass = true;\r\n\r\n this._renderer.customIsReadyFunction = (mesh: AbstractMesh, refreshRate: number, preWarm?: boolean) => {\r\n if (this.dontRenderWhenMaterialDepthWriteIsDisabled && mesh.material && mesh.material.disableDepthWrite) {\r\n return !!preWarm;\r\n }\r\n\r\n return mesh.isReady(refreshRate === 0);\r\n };\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._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryNormViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n /**\r\n * Excludes the given skinned mesh from computing bones velocities.\r\n * Computing bones velocities can have a cost. The cost can be saved by calling this function and by passing the skinned mesh to ignore.\r\n * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.\r\n */\r\n public excludeSkinnedMeshFromVelocityTexture(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n const list = this.excludedSkinnedMeshFromVelocityTexture;\r\n if (list.indexOf(skinnedMesh) === -1) {\r\n list.push(skinnedMesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.\r\n * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.\r\n * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.\r\n */\r\n public removeExcludedSkinnedMeshFromVelocityTexture(skinnedMesh: AbstractMesh): void {\r\n const list = this.excludedSkinnedMeshFromVelocityTexture;\r\n const index = list.indexOf(skinnedMesh);\r\n if (index !== -1) {\r\n list.splice(index, 1);\r\n }\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphGeometryRendererTask\";\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void): FrameGraphRenderPass {\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = super.record(skipCreationOfDisabledPasses, additionalExecute) as FrameGraphRenderPass;\r\n\r\n const outputTextureHandles = pass.renderTarget as FrameGraphTextureHandle[];\r\n\r\n let needPreviousWorldMatrices = false;\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const handle = outputTextureHandles[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryNormViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryScreenDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLocalPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryAlbedoTexture, handle);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryReflectivityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryVelocityTexture, handle);\r\n needPreviousWorldMatrices = true;\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);\r\n needPreviousWorldMatrices = true;\r\n break;\r\n }\r\n }\r\n\r\n this._scene.needsPreviousWorldMatrices = needPreviousWorldMatrices;\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n protected override _resolveDanglingHandles(_targetTextures: FrameGraphTextureHandle[]) {\r\n if (this.targetTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n }\r\n\r\n protected override _checkParameters() {\r\n if (this.objectList === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and camera must be provided`);\r\n }\r\n }\r\n\r\n protected override _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean {\r\n let depthEnabled = false;\r\n\r\n let dimensions: { width: number; height: number } | null = null;\r\n\r\n if (this.targetTexture !== undefined) {\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);\r\n if (this.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the target texture and the output geometry textures must have the same number of samples`);\r\n }\r\n dimensions = outputTextureDescription.size;\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples && this.textureDescriptions.length > 0) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output geometry textures must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n dimensions = depthTextureDescription.size;\r\n }\r\n\r\n const geomTextureDimensions = this.sizeIsPercentage ? this._frameGraph.textureManager.getAbsoluteDimensions(this.size) : this.size;\r\n if (dimensions !== null) {\r\n if (geomTextureDimensions.width !== dimensions.width || geomTextureDimensions.height !== dimensions.height) {\r\n throw new Error(\r\n `FrameGraphGeometryRendererTask ${this.name}: the geometry textures (size: ${geomTextureDimensions.width}x${geomTextureDimensions.height}) and the target/depth texture (size: ${dimensions.width}x${dimensions.height}) must have the same dimensions.`\r\n );\r\n }\r\n }\r\n\r\n depthEnabled = depthEnabled || super._checkTextureCompatibility(targetTextures);\r\n\r\n return depthEnabled;\r\n }\r\n\r\n protected override _getTargetHandles(): FrameGraphTextureHandle[] {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n const handles: FrameGraphTextureHandle[] = [];\r\n\r\n if (this.textureDescriptions.length > 0) {\r\n const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n });\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n handles.push(baseHandle + i);\r\n }\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n if (Array.isArray(this.targetTexture)) {\r\n handles.push(...this.targetTexture);\r\n } else {\r\n handles.push(this.targetTexture);\r\n }\r\n }\r\n\r\n return handles;\r\n }\r\n\r\n protected override _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean) {\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(ClearColors[clearType], layout);\r\n });\r\n\r\n context.bindAttachments(this._allAttachmentsLayout);\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n let layout = clearAttachmentsLayout.get(GeometryRenderingTextureClearType.Zero);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(GeometryRenderingTextureClearType.Zero, layout);\r\n for (let j = 0; j < this.textureDescriptions.length - 1; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout) => {\r\n layout.push(false);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n configuration.defines[\"PREPASS_COLOR_INDEX\"] = this.textureDescriptions.length;\r\n }\r\n\r\n configuration.reverseCulling = this.reverseCulling;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAqC,+DAAwD;AACrI,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAuBpE,MAAM,WAAW,GAAa,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvG;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,4BAA4B;IAkB5E;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IA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CAAC;YACnC,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC;QACnF,CAAC;QAED,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, Scene, FrameGraph, AbstractMesh, ObjectRendererOptions, FrameGraphRenderContext, FrameGraphRenderPass, ObjectRenderer } from \"core/index\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering, GeometryRenderingTextureClearType } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst ClearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(0, 0, 0, 0)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n private _reverseCulling = false;\r\n\r\n /**\r\n * Whether to reverse culling (default is false).\r\n */\r\n public get reverseCulling() {\r\n return this._reverseCulling;\r\n }\r\n\r\n public set reverseCulling(value: boolean) {\r\n this._reverseCulling = value;\r\n\r\n const configuration = MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId);\r\n if (configuration) {\r\n configuration.reverseCulling = value;\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if a mesh shouldn't be rendered when its material has depth write disabled (default is true).\r\n */\r\n public dontRenderWhenMaterialDepthWriteIsDisabled = true;\r\n\r\n private _disableDepthPrePass = true;\r\n /**\r\n * Indicates whether the depth pre-pass is disabled (default is true).\r\n * Materials that require depth pre-pass (Material.needDepthPrePass == true) don't work with the geometry renderer, that's why this setting is true by default.\r\n * However, if the geometry renderer doesn't generate any geometry textures but only renders to the main target texture, then depth pre-pass can be enabled.\r\n */\r\n public get disableDepthPrePass() {\r\n return this._disableDepthPrePass;\r\n }\r\n\r\n public set disableDepthPrePass(value: boolean) {\r\n this._disableDepthPrePass = value;\r\n this._renderer.disableDepthPrePass = value;\r\n }\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normalized depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n * The normalization is (d - near) / (far - near), where d is the depth value in view space and near and far are the near and far planes of the camera.\r\n */\r\n public readonly geometryNormViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Gets or sets the name of the task.\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 private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry 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 * @param existingObjectRenderer An existing object renderer to use (optional). If provided, the options parameter will be ignored.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions, existingObjectRenderer?: ObjectRenderer) {\r\n super(name, frameGraph, scene, options, existingObjectRenderer);\r\n\r\n this.renderSprites = false;\r\n this.renderParticles = false;\r\n this.enableBoundingBoxRendering = false;\r\n this.enableOutlineRendering = false;\r\n this._renderer.disableDepthPrePass = true;\r\n\r\n this._renderer.customIsReadyFunction = (mesh: AbstractMesh, refreshRate: number, preWarm?: boolean) => {\r\n if (this.dontRenderWhenMaterialDepthWriteIsDisabled && mesh.material && mesh.material.disableDepthWrite) {\r\n return !!preWarm;\r\n }\r\n\r\n return mesh.isReady(refreshRate === 0);\r\n };\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._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryNormViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n /**\r\n * Excludes the given skinned mesh from computing bones velocities.\r\n * Computing bones velocities can have a cost. The cost can be saved by calling this function and by passing the skinned mesh to ignore.\r\n * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.\r\n */\r\n public excludeSkinnedMeshFromVelocityTexture(skinnedMesh: AbstractMesh): void {\r\n if (skinnedMesh.skeleton) {\r\n const list = this.excludedSkinnedMeshFromVelocityTexture;\r\n if (list.indexOf(skinnedMesh) === -1) {\r\n list.push(skinnedMesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.\r\n * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.\r\n * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.\r\n */\r\n public removeExcludedSkinnedMeshFromVelocityTexture(skinnedMesh: AbstractMesh): void {\r\n const list = this.excludedSkinnedMeshFromVelocityTexture;\r\n const index = list.indexOf(skinnedMesh);\r\n if (index !== -1) {\r\n list.splice(index, 1);\r\n }\r\n }\r\n\r\n public override getClassName(): string {\r\n return \"FrameGraphGeometryRendererTask\";\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void): FrameGraphRenderPass {\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = super.record(skipCreationOfDisabledPasses, additionalExecute) as FrameGraphRenderPass;\r\n\r\n const outputTextureHandles = pass.renderTarget as FrameGraphTextureHandle[];\r\n\r\n let needPreviousWorldMatrices = false;\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const handle = outputTextureHandles[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMALIZED_VIEW_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryNormViewDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryScreenDepthTexture, handle);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldNormalTexture, handle);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLocalPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldPositionTexture, handle);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryAlbedoTexture, handle);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryReflectivityTexture, handle);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryVelocityTexture, handle);\r\n needPreviousWorldMatrices = true;\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);\r\n needPreviousWorldMatrices = true;\r\n break;\r\n }\r\n }\r\n\r\n this._scene.needsPreviousWorldMatrices = needPreviousWorldMatrices;\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n protected override _resolveDanglingHandles(_targetTextures: FrameGraphTextureHandle[]) {\r\n if (this.targetTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n }\r\n\r\n protected override _checkParameters() {\r\n if (this.objectList === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and camera must be provided`);\r\n }\r\n }\r\n\r\n protected override _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean {\r\n let depthEnabled = false;\r\n\r\n let dimensions: { width: number; height: number } | null = null;\r\n\r\n if (this.targetTexture !== undefined) {\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(Array.isArray(this.targetTexture) ? this.targetTexture[0] : this.targetTexture);\r\n if (this.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the target texture and the output geometry textures must have the same number of samples`);\r\n }\r\n dimensions = outputTextureDescription.size;\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples && this.textureDescriptions.length > 0) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output geometry textures must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n dimensions = depthTextureDescription.size;\r\n }\r\n\r\n const geomTextureDimensions = this.sizeIsPercentage ? this._frameGraph.textureManager.getAbsoluteDimensions(this.size) : this.size;\r\n if (dimensions !== null) {\r\n if (geomTextureDimensions.width !== dimensions.width || geomTextureDimensions.height !== dimensions.height) {\r\n throw new Error(\r\n `FrameGraphGeometryRendererTask ${this.name}: the geometry textures (size: ${geomTextureDimensions.width}x${geomTextureDimensions.height}) and the target/depth texture (size: ${dimensions.width}x${dimensions.height}) must have the same dimensions.`\r\n );\r\n }\r\n }\r\n\r\n depthEnabled = depthEnabled || super._checkTextureCompatibility(targetTextures);\r\n\r\n return depthEnabled;\r\n }\r\n\r\n protected override _getTargetHandles(): FrameGraphTextureHandle[] {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n const handles: FrameGraphTextureHandle[] = [];\r\n\r\n if (this.textureDescriptions.length > 0) {\r\n const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n });\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n handles.push(baseHandle + i);\r\n }\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n if (Array.isArray(this.targetTexture)) {\r\n handles.push(...this.targetTexture);\r\n } else {\r\n handles.push(this.targetTexture);\r\n }\r\n }\r\n\r\n return handles;\r\n }\r\n\r\n protected override _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean) {\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n context.pushDebugGroup(`Clear attachments`);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(ClearColors[clearType], layout);\r\n });\r\n\r\n context.restoreDefaultFramebuffer();\r\n context.popDebugGroup();\r\n\r\n return this._allAttachmentsLayout;\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n let layout = clearAttachmentsLayout.get(GeometryRenderingTextureClearType.Zero);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(GeometryRenderingTextureClearType.Zero, layout);\r\n for (let j = 0; j < this.textureDescriptions.length - 1; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout) => {\r\n layout.push(false);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n\r\n if (this.targetTexture !== undefined) {\r\n configuration.defines[\"PREPASS_COLOR_INDEX\"] = this.textureDescriptions.length;\r\n }\r\n\r\n configuration.reverseCulling = this.reverseCulling;\r\n }\r\n}\r\n"]}
@@ -179,7 +179,8 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRen
179
179
  protected _checkParameters(): void;
180
180
  protected _checkTextureCompatibility(targetTextures: FrameGraphTextureHandle[]): boolean;
181
181
  protected _getTargetHandles(): FrameGraphTextureHandle[];
182
- protected _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean): void;
182
+ protected _prepareRendering(context: FrameGraphRenderContext, depthEnabled: boolean): Nullable<number[]>;
183
183
  protected _setLightsForShadow(): void;
184
184
  protected _renderTransparentMeshesWithOIT(transparentSubMeshes: SmartArray<SubMesh>): void;
185
+ protected _sceneHasClusteredLights(): boolean;
185
186
  }
@@ -5,6 +5,7 @@ import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
5
5
  import { ThinDepthPeelingRenderer } from "../../../Rendering/thinDepthPeelingRenderer.js";
6
6
  import { RenderingManager } from "../../../Rendering/renderingManager.js";
7
7
  import { FrameGraphRenderTarget } from "../../frameGraphRenderTarget.js";
8
+ import { LightConstants } from "../../../Lights/lightConstants.js";
8
9
  /**
9
10
  * Task used to render objects to a texture.
10
11
  */
@@ -284,8 +285,17 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
284
285
  this._oitRenderer.useRenderPasses = true;
285
286
  this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
286
287
  this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
288
+ this.onBeforeTaskExecute.add(() => {
289
+ /**
290
+ * When clustered lights are used, we need to disable the debug markers because there's a flushFramebuffer call
291
+ * done by the clustered light container during the frame rendering that breaks the debug groups.
292
+ */
293
+ this._disableDebugMarkers = this._engine._enableGPUDebugMarkers && this._sceneHasClusteredLights();
294
+ });
287
295
  }
288
296
  isReady() {
297
+ this._renderer.renderList = this.objectList.meshes;
298
+ this._renderer.particleSystemList = this.objectList.particleSystems;
289
299
  return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);
290
300
  }
291
301
  getClassName() {
@@ -293,9 +303,6 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
293
303
  }
294
304
  record(skipCreationOfDisabledPasses = false, additionalExecute) {
295
305
  this._checkParameters();
296
- // Make sure the renderList / particleSystemList are set when FrameGraphObjectRendererTask.isReady() is called!
297
- this._renderer.renderList = this.objectList.meshes;
298
- this._renderer.particleSystemList = this.objectList.particleSystems;
299
306
  const targetTextures = this._getTargetHandles();
300
307
  const depthEnabled = this._checkTextureCompatibility(targetTextures);
301
308
  this._resolveDanglingHandles(targetTextures);
@@ -326,8 +333,8 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
326
333
  if (boundingBoxRenderer) {
327
334
  currentBoundingBoxMeshList.length = boundingBoxRenderer.renderList.length;
328
335
  }
329
- this._prepareRendering(context, depthEnabled);
330
- const currentOITRenderer = this._scene.depthPeelingRenderer;
336
+ const attachments = this._prepareRendering(context, depthEnabled);
337
+ const currentOITRenderer = this._scene._depthPeelingRenderer;
331
338
  this._scene._depthPeelingRenderer = this._oitRenderer;
332
339
  const camera = this._renderer.activeCamera;
333
340
  if (camera && camera.cameraRigMode !== 0 && !camera._renderingMultiview) {
@@ -335,13 +342,21 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
335
342
  const rigCamera = camera._rigCameras[index];
336
343
  rigCamera.rigParent = undefined; // for some reasons, ObjectRenderer uses the rigParent viewport if rigParent is defined (we want to use rigCamera.viewport instead)
337
344
  this._renderer.activeCamera = rigCamera;
338
- context.render(this._renderer, this._textureWidth, this._textureHeight);
345
+ context.pushDebugGroup(`Render objects for camera rig ${index} "${rigCamera.name}"`);
346
+ context.bindRenderTarget(pass.frameGraphRenderTarget);
347
+ attachments && context.bindAttachments(attachments);
348
+ context.render(this._renderer, this._textureWidth, this._textureHeight, true);
349
+ context.popDebugGroup();
339
350
  rigCamera.rigParent = camera;
340
351
  }
341
352
  this._renderer.activeCamera = camera;
342
353
  }
343
354
  else {
344
- context.render(this._renderer, this._textureWidth, this._textureHeight);
355
+ context.pushDebugGroup(`Render objects for camera "${this._renderer.activeCamera?.name ?? "undefined"}"`);
356
+ context.bindRenderTarget(pass.frameGraphRenderTarget);
357
+ attachments && context.bindAttachments(attachments);
358
+ context.render(this._renderer, this._textureWidth, this._textureHeight, true);
359
+ context.popDebugGroup();
345
360
  }
346
361
  additionalExecute?.(context);
347
362
  this._scene._depthPeelingRenderer = currentOITRenderer;
@@ -410,6 +425,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
410
425
  }
411
426
  _prepareRendering(context, depthEnabled) {
412
427
  context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
428
+ return null;
413
429
  }
414
430
  _setLightsForShadow() {
415
431
  const lightsForShadow = new Set();
@@ -469,5 +485,13 @@ export class FrameGraphObjectRendererTask extends FrameGraphTaskMultiRenderTarge
469
485
  }
470
486
  this._scene._useOrderIndependentTransparency = saveOIT;
471
487
  }
488
+ _sceneHasClusteredLights() {
489
+ for (const light of this._scene.lights) {
490
+ if (light.getTypeID() === LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER && light.isSupported) {
491
+ return true;
492
+ }
493
+ }
494
+ return false;
495
+ }
472
496
  }
473
497
  //# sourceMappingURL=objectRendererTask.js.map