@babylonjs/core 6.44.0 → 6.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/Buffers/buffer.d.ts +22 -22
  2. package/Buffers/buffer.js +16 -15
  3. package/Buffers/buffer.js.map +1 -1
  4. package/Cameras/camera.d.ts +5 -5
  5. package/Cameras/camera.js +19 -19
  6. package/Cameras/camera.js.map +1 -1
  7. package/Engines/ICanvas.d.ts +2 -1
  8. package/Engines/ICanvas.js.map +1 -1
  9. package/Engines/constants.d.ts +96 -0
  10. package/Engines/constants.js +96 -0
  11. package/Engines/constants.js.map +1 -1
  12. package/Engines/thinEngine.js +2 -2
  13. package/Engines/thinEngine.js.map +1 -1
  14. package/Gizmos/gizmo.d.ts +14 -0
  15. package/Gizmos/gizmo.js +16 -0
  16. package/Gizmos/gizmo.js.map +1 -1
  17. package/Gizmos/gizmoManager.d.ts +12 -0
  18. package/Gizmos/gizmoManager.js +26 -0
  19. package/Gizmos/gizmoManager.js.map +1 -1
  20. package/Gizmos/positionGizmo.d.ts +16 -2
  21. package/Gizmos/positionGizmo.js +12 -2
  22. package/Gizmos/positionGizmo.js.map +1 -1
  23. package/Gizmos/rotationGizmo.d.ts +8 -0
  24. package/Gizmos/rotationGizmo.js +9 -0
  25. package/Gizmos/rotationGizmo.js.map +1 -1
  26. package/Gizmos/scaleGizmo.d.ts +15 -1
  27. package/Gizmos/scaleGizmo.js +11 -1
  28. package/Gizmos/scaleGizmo.js.map +1 -1
  29. package/Layers/effectLayer.js +4 -4
  30. package/Layers/effectLayer.js.map +1 -1
  31. package/Lights/Shadows/shadowGenerator.js +5 -5
  32. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  33. package/Materials/Background/backgroundMaterial.js +16 -16
  34. package/Materials/Background/backgroundMaterial.js.map +1 -1
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +8 -8
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/Blocks/Dual/fogBlock.js +2 -2
  38. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  39. package/Materials/Node/Blocks/Dual/lightBlock.js +6 -6
  40. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  41. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +2 -2
  42. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  43. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +7 -7
  44. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  45. package/Materials/Node/Blocks/Vertex/bonesBlock.js +3 -3
  46. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  47. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +3 -3
  48. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  49. package/Materials/Node/nodeMaterial.js +3 -3
  50. package/Materials/Node/nodeMaterial.js.map +1 -1
  51. package/Materials/PBR/pbrAnisotropicConfiguration.js +3 -3
  52. package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
  53. package/Materials/PBR/pbrBaseMaterial.js +41 -41
  54. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  55. package/Materials/PBR/pbrClearCoatConfiguration.js +10 -10
  56. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  57. package/Materials/PBR/pbrIridescenceConfiguration.js +6 -6
  58. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  59. package/Materials/PBR/pbrSheenConfiguration.js +6 -6
  60. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  61. package/Materials/PBR/pbrSubSurfaceConfiguration.js +7 -7
  62. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  63. package/Materials/Textures/Loaders/ktxTextureLoader.js +1 -1
  64. package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
  65. package/Materials/Textures/dynamicTexture.js +1 -1
  66. package/Materials/Textures/dynamicTexture.js.map +1 -1
  67. package/Materials/Textures/texture.js +1 -1
  68. package/Materials/Textures/texture.js.map +1 -1
  69. package/Materials/index.d.ts +1 -0
  70. package/Materials/index.js +1 -0
  71. package/Materials/index.js.map +1 -1
  72. package/Materials/material.decalMapConfiguration.js +3 -3
  73. package/Materials/material.decalMapConfiguration.js.map +1 -1
  74. package/Materials/material.detailMapConfiguration.js +3 -3
  75. package/Materials/material.detailMapConfiguration.js.map +1 -1
  76. package/Materials/material.js +2 -2
  77. package/Materials/material.js.map +1 -1
  78. package/Materials/materialHelper.d.ts +1 -4
  79. package/Materials/materialHelper.functions.d.ts +275 -0
  80. package/Materials/materialHelper.functions.js +823 -0
  81. package/Materials/materialHelper.functions.js.map +1 -0
  82. package/Materials/materialHelper.js +64 -589
  83. package/Materials/materialHelper.js.map +1 -1
  84. package/Materials/materialPluginBase.d.ts +1 -1
  85. package/Materials/materialPluginBase.js +1 -1
  86. package/Materials/materialPluginBase.js.map +1 -1
  87. package/Materials/shaderMaterial.js +8 -8
  88. package/Materials/shaderMaterial.js.map +1 -1
  89. package/Materials/standardMaterial.js +33 -33
  90. package/Materials/standardMaterial.js.map +1 -1
  91. package/Meshes/Compression/dracoCompression.d.ts +23 -2
  92. package/Meshes/Compression/dracoCompression.js +76 -236
  93. package/Meshes/Compression/dracoCompression.js.map +1 -1
  94. package/Meshes/Compression/dracoCompressionWorker.d.ts +44 -0
  95. package/Meshes/Compression/dracoCompressionWorker.js +189 -0
  96. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -0
  97. package/Meshes/trailMesh.js +1 -1
  98. package/Meshes/trailMesh.js.map +1 -1
  99. package/Misc/basis.d.ts +6 -1
  100. package/Misc/basis.js +11 -231
  101. package/Misc/basis.js.map +1 -1
  102. package/Misc/basisWorker.d.ts +13 -0
  103. package/Misc/basisWorker.js +249 -0
  104. package/Misc/basisWorker.js.map +1 -0
  105. package/Misc/khronosTextureContainer2.d.ts +25 -3
  106. package/Misc/khronosTextureContainer2.js +35 -106
  107. package/Misc/khronosTextureContainer2.js.map +1 -1
  108. package/Misc/khronosTextureContainer2Worker.d.ts +12 -0
  109. package/Misc/khronosTextureContainer2Worker.js +136 -0
  110. package/Misc/khronosTextureContainer2Worker.js.map +1 -0
  111. package/Navigation/Plugins/recastJSPlugin.d.ts +1 -1
  112. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  113. package/Particles/gpuParticleSystem.js +3 -3
  114. package/Particles/gpuParticleSystem.js.map +1 -1
  115. package/Particles/particleSystem.js +7 -3
  116. package/Particles/particleSystem.js.map +1 -1
  117. package/Physics/v2/IPhysicsEnginePlugin.d.ts +8 -0
  118. package/Physics/v2/IPhysicsEnginePlugin.js +9 -0
  119. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  120. package/Physics/v2/Plugins/havokPlugin.d.ts +7 -1
  121. package/Physics/v2/Plugins/havokPlugin.js +19 -1
  122. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  123. package/PostProcesses/volumetricLightScatteringPostProcess.js +2 -2
  124. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  125. package/Rendering/depthRenderer.js +4 -4
  126. package/Rendering/depthRenderer.js.map +1 -1
  127. package/Rendering/geometryBufferRenderer.js +5 -5
  128. package/Rendering/geometryBufferRenderer.js.map +1 -1
  129. package/Rendering/outlineRenderer.js +4 -4
  130. package/Rendering/outlineRenderer.js.map +1 -1
  131. package/package.json +1 -1
  132. package/scene.d.ts +4 -4
  133. package/scene.js.map +1 -1
@@ -0,0 +1,823 @@
1
+ import { Logger } from "../Misc/logger.js";
2
+
3
+ import { Color3 } from "../Maths/math.color.js";
4
+ import { EngineStore } from "../Engines/engineStore.js";
5
+ import { LightConstants } from "../Lights/lightConstants.js";
6
+ import { prepareDefinesForClipPlanes } from "./clipPlaneMaterialHelper.js";
7
+ // Temps
8
+ const _TempFogColor = Color3.Black();
9
+ const _TmpMorphInfluencers = { NUM_MORPH_INFLUENCERS: 0 };
10
+ /**
11
+ * Binds the logarithmic depth information from the scene to the effect for the given defines.
12
+ * @param defines The generated defines used in the effect
13
+ * @param effect The effect we are binding the data to
14
+ * @param scene The scene we are willing to render with logarithmic scale for
15
+ */
16
+ export function BindLogDepth(defines, effect, scene) {
17
+ if (!defines || defines["LOGARITHMICDEPTH"] || (defines.indexOf && defines.indexOf("LOGARITHMICDEPTH") >= 0)) {
18
+ const camera = scene.activeCamera;
19
+ if (camera.mode === 1) {
20
+ Logger.Error("Logarithmic depth is not compatible with orthographic cameras!", 20);
21
+ }
22
+ effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(camera.maxZ + 1.0) / Math.LN2));
23
+ }
24
+ }
25
+ /**
26
+ * Binds the fog information from the scene to the effect for the given mesh.
27
+ * @param scene The scene the lights belongs to
28
+ * @param mesh The mesh we are binding the information to render
29
+ * @param effect The effect we are binding the data to
30
+ * @param linearSpace Defines if the fog effect is applied in linear space
31
+ */
32
+ export function BindFogParameters(scene, mesh, effect, linearSpace = false) {
33
+ if (effect && scene.fogEnabled && (!mesh || mesh.applyFog) && scene.fogMode !== 0) {
34
+ effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
35
+ // Convert fog color to linear space if used in a linear space computed shader.
36
+ if (linearSpace) {
37
+ scene.fogColor.toLinearSpaceToRef(_TempFogColor, scene.getEngine().useExactSrgbConversions);
38
+ effect.setColor3("vFogColor", _TempFogColor);
39
+ }
40
+ else {
41
+ effect.setColor3("vFogColor", scene.fogColor);
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Prepares the list of attributes required for morph targets according to the effect defines.
47
+ * @param attribs The current list of supported attribs
48
+ * @param mesh The mesh to prepare the morph targets attributes for
49
+ * @param influencers The number of influencers
50
+ */
51
+ export function PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, influencers) {
52
+ _TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = influencers;
53
+ PrepareAttributesForMorphTargets(attribs, mesh, _TmpMorphInfluencers);
54
+ }
55
+ /**
56
+ * Prepares the list of attributes required for morph targets according to the effect defines.
57
+ * @param attribs The current list of supported attribs
58
+ * @param mesh The mesh to prepare the morph targets attributes for
59
+ * @param defines The current Defines of the effect
60
+ */
61
+ export function PrepareAttributesForMorphTargets(attribs, mesh, defines) {
62
+ const influencers = defines["NUM_MORPH_INFLUENCERS"];
63
+ if (influencers > 0 && EngineStore.LastCreatedEngine) {
64
+ const maxAttributesCount = EngineStore.LastCreatedEngine.getCaps().maxVertexAttribs;
65
+ const manager = mesh.morphTargetManager;
66
+ if (manager?.isUsingTextureForTargets) {
67
+ return;
68
+ }
69
+ const normal = manager && manager.supportsNormals && defines["NORMAL"];
70
+ const tangent = manager && manager.supportsTangents && defines["TANGENT"];
71
+ const uv = manager && manager.supportsUVs && defines["UV1"];
72
+ for (let index = 0; index < influencers; index++) {
73
+ attribs.push(`position` + index);
74
+ if (normal) {
75
+ attribs.push(`normal` + index);
76
+ }
77
+ if (tangent) {
78
+ attribs.push(`tangent` + index);
79
+ }
80
+ if (uv) {
81
+ attribs.push(`uv` + "_" + index);
82
+ }
83
+ if (attribs.length > maxAttributesCount) {
84
+ Logger.Error("Cannot add more vertex attributes for mesh " + mesh.name);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * Add the list of attributes required for instances to the attribs array.
91
+ * @param attribs The current list of supported attribs
92
+ * @param needsPreviousMatrices If the shader needs previous matrices
93
+ */
94
+ export function PushAttributesForInstances(attribs, needsPreviousMatrices = false) {
95
+ attribs.push("world0");
96
+ attribs.push("world1");
97
+ attribs.push("world2");
98
+ attribs.push("world3");
99
+ if (needsPreviousMatrices) {
100
+ attribs.push("previousWorld0");
101
+ attribs.push("previousWorld1");
102
+ attribs.push("previousWorld2");
103
+ attribs.push("previousWorld3");
104
+ }
105
+ }
106
+ /**
107
+ * Binds the morph targets information from the mesh to the effect.
108
+ * @param abstractMesh The mesh we are binding the information to render
109
+ * @param effect The effect we are binding the data to
110
+ */
111
+ export function BindMorphTargetParameters(abstractMesh, effect) {
112
+ const manager = abstractMesh.morphTargetManager;
113
+ if (!abstractMesh || !manager) {
114
+ return;
115
+ }
116
+ effect.setFloatArray("morphTargetInfluences", manager.influences);
117
+ }
118
+ /**
119
+ * Binds the scene's uniform buffer to the effect.
120
+ * @param effect defines the effect to bind to the scene uniform buffer
121
+ * @param sceneUbo defines the uniform buffer storing scene data
122
+ */
123
+ export function BindSceneUniformBuffer(effect, sceneUbo) {
124
+ sceneUbo.bindToEffect(effect, "Scene");
125
+ }
126
+ /**
127
+ * Helps preparing the defines values about the UVs in used in the effect.
128
+ * UVs are shared as much as we can across channels in the shaders.
129
+ * @param texture The texture we are preparing the UVs for
130
+ * @param defines The defines to update
131
+ * @param key The channel key "diffuse", "specular"... used in the shader
132
+ */
133
+ export function PrepareDefinesForMergedUV(texture, defines, key) {
134
+ defines._needUVs = true;
135
+ defines[key] = true;
136
+ if (texture.optimizeUVAllocation && texture.getTextureMatrix().isIdentityAs3x2()) {
137
+ defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
138
+ defines["MAINUV" + (texture.coordinatesIndex + 1)] = true;
139
+ }
140
+ else {
141
+ defines[key + "DIRECTUV"] = 0;
142
+ }
143
+ }
144
+ /**
145
+ * Binds a texture matrix value to its corresponding uniform
146
+ * @param texture The texture to bind the matrix for
147
+ * @param uniformBuffer The uniform buffer receiving the data
148
+ * @param key The channel key "diffuse", "specular"... used in the shader
149
+ */
150
+ export function BindTextureMatrix(texture, uniformBuffer, key) {
151
+ const matrix = texture.getTextureMatrix();
152
+ uniformBuffer.updateMatrix(key + "Matrix", matrix);
153
+ }
154
+ /**
155
+ * Prepares the list of attributes required for baked vertex animations according to the effect defines.
156
+ * @param attribs The current list of supported attribs
157
+ * @param mesh The mesh to prepare for baked vertex animations
158
+ * @param defines The current Defines of the effect
159
+ */
160
+ export function PrepareAttributesForBakedVertexAnimation(attribs, mesh, defines) {
161
+ const enabled = defines["BAKED_VERTEX_ANIMATION_TEXTURE"] && defines["INSTANCES"];
162
+ if (enabled) {
163
+ attribs.push("bakedVertexAnimationSettingsInstanced");
164
+ }
165
+ }
166
+ // Copies the bones transformation matrices into the target array and returns the target's reference
167
+ function _CopyBonesTransformationMatrices(source, target) {
168
+ target.set(source);
169
+ return target;
170
+ }
171
+ /**
172
+ * Binds the bones information from the mesh to the effect.
173
+ * @param mesh The mesh we are binding the information to render
174
+ * @param effect The effect we are binding the data to
175
+ * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
176
+ */
177
+ export function BindBonesParameters(mesh, effect, prePassConfiguration) {
178
+ if (!effect || !mesh) {
179
+ return;
180
+ }
181
+ if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
182
+ mesh.computeBonesUsingShaders = false;
183
+ }
184
+ if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
185
+ const skeleton = mesh.skeleton;
186
+ if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
187
+ const boneTexture = skeleton.getTransformMatrixTexture(mesh);
188
+ effect.setTexture("boneSampler", boneTexture);
189
+ effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
190
+ }
191
+ else {
192
+ const matrices = skeleton.getTransformMatrices(mesh);
193
+ if (matrices) {
194
+ effect.setMatrices("mBones", matrices);
195
+ if (prePassConfiguration && mesh.getScene().prePassRenderer && mesh.getScene().prePassRenderer.getIndex(2)) {
196
+ if (!prePassConfiguration.previousBones[mesh.uniqueId]) {
197
+ prePassConfiguration.previousBones[mesh.uniqueId] = matrices.slice();
198
+ }
199
+ effect.setMatrices("mPreviousBones", prePassConfiguration.previousBones[mesh.uniqueId]);
200
+ _CopyBonesTransformationMatrices(matrices, prePassConfiguration.previousBones[mesh.uniqueId]);
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ /**
207
+ * Binds the light information to the effect.
208
+ * @param light The light containing the generator
209
+ * @param effect The effect we are binding the data to
210
+ * @param lightIndex The light index in the effect used to render
211
+ */
212
+ export function BindLightProperties(light, effect, lightIndex) {
213
+ light.transferToEffect(effect, lightIndex + "");
214
+ }
215
+ /**
216
+ * Binds the lights information from the scene to the effect for the given mesh.
217
+ * @param light Light to bind
218
+ * @param lightIndex Light index
219
+ * @param scene The scene where the light belongs to
220
+ * @param effect The effect we are binding the data to
221
+ * @param useSpecular Defines if specular is supported
222
+ * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows
223
+ */
224
+ export function BindLight(light, lightIndex, scene, effect, useSpecular, receiveShadows = true) {
225
+ light._bindLight(lightIndex, scene, effect, useSpecular, receiveShadows);
226
+ }
227
+ /**
228
+ * Binds the lights information from the scene to the effect for the given mesh.
229
+ * @param scene The scene the lights belongs to
230
+ * @param mesh The mesh we are binding the information to render
231
+ * @param effect The effect we are binding the data to
232
+ * @param defines The generated defines for the effect
233
+ * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
234
+ */
235
+ export function BindLights(scene, mesh, effect, defines, maxSimultaneousLights = 4) {
236
+ const len = Math.min(mesh.lightSources.length, maxSimultaneousLights);
237
+ for (let i = 0; i < len; i++) {
238
+ const light = mesh.lightSources[i];
239
+ BindLight(light, i, scene, effect, typeof defines === "boolean" ? defines : defines["SPECULARTERM"], mesh.receiveShadows);
240
+ }
241
+ }
242
+ /**
243
+ * Prepares the list of attributes required for bones according to the effect defines.
244
+ * @param attribs The current list of supported attribs
245
+ * @param mesh The mesh to prepare the bones attributes for
246
+ * @param defines The current Defines of the effect
247
+ * @param fallbacks The current effect fallback strategy
248
+ */
249
+ export function PrepareAttributesForBones(attribs, mesh, defines, fallbacks) {
250
+ if (defines["NUM_BONE_INFLUENCERS"] > 0) {
251
+ fallbacks.addCPUSkinningFallback(0, mesh);
252
+ attribs.push(`matricesIndices`);
253
+ attribs.push(`matricesWeights`);
254
+ if (defines["NUM_BONE_INFLUENCERS"] > 4) {
255
+ attribs.push(`matricesIndicesExtra`);
256
+ attribs.push(`matricesWeightsExtra`);
257
+ }
258
+ }
259
+ }
260
+ /**
261
+ * Check and prepare the list of attributes required for instances according to the effect defines.
262
+ * @param attribs The current list of supported attribs
263
+ * @param defines The current MaterialDefines of the effect
264
+ */
265
+ export function PrepareAttributesForInstances(attribs, defines) {
266
+ if (defines["INSTANCES"] || defines["THIN_INSTANCES"]) {
267
+ PushAttributesForInstances(attribs, !!defines["PREPASS_VELOCITY"]);
268
+ }
269
+ if (defines.INSTANCESCOLOR) {
270
+ attribs.push(`instanceColor`);
271
+ }
272
+ }
273
+ /**
274
+ * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
275
+ * @param defines The defines to update while falling back
276
+ * @param fallbacks The authorized effect fallbacks
277
+ * @param maxSimultaneousLights The maximum number of lights allowed
278
+ * @param rank the current rank of the Effect
279
+ * @returns The newly affected rank
280
+ */
281
+ export function HandleFallbacksForShadows(defines, fallbacks, maxSimultaneousLights = 4, rank = 0) {
282
+ let lightFallbackRank = 0;
283
+ for (let lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
284
+ if (!defines["LIGHT" + lightIndex]) {
285
+ break;
286
+ }
287
+ if (lightIndex > 0) {
288
+ lightFallbackRank = rank + lightIndex;
289
+ fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
290
+ }
291
+ if (!defines["SHADOWS"]) {
292
+ if (defines["SHADOW" + lightIndex]) {
293
+ fallbacks.addFallback(rank, "SHADOW" + lightIndex);
294
+ }
295
+ if (defines["SHADOWPCF" + lightIndex]) {
296
+ fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
297
+ }
298
+ if (defines["SHADOWPCSS" + lightIndex]) {
299
+ fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
300
+ }
301
+ if (defines["SHADOWPOISSON" + lightIndex]) {
302
+ fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
303
+ }
304
+ if (defines["SHADOWESM" + lightIndex]) {
305
+ fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
306
+ }
307
+ if (defines["SHADOWCLOSEESM" + lightIndex]) {
308
+ fallbacks.addFallback(rank, "SHADOWCLOSEESM" + lightIndex);
309
+ }
310
+ }
311
+ }
312
+ return lightFallbackRank++;
313
+ }
314
+ /**
315
+ * Gets the current status of the fog (should it be enabled?)
316
+ * @param mesh defines the mesh to evaluate for fog support
317
+ * @param scene defines the hosting scene
318
+ * @returns true if fog must be enabled
319
+ */
320
+ export function GetFogState(mesh, scene) {
321
+ return scene.fogEnabled && mesh.applyFog && scene.fogMode !== 0;
322
+ }
323
+ /**
324
+ * Helper used to prepare the list of defines associated with misc. values for shader compilation
325
+ * @param mesh defines the current mesh
326
+ * @param scene defines the current scene
327
+ * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
328
+ * @param pointsCloud defines if point cloud rendering has to be turned on
329
+ * @param fogEnabled defines if fog has to be turned on
330
+ * @param alphaTest defines if alpha testing has to be turned on
331
+ * @param defines defines the current list of defines
332
+ * @param applyDecalAfterDetail Defines if the decal is applied after or before the detail
333
+ */
334
+ export function PrepareDefinesForMisc(mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines, applyDecalAfterDetail = false) {
335
+ if (defines._areMiscDirty) {
336
+ defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
337
+ defines["POINTSIZE"] = pointsCloud;
338
+ defines["FOG"] = fogEnabled && GetFogState(mesh, scene);
339
+ defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
340
+ defines["ALPHATEST"] = alphaTest;
341
+ defines["DECAL_AFTER_DETAIL"] = applyDecalAfterDetail;
342
+ }
343
+ }
344
+ /**
345
+ * Prepares the defines related to the light information passed in parameter
346
+ * @param scene The scene we are intending to draw
347
+ * @param mesh The mesh the effect is compiling for
348
+ * @param defines The defines to update
349
+ * @param specularSupported Specifies whether specular is supported or not (override lights data)
350
+ * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
351
+ * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
352
+ * @returns true if normals will be required for the rest of the effect
353
+ */
354
+ export function PrepareDefinesForLights(scene, mesh, defines, specularSupported, maxSimultaneousLights = 4, disableLighting = false) {
355
+ if (!defines._areLightsDirty) {
356
+ return defines._needNormals;
357
+ }
358
+ let lightIndex = 0;
359
+ const state = {
360
+ needNormals: defines._needNormals,
361
+ needRebuild: false,
362
+ lightmapMode: false,
363
+ shadowEnabled: false,
364
+ specularEnabled: false,
365
+ };
366
+ if (scene.lightsEnabled && !disableLighting) {
367
+ for (const light of mesh.lightSources) {
368
+ PrepareDefinesForLight(scene, mesh, light, lightIndex, defines, specularSupported, state);
369
+ lightIndex++;
370
+ if (lightIndex === maxSimultaneousLights) {
371
+ break;
372
+ }
373
+ }
374
+ }
375
+ defines["SPECULARTERM"] = state.specularEnabled;
376
+ defines["SHADOWS"] = state.shadowEnabled;
377
+ // Resetting all other lights if any
378
+ for (let index = lightIndex; index < maxSimultaneousLights; index++) {
379
+ if (defines["LIGHT" + index] !== undefined) {
380
+ defines["LIGHT" + index] = false;
381
+ defines["HEMILIGHT" + index] = false;
382
+ defines["POINTLIGHT" + index] = false;
383
+ defines["DIRLIGHT" + index] = false;
384
+ defines["SPOTLIGHT" + index] = false;
385
+ defines["SHADOW" + index] = false;
386
+ defines["SHADOWCSM" + index] = false;
387
+ defines["SHADOWCSMDEBUG" + index] = false;
388
+ defines["SHADOWCSMNUM_CASCADES" + index] = false;
389
+ defines["SHADOWCSMUSESHADOWMAXZ" + index] = false;
390
+ defines["SHADOWCSMNOBLEND" + index] = false;
391
+ defines["SHADOWCSM_RIGHTHANDED" + index] = false;
392
+ defines["SHADOWPCF" + index] = false;
393
+ defines["SHADOWPCSS" + index] = false;
394
+ defines["SHADOWPOISSON" + index] = false;
395
+ defines["SHADOWESM" + index] = false;
396
+ defines["SHADOWCLOSEESM" + index] = false;
397
+ defines["SHADOWCUBE" + index] = false;
398
+ defines["SHADOWLOWQUALITY" + index] = false;
399
+ defines["SHADOWMEDIUMQUALITY" + index] = false;
400
+ }
401
+ }
402
+ const caps = scene.getEngine().getCaps();
403
+ if (defines["SHADOWFLOAT"] === undefined) {
404
+ state.needRebuild = true;
405
+ }
406
+ defines["SHADOWFLOAT"] =
407
+ state.shadowEnabled && ((caps.textureFloatRender && caps.textureFloatLinearFiltering) || (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
408
+ defines["LIGHTMAPEXCLUDED"] = state.lightmapMode;
409
+ if (state.needRebuild) {
410
+ defines.rebuild();
411
+ }
412
+ return state.needNormals;
413
+ }
414
+ /**
415
+ * Prepares the defines related to the light information passed in parameter
416
+ * @param scene The scene we are intending to draw
417
+ * @param mesh The mesh the effect is compiling for
418
+ * @param light The light the effect is compiling for
419
+ * @param lightIndex The index of the light
420
+ * @param defines The defines to update
421
+ * @param specularSupported Specifies whether specular is supported or not (override lights data)
422
+ * @param state Defines the current state regarding what is needed (normals, etc...)
423
+ * @param state.needNormals
424
+ * @param state.needRebuild
425
+ * @param state.shadowEnabled
426
+ * @param state.specularEnabled
427
+ * @param state.lightmapMode
428
+ */
429
+ export function PrepareDefinesForLight(scene, mesh, light, lightIndex, defines, specularSupported, state) {
430
+ state.needNormals = true;
431
+ if (defines["LIGHT" + lightIndex] === undefined) {
432
+ state.needRebuild = true;
433
+ }
434
+ defines["LIGHT" + lightIndex] = true;
435
+ defines["SPOTLIGHT" + lightIndex] = false;
436
+ defines["HEMILIGHT" + lightIndex] = false;
437
+ defines["POINTLIGHT" + lightIndex] = false;
438
+ defines["DIRLIGHT" + lightIndex] = false;
439
+ light.prepareLightSpecificDefines(defines, lightIndex);
440
+ // FallOff.
441
+ defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
442
+ defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
443
+ defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
444
+ switch (light.falloffType) {
445
+ case LightConstants.FALLOFF_GLTF:
446
+ defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
447
+ break;
448
+ case LightConstants.FALLOFF_PHYSICAL:
449
+ defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
450
+ break;
451
+ case LightConstants.FALLOFF_STANDARD:
452
+ defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
453
+ break;
454
+ }
455
+ // Specular
456
+ if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
457
+ state.specularEnabled = true;
458
+ }
459
+ // Shadows
460
+ defines["SHADOW" + lightIndex] = false;
461
+ defines["SHADOWCSM" + lightIndex] = false;
462
+ defines["SHADOWCSMDEBUG" + lightIndex] = false;
463
+ defines["SHADOWCSMNUM_CASCADES" + lightIndex] = false;
464
+ defines["SHADOWCSMUSESHADOWMAXZ" + lightIndex] = false;
465
+ defines["SHADOWCSMNOBLEND" + lightIndex] = false;
466
+ defines["SHADOWCSM_RIGHTHANDED" + lightIndex] = false;
467
+ defines["SHADOWPCF" + lightIndex] = false;
468
+ defines["SHADOWPCSS" + lightIndex] = false;
469
+ defines["SHADOWPOISSON" + lightIndex] = false;
470
+ defines["SHADOWESM" + lightIndex] = false;
471
+ defines["SHADOWCLOSEESM" + lightIndex] = false;
472
+ defines["SHADOWCUBE" + lightIndex] = false;
473
+ defines["SHADOWLOWQUALITY" + lightIndex] = false;
474
+ defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
475
+ if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
476
+ const shadowGenerator = light.getShadowGenerator(scene.activeCamera) ?? light.getShadowGenerator();
477
+ if (shadowGenerator) {
478
+ const shadowMap = shadowGenerator.getShadowMap();
479
+ if (shadowMap) {
480
+ if (shadowMap.renderList && shadowMap.renderList.length > 0) {
481
+ state.shadowEnabled = true;
482
+ shadowGenerator.prepareDefines(defines, lightIndex);
483
+ }
484
+ }
485
+ }
486
+ }
487
+ if (light.lightmapMode != LightConstants.LIGHTMAP_DEFAULT) {
488
+ state.lightmapMode = true;
489
+ defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
490
+ defines["LIGHTMAPNOSPECULAR" + lightIndex] = light.lightmapMode == LightConstants.LIGHTMAP_SHADOWSONLY;
491
+ }
492
+ else {
493
+ defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
494
+ defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
495
+ }
496
+ }
497
+ /**
498
+ * Helper used to prepare the list of defines associated with frame values for shader compilation
499
+ * @param scene defines the current scene
500
+ * @param engine defines the current engine
501
+ * @param material defines the material we are compiling the shader for
502
+ * @param defines specifies the list of active defines
503
+ * @param useInstances defines if instances have to be turned on
504
+ * @param useClipPlane defines if clip plane have to be turned on
505
+ * @param useThinInstances defines if thin instances have to be turned on
506
+ */
507
+ export function PrepareDefinesForFrameBoundValues(scene, engine, material, defines, useInstances, useClipPlane = null, useThinInstances = false) {
508
+ let changed = PrepareDefinesForCamera(scene, defines);
509
+ if (useClipPlane !== false) {
510
+ changed = prepareDefinesForClipPlanes(material, scene, defines);
511
+ }
512
+ if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
513
+ defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
514
+ changed = true;
515
+ }
516
+ if (defines["INSTANCES"] !== useInstances) {
517
+ defines["INSTANCES"] = useInstances;
518
+ changed = true;
519
+ }
520
+ if (defines["THIN_INSTANCES"] !== useThinInstances) {
521
+ defines["THIN_INSTANCES"] = useThinInstances;
522
+ changed = true;
523
+ }
524
+ if (changed) {
525
+ defines.markAsUnprocessed();
526
+ }
527
+ }
528
+ /**
529
+ * Prepares the defines for bones
530
+ * @param mesh The mesh containing the geometry data we will draw
531
+ * @param defines The defines to update
532
+ */
533
+ export function PrepareDefinesForBones(mesh, defines) {
534
+ if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
535
+ defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
536
+ const materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
537
+ if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
538
+ defines["BONETEXTURE"] = true;
539
+ }
540
+ else {
541
+ defines["BonesPerMesh"] = mesh.skeleton.bones.length + 1;
542
+ defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
543
+ const prePassRenderer = mesh.getScene().prePassRenderer;
544
+ if (prePassRenderer && prePassRenderer.enabled) {
545
+ const nonExcluded = prePassRenderer.excludedSkinnedMesh.indexOf(mesh) === -1;
546
+ defines["BONES_VELOCITY_ENABLED"] = nonExcluded;
547
+ }
548
+ }
549
+ }
550
+ else {
551
+ defines["NUM_BONE_INFLUENCERS"] = 0;
552
+ defines["BonesPerMesh"] = 0;
553
+ if (defines["BONETEXTURE"] !== undefined) {
554
+ defines["BONETEXTURE"] = false;
555
+ }
556
+ }
557
+ }
558
+ /**
559
+ * Prepares the defines for morph targets
560
+ * @param mesh The mesh containing the geometry data we will draw
561
+ * @param defines The defines to update
562
+ */
563
+ export function PrepareDefinesForMorphTargets(mesh, defines) {
564
+ const manager = mesh.morphTargetManager;
565
+ if (manager) {
566
+ defines["MORPHTARGETS_UV"] = manager.supportsUVs && defines["UV1"];
567
+ defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
568
+ defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
569
+ defines["NUM_MORPH_INFLUENCERS"] = manager.numMaxInfluencers || manager.numInfluencers;
570
+ defines["MORPHTARGETS"] = defines["NUM_MORPH_INFLUENCERS"] > 0;
571
+ defines["MORPHTARGETS_TEXTURE"] = manager.isUsingTextureForTargets;
572
+ }
573
+ else {
574
+ defines["MORPHTARGETS_UV"] = false;
575
+ defines["MORPHTARGETS_TANGENT"] = false;
576
+ defines["MORPHTARGETS_NORMAL"] = false;
577
+ defines["MORPHTARGETS"] = false;
578
+ defines["NUM_MORPH_INFLUENCERS"] = 0;
579
+ }
580
+ }
581
+ /**
582
+ * Prepares the defines for baked vertex animation
583
+ * @param mesh The mesh containing the geometry data we will draw
584
+ * @param defines The defines to update
585
+ */
586
+ export function PrepareDefinesForBakedVertexAnimation(mesh, defines) {
587
+ const manager = mesh.bakedVertexAnimationManager;
588
+ defines["BAKED_VERTEX_ANIMATION_TEXTURE"] = manager && manager.isEnabled ? true : false;
589
+ }
590
+ /**
591
+ * Prepares the defines used in the shader depending on the attributes data available in the mesh
592
+ * @param mesh The mesh containing the geometry data we will draw
593
+ * @param defines The defines to update
594
+ * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
595
+ * @param useBones Precise whether bones should be used or not (override mesh info)
596
+ * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
597
+ * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
598
+ * @param useBakedVertexAnimation Precise whether baked vertex animation should be used or not (override mesh info)
599
+ * @returns false if defines are considered not dirty and have not been checked
600
+ */
601
+ export function PrepareDefinesForAttributes(mesh, defines, useVertexColor, useBones, useMorphTargets = false, useVertexAlpha = true, useBakedVertexAnimation = true) {
602
+ if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
603
+ return false;
604
+ }
605
+ defines._normals = defines._needNormals;
606
+ defines._uvs = defines._needUVs;
607
+ defines["NORMAL"] = defines._needNormals && mesh.isVerticesDataPresent(`normal`);
608
+ if (defines._needNormals && mesh.isVerticesDataPresent(`tangent`)) {
609
+ defines["TANGENT"] = true;
610
+ }
611
+ for (let i = 1; i <= 6; ++i) {
612
+ defines["UV" + i] = defines._needUVs ? mesh.isVerticesDataPresent(`uv${i === 1 ? "" : i}`) : false;
613
+ }
614
+ if (useVertexColor) {
615
+ const hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(`color`);
616
+ defines["VERTEXCOLOR"] = hasVertexColors;
617
+ defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
618
+ }
619
+ if (mesh.isVerticesDataPresent(`instanceColor`) && (mesh.hasInstances || mesh.hasThinInstances)) {
620
+ defines["INSTANCESCOLOR"] = true;
621
+ }
622
+ if (useBones) {
623
+ PrepareDefinesForBones(mesh, defines);
624
+ }
625
+ if (useMorphTargets) {
626
+ PrepareDefinesForMorphTargets(mesh, defines);
627
+ }
628
+ if (useBakedVertexAnimation) {
629
+ PrepareDefinesForBakedVertexAnimation(mesh, defines);
630
+ }
631
+ return true;
632
+ }
633
+ /**
634
+ * Prepares the defines related to multiview
635
+ * @param scene The scene we are intending to draw
636
+ * @param defines The defines to update
637
+ */
638
+ export function PrepareDefinesForMultiview(scene, defines) {
639
+ if (scene.activeCamera) {
640
+ const previousMultiview = defines.MULTIVIEW;
641
+ defines.MULTIVIEW = scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1;
642
+ if (defines.MULTIVIEW != previousMultiview) {
643
+ defines.markAsUnprocessed();
644
+ }
645
+ }
646
+ }
647
+ /**
648
+ * Prepares the defines related to order independant transparency
649
+ * @param scene The scene we are intending to draw
650
+ * @param defines The defines to update
651
+ * @param needAlphaBlending Determines if the material needs alpha blending
652
+ */
653
+ export function PrepareDefinesForOIT(scene, defines, needAlphaBlending) {
654
+ const previousDefine = defines.ORDER_INDEPENDENT_TRANSPARENCY;
655
+ const previousDefine16Bits = defines.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
656
+ defines.ORDER_INDEPENDENT_TRANSPARENCY = scene.useOrderIndependentTransparency && needAlphaBlending;
657
+ defines.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !scene.getEngine().getCaps().textureFloatLinearFiltering;
658
+ if (previousDefine !== defines.ORDER_INDEPENDENT_TRANSPARENCY || previousDefine16Bits !== defines.ORDER_INDEPENDENT_TRANSPARENCY_16BITS) {
659
+ defines.markAsUnprocessed();
660
+ }
661
+ }
662
+ /**
663
+ * Prepares the defines related to the prepass
664
+ * @param scene The scene we are intending to draw
665
+ * @param defines The defines to update
666
+ * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
667
+ */
668
+ export function PrepareDefinesForPrePass(scene, defines, canRenderToMRT) {
669
+ const previousPrePass = defines.PREPASS;
670
+ if (!defines._arePrePassDirty) {
671
+ return;
672
+ }
673
+ const texturesList = [
674
+ {
675
+ type: 1,
676
+ define: "PREPASS_POSITION",
677
+ index: "PREPASS_POSITION_INDEX",
678
+ },
679
+ {
680
+ type: 2,
681
+ define: "PREPASS_VELOCITY",
682
+ index: "PREPASS_VELOCITY_INDEX",
683
+ },
684
+ {
685
+ type: 3,
686
+ define: "PREPASS_REFLECTIVITY",
687
+ index: "PREPASS_REFLECTIVITY_INDEX",
688
+ },
689
+ {
690
+ type: 0,
691
+ define: "PREPASS_IRRADIANCE",
692
+ index: "PREPASS_IRRADIANCE_INDEX",
693
+ },
694
+ {
695
+ type: 7,
696
+ define: "PREPASS_ALBEDO_SQRT",
697
+ index: "PREPASS_ALBEDO_SQRT_INDEX",
698
+ },
699
+ {
700
+ type: 5,
701
+ define: "PREPASS_DEPTH",
702
+ index: "PREPASS_DEPTH_INDEX",
703
+ },
704
+ {
705
+ type: 6,
706
+ define: "PREPASS_NORMAL",
707
+ index: "PREPASS_NORMAL_INDEX",
708
+ },
709
+ ];
710
+ if (scene.prePassRenderer && scene.prePassRenderer.enabled && canRenderToMRT) {
711
+ defines.PREPASS = true;
712
+ defines.SCENE_MRT_COUNT = scene.prePassRenderer.mrtCount;
713
+ defines.PREPASS_NORMAL_WORLDSPACE = scene.prePassRenderer.generateNormalsInWorldSpace;
714
+ for (let i = 0; i < texturesList.length; i++) {
715
+ const index = scene.prePassRenderer.getIndex(texturesList[i].type);
716
+ if (index !== -1) {
717
+ defines[texturesList[i].define] = true;
718
+ defines[texturesList[i].index] = index;
719
+ }
720
+ else {
721
+ defines[texturesList[i].define] = false;
722
+ }
723
+ }
724
+ }
725
+ else {
726
+ defines.PREPASS = false;
727
+ for (let i = 0; i < texturesList.length; i++) {
728
+ defines[texturesList[i].define] = false;
729
+ }
730
+ }
731
+ if (defines.PREPASS != previousPrePass) {
732
+ defines.markAsUnprocessed();
733
+ defines.markAsImageProcessingDirty();
734
+ }
735
+ }
736
+ /**
737
+ * Helper used to prepare the defines relative to the active camera
738
+ * @param scene defines the current scene
739
+ * @param defines specifies the list of active defines
740
+ * @returns true if the defines have been updated, else false
741
+ */
742
+ export function PrepareDefinesForCamera(scene, defines) {
743
+ let changed = false;
744
+ if (scene.activeCamera) {
745
+ const wasOrtho = defines["CAMERA_ORTHOGRAPHIC"] ? 1 : 0;
746
+ const wasPersp = defines["CAMERA_PERSPECTIVE"] ? 1 : 0;
747
+ const isOrtho = scene.activeCamera.mode === 1 ? 1 : 0;
748
+ const isPersp = scene.activeCamera.mode === 0 ? 1 : 0;
749
+ if (wasOrtho ^ isOrtho || wasPersp ^ isPersp) {
750
+ defines["CAMERA_ORTHOGRAPHIC"] = isOrtho === 1;
751
+ defines["CAMERA_PERSPECTIVE"] = isPersp === 1;
752
+ changed = true;
753
+ }
754
+ }
755
+ return changed;
756
+ }
757
+ /**
758
+ * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
759
+ * @param lightIndex defines the light index
760
+ * @param uniformsList The uniform list
761
+ * @param samplersList The sampler list
762
+ * @param projectedLightTexture defines if projected texture must be used
763
+ * @param uniformBuffersList defines an optional list of uniform buffers
764
+ * @param updateOnlyBuffersList True to only update the uniformBuffersList array
765
+ */
766
+ export function PrepareUniformsAndSamplersForLight(lightIndex, uniformsList, samplersList, projectedLightTexture, uniformBuffersList = null, updateOnlyBuffersList = false) {
767
+ if (uniformBuffersList) {
768
+ uniformBuffersList.push("Light" + lightIndex);
769
+ }
770
+ if (updateOnlyBuffersList) {
771
+ return;
772
+ }
773
+ uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
774
+ samplersList.push("shadowSampler" + lightIndex);
775
+ samplersList.push("depthSampler" + lightIndex);
776
+ uniformsList.push("viewFrustumZ" + lightIndex, "cascadeBlendFactor" + lightIndex, "lightSizeUVCorrection" + lightIndex, "depthCorrection" + lightIndex, "penumbraDarkness" + lightIndex, "frustumLengths" + lightIndex);
777
+ if (projectedLightTexture) {
778
+ samplersList.push("projectionLightSampler" + lightIndex);
779
+ uniformsList.push("textureProjectionMatrix" + lightIndex);
780
+ }
781
+ }
782
+ /**
783
+ * Prepares the uniforms and samplers list to be used in the effect
784
+ * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
785
+ * @param samplersList The sampler list
786
+ * @param defines The defines helping in the list generation
787
+ * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
788
+ */
789
+ export function PrepareUniformsAndSamplersList(uniformsListOrOptions, samplersList, defines, maxSimultaneousLights = 4) {
790
+ let uniformsList;
791
+ let uniformBuffersList = null;
792
+ if (uniformsListOrOptions.uniformsNames) {
793
+ const options = uniformsListOrOptions;
794
+ uniformsList = options.uniformsNames;
795
+ uniformBuffersList = options.uniformBuffersNames;
796
+ samplersList = options.samplers;
797
+ defines = options.defines;
798
+ maxSimultaneousLights = options.maxSimultaneousLights || 0;
799
+ }
800
+ else {
801
+ uniformsList = uniformsListOrOptions;
802
+ if (!samplersList) {
803
+ samplersList = [];
804
+ }
805
+ }
806
+ for (let lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
807
+ if (!defines["LIGHT" + lightIndex]) {
808
+ break;
809
+ }
810
+ PrepareUniformsAndSamplersForLight(lightIndex, uniformsList, samplersList, defines["PROJECTEDLIGHTTEXTURE" + lightIndex], uniformBuffersList);
811
+ }
812
+ if (defines["NUM_MORPH_INFLUENCERS"]) {
813
+ uniformsList.push("morphTargetInfluences");
814
+ uniformsList.push("morphTargetCount");
815
+ }
816
+ if (defines["BAKED_VERTEX_ANIMATION_TEXTURE"]) {
817
+ uniformsList.push("bakedVertexAnimationSettings");
818
+ uniformsList.push("bakedVertexAnimationTextureSizeInverted");
819
+ uniformsList.push("bakedVertexAnimationTime");
820
+ samplersList.push("bakedVertexAnimationTexture");
821
+ }
822
+ }
823
+ //# sourceMappingURL=materialHelper.functions.js.map