@onerjs/core 8.30.5 → 8.30.7

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 (219) 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/AudioV2/abstractAudio/abstractSound.js +1 -0
  9. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  10. package/AudioV2/abstractAudio/audioEngineV2.d.ts +2 -0
  11. package/AudioV2/abstractAudio/audioEngineV2.js +18 -8
  12. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  13. package/AudioV2/webAudio/webAudioStaticSound.js +8 -3
  14. package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
  15. package/Collisions/gpuPicker.js +0 -1
  16. package/Collisions/gpuPicker.js.map +1 -1
  17. package/Debug/debugLayer.d.ts +1 -1
  18. package/Debug/debugLayer.js.map +1 -1
  19. package/Decorators/nodeDecorator.d.ts +3 -1
  20. package/Decorators/nodeDecorator.js +2 -0
  21. package/Decorators/nodeDecorator.js.map +1 -1
  22. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  23. package/Engines/Native/nativeInterfaces.js.map +1 -1
  24. package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
  25. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  26. package/Engines/abstractEngine.js +2 -2
  27. package/Engines/abstractEngine.js.map +1 -1
  28. package/Engines/nativeEngine.js +12 -13
  29. package/Engines/nativeEngine.js.map +1 -1
  30. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.d.ts +2 -2
  31. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js +2 -2
  32. package/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.js.map +1 -1
  33. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
  34. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
  35. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  36. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +44 -0
  37. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +152 -0
  38. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -0
  39. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.d.ts +2 -2
  40. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js +2 -2
  41. package/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.js.map +1 -1
  42. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.d.ts +2 -2
  43. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js +2 -2
  44. package/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.js.map +1 -1
  45. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.d.ts +2 -2
  46. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js +2 -2
  47. package/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.js.map +1 -1
  48. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.d.ts +2 -2
  49. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +2 -2
  50. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js.map +1 -1
  51. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.d.ts +2 -2
  52. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +2 -2
  53. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js.map +1 -1
  54. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.d.ts +2 -2
  55. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js +2 -2
  56. package/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.js.map +1 -1
  57. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.d.ts +2 -2
  58. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js +2 -2
  59. package/FrameGraph/Node/Blocks/PostProcesses/extractHighlightsPostProcessBlock.js.map +1 -1
  60. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.d.ts +2 -2
  61. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +2 -2
  62. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js.map +1 -1
  63. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.d.ts +2 -2
  64. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js +2 -2
  65. package/FrameGraph/Node/Blocks/PostProcesses/fxaaPostProcessBlock.js.map +1 -1
  66. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.d.ts +2 -2
  67. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js +2 -2
  68. package/FrameGraph/Node/Blocks/PostProcesses/grainPostProcessBlock.js.map +1 -1
  69. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.d.ts +2 -2
  70. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
  71. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js.map +1 -1
  72. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.d.ts +2 -2
  73. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js +2 -2
  74. package/FrameGraph/Node/Blocks/PostProcesses/motionBlurPostProcessBlock.js.map +1 -1
  75. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.d.ts +3 -3
  76. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js +3 -3
  77. package/FrameGraph/Node/Blocks/PostProcesses/passPostProcessBlock.js.map +1 -1
  78. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.d.ts +2 -2
  79. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js +2 -2
  80. package/FrameGraph/Node/Blocks/PostProcesses/screenSpaceCurvaturePostProcessBlock.js.map +1 -1
  81. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.d.ts +2 -2
  82. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js +4 -4
  83. package/FrameGraph/Node/Blocks/PostProcesses/sharpenPostProcessBlock.js.map +1 -1
  84. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.d.ts +2 -2
  85. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js +2 -2
  86. package/FrameGraph/Node/Blocks/PostProcesses/taaPostProcessBlock.js.map +1 -1
  87. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.d.ts +2 -2
  88. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js +2 -2
  89. package/FrameGraph/Node/Blocks/PostProcesses/tonemapPostProcessBlock.js.map +1 -1
  90. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
  91. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
  92. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
  93. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
  94. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +20 -1
  95. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +83 -0
  96. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  97. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  98. package/FrameGraph/Node/Blocks/index.js +1 -0
  99. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  100. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +7 -1
  101. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +8 -2
  102. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  103. package/FrameGraph/Tasks/PostProcesses/taaTask.d.ts +1 -1
  104. package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
  105. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
  106. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
  107. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
  108. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -4
  109. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -3
  110. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  111. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
  112. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
  113. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
  114. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
  115. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
  116. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
  117. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +11 -1
  118. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +10 -1
  119. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  120. package/FrameGraph/frameGraphContext.d.ts +8 -1
  121. package/FrameGraph/frameGraphContext.js +9 -0
  122. package/FrameGraph/frameGraphContext.js.map +1 -1
  123. package/FrameGraph/frameGraphRenderContext.d.ts +5 -2
  124. package/FrameGraph/frameGraphRenderContext.js +32 -7
  125. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  126. package/FrameGraph/frameGraphTask.d.ts +8 -0
  127. package/FrameGraph/frameGraphTask.js +12 -0
  128. package/FrameGraph/frameGraphTask.js.map +1 -1
  129. package/Materials/PBR/openpbrMaterial.js +2 -1
  130. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  131. package/Materials/Textures/mirrorTexture.js +4 -1
  132. package/Materials/Textures/mirrorTexture.js.map +1 -1
  133. package/Materials/clipPlaneMaterialHelper.js +11 -1
  134. package/Materials/clipPlaneMaterialHelper.js.map +1 -1
  135. package/Materials/floatingOriginMatrixOverrides.d.ts +4 -1
  136. package/Materials/floatingOriginMatrixOverrides.js +14 -2
  137. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  138. package/Materials/index.d.ts +1 -0
  139. package/Materials/index.js +1 -0
  140. package/Materials/index.js.map +1 -1
  141. package/Materials/shaderMaterial.js +1 -1
  142. package/Materials/shaderMaterial.js.map +1 -1
  143. package/Maths/math.vector.functions.d.ts +31 -5
  144. package/Maths/math.vector.functions.js +41 -4
  145. package/Maths/math.vector.functions.js.map +1 -1
  146. package/Meshes/Node/Blocks/randomBlock.js +11 -11
  147. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  148. package/Misc/copyTextureToTexture.d.ts +18 -1
  149. package/Misc/copyTextureToTexture.js +31 -2
  150. package/Misc/copyTextureToTexture.js.map +1 -1
  151. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +7 -7
  152. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  153. package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
  154. package/Particles/Node/Blocks/Emitters/createParticleBlock.js +18 -2
  155. package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
  156. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +7 -7
  157. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  158. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +8 -8
  159. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  160. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +9 -9
  161. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  162. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +6 -6
  163. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  164. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +7 -7
  165. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  166. package/Particles/Node/Blocks/particleRandomBlock.js +10 -10
  167. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  168. package/Particles/Node/Blocks/systemBlock.d.ts +33 -1
  169. package/Particles/Node/Blocks/systemBlock.js +83 -3
  170. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  171. package/Particles/Node/nodeParticleBuildState.d.ts +2 -7
  172. package/Particles/Node/nodeParticleBuildState.js +7 -22
  173. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  174. package/Particles/Node/nodeParticleSystemSet.helper.js +224 -58
  175. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  176. package/Particles/Node/nodeParticleSystemSet.js +1 -1
  177. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  178. package/Particles/thinParticleSystem.js +1 -0
  179. package/Particles/thinParticleSystem.js.map +1 -1
  180. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -1
  181. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  182. package/Physics/v2/Plugins/havokPlugin.d.ts +27 -4
  183. package/Physics/v2/Plugins/havokPlugin.js +72 -8
  184. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  185. package/Physics/v2/physicsEngine.d.ts +12 -2
  186. package/Physics/v2/physicsEngine.js +15 -1
  187. package/Physics/v2/physicsEngine.js.map +1 -1
  188. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
  189. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  190. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -0
  191. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  192. package/Shaders/copyTextureToTexture.fragment.js +2 -2
  193. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  194. package/Shaders/picking.fragment.js +1 -1
  195. package/Shaders/picking.fragment.js.map +1 -1
  196. package/Shaders/picking.vertex.js +1 -1
  197. package/Shaders/picking.vertex.js.map +1 -1
  198. package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
  199. package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
  200. package/ShadersWGSL/iblVoxelGrid.vertex.js +1 -1
  201. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  202. package/ShadersWGSL/picking.fragment.js +1 -1
  203. package/ShadersWGSL/picking.fragment.js.map +1 -1
  204. package/ShadersWGSL/picking.vertex.js +1 -1
  205. package/ShadersWGSL/picking.vertex.js.map +1 -1
  206. package/Sprites/spriteRenderer.js +10 -8
  207. package/Sprites/spriteRenderer.js.map +1 -1
  208. package/XR/features/WebXRLightEstimation.d.ts +8 -0
  209. package/XR/features/WebXRLightEstimation.js +6 -1
  210. package/XR/features/WebXRLightEstimation.js.map +1 -1
  211. package/XR/webXRSessionManager.js +4 -0
  212. package/XR/webXRSessionManager.js.map +1 -1
  213. package/assetContainer.d.ts +1 -1
  214. package/assetContainer.js +1 -1
  215. package/assetContainer.js.map +1 -1
  216. package/package.json +1 -1
  217. package/scene.d.ts +5 -2
  218. package/scene.js +9 -14
  219. package/scene.js.map +1 -1
@@ -1,7 +1,9 @@
1
+ import { __decorate } from "../../../../tslib.es6.js";
1
2
  import { NodeRenderGraphBlock } from "../../nodeRenderGraphBlock.js";
2
3
  import { RegisterClass } from "../../../../Misc/typeStore.js";
3
4
  import { NodeRenderGraphBlockConnectionPointTypes } from "../../Types/nodeRenderGraphTypes.js";
4
5
  import { FrameGraphCopyToTextureTask } from "../../../Tasks/Texture/copyToTextureTask.js";
6
+ import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
5
7
  /**
6
8
  * Block used to copy a texture
7
9
  */
@@ -20,6 +22,9 @@ export class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {
20
22
  */
21
23
  constructor(name, frameGraph, scene) {
22
24
  super(name, frameGraph, scene);
25
+ this._useCurrentViewport = false;
26
+ this._useFullScreenViewport = true;
27
+ this._viewport = { x: 0, y: 0, width: 1, height: 1 };
23
28
  this.registerInput("source", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);
24
29
  this.registerInput("target", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);
25
30
  this._addDependenciesInput();
@@ -29,6 +34,48 @@ export class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {
29
34
  this.output._typeConnectionSource = this.source;
30
35
  this._frameGraphTask = new FrameGraphCopyToTextureTask(name, frameGraph);
31
36
  }
37
+ _setViewport() {
38
+ if (this._useCurrentViewport) {
39
+ this._frameGraphTask.viewport = null;
40
+ }
41
+ else if (this._useFullScreenViewport) {
42
+ this._frameGraphTask.viewport = undefined;
43
+ }
44
+ else {
45
+ this._frameGraphTask.viewport = this._viewport;
46
+ }
47
+ }
48
+ /** If true, the current viewport will be left unchanged. */
49
+ get useCurrentViewport() {
50
+ return this._useCurrentViewport;
51
+ }
52
+ set useCurrentViewport(value) {
53
+ this._useCurrentViewport = value;
54
+ this._setViewport();
55
+ }
56
+ /** If true, a full screen viewport will be used. */
57
+ get useFullScreenViewport() {
58
+ return this._useFullScreenViewport;
59
+ }
60
+ set useFullScreenViewport(value) {
61
+ this._useFullScreenViewport = value;
62
+ this._setViewport();
63
+ }
64
+ /** The viewport to use. */
65
+ get viewport() {
66
+ return this._viewport;
67
+ }
68
+ set viewport(value) {
69
+ this._viewport = value;
70
+ this._setViewport();
71
+ }
72
+ /** The LOD level to copy from the source texture (default: 0). */
73
+ get lodLevel() {
74
+ return this._frameGraphTask.lodLevel;
75
+ }
76
+ set lodLevel(value) {
77
+ this._frameGraphTask.lodLevel = value;
78
+ }
32
79
  /**
33
80
  * Gets the current class name
34
81
  * @returns the class name
@@ -60,6 +107,42 @@ export class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {
60
107
  this._frameGraphTask.sourceTexture = this.source.connectedPoint?.value;
61
108
  this._frameGraphTask.targetTexture = this.target.connectedPoint?.value;
62
109
  }
110
+ _dumpPropertiesCode() {
111
+ const codes = [];
112
+ codes.push(`${this._codeVariableName}.viewport = ${this._useCurrentViewport ? "null" : this._useFullScreenViewport ? "undefined" : JSON.stringify(this._viewport)};`);
113
+ codes.push(`${this._codeVariableName}.lodLevel = ${this.lodLevel};`);
114
+ return super._dumpPropertiesCode() + codes.join("\n");
115
+ }
116
+ serialize() {
117
+ const serializationObject = super.serialize();
118
+ serializationObject.useCurrentViewport = this._useCurrentViewport;
119
+ serializationObject.useFullScreenViewport = this._useFullScreenViewport;
120
+ serializationObject.viewport = this._viewport;
121
+ serializationObject.lodLevel = this.lodLevel;
122
+ return serializationObject;
123
+ }
124
+ _deserialize(serializationObject) {
125
+ super._deserialize(serializationObject);
126
+ if (serializationObject.useCurrentViewport !== undefined) {
127
+ this._useCurrentViewport = serializationObject.useCurrentViewport;
128
+ this._useFullScreenViewport = serializationObject.useFullScreenViewport;
129
+ this._viewport = serializationObject.viewport;
130
+ }
131
+ this.lodLevel = serializationObject.lodLevel ?? 0;
132
+ this._setViewport();
133
+ }
63
134
  }
135
+ __decorate([
136
+ editableInPropertyPage("Use currently active viewport", 0 /* PropertyTypeForEdition.Boolean */, "PROPERTIES")
137
+ ], NodeRenderGraphCopyTextureBlock.prototype, "useCurrentViewport", null);
138
+ __decorate([
139
+ editableInPropertyPage("Use full screen viewport", 0 /* PropertyTypeForEdition.Boolean */, "PROPERTIES")
140
+ ], NodeRenderGraphCopyTextureBlock.prototype, "useFullScreenViewport", null);
141
+ __decorate([
142
+ editableInPropertyPage("Viewport", 12 /* PropertyTypeForEdition.Viewport */, "PROPERTIES")
143
+ ], NodeRenderGraphCopyTextureBlock.prototype, "viewport", null);
144
+ __decorate([
145
+ editableInPropertyPage("LOD Level", 2 /* PropertyTypeForEdition.Int */, "PROPERTIES", { min: 0, max: 16 })
146
+ ], NodeRenderGraphCopyTextureBlock.prototype, "lodLevel", null);
64
147
  RegisterClass("BABYLON.NodeRenderGraphCopyTextureBlock", NodeRenderGraphCopyTextureBlock);
65
148
  //# sourceMappingURL=copyTextureBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FrameGraph/Node/Blocks/Textures/copyTextureBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,oBAAoB;IAGrE;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,YAAmB,IAAY,EAAE,UAAsB,EAAE,KAAY;QACjE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAE/B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAAU,CAAC,CAAC;QAClF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,wCAAwC,CAAC,UAA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":["import type { NodeRenderGraphConnectionPoint, Scene, FrameGraphTextureHandle, FrameGraph, NodeRenderGraphBuildState } from \"core/index\";\r\nimport { NodeRenderGraphBlock } from \"../../nodeRenderGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeRenderGraphBlockConnectionPointTypes } from \"../../Types/nodeRenderGraphTypes\";\r\nimport { FrameGraphCopyToTextureTask } from \"../../../Tasks/Texture/copyToTextureTask\";\r\n\r\n/**\r\n * Block used to copy a texture\r\n */\r\nexport class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {\r\n protected override _frameGraphTask: FrameGraphCopyToTextureTask;\r\n\r\n /**\r\n * Gets the frame graph task associated with this block\r\n */\r\n public override get task() {\r\n return this._frameGraphTask;\r\n }\r\n\r\n /**\r\n * Create a new NodeRenderGraphCopyTextureBlock\r\n * @param name defines the block name\r\n * @param frameGraph defines the hosting frame graph\r\n * @param scene defines the hosting scene\r\n */\r\n public constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this.registerInput(\"source\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"target\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this._addDependenciesInput();\r\n this.registerOutput(\"output\", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.source.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAllButBackBuffer);\r\n this.target.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);\r\n this.output._typeConnectionSource = this.source;\r\n\r\n this._frameGraphTask = new FrameGraphCopyToTextureTask(name, frameGraph);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeRenderGraphCopyTextureBlock\";\r\n }\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeRenderGraphConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeRenderGraphBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.output.value = this._frameGraphTask.outputTexture; // the value of the output connection point is the \"output\" texture of the task\r\n\r\n this._frameGraphTask.sourceTexture = this.source.connectedPoint?.value as FrameGraphTextureHandle;\r\n this._frameGraphTask.targetTexture = this.target.connectedPoint?.value as FrameGraphTextureHandle;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NodeRenderGraphCopyTextureBlock\", NodeRenderGraphCopyTextureBlock);\r\n"]}
1
+ {"version":3,"file":"copyTextureBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FrameGraph/Node/Blocks/Textures/copyTextureBlock.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,wCAAwC,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAA0B,MAAM,sCAAsC,CAAC;AAEtG;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,oBAAoB;IAOrE;;OAEG;IACH,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,YAAmB,IAAY,EAAE,UAAsB,EAAE,KAAY;QACjE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;QAlBzB,wBAAmB,GAAG,KAAK,CAAC;QAC5B,2BAAsB,GAAG,IAAI,CAA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,qBAAqB,CAAC;YACxE,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC;QAClD,CAAC;QACD,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;CACJ;AAxGG;IADC,sBAAsB,CAAC,+BAA+B,0CAAkC,YAAY,CAAC;yEAGrG;AASD;IADC,sBAAsB,CAAC,0BAA0B,0CAAkC,YAAY,CAAC;4EAGhG;AASD;IADC,sBAAsB,CAAC,UAAU,4CAAmC,YAAY,CAAC;+DAGjF;AASD;IADC,sBAAsB,CAAC,WAAW,sCAA8B,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;+DAGlG;AAuEL,aAAa,CAAC,yCAAyC,EAAE,+BAA+B,CAAC,CAAC","sourcesContent":["import type { NodeRenderGraphConnectionPoint, Scene, FrameGraphTextureHandle, FrameGraph, NodeRenderGraphBuildState, IViewportLike } from \"core/index\";\r\nimport { NodeRenderGraphBlock } from \"../../nodeRenderGraphBlock\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeRenderGraphBlockConnectionPointTypes } from \"../../Types/nodeRenderGraphTypes\";\r\nimport { FrameGraphCopyToTextureTask } from \"../../../Tasks/Texture/copyToTextureTask\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"../../../../Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to copy a texture\r\n */\r\nexport class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {\r\n protected override _frameGraphTask: FrameGraphCopyToTextureTask;\r\n\r\n protected _useCurrentViewport = false;\r\n protected _useFullScreenViewport = true;\r\n protected _viewport: IViewportLike = { x: 0, y: 0, width: 1, height: 1 };\r\n\r\n /**\r\n * Gets the frame graph task associated with this block\r\n */\r\n public override get task() {\r\n return this._frameGraphTask;\r\n }\r\n\r\n /**\r\n * Create a new NodeRenderGraphCopyTextureBlock\r\n * @param name defines the block name\r\n * @param frameGraph defines the hosting frame graph\r\n * @param scene defines the hosting scene\r\n */\r\n public constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this.registerInput(\"source\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"target\", NodeRenderGraphBlockConnectionPointTypes.AutoDetect);\r\n this._addDependenciesInput();\r\n this.registerOutput(\"output\", NodeRenderGraphBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.source.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAllButBackBuffer);\r\n this.target.addExcludedConnectionPointFromAllowedTypes(NodeRenderGraphBlockConnectionPointTypes.TextureAll);\r\n this.output._typeConnectionSource = this.source;\r\n\r\n this._frameGraphTask = new FrameGraphCopyToTextureTask(name, frameGraph);\r\n }\r\n\r\n private _setViewport() {\r\n if (this._useCurrentViewport) {\r\n this._frameGraphTask.viewport = null;\r\n } else if (this._useFullScreenViewport) {\r\n this._frameGraphTask.viewport = undefined;\r\n } else {\r\n this._frameGraphTask.viewport = this._viewport;\r\n }\r\n }\r\n\r\n /** If true, the current viewport will be left unchanged. */\r\n @editableInPropertyPage(\"Use currently active viewport\", PropertyTypeForEdition.Boolean, \"PROPERTIES\")\r\n public get useCurrentViewport(): boolean {\r\n return this._useCurrentViewport;\r\n }\r\n\r\n public set useCurrentViewport(value: boolean) {\r\n this._useCurrentViewport = value;\r\n this._setViewport();\r\n }\r\n\r\n /** If true, a full screen viewport will be used. */\r\n @editableInPropertyPage(\"Use full screen viewport\", PropertyTypeForEdition.Boolean, \"PROPERTIES\")\r\n public get useFullScreenViewport(): boolean {\r\n return this._useFullScreenViewport;\r\n }\r\n\r\n public set useFullScreenViewport(value: boolean) {\r\n this._useFullScreenViewport = value;\r\n this._setViewport();\r\n }\r\n\r\n /** The viewport to use. */\r\n @editableInPropertyPage(\"Viewport\", PropertyTypeForEdition.Viewport, \"PROPERTIES\")\r\n public get viewport(): IViewportLike {\r\n return this._viewport;\r\n }\r\n\r\n public set viewport(value: IViewportLike) {\r\n this._viewport = value;\r\n this._setViewport();\r\n }\r\n\r\n /** The LOD level to copy from the source texture (default: 0). */\r\n @editableInPropertyPage(\"LOD Level\", PropertyTypeForEdition.Int, \"PROPERTIES\", { min: 0, max: 16 })\r\n public get lodLevel(): number {\r\n return this._frameGraphTask.lodLevel;\r\n }\r\n\r\n public set lodLevel(value: number) {\r\n this._frameGraphTask.lodLevel = value;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeRenderGraphCopyTextureBlock\";\r\n }\r\n /**\r\n * Gets the source input component\r\n */\r\n public get source(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the target input component\r\n */\r\n public get target(): NodeRenderGraphConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeRenderGraphConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeRenderGraphBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.output.value = this._frameGraphTask.outputTexture; // the value of the output connection point is the \"output\" texture of the task\r\n\r\n this._frameGraphTask.sourceTexture = this.source.connectedPoint?.value as FrameGraphTextureHandle;\r\n this._frameGraphTask.targetTexture = this.target.connectedPoint?.value as FrameGraphTextureHandle;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codes: string[] = [];\r\n codes.push(`${this._codeVariableName}.viewport = ${this._useCurrentViewport ? \"null\" : this._useFullScreenViewport ? \"undefined\" : JSON.stringify(this._viewport)};`);\r\n codes.push(`${this._codeVariableName}.lodLevel = ${this.lodLevel};`);\r\n return super._dumpPropertiesCode() + codes.join(\"\\n\");\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.useCurrentViewport = this._useCurrentViewport;\r\n serializationObject.useFullScreenViewport = this._useFullScreenViewport;\r\n serializationObject.viewport = this._viewport;\r\n serializationObject.lodLevel = this.lodLevel;\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n if (serializationObject.useCurrentViewport !== undefined) {\r\n this._useCurrentViewport = serializationObject.useCurrentViewport;\r\n this._useFullScreenViewport = serializationObject.useFullScreenViewport;\r\n this._viewport = serializationObject.viewport;\r\n }\r\n this.lodLevel = serializationObject.lodLevel ?? 0;\r\n this._setViewport();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NodeRenderGraphCopyTextureBlock\", NodeRenderGraphCopyTextureBlock);\r\n"]}
@@ -9,6 +9,7 @@ export * from "./Layers/glowLayerBlock.js";
9
9
  export * from "./Layers/highlightLayerBlock.js";
10
10
  export * from "./PostProcesses/anaglyphPostProcessBlock.js";
11
11
  export * from "./PostProcesses/basePostProcessBlock.js";
12
+ export * from "./PostProcesses/baseWithPropertiesPostProcessBlock.js";
12
13
  export * from "./PostProcesses/blackAndWhitePostProcessBlock.js";
13
14
  export * from "./PostProcesses/bloomPostProcessBlock.js";
14
15
  export * from "./PostProcesses/blurPostProcessBlock.js";
@@ -9,6 +9,7 @@ export * from "./Layers/glowLayerBlock.js";
9
9
  export * from "./Layers/highlightLayerBlock.js";
10
10
  export * from "./PostProcesses/anaglyphPostProcessBlock.js";
11
11
  export * from "./PostProcesses/basePostProcessBlock.js";
12
+ export * from "./PostProcesses/baseWithPropertiesPostProcessBlock.js";
12
13
  export * from "./PostProcesses/blackAndWhitePostProcessBlock.js";
13
14
  export * from "./PostProcesses/bloomPostProcessBlock.js";
14
15
  export * from "./PostProcesses/blurPostProcessBlock.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qDAAqD,CAAC;AACpE,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAChE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,sDAAsD,CAAC;AACrE,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yCAAyC,CAAC;AAExD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./computeShaderBlock\";\r\nexport * from \"./cullObjectsBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./executeBlock\";\r\nexport * from \"./inputBlock\";\r\nexport * from \"./outputBlock\";\r\nexport * from \"./resourceContainerBlock\";\r\n\r\nexport * from \"./Layers/glowLayerBlock\";\r\nexport * from \"./Layers/highlightLayerBlock\";\r\n\r\nexport * from \"./PostProcesses/anaglyphPostProcessBlock\";\r\nexport * from \"./PostProcesses/basePostProcessBlock\";\r\nexport * from \"./PostProcesses/blackAndWhitePostProcessBlock\";\r\nexport * from \"./PostProcesses/bloomPostProcessBlock\";\r\nexport * from \"./PostProcesses/blurPostProcessBlock\";\r\nexport * from \"./PostProcesses/chromaticAberrationPostProcessBlock\";\r\nexport * from \"./PostProcesses/circleOfConfusionPostProcessBlock\";\r\nexport * from \"./PostProcesses/colorCorrectionPostProcessBlock\";\r\nexport * from \"./PostProcesses/convolutionPostProcessBlock\";\r\nexport * from \"./PostProcesses/depthOfFieldPostProcessBlock\";\r\nexport * from \"./PostProcesses/extractHighlightsPostProcessBlock\";\r\nexport * from \"./PostProcesses/filterPostProcessBlock\";\r\nexport * from \"./PostProcesses/fxaaPostProcessBlock\";\r\nexport * from \"./PostProcesses/grainPostProcessBlock\";\r\nexport * from \"./PostProcesses/imageProcessingPostProcessBlock\";\r\nexport * from \"./PostProcesses/motionBlurPostProcessBlock\";\r\nexport * from \"./PostProcesses/passPostProcessBlock\";\r\nexport * from \"./PostProcesses/sharpenPostProcessBlock\";\r\nexport * from \"./PostProcesses/screenSpaceCurvaturePostProcessBlock\";\r\nexport * from \"./PostProcesses/ssao2PostProcessBlock\";\r\nexport * from \"./PostProcesses/ssrPostProcessBlock\";\r\nexport * from \"./PostProcesses/taaPostProcessBlock\";\r\nexport * from \"./PostProcesses/tonemapPostProcessBlock\";\r\n\r\nexport * from \"./Rendering/csmShadowGeneratorBlock\";\r\nexport * from \"./Rendering/geometryRendererBlock\";\r\nexport * from \"./Rendering/objectRendererBlock\";\r\nexport * from \"./Rendering/shadowGeneratorBlock\";\r\nexport * from \"./Rendering/utilityLayerRendererBlock\";\r\n\r\nexport * from \"./Teleport/teleportInBlock\";\r\nexport * from \"./Teleport/teleportOutBlock\";\r\n\r\nexport * from \"./Textures/clearBlock\";\r\nexport * from \"./Textures/copyTextureBlock\";\r\nexport * from \"./Textures/generateMipmapsBlock\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AAEzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oDAAoD,CAAC;AACnE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qDAAqD,CAAC;AACpE,cAAc,mDAAmD,CAAC;AAClE,cAAc,iDAAiD,CAAC;AAChE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,sDAAsD,CAAC;AACrE,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,yCAAyC,CAAC;AAExD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC","sourcesContent":["export * from \"./computeShaderBlock\";\r\nexport * from \"./cullObjectsBlock\";\r\nexport * from \"./elbowBlock\";\r\nexport * from \"./executeBlock\";\r\nexport * from \"./inputBlock\";\r\nexport * from \"./outputBlock\";\r\nexport * from \"./resourceContainerBlock\";\r\n\r\nexport * from \"./Layers/glowLayerBlock\";\r\nexport * from \"./Layers/highlightLayerBlock\";\r\n\r\nexport * from \"./PostProcesses/anaglyphPostProcessBlock\";\r\nexport * from \"./PostProcesses/basePostProcessBlock\";\r\nexport * from \"./PostProcesses/baseWithPropertiesPostProcessBlock\";\r\nexport * from \"./PostProcesses/blackAndWhitePostProcessBlock\";\r\nexport * from \"./PostProcesses/bloomPostProcessBlock\";\r\nexport * from \"./PostProcesses/blurPostProcessBlock\";\r\nexport * from \"./PostProcesses/chromaticAberrationPostProcessBlock\";\r\nexport * from \"./PostProcesses/circleOfConfusionPostProcessBlock\";\r\nexport * from \"./PostProcesses/colorCorrectionPostProcessBlock\";\r\nexport * from \"./PostProcesses/convolutionPostProcessBlock\";\r\nexport * from \"./PostProcesses/depthOfFieldPostProcessBlock\";\r\nexport * from \"./PostProcesses/extractHighlightsPostProcessBlock\";\r\nexport * from \"./PostProcesses/filterPostProcessBlock\";\r\nexport * from \"./PostProcesses/fxaaPostProcessBlock\";\r\nexport * from \"./PostProcesses/grainPostProcessBlock\";\r\nexport * from \"./PostProcesses/imageProcessingPostProcessBlock\";\r\nexport * from \"./PostProcesses/motionBlurPostProcessBlock\";\r\nexport * from \"./PostProcesses/passPostProcessBlock\";\r\nexport * from \"./PostProcesses/sharpenPostProcessBlock\";\r\nexport * from \"./PostProcesses/screenSpaceCurvaturePostProcessBlock\";\r\nexport * from \"./PostProcesses/ssao2PostProcessBlock\";\r\nexport * from \"./PostProcesses/ssrPostProcessBlock\";\r\nexport * from \"./PostProcesses/taaPostProcessBlock\";\r\nexport * from \"./PostProcesses/tonemapPostProcessBlock\";\r\n\r\nexport * from \"./Rendering/csmShadowGeneratorBlock\";\r\nexport * from \"./Rendering/geometryRendererBlock\";\r\nexport * from \"./Rendering/objectRendererBlock\";\r\nexport * from \"./Rendering/shadowGeneratorBlock\";\r\nexport * from \"./Rendering/utilityLayerRendererBlock\";\r\n\r\nexport * from \"./Teleport/teleportInBlock\";\r\nexport * from \"./Teleport/teleportOutBlock\";\r\n\r\nexport * from \"./Textures/clearBlock\";\r\nexport * from \"./Textures/copyTextureBlock\";\r\nexport * from \"./Textures/generateMipmapsBlock\";\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,G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QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { FrameGraph, FrameGraphTextureHandle, DrawWrapper, FrameGraphRenderPass, FrameGraphRenderContext, EffectWrapper, 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;QAE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,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAChB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACvC,CAAC;oBACD,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;gBACpF,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphTextureHandle,\r\n DrawWrapper,\r\n FrameGraphRenderPass,\r\n FrameGraphRenderContext,\r\n EffectWrapper,\r\n 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"]}
@@ -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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"taaTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/taaTask.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,yBAAyB;IAiB5D;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAoC;QAClF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC;IAEe,MAAM;QAClB,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC5E,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,IAAI,sDAAsD,CAAC,CAAC;QACnH,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1F,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,GAAG,CAAC,GAAG,EAAE;YACzF,IAAI,IAAI,CAAC,WAAW,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACtD,IAAI,CAAC,WAAW,CAA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AAG,IAAI,CAAC,eAAe,CAAC;QAEpD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEjD,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QAC/D,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAc,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,kBAAkB,EAAE,cAAc,CAAC,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,wBAAwB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC1F,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraph,\r\n FrameGraphRenderPass,\r\n FrameGraphObjectRendererTask,\r\n FrameGraphTextureCreationOptions,\r\n Observer,\r\n ObjectRenderer,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n} from \"core/index\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task which applies a Temporal Anti-Aliasing post process.\r\n */\r\nexport class FrameGraphTAATask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinTAAPostProcess;\r\n\r\n /**\r\n * The object renderer task used to render the scene objects.\r\n */\r\n public objectRendererTask: FrameGraphObjectRendererTask;\r\n\r\n /**\r\n * The handle to the velocity texture. Only needed if postProcess.reprojectHistory is enabled.\r\n * Note that you must use the linear velocity texture!\r\n */\r\n public velocityTexture: FrameGraphTextureHandle;\r\n\r\n protected _onBeforeRenderSceneObserver: Observer<Scene>;\r\n protected _initRenderingObserver: Observer<ObjectRenderer>;\r\n\r\n /**\r\n * Constructs a new Temporal Anti-Aliasing 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 Temporal Anti-Aliasing effect. If not provided, a new one will be created.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinTAAPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinTAAPostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.objectRendererTask === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture and objectRendererTask are required`);\r\n }\r\n\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n this._onBeforeRenderSceneObserver = this._frameGraph.scene.onBeforeRenderObservable.add(() => {\r\n if (this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n }\r\n });\r\n\r\n const objectRenderer = this.objectRendererTask.objectRenderer;\r\n\r\n objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._initRenderingObserver = objectRenderer.onInitRenderingObservable.add(() => {\r\n if (!this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n\r\n // We pass false to this.camera.getProjectionMatrix() when TAA is enabled to avoid overwriting the projection matrix calculated by the call to this.postProcess.updateJitter()\r\n const camera = objectRenderer.activeCamera!;\r\n this._frameGraph.scene.setTransformMatrix(camera.getViewMatrix(), camera.getProjectionMatrix(this.postProcess.disabled));\r\n }\r\n });\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const sourceSize = textureManager.getTextureAbsoluteDimensions(this.sourceTexture);\r\n\r\n this._sourceWidth = this._outputWidth = sourceSize.width;\r\n this._sourceHeight = this._outputHeight = sourceSize.height;\r\n\r\n const renderTextureSize = textureManager.getTextureAbsoluteDimensions(this.objectRendererTask.outputTexture);\r\n\r\n this.postProcess.textureWidth = renderTextureSize.width;\r\n this.postProcess.textureHeight = renderTextureSize.height;\r\n\r\n const pingPongTextureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: sourceSize,\r\n options: {\r\n createMipMaps: false,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = textureManager.createRenderTargetTexture(`${this.name} history`, pingPongTextureCreationOptions);\r\n\r\n textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\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 objectRenderer.dontSetTransformationMatrix = !this.postProcess.reprojectHistory;\r\n this.postProcess.camera = objectRenderer.activeCamera;\r\n\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n if (this.velocityTexture !== undefined) {\r\n context.setTextureSamplingMode(this.velocityTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n }\r\n\r\n context.setTextureSamplingMode(pingPongHandle, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture!);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n if (this.postProcess.reprojectHistory && this.velocityTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"velocitySampler\", this.velocityTexture);\r\n }\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 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 context.copyTexture(this.sourceTexture!);\r\n });\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose() {\r\n this.objectRendererTask?.objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n super.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"taaTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/PostProcesses/taaTask.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,yBAAyB;IAiB5D;;;;;OAKG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,eAAoC;QAClF,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,eAAe,IAAI,IAAI,kBAAkB,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC;IAEe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rameGraphObjectRendererTask,\r\n FrameGraphTextureCreationOptions,\r\n Observer,\r\n ObjectRenderer,\r\n FrameGraphTextureHandle,\r\n Scene,\r\n} from \"core/index\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { FrameGraphPostProcessTask } from \"./postProcessTask\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task which applies a Temporal Anti-Aliasing post process.\r\n */\r\nexport class FrameGraphTAATask extends FrameGraphPostProcessTask {\r\n public override readonly postProcess: ThinTAAPostProcess;\r\n\r\n /**\r\n * The object renderer task used to render the scene objects.\r\n */\r\n public objectRendererTask: FrameGraphObjectRendererTask;\r\n\r\n /**\r\n * The handle to the velocity texture. Only needed if postProcess.reprojectHistory is enabled.\r\n * Note that you must use the linear velocity texture!\r\n */\r\n public velocityTexture?: FrameGraphTextureHandle;\r\n\r\n protected _onBeforeRenderSceneObserver: Observer<Scene>;\r\n protected _initRenderingObserver: Observer<ObjectRenderer>;\r\n\r\n /**\r\n * Constructs a new Temporal Anti-Aliasing 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 Temporal Anti-Aliasing effect. If not provided, a new one will be created.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, thinPostProcess?: ThinTAAPostProcess) {\r\n super(name, frameGraph, thinPostProcess || new ThinTAAPostProcess(name, frameGraph.scene));\r\n }\r\n\r\n public override record(): FrameGraphRenderPass {\r\n if (this.sourceTexture === undefined || this.objectRendererTask === undefined) {\r\n throw new Error(`FrameGraphPostProcessTask \"${this.name}\": sourceTexture and objectRendererTask are required`);\r\n }\r\n\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n this._onBeforeRenderSceneObserver = this._frameGraph.scene.onBeforeRenderObservable.add(() => {\r\n if (this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n }\r\n });\r\n\r\n const objectRenderer = this.objectRendererTask.objectRenderer;\r\n\r\n objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._initRenderingObserver = objectRenderer.onInitRenderingObservable.add(() => {\r\n if (!this.postProcess.reprojectHistory && !this.disabled) {\r\n this.postProcess._updateJitter();\r\n\r\n // We pass false to this.camera.getProjectionMatrix() when TAA is enabled to avoid overwriting the projection matrix calculated by the call to this.postProcess.updateJitter()\r\n const camera = objectRenderer.activeCamera!;\r\n this._frameGraph.scene.setTransformMatrix(camera.getViewMatrix(), camera.getProjectionMatrix(this.postProcess.disabled));\r\n }\r\n });\r\n\r\n const textureManager = this._frameGraph.textureManager;\r\n const sourceSize = textureManager.getTextureAbsoluteDimensions(this.sourceTexture);\r\n\r\n this._sourceWidth = this._outputWidth = sourceSize.width;\r\n this._sourceHeight = this._outputHeight = sourceSize.height;\r\n\r\n const renderTextureSize = textureManager.getTextureAbsoluteDimensions(this.objectRendererTask.outputTexture);\r\n\r\n this.postProcess.textureWidth = renderTextureSize.width;\r\n this.postProcess.textureHeight = renderTextureSize.height;\r\n\r\n const pingPongTextureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: sourceSize,\r\n options: {\r\n createMipMaps: false,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n creationFlags: [0],\r\n labels: [\"\"],\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = textureManager.createRenderTargetTexture(`${this.name} history`, pingPongTextureCreationOptions);\r\n\r\n textureManager.resolveDanglingHandle(this.outputTexture, pingPongHandle);\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 objectRenderer.dontSetTransformationMatrix = !this.postProcess.reprojectHistory;\r\n this.postProcess.camera = objectRenderer.activeCamera;\r\n\r\n if (this.sourceTexture !== undefined) {\r\n context.setTextureSamplingMode(this.sourceTexture, this.sourceSamplingMode);\r\n }\r\n if (this.velocityTexture !== undefined) {\r\n context.setTextureSamplingMode(this.velocityTexture, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n }\r\n\r\n context.setTextureSamplingMode(pingPongHandle, Constants.TEXTURE_BILINEAR_SAMPLINGMODE);\r\n\r\n context.applyFullScreenEffect(\r\n this._postProcessDrawWrapper,\r\n () => {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.sourceTexture!);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n if (this.postProcess.reprojectHistory && this.velocityTexture !== undefined) {\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"velocitySampler\", this.velocityTexture);\r\n }\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 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 context.copyTexture(this.sourceTexture!);\r\n });\r\n\r\n return pass;\r\n }\r\n\r\n public override dispose() {\r\n this.objectRendererTask?.objectRenderer.onInitRenderingObservable.remove(this._initRenderingObserver);\r\n this._frameGraph.scene.onBeforeRenderObservable.remove(this._onBeforeRenderSceneObserver);\r\n super.dispose();\r\n }\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { FrameGraphTextureHandle, FrameGraph, Scene } from "../../../index.js";
1
+ import type { FrameGraphTextureHandle, FrameGraph } from "../../../index.js";
2
2
  import { CascadedShadowGenerator } from "../../../Lights/Shadows/cascadedShadowGenerator.js";
3
3
  import { FrameGraphShadowGeneratorTask } from "./shadowGeneratorTask.js";
4
4
  import { DepthTextureType, ThinMinMaxReducer } from "../../../Misc/thinMinMaxReducer.js";
@@ -14,8 +14,9 @@ export declare class FrameGraphCascadedShadowGeneratorTask extends FrameGraphSha
14
14
  */
15
15
  static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask;
16
16
  /**
17
- * The depth texture used by the autoCalcDepthBounds feature (optional if autoCalcDepthBounds is set to false)
17
+ * The depth texture used by the autoCalcDepthBounds feature (optional if autoCalcDepthBounds is set to false).
18
18
  * This texture is used to compute the min/max depth bounds of the scene to setup the cascaded shadow generator.
19
+ * The texture should contain either “view,” “normalized view,” or “screen” depth values - if possible, connect “normalized view,” or “screen” for best performance.
19
20
  * Warning: Do not set a texture if you are not using the autoCalcDepthBounds feature, to avoid generating a depth texture that will not be used.
20
21
  */
21
22
  depthTexture?: FrameGraphTextureHandle;
@@ -84,9 +85,8 @@ export declare class FrameGraphCascadedShadowGeneratorTask extends FrameGraphSha
84
85
  * Creates a new shadow generator task.
85
86
  * @param name The name of the task.
86
87
  * @param frameGraph The frame graph the task belongs to.
87
- * @param scene The scene to create the shadow generator for.
88
88
  */
89
- constructor(name: string, frameGraph: FrameGraph, scene: Scene);
89
+ constructor(name: string, frameGraph: FrameGraph);
90
90
  protected _createShadowGenerator(): void;
91
91
  protected _setupShadowGenerator(): void;
92
92
  record(): void;
@@ -156,10 +156,9 @@ export class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGener
156
156
  * Creates a new shadow generator task.
157
157
  * @param name The name of the task.
158
158
  * @param frameGraph The frame graph the task belongs to.
159
- * @param scene The scene to create the shadow generator for.
160
159
  */
161
- constructor(name, frameGraph, scene) {
162
- super(name, frameGraph, scene);
160
+ constructor(name, frameGraph) {
161
+ super(name, frameGraph);
163
162
  /**
164
163
  * The type of the depth texture used by the autoCalcDepthBounds feature.
165
164
  */
@@ -174,7 +173,7 @@ export class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGener
174
173
  this._currentAutoCalcDepthBoundsCounter = 0;
175
174
  this._autoCalcDepthBoundsRefreshRate = 1;
176
175
  this._shadowMaxZ = 10000;
177
- this._thinMinMaxReducer = new ThinMinMaxReducer(scene);
176
+ this._thinMinMaxReducer = new ThinMinMaxReducer(frameGraph.scene);
178
177
  this._thinMinMaxReducer.onAfterReductionPerformed.add((minmax) => {
179
178
  if (!this._shadowGenerator) {
180
179
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"csmShadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAoB,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AAEzF;;GAEG;AACH,MAAM,OAAO,qCAAsC,SAAQ,6BAA6B;IAGpF;;;;OAIG;IACI,MAAM,CAAC,yBAAyB,CAAC,IAAmC;QACvE,OAAQ,IAA8C,CAAC,WAAW,KAAK,SAAS,CAAC;IACrF,CAAC;IAeD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC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I,CAAC,WAAW,CAAC,cAAc,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,EAAE,EAAE,2BAA2B,CAAC,CAAC;gBAEzJ,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAEzB,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC;YAC9C,CAAC;YAED,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,0BAA0B,CAAC,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;gBACxF,OAAO,CAAC,aAAa,EAAE,CAAC;gBACxB,IAAI,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,kCAAkC,IAAI,CAAC,EAAE,CAAC;oBAC5E,IAAI,EAAE,IAAI,CAAC,kCAAkC,IAAI,IAAI,CAAC,+BAA+B,EAAE,CAAC;wBACpF,MAAM,aAAa,GAAG,OAAO,CAAC,oBAAoB,CAAC,aAAc,CAAC,CAAC;wBACnE,IAAI,aAAa,EAAE,CAAC;4BAChB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;wBACtD,CAAC;oBACL,CAAC;oBACD,IAAI,CAAC,kCAAkC,IAAI,IAAI,CAAC,+BAA+B,CAAC;oBAChF,IAAI,IAAI,CAAC,+BAA+B,KAAK,CAAC,EAAE,CAAC;wBAC7C,IAAI,CAAC,kCAAkC,GAAG,CAAC,CAAC,CAAC;oBACjD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,KAAK,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;IAEe,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, FrameGraph, Scene } from \"core/index\";\r\nimport { CascadedShadowGenerator } from \"../../../Lights/Shadows/cascadedShadowGenerator\";\r\nimport { FrameGraphShadowGeneratorTask } from \"./shadowGeneratorTask\";\r\nimport { DirectionalLight } from \"../../../Lights/directionalLight\";\r\nimport { DepthTextureType, ThinMinMaxReducer } from \"../../../Misc/thinMinMaxReducer\";\r\nimport { FrameGraphPostProcessTask } from \"../PostProcesses/postProcessTask\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { textureSizeIsObject } from \"../../../Materials/Textures/textureCreationOptions\";\r\n\r\n/**\r\n * Task used to generate a cascaded shadow map from a list of objects.\r\n */\r\nexport class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {\r\n protected override _shadowGenerator: CascadedShadowGenerator | undefined;\r\n\r\n /**\r\n * Checks if a shadow generator task is a cascaded shadow generator task.\r\n * @param task The task to check.\r\n * @returns True if the task is a cascaded shadow generator task, else false.\r\n */\r\n public static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask {\r\n return (task as FrameGraphCascadedShadowGeneratorTask).numCascades !== undefined;\r\n }\r\n\r\n /**\r\n * The depth texture used by the autoCalcDepthBounds feature (optional if autoCalcDepthBounds is set to false)\r\n * This texture is used to compute the min/max depth bounds of the scene to setup the cascaded shadow generator.\r\n * Warning: Do not set a texture if you are not using the autoCalcDepthBounds feature, to avoid generating a depth texture that will not be used.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The type of the depth texture used by the autoCalcDepthBounds feature.\r\n */\r\n public depthTextureType: DepthTextureType = DepthTextureType.NormalizedViewDepth;\r\n\r\n private _numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;\r\n /**\r\n * The number of cascades.\r\n */\r\n public get numCascades() {\r\n return this._numCascades;\r\n }\r\n\r\n public set numCascades(value: number) {\r\n if (value === this._numCascades) {\r\n return;\r\n }\r\n\r\n this._numCascades = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _debug = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should display the cascades.\r\n */\r\n public get debug() {\r\n return this._debug;\r\n }\r\n\r\n public set debug(value: boolean) {\r\n if (value === this._debug) {\r\n return;\r\n }\r\n\r\n this._debug = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.debug = value;\r\n }\r\n }\r\n\r\n private _stabilizeCascades = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.\r\n */\r\n public get stabilizeCascades() {\r\n return this._stabilizeCascades;\r\n }\r\n\r\n public set stabilizeCascades(value: boolean) {\r\n if (value === this._stabilizeCascades) {\r\n return;\r\n }\r\n\r\n this._stabilizeCascades = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.stabilizeCascades = value;\r\n }\r\n }\r\n\r\n private _lambda = 0.5;\r\n /**\r\n * Gets or sets the lambda parameter of the shadow generator.\r\n */\r\n public get lambda() {\r\n return this._lambda;\r\n }\r\n\r\n public set lambda(value: number) {\r\n if (value === this._lambda) {\r\n return;\r\n }\r\n\r\n this._lambda = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.lambda = value;\r\n }\r\n }\r\n\r\n private _cascadeBlendPercentage = 0.1;\r\n /**\r\n * Gets or sets the cascade blend percentage.\r\n */\r\n public get cascadeBlendPercentage() {\r\n return this._cascadeBlendPercentage;\r\n }\r\n\r\n public set cascadeBlendPercentage(value: number) {\r\n if (value === this._cascadeBlendPercentage) {\r\n return;\r\n }\r\n\r\n this._cascadeBlendPercentage = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.cascadeBlendPercentage = value;\r\n }\r\n }\r\n\r\n private _depthClamp = true;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should use depth clamping.\r\n */\r\n public get depthClamp() {\r\n return this._depthClamp;\r\n }\r\n\r\n public set depthClamp(value: boolean) {\r\n if (value === this._depthClamp) {\r\n return;\r\n }\r\n\r\n this._depthClamp = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.depthClamp = value;\r\n }\r\n }\r\n\r\n private _autoCalcDepthBounds = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.\r\n */\r\n public get autoCalcDepthBounds() {\r\n return this._autoCalcDepthBounds;\r\n }\r\n\r\n public set autoCalcDepthBounds(value: boolean) {\r\n if (value === this._autoCalcDepthBounds) {\r\n return;\r\n }\r\n\r\n this._autoCalcDepthBounds = value;\r\n this._currentAutoCalcDepthBoundsCounter = this._autoCalcDepthBoundsRefreshRate;\r\n\r\n if (!value) {\r\n this._shadowGenerator?.setMinMaxDistance(0, 1);\r\n }\r\n\r\n // All passes but the last one are related to min/max reduction and should be enabled/disabled depending on autoCalcDepthBounds value\r\n const passes = this.passes;\r\n for (let i = 0; i < passes.length - 1; ++i) {\r\n passes[i].disabled = !value;\r\n }\r\n }\r\n\r\n private _currentAutoCalcDepthBoundsCounter = 0;\r\n private _autoCalcDepthBoundsRefreshRate = 1;\r\n /**\r\n * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true\r\n * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...\r\n */\r\n public get autoCalcDepthBoundsRefreshRate() {\r\n return this._autoCalcDepthBoundsRefreshRate;\r\n }\r\n\r\n public set autoCalcDepthBoundsRefreshRate(value: number) {\r\n this._autoCalcDepthBoundsRefreshRate = value;\r\n this._currentAutoCalcDepthBoundsCounter = this._autoCalcDepthBoundsRefreshRate;\r\n }\r\n\r\n private _shadowMaxZ = 10000;\r\n /**\r\n * Gets or sets the maximum shadow Z value.\r\n */\r\n public get shadowMaxZ() {\r\n return this._shadowMaxZ;\r\n }\r\n\r\n public set shadowMaxZ(value: number) {\r\n if (value === this._shadowMaxZ) {\r\n return;\r\n }\r\n\r\n this._shadowMaxZ = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.shadowMaxZ = value;\r\n }\r\n }\r\n\r\n protected readonly _thinMinMaxReducer: ThinMinMaxReducer;\r\n\r\n /**\r\n * Creates a new shadow generator task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene to create the shadow generator for.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this._thinMinMaxReducer = new ThinMinMaxReducer(scene);\r\n\r\n this._thinMinMaxReducer.onAfterReductionPerformed.add((minmax: { min: number; max: number }) => {\r\n if (!this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n\r\n let min = minmax.min,\r\n max = minmax.max;\r\n\r\n if (min >= max) {\r\n min = 0;\r\n max = 1;\r\n } else if (camera && this.depthTextureType !== DepthTextureType.NormalizedViewDepth) {\r\n if (this.depthTextureType === DepthTextureType.ScreenDepth) {\r\n const engine = this._frameGraph.engine;\r\n const projectionMatrix = camera.getProjectionMatrix();\r\n const p2z = projectionMatrix.m[10];\r\n const p3z = projectionMatrix.m[14];\r\n\r\n if (!engine.isNDCHalfZRange) {\r\n // Convert to NDC depth\r\n min = min * 2 - 1;\r\n max = max * 2 - 1;\r\n }\r\n\r\n // Convert to view depth\r\n min = p3z / (min - p2z);\r\n max = p3z / (max - p2z);\r\n }\r\n\r\n // Convert to normalized view depth\r\n const zNear = camera.minZ;\r\n const zFar = camera.maxZ;\r\n\r\n min = (min - zNear) / (zFar - zNear);\r\n max = (max - zNear) / (zFar - zNear);\r\n }\r\n\r\n if (min !== this._shadowGenerator.minDistance || max !== this._shadowGenerator.maxDistance) {\r\n this._shadowGenerator.setMinMaxDistance(min, max);\r\n }\r\n });\r\n }\r\n\r\n protected override _createShadowGenerator() {\r\n if (!(this.light instanceof DirectionalLight)) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);\r\n }\r\n this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this.camera, this.useRedTextureFormat);\r\n this._shadowGenerator.numCascades = this._numCascades;\r\n }\r\n\r\n protected override _setupShadowGenerator() {\r\n super._setupShadowGenerator();\r\n\r\n const shadowGenerator = this._shadowGenerator;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n\r\n shadowGenerator.debug = this._debug;\r\n shadowGenerator.stabilizeCascades = this._stabilizeCascades;\r\n shadowGenerator.lambda = this._lambda;\r\n shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;\r\n shadowGenerator.depthClamp = this._depthClamp;\r\n shadowGenerator.shadowMaxZ = this._shadowMaxZ;\r\n }\r\n\r\n public override record() {\r\n if (this.light === undefined || this.objectList === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: light, objectList and camera are required`);\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.depthTexture);\r\n\r\n const size = !depthTextureCreationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(depthTextureCreationOptions.size)\r\n ? depthTextureCreationOptions.size\r\n : { width: depthTextureCreationOptions.size, height: depthTextureCreationOptions.size }\r\n : this._frameGraph.textureManager.getAbsoluteDimensions(depthTextureCreationOptions.size);\r\n\r\n const width = size.width;\r\n const height = size.height;\r\n\r\n depthTextureCreationOptions.sizeIsPercentage = false;\r\n depthTextureCreationOptions.options.formats = [Constants.TEXTUREFORMAT_RG];\r\n depthTextureCreationOptions.options.samples = 1;\r\n\r\n this._thinMinMaxReducer.setTextureDimensions(width, height, this.depthTextureType);\r\n\r\n const reductionSteps = this._thinMinMaxReducer.reductionSteps;\r\n\r\n let targetTexture: FrameGraphTextureHandle;\r\n\r\n this._frameGraph.addPass(`${this.name} Before Min Max Reduction`).setExecuteFunc((context) => {\r\n context.pushDebugGroup(`Min Max Reduction`);\r\n });\r\n\r\n for (let i = 0; i < reductionSteps.length - 1; ++i) {\r\n const reductionStep = reductionSteps[i];\r\n\r\n depthTextureCreationOptions.size = { width: reductionSteps[i + 1].textureWidth, height: reductionSteps[i + 1].textureHeight };\r\n\r\n const postProcess = new FrameGraphPostProcessTask(reductionStep.name, this._frameGraph, reductionStep);\r\n\r\n postProcess.sourceTexture = i == 0 ? this.depthTexture : targetTexture!;\r\n postProcess.sourceSamplingMode = Constants.TEXTURE_NEAREST_NEAREST;\r\n postProcess.targetTexture = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} ${reductionStep.name}`, depthTextureCreationOptions);\r\n\r\n postProcess.record(true);\r\n\r\n targetTexture = postProcess.outputTexture;\r\n }\r\n\r\n this._frameGraph.addPass(`${this.name} After Min Max Reduction`).setExecuteFunc((context) => {\r\n context.popDebugGroup();\r\n if (this._autoCalcDepthBounds && this._currentAutoCalcDepthBoundsCounter >= 0) {\r\n if (++this._currentAutoCalcDepthBoundsCounter >= this._autoCalcDepthBoundsRefreshRate) {\r\n const minMaxTexture = context.getTextureFromHandle(targetTexture!);\r\n if (minMaxTexture) {\r\n this._thinMinMaxReducer.readMinMax(minMaxTexture);\r\n }\r\n }\r\n this._currentAutoCalcDepthBoundsCounter %= this._autoCalcDepthBoundsRefreshRate;\r\n if (this._autoCalcDepthBoundsRefreshRate === 0) {\r\n this._currentAutoCalcDepthBoundsCounter = -1;\r\n }\r\n }\r\n });\r\n }\r\n\r\n super.record();\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this._thinMinMaxReducer.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"csmShadowGeneratorTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAoB,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MA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AAG,CAAC,CAAC,CAAC;oBACjD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,KAAK,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;IAEe,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;CACJ","sourcesContent":["import type { FrameGraphTextureHandle, FrameGraph } from \"core/index\";\r\nimport { CascadedShadowGenerator } from \"../../../Lights/Shadows/cascadedShadowGenerator\";\r\nimport { FrameGraphShadowGeneratorTask } from \"./shadowGeneratorTask\";\r\nimport { DirectionalLight } from \"../../../Lights/directionalLight\";\r\nimport { DepthTextureType, ThinMinMaxReducer } from \"../../../Misc/thinMinMaxReducer\";\r\nimport { FrameGraphPostProcessTask } from \"../PostProcesses/postProcessTask\";\r\nimport { Constants } from \"../../../Engines/constants\";\r\nimport { textureSizeIsObject } from \"../../../Materials/Textures/textureCreationOptions\";\r\n\r\n/**\r\n * Task used to generate a cascaded shadow map from a list of objects.\r\n */\r\nexport class FrameGraphCascadedShadowGeneratorTask extends FrameGraphShadowGeneratorTask {\r\n protected override _shadowGenerator: CascadedShadowGenerator | undefined;\r\n\r\n /**\r\n * Checks if a shadow generator task is a cascaded shadow generator task.\r\n * @param task The task to check.\r\n * @returns True if the task is a cascaded shadow generator task, else false.\r\n */\r\n public static IsCascadedShadowGenerator(task: FrameGraphShadowGeneratorTask): task is FrameGraphCascadedShadowGeneratorTask {\r\n return (task as FrameGraphCascadedShadowGeneratorTask).numCascades !== undefined;\r\n }\r\n\r\n /**\r\n * The depth texture used by the autoCalcDepthBounds feature (optional if autoCalcDepthBounds is set to false).\r\n * This texture is used to compute the min/max depth bounds of the scene to setup the cascaded shadow generator.\r\n * The texture should contain either “view,” “normalized view,” or “screen” depth values - if possible, connect “normalized view,” or “screen” for best performance.\r\n * Warning: Do not set a texture if you are not using the autoCalcDepthBounds feature, to avoid generating a depth texture that will not be used.\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The type of the depth texture used by the autoCalcDepthBounds feature.\r\n */\r\n public depthTextureType: DepthTextureType = DepthTextureType.NormalizedViewDepth;\r\n\r\n private _numCascades = CascadedShadowGenerator.DEFAULT_CASCADES_COUNT;\r\n /**\r\n * The number of cascades.\r\n */\r\n public get numCascades() {\r\n return this._numCascades;\r\n }\r\n\r\n public set numCascades(value: number) {\r\n if (value === this._numCascades) {\r\n return;\r\n }\r\n\r\n this._numCascades = value;\r\n this._setupShadowGenerator();\r\n }\r\n\r\n private _debug = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should display the cascades.\r\n */\r\n public get debug() {\r\n return this._debug;\r\n }\r\n\r\n public set debug(value: boolean) {\r\n if (value === this._debug) {\r\n return;\r\n }\r\n\r\n this._debug = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.debug = value;\r\n }\r\n }\r\n\r\n private _stabilizeCascades = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should stabilize the cascades.\r\n */\r\n public get stabilizeCascades() {\r\n return this._stabilizeCascades;\r\n }\r\n\r\n public set stabilizeCascades(value: boolean) {\r\n if (value === this._stabilizeCascades) {\r\n return;\r\n }\r\n\r\n this._stabilizeCascades = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.stabilizeCascades = value;\r\n }\r\n }\r\n\r\n private _lambda = 0.5;\r\n /**\r\n * Gets or sets the lambda parameter of the shadow generator.\r\n */\r\n public get lambda() {\r\n return this._lambda;\r\n }\r\n\r\n public set lambda(value: number) {\r\n if (value === this._lambda) {\r\n return;\r\n }\r\n\r\n this._lambda = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.lambda = value;\r\n }\r\n }\r\n\r\n private _cascadeBlendPercentage = 0.1;\r\n /**\r\n * Gets or sets the cascade blend percentage.\r\n */\r\n public get cascadeBlendPercentage() {\r\n return this._cascadeBlendPercentage;\r\n }\r\n\r\n public set cascadeBlendPercentage(value: number) {\r\n if (value === this._cascadeBlendPercentage) {\r\n return;\r\n }\r\n\r\n this._cascadeBlendPercentage = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.cascadeBlendPercentage = value;\r\n }\r\n }\r\n\r\n private _depthClamp = true;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should use depth clamping.\r\n */\r\n public get depthClamp() {\r\n return this._depthClamp;\r\n }\r\n\r\n public set depthClamp(value: boolean) {\r\n if (value === this._depthClamp) {\r\n return;\r\n }\r\n\r\n this._depthClamp = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.depthClamp = value;\r\n }\r\n }\r\n\r\n private _autoCalcDepthBounds = false;\r\n /**\r\n * Gets or sets a value indicating whether the shadow generator should automatically calculate the depth bounds.\r\n */\r\n public get autoCalcDepthBounds() {\r\n return this._autoCalcDepthBounds;\r\n }\r\n\r\n public set autoCalcDepthBounds(value: boolean) {\r\n if (value === this._autoCalcDepthBounds) {\r\n return;\r\n }\r\n\r\n this._autoCalcDepthBounds = value;\r\n this._currentAutoCalcDepthBoundsCounter = this._autoCalcDepthBoundsRefreshRate;\r\n\r\n if (!value) {\r\n this._shadowGenerator?.setMinMaxDistance(0, 1);\r\n }\r\n\r\n // All passes but the last one are related to min/max reduction and should be enabled/disabled depending on autoCalcDepthBounds value\r\n const passes = this.passes;\r\n for (let i = 0; i < passes.length - 1; ++i) {\r\n passes[i].disabled = !value;\r\n }\r\n }\r\n\r\n private _currentAutoCalcDepthBoundsCounter = 0;\r\n private _autoCalcDepthBoundsRefreshRate = 1;\r\n /**\r\n * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true\r\n * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...\r\n */\r\n public get autoCalcDepthBoundsRefreshRate() {\r\n return this._autoCalcDepthBoundsRefreshRate;\r\n }\r\n\r\n public set autoCalcDepthBoundsRefreshRate(value: number) {\r\n this._autoCalcDepthBoundsRefreshRate = value;\r\n this._currentAutoCalcDepthBoundsCounter = this._autoCalcDepthBoundsRefreshRate;\r\n }\r\n\r\n private _shadowMaxZ = 10000;\r\n /**\r\n * Gets or sets the maximum shadow Z value.\r\n */\r\n public get shadowMaxZ() {\r\n return this._shadowMaxZ;\r\n }\r\n\r\n public set shadowMaxZ(value: number) {\r\n if (value === this._shadowMaxZ) {\r\n return;\r\n }\r\n\r\n this._shadowMaxZ = value;\r\n if (this._shadowGenerator) {\r\n this._shadowGenerator.shadowMaxZ = value;\r\n }\r\n }\r\n\r\n protected readonly _thinMinMaxReducer: ThinMinMaxReducer;\r\n\r\n /**\r\n * Creates a new shadow generator task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph) {\r\n super(name, frameGraph);\r\n\r\n this._thinMinMaxReducer = new ThinMinMaxReducer(frameGraph.scene);\r\n\r\n this._thinMinMaxReducer.onAfterReductionPerformed.add((minmax: { min: number; max: number }) => {\r\n if (!this._shadowGenerator) {\r\n return;\r\n }\r\n\r\n const camera = this.camera;\r\n\r\n let min = minmax.min,\r\n max = minmax.max;\r\n\r\n if (min >= max) {\r\n min = 0;\r\n max = 1;\r\n } else if (camera && this.depthTextureType !== DepthTextureType.NormalizedViewDepth) {\r\n if (this.depthTextureType === DepthTextureType.ScreenDepth) {\r\n const engine = this._frameGraph.engine;\r\n const projectionMatrix = camera.getProjectionMatrix();\r\n const p2z = projectionMatrix.m[10];\r\n const p3z = projectionMatrix.m[14];\r\n\r\n if (!engine.isNDCHalfZRange) {\r\n // Convert to NDC depth\r\n min = min * 2 - 1;\r\n max = max * 2 - 1;\r\n }\r\n\r\n // Convert to view depth\r\n min = p3z / (min - p2z);\r\n max = p3z / (max - p2z);\r\n }\r\n\r\n // Convert to normalized view depth\r\n const zNear = camera.minZ;\r\n const zFar = camera.maxZ;\r\n\r\n min = (min - zNear) / (zFar - zNear);\r\n max = (max - zNear) / (zFar - zNear);\r\n }\r\n\r\n if (min !== this._shadowGenerator.minDistance || max !== this._shadowGenerator.maxDistance) {\r\n this._shadowGenerator.setMinMaxDistance(min, max);\r\n }\r\n });\r\n }\r\n\r\n protected override _createShadowGenerator() {\r\n if (!(this.light instanceof DirectionalLight)) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);\r\n }\r\n this._shadowGenerator = new CascadedShadowGenerator(this.mapSize, this.light, this.useFloat32TextureType, this.camera, this.useRedTextureFormat);\r\n this._shadowGenerator.numCascades = this._numCascades;\r\n }\r\n\r\n protected override _setupShadowGenerator() {\r\n super._setupShadowGenerator();\r\n\r\n const shadowGenerator = this._shadowGenerator;\r\n if (shadowGenerator === undefined) {\r\n return;\r\n }\r\n\r\n shadowGenerator.debug = this._debug;\r\n shadowGenerator.stabilizeCascades = this._stabilizeCascades;\r\n shadowGenerator.lambda = this._lambda;\r\n shadowGenerator.cascadeBlendPercentage = this._cascadeBlendPercentage;\r\n shadowGenerator.depthClamp = this._depthClamp;\r\n shadowGenerator.shadowMaxZ = this._shadowMaxZ;\r\n }\r\n\r\n public override record() {\r\n if (this.light === undefined || this.objectList === undefined || this.camera === undefined) {\r\n throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: light, objectList and camera are required`);\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.depthTexture);\r\n\r\n const size = !depthTextureCreationOptions.sizeIsPercentage\r\n ? textureSizeIsObject(depthTextureCreationOptions.size)\r\n ? depthTextureCreationOptions.size\r\n : { width: depthTextureCreationOptions.size, height: depthTextureCreationOptions.size }\r\n : this._frameGraph.textureManager.getAbsoluteDimensions(depthTextureCreationOptions.size);\r\n\r\n const width = size.width;\r\n const height = size.height;\r\n\r\n depthTextureCreationOptions.sizeIsPercentage = false;\r\n depthTextureCreationOptions.options.formats = [Constants.TEXTUREFORMAT_RG];\r\n depthTextureCreationOptions.options.samples = 1;\r\n\r\n this._thinMinMaxReducer.setTextureDimensions(width, height, this.depthTextureType);\r\n\r\n const reductionSteps = this._thinMinMaxReducer.reductionSteps;\r\n\r\n let targetTexture: FrameGraphTextureHandle;\r\n\r\n this._frameGraph.addPass(`${this.name} Before Min Max Reduction`).setExecuteFunc((context) => {\r\n context.pushDebugGroup(`Min Max Reduction`);\r\n });\r\n\r\n for (let i = 0; i < reductionSteps.length - 1; ++i) {\r\n const reductionStep = reductionSteps[i];\r\n\r\n depthTextureCreationOptions.size = { width: reductionSteps[i + 1].textureWidth, height: reductionSteps[i + 1].textureHeight };\r\n\r\n const postProcess = new FrameGraphPostProcessTask(reductionStep.name, this._frameGraph, reductionStep);\r\n\r\n postProcess.sourceTexture = i == 0 ? this.depthTexture : targetTexture!;\r\n postProcess.sourceSamplingMode = Constants.TEXTURE_NEAREST_NEAREST;\r\n postProcess.targetTexture = this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} ${reductionStep.name}`, depthTextureCreationOptions);\r\n\r\n postProcess.record(true);\r\n\r\n targetTexture = postProcess.outputTexture;\r\n }\r\n\r\n this._frameGraph.addPass(`${this.name} After Min Max Reduction`).setExecuteFunc((context) => {\r\n context.popDebugGroup();\r\n if (this._autoCalcDepthBounds && this._currentAutoCalcDepthBoundsCounter >= 0) {\r\n if (++this._currentAutoCalcDepthBoundsCounter >= this._autoCalcDepthBoundsRefreshRate) {\r\n const minMaxTexture = context.getTextureFromHandle(targetTexture!);\r\n if (minMaxTexture) {\r\n this._thinMinMaxReducer.readMinMax(minMaxTexture);\r\n }\r\n }\r\n this._currentAutoCalcDepthBoundsCounter %= this._autoCalcDepthBoundsRefreshRate;\r\n if (this._autoCalcDepthBoundsRefreshRate === 0) {\r\n this._currentAutoCalcDepthBoundsCounter = -1;\r\n }\r\n }\r\n });\r\n }\r\n\r\n super.record();\r\n }\r\n\r\n public override dispose() {\r\n super.dispose();\r\n this._thinMinMaxReducer.dispose();\r\n }\r\n}\r\n"]}
@@ -55,19 +55,19 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
55
55
  isMainObjectRenderer: boolean;
56
56
  private _renderParticles;
57
57
  /**
58
- * Define if particles should be rendered (default is true).
58
+ * Defines if particles should be rendered (default is true).
59
59
  */
60
60
  get renderParticles(): boolean;
61
61
  set renderParticles(value: boolean);
62
62
  private _renderSprites;
63
63
  /**
64
- * Define if sprites should be rendered (default is true).
64
+ * Defines if sprites should be rendered (default is true).
65
65
  */
66
66
  get renderSprites(): boolean;
67
67
  set renderSprites(value: boolean);
68
68
  private _forceLayerMaskCheck;
69
69
  /**
70
- * Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
70
+ * Forces checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
71
71
  */
72
72
  get forceLayerMaskCheck(): boolean;
73
73
  set forceLayerMaskCheck(value: boolean);
@@ -85,7 +85,7 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
85
85
  set enableOutlineRendering(value: boolean);
86
86
  /**
87
87
  * The output texture.
88
- * This texture will point to the same texture than the targetTexture property if it is set.
88
+ * This texture will point to the same texture than the targetTexture property.
89
89
  * Note, however, that the handle itself will be different!
90
90
  */
91
91
  readonly outputTexture: FrameGraphTextureHandle;
@@ -32,7 +32,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
32
32
  this._renderer.disableImageProcessing = value;
33
33
  }
34
34
  /**
35
- * Define if particles should be rendered (default is true).
35
+ * Defines if particles should be rendered (default is true).
36
36
  */
37
37
  get renderParticles() {
38
38
  return this._renderParticles;
@@ -45,7 +45,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
45
45
  this._renderer.renderParticles = value;
46
46
  }
47
47
  /**
48
- * Define if sprites should be rendered (default is true).
48
+ * Defines if sprites should be rendered (default is true).
49
49
  */
50
50
  get renderSprites() {
51
51
  return this._renderSprites;
@@ -58,7 +58,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
58
58
  this._renderer.renderSprites = value;
59
59
  }
60
60
  /**
61
- * Force checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
61
+ * Forces checking the layerMask property even if a custom list of meshes is provided (ie. if renderList is not undefined). Default is true.
62
62
  */
63
63
  get forceLayerMaskCheck() {
64
64
  return this._forceLayerMaskCheck;