@onerjs/core 8.30.4 → 8.30.6

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 (288) hide show
  1. package/Actions/action.d.ts +5 -0
  2. package/Actions/action.js.map +1 -1
  3. package/Actions/actionManager.js +6 -2
  4. package/Actions/actionManager.js.map +1 -1
  5. package/Animations/runtimeAnimation.d.ts +0 -2
  6. package/Animations/runtimeAnimation.js +3 -5
  7. package/Animations/runtimeAnimation.js.map +1 -1
  8. package/Audio/audioSceneComponent.d.ts +9 -5
  9. package/Audio/audioSceneComponent.js +1 -0
  10. package/Audio/audioSceneComponent.js.map +1 -1
  11. package/AudioV2/abstractAudio/abstractSound.js +1 -0
  12. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  13. package/AudioV2/abstractAudio/audioEngineV2.d.ts +10 -0
  14. package/AudioV2/abstractAudio/audioEngineV2.js +29 -0
  15. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  16. package/AudioV2/webAudio/webAudioEngine.d.ts +5 -0
  17. package/AudioV2/webAudio/webAudioEngine.js +8 -0
  18. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  19. package/AudioV2/webAudio/webAudioStaticSound.js +10 -5
  20. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  21. package/AudioV2/webAudio/webAudioStreamingSound.js +5 -2
  22. package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
  23. package/Cameras/camera.d.ts +4 -0
  24. package/Cameras/camera.js +18 -9
  25. package/Cameras/camera.js.map +1 -1
  26. package/Collisions/gpuPicker.js +0 -1
  27. package/Collisions/gpuPicker.js.map +1 -1
  28. package/Decorators/nodeDecorator.d.ts +3 -1
  29. package/Decorators/nodeDecorator.js +2 -0
  30. package/Decorators/nodeDecorator.js.map +1 -1
  31. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  32. package/Engines/Native/nativeInterfaces.js.map +1 -1
  33. package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
  34. package/Engines/WebGPU/webgpuDrawContext.js +8 -0
  35. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  36. package/Engines/abstractEngine.js +2 -2
  37. package/Engines/abstractEngine.js.map +1 -1
  38. package/Engines/nativeEngine.js +12 -13
  39. package/Engines/nativeEngine.js.map +1 -1
  40. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
  41. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
  42. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  44. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
  46. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
  47. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
  48. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
  49. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
  50. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
  51. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +1 -1
  52. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  53. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
  54. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
  55. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
  56. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
  57. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +3 -3
  58. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
  59. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
  60. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
  61. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
  62. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
  63. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
  64. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
  65. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
  66. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
  67. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
  68. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
  69. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
  70. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
  71. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
  72. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
  73. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
  74. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
  75. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
  76. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
  77. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
  78. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
  79. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
  80. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
  81. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
  82. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
  83. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
  84. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
  85. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
  86. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
  87. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
  88. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
  89. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
  90. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
  91. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
  92. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
  93. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
  94. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
  95. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
  96. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
  97. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
  98. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
  99. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
  100. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
  101. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +17 -1
  102. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +70 -0
  103. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  104. package/FrameGraph/Node/Blocks/computeShaderBlock.d.ts +42 -0
  105. package/FrameGraph/Node/Blocks/computeShaderBlock.js +74 -0
  106. package/FrameGraph/Node/Blocks/computeShaderBlock.js.map +1 -0
  107. package/FrameGraph/Node/Blocks/executeBlock.d.ts +11 -1
  108. package/FrameGraph/Node/Blocks/executeBlock.js +18 -0
  109. package/FrameGraph/Node/Blocks/executeBlock.js.map +1 -1
  110. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  111. package/FrameGraph/Node/Blocks/index.js +1 -0
  112. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  113. package/FrameGraph/Node/Blocks/inputBlock.js +2 -0
  114. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  115. package/FrameGraph/Node/Blocks/outputBlock.js +1 -0
  116. package/FrameGraph/Node/Blocks/outputBlock.js.map +1 -1
  117. package/FrameGraph/Node/nodeRenderGraph.d.ts +1 -1
  118. package/FrameGraph/Node/nodeRenderGraph.js +7 -3
  119. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  120. package/FrameGraph/Node/nodeRenderGraphBlock.js +7 -0
  121. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  122. package/FrameGraph/Passes/pass.d.ts +11 -1
  123. package/FrameGraph/Passes/pass.js +11 -1
  124. package/FrameGraph/Passes/pass.js.map +1 -1
  125. package/FrameGraph/Tasks/Misc/computeShaderTask.d.ts +115 -0
  126. package/FrameGraph/Tasks/Misc/computeShaderTask.js +174 -0
  127. package/FrameGraph/Tasks/Misc/computeShaderTask.js.map +1 -0
  128. package/FrameGraph/Tasks/Misc/executeTask.d.ts +5 -0
  129. package/FrameGraph/Tasks/Misc/executeTask.js +3 -0
  130. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
  131. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +1 -1
  132. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
  133. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  134. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
  135. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
  136. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  137. package/FrameGraph/Tasks/PostProcesses/ssao2Task.d.ts +1 -0
  138. package/FrameGraph/Tasks/PostProcesses/ssao2Task.js +7 -0
  139. package/FrameGraph/Tasks/PostProcesses/ssao2Task.js.map +1 -1
  140. package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
  141. package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
  142. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
  143. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
  144. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  145. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +7 -1
  146. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +4 -1
  147. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  148. package/FrameGraph/frameGraph.d.ts +1 -1
  149. package/FrameGraph/frameGraph.js +3 -6
  150. package/FrameGraph/frameGraph.js.map +1 -1
  151. package/FrameGraph/frameGraphContext.d.ts +8 -1
  152. package/FrameGraph/frameGraphContext.js +9 -0
  153. package/FrameGraph/frameGraphContext.js.map +1 -1
  154. package/FrameGraph/frameGraphRenderContext.d.ts +4 -2
  155. package/FrameGraph/frameGraphRenderContext.js +11 -5
  156. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  157. package/FrameGraph/frameGraphTask.d.ts +11 -2
  158. package/FrameGraph/frameGraphTask.js +17 -2
  159. package/FrameGraph/frameGraphTask.js.map +1 -1
  160. package/FrameGraph/frameGraphTextureManager.js +2 -2
  161. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  162. package/FrameGraph/index.d.ts +1 -0
  163. package/FrameGraph/index.js +1 -0
  164. package/FrameGraph/index.js.map +1 -1
  165. package/Lights/directionalLight.js +1 -4
  166. package/Lights/directionalLight.js.map +1 -1
  167. package/Lights/pointLight.js +2 -5
  168. package/Lights/pointLight.js.map +1 -1
  169. package/Materials/Textures/mirrorTexture.js +4 -1
  170. package/Materials/Textures/mirrorTexture.js.map +1 -1
  171. package/Materials/clipPlaneMaterialHelper.js +11 -1
  172. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  173. package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
  174. package/Materials/floatingOriginMatrixOverrides.js +14 -2
  175. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  176. package/Materials/index.d.ts +1 -0
  177. package/Materials/index.js +1 -0
  178. package/Materials/index.js.map +1 -1
  179. package/Materials/materialHelper.functions.d.ts +8 -0
  180. package/Materials/materialHelper.functions.js +31 -0
  181. package/Materials/materialHelper.functions.js.map +1 -1
  182. package/Materials/shaderMaterial.js +21 -1
  183. package/Materials/shaderMaterial.js.map +1 -1
  184. package/Maths/math.vector.functions.d.ts +55 -16
  185. package/Maths/math.vector.functions.js +68 -10
  186. package/Maths/math.vector.functions.js.map +1 -1
  187. package/Misc/copyTextureToTexture.d.ts +10 -0
  188. package/Misc/copyTextureToTexture.js +15 -0
  189. package/Misc/copyTextureToTexture.js.map +1 -1
  190. package/Misc/decorators.d.ts +1 -1
  191. package/Misc/decorators.js.map +1 -1
  192. package/Misc/dumpTools.d.ts +20 -0
  193. package/Misc/dumpTools.js +60 -49
  194. package/Misc/dumpTools.js.map +1 -1
  195. package/Misc/index.d.ts +1 -2
  196. package/Misc/index.js +1 -2
  197. package/Misc/index.js.map +1 -1
  198. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
  199. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  200. package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +57 -0
  201. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +163 -0
  202. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -0
  203. package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
  204. package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
  205. package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
  206. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
  207. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  208. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
  209. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  210. package/Particles/Node/Blocks/Emitters/index.d.ts +5 -4
  211. package/Particles/Node/Blocks/Emitters/index.js +5 -4
  212. package/Particles/Node/Blocks/Emitters/index.js.map +1 -1
  213. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
  214. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  215. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
  216. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  217. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
  218. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  219. package/Particles/Node/Blocks/particleInputBlock.js +2 -0
  220. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  221. package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
  222. package/Particles/Node/Blocks/systemBlock.js +82 -3
  223. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  224. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +5 -1
  225. package/Particles/Node/Enums/nodeParticleContextualSources.js +4 -0
  226. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  227. package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
  228. package/Particles/Node/nodeParticleBuildState.js +12 -22
  229. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  230. package/Particles/Node/nodeParticleSystemSet.helper.d.ts +4 -3
  231. package/Particles/Node/nodeParticleSystemSet.helper.js +344 -112
  232. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  233. package/Particles/thinParticleSystem.js +1 -0
  234. package/Particles/thinParticleSystem.js.map +1 -1
  235. package/Physics/physicsRaycastResult.d.ts +3 -0
  236. package/Physics/physicsRaycastResult.js.map +1 -1
  237. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
  238. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  239. package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
  240. package/Physics/v2/Plugins/havokPlugin.js +73 -9
  241. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  242. package/Physics/v2/physicsEngine.d.ts +12 -2
  243. package/Physics/v2/physicsEngine.js +15 -1
  244. package/Physics/v2/physicsEngine.js.map +1 -1
  245. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -0
  246. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +9 -1
  247. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  248. package/PostProcesses/thinSSAO2PostProcess.d.ts +1 -0
  249. package/PostProcesses/thinSSAO2PostProcess.js +18 -6
  250. package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
  251. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
  252. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  253. package/Shaders/ShadersInclude/openpbrDirectLighting.js +5 -2
  254. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  255. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +1 -1
  256. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  257. package/Shaders/particles.vertex.js +1 -1
  258. package/Shaders/particles.vertex.js.map +1 -1
  259. package/Shaders/picking.fragment.js +1 -1
  260. package/Shaders/picking.fragment.js.map +1 -1
  261. package/Shaders/picking.vertex.js +1 -1
  262. package/Shaders/picking.vertex.js.map +1 -1
  263. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
  264. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  265. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +5 -2
  266. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  267. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +2 -2
  268. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  269. package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -4
  270. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  271. package/ShadersWGSL/particles.vertex.js +1 -1
  272. package/ShadersWGSL/particles.vertex.js.map +1 -1
  273. package/ShadersWGSL/picking.fragment.js +1 -1
  274. package/ShadersWGSL/picking.fragment.js.map +1 -1
  275. package/ShadersWGSL/picking.vertex.js +1 -1
  276. package/ShadersWGSL/picking.vertex.js.map +1 -1
  277. package/Sprites/spriteRenderer.js +10 -8
  278. package/Sprites/spriteRenderer.js.map +1 -1
  279. package/XR/features/WebXRLightEstimation.d.ts +8 -0
  280. package/XR/features/WebXRLightEstimation.js +6 -1
  281. package/XR/features/WebXRLightEstimation.js.map +1 -1
  282. package/assetContainer.d.ts +1 -1
  283. package/assetContainer.js +1 -1
  284. package/assetContainer.js.map +1 -1
  285. package/package.json +1 -1
  286. package/scene.d.ts +7 -2
  287. package/scene.js +11 -8
  288. package/scene.js.map +1 -1
@@ -0,0 +1,115 @@
1
+ import type { BaseTexture, DataBuffer, ExternalTexture, FrameGraph, FrameGraphContext, FrameGraphPass, IComputeShaderOptions, IComputeShaderPath, InternalTexture, StorageBuffer, TextureSampler, VideoTexture } from "../../../index.js";
2
+ import { FrameGraphTask } from "../../frameGraphTask.js";
3
+ import { ComputeShader } from "../../../Compute/computeShader.js";
4
+ import { Vector3 } from "../../../Maths/math.vector.js";
5
+ import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
6
+ /**
7
+ * Task used to execute a compute shader (WebGPU only)
8
+ */
9
+ export declare class FrameGraphComputeShaderTask extends FrameGraphTask {
10
+ private readonly _notSupported;
11
+ private readonly _cs;
12
+ private readonly _ubo;
13
+ /**
14
+ * Defines the dispatch size for the compute shader
15
+ */
16
+ dispatchSize: Vector3;
17
+ /**
18
+ * Defines an indirect dispatch buffer and offset.
19
+ * If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.
20
+ * "offset" is the offset in the buffer where the workgroup counts are stored (default: 0)
21
+ */
22
+ indirectDispatch?: {
23
+ buffer: StorageBuffer | DataBuffer;
24
+ offset?: number;
25
+ };
26
+ /**
27
+ * An optional execute function that will be called at the beginning of the task execution
28
+ */
29
+ execute?: (context: FrameGraphContext) => void;
30
+ /**
31
+ * Gets the compute shader used by the task
32
+ */
33
+ get computeShader(): ComputeShader;
34
+ /**
35
+ * Gets a uniform buffer created by a call to createUniformBuffer()
36
+ * @param name Name of the uniform buffer
37
+ * @returns The uniform buffer
38
+ */
39
+ getUniformBuffer(name: string): UniformBuffer;
40
+ /**
41
+ * Creates a new compute shader task.
42
+ * @param name The name of the task.
43
+ * @param frameGraph The frame graph the task belongs to.
44
+ * @param shaderPath Defines the route to the shader code in one of three ways:
45
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
46
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
47
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
48
+ * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
49
+ * @param options Define the options used to create the shader
50
+ */
51
+ constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options?: Partial<IComputeShaderOptions>);
52
+ isReady(): boolean;
53
+ /**
54
+ * Creates a uniform buffer and binds it to the shader
55
+ * @param name Name of the uniform buffer
56
+ * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
57
+ * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
58
+ * @returns The created uniform buffer
59
+ */
60
+ createUniformBuffer(name: string, description: {
61
+ [name: string]: number;
62
+ }, autoUpdate?: boolean): UniformBuffer;
63
+ /**
64
+ * Binds a texture to the shader
65
+ * @param name Binding name of the texture
66
+ * @param texture Texture to bind
67
+ * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
68
+ */
69
+ setTexture(name: string, texture: BaseTexture, bindSampler?: boolean): void;
70
+ /**
71
+ * Binds an internal texture to the shader
72
+ * @param name Binding name of the texture
73
+ * @param texture Texture to bind
74
+ */
75
+ setInternalTexture(name: string, texture: InternalTexture): void;
76
+ /**
77
+ * Binds a storage texture to the shader
78
+ * @param name Binding name of the texture
79
+ * @param texture Texture to bind
80
+ */
81
+ setStorageTexture(name: string, texture: BaseTexture): void;
82
+ /**
83
+ * Binds an external texture to the shader
84
+ * @param name Binding name of the texture
85
+ * @param texture Texture to bind
86
+ */
87
+ setExternalTexture(name: string, texture: ExternalTexture): void;
88
+ /**
89
+ * Binds a video texture to the shader (by binding the external texture attached to this video)
90
+ * @param name Binding name of the texture
91
+ * @param texture Texture to bind
92
+ * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
93
+ */
94
+ setVideoTexture(name: string, texture: VideoTexture): boolean;
95
+ /**
96
+ * Binds a uniform buffer to the shader
97
+ * @param name Binding name of the buffer
98
+ * @param buffer Buffer to bind
99
+ */
100
+ setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void;
101
+ /**
102
+ * Binds a storage buffer to the shader
103
+ * @param name Binding name of the buffer
104
+ * @param buffer Buffer to bind
105
+ */
106
+ setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void;
107
+ /**
108
+ * Binds a texture sampler to the shader
109
+ * @param name Binding name of the sampler
110
+ * @param sampler Sampler to bind
111
+ */
112
+ setTextureSampler(name: string, sampler: TextureSampler): void;
113
+ record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext>;
114
+ dispose(): void;
115
+ }
@@ -0,0 +1,174 @@
1
+ import { FrameGraphTask } from "../../frameGraphTask.js";
2
+ import { ComputeShader } from "../../../Compute/computeShader.js";
3
+ import { Vector3 } from "../../../Maths/math.vector.js";
4
+ import { UniformBuffer } from "../../../Materials/uniformBuffer.js";
5
+ import { Logger } from "../../../Misc/logger.js";
6
+ /**
7
+ * Task used to execute a compute shader (WebGPU only)
8
+ */
9
+ export class FrameGraphComputeShaderTask extends FrameGraphTask {
10
+ /**
11
+ * Gets the compute shader used by the task
12
+ */
13
+ get computeShader() {
14
+ return this._cs;
15
+ }
16
+ /**
17
+ * Gets a uniform buffer created by a call to createUniformBuffer()
18
+ * @param name Name of the uniform buffer
19
+ * @returns The uniform buffer
20
+ */
21
+ getUniformBuffer(name) {
22
+ return this._ubo[name]?.ubo;
23
+ }
24
+ /**
25
+ * Creates a new compute shader task.
26
+ * @param name The name of the task.
27
+ * @param frameGraph The frame graph the task belongs to.
28
+ * @param shaderPath Defines the route to the shader code in one of three ways:
29
+ * * object: \{ compute: "custom" \}, used with ShaderStore.ShadersStoreWGSL["customComputeShader"]
30
+ * * object: \{ computeElement: "HTMLElementId" \}, used with shader code in script tags
31
+ * * object: \{ computeSource: "compute shader code string" \}, where the string contains the shader code
32
+ * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + "ComputeShader"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.
33
+ * @param options Define the options used to create the shader
34
+ */
35
+ constructor(name, frameGraph, shaderPath, options = {}) {
36
+ super(name, frameGraph);
37
+ /**
38
+ * Defines the dispatch size for the compute shader
39
+ */
40
+ this.dispatchSize = new Vector3(1, 1, 1);
41
+ if (!frameGraph.engine.getCaps().supportComputeShaders) {
42
+ this._notSupported = true;
43
+ Logger.Error("This engine does not support compute shaders!");
44
+ return;
45
+ }
46
+ this._notSupported = false;
47
+ this._cs = new ComputeShader(name + "_cs", frameGraph.engine, shaderPath, options);
48
+ this._ubo = {};
49
+ }
50
+ isReady() {
51
+ return this._notSupported ? true : this._cs.isReady();
52
+ }
53
+ /**
54
+ * Creates a uniform buffer and binds it to the shader
55
+ * @param name Name of the uniform buffer
56
+ * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms
57
+ * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)
58
+ * @returns The created uniform buffer
59
+ */
60
+ createUniformBuffer(name, description, autoUpdate = true) {
61
+ const uBuffer = new UniformBuffer(this._frameGraph.engine);
62
+ this._ubo[name] = { ubo: uBuffer, autoUpdate };
63
+ for (const key in description) {
64
+ uBuffer.addUniform(key, description[key]);
65
+ }
66
+ this._cs.setUniformBuffer(name, uBuffer);
67
+ return uBuffer;
68
+ }
69
+ /**
70
+ * Binds a texture to the shader
71
+ * @param name Binding name of the texture
72
+ * @param texture Texture to bind
73
+ * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture
74
+ */
75
+ setTexture(name, texture, bindSampler = true) {
76
+ this._cs.setTexture(name, texture, bindSampler);
77
+ }
78
+ /**
79
+ * Binds an internal texture to the shader
80
+ * @param name Binding name of the texture
81
+ * @param texture Texture to bind
82
+ */
83
+ setInternalTexture(name, texture) {
84
+ this._cs.setInternalTexture(name, texture);
85
+ }
86
+ /**
87
+ * Binds a storage texture to the shader
88
+ * @param name Binding name of the texture
89
+ * @param texture Texture to bind
90
+ */
91
+ setStorageTexture(name, texture) {
92
+ this._cs.setStorageTexture(name, texture);
93
+ }
94
+ /**
95
+ * Binds an external texture to the shader
96
+ * @param name Binding name of the texture
97
+ * @param texture Texture to bind
98
+ */
99
+ setExternalTexture(name, texture) {
100
+ this._cs.setExternalTexture(name, texture);
101
+ }
102
+ /**
103
+ * Binds a video texture to the shader (by binding the external texture attached to this video)
104
+ * @param name Binding name of the texture
105
+ * @param texture Texture to bind
106
+ * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures
107
+ */
108
+ setVideoTexture(name, texture) {
109
+ return this._cs.setVideoTexture(name, texture);
110
+ }
111
+ /**
112
+ * Binds a uniform buffer to the shader
113
+ * @param name Binding name of the buffer
114
+ * @param buffer Buffer to bind
115
+ */
116
+ setUniformBuffer(name, buffer) {
117
+ this._cs.setUniformBuffer(name, buffer);
118
+ }
119
+ /**
120
+ * Binds a storage buffer to the shader
121
+ * @param name Binding name of the buffer
122
+ * @param buffer Buffer to bind
123
+ */
124
+ setStorageBuffer(name, buffer) {
125
+ this._cs.setStorageBuffer(name, buffer);
126
+ }
127
+ /**
128
+ * Binds a texture sampler to the shader
129
+ * @param name Binding name of the sampler
130
+ * @param sampler Sampler to bind
131
+ */
132
+ setTextureSampler(name, sampler) {
133
+ this._cs.setTextureSampler(name, sampler);
134
+ }
135
+ record(skipCreationOfDisabledPasses) {
136
+ const pass = this._frameGraph.addPass(this.name);
137
+ if (this._notSupported) {
138
+ pass.setExecuteFunc(() => { });
139
+ }
140
+ else {
141
+ pass.setExecuteFunc((context) => {
142
+ this.execute?.(context);
143
+ for (const key in this._ubo) {
144
+ const uboEntry = this._ubo[key];
145
+ if (uboEntry.autoUpdate) {
146
+ uboEntry.ubo.update();
147
+ }
148
+ }
149
+ if (this.indirectDispatch) {
150
+ context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);
151
+ this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);
152
+ context.popDebugGroup();
153
+ }
154
+ else {
155
+ context.pushDebugGroup(`Dispatch compute shader (${this.name})`);
156
+ this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);
157
+ context.popDebugGroup();
158
+ }
159
+ });
160
+ }
161
+ if (!skipCreationOfDisabledPasses) {
162
+ const passDisabled = this._frameGraph.addPass(this.name + "_disabled", true);
163
+ passDisabled.setExecuteFunc(() => { });
164
+ }
165
+ return pass;
166
+ }
167
+ dispose() {
168
+ for (const key in this._ubo) {
169
+ this._ubo[key].ubo.dispose();
170
+ }
171
+ super.dispose();
172
+ }
173
+ }
174
+ //# sourceMappingURL=computeShaderTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeShaderTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/computeShaderTask.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,0CAAmC;AAC3D,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACjD,OAAO,EAAE,aAAa,EAAE,4CAAqC;AAC7D,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAE1C;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,cAAc;IAsB3D;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAChC,CAAC;IAED;;;;;;;;;;OAUG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,UAAuC,EAAE,UAA0C,EAAE;QACnI,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA7C5B;;WAEG;QACI,iBAAY,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QA4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C,CAAC;QAC1C,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n BaseTexture,\r\n DataBuffer,\r\n ExternalTexture,\r\n FrameGraph,\r\n FrameGraphContext,\r\n FrameGraphPass,\r\n IComputeShaderOptions,\r\n IComputeShaderPath,\r\n InternalTexture,\r\n StorageBuffer,\r\n TextureSampler,\r\n VideoTexture,\r\n} from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ComputeShader } from \"core/Compute/computeShader\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { UniformBuffer } from \"core/Materials/uniformBuffer\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Task used to execute a compute shader (WebGPU only)\r\n */\r\nexport class FrameGraphComputeShaderTask extends FrameGraphTask {\r\n private readonly _notSupported: boolean;\r\n private readonly _cs: ComputeShader;\r\n private readonly _ubo: { [name: string]: { ubo: UniformBuffer; autoUpdate: boolean } };\r\n\r\n /**\r\n * Defines the dispatch size for the compute shader\r\n */\r\n public dispatchSize = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * Defines an indirect dispatch buffer and offset.\r\n * If set, this will be used instead of the dispatchSize property and an indirect dispatch will be performed.\r\n * \"offset\" is the offset in the buffer where the workgroup counts are stored (default: 0)\r\n */\r\n public indirectDispatch?: { buffer: StorageBuffer | DataBuffer; offset?: number };\r\n\r\n /**\r\n * An optional execute function that will be called at the beginning of the task execution\r\n */\r\n public execute?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Gets the compute shader used by the task\r\n */\r\n public get computeShader(): ComputeShader {\r\n return this._cs;\r\n }\r\n\r\n /**\r\n * Gets a uniform buffer created by a call to createUniformBuffer()\r\n * @param name Name of the uniform buffer\r\n * @returns The uniform buffer\r\n */\r\n public getUniformBuffer(name: string): UniformBuffer {\r\n return this._ubo[name]?.ubo;\r\n }\r\n\r\n /**\r\n * Creates a new compute shader task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param shaderPath Defines the route to the shader code in one of three ways:\r\n * * object: \\{ compute: \"custom\" \\}, used with ShaderStore.ShadersStoreWGSL[\"customComputeShader\"]\r\n * * object: \\{ computeElement: \"HTMLElementId\" \\}, used with shader code in script tags\r\n * * object: \\{ computeSource: \"compute shader code string\" \\}, where the string contains the shader code\r\n * * string: try first to find the code in ShaderStore.ShadersStoreWGSL[shaderPath + \"ComputeShader\"]. If not, assumes it is a file with name shaderPath.compute.fx in index.html folder.\r\n * @param options Define the options used to create the shader\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, shaderPath: IComputeShaderPath | string, options: Partial<IComputeShaderOptions> = {}) {\r\n super(name, frameGraph);\r\n\r\n if (!frameGraph.engine.getCaps().supportComputeShaders) {\r\n this._notSupported = true;\r\n Logger.Error(\"This engine does not support compute shaders!\");\r\n return;\r\n }\r\n\r\n this._notSupported = false;\r\n this._cs = new ComputeShader(name + \"_cs\", frameGraph.engine, shaderPath, options);\r\n this._ubo = {};\r\n }\r\n\r\n public override isReady(): boolean {\r\n return this._notSupported ? true : this._cs.isReady();\r\n }\r\n\r\n /**\r\n * Creates a uniform buffer and binds it to the shader\r\n * @param name Name of the uniform buffer\r\n * @param description Description of the uniform buffer: names and sizes (in floats) of the uniforms\r\n * @param autoUpdate If the UBO must be updated automatically before each dispatch (default: true)\r\n * @returns The created uniform buffer\r\n */\r\n public createUniformBuffer(name: string, description: { [name: string]: number }, autoUpdate = true): UniformBuffer {\r\n const uBuffer = new UniformBuffer(this._frameGraph.engine);\r\n\r\n this._ubo[name] = { ubo: uBuffer, autoUpdate };\r\n\r\n for (const key in description) {\r\n uBuffer.addUniform(key, description[key]);\r\n }\r\n\r\n this._cs.setUniformBuffer(name, uBuffer);\r\n\r\n return uBuffer;\r\n }\r\n\r\n /**\r\n * Binds a texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @param bindSampler Bind the sampler corresponding to the texture (default: true). The sampler will be bound just before the binding index of the texture\r\n */\r\n public setTexture(name: string, texture: BaseTexture, bindSampler = true): void {\r\n this._cs.setTexture(name, texture, bindSampler);\r\n }\r\n\r\n /**\r\n * Binds an internal texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setInternalTexture(name: string, texture: InternalTexture): void {\r\n this._cs.setInternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a storage texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setStorageTexture(name: string, texture: BaseTexture): void {\r\n this._cs.setStorageTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds an external texture to the shader\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n */\r\n public setExternalTexture(name: string, texture: ExternalTexture): void {\r\n this._cs.setExternalTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a video texture to the shader (by binding the external texture attached to this video)\r\n * @param name Binding name of the texture\r\n * @param texture Texture to bind\r\n * @returns true if the video texture was successfully bound, else false. false will be returned if the current engine does not support external textures\r\n */\r\n public setVideoTexture(name: string, texture: VideoTexture) {\r\n return this._cs.setVideoTexture(name, texture);\r\n }\r\n\r\n /**\r\n * Binds a uniform buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setUniformBuffer(name: string, buffer: UniformBuffer | DataBuffer): void {\r\n this._cs.setUniformBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a storage buffer to the shader\r\n * @param name Binding name of the buffer\r\n * @param buffer Buffer to bind\r\n */\r\n public setStorageBuffer(name: string, buffer: StorageBuffer | DataBuffer): void {\r\n this._cs.setStorageBuffer(name, buffer);\r\n }\r\n\r\n /**\r\n * Binds a texture sampler to the shader\r\n * @param name Binding name of the sampler\r\n * @param sampler Sampler to bind\r\n */\r\n public setTextureSampler(name: string, sampler: TextureSampler): void {\r\n this._cs.setTextureSampler(name, sampler);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses?: boolean): FrameGraphPass<FrameGraphContext> {\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n if (this._notSupported) {\r\n pass.setExecuteFunc(() => {});\r\n } else {\r\n pass.setExecuteFunc((context) => {\r\n this.execute?.(context);\r\n\r\n for (const key in this._ubo) {\r\n const uboEntry = this._ubo[key];\r\n if (uboEntry.autoUpdate) {\r\n uboEntry.ubo.update();\r\n }\r\n }\r\n\r\n if (this.indirectDispatch) {\r\n context.pushDebugGroup(`Indirect dispatch compute shader (${this.name})`);\r\n this._cs.dispatchIndirect(this.indirectDispatch.buffer, this.indirectDispatch.offset);\r\n context.popDebugGroup();\r\n } else {\r\n context.pushDebugGroup(`Dispatch compute shader (${this.name})`);\r\n this._cs.dispatch(this.dispatchSize.x, this.dispatchSize.y, this.dispatchSize.z);\r\n context.popDebugGroup();\r\n }\r\n });\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc(() => {});\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n for (const key in this._ubo) {\r\n this._ubo[key].ubo.dispose();\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -12,6 +12,11 @@ export declare class FrameGraphExecuteTask extends FrameGraphTask {
12
12
  * The function to execute when the task is disabled (optional).
13
13
  */
14
14
  funcDisabled?: (context: FrameGraphContext) => void;
15
+ /**
16
+ * Custom readiness check (optional).
17
+ */
18
+ customIsReady?: () => boolean;
19
+ isReady(): boolean;
15
20
  /**
16
21
  * Creates a new execute task.
17
22
  * @param name The name of the task.
@@ -3,6 +3,9 @@ import { FrameGraphTask } from "../../frameGraphTask.js";
3
3
  * Task used to execute a custom function.
4
4
  */
5
5
  export class FrameGraphExecuteTask extends FrameGraphTask {
6
+ isReady() {
7
+ return !this.customIsReady || this.customIsReady();
8
+ }
6
9
  /**
7
10
  * Creates a new execute task.
8
11
  * @param name The name of the task.
@@ -1 +1 @@
1
- {"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAWrD;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphContext, FrameGraphPass } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Creates a new execute task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n }\r\n\r\n public record(): FrameGraphPass<FrameGraphContext> {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"executeTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Misc/executeTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IAgBrC,OAAO;QACnB,OAAO,CAAC,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;IACvD,CAAC;IAED;;;;OAIG;IACH,YAAY,IAAY,EAAE,UAAsB;QAC5C,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5B,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QACjF,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphContext, FrameGraphPass } from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to execute a custom function.\r\n */\r\nexport class FrameGraphExecuteTask extends FrameGraphTask {\r\n /**\r\n * The function to execute.\r\n */\r\n public func: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * The function to execute when the task is disabled (optional).\r\n */\r\n public funcDisabled?: (context: FrameGraphContext) => void;\r\n\r\n /**\r\n * Custom readiness check (optional).\r\n */\r\n public customIsReady?: () => boolean;\r\n\r\n public override isReady(): boolean {\r\n return !this.customIsReady || this.customIsReady();\r\n }\r\n\r\n /**\r\n * Creates a new execute task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n }\r\n\r\n public record(): FrameGraphPass<FrameGraphContext> {\r\n if (!this.func) {\r\n throw new Error(\"FrameGraphExecuteTask: Execute task must have a function.\");\r\n }\r\n\r\n const pass = this._frameGraph.addPass(this.name);\r\n\r\n pass.setExecuteFunc((context) => {\r\n this.func(context);\r\n });\r\n\r\n const passDisabled = this._frameGraph.addPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setExecuteFunc((context) => {\r\n this.funcDisabled?.(context);\r\n });\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
@@ -51,7 +51,7 @@ export declare class FrameGraphBloomTask extends FrameGraphTask {
51
51
  * @param hdr Whether the bloom effect is HDR.
52
52
  * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
53
53
  */
54
- constructor(name: string, frameGraph: FrameGraph, weight: number, kernel: number, threshold: number, hdr?: boolean, bloomScale?: number);
54
+ constructor(name: string, frameGraph: FrameGraph, weight?: number, kernel?: number, threshold?: number, hdr?: boolean, bloomScale?: number);
55
55
  isReady(): boolean;
56
56
  record(): void;
57
57
  dispose(): void;
@@ -39,7 +39,7 @@ export class FrameGraphBloomTask extends FrameGraphTask {
39
39
  * @param hdr Whether the bloom effect is HDR.
40
40
  * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.
41
41
  */
42
- constructor(name, frameGraph, weight, kernel, threshold, hdr = false, bloomScale = 0.5) {
42
+ constructor(name, frameGraph, weight = 0.25, kernel = 64, threshold = 0.2, hdr = false, bloomScale = 0.5) {
43
43
  super(name, frameGraph);
44
44
  /**
45
45
  * The sampling mode to use for the source texture.
@@ -1 +1 @@
1
- {"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,kDAA2C;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD;;G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MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * 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(name: string) {\r\n this._name = name;\r\n if (this._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, weight: number, kernel: number, threshold: number, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.targetTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.targetTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.targetTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.targetTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"bloomTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/bloomTask.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,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAAC;QAE9I,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACzD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureCreationOptions, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphBloomMergeTask } from \"./bloomMergeTask\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ThinBloomEffect } from \"core/PostProcesses/thinBloomEffect\";\r\nimport { FrameGraphExtractHighlightsTask } from \"./extractHighlightsTask\";\r\nimport { FrameGraphBlurTask } from \"./blurTask\";\r\n\r\n/**\r\n * Task which applies a bloom render effect.\r\n */\r\nexport class FrameGraphBloomTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the bloom effect on.\r\n */\r\n public sourceTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the bloom effect to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the bloom effect.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The bloom effect to apply.\r\n */\r\n public readonly bloom: ThinBloomEffect;\r\n\r\n /**\r\n * Whether the bloom effect is HDR.\r\n * When true, the bloom effect will use a higher precision texture format (half float or float). Else, it will use unsigned byte.\r\n */\r\n public readonly hdr: boolean;\r\n\r\n /**\r\n * 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(name: string) {\r\n this._name = name;\r\n if (this._downscale) {\r\n this._downscale.name = `${name} Downscale`;\r\n }\r\n\r\n if (this._blurX) {\r\n this._blurX.name = `${name} Blur X`;\r\n }\r\n\r\n if (this._blurY) {\r\n this._blurY.name = `${name} Blur Y`;\r\n }\r\n\r\n if (this._merge) {\r\n this._merge.name = `${name} Merge`;\r\n }\r\n }\r\n\r\n private readonly _downscale: FrameGraphExtractHighlightsTask;\r\n private readonly _blurX: FrameGraphBlurTask;\r\n private readonly _blurY: FrameGraphBlurTask;\r\n private readonly _merge: FrameGraphBloomMergeTask;\r\n private readonly _defaultPipelineTextureType: number;\r\n\r\n /**\r\n * Constructs a new bloom task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param weight Weight of the bloom effect.\r\n * @param kernel Kernel size of the bloom effect.\r\n * @param threshold Threshold of the bloom effect.\r\n * @param hdr Whether the bloom effect is HDR.\r\n * @param bloomScale The scale of the bloom effect. This value is multiplied by the source texture size to determine the bloom texture size.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, weight = 0.25, kernel = 64, threshold = 0.2, hdr = false, bloomScale = 0.5) {\r\n super(name, frameGraph);\r\n\r\n this.hdr = hdr;\r\n\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (hdr) {\r\n const caps = frameGraph.engine.getCaps();\r\n if (caps.textureHalfFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else if (caps.textureFloatRender) {\r\n this._defaultPipelineTextureType = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n }\r\n\r\n this.bloom = new ThinBloomEffect(name, frameGraph.engine, bloomScale);\r\n this.bloom.threshold = threshold;\r\n this.bloom.kernel = kernel;\r\n this.bloom.weight = weight;\r\n\r\n this._downscale = new FrameGraphExtractHighlightsTask(`${name} Downscale`, this._frameGraph, this.bloom._downscale);\r\n this._blurX = new FrameGraphBlurTask(`${name} Blur X`, this._frameGraph, this.bloom._blurX);\r\n this._blurY = new FrameGraphBlurTask(`${name} Blur Y`, this._frameGraph, this.bloom._blurY);\r\n this._merge = new FrameGraphBloomMergeTask(`${name} Merge`, this._frameGraph, this.bloom._merge);\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.bloom.isReady();\r\n }\r\n\r\n public record(): void {\r\n if (this.sourceTexture === undefined) {\r\n throw new Error(\"FrameGraphBloomTask: sourceTexture is required\");\r\n }\r\n\r\n const sourceTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.sourceTexture);\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: {\r\n width: Math.floor(sourceTextureDescription.size.width * this.bloom.scale) || 1,\r\n height: Math.floor(sourceTextureDescription.size.height * this.bloom.scale) || 1,\r\n },\r\n options: {\r\n createMipMaps: false,\r\n types: [this._defaultPipelineTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n };\r\n\r\n const downscaleTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._downscale.name, textureCreationOptions);\r\n\r\n this._downscale.sourceTexture = this.sourceTexture;\r\n this._downscale.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._downscale.targetTexture = downscaleTextureHandle;\r\n this._downscale.record(true);\r\n\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX.name, textureCreationOptions);\r\n\r\n this._blurX.sourceTexture = downscaleTextureHandle;\r\n this._blurX.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX.targetTexture = blurXTextureHandle;\r\n this._blurX.record(true);\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY.name, textureCreationOptions);\r\n\r\n this._blurY.sourceTexture = blurXTextureHandle;\r\n this._blurY.sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY.targetTexture = blurYTextureHandle;\r\n this._blurY.record(true);\r\n\r\n const sourceTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture);\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this._merge.name, sourceTextureCreationOptions);\r\n\r\n this._merge.sourceTexture = this.sourceTexture;\r\n this._merge.sourceSamplingMode = this.sourceSamplingMode;\r\n this._merge.blurTexture = blurYTextureHandle;\r\n this._merge.targetTexture = this.outputTexture;\r\n this._merge.record(true);\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.sourceTexture);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n this._downscale.dispose();\r\n this._blurX.dispose();\r\n this._blurY.dispose();\r\n this._merge.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, IStencilState } from "../../../index.js";
1
+ import type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, IStencilState, IViewportLike, Nullable } from "../../../index.js";
2
2
  import { FrameGraphTask } from "../../frameGraphTask.js";
3
3
  /**
4
4
  * Task which applies a post process.
@@ -55,6 +55,12 @@ export declare class FrameGraphPostProcessTask extends FrameGraphTask {
55
55
  * If depth testing should be enabled (default is true).
56
56
  */
57
57
  depthTest: boolean;
58
+ /**
59
+ * The viewport to use when applying the post process.
60
+ * If set to null, the currently active viewport is used.
61
+ * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.
62
+ */
63
+ viewport?: Nullable<IViewportLike>;
58
64
  /**
59
65
  * The output texture of the post process.
60
66
  */
@@ -88,13 +88,16 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
88
88
  context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);
89
89
  }
90
90
  additionalExecute?.(context);
91
+ if (this.viewport) {
92
+ context.setViewport(this.viewport);
93
+ }
91
94
  context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {
92
95
  if (this.sourceTexture !== undefined) {
93
96
  context.bindTextureHandle(this._postProcessDrawWrapper.effect, "textureSampler", this.sourceTexture);
94
97
  }
95
98
  additionalBindings?.(context);
96
99
  this.postProcess.bind();
97
- }, this.stencilState, this.disableColorWrite, this.drawBackFace, this.depthTest);
100
+ }, this.stencilState, this.disableColorWrite, this.drawBackFace, this.depthTest, this.viewport !== undefined);
98
101
  });
99
102
  if (!skipCreationOfDisabledPasses) {
100
103
  const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
@@ -105,7 +108,10 @@ export class FrameGraphPostProcessTask extends FrameGraphTask {
105
108
  passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);
106
109
  passDisabled.setExecuteFunc((context) => {
107
110
  if (this.sourceTexture !== undefined) {
108
- context.copyTexture(this.sourceTexture);
111
+ if (this.viewport) {
112
+ context.setViewport(this.viewport);
113
+ }
114
+ context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);
109
115
  }
110
116
  });
111
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IA+EzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA3F5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAmBpE;;;;;WAKG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;;;;WAKG;QACI,oBAAe,GAAG,KAAK,CAAC;QAE/B;;;WAGG;QACI,sBAAiB,GAAG,KAAK,CAAC;QAEjC;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QAyCpB,IAAI,CAAC,WAAW,GAAG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FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, IStencilState } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilState;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * The output texture of the post process.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest\r\n );\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.copyTexture(this.sourceTexture);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"postProcessTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/postProcessTask.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,cAAc;IAsFzD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACxC,CAAC;IAQD;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,WAA0B;QACxE,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAlG5B;;WAEG;QACI,uBAAkB,GAAG,SAAS,CAAC,6BAA6B,CAAC;QAmBpE;;;;;WAKG;QACI,kBAAa,GAAG,KAAK,CAAC;QAE7B;;;;;WAKG;QACI,oBAAe,GAAG,KAAK,CAAC;QAE/B;;;WAGG;QACI,sBAAiB,GAAG,KAAK,CAAC;QAEjC;;WAEG;QACI,iBAAY,GAAG,KAAK,CAAC;QAE5B;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QAgDpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,CA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AC,QAAQ,KAAK,SAAS,CAAC,CAAC;gBACpF,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n IStencilState,\r\n IViewportLike,\r\n Nullable,\r\n} from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task which applies a post process.\r\n */\r\nexport class FrameGraphPostProcessTask extends FrameGraphTask {\r\n /**\r\n * The source texture to apply the post process on.\r\n * It's allowed to be undefined if the post process does not require a source texture.\r\n * In that case, targetTexture must be provided.\r\n */\r\n public sourceTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The sampling mode to use for the source texture.\r\n */\r\n public sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n\r\n /**\r\n * The target texture to render the post process to.\r\n * If not supplied, a texture with the same configuration as the source texture will be created.\r\n */\r\n public targetTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The stencil state to use for the post process (optional).\r\n */\r\n public stencilState?: IStencilState;\r\n\r\n /**\r\n * The depth attachment texture to use for the post process (optional).\r\n * Note that a post-process task never writes to the depth buffer: attaching a depth texture is only useful if you want to test against the depth/stencil aspect or write to the stencil buffer.\r\n */\r\n public depthAttachmentTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * If true, the depth attachment will be read-only.\r\n * This means that the post process will not write to the depth buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * If true, the stencil attachment will be read-only.\r\n * This means that the post process will not write to the stencil buffer.\r\n * Setting depthReadOnly and stencilReadOnly to true is useful when you want to also be able to bind this same depth/stencil attachment to a shader.\r\n * Note that it will only work in WebGPU, as WebGL does not support read-only depth/stencil attachments.\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * If true, color write will be disabled when applying the post process.\r\n * This means that the post process will not write to the color buffer.\r\n */\r\n public disableColorWrite = false;\r\n\r\n /**\r\n * If true, the post process will be generated by a back face full-screen quad (CW order).\r\n */\r\n public drawBackFace = false;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * The viewport to use when applying the post process.\r\n * If set to null, the currently active viewport is used.\r\n * If undefined (default), the viewport is reset to a full screen viewport before applying the post process.\r\n */\r\n public viewport?: Nullable<IViewportLike>;\r\n\r\n /**\r\n * The output texture of the post process.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthAttachmentTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthAttachmentTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The post process to apply.\r\n */\r\n public readonly postProcess: EffectWrapper;\r\n\r\n /**\r\n * The draw wrapper used by the post process\r\n */\r\n public get drawWrapper() {\r\n return this._postProcessDrawWrapper;\r\n }\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n protected _sourceWidth: number;\r\n protected _sourceHeight: number;\r\n protected _outputWidth: number;\r\n protected _outputHeight: number;\r\n\r\n /**\r\n * Constructs a new post process task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param postProcess The post process to apply.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, postProcess: EffectWrapper) {\r\n super(name, frameGraph);\r\n\r\n this.postProcess = postProcess;\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n this.outputDepthAttachmentTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this.postProcess.isReady();\r\n }\r\n\r\n public record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined && this.targetTexture === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture or targetTexture is required`);\r\n }\r\n\r\n const sourceTextureCreationOptions = this.sourceTexture !== undefined ? this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture) : undefined;\r\n if (sourceTextureCreationOptions) {\r\n sourceTextureCreationOptions.options.samples = 1;\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture, this.name, sourceTextureCreationOptions);\r\n if (this.depthAttachmentTexture !== undefined) {\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture, this.depthAttachmentTexture);\r\n }\r\n\r\n if (sourceTextureCreationOptions) {\r\n const sourceSize = this._frameGraph.textureManager.getTextureAbsoluteDimensions(sourceTextureCreationOptions);\r\n\r\n this._sourceWidth = sourceSize.width;\r\n this._sourceHeight = sourceSize.height;\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.textureManager.getTextureDescription(this.outputTexture);\r\n\r\n this._outputWidth = outputTextureDescription.size.width;\r\n this._outputHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.depthReadOnly = this.depthReadOnly;\r\n pass.stencilReadOnly = this.stencilReadOnly;\r\n\r\n pass.addDependencies(this.sourceTexture);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n pass.setRenderTargetDepth(this.depthAttachmentTexture);\r\n pass.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n additionalExecute?.(context);\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n if (this.sourceTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture);\r\n }\r\n additionalBindings?.(context);\r\n this.postProcess.bind();\r\n },\r\n this.stencilState,\r\n this.disableColorWrite,\r\n this.drawBackFace,\r\n this.depthTest,\r\n this.viewport !== undefined\r\n );\r\n });\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.depthReadOnly = this.depthReadOnly;\r\n passDisabled.stencilReadOnly = this.stencilReadOnly;\r\n\r\n passDisabled.addDependencies(this.sourceTexture);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n passDisabled.setRenderTargetDepth(this.depthAttachmentTexture);\r\n passDisabled.setExecuteFunc((context) => {\r\n if (this.sourceTexture !== undefined) {\r\n if (this.viewport) {\r\n context.setViewport(this.viewport);\r\n }\r\n context.copyTexture(this.sourceTexture, undefined, this.viewport !== undefined);\r\n }\r\n });\r\n }\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose(): void {\r\n this.postProcess.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -9,6 +9,7 @@ export declare class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {
9
9
  normalTexture: FrameGraphTextureHandle;
10
10
  camera: Camera;
11
11
  readonly postProcess: ThinSSAO2PostProcess;
12
+ private _currentCameraMode;
12
13
  constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSAO2PostProcess);
13
14
  record(skipCreationOfDisabledPasses?: boolean): FrameGraphRenderPass;
14
15
  }
@@ -7,13 +7,20 @@ import { ThinSSAO2PostProcess } from "../../../PostProcesses/thinSSAO2PostProces
7
7
  export class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {
8
8
  constructor(name, frameGraph, thinPostProcess) {
9
9
  super(name, frameGraph, thinPostProcess || new ThinSSAO2PostProcess(name, frameGraph.scene));
10
+ this._currentCameraMode = -1;
10
11
  }
11
12
  record(skipCreationOfDisabledPasses = false) {
12
13
  if (this.sourceTexture === undefined || this.depthTexture === undefined || this.normalTexture === undefined || this.camera === undefined) {
13
14
  throw new Error(`FrameGraphSSAO2Task "${this.name}": sourceTexture, depthTexture, normalTexture and camera are required`);
14
15
  }
16
+ this._currentCameraMode = this.camera.mode;
17
+ this.postProcess.updateEffect();
15
18
  const pass = super.record(skipCreationOfDisabledPasses, (context) => {
16
19
  this.postProcess.camera = this.camera;
20
+ if (this._currentCameraMode !== this.camera.mode) {
21
+ this._currentCameraMode = this.camera.mode;
22
+ this.postProcess.updateEffect();
23
+ }
17
24
  context.setTextureSamplingMode(this.depthTexture, 2);
18
25
  context.setTextureSamplingMode(this.normalTexture, 2);
19
26
  }, (context) => {
@@ -1 +1 @@
1
- {"version":3,"file":"ssao2Task.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/ssao2Task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,uDAAgD;AAE/E;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,yBAAyB;IAS9D,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAsC;QACpF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACjG,CAAC;IAEe,MAAM,CAAC,4BAA4B,GAAG,KAAK;QACvD,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvI,MAAM,IAAI,KAAK,CAAC,wBAAwB,IAAI,CAAC,IAAI,uEAAuE,CAAC,CAAC;QAC9H,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CACrB,4BAA4B,EAC5B,CAAC,OAAO,EAAE,EAAE;YACR,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAEtC,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,6BAA6B,CAAC,CAAC;YAC3F,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,6BAA6B,CAAC,CAAC;QAChG,CAAC,EACD,CAAC,OAAO,EAAE,EAAE;YACR,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACnG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACzG,CAAC,CACJ,CAAC;QAEF,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAE1C,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAEpD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphRenderPass, Camera, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { ThinSSAO2PostProcess } from \"core/PostProcesses/thinSSAO2PostProcess\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n public normalTexture: FrameGraphTextureHandle;\r\n\r\n public camera: Camera;\r\n\r\n public override readonly postProcess: ThinSSAO2PostProcess;\r\n\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSAO2PostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinSSAO2PostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.normalTexture === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphSSAO2Task \"${this.name}\": sourceTexture, depthTexture, normalTexture and camera are required`);\r\n }\r\n\r\n const pass = super.record(\r\n skipCreationOfDisabledPasses,\r\n (context) => {\r\n this.postProcess.camera = this.camera;\r\n\r\n context.setTextureSamplingMode(this.depthTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n context.setTextureSamplingMode(this.normalTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n },\r\n (context) => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"depthSampler\", this.depthTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"normalSampler\", this.normalTexture);\r\n }\r\n );\r\n\r\n pass.addDependencies([this.depthTexture]);\r\n\r\n this.postProcess.textureWidth = this._sourceWidth;\r\n this.postProcess.textureHeight = this._sourceHeight;\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ssao2Task.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/ssao2Task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,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,CAAC,CAAC;YAC3F,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,6BAA6B,CAAC,CAAC;QAChG,CAAC,EACD,CAAC,OAAO,EAAE,EAAE;YACR,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YACnG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACzG,CAAC,CACJ,CAAC;QAEF,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QAE1C,IAAI,CAAC,WAAW,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,WAAW,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAEpD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphRenderPass, Camera, FrameGraphTextureHandle } from \"core/index\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { ThinSSAO2PostProcess } from \"core/PostProcesses/thinSSAO2PostProcess\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphSSAO2Task extends FrameGraphPostProcessTask {\r\n public depthTexture: FrameGraphTextureHandle;\r\n\r\n public normalTexture: FrameGraphTextureHandle;\r\n\r\n public camera: Camera;\r\n\r\n public override readonly postProcess: ThinSSAO2PostProcess;\r\n\r\n private _currentCameraMode = -1;\r\n\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinSSAO2PostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinSSAO2PostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(skipCreationOfDisabledPasses = false): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.depthTexture === undefined || this.normalTexture === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphSSAO2Task \"${this.name}\": sourceTexture, depthTexture, normalTexture and camera are required`);\r\n }\r\n\r\n this._currentCameraMode = this.camera.mode;\r\n this.postProcess.updateEffect();\r\n\r\n const pass = super.record(\r\n skipCreationOfDisabledPasses,\r\n (context) => {\r\n this.postProcess.camera = this.camera;\r\n\r\n if (this._currentCameraMode !== this.camera.mode) {\r\n this._currentCameraMode = this.camera.mode;\r\n this.postProcess.updateEffect();\r\n }\r\n\r\n context.setTextureSamplingMode(this.depthTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n context.setTextureSamplingMode(this.normalTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n },\r\n (context) => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"depthSampler\", this.depthTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"normalSampler\", this.normalTexture);\r\n }\r\n );\r\n\r\n pass.addDependencies([this.depthTexture]);\r\n\r\n this.postProcess.textureWidth = this._sourceWidth;\r\n this.postProcess.textureHeight = this._sourceHeight;\r\n\r\n return pass;\r\n }\r\n}\r\n"]}
@@ -14,7 +14,7 @@ export declare class FrameGraphTAATask extends FrameGraphPostProcessTask {
14
14
  * The handle to the velocity texture. Only needed if postProcess.reprojectHistory is enabled.
15
15
  * Note that you must use the linear velocity texture!
16
16
  */
17
- velocityTexture: FrameGraphTextureHandle;
17
+ velocityTexture?: FrameGraphTextureHandle;
18
18
  protected _onBeforeRenderSceneObserver: Observer<Scene>;
19
19
  protected _initRenderingObserver: Observer<ObjectRenderer>;
20
20
  /**