@babylonjs/core 8.18.0 → 8.19.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 (100) hide show
  1. package/Collisions/intersectionInfo.d.ts +1 -0
  2. package/Collisions/intersectionInfo.js +1 -0
  3. package/Collisions/intersectionInfo.js.map +1 -1
  4. package/Compute/computeShader.d.ts +7 -0
  5. package/Compute/computeShader.js +15 -0
  6. package/Compute/computeShader.js.map +1 -1
  7. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  8. package/Engines/Extensions/engine.computeShader.js +1 -0
  9. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  10. package/Engines/IDrawContext.d.ts +31 -1
  11. package/Engines/IDrawContext.js.map +1 -1
  12. package/Engines/IMaterialContext.d.ts +1 -0
  13. package/Engines/IMaterialContext.js.map +1 -1
  14. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -1
  15. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +2 -2
  16. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  17. package/Engines/WebGPU/webgpuComputeContext.js +15 -0
  18. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  19. package/Engines/WebGPU/webgpuDrawContext.d.ts +48 -3
  20. package/Engines/WebGPU/webgpuDrawContext.js +81 -13
  21. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  22. package/Engines/WebGPU/webgpuMaterialContext.d.ts +1 -0
  23. package/Engines/WebGPU/webgpuMaterialContext.js +1 -0
  24. package/Engines/WebGPU/webgpuMaterialContext.js.map +1 -1
  25. package/Engines/WebGPU/webgpuStencilStateComposer.js +7 -3
  26. package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
  27. package/Engines/abstractEngine.d.ts +4 -1
  28. package/Engines/abstractEngine.js +2 -2
  29. package/Engines/abstractEngine.js.map +1 -1
  30. package/Engines/engine.d.ts +2 -2
  31. package/Engines/nativeEngine.d.ts +1 -1
  32. package/Engines/nativeEngine.js +2 -2
  33. package/Engines/nativeEngine.js.map +1 -1
  34. package/Engines/renderTargetWrapper.d.ts +8 -0
  35. package/Engines/renderTargetWrapper.js +8 -0
  36. package/Engines/renderTargetWrapper.js.map +1 -1
  37. package/Engines/thinEngine.d.ts +2 -3
  38. package/Engines/thinEngine.js +3 -2
  39. package/Engines/thinEngine.js.map +1 -1
  40. package/Engines/webgpuEngine.d.ts +7 -4
  41. package/Engines/webgpuEngine.js +28 -15
  42. package/Engines/webgpuEngine.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
  44. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Passes/renderPass.d.ts +8 -0
  46. package/FrameGraph/Passes/renderPass.js +10 -1
  47. package/FrameGraph/Passes/renderPass.js.map +1 -1
  48. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +46 -2
  49. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +62 -15
  50. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  51. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +4 -0
  52. package/FrameGraph/Tasks/Texture/clearTextureTask.js +5 -1
  53. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  54. package/FrameGraph/frameGraphRenderContext.d.ts +14 -5
  55. package/FrameGraph/frameGraphRenderContext.js +34 -14
  56. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  57. package/FrameGraph/frameGraphTextureManager.d.ts +3 -1
  58. package/FrameGraph/frameGraphTextureManager.js +16 -10
  59. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  60. package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +1 -0
  61. package/Materials/Node/Blocks/PBR/reflectionBlock.js +4 -1
  62. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  63. package/Materials/Node/nodeMaterial.js +7 -0
  64. package/Materials/Node/nodeMaterial.js.map +1 -1
  65. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  66. package/Materials/PBR/pbrBaseMaterial.js +8 -6
  67. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  68. package/Materials/drawWrapper.d.ts +34 -2
  69. package/Materials/drawWrapper.js +22 -2
  70. package/Materials/drawWrapper.js.map +1 -1
  71. package/Materials/effectRenderer.d.ts +4 -0
  72. package/Materials/effectRenderer.js +2 -1
  73. package/Materials/effectRenderer.js.map +1 -1
  74. package/Materials/index.d.ts +1 -0
  75. package/Materials/index.js +1 -0
  76. package/Materials/index.js.map +1 -1
  77. package/Materials/material.d.ts +8 -1
  78. package/Materials/material.js +21 -1
  79. package/Materials/material.js.map +1 -1
  80. package/Materials/materialHelper.functions.d.ts +3 -1
  81. package/Materials/materialHelper.functions.js +7 -1
  82. package/Materials/materialHelper.functions.js.map +1 -1
  83. package/Materials/shaderMaterial.js +11 -0
  84. package/Materials/shaderMaterial.js.map +1 -1
  85. package/Materials/standardMaterial.d.ts +1 -0
  86. package/Materials/standardMaterial.js +2 -1
  87. package/Materials/standardMaterial.js.map +1 -1
  88. package/Materials/uniformBuffer.d.ts +6 -0
  89. package/Materials/uniformBuffer.js +8 -0
  90. package/Materials/uniformBuffer.js.map +1 -1
  91. package/Meshes/abstractMesh.js +3 -2
  92. package/Meshes/abstractMesh.js.map +1 -1
  93. package/Meshes/mesh.js +6 -0
  94. package/Meshes/mesh.js.map +1 -1
  95. package/Misc/fileTools.js +1 -1
  96. package/Misc/fileTools.js.map +1 -1
  97. package/States/index.d.ts +1 -0
  98. package/States/index.js +1 -0
  99. package/States/index.js.map +1 -1
  100. package/package.json +1 -1
@@ -2,7 +2,7 @@ import type { NodeRenderGraphConnectionPoint, Scene, NodeRenderGraphBuildState,
2
2
  import { NodeRenderGraphBlock } from "../../nodeRenderGraphBlock.js";
3
3
  interface IPostProcessLike {
4
4
  sourceSamplingMode: number;
5
- sourceTexture: FrameGraphTextureHandle;
5
+ sourceTexture?: FrameGraphTextureHandle;
6
6
  targetTexture?: FrameGraphTextureHandle;
7
7
  outputTexture: FrameGraphTextureHandle;
8
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"basePostProcessBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAStG;;GAEG;AACH,MAAM,OAAO,mCAAoC,SAAQ,oBAAoB;IAGzE;;;;;OAKG;IACH,YAAmB,IAAY,EAAE,UAAsB,EAAE,KAAY;QACjE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAE/B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAAU,CAAC,CAAC;QAClF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAExF,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,wCAAwC,CAAC,uBAAuB,CAAC,CAAC;QACzH,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,wCAAwC,CAAC,UAAU,CAAC,CAAC;IAChH,CAAC;IAES,+BAA+B;QACrC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,wCAAwC,CAAC,YAAY,CAAC,CAAC;QAErF,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,GAAG,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAC/D,C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EAAE,CAAC;QAC9C,mBAAmB,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;IACrE,CAAC;CACJ;AA9DG;IADC,sBAAsB,CAAC,sBAAsB,+CAAuC,YAAY,CAAC;6EAGjG","sourcesContent":["import type { NodeRenderGraphConnectionPoint, Scene, NodeRenderGraphBuildState, FrameGraphTextureHandle, FrameGraph, FrameGraphTask } from \"core/index\";\r\nimport { NodeRenderGraphBlock } from \"../../nodeRenderGraphBlock\";\r\nimport { NodeRenderGraphBlockConnectionPointTypes } from \"../../Types/nodeRenderGraphTypes\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\n\r\ninterface IPostProcessLike {\r\n sourceSamplingMode: number;\r\n sourceTexture: FrameGraphTextureHandle;\r\n targetTexture?: FrameGraphTextureHandle;\r\n outputTexture: FrameGraphTextureHandle;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class NodeRenderGraphBasePostProcessBlock extends NodeRenderGraphBlock {\r\n protected override _frameGraphTask: IPostProcessLike & FrameGraphTask;\r\n\r\n /**\r\n * Create a new NodeRenderGraphBasePostProcessBlock\r\n * @param name defines the block name\r\n * @param frameGraph defines the hosting frame graph\r\n * @param scene defines the hosting scene\r\n */\r\n public constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this.registerInput(\"source\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"target\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect, true);\r\n\r\n this.source.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAllButBackBuffer);\r\n this.target.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);\r\n }\r\n\r\n protected _finalizeInputOutputRegistering() {\r\n this._addDependenciesInput();\r\n this.registerOutput(\"output\", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = () => {\r\n return this.target.isConnected ? this.target : this.source;\r\n };\r\n }\r\n\r\n /** Sampling mode used to sample from the source texture */\r\n @editableInPropertyPage(\"Source sampling mode\", PropertyTypeForEdition.SamplingMode, \"PROPERTIES\")\r\n public get sourceSamplingMode() {\r\n return this._frameGraphTask.sourceSamplingMode;\r\n }\r\n\r\n public set sourceSamplingMode(value: number) {\r\n this._frameGraphTask.sourceSamplingMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeRenderGraphBasePostProcessBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeRenderGraphConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeRenderGraphBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.output.value = this._frameGraphTask.outputTexture;\r\n\r\n this._frameGraphTask.sourceTexture = this.source.connectedPoint?.value as FrameGraphTextureHandle;\r\n this._frameGraphTask.targetTexture = this.target.connectedPoint?.value as FrameGraphTextureHandle;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codes: string[] = [];\r\n codes.push(`${this._codeVariableName}.sourceSamplingMode = ${this.sourceSamplingMode};`);\r\n return super._dumpPropertiesCode() + codes.join(\"\\n\");\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.sourceSamplingMode = this.sourceSamplingMode;\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n this.sourceSamplingMode = serializationObject.sourceSamplingMode;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"basePostProcessBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAStG;;GAEG;AACH,MAAM,OAAO,mCAAoC,SAAQ,oBAAoB;IAGzE;;;;;OAKG;IACH,YAAmB,IAAY,EAAE,UAAsB,EAAE,KAAY;QACjE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAE/B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAAU,CAAC,CAAC;QAClF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAExF,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,wCAAwC,CAAC,uBAAuB,CAAC,CAAC;QACzH,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,wCAAwC,CAAC,UAAU,CAAC,CAAC;IAChH,CAAC;IAES,+BAA+B;QACrC,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,wCAAwC,CAAC,YAAY,CAAC,CAAC;QAErF,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,GAAG,EAAE;YACrC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,C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AAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAC9C,mBAAmB,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;IACrE,CAAC;CACJ;AA9DG;IADC,sBAAsB,CAAC,sBAAsB,+CAAuC,YAAY,CAAC;6EAGjG","sourcesContent":["import type { NodeRenderGraphConnectionPoint, Scene, NodeRenderGraphBuildState, FrameGraphTextureHandle, FrameGraph, FrameGraphTask } from \"core/index\";\r\nimport { NodeRenderGraphBlock } from \"../../nodeRenderGraphBlock\";\r\nimport { NodeRenderGraphBlockConnectionPointTypes } from \"../../Types/nodeRenderGraphTypes\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\n\r\ninterface IPostProcessLike {\r\n sourceSamplingMode: number;\r\n sourceTexture?: FrameGraphTextureHandle;\r\n targetTexture?: FrameGraphTextureHandle;\r\n outputTexture: FrameGraphTextureHandle;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class NodeRenderGraphBasePostProcessBlock extends NodeRenderGraphBlock {\r\n protected override _frameGraphTask: IPostProcessLike & FrameGraphTask;\r\n\r\n /**\r\n * Create a new NodeRenderGraphBasePostProcessBlock\r\n * @param name defines the block name\r\n * @param frameGraph defines the hosting frame graph\r\n * @param scene defines the hosting scene\r\n */\r\n public constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this.registerInput(\"source\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"target\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect, true);\r\n\r\n this.source.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAllButBackBuffer);\r\n this.target.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);\r\n }\r\n\r\n protected _finalizeInputOutputRegistering() {\r\n this._addDependenciesInput();\r\n this.registerOutput(\"output\", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = () => {\r\n return this.target.isConnected ? this.target : this.source;\r\n };\r\n }\r\n\r\n /** Sampling mode used to sample from the source texture */\r\n @editableInPropertyPage(\"Source sampling mode\", PropertyTypeForEdition.SamplingMode, \"PROPERTIES\")\r\n public get sourceSamplingMode() {\r\n return this._frameGraphTask.sourceSamplingMode;\r\n }\r\n\r\n public set sourceSamplingMode(value: number) {\r\n this._frameGraphTask.sourceSamplingMode = value;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeRenderGraphBasePostProcessBlock\";\r\n }\r\n\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeRenderGraphConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeRenderGraphBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.output.value = this._frameGraphTask.outputTexture;\r\n\r\n this._frameGraphTask.sourceTexture = this.source.connectedPoint?.value as FrameGraphTextureHandle;\r\n this._frameGraphTask.targetTexture = this.target.connectedPoint?.value as FrameGraphTextureHandle;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codes: string[] = [];\r\n codes.push(`${this._codeVariableName}.sourceSamplingMode = ${this.sourceSamplingMode};`);\r\n return super._dumpPropertiesCode() + codes.join(\"\\n\");\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.sourceSamplingMode = this.sourceSamplingMode;\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n this.sourceSamplingMode = serializationObject.sourceSamplingMode;\r\n }\r\n}\r\n"]}
@@ -23,6 +23,14 @@ export declare class FrameGraphRenderPass extends FrameGraphPass<FrameGraphRende
23
23
  * Gets the render target depth used by the render pass.
24
24
  */
25
25
  get renderTargetDepth(): FrameGraphTextureHandle | undefined;
26
+ /**
27
+ * If true, the depth attachment will be read-only (may allow some optimizations in WebGPU)
28
+ */
29
+ depthReadOnly: boolean;
30
+ /**
31
+ * If true, the stencil attachment will be read-only (may allow some optimizations in WebGPU)
32
+ */
33
+ stencilReadOnly: boolean;
26
34
  /** @internal */
27
35
  constructor(name: string, parentTask: FrameGraphTask, context: FrameGraphRenderContext, engine: AbstractEngine);
28
36
  /**
@@ -27,6 +27,14 @@ export class FrameGraphRenderPass extends FrameGraphPass {
27
27
  constructor(name, parentTask, context, engine) {
28
28
  super(name, parentTask, context);
29
29
  this._dependencies = new Set();
30
+ /**
31
+ * If true, the depth attachment will be read-only (may allow some optimizations in WebGPU)
32
+ */
33
+ this.depthReadOnly = false;
34
+ /**
35
+ * If true, the stencil attachment will be read-only (may allow some optimizations in WebGPU)
36
+ */
37
+ this.stencilReadOnly = false;
30
38
  this._engine = engine;
31
39
  }
32
40
  /**
@@ -87,7 +95,8 @@ export class FrameGraphRenderPass extends FrameGraphPass {
87
95
  }
88
96
  /** @internal */
89
97
  _execute() {
90
- this._frameGraphRenderTarget = this._frameGraphRenderTarget || this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth);
98
+ this._frameGraphRenderTarget =
99
+ this._frameGraphRenderTarget || this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth, this.depthReadOnly, this.stencilReadOnly);
91
100
  this._context.bindRenderTarget(this._frameGraphRenderTarget, `frame graph render pass - ${this.name}`);
92
101
  super._execute();
93
102
  this._context._flushDebugMessages();
@@ -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;AAExC;;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,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAAgC,EAAE,MAAsB;QAC1G,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QA3B3B,kBAAa,GAAiC,IAAI,GAAG,EAAE,CAAC;QA4B9D,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,CAAC,YAAY,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;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AI,CAAC,uBAAuB,EAAE,6BAA6B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEvG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEjB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACxC,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;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 * 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 | undefined;\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 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 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 /** @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) {\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) {\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) {\r\n dependencies.add(this._renderTargetDepth);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _execute() {\r\n this._frameGraphRenderTarget = this._frameGraphRenderTarget || this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth);\r\n\r\n this._context.bindRenderTarget(this._frameGraphRenderTarget, `frame graph render pass - ${this.name}`);\r\n\r\n super._execute();\r\n\r\n this._context._flushDebugMessages();\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"]}
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;AAExC;;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;IAYD,gBAAgB;IAChB,YAAY,IAAY,EAAE,UAA0B,EAAE,OAAgC,EAAE,MAAsB;QAC1G,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QArC3B,kBAAa,GAAiC,IAAI,GAAG,EAAE,CAAC;QAyBlE;;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,C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C;YACzC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,uBAAuB;YACxB,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAEvK,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,uBAAuB,EAAE,6BAA6B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAEvG,KAAK,CAAC,QAAQ,EAAE,CAAC;QAEjB,IAAI,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;IACxC,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;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 * 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 | undefined;\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 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 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 * 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) {\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) {\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) {\r\n dependencies.add(this._renderTargetDepth);\r\n }\r\n }\r\n\r\n /** @internal */\r\n public override _execute() {\r\n this._frameGraphRenderTarget =\r\n this._frameGraphRenderTarget || this._context.createRenderTarget(this.name, this._renderTarget, this._renderTargetDepth, this.depthReadOnly, this.stencilReadOnly);\r\n\r\n this._context.bindRenderTarget(this._frameGraphRenderTarget, `frame graph render pass - ${this.name}`);\r\n\r\n super._execute();\r\n\r\n this._context._flushDebugMessages();\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"]}
@@ -1,4 +1,4 @@
1
- import type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper } from "../../../index.js";
1
+ import type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, IStencilState } from "../../../index.js";
2
2
  import { FrameGraphTask } from "../../frameGraphTask.js";
3
3
  /**
4
4
  * Task which applies a post process.
@@ -6,8 +6,10 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
6
6
  export declare class FrameGraphPostProcessTask extends FrameGraphTask {
7
7
  /**
8
8
  * The source texture to apply the post process on.
9
+ * It's allowed to be undefined if the post process does not require a source texture.
10
+ * In that case, targetTexture must be provided.
9
11
  */
10
- sourceTexture: FrameGraphTextureHandle;
12
+ sourceTexture?: FrameGraphTextureHandle;
11
13
  /**
12
14
  * The sampling mode to use for the source texture.
13
15
  */
@@ -17,10 +19,52 @@ export declare class FrameGraphPostProcessTask extends FrameGraphTask {
17
19
  * If not supplied, a texture with the same configuration as the source texture will be created.
18
20
  */
19
21
  targetTexture?: FrameGraphTextureHandle;
22
+ /**
23
+ * The stencil state to use for the post process (optional).
24
+ */
25
+ stencilState?: IStencilState;
26
+ /**
27
+ * The depth attachment texture to use for the post process (optional).
28
+ * 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.
29
+ */
30
+ depthAttachmentTexture?: FrameGraphTextureHandle;
31
+ /**
32
+ * If true, the depth attachment will be read-only.
33
+ * This means that the post process will not write to the depth buffer.
34
+ * 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.
35
+ * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.
36
+ */
37
+ depthReadOnly: boolean;
38
+ /**
39
+ * If true, the stencil attachment will be read-only.
40
+ * This means that the post process will not write to the stencil buffer.
41
+ * 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.
42
+ * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.
43
+ */
44
+ stencilReadOnly: boolean;
45
+ /**
46
+ * If true, color write will be disabled when applying the post process.
47
+ * This means that the post process will not write to the color buffer.
48
+ */
49
+ disableColorWrite: boolean;
50
+ /**
51
+ * If true, the post process will be generated by a back face full-screen quad (CW order).
52
+ */
53
+ drawBackFace: boolean;
54
+ /**
55
+ * If depth testing should be enabled (default is true).
56
+ */
57
+ depthTest: boolean;
20
58
  /**
21
59
  * The output texture of the post process.
22
60
  */
23
61
  readonly outputTexture: FrameGraphTextureHandle;
62
+ /**
63
+ * The output depth attachment texture.
64
+ * This texture will point to the same texture than the depthAttachmentTexture property if it is set.
65
+ * Note, however, that the handle itself will be different!
66
+ */
67
+ readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;
24
68
  /**
25
69
  * The post process to apply.
26
70
  */
@@ -23,50 +23,97 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
23
23
  * The sampling mode to use for the source texture.
24
24
  */
25
25
  this.sourceSamplingMode = 2;
26
+ /**
27
+ * If true, the depth attachment will be read-only.
28
+ * This means that the post process will not write to the depth buffer.
29
+ * 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.
30
+ * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.
31
+ */
32
+ this.depthReadOnly = false;
33
+ /**
34
+ * If true, the stencil attachment will be read-only.
35
+ * This means that the post process will not write to the stencil buffer.
36
+ * 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.
37
+ * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.
38
+ */
39
+ this.stencilReadOnly = false;
40
+ /**
41
+ * If true, color write will be disabled when applying the post process.
42
+ * This means that the post process will not write to the color buffer.
43
+ */
44
+ this.disableColorWrite = false;
45
+ /**
46
+ * If true, the post process will be generated by a back face full-screen quad (CW order).
47
+ */
48
+ this.drawBackFace = false;
49
+ /**
50
+ * If depth testing should be enabled (default is true).
51
+ */
52
+ this.depthTest = true;
26
53
  this.postProcess = postProcess;
27
54
  this._postProcessDrawWrapper = this.postProcess.drawWrapper;
28
55
  this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
56
+ this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();
29
57
  this.onTexturesAllocatedObservable.add((context) => {
30
- context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);
58
+ if (this.sourceTexture !== undefined) {
59
+ context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);
60
+ }
31
61
  });
32
62
  }
33
63
  isReady() {
34
64
  return this.postProcess.isReady();
35
65
  }
36
66
  record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {
37
- if (this.sourceTexture === undefined) {
38
- throw new Error(`FrameGraphPostProcessTask "${this.name}": sourceTexture is required`);
67
+ if (this.sourceTexture === undefined && this.targetTexture === undefined) {
68
+ throw new Error(`FrameGraphPostProcessTask "${this.name}": sourceTexture or targetTexture is required`);
69
+ }
70
+ const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;
71
+ if (sourceTextureCreationOptions) {
72
+ sourceTextureCreationOptions.options.samples = 1;
39
73
  }
40
- const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);
41
- sourceTextureCreationOptions.options.samples = 1;
42
74
  this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);
43
- const sourceSize = !sourceTextureCreationOptions.sizeIsPercentage
44
- ? textureSizeIsObject(sourceTextureCreationOptions.size)
45
- ? sourceTextureCreationOptions.size
46
- : { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }
47
- : this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);
48
- this._sourceWidth = sourceSize.width;
49
- this._sourceHeight = sourceSize.height;
75
+ if (this.depthAttachmentTexture !== undefined) {
76
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);
77
+ }
78
+ if (sourceTextureCreationOptions) {
79
+ const sourceSize = !sourceTextureCreationOptions.sizeIsPercentage
80
+ ? textureSizeIsObject(sourceTextureCreationOptions.size)
81
+ ? sourceTextureCreationOptions.size
82
+ : { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }
83
+ : this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);
84
+ this._sourceWidth = sourceSize.width;
85
+ this._sourceHeight = sourceSize.height;
86
+ }
50
87
  const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);
51
88
  this._outputWidth = outputTextureDescription.size.width;
52
89
  this._outputHeight = outputTextureDescription.size.height;
53
90
  const pass = this._frameGraph.addRenderPass(this.name);
91
+ pass.depthReadOnly = this.depthReadOnly;
92
+ pass.stencilReadOnly = this.stencilReadOnly;
54
93
  pass.addDependencies(this.sourceTexture);
55
94
  pass.setRenderTarget(this.outputTexture);
95
+ pass.setRenderTargetDepth(this.depthAttachmentTexture);
56
96
  pass.setExecuteFunc((context) => {
57
97
  additionalExecute?.(context);
58
98
  context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {
59
- context.bindTextureHandle(this._postProcessDrawWrapper.effect, "textureSampler", this.sourceTexture);
99
+ if (this.sourceTexture !== undefined) {
100
+ context.bindTextureHandle(this._postProcessDrawWrapper.effect, "textureSampler", this.sourceTexture);
101
+ }
60
102
  additionalBindings?.(context);
61
103
  this.postProcess.bind();
62
- });
104
+ }, this.stencilState, this.disableColorWrite, this.drawBackFace, this.depthTest);
63
105
  });
64
106
  if (!skipCreationOfDisabledPasses) {
65
107
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
108
+ passDisabled.depthReadOnly = this.depthReadOnly;
109
+ passDisabled.stencilReadOnly = this.stencilReadOnly;
66
110
  passDisabled.addDependencies(this.sourceTexture);
67
111
  passDisabled.setRenderTarget(this.outputTexture);
112
+ passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);
68
113
  passDisabled.setExecuteFunc((context) => {
69
- context.copyTexture(this.sourceTexture);
114
+ if (this.sourceTexture !== undefined) {
115
+ context.copyTexture(this.sourceTexture);
116
+ }
70
117
  });
71
118
  }
72
119
  return pass;
@@ -1 +1 @@
1
- {"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AAEzF;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IA2BzD;;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;QAzC5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAwChE,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;QAE5E,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC/C,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IAEM,MAAM,CACT,4BAA4B,GAAG,KAAK,EACpC,iBAA8D,EAC9D,kBAA+D;QAE/D,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YAC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CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC;YAC7B,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;gBAC7D,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;gBACtG,kBAAkB,EAAE,CAAC,OAAO,CAAC,CAAC;gBAC9B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YAC5B,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC5C,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 { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { textureSizeIsObject } from \"../../../Materials/Textures/textureCreationOptions\";\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 */\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 output texture of the post process.\r\n */\r\n public readonly outputTexture: 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\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n });\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\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) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n sourceTextureCreationOptions.options.samples = 1;\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n\r\n const sourceSize = !sourceTextureCreationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(sourceTextureCreationOptions.size)\r\n ? sourceTextureCreationOptions.size\r\n : { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }\r\n : this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\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.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setExecuteFunc((context) => {\r\n additionalExecute?.(context);\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\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.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\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":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AAEzF;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IA+EzD;;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;QA3F5B;;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;QAyCpB,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;QAE3F,IAAI,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YAC/C,IAAI,IA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type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, IStencilState } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { textureSizeIsObject } from \"../../../Materials/Textures/textureCreationOptions\";\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?: IStencilState;\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 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 this.onTexturesAllocatedObservable.add((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n });\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\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 = !sourceTextureCreationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(sourceTextureCreationOptions.size)\r\n ? sourceTextureCreationOptions.size\r\n : { width: sourceTextureCreationOptions.size, height: sourceTextureCreationOptions.size }\r\n : this._frameGraph.textureManager.getAbsoluteDimensions(sourceTextureCreationOptions.size);\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 additionalExecute?.(context);\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 );\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 context.copyTexture(this.sourceTexture);\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"]}
@@ -25,6 +25,10 @@ export declare class FrameGraphClearTextureTask extends FrameGraphTask {
25
25
  * If the stencil should be cleared.
26
26
  */
27
27
  clearStencil: boolean;
28
+ /**
29
+ * The value to use to clear the stencil buffer (default: 0).
30
+ */
31
+ stencilValue: number;
28
32
  /**
29
33
  * The color texture to clear.
30
34
  */
@@ -31,6 +31,10 @@ export class FrameGraphClearTextureTask extends FrameGraphTask {
31
31
  * If the stencil should be cleared.
32
32
  */
33
33
  this.clearStencil = false;
34
+ /**
35
+ * The value to use to clear the stencil buffer (default: 0).
36
+ */
37
+ this.stencilValue = 0;
34
38
  this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
35
39
  this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
36
40
  }
@@ -62,7 +66,7 @@ export class FrameGraphClearTextureTask extends FrameGraphTask {
62
66
  if (this.convertColorToLinearSpace) {
63
67
  color.toLinearSpaceToRef(color);
64
68
  }
65
- context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);
69
+ context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);
66
70
  });
67
71
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
68
72
  passDisabled.setRenderTarget(targetTextures);
@@ -1 +1 @@
1
- {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,cAAc;IA8C1D;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAnD5B;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAE5C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAEzB;;WAEG;QACI,8BAAyB,GAAG,KAAK,CAAC;QAEzC;;WAEG;QACI,eAAU,GAAG,KAAK,CAAC;QAE1B;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QA8BxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;QAC5E,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC;IACrF,CAAC;IAEM,MAAM;QACT,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACtE,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,IAAI,2DAA2D,CA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\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | FrameGraphTextureHandle[];\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as targetTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record(): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n let textureSamples = 0;\r\n let depthSamples = 0;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureSamples = this._frameGraph.textureManager.getTextureDescription(targetTextures![0]).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n depthSamples = this._frameGraph.textureManager.getTextureDescription(this.depthTexture).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture and the target texture must have the same number of samples.`);\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(targetTextures ? Array(targetTextures.length).fill(true) : []);\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"clearTextureTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Texture/clearTextureTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ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AAE,EAAE;YAC5B,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,IAAI,IAAI,CAAC,yBAAyB,EAAE,CAAC;gBACjC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC;YAED,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/H,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC7C,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, FrameGraphRenderPass } from \"core/index\";\r\nimport { Color4, TmpColors } from \"../../../Maths/math.color\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to clear a texture.\r\n */\r\nexport class FrameGraphClearTextureTask extends FrameGraphTask {\r\n /**\r\n * The color to clear the texture with.\r\n */\r\n public color = new Color4(0.2, 0.2, 0.3, 1);\r\n\r\n /**\r\n * If the color should be cleared.\r\n */\r\n public clearColor = true;\r\n\r\n /**\r\n * If the color should be converted to linear space (default: false).\r\n */\r\n public convertColorToLinearSpace = false;\r\n\r\n /**\r\n * If the depth should be cleared.\r\n */\r\n public clearDepth = false;\r\n\r\n /**\r\n * If the stencil should be cleared.\r\n */\r\n public clearStencil = false;\r\n\r\n /**\r\n * The value to use to clear the stencil buffer (default: 0).\r\n */\r\n public stencilValue = 0;\r\n\r\n /**\r\n * The color texture to clear.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle | FrameGraphTextureHandle[];\r\n\r\n /**\r\n * The depth attachment texture to clear.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture (same as targetTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth texture (same as depthTexture, but the handle will be different).\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * Constructs a new clear task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public record(): FrameGraphRenderPass {\r\n if (this.targetTexture === undefined && this.depthTexture === undefined) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: targetTexture and depthTexture can't both be undefined.`);\r\n }\r\n\r\n const targetTextures = this.targetTexture !== undefined ? (Array.isArray(this.targetTexture) ? this.targetTexture : [this.targetTexture]) : undefined;\r\n\r\n let textureSamples = 0;\r\n let depthSamples = 0;\r\n\r\n if (this.targetTexture !== undefined) {\r\n textureSamples = this._frameGraph.textureManager.getTextureDescription(targetTextures![0]).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, targetTextures![0]);\r\n }\r\n if (this.depthTexture !== undefined) {\r\n depthSamples = this._frameGraph.textureManager.getTextureDescription(this.depthTexture).options.samples || 1;\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n if (textureSamples !== depthSamples && textureSamples !== 0 && depthSamples !== 0) {\r\n throw new Error(`FrameGraphClearTextureTask ${this.name}: the depth texture and the target texture must have the same number of samples.`);\r\n }\r\n\r\n const attachments = this._frameGraph.engine.buildTextureLayout(targetTextures ? Array(targetTextures.length).fill(true) : []);\r\n\r\n const color = TmpColors.Color4[0];\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(targetTextures);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n color.copyFrom(this.color);\r\n if (this.convertColorToLinearSpace) {\r\n color.toLinearSpaceToRef(color);\r\n }\r\n\r\n context.clearAttachments(color, attachments, !!this.clearColor, !!this.clearDepth, !!this.clearStencil, this.stencilValue);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(targetTextures);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene, FrameGraphRenderTarget, UtilityLayerRenderer } from "../index.js";
1
+ import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene, FrameGraphRenderTarget, UtilityLayerRenderer, IStencilState } from "../index.js";
2
2
  import { FrameGraphContext } from "./frameGraphContext.js";
3
3
  /**
4
4
  * Frame graph context used render passes.
@@ -6,6 +6,7 @@ import { FrameGraphContext } from "./frameGraphContext.js";
6
6
  */
7
7
  export declare class FrameGraphRenderContext extends FrameGraphContext {
8
8
  private readonly _effectRenderer;
9
+ private readonly _effectRendererBack;
9
10
  private _currentRenderTarget;
10
11
  private _debugMessageWhenTargetBound;
11
12
  private _debugMessageHasBeenPushed;
@@ -38,17 +39,20 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
38
39
  * @param name Name of the render target wrapper
39
40
  * @param renderTargets Render target handles (textures) to use
40
41
  * @param renderTargetDepth Render target depth handle (texture) to use
42
+ * @param depthReadOnly If true, the depth buffer will be read-only
43
+ * @param stencilReadOnly If true, the stencil buffer will be read-only
41
44
  * @returns The created render target wrapper
42
45
  */
43
- createRenderTarget(name: string, renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[], renderTargetDepth?: FrameGraphTextureHandle): FrameGraphRenderTarget;
46
+ createRenderTarget(name: string, renderTargets?: FrameGraphTextureHandle | FrameGraphTextureHandle[], renderTargetDepth?: FrameGraphTextureHandle, depthReadOnly?: boolean, stencilReadOnly?: boolean): FrameGraphRenderTarget;
44
47
  /**
45
48
  * Clears the current render buffer or the current render target (if any is set up)
46
49
  * @param color Defines the color to use
47
50
  * @param backBuffer Defines if the back buffer must be cleared
48
51
  * @param depth Defines if the depth buffer must be cleared
49
52
  * @param stencil Defines if the stencil buffer must be cleared
53
+ * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)
50
54
  */
51
- clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
55
+ clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue?: number): void;
52
56
  /**
53
57
  * Clears the color attachments of the current render target
54
58
  * @param color Defines the color to use
@@ -62,8 +66,9 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
62
66
  * @param backBuffer Defines if the back buffer must be cleared
63
67
  * @param depth Defines if the depth buffer must be cleared
64
68
  * @param stencil Defines if the stencil buffer must be cleared
69
+ * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)
65
70
  */
66
- clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean): void;
71
+ clearAttachments(color: Nullable<IColor4Like>, attachments: number[], backBuffer: boolean, depth: boolean, stencil?: boolean, stencilClearValue?: number): void;
67
72
  /**
68
73
  * Binds the attachments to the current render target
69
74
  * @param attachments The attachments to bind
@@ -90,9 +95,13 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
90
95
  * Applies a full-screen effect to the current render target
91
96
  * @param drawWrapper The draw wrapper containing the effect to apply
92
97
  * @param customBindings The custom bindings to use when applying the effect (optional)
98
+ * @param stencilState The stencil state to use when applying the effect (optional)
99
+ * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)
100
+ * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)
101
+ * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)
93
102
  * @returns True if the effect was applied, otherwise false (effect not ready)
94
103
  */
95
- applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void): boolean;
104
+ applyFullScreenEffect(drawWrapper: DrawWrapper, customBindings?: () => void, stencilState?: IStencilState, disableColorWrite?: boolean, drawBackFace?: boolean, depthTest?: boolean): boolean;
96
105
  /**
97
106
  * Copies a texture to the current render target
98
107
  * @param sourceTexture The source texture to copy from
@@ -16,6 +16,10 @@ export class FrameGraphRenderContext extends FrameGraphContext {
16
16
  this._debugMessageHasBeenPushed = false;
17
17
  this._renderTargetIsBound = true;
18
18
  this._effectRenderer = new EffectRenderer(this._engine);
19
+ this._effectRendererBack = new EffectRenderer(this._engine, {
20
+ positions: [1, 1, -1, 1, -1, -1, 1, -1],
21
+ indices: [0, 2, 1, 0, 3, 2],
22
+ });
19
23
  this._copyTexture = new CopyTextureToTexture(this._engine);
20
24
  }
21
25
  /**
@@ -48,10 +52,12 @@ export class FrameGraphRenderContext extends FrameGraphContext {
48
52
  * @param name Name of the render target wrapper
49
53
  * @param renderTargets Render target handles (textures) to use
50
54
  * @param renderTargetDepth Render target depth handle (texture) to use
55
+ * @param depthReadOnly If true, the depth buffer will be read-only
56
+ * @param stencilReadOnly If true, the stencil buffer will be read-only
51
57
  * @returns The created render target wrapper
52
58
  */
53
- createRenderTarget(name, renderTargets, renderTargetDepth) {
54
- return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth);
59
+ createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly) {
60
+ return this._textureManager.createRenderTarget(name, renderTargets, renderTargetDepth, depthReadOnly, stencilReadOnly);
55
61
  }
56
62
  /**
57
63
  * Clears the current render buffer or the current render target (if any is set up)
@@ -59,10 +65,11 @@ export class FrameGraphRenderContext extends FrameGraphContext {
59
65
  * @param backBuffer Defines if the back buffer must be cleared
60
66
  * @param depth Defines if the depth buffer must be cleared
61
67
  * @param stencil Defines if the stencil buffer must be cleared
68
+ * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)
62
69
  */
63
- clear(color, backBuffer, depth, stencil) {
70
+ clear(color, backBuffer, depth, stencil, stencilClearValue = 0) {
64
71
  this._applyRenderTarget();
65
- this._engine.clear(color, backBuffer, depth, stencil);
72
+ this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);
66
73
  }
67
74
  /**
68
75
  * Clears the color attachments of the current render target
@@ -81,11 +88,12 @@ export class FrameGraphRenderContext extends FrameGraphContext {
81
88
  * @param backBuffer Defines if the back buffer must be cleared
82
89
  * @param depth Defines if the depth buffer must be cleared
83
90
  * @param stencil Defines if the stencil buffer must be cleared
91
+ * @param stencilClearValue Defines the value to use to clear the stencil buffer (default is 0)
84
92
  */
85
- clearAttachments(color, attachments, backBuffer, depth, stencil) {
93
+ clearAttachments(color, attachments, backBuffer, depth, stencil, stencilClearValue = 0) {
86
94
  this._applyRenderTarget();
87
95
  this._engine.bindAttachments(attachments);
88
- this._engine.clear(color, backBuffer, depth, stencil);
96
+ this._engine.clear(color, backBuffer, depth, stencil, stencilClearValue);
89
97
  }
90
98
  /**
91
99
  * Binds the attachments to the current render target
@@ -153,24 +161,35 @@ export class FrameGraphRenderContext extends FrameGraphContext {
153
161
  * Applies a full-screen effect to the current render target
154
162
  * @param drawWrapper The draw wrapper containing the effect to apply
155
163
  * @param customBindings The custom bindings to use when applying the effect (optional)
164
+ * @param stencilState The stencil state to use when applying the effect (optional)
165
+ * @param disableColorWrite If true, color write will be disabled when applying the effect (optional)
166
+ * @param drawBackFace If true, the fullscreen quad will be drawn as a back face (in CW - optional)
167
+ * @param depthTest If true, depth testing will be enabled when applying the effect (default is false)
156
168
  * @returns True if the effect was applied, otherwise false (effect not ready)
157
169
  */
158
- applyFullScreenEffect(drawWrapper, customBindings) {
170
+ applyFullScreenEffect(drawWrapper, customBindings, stencilState, disableColorWrite, drawBackFace, depthTest) {
159
171
  if (!drawWrapper.effect?.isReady()) {
160
172
  return false;
161
173
  }
162
174
  this._applyRenderTarget();
163
175
  const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates
164
- this._effectRenderer.saveStates();
165
- this._effectRenderer.setViewport();
176
+ const effectRenderer = drawBackFace ? this._effectRendererBack : this._effectRenderer;
177
+ effectRenderer.saveStates();
178
+ effectRenderer.setViewport();
166
179
  this._engine.enableEffect(drawWrapper);
167
- this._engine.setState(false);
168
- this._engine.setDepthBuffer(false);
180
+ this._engine.setState(false, undefined, undefined, undefined, undefined, stencilState);
181
+ this._engine.setDepthBuffer(!!depthTest);
182
+ if (disableColorWrite) {
183
+ this._engine.setColorWrite(false);
184
+ }
169
185
  this._engine.setDepthWrite(false);
170
- this._effectRenderer.bindBuffers(drawWrapper.effect);
186
+ effectRenderer.bindBuffers(drawWrapper.effect);
171
187
  customBindings?.();
172
- this._effectRenderer.draw();
173
- this._effectRenderer.restoreStates();
188
+ effectRenderer.draw();
189
+ effectRenderer.restoreStates();
190
+ if (disableColorWrite) {
191
+ this._engine.setColorWrite(true);
192
+ }
174
193
  this._engine.setDepthWrite(engineDepthMask);
175
194
  this._engine.setAlphaMode(0);
176
195
  return true;
@@ -271,6 +290,7 @@ export class FrameGraphRenderContext extends FrameGraphContext {
271
290
  /** @internal */
272
291
  _dispose() {
273
292
  this._effectRenderer.dispose();
293
+ this._effectRendererBack.dispose();
274
294
  this._copyTexture.dispose();
275
295
  }
276
296
  }