@babylonjs/core 7.44.0 → 7.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/Debug/debugLayer.d.ts +4 -0
  2. package/Debug/debugLayer.js +9 -0
  3. package/Debug/debugLayer.js.map +1 -1
  4. package/Engines/Extensions/engine.renderTarget.js +2 -4
  5. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  6. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -4
  7. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  8. package/Engines/abstractEngine.d.ts +19 -1
  9. package/Engines/abstractEngine.js +48 -9
  10. package/Engines/abstractEngine.js.map +1 -1
  11. package/Engines/engine.d.ts +1 -1
  12. package/Engines/engine.js +2 -20
  13. package/Engines/engine.js.map +1 -1
  14. package/Engines/renderTargetWrapper.js +2 -2
  15. package/Engines/renderTargetWrapper.js.map +1 -1
  16. package/Engines/thinEngine.js +1 -5
  17. package/Engines/thinEngine.js.map +1 -1
  18. package/Engines/webgpuEngine.js +1 -0
  19. package/Engines/webgpuEngine.js.map +1 -1
  20. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +16 -12
  21. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +63 -27
  22. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.d.ts +72 -0
  24. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +197 -0
  25. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -0
  26. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +4 -0
  27. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +9 -0
  28. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  30. package/FrameGraph/Node/Blocks/index.js +1 -0
  31. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  32. package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +4 -2
  33. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +2 -0
  34. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
  35. package/FrameGraph/Node/nodeRenderGraph.d.ts +3 -2
  36. package/FrameGraph/Node/nodeRenderGraph.js +4 -3
  37. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  38. package/FrameGraph/Node/nodeRenderGraphBlock.js +4 -4
  39. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  40. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.d.ts +8 -0
  41. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -0
  42. package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
  43. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.d.ts +21 -0
  44. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js +31 -0
  45. package/FrameGraph/Node/nodeRenderGraphConnectionPointCustomObject.js.map +1 -0
  46. package/FrameGraph/Passes/pass.d.ts +1 -0
  47. package/FrameGraph/Passes/pass.js +4 -1
  48. package/FrameGraph/Passes/pass.js.map +1 -1
  49. package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +81 -0
  50. package/FrameGraph/Tasks/Layers/baseLayerTask.js +304 -0
  51. package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -0
  52. package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +3 -40
  53. package/FrameGraph/Tasks/Layers/glowLayerTask.js +4 -158
  54. package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -1
  55. package/FrameGraph/Tasks/Layers/highlightLayerTask.d.ts +21 -0
  56. package/FrameGraph/Tasks/Layers/highlightLayerTask.js +32 -0
  57. package/FrameGraph/Tasks/Layers/highlightLayerTask.js.map +1 -0
  58. package/FrameGraph/Tasks/Misc/executeTask.d.ts +2 -2
  59. package/FrameGraph/Tasks/Misc/executeTask.js +1 -0
  60. package/FrameGraph/Tasks/Misc/executeTask.js.map +1 -1
  61. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
  62. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
  63. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +1 -1
  64. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  65. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +5 -4
  66. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
  67. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +5 -4
  68. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
  69. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +2 -4
  70. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  71. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -2
  72. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  73. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -2
  74. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +1 -0
  75. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  76. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +2 -2
  77. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +1 -0
  78. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  79. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
  80. package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -0
  81. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  82. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
  83. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  84. package/FrameGraph/frameGraph.d.ts +8 -2
  85. package/FrameGraph/frameGraph.js +31 -5
  86. package/FrameGraph/frameGraph.js.map +1 -1
  87. package/FrameGraph/frameGraphRenderContext.d.ts +10 -0
  88. package/FrameGraph/frameGraphRenderContext.js +14 -0
  89. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  90. package/FrameGraph/frameGraphTask.d.ts +3 -2
  91. package/FrameGraph/frameGraphTask.js +12 -2
  92. package/FrameGraph/frameGraphTask.js.map +1 -1
  93. package/FrameGraph/frameGraphTypes.d.ts +4 -0
  94. package/FrameGraph/frameGraphTypes.js.map +1 -1
  95. package/FrameGraph/index.d.ts +1 -0
  96. package/FrameGraph/index.js +1 -0
  97. package/FrameGraph/index.js.map +1 -1
  98. package/Helpers/environmentHelper.js +7 -6
  99. package/Helpers/environmentHelper.js.map +1 -1
  100. package/Layers/effectLayer.d.ts +1 -1
  101. package/Layers/effectLayer.js.map +1 -1
  102. package/Layers/glowLayer.d.ts +2 -14
  103. package/Layers/glowLayer.js +34 -36
  104. package/Layers/glowLayer.js.map +1 -1
  105. package/Layers/highlightLayer.d.ts +13 -74
  106. package/Layers/highlightLayer.js +123 -309
  107. package/Layers/highlightLayer.js.map +1 -1
  108. package/Layers/index.d.ts +1 -0
  109. package/Layers/index.js +1 -0
  110. package/Layers/index.js.map +1 -1
  111. package/Layers/thinEffectLayer.d.ts +55 -2
  112. package/Layers/thinEffectLayer.js +66 -0
  113. package/Layers/thinEffectLayer.js.map +1 -1
  114. package/Layers/thinGlowLayer.d.ts +3 -6
  115. package/Layers/thinGlowLayer.js +4 -1
  116. package/Layers/thinGlowLayer.js.map +1 -1
  117. package/Layers/thinHighlightLayer.d.ts +197 -0
  118. package/Layers/thinHighlightLayer.js +417 -0
  119. package/Layers/thinHighlightLayer.js.map +1 -0
  120. package/Materials/Node/nodeMaterial.js +2 -1
  121. package/Materials/Node/nodeMaterial.js.map +1 -1
  122. package/Materials/PBR/pbrBRDFConfiguration.d.ts +14 -0
  123. package/Materials/PBR/pbrBRDFConfiguration.js +19 -0
  124. package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
  125. package/Materials/effect.d.ts +5 -0
  126. package/Materials/effect.js +15 -0
  127. package/Materials/effect.js.map +1 -1
  128. package/Meshes/Compression/dracoCompression.d.ts +4 -2
  129. package/Meshes/Compression/dracoCompression.js +24 -11
  130. package/Meshes/Compression/dracoCompression.js.map +1 -1
  131. package/Meshes/Compression/dracoCompressionWorker.js +4 -4
  132. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  133. package/Meshes/Compression/dracoEncoder.d.ts +5 -1
  134. package/Meshes/Compression/dracoEncoder.js +23 -17
  135. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  136. package/Meshes/Compression/dracoEncoder.types.d.ts +4 -4
  137. package/Meshes/Compression/dracoEncoder.types.js.map +1 -1
  138. package/Meshes/Compression/meshoptCompression.js +17 -2
  139. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  140. package/Meshes/Compression/test/integration/draco.test.d.ts +1 -0
  141. package/Meshes/Compression/test/integration/draco.test.js +30 -0
  142. package/Meshes/Compression/test/integration/draco.test.js.map +1 -0
  143. package/Meshes/csg.js +4 -0
  144. package/Meshes/csg.js.map +1 -1
  145. package/Meshes/transformNode.d.ts +4 -1
  146. package/Meshes/transformNode.js +4 -1
  147. package/Meshes/transformNode.js.map +1 -1
  148. package/Misc/copyTextureToTexture.js +1 -1
  149. package/Misc/copyTextureToTexture.js.map +1 -1
  150. package/Misc/error.d.ts +6 -0
  151. package/Misc/error.js +10 -0
  152. package/Misc/error.js.map +1 -1
  153. package/Misc/screenshotTools.js +58 -5
  154. package/Misc/screenshotTools.js.map +1 -1
  155. package/Misc/tools.d.ts +21 -1
  156. package/Misc/tools.js +33 -0
  157. package/Misc/tools.js.map +1 -1
  158. package/Particles/particleHelper.js +2 -1
  159. package/Particles/particleHelper.js.map +1 -1
  160. package/Particles/particleSystemSet.d.ts +1 -0
  161. package/Particles/particleSystemSet.js +1 -0
  162. package/Particles/particleSystemSet.js.map +1 -1
  163. package/Particles/webgl2ParticleSystem.d.ts +1 -1
  164. package/Particles/webgl2ParticleSystem.js +1 -2
  165. package/Particles/webgl2ParticleSystem.js.map +1 -1
  166. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +2 -1
  167. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  168. package/Rendering/depthRenderer.js +1 -1
  169. package/Rendering/depthRenderer.js.map +1 -1
  170. package/Rendering/objectRenderer.d.ts +5 -3
  171. package/Rendering/objectRenderer.js +5 -3
  172. package/Rendering/objectRenderer.js.map +1 -1
  173. package/Rendering/renderingManager.d.ts +4 -0
  174. package/Rendering/renderingManager.js +1 -0
  175. package/Rendering/renderingManager.js.map +1 -1
  176. package/Shaders/ShadersInclude/intersectionFunctions.d.ts +5 -0
  177. package/Shaders/ShadersInclude/intersectionFunctions.js +14 -0
  178. package/Shaders/ShadersInclude/intersectionFunctions.js.map +1 -0
  179. package/Shaders/ShadersInclude/pbrBlockReflection.js +7 -1
  180. package/Shaders/ShadersInclude/pbrBlockReflection.js.map +1 -1
  181. package/Shaders/background.fragment.d.ts +1 -0
  182. package/Shaders/background.fragment.js +3 -5
  183. package/Shaders/background.fragment.js.map +1 -1
  184. package/Shaders/gaussianSplatting.vertex.d.ts +1 -0
  185. package/Shaders/gaussianSplatting.vertex.js +3 -1
  186. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  187. package/ShadersWGSL/ShadersInclude/intersectionFunctions.d.ts +5 -0
  188. package/ShadersWGSL/ShadersInclude/intersectionFunctions.js +14 -0
  189. package/ShadersWGSL/ShadersInclude/intersectionFunctions.js.map +1 -0
  190. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js +7 -1
  191. package/ShadersWGSL/ShadersInclude/pbrBlockReflection.js.map +1 -1
  192. package/ShadersWGSL/background.fragment.d.ts +1 -0
  193. package/ShadersWGSL/background.fragment.js +3 -5
  194. package/ShadersWGSL/background.fragment.js.map +1 -1
  195. package/ShadersWGSL/glowMapGeneration.fragment.js +1 -2
  196. package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
  197. package/ShadersWGSL/layer.fragment.js +1 -2
  198. package/ShadersWGSL/layer.fragment.js.map +1 -1
  199. package/XR/features/WebXRHandTracking.js +8 -7
  200. package/XR/features/WebXRHandTracking.js.map +1 -1
  201. package/package.json +1 -1
  202. package/types.d.ts +4 -0
  203. package/types.js.map +1 -1
@@ -0,0 +1,304 @@
1
+ import { FrameGraphTask } from "../../frameGraphTask.js";
2
+ import { FrameGraphObjectRendererTask } from "../Rendering/objectRendererTask.js";
3
+ import { FrameGraphClearTextureTask } from "../Texture/clearTextureTask.js";
4
+ import { FrameGraphBlurTask } from "../PostProcesses/blurTask.js";
5
+
6
+ import { FrameGraphTextureManager } from "../../frameGraphTextureManager.js";
7
+ import { getDimensionsFromTextureSize } from "../../../Materials/Textures/textureCreationOptions.js";
8
+ import { FrameGraphPostProcessTask } from "../PostProcesses/postProcessTask.js";
9
+ import { Vector2 } from "../../../Maths/math.vector.js";
10
+ import { ThinGlowBlurPostProcess } from "../../../Layers/thinEffectLayer.js";
11
+ import { FrameGraphExecuteTask } from "../Misc/executeTask.js";
12
+ class FrameGraphGlowBlurTask extends FrameGraphPostProcessTask {
13
+ /**
14
+ * Constructs a new glow blur task.
15
+ * @param name The name of the task.
16
+ * @param frameGraph The frame graph this task is associated with.
17
+ * @param thinPostProcess The thin post process to use for the glow blur effect. If not provided, a new one will be created.
18
+ */
19
+ constructor(name, frameGraph, thinPostProcess) {
20
+ super(name, frameGraph, thinPostProcess || new ThinGlowBlurPostProcess(name, frameGraph.engine, new Vector2(1, 0), 1));
21
+ }
22
+ record(skipCreationOfDisabledPasses = false, additionalExecute, additionalBindings) {
23
+ const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);
24
+ this.postProcess.textureWidth = this._outputWidth;
25
+ this.postProcess.textureHeight = this._outputHeight;
26
+ return pass;
27
+ }
28
+ }
29
+ /**
30
+ * @internal
31
+ */
32
+ export class FrameGraphBaseLayerTask extends FrameGraphTask {
33
+ /**
34
+ * The name of the task.
35
+ */
36
+ get name() {
37
+ return this._name;
38
+ }
39
+ set name(name) {
40
+ this._name = name;
41
+ if (this._blurX) {
42
+ for (let i = 0; i < this._blurX.length; i++) {
43
+ this._blurX[i].name = `${name} Blur X${i}`;
44
+ this._blurY[i].name = `${name} Blur Y${i}`;
45
+ }
46
+ }
47
+ if (this._clearLayerTextures) {
48
+ this._clearLayerTextures.name = name + " Clear Layer";
49
+ }
50
+ if (this._objectRendererForLayer) {
51
+ this._objectRendererForLayer.name = name + " Render to Layer";
52
+ }
53
+ }
54
+ /**
55
+ * Constructs a new layer task.
56
+ * @param name Name of the task.
57
+ * @param frameGraph The frame graph this task is associated with.
58
+ * @param scene The scene to render the layer in.
59
+ * @param layer The layer.
60
+ * @param numBlurPasses The number of blur passes applied by the layer.
61
+ * @param useCustomBlur If true, the layer will use a custom blur post process instead of the default one.
62
+ * @param _setRenderTargetDepth If true, the task will set the render target depth.
63
+ * @param _notifyBlurObservable If true, the task will notify before and after blurring occurs.
64
+ */
65
+ constructor(name, frameGraph, scene, layer, numBlurPasses, useCustomBlur = false, _setRenderTargetDepth = false, _notifyBlurObservable = false) {
66
+ super(name, frameGraph);
67
+ this._setRenderTargetDepth = _setRenderTargetDepth;
68
+ this._notifyBlurObservable = _notifyBlurObservable;
69
+ this._blurX = [];
70
+ this._blurY = [];
71
+ this._onBeforeBlurTask = null;
72
+ this._onAfterBlurTask = null;
73
+ this._onBeforeObservableObserver = null;
74
+ this._onAfterObservableObserver = null;
75
+ this._onAfterRenderingGroupObserver = null;
76
+ this._scene = scene;
77
+ this._engine = scene.getEngine();
78
+ this.layer = layer;
79
+ for (let i = 0; i < numBlurPasses; i++) {
80
+ if (useCustomBlur) {
81
+ this._blurX.push(new FrameGraphGlowBlurTask(`${name} Blur X${i}`, this._frameGraph, this.layer._postProcesses[1 + i * 2 + 0]));
82
+ this._blurY.push(new FrameGraphGlowBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.layer._postProcesses[1 + i * 2 + 1]));
83
+ }
84
+ else {
85
+ this._blurX.push(new FrameGraphBlurTask(`${name} Blur X${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 0]));
86
+ this._blurY.push(new FrameGraphBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 1]));
87
+ }
88
+ }
89
+ this._clearLayerTextures = new FrameGraphClearTextureTask(name + " Clear Layer", frameGraph);
90
+ this._clearLayerTextures.clearColor = true;
91
+ this._clearLayerTextures.clearDepth = true;
92
+ this._objectRendererForLayer = new FrameGraphObjectRendererTask(name + " Render to Layer", frameGraph, scene, undefined, this.layer.objectRenderer);
93
+ if (this._notifyBlurObservable) {
94
+ this._onBeforeBlurTask = new FrameGraphExecuteTask(name + " On Before Blur", frameGraph);
95
+ this._onAfterBlurTask = new FrameGraphExecuteTask(name + " On After Blur", frameGraph);
96
+ this._onBeforeBlurTask.func = () => {
97
+ if (this.layer.onBeforeBlurObservable.hasObservers()) {
98
+ this.layer.onBeforeBlurObservable.notifyObservers(this.layer);
99
+ }
100
+ };
101
+ this._onAfterBlurTask.func = () => {
102
+ if (this.layer.onAfterBlurObservable.hasObservers()) {
103
+ this.layer.onAfterBlurObservable.notifyObservers(this.layer);
104
+ }
105
+ };
106
+ }
107
+ this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
108
+ this.onTexturesAllocatedObservable.add((context) => {
109
+ for (let i = 0; i < this._blurX.length; i++) {
110
+ this._blurX[i].onTexturesAllocatedObservable.notifyObservers(context);
111
+ this._blurY[i].onTexturesAllocatedObservable.notifyObservers(context);
112
+ }
113
+ context.setTextureSamplingMode(this._blurY[this._blurY.length - 1].destinationTexture, 2);
114
+ });
115
+ }
116
+ isReady() {
117
+ return this._objectRendererForLayer.isReady() && this.layer.isLayerReady();
118
+ }
119
+ record() {
120
+ if (this.destinationTexture === undefined || this.objectRendererTask === undefined) {
121
+ throw new Error(`${this.constructor.name} "${this.name}": destinationTexture and objectRendererTask are required`);
122
+ }
123
+ this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
124
+ // Uses the layerTexture or creates a color texture to render the layer to
125
+ let textureSize;
126
+ let textureCreationOptions;
127
+ let colorLayerOutput;
128
+ if (this.layerTexture) {
129
+ colorLayerOutput = this.layerTexture;
130
+ textureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.layerTexture);
131
+ textureSize = getDimensionsFromTextureSize(textureCreationOptions.size);
132
+ textureCreationOptions.size = textureSize;
133
+ }
134
+ else {
135
+ const destinationTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.destinationTexture);
136
+ const fixedTextureSize = this.layer._options.mainTextureFixedSize ? Math.max(2, this.layer._options.mainTextureFixedSize) : 0;
137
+ textureSize = getDimensionsFromTextureSize(destinationTextureCreationOptions.size);
138
+ textureSize.width = fixedTextureSize || Math.floor(textureSize.width * (this.layer._options.mainTextureRatio || 0.1));
139
+ textureSize.height = fixedTextureSize || Math.floor(textureSize.height * (this.layer._options.mainTextureRatio || 0.1));
140
+ textureCreationOptions = {
141
+ size: textureSize,
142
+ options: {
143
+ createMipMaps: false,
144
+ types: [this.layer._options.mainTextureType],
145
+ formats: [5],
146
+ samples: 1,
147
+ useSRGBBuffers: [false],
148
+ creationFlags: [0],
149
+ },
150
+ sizeIsPercentage: this.layer._options.mainTextureFixedSize ? false : destinationTextureCreationOptions.sizeIsPercentage,
151
+ };
152
+ colorLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Color`, textureCreationOptions);
153
+ }
154
+ // Creates a depth texture, used to render objects to the layer
155
+ // We don't reuse the depth texture of the objectRendererTask, as the size of the layer texture will generally be different (smaller).
156
+ const textureDepthCreationOptions = {
157
+ size: textureSize,
158
+ options: FrameGraphTextureManager.CloneTextureOptions(textureCreationOptions.options),
159
+ sizeIsPercentage: textureCreationOptions.sizeIsPercentage,
160
+ };
161
+ textureDepthCreationOptions.options.formats[0] = 14;
162
+ const depthLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Depth`, textureDepthCreationOptions);
163
+ this._addInternalDependencies([colorLayerOutput, depthLayerOutput]);
164
+ // Clears the textures
165
+ this._clearLayerTextures.destinationTexture = colorLayerOutput;
166
+ this._clearLayerTextures.depthTexture = depthLayerOutput;
167
+ this._clearLayerTextures.color = this.layer.neutralColor;
168
+ this._clearLayerTextures.clearDepth = true;
169
+ const clearTaskPass = this._clearLayerTextures.record();
170
+ // Renders the objects to the layer texture
171
+ this._objectRendererForLayer.destinationTexture = this._clearLayerTextures.outputTexture;
172
+ this._objectRendererForLayer.depthTexture = this._clearLayerTextures.outputDepthTexture;
173
+ this._objectRendererForLayer.camera = this.objectRendererTask.camera;
174
+ this._objectRendererForLayer.objectList = this.objectRendererTask.objectList;
175
+ this._objectRendererForLayer.disableShadows = true;
176
+ const objectRendererForLayerTaskPass = this._objectRendererForLayer.record();
177
+ // Blurs the layer color texture
178
+ let blurTextureType = 0;
179
+ if (this._engine.getCaps().textureHalfFloatRender) {
180
+ blurTextureType = 2;
181
+ }
182
+ else {
183
+ blurTextureType = 0;
184
+ }
185
+ textureCreationOptions.options.types[0] = blurTextureType;
186
+ const blurTextureSizeRatio = this.layer._options.blurTextureSizeRatio !== undefined ? this.layer._options.blurTextureSizeRatio || 0.1 : undefined;
187
+ if (blurTextureSizeRatio !== undefined) {
188
+ textureSize.width = Math.floor(textureSize.width * blurTextureSizeRatio);
189
+ textureSize.height = Math.floor(textureSize.height * blurTextureSizeRatio);
190
+ }
191
+ const onBeforeBlurPass = this._onBeforeBlurTask?.record();
192
+ const blurPasses = [];
193
+ for (let i = 0; i < this._blurX.length; i++) {
194
+ const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[i].name, textureCreationOptions);
195
+ this._blurX[i].sourceTexture = i === 0 ? this._objectRendererForLayer.outputTexture : this._blurY[i - 1].outputTexture;
196
+ this._blurX[i].sourceSamplingMode = 2;
197
+ this._blurX[i].destinationTexture = blurXTextureHandle;
198
+ blurPasses.push(this._blurX[i].record(true));
199
+ const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[i].name, textureCreationOptions);
200
+ this._blurY[i].sourceTexture = this._blurX[i].outputTexture;
201
+ this._blurY[i].sourceSamplingMode = 2;
202
+ this._blurY[i].destinationTexture = blurYTextureHandle;
203
+ blurPasses.push(this._blurY[i].record(true));
204
+ this._addInternalDependencies([blurXTextureHandle, blurYTextureHandle]);
205
+ textureSize.width = textureSize.width >> 1;
206
+ textureSize.height = textureSize.height >> 1;
207
+ }
208
+ const onAfterBlurPass = this._onAfterBlurTask?.record();
209
+ // Enables stencil (if stencil is needed) when rendering objects to the main texture
210
+ // We also disable the internal passes if the layer should not render
211
+ this.objectRendererTask.objectRenderer.onBeforeRenderObservable.remove(this._onBeforeObservableObserver);
212
+ this._onBeforeObservableObserver = this.objectRendererTask.objectRenderer.onBeforeRenderObservable.add(() => {
213
+ const shouldRender = this.layer.shouldRender();
214
+ clearTaskPass.disabled = !shouldRender;
215
+ objectRendererForLayerTaskPass.disabled = !shouldRender;
216
+ if (onBeforeBlurPass) {
217
+ onBeforeBlurPass.disabled = !shouldRender;
218
+ }
219
+ for (let i = 0; i < blurPasses.length; i++) {
220
+ blurPasses[i].disabled = !shouldRender;
221
+ }
222
+ if (onAfterBlurPass) {
223
+ onAfterBlurPass.disabled = !shouldRender;
224
+ }
225
+ if (shouldRender && this.layer.needStencil()) {
226
+ this._engine.setStencilBuffer(true);
227
+ this._engine.setStencilFunctionReference(1);
228
+ }
229
+ });
230
+ this.objectRendererTask.objectRenderer.onAfterRenderObservable.remove(this._onAfterObservableObserver);
231
+ this._onAfterObservableObserver = this.objectRendererTask.objectRenderer.onAfterRenderObservable.add(() => {
232
+ if (this.layer.shouldRender() && this.layer.needStencil()) {
233
+ this._engine.setStencilBuffer(false);
234
+ }
235
+ });
236
+ // Composes the layer with the destination texture
237
+ this.layer.bindTexturesForCompose = undefined;
238
+ this._clearAfterRenderingGroupObserver();
239
+ const pass = this._frameGraph.addRenderPass(this.name);
240
+ pass.setRenderTarget(this.outputTexture);
241
+ if (this._setRenderTargetDepth) {
242
+ pass.setRenderTargetDepth(this.objectRendererTask.depthTexture);
243
+ }
244
+ pass.setExecuteFunc((context) => {
245
+ if (!this.layer.bindTexturesForCompose) {
246
+ this.layer.bindTexturesForCompose = (effect) => {
247
+ for (let i = 0; i < this._blurY.length; i++) {
248
+ context.bindTextureHandle(effect, `textureSampler${i > 0 ? i + 1 : ""}`, this._blurY[i].outputTexture);
249
+ }
250
+ };
251
+ }
252
+ if (this.layer._options.renderingGroupId !== -1) {
253
+ if (!this._onAfterRenderingGroupObserver) {
254
+ this._onAfterRenderingGroupObserver = this._scene.onAfterRenderingGroupObservable.add((info) => {
255
+ if (!this.layer.shouldRender() ||
256
+ info.renderingGroupId !== this.layer._options.renderingGroupId ||
257
+ info.renderingManager !== this.objectRendererTask.objectRenderer._renderingManager) {
258
+ return;
259
+ }
260
+ this._objectRendererForLayer.objectList = this.objectRendererTask.objectList;
261
+ context.saveDepthStates();
262
+ context.setDepthStates(false, false);
263
+ context._applyRenderTarget();
264
+ this.layer.compose();
265
+ context.restoreDepthStates();
266
+ });
267
+ }
268
+ }
269
+ else {
270
+ this._clearAfterRenderingGroupObserver();
271
+ if (this.layer.shouldRender()) {
272
+ this._objectRendererForLayer.objectList = this.objectRendererTask.objectList; // in case the object list has changed in objectRendererTask
273
+ context.setDepthStates(false, false);
274
+ context._applyRenderTarget();
275
+ this.layer.compose();
276
+ }
277
+ }
278
+ });
279
+ const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
280
+ passDisabled.setRenderTarget(this.outputTexture);
281
+ if (this._setRenderTargetDepth) {
282
+ passDisabled.setRenderTargetDepth(this.objectRendererTask.depthTexture);
283
+ }
284
+ passDisabled.setExecuteFunc((_context) => { });
285
+ }
286
+ _clearAfterRenderingGroupObserver() {
287
+ this._scene.onAfterRenderingGroupObservable.remove(this._onAfterRenderingGroupObserver);
288
+ this._onAfterRenderingGroupObserver = null;
289
+ }
290
+ dispose() {
291
+ this._clearAfterRenderingGroupObserver();
292
+ this._clearLayerTextures.dispose();
293
+ this._objectRendererForLayer.dispose();
294
+ this._onBeforeBlurTask?.dispose();
295
+ this._onAfterBlurTask?.dispose();
296
+ this.layer.dispose();
297
+ for (let i = 0; i < this._blurX.length; i++) {
298
+ this._blurX[i].dispose();
299
+ this._blurY[i].dispose();
300
+ }
301
+ super.dispose();
302
+ }
303
+ }
304
+ //# sourceMappingURL=baseLayerTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseLayerTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Layers/baseLayerTask.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,sBAAuB,SAAQ,yBAAyB;IAG1D;;;;;OAKG;IACH,YAAY,IAAY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AAa,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QAC5E,CAAC;QACD,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,EAAE,GAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEO,iCAAiC;QACrC,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACxF,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAC/C,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,iCAAiC,EAAE,CAAC;QACzC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n FrameGraphTextureCreationOptions,\r\n Effect,\r\n ThinBlurPostProcess,\r\n AbstractEngine,\r\n Nullable,\r\n Observer,\r\n RenderingGroupInfo,\r\n ThinEffectLayer,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { FrameGraphObjectRendererTask } from \"../Rendering/objectRendererTask\";\r\nimport { FrameGraphClearTextureTask } from \"../Texture/clearTextureTask\";\r\nimport { FrameGraphBlurTask } from \"../PostProcesses/blurTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTextureManager } from \"../../frameGraphTextureManager\";\r\nimport { getDimensionsFromTextureSize } from \"../../../Materials/Textures/textureCreationOptions\";\r\nimport { FrameGraphPostProcessTask } from \"../PostProcesses/postProcessTask\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { ThinGlowBlurPostProcess } from \"../../../Layers/thinEffectLayer\";\r\nimport { FrameGraphExecuteTask } from \"../Misc/executeTask\";\r\n\r\nclass FrameGraphGlowBlurTask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinGlowBlurPostProcess;\r\n\r\n /**\r\n * Constructs a new glow blur task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param thinPostProcess The thin post process to use for the glow blur effect. If not provided, a new one will be created.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinGlowBlurPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinGlowBlurPostProcess(name, frameGraph.engine, new Vector2(1, 0), 1));\r\n }\r\n\r\n public override record(\r\n skipCreationOfDisabledPasses = false,\r\n additionalExecute?: (context: FrameGraphRenderContext) => void,\r\n additionalBindings?: (context: FrameGraphRenderContext) => void\r\n ): FrameGraphRenderPass {\r\n const pass = super.record(skipCreationOfDisabledPasses, additionalExecute, additionalBindings);\r\n\r\n this.postProcess.textureWidth = this._outputWidth;\r\n this.postProcess.textureHeight = this._outputHeight;\r\n\r\n return pass;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class FrameGraphBaseLayerTask extends FrameGraphTask {\r\n /**\r\n * The destination texture to apply the effect layer to.\r\n * The effect will be blended with the contents of this texture.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer task used to render the objects in the texture to which the layer will be applied.\r\n * This is needed because the layer may have to inject code in the rendering manager used by object renderer task.\r\n */\r\n public objectRendererTask: FrameGraphObjectRendererTask;\r\n\r\n /**\r\n * The layer texture to render the effect into.\r\n * If not provided, a default texture will be created.\r\n */\r\n public layerTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output texture of the task (same as destinationTexture, but the handle will be different).\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The layer object. Use this object to update the layer properties.\r\n */\r\n public readonly layer: ThinEffectLayer;\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._blurX) {\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].name = `${name} Blur X${i}`;\r\n this._blurY[i].name = `${name} Blur Y${i}`;\r\n }\r\n }\r\n\r\n if (this._clearLayerTextures) {\r\n this._clearLayerTextures.name = name + \" Clear Layer\";\r\n }\r\n\r\n if (this._objectRendererForLayer) {\r\n this._objectRendererForLayer.name = name + \" Render to Layer\";\r\n }\r\n }\r\n\r\n protected readonly _scene: Scene;\r\n protected readonly _engine: AbstractEngine;\r\n protected readonly _clearLayerTextures: FrameGraphClearTextureTask;\r\n protected readonly _objectRendererForLayer: FrameGraphObjectRendererTask;\r\n protected readonly _blurX: Array<FrameGraphBlurTask | FrameGraphGlowBlurTask> = [];\r\n protected readonly _blurY: Array<FrameGraphBlurTask | FrameGraphGlowBlurTask> = [];\r\n private readonly _onBeforeBlurTask: Nullable<FrameGraphExecuteTask> = null;\r\n private readonly _onAfterBlurTask: Nullable<FrameGraphExecuteTask> = null;\r\n private _onBeforeObservableObserver: Nullable<Observer<number>> = null;\r\n private _onAfterObservableObserver: Nullable<Observer<number>> = null;\r\n private _onAfterRenderingGroupObserver: Nullable<Observer<RenderingGroupInfo>> = null;\r\n\r\n /**\r\n * Constructs a new layer task.\r\n * @param name Name of the task.\r\n * @param frameGraph The frame graph this task is associated with.\r\n * @param scene The scene to render the layer in.\r\n * @param layer The layer.\r\n * @param numBlurPasses The number of blur passes applied by the layer.\r\n * @param useCustomBlur If true, the layer will use a custom blur post process instead of the default one.\r\n * @param _setRenderTargetDepth If true, the task will set the render target depth.\r\n * @param _notifyBlurObservable If true, the task will notify before and after blurring occurs.\r\n */\r\n constructor(\r\n name: string,\r\n frameGraph: FrameGraph,\r\n scene: Scene,\r\n layer: ThinEffectLayer,\r\n numBlurPasses: number,\r\n useCustomBlur = false,\r\n private _setRenderTargetDepth = false,\r\n private _notifyBlurObservable = false\r\n ) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n this.layer = layer;\r\n for (let i = 0; i < numBlurPasses; i++) {\r\n if (useCustomBlur) {\r\n this._blurX.push(new FrameGraphGlowBlurTask(`${name} Blur X${i}`, this._frameGraph, this.layer._postProcesses[1 + i * 2 + 0] as ThinGlowBlurPostProcess));\r\n this._blurY.push(new FrameGraphGlowBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.layer._postProcesses[1 + i * 2 + 1] as ThinGlowBlurPostProcess));\r\n } else {\r\n this._blurX.push(new FrameGraphBlurTask(`${name} Blur X${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 0] as ThinBlurPostProcess));\r\n this._blurY.push(new FrameGraphBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 1] as ThinBlurPostProcess));\r\n }\r\n }\r\n\r\n this._clearLayerTextures = new FrameGraphClearTextureTask(name + \" Clear Layer\", frameGraph);\r\n this._clearLayerTextures.clearColor = true;\r\n this._clearLayerTextures.clearDepth = true;\r\n\r\n this._objectRendererForLayer = new FrameGraphObjectRendererTask(name + \" Render to Layer\", frameGraph, scene, undefined, this.layer.objectRenderer);\r\n\r\n if (this._notifyBlurObservable) {\r\n this._onBeforeBlurTask = new FrameGraphExecuteTask(name + \" On Before Blur\", frameGraph);\r\n this._onAfterBlurTask = new FrameGraphExecuteTask(name + \" On After Blur\", frameGraph);\r\n\r\n this._onBeforeBlurTask.func = () => {\r\n if (this.layer.onBeforeBlurObservable.hasObservers()) {\r\n this.layer.onBeforeBlurObservable.notifyObservers(this.layer);\r\n }\r\n };\r\n this._onAfterBlurTask.func = () => {\r\n if (this.layer.onAfterBlurObservable.hasObservers()) {\r\n this.layer.onAfterBlurObservable.notifyObservers(this.layer);\r\n }\r\n };\r\n }\r\n\r\n this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();\r\n\r\n this.onTexturesAllocatedObservable.add((context) => {\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n this._blurY[i].onTexturesAllocatedObservable.notifyObservers(context);\r\n }\r\n\r\n context.setTextureSamplingMode(this._blurY[this._blurY.length - 1].destinationTexture!, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n });\r\n }\r\n\r\n public override isReady() {\r\n return this._objectRendererForLayer.isReady() && this.layer.isLayerReady();\r\n }\r\n\r\n public record() {\r\n if (this.destinationTexture === undefined || this.objectRendererTask === undefined) {\r\n throw new Error(`${this.constructor.name} \"${this.name}\": destinationTexture and objectRendererTask are required`);\r\n }\r\n\r\n this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n\r\n // Uses the layerTexture or creates a color texture to render the layer to\r\n let textureSize: {\r\n width: number;\r\n height: number;\r\n };\r\n let textureCreationOptions: FrameGraphTextureCreationOptions;\r\n\r\n let colorLayerOutput: FrameGraphTextureHandle;\r\n\r\n if (this.layerTexture) {\r\n colorLayerOutput = this.layerTexture;\r\n textureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.layerTexture);\r\n textureSize = getDimensionsFromTextureSize(textureCreationOptions.size);\r\n textureCreationOptions.size = textureSize;\r\n } else {\r\n const destinationTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.destinationTexture);\r\n const fixedTextureSize = this.layer._options.mainTextureFixedSize ? Math.max(2, this.layer._options.mainTextureFixedSize) : 0;\r\n\r\n textureSize = getDimensionsFromTextureSize(destinationTextureCreationOptions.size);\r\n textureSize.width = fixedTextureSize || Math.floor(textureSize.width * (this.layer._options.mainTextureRatio || 0.1));\r\n textureSize.height = fixedTextureSize || Math.floor(textureSize.height * (this.layer._options.mainTextureRatio || 0.1));\r\n\r\n textureCreationOptions = {\r\n size: textureSize,\r\n options: {\r\n createMipMaps: false,\r\n types: [this.layer._options.mainTextureType],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n },\r\n sizeIsPercentage: this.layer._options.mainTextureFixedSize ? false : destinationTextureCreationOptions.sizeIsPercentage,\r\n };\r\n colorLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Color`, textureCreationOptions);\r\n }\r\n\r\n // Creates a depth texture, used to render objects to the layer\r\n // We don't reuse the depth texture of the objectRendererTask, as the size of the layer texture will generally be different (smaller).\r\n const textureDepthCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: textureSize,\r\n options: FrameGraphTextureManager.CloneTextureOptions(textureCreationOptions.options),\r\n sizeIsPercentage: textureCreationOptions.sizeIsPercentage,\r\n };\r\n\r\n textureDepthCreationOptions.options.formats![0] = Constants.TEXTUREFORMAT_DEPTH32_FLOAT;\r\n\r\n const depthLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Depth`, textureDepthCreationOptions);\r\n\r\n this._addInternalDependencies([colorLayerOutput, depthLayerOutput]);\r\n\r\n // Clears the textures\r\n this._clearLayerTextures.destinationTexture = colorLayerOutput;\r\n this._clearLayerTextures.depthTexture = depthLayerOutput;\r\n this._clearLayerTextures.color = this.layer.neutralColor;\r\n this._clearLayerTextures.clearDepth = true;\r\n\r\n const clearTaskPass = this._clearLayerTextures.record();\r\n\r\n // Renders the objects to the layer texture\r\n this._objectRendererForLayer.destinationTexture = this._clearLayerTextures.outputTexture;\r\n this._objectRendererForLayer.depthTexture = this._clearLayerTextures.outputDepthTexture;\r\n this._objectRendererForLayer.camera = this.objectRendererTask.camera;\r\n this._objectRendererForLayer.objectList = this.objectRendererTask.objectList;\r\n this._objectRendererForLayer.disableShadows = true;\r\n\r\n const objectRendererForLayerTaskPass = this._objectRendererForLayer.record();\r\n\r\n // Blurs the layer color texture\r\n let blurTextureType = 0;\r\n if (this._engine.getCaps().textureHalfFloatRender) {\r\n blurTextureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n } else {\r\n blurTextureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n textureCreationOptions.options.types![0] = blurTextureType;\r\n\r\n const blurTextureSizeRatio = (this.layer._options as any).blurTextureSizeRatio !== undefined ? (this.layer._options as any).blurTextureSizeRatio || 0.1 : undefined;\r\n if (blurTextureSizeRatio !== undefined) {\r\n textureSize.width = Math.floor(textureSize.width * blurTextureSizeRatio);\r\n textureSize.height = Math.floor(textureSize.height * blurTextureSizeRatio);\r\n }\r\n\r\n const onBeforeBlurPass = this._onBeforeBlurTask?.record();\r\n\r\n const blurPasses: FrameGraphRenderPass[] = [];\r\n\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[i].name, textureCreationOptions);\r\n\r\n this._blurX[i].sourceTexture = i === 0 ? this._objectRendererForLayer.outputTexture : this._blurY[i - 1].outputTexture;\r\n this._blurX[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurX[i].destinationTexture = blurXTextureHandle;\r\n blurPasses.push(this._blurX[i].record(true));\r\n\r\n const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[i].name, textureCreationOptions);\r\n\r\n this._blurY[i].sourceTexture = this._blurX[i].outputTexture;\r\n this._blurY[i].sourceSamplingMode = Constants.TEXTURE_BILINEAR_SAMPLINGMODE;\r\n this._blurY[i].destinationTexture = blurYTextureHandle;\r\n blurPasses.push(this._blurY[i].record(true));\r\n\r\n this._addInternalDependencies([blurXTextureHandle, blurYTextureHandle]);\r\n\r\n textureSize.width = textureSize.width >> 1;\r\n textureSize.height = textureSize.height >> 1;\r\n }\r\n\r\n const onAfterBlurPass = this._onAfterBlurTask?.record();\r\n\r\n // Enables stencil (if stencil is needed) when rendering objects to the main texture\r\n // We also disable the internal passes if the layer should not render\r\n this.objectRendererTask.objectRenderer.onBeforeRenderObservable.remove(this._onBeforeObservableObserver);\r\n this._onBeforeObservableObserver = this.objectRendererTask.objectRenderer.onBeforeRenderObservable.add(() => {\r\n const shouldRender = this.layer.shouldRender();\r\n\r\n clearTaskPass.disabled = !shouldRender;\r\n objectRendererForLayerTaskPass.disabled = !shouldRender;\r\n if (onBeforeBlurPass) {\r\n onBeforeBlurPass.disabled = !shouldRender;\r\n }\r\n for (let i = 0; i < blurPasses.length; i++) {\r\n blurPasses[i].disabled = !shouldRender;\r\n }\r\n if (onAfterBlurPass) {\r\n onAfterBlurPass.disabled = !shouldRender;\r\n }\r\n\r\n if (shouldRender && this.layer.needStencil()) {\r\n this._engine.setStencilBuffer(true);\r\n this._engine.setStencilFunctionReference(1);\r\n }\r\n });\r\n\r\n this.objectRendererTask.objectRenderer.onAfterRenderObservable.remove(this._onAfterObservableObserver);\r\n this._onAfterObservableObserver = this.objectRendererTask.objectRenderer.onAfterRenderObservable.add(() => {\r\n if (this.layer.shouldRender() && this.layer.needStencil()) {\r\n this._engine.setStencilBuffer(false);\r\n }\r\n });\r\n\r\n // Composes the layer with the destination texture\r\n this.layer.bindTexturesForCompose = undefined as any;\r\n\r\n this._clearAfterRenderingGroupObserver();\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.outputTexture);\r\n if (this._setRenderTargetDepth) {\r\n pass.setRenderTargetDepth(this.objectRendererTask.depthTexture);\r\n }\r\n pass.setExecuteFunc((context) => {\r\n if (!this.layer.bindTexturesForCompose) {\r\n this.layer.bindTexturesForCompose = (effect: Effect) => {\r\n for (let i = 0; i < this._blurY.length; i++) {\r\n context.bindTextureHandle(effect, `textureSampler${i > 0 ? i + 1 : \"\"}`, this._blurY[i].outputTexture);\r\n }\r\n };\r\n }\r\n\r\n if (this.layer._options.renderingGroupId !== -1) {\r\n if (!this._onAfterRenderingGroupObserver) {\r\n this._onAfterRenderingGroupObserver = this._scene.onAfterRenderingGroupObservable.add((info) => {\r\n if (\r\n !this.layer.shouldRender() ||\r\n info.renderingGroupId !== this.layer._options.renderingGroupId ||\r\n info.renderingManager !== this.objectRendererTask.objectRenderer._renderingManager\r\n ) {\r\n return;\r\n }\r\n this._objectRendererForLayer.objectList = this.objectRendererTask.objectList;\r\n context.saveDepthStates();\r\n context.setDepthStates(false, false);\r\n context._applyRenderTarget();\r\n this.layer.compose();\r\n context.restoreDepthStates();\r\n });\r\n }\r\n } else {\r\n this._clearAfterRenderingGroupObserver();\r\n if (this.layer.shouldRender()) {\r\n this._objectRendererForLayer.objectList = this.objectRendererTask.objectList; // in case the object list has changed in objectRendererTask\r\n\r\n context.setDepthStates(false, false);\r\n context._applyRenderTarget();\r\n\r\n this.layer.compose();\r\n }\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n if (this._setRenderTargetDepth) {\r\n passDisabled.setRenderTargetDepth(this.objectRendererTask.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((_context) => {});\r\n }\r\n\r\n private _clearAfterRenderingGroupObserver() {\r\n this._scene.onAfterRenderingGroupObservable.remove(this._onAfterRenderingGroupObserver);\r\n this._onAfterRenderingGroupObserver = null;\r\n }\r\n\r\n public override dispose(): void {\r\n this._clearAfterRenderingGroupObserver();\r\n this._clearLayerTextures.dispose();\r\n this._objectRendererForLayer.dispose();\r\n this._onBeforeBlurTask?.dispose();\r\n this._onAfterBlurTask?.dispose();\r\n this.layer.dispose();\r\n for (let i = 0; i < this._blurX.length; i++) {\r\n this._blurX[i].dispose();\r\n this._blurY[i].dispose();\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -1,48 +1,14 @@
1
- import type { FrameGraph, FrameGraphTextureHandle, Scene, IThinGlowLayerOptions, Camera, FrameGraphObjectList } from "../../../index.js";
2
- import { FrameGraphTask } from "../../frameGraphTask";
1
+ import type { FrameGraph, Scene, IThinGlowLayerOptions } from "../../../index.js";
3
2
  import { ThinGlowLayer } from "../../../Layers/thinGlowLayer.js";
3
+ import { FrameGraphBaseLayerTask } from "./baseLayerTask";
4
4
  /**
5
5
  * Task which applies a glowing effect to a texture.
6
6
  */
7
- export declare class FrameGraphGlowLayerTask extends FrameGraphTask {
8
- /**
9
- * The destination texture to apply the glow layer to.
10
- * The glow effect will be blended with the contents of this texture.
11
- */
12
- destinationTexture: FrameGraphTextureHandle;
13
- /**
14
- * The layer texture to render the glow layer to.
15
- * If not provided, a default texture will be created.
16
- */
17
- layerTexture?: FrameGraphTextureHandle;
18
- private _camera;
19
- /**
20
- * Gets or sets the camera used to render the objects to the glow layer.
21
- */
22
- get camera(): Camera;
23
- set camera(camera: Camera);
24
- /**
25
- * The list of objects to render to the glow layer.
26
- */
27
- objectList: FrameGraphObjectList;
28
- /**
29
- * The output texture of the task (same as destinationTexture, but the handle will be different).
30
- */
31
- readonly outputTexture: FrameGraphTextureHandle;
7
+ export declare class FrameGraphGlowLayerTask extends FrameGraphBaseLayerTask {
32
8
  /**
33
9
  * The glow layer object. Use this object to update the glow layer properties (e.g. intensity, blur kernel size).
34
10
  */
35
11
  readonly layer: ThinGlowLayer;
36
- /**
37
- * The name of the task.
38
- */
39
- get name(): string;
40
- set name(name: string);
41
- private readonly _engine;
42
- private readonly _clearTask;
43
- private readonly _objectRendererTask;
44
- private readonly _blurX;
45
- private readonly _blurY;
46
12
  /**
47
13
  * Constructs a new glow layer task.
48
14
  * @param name Name of the task.
@@ -51,7 +17,4 @@ export declare class FrameGraphGlowLayerTask extends FrameGraphTask {
51
17
  * @param options Options for the glow layer.
52
18
  */
53
19
  constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: IThinGlowLayerOptions);
54
- isReady(): boolean;
55
- record(): void;
56
- dispose(): void;
57
20
  }
@@ -1,46 +1,9 @@
1
- import { FrameGraphTask } from "../../frameGraphTask.js";
2
1
  import { ThinGlowLayer } from "../../../Layers/thinGlowLayer.js";
3
- import { FrameGraphObjectRendererTask } from "../Rendering/objectRendererTask.js";
4
- import { FrameGraphClearTextureTask } from "../Texture/clearTextureTask.js";
5
- import { FrameGraphBlurTask } from "../PostProcesses/blurTask.js";
6
-
7
- import { FrameGraphTextureManager } from "../../frameGraphTextureManager.js";
8
- import { getDimensionsFromTextureSize } from "../../../Materials/Textures/textureCreationOptions.js";
2
+ import { FrameGraphBaseLayerTask } from "./baseLayerTask.js";
9
3
  /**
10
4
  * Task which applies a glowing effect to a texture.
11
5
  */
12
- export class FrameGraphGlowLayerTask extends FrameGraphTask {
13
- /**
14
- * Gets or sets the camera used to render the objects to the glow layer.
15
- */
16
- get camera() {
17
- return this._camera;
18
- }
19
- set camera(camera) {
20
- this._camera = camera;
21
- this.layer.camera = this.camera;
22
- }
23
- /**
24
- * The name of the task.
25
- */
26
- get name() {
27
- return this._name;
28
- }
29
- set name(name) {
30
- this._name = name;
31
- if (this._blurX) {
32
- for (let i = 0; i < this._blurX.length; i++) {
33
- this._blurX[i].name = `${name} Blur X${i}`;
34
- this._blurY[i].name = `${name} Blur Y${i}`;
35
- }
36
- }
37
- if (this._clearTask) {
38
- this._clearTask.name = name + " Clear Layer";
39
- }
40
- if (this._objectRendererTask) {
41
- this._objectRendererTask.name = name + " Render to Layer";
42
- }
43
- }
6
+ export class FrameGraphGlowLayerTask extends FrameGraphBaseLayerTask {
44
7
  /**
45
8
  * Constructs a new glow layer task.
46
9
  * @param name Name of the task.
@@ -49,125 +12,8 @@ export class FrameGraphGlowLayerTask extends FrameGraphTask {
49
12
  * @param options Options for the glow layer.
50
13
  */
51
14
  constructor(name, frameGraph, scene, options) {
52
- super(name, frameGraph);
53
- this._blurX = [];
54
- this._blurY = [];
55
- this._engine = scene.getEngine();
56
- this.layer = new ThinGlowLayer(name, scene, options, true);
57
- for (let i = 0; i < 2; i++) {
58
- this._blurX.push(new FrameGraphBlurTask(`${name} Blur X${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 0]));
59
- this._blurY.push(new FrameGraphBlurTask(`${name} Blur Y${i}`, this._frameGraph, this.layer._postProcesses[i * 2 + 1]));
60
- }
61
- this._clearTask = new FrameGraphClearTextureTask(name + " Clear Layer", frameGraph);
62
- this._clearTask.clearColor = true;
63
- this._clearTask.clearDepth = true;
64
- this._objectRendererTask = new FrameGraphObjectRendererTask(name + " Render to Layer", frameGraph, scene, undefined, this.layer.objectRenderer);
65
- this.layer._renderPassId = this._objectRendererTask.objectRenderer.renderPassId;
66
- this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
67
- }
68
- isReady() {
69
- return this._objectRendererTask.isReady() && this.layer.isLayerReady();
70
- }
71
- record() {
72
- if (this.destinationTexture === undefined || this.objectList === undefined || this.camera === undefined) {
73
- throw new Error(`FrameGrapGlowLayerTask "${this.name}": destinationTexture, objectList and camera are required`);
74
- }
75
- this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.destinationTexture);
76
- // Uses the layerTexture or creates a color texture to render the glow layer to
77
- let textureSize;
78
- let textureCreationOptions;
79
- let colorLayerOutput;
80
- if (this.layerTexture) {
81
- colorLayerOutput = this.layerTexture;
82
- textureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.layerTexture);
83
- textureSize = getDimensionsFromTextureSize(textureCreationOptions.size);
84
- textureCreationOptions.size = textureSize;
85
- }
86
- else {
87
- textureSize = { width: 50, height: 50 };
88
- textureCreationOptions = {
89
- size: textureSize,
90
- options: {
91
- createMipMaps: false,
92
- types: [0],
93
- formats: [5],
94
- samples: 1,
95
- useSRGBBuffers: [false],
96
- creationFlags: [0],
97
- },
98
- sizeIsPercentage: true,
99
- };
100
- colorLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Color`, textureCreationOptions);
101
- }
102
- // Creates a depth texture, used to render objects to the glow layer
103
- const textureDepthCreationOptions = {
104
- size: textureSize,
105
- options: FrameGraphTextureManager.CloneTextureOptions(textureCreationOptions.options),
106
- sizeIsPercentage: textureCreationOptions.sizeIsPercentage,
107
- };
108
- textureDepthCreationOptions.options.formats[0] = 14;
109
- const depthLayerOutput = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} Depth`, textureDepthCreationOptions);
110
- // Clears the textures
111
- this._clearTask.destinationTexture = colorLayerOutput;
112
- this._clearTask.depthTexture = depthLayerOutput;
113
- this._clearTask.color = this.layer.neutralColor;
114
- this._clearTask.record();
115
- // Renders the objects to the layer texture
116
- this._objectRendererTask.destinationTexture = this._clearTask.outputTexture;
117
- this._objectRendererTask.depthTexture = this._clearTask.outputDepthTexture;
118
- this._objectRendererTask.camera = this.camera;
119
- this._objectRendererTask.objectList = this.objectList;
120
- this._objectRendererTask.disableShadows = true;
121
- this._objectRendererTask.record();
122
- // Blurs the layer color texture
123
- let blurTextureType = 0;
124
- if (this._engine.getCaps().textureHalfFloatRender) {
125
- blurTextureType = 2;
126
- }
127
- else {
128
- blurTextureType = 0;
129
- }
130
- textureCreationOptions.options.types[0] = blurTextureType;
131
- for (let i = 0; i < this._blurX.length; i++) {
132
- const blurXTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurX[i].name, textureCreationOptions);
133
- this._blurX[i].sourceTexture = i === 0 ? this._objectRendererTask.outputTexture : this._blurY[i - 1].outputTexture;
134
- this._blurX[i].sourceSamplingMode = 2;
135
- this._blurX[i].destinationTexture = blurXTextureHandle;
136
- this._blurX[i].record(true);
137
- const blurYTextureHandle = this._frameGraph.textureManager.createRenderTargetTexture(this._blurY[i].name, textureCreationOptions);
138
- this._blurY[i].sourceTexture = this._blurX[i].outputTexture;
139
- this._blurY[i].sourceSamplingMode = 2;
140
- this._blurY[i].destinationTexture = blurYTextureHandle;
141
- this._blurY[i].record(true);
142
- textureSize.width = textureSize.width >> 1;
143
- textureSize.height = textureSize.height >> 1;
144
- }
145
- this._internalDependencies.push(this._blurY[0].outputTexture, this._blurY[1].outputTexture);
146
- // Composes the glow layer with the destination texture
147
- const pass = this._frameGraph.addRenderPass(this.name);
148
- pass.setRenderTarget(this.outputTexture);
149
- pass.setExecuteFunc((context) => {
150
- this.layer.bindTexturesForCompose = (effect) => {
151
- context.bindTextureHandle(effect, "textureSampler", this._blurY[0].outputTexture);
152
- context.setTextureSamplingMode(this._blurY[1].destinationTexture, 2);
153
- context.bindTextureHandle(effect, "textureSampler2", this._blurY[1].outputTexture);
154
- };
155
- context._applyRenderTarget();
156
- this.layer.compose();
157
- });
158
- const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
159
- passDisabled.setRenderTarget(this.outputTexture);
160
- passDisabled.setExecuteFunc((_context) => { });
161
- }
162
- dispose() {
163
- this._clearTask.dispose();
164
- this._objectRendererTask.dispose();
165
- this.layer.dispose();
166
- for (let i = 0; i < this._blurX.length; i++) {
167
- this._blurX[i].dispose();
168
- this._blurY[i].dispose();
169
- }
170
- super.dispose();
15
+ super(name, frameGraph, scene, new ThinGlowLayer(name, scene, options, true), 2);
16
+ this.layer._renderPassId = this._objectRendererForLayer.objectRenderer.renderPassId;
171
17
  }
172
18
  }
173
19
  //# sourceMappingURL=glowLayerTask.js.map