@babylonjs/core 7.35.1 → 7.36.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 (180) hide show
  1. package/Engines/Extensions/engine.multiRender.d.ts +11 -0
  2. package/Engines/Extensions/engine.multiRender.js +71 -32
  3. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  4. package/Engines/Extensions/engine.prefilteredCubeTexture.js +3 -2
  5. package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
  6. package/Engines/Extensions/engine.renderTarget.js +1 -13
  7. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  8. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +2 -0
  9. package/Engines/WebGL/webGLRenderTargetWrapper.js +37 -7
  10. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  11. package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +11 -0
  12. package/Engines/WebGPU/Extensions/engine.multiRender.js +30 -11
  13. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -5
  15. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  16. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +3 -2
  17. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  18. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +3 -1
  19. package/Engines/WebGPU/webgpuHardwareTexture.js +5 -4
  20. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  21. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  22. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  23. package/Engines/abstractEngine.d.ts +11 -0
  24. package/Engines/abstractEngine.js +2 -2
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/renderTargetWrapper.d.ts +33 -1
  27. package/Engines/renderTargetWrapper.js +64 -4
  28. package/Engines/renderTargetWrapper.js.map +1 -1
  29. package/Engines/thinEngine.d.ts +13 -1
  30. package/Engines/thinEngine.js +115 -24
  31. package/Engines/thinEngine.js.map +1 -1
  32. package/Engines/thinWebGPUEngine.d.ts +2 -0
  33. package/Engines/thinWebGPUEngine.js +7 -0
  34. package/Engines/thinWebGPUEngine.js.map +1 -1
  35. package/Engines/webgpuEngine.d.ts +12 -3
  36. package/Engines/webgpuEngine.js +39 -9
  37. package/Engines/webgpuEngine.js.map +1 -1
  38. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +8 -0
  39. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +22 -1
  40. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  41. package/FrameGraph/Node/Blocks/inputBlock.d.ts +4 -9
  42. package/FrameGraph/Node/Blocks/inputBlock.js +15 -25
  43. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  44. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -2
  45. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  46. package/FrameGraph/Passes/renderPass.d.ts +10 -10
  47. package/FrameGraph/Passes/renderPass.js +10 -10
  48. package/FrameGraph/Passes/renderPass.js.map +1 -1
  49. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +10 -5
  50. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +29 -14
  51. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  52. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -0
  53. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  54. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +11 -6
  55. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +30 -13
  56. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  57. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -6
  58. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  59. package/FrameGraph/Tasks/Rendering/cullObjectsTask.d.ts +1 -1
  60. package/FrameGraph/Tasks/Rendering/cullObjectsTask.js.map +1 -1
  61. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +3 -3
  62. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +33 -32
  63. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  64. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -2
  65. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +8 -12
  66. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  67. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +13 -18
  68. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  69. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +15 -2
  70. package/FrameGraph/Tasks/Texture/clearTextureTask.js +17 -4
  71. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  72. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +2 -2
  73. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  74. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +3 -3
  75. package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -1
  76. package/FrameGraph/frameGraph.d.ts +11 -74
  77. package/FrameGraph/frameGraph.js +12 -126
  78. package/FrameGraph/frameGraph.js.map +1 -1
  79. package/FrameGraph/frameGraphRenderContext.d.ts +17 -8
  80. package/FrameGraph/frameGraphRenderContext.js +55 -43
  81. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  82. package/FrameGraph/frameGraphRenderTarget.d.ts +16 -0
  83. package/FrameGraph/frameGraphRenderTarget.js +67 -0
  84. package/FrameGraph/frameGraphRenderTarget.js.map +1 -0
  85. package/FrameGraph/frameGraphTask.d.ts +4 -3
  86. package/FrameGraph/frameGraphTask.js +41 -8
  87. package/FrameGraph/frameGraphTask.js.map +1 -1
  88. package/FrameGraph/frameGraphTextureManager.d.ts +130 -22
  89. package/FrameGraph/frameGraphTextureManager.js +312 -130
  90. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  91. package/FrameGraph/frameGraphTypes.d.ts +28 -13
  92. package/FrameGraph/frameGraphTypes.js.map +1 -1
  93. package/FrameGraph/index.d.ts +1 -0
  94. package/FrameGraph/index.js +1 -0
  95. package/FrameGraph/index.js.map +1 -1
  96. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +3 -2
  97. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  98. package/Materials/Node/Blocks/conditionalBlock.d.ts +2 -0
  99. package/Materials/Node/Blocks/conditionalBlock.js +13 -0
  100. package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
  101. package/Materials/Node/nodeMaterialBlock.js +4 -1
  102. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  103. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +12 -4
  104. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  105. package/Materials/Textures/equiRectangularCubeTexture.js +14 -4
  106. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  107. package/Materials/Textures/internalTexture.d.ts +20 -0
  108. package/Materials/Textures/internalTexture.js +48 -0
  109. package/Materials/Textures/internalTexture.js.map +1 -1
  110. package/Materials/Textures/multiRenderTarget.d.ts +5 -0
  111. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  112. package/Materials/Textures/textureCreationOptions.d.ts +6 -6
  113. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  114. package/Materials/drawWrapper.js +4 -0
  115. package/Materials/drawWrapper.js.map +1 -1
  116. package/Materials/effect.js +2 -2
  117. package/Materials/effect.js.map +1 -1
  118. package/Materials/material.d.ts +2 -2
  119. package/Materials/material.js +5 -5
  120. package/Materials/material.js.map +1 -1
  121. package/Maths/math.color.d.ts +16 -0
  122. package/Maths/math.color.js +16 -0
  123. package/Maths/math.color.js.map +1 -1
  124. package/Maths/math.vector.d.ts +32 -0
  125. package/Maths/math.vector.js +32 -0
  126. package/Maths/math.vector.js.map +1 -1
  127. package/Meshes/Compression/dracoCompression.d.ts +3 -1
  128. package/Meshes/Compression/dracoCompression.js +5 -2
  129. package/Meshes/Compression/dracoCompression.js.map +1 -1
  130. package/Meshes/Node/Blocks/Matrices/rotationXBlock.d.ts +0 -1
  131. package/Meshes/Node/Blocks/Matrices/rotationXBlock.js +1 -9
  132. package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -1
  133. package/Meshes/Node/Blocks/Matrices/rotationYBlock.d.ts +0 -1
  134. package/Meshes/Node/Blocks/Matrices/rotationYBlock.js +1 -9
  135. package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -1
  136. package/Meshes/Node/Blocks/Matrices/rotationZBlock.d.ts +0 -1
  137. package/Meshes/Node/Blocks/Matrices/rotationZBlock.js +1 -9
  138. package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -1
  139. package/Meshes/Node/Blocks/Set/latticeBlock.js +3 -1
  140. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
  141. package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
  142. package/Meshes/Node/Blocks/conditionBlock.js +15 -0
  143. package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
  144. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +4 -4
  145. package/Meshes/Node/Blocks/geometryClampBlock.js +16 -25
  146. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  147. package/Meshes/Node/Blocks/geometryLerpBlock.js +2 -2
  148. package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -1
  149. package/Meshes/Node/Blocks/geometryNLerpBlock.js +2 -2
  150. package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -1
  151. package/Meshes/Node/Blocks/geometryReplaceColorBlock.js +2 -2
  152. package/Meshes/Node/Blocks/geometryReplaceColorBlock.js.map +1 -1
  153. package/Meshes/Node/Blocks/geometryRotate2dBlock.js +2 -2
  154. package/Meshes/Node/Blocks/geometryRotate2dBlock.js.map +1 -1
  155. package/Meshes/Node/Blocks/geometrySmoothStepBlock.js +3 -3
  156. package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -1
  157. package/Meshes/Node/Blocks/geometryStepBlock.js +2 -2
  158. package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -1
  159. package/Meshes/Node/nodeGeometry.js +1 -1
  160. package/Meshes/Node/nodeGeometry.js.map +1 -1
  161. package/Meshes/Node/nodeGeometryBlock.d.ts +3 -1
  162. package/Meshes/Node/nodeGeometryBlock.js +2 -1
  163. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  164. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +10 -2
  165. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  166. package/Meshes/abstractMesh.js +1 -1
  167. package/Meshes/abstractMesh.js.map +1 -1
  168. package/Meshes/lattice.material.d.ts +1 -1
  169. package/Meshes/lattice.material.js +3 -3
  170. package/Meshes/lattice.material.js.map +1 -1
  171. package/Misc/observable.d.ts +3 -1
  172. package/Misc/observable.js +7 -2
  173. package/Misc/observable.js.map +1 -1
  174. package/ShadersWGSL/glowMapGeneration.fragment.js +4 -3
  175. package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
  176. package/ShadersWGSL/pbr.fragment.js +4 -3
  177. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  178. package/package.json +1 -1
  179. package/scene.js +6 -6
  180. package/scene.js.map +1 -1
@@ -83,17 +83,17 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
83
83
  this.name = name;
84
84
  this._clearAttachmentsLayout = new Map();
85
85
  this._allAttachmentsLayout = [];
86
- this.outputDepthTexture = this._frameGraph.createDanglingHandle();
87
- this.geometryViewDepthTexture = this._frameGraph.createDanglingHandle();
88
- this.geometryScreenDepthTexture = this._frameGraph.createDanglingHandle();
89
- this.geometryViewNormalTexture = this._frameGraph.createDanglingHandle();
90
- this.geometryWorldNormalTexture = this._frameGraph.createDanglingHandle();
91
- this.geometryLocalPositionTexture = this._frameGraph.createDanglingHandle();
92
- this.geometryWorldPositionTexture = this._frameGraph.createDanglingHandle();
93
- this.geometryAlbedoTexture = this._frameGraph.createDanglingHandle();
94
- this.geometryReflectivityTexture = this._frameGraph.createDanglingHandle();
95
- this.geometryVelocityTexture = this._frameGraph.createDanglingHandle();
96
- this.geometryLinearVelocityTexture = this._frameGraph.createDanglingHandle();
86
+ this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
87
+ this.geometryViewDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
88
+ this.geometryScreenDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
89
+ this.geometryViewNormalTexture = this._frameGraph.textureManager.createDanglingHandle();
90
+ this.geometryWorldNormalTexture = this._frameGraph.textureManager.createDanglingHandle();
91
+ this.geometryLocalPositionTexture = this._frameGraph.textureManager.createDanglingHandle();
92
+ this.geometryWorldPositionTexture = this._frameGraph.textureManager.createDanglingHandle();
93
+ this.geometryAlbedoTexture = this._frameGraph.textureManager.createDanglingHandle();
94
+ this.geometryReflectivityTexture = this._frameGraph.textureManager.createDanglingHandle();
95
+ this.geometryVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();
96
+ this.geometryLinearVelocityTexture = this._frameGraph.textureManager.createDanglingHandle();
97
97
  }
98
98
  /**
99
99
  * Gets the list of excluded meshes from the velocity texture.
@@ -112,54 +112,52 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
112
112
  const depthEnabled = this._checkDepthTextureCompatibility();
113
113
  this._buildClearAttachmentsLayout();
114
114
  this._registerForRenderPassId(this._renderer.renderPassId);
115
- const outputTextureDescription = this._frameGraph.getTextureDescription(outputTextureHandle);
115
+ const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(outputTextureHandle[0]);
116
116
  this._textureWidth = outputTextureDescription.size.width;
117
117
  this._textureHeight = outputTextureDescription.size.height;
118
118
  // Create pass
119
119
  MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);
120
120
  const pass = this._frameGraph.addRenderPass(this.name);
121
121
  pass.setRenderTarget(outputTextureHandle);
122
- let handle = outputTextureHandle + 1;
123
122
  for (let i = 0; i < this.textureDescriptions.length; i++) {
124
123
  const description = this.textureDescriptions[i];
124
+ const handle = outputTextureHandle[i];
125
125
  const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);
126
126
  const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];
127
127
  switch (geometryDescription.type) {
128
128
  case 5:
129
- this._frameGraph.resolveDanglingHandle(this.geometryViewDepthTexture, handle++);
129
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewDepthTexture, handle);
130
130
  break;
131
131
  case 10:
132
- this._frameGraph.resolveDanglingHandle(this.geometryScreenDepthTexture, handle++);
132
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryScreenDepthTexture, handle);
133
133
  break;
134
134
  case 6:
135
- this._frameGraph.resolveDanglingHandle(this.geometryViewNormalTexture, handle++);
135
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryViewNormalTexture, handle);
136
136
  break;
137
137
  case 8:
138
- this._frameGraph.resolveDanglingHandle(this.geometryWorldNormalTexture, handle++);
138
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldNormalTexture, handle);
139
139
  break;
140
140
  case 9:
141
- this._frameGraph.resolveDanglingHandle(this.geometryLocalPositionTexture, handle++);
141
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLocalPositionTexture, handle);
142
142
  break;
143
143
  case 1:
144
- this._frameGraph.resolveDanglingHandle(this.geometryWorldPositionTexture, handle++);
144
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryWorldPositionTexture, handle);
145
145
  break;
146
146
  case 12:
147
- this._frameGraph.resolveDanglingHandle(this.geometryAlbedoTexture, handle++);
147
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryAlbedoTexture, handle);
148
148
  break;
149
149
  case 3:
150
- this._frameGraph.resolveDanglingHandle(this.geometryReflectivityTexture, handle++);
150
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryReflectivityTexture, handle);
151
151
  break;
152
152
  case 2:
153
- this._frameGraph.resolveDanglingHandle(this.geometryVelocityTexture, handle++);
153
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryVelocityTexture, handle);
154
154
  break;
155
155
  case 11:
156
- this._frameGraph.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle++);
156
+ this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);
157
157
  break;
158
158
  }
159
159
  }
160
- if (this.depthTexture !== undefined) {
161
- pass.setRenderTargetDepth(this.depthTexture);
162
- }
160
+ pass.setRenderTargetDepth(this.depthTexture);
163
161
  pass.setExecuteFunc((context) => {
164
162
  this._renderer.renderList = this.objectList.meshes;
165
163
  this._renderer.particleSystemList = this.objectList.particleSystems;
@@ -192,20 +190,23 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
192
190
  labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;
193
191
  useSRGBBuffers[i] = false;
194
192
  }
195
- return this._frameGraph.createRenderTargetTexture(this.name, {
193
+ const baseHandle = this._frameGraph.textureManager.createRenderTargetTexture(this.name, {
196
194
  size: this.size,
197
195
  sizeIsPercentage: this.sizeIsPercentage,
198
196
  options: {
199
197
  createMipMaps: false,
200
- generateDepthBuffer: false,
201
- textureCount: this.textureDescriptions.length,
202
198
  samples: this.samples,
203
199
  types,
204
200
  formats,
205
201
  useSRGBBuffers,
206
202
  labels,
207
203
  },
208
- }, true);
204
+ });
205
+ const handles = [];
206
+ for (let i = 0; i < this.textureDescriptions.length; i++) {
207
+ handles.push(baseHandle + i);
208
+ }
209
+ return handles;
209
210
  }
210
211
  _checkDepthTextureCompatibility() {
211
212
  let depthEnabled = false;
@@ -213,11 +214,11 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
213
214
  if (this.depthTexture === backbufferDepthStencilTextureHandle) {
214
215
  throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);
215
216
  }
216
- const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);
217
+ const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
217
218
  if (depthTextureDescription.options.samples !== this.samples) {
218
219
  throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);
219
220
  }
220
- this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
221
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
221
222
  depthEnabled = true;
222
223
  }
223
224
  return depthEnabled;
@@ -1 +1 @@
1
- {"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAE,+DAAwD;AAClG,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuBnE,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,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,G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r\n Camera,\r\n AbstractEngine,\r\n FrameGraph,\r\n GeometryRenderingTextureClearType,\r\n FrameGraphObjectList,\r\n AbstractMesh,\r\n ObjectRendererOptions,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\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(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\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 /**\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 output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The 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 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 * The object renderer used by the geometry renderer task.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\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 _engine: AbstractEngine;\r\n private _scene: Scene;\r\n private _renderer: ObjectRenderer;\r\n private _textureWidth: number;\r\n private _textureHeight: number;\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 */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this._renderer.renderSprites = false;\r\n this._renderer.renderParticles = false;\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.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.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 public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(outputTextureHandle);\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n let handle = outputTextureHandle + 1;\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 switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryScreenDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLocalPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryAlbedoTexture, handle++);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryReflectivityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryVelocityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle++);\r\n break;\r\n }\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\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 context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n });\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 private _createMultiRenderTargetTexture(): 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 return this._frameGraph.createRenderTargetTexture(\r\n this.name,\r\n {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n generateDepthBuffer: false,\r\n textureCount: this.textureDescriptions.length,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n },\r\n true\r\n );\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n return depthEnabled;\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 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}\r\n"]}
1
+ {"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAE,+DAAwD;AAClG,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuBnE,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,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,cAAc;IAQ9D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IA8FD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,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ameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n AbstractEngine,\r\n FrameGraph,\r\n GeometryRenderingTextureClearType,\r\n FrameGraphObjectList,\r\n AbstractMesh,\r\n ObjectRendererOptions,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\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(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\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 /**\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 output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The 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 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 * The object renderer used by the geometry renderer task.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\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 readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _renderer: ObjectRenderer;\r\n private _textureWidth: number;\r\n private _textureHeight: number;\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 */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this._renderer.renderSprites = false;\r\n this._renderer.renderParticles = false;\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.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.geometryViewDepthTexture = 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 public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(outputTextureHandle[0]);\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const handle = outputTextureHandle[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_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 break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle);\r\n break;\r\n }\r\n }\r\n\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\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 context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n });\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 private _createMultiRenderTargetTexture(): 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 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 const handles: FrameGraphTextureHandle[] = [];\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n handles.push(baseHandle + i);\r\n }\r\n\r\n return handles;\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture 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 }\r\n\r\n return depthEnabled;\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 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}\r\n"]}
@@ -37,6 +37,8 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
37
37
  depthWrite: boolean;
38
38
  /**
39
39
  * The output texture.
40
+ * This texture will point to the same texture than the destinationTexture property if it is set.
41
+ * Note, however, that the handle itself will be different!
40
42
  */
41
43
  readonly outputTexture: FrameGraphTextureHandle;
42
44
  /**
@@ -45,8 +47,8 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
45
47
  * Note, however, that the handle itself will be different!
46
48
  */
47
49
  readonly outputDepthTexture: FrameGraphTextureHandle;
48
- protected _scene: Scene;
49
- protected _renderer: ObjectRenderer;
50
+ protected readonly _scene: Scene;
51
+ protected readonly _renderer: ObjectRenderer;
50
52
  protected _textureWidth: number;
51
53
  protected _textureHeight: number;
52
54
  /**
@@ -59,8 +59,8 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
59
59
  scene.updateTransformMatrix(true);
60
60
  }
61
61
  });
62
- this.outputTexture = this._frameGraph.createDanglingHandle();
63
- this.outputDepthTexture = this._frameGraph.createDanglingHandle();
62
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
63
+ this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();
64
64
  }
65
65
  isReady() {
66
66
  return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);
@@ -69,7 +69,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
69
69
  if (this.destinationTexture === undefined || this.objectList === undefined) {
70
70
  throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);
71
71
  }
72
- const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);
72
+ const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);
73
73
  let depthEnabled = false;
74
74
  if (this.depthTexture !== undefined) {
75
75
  if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {
@@ -78,23 +78,21 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
78
78
  if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {
79
79
  throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`);
80
80
  }
81
- const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);
81
+ const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
82
82
  if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {
83
83
  throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);
84
84
  }
85
85
  depthEnabled = true;
86
86
  }
87
- this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
87
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
88
88
  if (this.depthTexture !== undefined) {
89
- this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
89
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
90
90
  }
91
91
  this._textureWidth = outputTextureDescription.size.width;
92
92
  this._textureHeight = outputTextureDescription.size.height;
93
93
  const pass = this._frameGraph.addRenderPass(this.name);
94
94
  pass.setRenderTarget(this.destinationTexture);
95
- if (this.depthTexture !== undefined) {
96
- pass.setRenderTargetDepth(this.depthTexture);
97
- }
95
+ pass.setRenderTargetDepth(this.depthTexture);
98
96
  pass.setExecuteFunc((context) => {
99
97
  this._renderer.renderList = this.objectList.meshes;
100
98
  this._renderer.particleSystemList = this.objectList.particleSystems;
@@ -110,9 +108,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
110
108
  if (!skipCreationOfDisabledPasses) {
111
109
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
112
110
  passDisabled.setRenderTarget(this.destinationTexture);
113
- if (this.depthTexture !== undefined) {
114
- passDisabled.setRenderTargetDepth(this.depthTexture);
115
- }
111
+ passDisabled.setRenderTargetDepth(this.depthTexture);
116
112
  passDisabled.setExecuteFunc((_context) => { });
117
113
  if (this.dependencies !== undefined) {
118
114
  for (const handle of this.dependencies) {
@@ -1 +1 @@
1
- {"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IAkCD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAoB,IAAI;QACpB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,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBAClC,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACzD,CAAC;YACD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;YAE9C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACrC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected _scene: Scene;\r\n protected _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,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AAS,EAAE,CAAC;YAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,4BAA4B,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;YAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACtD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACrD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;YAE9C,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;gBAClC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBACrC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACpC,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n * This texture will point to the same texture than the destinationTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -25,10 +25,10 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
25
25
  if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {
26
26
  throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);
27
27
  }
28
- const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);
28
+ const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);
29
29
  let depthEnabled = false;
30
30
  if (this.depthTexture !== undefined) {
31
- const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);
31
+ const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);
32
32
  if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {
33
33
  throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);
34
34
  }
@@ -40,32 +40,28 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
40
40
  const textureCreationOptions = {
41
41
  size: outputTextureDescription.size,
42
42
  options: {
43
- createMipMaps: false,
44
- generateMipMaps: false,
43
+ createMipMaps: outputTextureDescription.options.createMipMaps,
45
44
  types: [2],
46
- samplingModes: [1],
47
45
  formats: [5],
48
46
  samples: 1,
49
47
  useSRGBBuffers: [false],
50
- generateDepthBuffer: false,
51
- generateStencilBuffer: false,
52
- label: "",
48
+ creationFlags: [0],
49
+ labels: [""],
53
50
  },
54
51
  sizeIsPercentage: false,
55
52
  isHistoryTexture: true,
56
53
  };
57
- const pingPongHandle = this._frameGraph.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);
58
- this._frameGraph.resolveDanglingHandle(this.outputTexture, pingPongHandle);
54
+ const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);
55
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);
59
56
  if (this.depthTexture !== undefined) {
60
- this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
57
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
61
58
  }
62
59
  this._textureWidth = outputTextureDescription.size.width;
63
60
  this._textureHeight = outputTextureDescription.size.height;
61
+ let pingPongRenderTargetWrapper;
64
62
  const pass = this._frameGraph.addRenderPass(this.name);
65
63
  pass.setRenderTarget(this.destinationTexture);
66
- if (this.depthTexture !== undefined) {
67
- pass.setRenderTargetDepth(this.depthTexture);
68
- }
64
+ pass.setRenderTargetDepth(this.depthTexture);
69
65
  pass.setExecuteFunc((context) => {
70
66
  this._renderer.renderList = this.objectList.meshes;
71
67
  this._renderer.particleSystemList = this.objectList.particleSystems;
@@ -79,7 +75,8 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
79
75
  }
80
76
  context.render(this._renderer, this._textureWidth, this._textureHeight);
81
77
  this._scene.activeCamera = null;
82
- context.bindRenderTarget(pingPongHandle, "frame graph - TAA merge with history texture");
78
+ pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);
79
+ context.bindRenderTarget(pingPongRenderTargetWrapper, "frame graph - TAA merge with history texture");
83
80
  if (!this.postProcess.disabled) {
84
81
  context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {
85
82
  this.postProcess.bind();
@@ -93,9 +90,7 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
93
90
  });
94
91
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
95
92
  passDisabled.setRenderTarget(this.outputTexture);
96
- if (this.depthTexture !== undefined) {
97
- passDisabled.setRenderTargetDepth(this.depthTexture);
98
- }
93
+ passDisabled.setRenderTargetDepth(this.depthTexture);
99
94
  passDisabled.setExecuteFunc((context) => {
100
95
  context.copyTexture(this.destinationTexture);
101
96
  });
@@ -1 +1 @@
1
- {"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,4BAA4B;IAQ7E;;;;;;OAMG;IACH,Y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-internal-modules\r\nimport type { FrameGraph, Scene, DrawWrapper, FrameGraphTextureCreationOptions, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph, scene, options);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: false,\r\n generateMipMaps: false,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n samplingModes: [Constants.TEXTURE_NEAREST_NEAREST],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n label: \"\",\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n context.bindRenderTarget(pingPongHandle, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,4BAA4B;IAQ7E;;;;;;OAMG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ourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, Scene, DrawWrapper, FrameGraphTextureCreationOptions, ObjectRendererOptions, FrameGraphRenderTarget } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph, scene, options);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: outputTextureDescription.options.createMipMaps,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n let pingPongRenderTargetWrapper: FrameGraphRenderTarget | undefined;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n pingPongRenderTargetWrapper = pingPongRenderTargetWrapper || context.createRenderTarget(`${this.name} ping/pong`, pingPongHandle);\r\n\r\n context.bindRenderTarget(pingPongRenderTargetWrapper, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -24,11 +24,24 @@ export declare class FrameGraphClearTextureTask extends FrameGraphTask {
24
24
  /**
25
25
  * The texture to clear.
26
26
  */
27
- destinationTexture: FrameGraphTextureHandle;
27
+ destinationTexture?: FrameGraphTextureHandle;
28
28
  /**
29
- * The output texture (same as destinationTexture, but the handle may be different).
29
+ * The depth attachment texture to clear.
30
+ */
31
+ depthTexture?: FrameGraphTextureHandle;
32
+ /**
33
+ * The output texture (same as destinationTexture, but the handle will be different).
30
34
  */
31
35
  readonly outputTexture: FrameGraphTextureHandle;
36
+ /**
37
+ * The output depth texture (same as depthTexture, but the handle will be different).
38
+ */
39
+ readonly outputDepthTexture: FrameGraphTextureHandle;
40
+ /**
41
+ * Constructs a new clear task.
42
+ * @param name The name of the task.
43
+ * @param frameGraph The frame graph the task belongs to.
44
+ */
32
45
  constructor(name: string, frameGraph: FrameGraph);
33
46
  record(): void;
34
47
  }