@babylonjs/smart-filters 1.0.13 → 8.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/blockFoundation/aggregateBlock.d.ts +3 -3
  2. package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
  3. package/dist/blockFoundation/aggregateBlock.js +1 -2
  4. package/dist/blockFoundation/aggregateBlock.js.map +1 -1
  5. package/dist/blockFoundation/baseBlock.d.ts +2 -2
  6. package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
  7. package/dist/blockFoundation/baseBlock.js +5 -6
  8. package/dist/blockFoundation/baseBlock.js.map +1 -1
  9. package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
  10. package/dist/blockFoundation/customAggregateBlock.js +2 -2
  11. package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
  12. package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
  13. package/dist/blockFoundation/customShaderBlock.js +4 -6
  14. package/dist/blockFoundation/customShaderBlock.js.map +1 -1
  15. package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
  16. package/dist/blockFoundation/disableableShaderBlock.js +4 -4
  17. package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
  18. package/dist/blockFoundation/index.js +0 -2
  19. package/dist/blockFoundation/index.js.map +1 -1
  20. package/dist/blockFoundation/inputBlock.d.ts +8 -8
  21. package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
  22. package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
  23. package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
  24. package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
  25. package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
  26. package/dist/blockFoundation/inputBlock.js +7 -7
  27. package/dist/blockFoundation/inputBlock.js.map +1 -1
  28. package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
  29. package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
  30. package/dist/blockFoundation/inputBlock.serializer.js +26 -28
  31. package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
  32. package/dist/blockFoundation/outputBlock.d.ts +4 -9
  33. package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
  34. package/dist/blockFoundation/outputBlock.js +13 -14
  35. package/dist/blockFoundation/outputBlock.js.map +1 -1
  36. package/dist/blockFoundation/shaderBlock.d.ts +4 -4
  37. package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
  38. package/dist/blockFoundation/shaderBlock.js +13 -19
  39. package/dist/blockFoundation/shaderBlock.js.map +1 -1
  40. package/dist/blockFoundation/textureOptions.d.ts +1 -1
  41. package/dist/blockFoundation/textureOptions.js +1 -1
  42. package/dist/command/command.d.ts +1 -1
  43. package/dist/command/command.js +1 -1
  44. package/dist/command/commandBuffer.d.ts +1 -1
  45. package/dist/command/commandBuffer.d.ts.map +1 -1
  46. package/dist/command/commandBuffer.js +2 -2
  47. package/dist/command/commandBufferDebugger.d.ts +2 -2
  48. package/dist/command/commandBufferDebugger.d.ts.map +1 -1
  49. package/dist/command/commandBufferDebugger.js +1 -1
  50. package/dist/command/commandBufferDebugger.js.map +1 -1
  51. package/dist/command/index.d.ts +3 -1
  52. package/dist/command/index.d.ts.map +1 -1
  53. package/dist/command/index.js +5 -1
  54. package/dist/command/index.js.map +1 -1
  55. package/dist/connection/connectionPoint.d.ts +3 -3
  56. package/dist/connection/connectionPoint.d.ts.map +1 -1
  57. package/dist/connection/connectionPoint.js +2 -2
  58. package/dist/connection/connectionPoint.js.map +1 -1
  59. package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
  60. package/dist/connection/connectionPointCompatibilityState.js +1 -1
  61. package/dist/connection/connectionPointType.d.ts +3 -3
  62. package/dist/connection/connectionPointType.d.ts.map +1 -1
  63. package/dist/connection/connectionPointWithDefault.d.ts +3 -3
  64. package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
  65. package/dist/connection/connectionPointWithDefault.js.map +1 -1
  66. package/dist/connection/index.d.ts +2 -1
  67. package/dist/connection/index.d.ts.map +1 -1
  68. package/dist/connection/index.js +3 -3
  69. package/dist/connection/index.js.map +1 -1
  70. package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
  71. package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
  72. package/dist/editorUtils/editableInPropertyPage.js +2 -2
  73. package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
  74. package/dist/editorUtils/index.d.ts +1 -0
  75. package/dist/editorUtils/index.d.ts.map +1 -1
  76. package/dist/editorUtils/index.js +2 -0
  77. package/dist/editorUtils/index.js.map +1 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +1 -1
  80. package/dist/index.js.map +1 -1
  81. package/dist/optimization/dependencyGraph.js.map +1 -1
  82. package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
  83. package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
  84. package/dist/optimization/optimizedShaderBlock.js.map +1 -1
  85. package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
  86. package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
  87. package/dist/optimization/smartFilterOptimizer.js +34 -57
  88. package/dist/optimization/smartFilterOptimizer.js.map +1 -1
  89. package/dist/runtime/index.d.ts +2 -1
  90. package/dist/runtime/index.d.ts.map +1 -1
  91. package/dist/runtime/index.js +3 -3
  92. package/dist/runtime/index.js.map +1 -1
  93. package/dist/runtime/renderTargetGenerator.d.ts +1 -1
  94. package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
  95. package/dist/runtime/renderTargetGenerator.js +5 -7
  96. package/dist/runtime/renderTargetGenerator.js.map +1 -1
  97. package/dist/runtime/shaderRuntime.d.ts +7 -7
  98. package/dist/runtime/shaderRuntime.d.ts.map +1 -1
  99. package/dist/runtime/shaderRuntime.js +7 -8
  100. package/dist/runtime/shaderRuntime.js.map +1 -1
  101. package/dist/runtime/smartFilterRuntime.d.ts +3 -3
  102. package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
  103. package/dist/runtime/smartFilterRuntime.js.map +1 -1
  104. package/dist/runtime/strongRef.d.ts +1 -1
  105. package/dist/runtime/strongRef.js +1 -1
  106. package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
  107. package/dist/serialization/importCustomBlockDefinition.js +8 -9
  108. package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
  109. package/dist/serialization/index.d.ts +1 -0
  110. package/dist/serialization/index.d.ts.map +1 -1
  111. package/dist/serialization/index.js +3 -0
  112. package/dist/serialization/index.js.map +1 -1
  113. package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
  114. package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
  115. package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
  116. package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
  117. package/dist/serialization/serializedSmartFilter.d.ts +1 -1
  118. package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
  119. package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
  120. package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
  121. package/dist/serialization/smartFilterDeserializer.js +9 -12
  122. package/dist/serialization/smartFilterDeserializer.js.map +1 -1
  123. package/dist/serialization/smartFilterSerializer.d.ts +2 -2
  124. package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
  125. package/dist/serialization/smartFilterSerializer.js +10 -13
  126. package/dist/serialization/smartFilterSerializer.js.map +1 -1
  127. package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
  128. package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
  129. package/dist/serialization/v1/defaultBlockSerializer.js +1 -1
  130. package/dist/serialization/v1/index.d.ts +1 -0
  131. package/dist/serialization/v1/index.d.ts.map +1 -1
  132. package/dist/serialization/v1/index.js +2 -0
  133. package/dist/serialization/v1/index.js.map +1 -1
  134. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
  135. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
  136. package/dist/serialization/v1/smartFilterSerialization.types.d.ts +2 -2
  137. package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
  138. package/dist/smartFilter.d.ts +8 -8
  139. package/dist/smartFilter.d.ts.map +1 -1
  140. package/dist/smartFilter.js +6 -7
  141. package/dist/smartFilter.js.map +1 -1
  142. package/dist/utils/buildTools/buildShaders.d.ts +3 -2
  143. package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
  144. package/dist/utils/buildTools/buildShaders.js +7 -6
  145. package/dist/utils/buildTools/buildShaders.js.map +1 -1
  146. package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
  147. package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
  148. package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
  149. package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
  150. package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
  151. package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
  152. package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
  153. package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
  154. package/dist/utils/buildTools/convertShaders.d.ts +8 -5
  155. package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
  156. package/dist/utils/buildTools/convertShaders.js +38 -14
  157. package/dist/utils/buildTools/convertShaders.js.map +1 -1
  158. package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
  159. package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
  160. package/dist/utils/buildTools/shaderConverter.js +17 -21
  161. package/dist/utils/buildTools/shaderConverter.js.map +1 -1
  162. package/dist/utils/buildTools/watchShaders.d.ts +3 -2
  163. package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
  164. package/dist/utils/buildTools/watchShaders.js +10 -8
  165. package/dist/utils/buildTools/watchShaders.js.map +1 -1
  166. package/dist/utils/index.d.ts +1 -0
  167. package/dist/utils/index.d.ts.map +1 -1
  168. package/dist/utils/index.js +2 -1
  169. package/dist/utils/index.js.map +1 -1
  170. package/dist/utils/renderTargetUtils.d.ts +3 -3
  171. package/dist/utils/renderTargetUtils.d.ts.map +1 -1
  172. package/dist/utils/renderTargetUtils.js +4 -4
  173. package/dist/utils/renderTargetUtils.js.map +1 -1
  174. package/dist/utils/shaderCodeUtils.d.ts +8 -8
  175. package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
  176. package/dist/utils/shaderCodeUtils.js +16 -28
  177. package/dist/utils/shaderCodeUtils.js.map +1 -1
  178. package/dist/utils/textureLoaders.d.ts +2 -2
  179. package/dist/utils/textureLoaders.d.ts.map +1 -1
  180. package/dist/utils/textureLoaders.js +2 -3
  181. package/dist/utils/textureLoaders.js.map +1 -1
  182. package/dist/utils/textureUtils.d.ts +5 -5
  183. package/dist/utils/textureUtils.d.ts.map +1 -1
  184. package/dist/utils/textureUtils.js +1 -1
  185. package/dist/utils/textureUtils.js.map +1 -1
  186. package/dist/version.d.ts +2 -2
  187. package/dist/version.js +2 -2
  188. package/license.md +21 -21
  189. package/package.json +13 -8
  190. package/src/blockFoundation/aggregateBlock.ts +148 -151
  191. package/src/blockFoundation/baseBlock.ts +339 -364
  192. package/src/blockFoundation/customAggregateBlock.ts +88 -104
  193. package/src/blockFoundation/customShaderBlock.ts +312 -326
  194. package/src/blockFoundation/disableableShaderBlock.ts +91 -100
  195. package/src/blockFoundation/index.ts +9 -9
  196. package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
  197. package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
  198. package/src/blockFoundation/inputBlock.serializer.ts +150 -150
  199. package/src/blockFoundation/inputBlock.ts +181 -192
  200. package/src/blockFoundation/outputBlock.ts +144 -151
  201. package/src/blockFoundation/shaderBlock.ts +156 -163
  202. package/src/blockFoundation/textureOptions.ts +57 -57
  203. package/src/command/command.ts +59 -59
  204. package/src/command/commandBuffer.ts +71 -71
  205. package/src/command/commandBufferDebugger.ts +14 -14
  206. package/src/command/index.ts +7 -3
  207. package/src/connection/connectionPoint.ts +205 -214
  208. package/src/connection/connectionPointCompatibilityState.ts +31 -31
  209. package/src/connection/connectionPointType.ts +45 -45
  210. package/src/connection/connectionPointWithDefault.ts +27 -35
  211. package/src/connection/index.ts +8 -9
  212. package/src/editorUtils/editableInPropertyPage.ts +106 -106
  213. package/src/editorUtils/index.ts +3 -1
  214. package/src/index.ts +16 -15
  215. package/src/optimization/dependencyGraph.ts +96 -96
  216. package/src/optimization/index.ts +1 -1
  217. package/src/optimization/optimizedShaderBlock.ts +131 -134
  218. package/src/optimization/smartFilterOptimizer.ts +757 -825
  219. package/src/runtime/index.ts +8 -6
  220. package/src/runtime/renderTargetGenerator.ts +222 -248
  221. package/src/runtime/shaderRuntime.ts +174 -173
  222. package/src/runtime/smartFilterRuntime.ts +112 -112
  223. package/src/runtime/strongRef.ts +18 -18
  224. package/src/serialization/importCustomBlockDefinition.ts +86 -86
  225. package/src/serialization/index.ts +10 -7
  226. package/src/serialization/serializedBlockDefinition.ts +12 -12
  227. package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
  228. package/src/serialization/serializedSmartFilter.ts +6 -6
  229. package/src/serialization/smartFilterDeserializer.ts +190 -220
  230. package/src/serialization/smartFilterSerializer.ts +110 -121
  231. package/src/serialization/v1/defaultBlockSerializer.ts +21 -21
  232. package/src/serialization/v1/index.ts +4 -2
  233. package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
  234. package/src/serialization/v1/smartFilterSerialization.types.ts +129 -133
  235. package/src/smartFilter.ts +255 -260
  236. package/src/utils/buildTools/buildShaders.ts +14 -13
  237. package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
  238. package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
  239. package/src/utils/buildTools/convertShaders.ts +65 -43
  240. package/src/utils/buildTools/recordVersionNumber.js +17 -0
  241. package/src/utils/buildTools/shaderConverter.ts +466 -478
  242. package/src/utils/buildTools/watchShaders.ts +44 -42
  243. package/src/utils/index.ts +4 -2
  244. package/src/utils/renderTargetUtils.ts +30 -35
  245. package/src/utils/shaderCodeUtils.ts +192 -207
  246. package/src/utils/textureLoaders.ts +31 -43
  247. package/src/utils/textureUtils.ts +28 -32
  248. package/src/version.ts +2 -2
  249. package/dist/utils/buildTools/determineVersion.d.ts +0 -36
  250. package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
  251. package/dist/utils/buildTools/determineVersion.js +0 -109
  252. package/dist/utils/buildTools/determineVersion.js.map +0 -1
  253. package/dist/utils/buildTools/versionUp.d.ts +0 -2
  254. package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
  255. package/dist/utils/buildTools/versionUp.js +0 -53
  256. package/dist/utils/buildTools/versionUp.js.map +0 -1
  257. package/src/utils/buildTools/determineVersion.ts +0 -128
  258. package/src/utils/buildTools/versionUp.ts +0 -61
@@ -1,134 +1,131 @@
1
- import type { Effect } from "@babylonjs/core/Materials/effect";
2
- import type { Nullable } from "@babylonjs/core/types";
3
-
4
- import type { SmartFilter } from "../smartFilter";
5
- import type { ShaderProgram } from "../utils/shaderCodeUtils";
6
- import type { RuntimeData } from "../connection/connectionPoint";
7
- import { ShaderBlock } from "../blockFoundation/shaderBlock.js";
8
- import { ShaderBinding } from "../runtime/shaderRuntime.js";
9
- import { ConnectionPointType } from "../connection/connectionPointType.js";
10
-
11
- /**
12
- * The shader bindings for the OptimizedShader block.
13
- * @internal
14
- */
15
- export class OptimizedShaderBinding extends ShaderBinding {
16
- private _shaderBindings: ShaderBinding[];
17
- private _inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> };
18
-
19
- /**
20
- * Creates a new shader binding instance for the OptimizedShader block.
21
- * @param shaderBindings - The list of shader bindings to process
22
- * @param inputTextures - The list of input textures to bind
23
- */
24
- constructor(
25
- shaderBindings: ShaderBinding[],
26
- inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> }
27
- ) {
28
- super();
29
-
30
- this._shaderBindings = shaderBindings;
31
- this._inputTextures = inputTextures;
32
- }
33
-
34
- /**
35
- * Binds all the required data to the shader when rendering.
36
- * @param effect - defines the effect to bind the data to
37
- * @param width - defines the width of the output
38
- * @param height - defines the height of the output
39
- */
40
- public override bind(effect: Effect, width: number, height: number): void {
41
- for (const shaderBinding of this._shaderBindings) {
42
- shaderBinding.bind(effect, width, height);
43
- }
44
-
45
- for (const name in this._inputTextures) {
46
- const texture = this._inputTextures[name];
47
- // texture can't be undefined, so let's add "!" to make Typescript happy
48
- effect.setTexture(this.getRemappedName(name), texture!.value);
49
- }
50
- }
51
- }
52
-
53
- /**
54
- * A block used by the smart filter optimizer to group shader blocks together.
55
- * Should be for internal use only.
56
- * @internal
57
- */
58
- export class OptimizedShaderBlock extends ShaderBlock {
59
- private _shaderBindings: Nullable<ShaderBinding[]>;
60
- private _inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> } = {};
61
- private _shaderProgram: ShaderProgram;
62
-
63
- /**
64
- * The class name of the block.
65
- */
66
- public static override ClassName = "OptimizedShaderBlock";
67
-
68
- /**
69
- * Returns if the block is an input block.
70
- */
71
- public override get isInput(): boolean {
72
- return false;
73
- }
74
-
75
- /**
76
- * Creates a new OptimizedShaderBlock.
77
- * @param smartFilter - The smart filter to add the block to
78
- * @param name - The name of the block
79
- */
80
- constructor(smartFilter: SmartFilter, name: string) {
81
- super(smartFilter, name, true);
82
-
83
- this._shaderBindings = null;
84
- this._shaderProgram = undefined as any;
85
- }
86
-
87
- /**
88
- * Gets the shader program to use to render the block.
89
- * @returns The shader program to use to render the block
90
- */
91
- public override getShaderProgram(): ShaderProgram {
92
- return this._shaderProgram;
93
- }
94
-
95
- /**
96
- * Sets the shader program to use to render the block.
97
- * @param shaderProgram - The shader program to use to render the block
98
- */
99
- public setShaderProgram(shaderProgram: ShaderProgram): void {
100
- this._shaderProgram = shaderProgram;
101
- }
102
-
103
- /**
104
- * Sets the list of shader bindings to use to render the block.
105
- * @param shaderBindings - The list of shader bindings to use to render the block
106
- */
107
- public setShaderBindings(shaderBindings: ShaderBinding[]): void {
108
- this._shaderBindings = shaderBindings;
109
- }
110
-
111
- /**
112
- * Get the class instance that binds all the required data to the shader (effect) when rendering.
113
- * @returns The class instance that binds the data to the effect
114
- */
115
- public getShaderBinding(): ShaderBinding {
116
- if (this._shaderBindings === null) {
117
- throw new Error("Shader bindings not set!");
118
- }
119
-
120
- for (const input of this.inputs) {
121
- const name = input.name;
122
-
123
- if (input.type === ConnectionPointType.Texture) {
124
- /**
125
- * These are the inputs created by the OptimizedShaderBlock
126
- * We pass them to OptimizedShaderBinding so that their value can be set appropriately at runtime (in the bind method)
127
- */
128
- this._inputTextures[name] = input.runtimeData as RuntimeData<ConnectionPointType.Texture>;
129
- }
130
- }
131
-
132
- return new OptimizedShaderBinding(this._shaderBindings, this._inputTextures);
133
- }
134
- }
1
+ import type { Effect } from "core/Materials/effect.js";
2
+ import type { Nullable } from "core/types.js";
3
+
4
+ import type { SmartFilter } from "../smartFilter.js";
5
+ import type { ShaderProgram } from "../utils/shaderCodeUtils.js";
6
+ import type { RuntimeData } from "../connection/connectionPoint.js";
7
+ import { ShaderBlock } from "../blockFoundation/shaderBlock.js";
8
+ import { ShaderBinding } from "../runtime/shaderRuntime.js";
9
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
10
+
11
+ /**
12
+ * The shader bindings for the OptimizedShader block.
13
+ * @internal
14
+ */
15
+ export class OptimizedShaderBinding extends ShaderBinding {
16
+ private _shaderBindings: ShaderBinding[];
17
+ private _inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> };
18
+
19
+ /**
20
+ * Creates a new shader binding instance for the OptimizedShader block.
21
+ * @param shaderBindings - The list of shader bindings to process
22
+ * @param inputTextures - The list of input textures to bind
23
+ */
24
+ constructor(shaderBindings: ShaderBinding[], inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> }) {
25
+ super();
26
+
27
+ this._shaderBindings = shaderBindings;
28
+ this._inputTextures = inputTextures;
29
+ }
30
+
31
+ /**
32
+ * Binds all the required data to the shader when rendering.
33
+ * @param effect - defines the effect to bind the data to
34
+ * @param width - defines the width of the output
35
+ * @param height - defines the height of the output
36
+ */
37
+ public override bind(effect: Effect, width: number, height: number): void {
38
+ for (const shaderBinding of this._shaderBindings) {
39
+ shaderBinding.bind(effect, width, height);
40
+ }
41
+
42
+ for (const name in this._inputTextures) {
43
+ const texture = this._inputTextures[name];
44
+ // texture can't be undefined, so let's add "!" to make Typescript happy
45
+ effect.setTexture(this.getRemappedName(name), texture!.value);
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * A block used by the smart filter optimizer to group shader blocks together.
52
+ * Should be for internal use only.
53
+ * @internal
54
+ */
55
+ export class OptimizedShaderBlock extends ShaderBlock {
56
+ private _shaderBindings: Nullable<ShaderBinding[]>;
57
+ private _inputTextures: { [name: string]: RuntimeData<ConnectionPointType.Texture> } = {};
58
+ private _shaderProgram: ShaderProgram;
59
+
60
+ /**
61
+ * The class name of the block.
62
+ */
63
+ public static override ClassName = "OptimizedShaderBlock";
64
+
65
+ /**
66
+ * Returns if the block is an input block.
67
+ */
68
+ public override get isInput(): boolean {
69
+ return false;
70
+ }
71
+
72
+ /**
73
+ * Creates a new OptimizedShaderBlock.
74
+ * @param smartFilter - The smart filter to add the block to
75
+ * @param name - The name of the block
76
+ */
77
+ constructor(smartFilter: SmartFilter, name: string) {
78
+ super(smartFilter, name, true);
79
+
80
+ this._shaderBindings = null;
81
+ this._shaderProgram = undefined as any;
82
+ }
83
+
84
+ /**
85
+ * Gets the shader program to use to render the block.
86
+ * @returns The shader program to use to render the block
87
+ */
88
+ public override getShaderProgram(): ShaderProgram {
89
+ return this._shaderProgram;
90
+ }
91
+
92
+ /**
93
+ * Sets the shader program to use to render the block.
94
+ * @param shaderProgram - The shader program to use to render the block
95
+ */
96
+ public setShaderProgram(shaderProgram: ShaderProgram): void {
97
+ this._shaderProgram = shaderProgram;
98
+ }
99
+
100
+ /**
101
+ * Sets the list of shader bindings to use to render the block.
102
+ * @param shaderBindings - The list of shader bindings to use to render the block
103
+ */
104
+ public setShaderBindings(shaderBindings: ShaderBinding[]): void {
105
+ this._shaderBindings = shaderBindings;
106
+ }
107
+
108
+ /**
109
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
110
+ * @returns The class instance that binds the data to the effect
111
+ */
112
+ public getShaderBinding(): ShaderBinding {
113
+ if (this._shaderBindings === null) {
114
+ throw new Error("Shader bindings not set!");
115
+ }
116
+
117
+ for (const input of this.inputs) {
118
+ const name = input.name;
119
+
120
+ if (input.type === ConnectionPointType.Texture) {
121
+ /**
122
+ * These are the inputs created by the OptimizedShaderBlock
123
+ * We pass them to OptimizedShaderBinding so that their value can be set appropriately at runtime (in the bind method)
124
+ */
125
+ this._inputTextures[name] = input.runtimeData as RuntimeData<ConnectionPointType.Texture>;
126
+ }
127
+ }
128
+
129
+ return new OptimizedShaderBinding(this._shaderBindings, this._inputTextures);
130
+ }
131
+ }