@babylonjs/core 7.42.0 → 7.43.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 (169) hide show
  1. package/Animations/animation.js +1 -1
  2. package/Animations/animation.js.map +1 -1
  3. package/Culling/Helper/computeShaderBoundingHelper.js +3 -4
  4. package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
  5. package/Culling/Helper/transformFeedbackBoundingHelper.js +27 -64
  6. package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
  7. package/Engines/Extensions/engine.multiRender.js +3 -2
  8. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  9. package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
  10. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +5 -0
  11. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  12. package/Engines/WebGPU/webgpuTextureManager.js +6 -1
  13. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  14. package/Engines/abstractEngine.js +2 -2
  15. package/Engines/abstractEngine.js.map +1 -1
  16. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +64 -0
  17. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +147 -0
  18. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -0
  19. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +0 -15
  20. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  21. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +4 -0
  22. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +9 -0
  23. package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
  24. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +1 -6
  25. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +0 -13
  26. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
  27. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +0 -1
  28. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  30. package/FrameGraph/Node/Blocks/index.js +1 -0
  31. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  32. package/FrameGraph/Node/nodeRenderGraphBlock.js +17 -0
  33. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  34. package/FrameGraph/Passes/renderPass.d.ts +0 -8
  35. package/FrameGraph/Passes/renderPass.js +0 -10
  36. package/FrameGraph/Passes/renderPass.js.map +1 -1
  37. package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +57 -0
  38. package/FrameGraph/Tasks/Layers/glowLayerTask.js +173 -0
  39. package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -0
  40. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
  41. package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
  42. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +7 -0
  43. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  44. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +1 -1
  45. package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
  46. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
  47. package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
  48. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +5 -5
  49. package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
  50. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +12 -4
  51. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  52. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +1 -1
  53. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  54. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +0 -8
  55. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +1 -17
  56. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
  57. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -0
  58. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  59. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -6
  60. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +20 -22
  61. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  62. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +7 -1
  63. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +21 -5
  64. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
  65. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +4 -6
  66. package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
  67. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
  68. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  69. package/FrameGraph/frameGraph.js +22 -11
  70. package/FrameGraph/frameGraph.js.map +1 -1
  71. package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
  72. package/FrameGraph/frameGraphRenderContext.js +2 -1
  73. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  74. package/FrameGraph/frameGraphTask.d.ts +11 -1
  75. package/FrameGraph/frameGraphTask.js +8 -0
  76. package/FrameGraph/frameGraphTask.js.map +1 -1
  77. package/FrameGraph/frameGraphTextureManager.d.ts +8 -2
  78. package/FrameGraph/frameGraphTextureManager.js +10 -4
  79. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  80. package/FrameGraph/index.d.ts +1 -0
  81. package/FrameGraph/index.js +1 -0
  82. package/FrameGraph/index.js.map +1 -1
  83. package/Layers/effectLayer.d.ts +32 -33
  84. package/Layers/effectLayer.js +144 -530
  85. package/Layers/effectLayer.js.map +1 -1
  86. package/Layers/glowLayer.d.ts +14 -41
  87. package/Layers/glowLayer.js +92 -178
  88. package/Layers/glowLayer.js.map +1 -1
  89. package/Layers/highlightLayer.d.ts +0 -1
  90. package/Layers/highlightLayer.js +0 -1
  91. package/Layers/highlightLayer.js.map +1 -1
  92. package/Layers/index.d.ts +2 -0
  93. package/Layers/index.js +2 -0
  94. package/Layers/index.js.map +1 -1
  95. package/Layers/thinEffectLayer.d.ts +230 -0
  96. package/Layers/thinEffectLayer.js +734 -0
  97. package/Layers/thinEffectLayer.js.map +1 -0
  98. package/Layers/thinGlowLayer.d.ts +141 -0
  99. package/Layers/thinGlowLayer.js +292 -0
  100. package/Layers/thinGlowLayer.js.map +1 -0
  101. package/Lights/Shadows/shadowGenerator.js +40 -19
  102. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  103. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +17 -11
  104. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
  105. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +18 -12
  106. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
  107. package/Materials/Node/Blocks/Input/inputBlock.js +34 -2
  108. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  109. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +34 -24
  110. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  111. package/Materials/Node/nodeMaterial.d.ts +10 -0
  112. package/Materials/Node/nodeMaterial.js +12 -0
  113. package/Materials/Node/nodeMaterial.js.map +1 -1
  114. package/Materials/PBR/pbrBaseMaterial.d.ts +5 -0
  115. package/Materials/PBR/pbrBaseMaterial.js +5 -0
  116. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  117. package/Materials/Textures/renderTargetTexture.d.ts +12 -0
  118. package/Materials/Textures/renderTargetTexture.js +29 -8
  119. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  120. package/Materials/materialHelper.functions.d.ts +17 -1
  121. package/Materials/materialHelper.functions.js +76 -4
  122. package/Materials/materialHelper.functions.js.map +1 -1
  123. package/Materials/shaderMaterial.d.ts +5 -4
  124. package/Materials/shaderMaterial.js +28 -51
  125. package/Materials/shaderMaterial.js.map +1 -1
  126. package/Materials/standardMaterial.d.ts +5 -0
  127. package/Materials/standardMaterial.js +5 -0
  128. package/Materials/standardMaterial.js.map +1 -1
  129. package/Meshes/Builders/greasedLineBuilder.d.ts +1 -1
  130. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +22 -22
  131. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  132. package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -0
  133. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  134. package/Meshes/abstractMesh.d.ts +1 -2
  135. package/Meshes/abstractMesh.js +1 -2
  136. package/Meshes/abstractMesh.js.map +1 -1
  137. package/Meshes/linesMesh.js +2 -2
  138. package/Meshes/linesMesh.js.map +1 -1
  139. package/Meshes/mesh.d.ts +30 -3
  140. package/Meshes/mesh.js +56 -29
  141. package/Meshes/mesh.js.map +1 -1
  142. package/Meshes/subMesh.js +16 -3
  143. package/Meshes/subMesh.js.map +1 -1
  144. package/Misc/fileTools.js +14 -7
  145. package/Misc/fileTools.js.map +1 -1
  146. package/Morph/morphTargetManager.d.ts +20 -0
  147. package/Morph/morphTargetManager.js +31 -1
  148. package/Morph/morphTargetManager.js.map +1 -1
  149. package/PostProcesses/volumetricLightScatteringPostProcess.js +15 -16
  150. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  151. package/Rendering/depthRenderer.js +13 -15
  152. package/Rendering/depthRenderer.js.map +1 -1
  153. package/Rendering/geometryBufferRenderer.js +13 -15
  154. package/Rendering/geometryBufferRenderer.js.map +1 -1
  155. package/Rendering/objectRenderer.d.ts +9 -2
  156. package/Rendering/objectRenderer.js +44 -7
  157. package/Rendering/objectRenderer.js.map +1 -1
  158. package/Rendering/outlineRenderer.js +13 -15
  159. package/Rendering/outlineRenderer.js.map +1 -1
  160. package/Shaders/ShadersInclude/morphTargetsVertex.js +16 -4
  161. package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
  162. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +17 -5
  163. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  164. package/assetContainer.d.ts +43 -0
  165. package/assetContainer.js +67 -0
  166. package/assetContainer.js.map +1 -1
  167. package/package.json +1 -1
  168. package/scene.js +10 -3
  169. package/scene.js.map +1 -1
@@ -2,19 +2,16 @@ import { __decorate } from "../tslib.es6.js";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  import { serialize } from "../Misc/decorators.js";
4
4
  import { Scene } from "../scene.js";
5
- import { Vector2 } from "../Maths/math.vector.js";
6
- import { VertexBuffer } from "../Buffers/buffer.js";
7
5
  import { Texture } from "../Materials/Textures/texture.js";
8
6
  import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
9
- import { Material } from "../Materials/material.js";
10
7
  import { BlurPostProcess } from "../PostProcesses/blurPostProcess.js";
11
8
  import { EffectLayer } from "./effectLayer.js";
12
9
 
13
10
  import { RegisterClass } from "../Misc/typeStore.js";
14
- import { Color4 } from "../Maths/math.color.js";
15
11
  import "../Layers/effectLayerSceneComponent.js";
16
12
  import { SerializationHelper } from "../Misc/decorators.serialization.js";
17
13
  import { GetExponentOfTwo } from "../Misc/tools.functions.js";
14
+ import { ThinGlowLayer } from "./thinGlowLayer.js";
18
15
  Scene.prototype.getGlowLayerByName = function (name) {
19
16
  for (let index = 0; index < this.effectLayers?.length; index++) {
20
17
  if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
@@ -31,37 +28,53 @@ Scene.prototype.getGlowLayerByName = function (name) {
31
28
  * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/mesh/glowLayer
32
29
  */
33
30
  export class GlowLayer extends EffectLayer {
31
+ /**
32
+ * Effect Name of the layer.
33
+ */
34
+ static get EffectName() {
35
+ return ThinGlowLayer.EffectName;
36
+ }
34
37
  /**
35
38
  * Sets the kernel size of the blur.
36
39
  */
37
40
  set blurKernelSize(value) {
38
- if (value === this._options.blurKernelSize) {
39
- return;
40
- }
41
- this._options.blurKernelSize = value;
42
- const effectiveKernel = this._getEffectiveBlurKernelSize();
43
- this._horizontalBlurPostprocess1.kernel = effectiveKernel;
44
- this._verticalBlurPostprocess1.kernel = effectiveKernel;
45
- this._horizontalBlurPostprocess2.kernel = effectiveKernel;
46
- this._verticalBlurPostprocess2.kernel = effectiveKernel;
41
+ this._thinGlowLayer.blurKernelSize = value;
47
42
  }
48
43
  /**
49
44
  * Gets the kernel size of the blur.
50
45
  */
51
46
  get blurKernelSize() {
52
- return this._options.blurKernelSize;
47
+ return this._thinGlowLayer.blurKernelSize;
53
48
  }
54
49
  /**
55
50
  * Sets the glow intensity.
56
51
  */
57
52
  set intensity(value) {
58
- this._intensity = value;
53
+ this._thinGlowLayer.intensity = value;
59
54
  }
60
55
  /**
61
56
  * Gets the glow intensity.
62
57
  */
63
58
  get intensity() {
64
- return this._intensity;
59
+ return this._thinGlowLayer.intensity;
60
+ }
61
+ /**
62
+ * Callback used to let the user override the color selection on a per mesh basis
63
+ */
64
+ get customEmissiveColorSelector() {
65
+ return this._thinGlowLayer.customEmissiveColorSelector;
66
+ }
67
+ set customEmissiveColorSelector(value) {
68
+ this._thinGlowLayer.customEmissiveColorSelector = value;
69
+ }
70
+ /**
71
+ * Callback used to let the user override the texture selection on a per mesh basis
72
+ */
73
+ get customEmissiveTextureSelector() {
74
+ return this._thinGlowLayer.customEmissiveTextureSelector;
75
+ }
76
+ set customEmissiveTextureSelector(value) {
77
+ this._thinGlowLayer.customEmissiveTextureSelector = value;
65
78
  }
66
79
  /**
67
80
  * Instantiates a new glow Layer and references it to the scene.
@@ -70,12 +83,9 @@ export class GlowLayer extends EffectLayer {
70
83
  * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
71
84
  */
72
85
  constructor(name, scene, options) {
73
- super(name, scene);
74
- this._intensity = 1.0;
75
- this._includedOnlyMeshes = [];
76
- this._excludedMeshes = [];
77
- this._meshesUsingTheirOwnMaterials = [];
78
- this.neutralColor = new Color4(0, 0, 0, 1);
86
+ const thinGlowLayer = new ThinGlowLayer(name, scene, options);
87
+ super(name, scene, false, thinGlowLayer);
88
+ this._thinGlowLayer = thinGlowLayer;
79
89
  // Adapt options
80
90
  this._options = {
81
91
  mainTextureRatio: GlowLayer.DefaultTextureRatio,
@@ -91,28 +101,7 @@ export class GlowLayer extends EffectLayer {
91
101
  ...options,
92
102
  };
93
103
  // Initialize the layer
94
- this._init({
95
- alphaBlendingMode: this._options.alphaBlendingMode,
96
- camera: this._options.camera,
97
- mainTextureFixedSize: this._options.mainTextureFixedSize,
98
- mainTextureRatio: this._options.mainTextureRatio,
99
- renderingGroupId: this._options.renderingGroupId,
100
- mainTextureType: this._options.mainTextureType,
101
- generateStencilBuffer: this._options.generateStencilBuffer,
102
- });
103
- }
104
- async _importShadersAsync() {
105
- if (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
106
- await Promise.all([
107
- import("../ShadersWGSL/glowMapMerge.fragment.js"),
108
- import("../ShadersWGSL/glowMapMerge.vertex.js"),
109
- import("../ShadersWGSL/glowBlurPostProcess.fragment.js"),
110
- ]);
111
- }
112
- else {
113
- await Promise.all([import("../Shaders/glowMapMerge.fragment.js"), import("../Shaders/glowMapMerge.vertex.js"), import("../Shaders/glowBlurPostProcess.fragment.js")]);
114
- }
115
- await super._importShadersAsync();
104
+ this._init(this._options);
116
105
  }
117
106
  /**
118
107
  * Get the effect name of the layer.
@@ -127,22 +116,13 @@ export class GlowLayer extends EffectLayer {
127
116
  * to the main canvas at the end of the scene rendering.
128
117
  */
129
118
  _createMergeEffect() {
130
- let defines = "#define EMISSIVE \n";
131
- if (this._options.ldrMerge) {
132
- defines += "#define LDR \n";
133
- }
134
- // Effect
135
- return this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], defines, undefined, undefined, undefined, undefined, this.shaderLanguage, this._shadersLoaded
136
- ? undefined
137
- : async () => {
138
- await this._importShadersAsync();
139
- this._shadersLoaded = true;
140
- });
119
+ return this._thinGlowLayer._createMergeEffect();
141
120
  }
142
121
  /**
143
122
  * Creates the render target textures and post processes used in the glow layer.
144
123
  */
145
124
  _createTextureAndPostProcesses() {
125
+ this._thinGlowLayer._renderPassId = this._mainTexture.renderPassId;
146
126
  let blurTextureWidth = this._mainTextureDesiredSize.width;
147
127
  let blurTextureHeight = this._mainTextureDesiredSize.height;
148
128
  blurTextureWidth = this._engine.needPOTTextures ? GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
@@ -175,35 +155,60 @@ export class GlowLayer extends EffectLayer {
175
155
  this._blurTexture2.renderParticles = false;
176
156
  this._blurTexture2.ignoreCameraViewport = true;
177
157
  this._textures = [this._blurTexture1, this._blurTexture2];
178
- const effectiveKernel = this._getEffectiveBlurKernelSize();
179
- this._horizontalBlurPostprocess1 = new BlurPostProcess("GlowLayerHBP1", new Vector2(1.0, 0), effectiveKernel, {
158
+ this._thinGlowLayer.bindTexturesForCompose = (effect) => {
159
+ effect.setTexture("textureSampler", this._blurTexture1);
160
+ effect.setTexture("textureSampler2", this._blurTexture2);
161
+ effect.setFloat("offset", this.intensity);
162
+ };
163
+ this._thinGlowLayer._createTextureAndPostProcesses();
164
+ const thinBlurPostProcesses1 = this._thinGlowLayer._postProcesses[0];
165
+ this._horizontalBlurPostprocess1 = new BlurPostProcess("GlowLayerHBP1", thinBlurPostProcesses1.direction, thinBlurPostProcesses1.kernel, {
166
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
167
+ engine: this._scene.getEngine(),
180
168
  width: blurTextureWidth,
181
169
  height: blurTextureHeight,
182
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
170
+ textureType,
171
+ effectWrapper: thinBlurPostProcesses1,
172
+ });
183
173
  this._horizontalBlurPostprocess1.width = blurTextureWidth;
184
174
  this._horizontalBlurPostprocess1.height = blurTextureHeight;
185
175
  this._horizontalBlurPostprocess1.externalTextureSamplerBinding = true;
186
176
  this._horizontalBlurPostprocess1.onApplyObservable.add((effect) => {
187
177
  effect.setTexture("textureSampler", this._mainTexture);
188
178
  });
189
- this._verticalBlurPostprocess1 = new BlurPostProcess("GlowLayerVBP1", new Vector2(0, 1.0), effectiveKernel, {
179
+ const thinBlurPostProcesses2 = this._thinGlowLayer._postProcesses[1];
180
+ this._verticalBlurPostprocess1 = new BlurPostProcess("GlowLayerVBP1", thinBlurPostProcesses2.direction, thinBlurPostProcesses2.kernel, {
181
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
182
+ engine: this._scene.getEngine(),
190
183
  width: blurTextureWidth,
191
184
  height: blurTextureHeight,
192
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
193
- this._horizontalBlurPostprocess2 = new BlurPostProcess("GlowLayerHBP2", new Vector2(1.0, 0), effectiveKernel, {
185
+ textureType,
186
+ effectWrapper: thinBlurPostProcesses2,
187
+ });
188
+ const thinBlurPostProcesses3 = this._thinGlowLayer._postProcesses[2];
189
+ this._horizontalBlurPostprocess2 = new BlurPostProcess("GlowLayerHBP2", thinBlurPostProcesses3.direction, thinBlurPostProcesses3.kernel, {
190
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
191
+ engine: this._scene.getEngine(),
194
192
  width: blurTextureWidth2,
195
193
  height: blurTextureHeight2,
196
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
194
+ textureType,
195
+ effectWrapper: thinBlurPostProcesses3,
196
+ });
197
197
  this._horizontalBlurPostprocess2.width = blurTextureWidth2;
198
198
  this._horizontalBlurPostprocess2.height = blurTextureHeight2;
199
199
  this._horizontalBlurPostprocess2.externalTextureSamplerBinding = true;
200
200
  this._horizontalBlurPostprocess2.onApplyObservable.add((effect) => {
201
201
  effect.setTexture("textureSampler", this._blurTexture1);
202
202
  });
203
- this._verticalBlurPostprocess2 = new BlurPostProcess("GlowLayerVBP2", new Vector2(0, 1.0), effectiveKernel, {
203
+ const thinBlurPostProcesses4 = this._thinGlowLayer._postProcesses[3];
204
+ this._verticalBlurPostprocess2 = new BlurPostProcess("GlowLayerVBP2", thinBlurPostProcesses4.direction, thinBlurPostProcesses4.kernel, {
205
+ samplingMode: Texture.BILINEAR_SAMPLINGMODE,
206
+ engine: this._scene.getEngine(),
204
207
  width: blurTextureWidth2,
205
208
  height: blurTextureHeight2,
206
- }, null, Texture.BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
209
+ textureType,
210
+ effectWrapper: thinBlurPostProcesses4,
211
+ });
207
212
  this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
208
213
  this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
209
214
  this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
@@ -224,13 +229,6 @@ export class GlowLayer extends EffectLayer {
224
229
  pp.autoClear = false;
225
230
  });
226
231
  }
227
- /**
228
- * @returns The blur kernel size used by the glow.
229
- * Note: The value passed in the options is divided by 2 for back compatibility.
230
- */
231
- _getEffectiveBlurKernelSize() {
232
- return this._options.blurKernelSize / 2;
233
- }
234
232
  /**
235
233
  * Checks for the readiness of the element composing the layer.
236
234
  * @param subMesh the mesh to check for
@@ -238,13 +236,7 @@ export class GlowLayer extends EffectLayer {
238
236
  * @returns true if ready otherwise, false
239
237
  */
240
238
  isReady(subMesh, useInstances) {
241
- const material = subMesh.getMaterial();
242
- const mesh = subMesh.getRenderingMesh();
243
- if (!material || !mesh) {
244
- return false;
245
- }
246
- const emissiveTexture = material.emissiveTexture;
247
- return super._isReady(subMesh, useInstances, emissiveTexture);
239
+ return this._thinGlowLayer.isReady(subMesh, useInstances);
248
240
  }
249
241
  /**
250
242
  * @returns whether or not the layer needs stencil enabled during the mesh rendering.
@@ -259,25 +251,14 @@ export class GlowLayer extends EffectLayer {
259
251
  * @returns true if it can be rendered otherwise false
260
252
  */
261
253
  _canRenderMesh(mesh, material) {
262
- return true;
254
+ return this._thinGlowLayer._canRenderMesh(mesh, material);
263
255
  }
264
256
  /**
265
257
  * Implementation specific of rendering the generating effect on the main canvas.
266
258
  * @param effect The effect used to render through
267
259
  */
268
260
  _internalRender(effect) {
269
- // Texture
270
- effect.setTexture("textureSampler", this._blurTexture1);
271
- effect.setTexture("textureSampler2", this._blurTexture2);
272
- effect.setFloat("offset", this._intensity);
273
- // Cache
274
- const engine = this._engine;
275
- const previousStencilBuffer = engine.getStencilBuffer();
276
- // Draw order
277
- engine.setStencilBuffer(false);
278
- engine.drawElementsType(Material.TriangleFillMode, 0, 6);
279
- // Draw order
280
- engine.setStencilBuffer(previousStencilBuffer);
261
+ this._thinGlowLayer._internalCompose(effect);
281
262
  }
282
263
  /**
283
264
  * Sets the required values for both the emissive texture and and the main color.
@@ -286,34 +267,7 @@ export class GlowLayer extends EffectLayer {
286
267
  * @param material
287
268
  */
288
269
  _setEmissiveTextureAndColor(mesh, subMesh, material) {
289
- let textureLevel = 1.0;
290
- if (this.customEmissiveTextureSelector) {
291
- this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
292
- }
293
- else {
294
- if (material) {
295
- this._emissiveTextureAndColor.texture = material.emissiveTexture;
296
- if (this._emissiveTextureAndColor.texture) {
297
- textureLevel = this._emissiveTextureAndColor.texture.level;
298
- }
299
- }
300
- else {
301
- this._emissiveTextureAndColor.texture = null;
302
- }
303
- }
304
- if (this.customEmissiveColorSelector) {
305
- this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
306
- }
307
- else {
308
- if (material.emissiveColor) {
309
- const emissiveIntensity = material.emissiveIntensity ?? 1;
310
- textureLevel *= emissiveIntensity;
311
- this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
312
- }
313
- else {
314
- this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
315
- }
316
- }
270
+ this._thinGlowLayer._setEmissiveTextureAndColor(mesh, subMesh, material);
317
271
  }
318
272
  /**
319
273
  * Returns true if the mesh should render, otherwise false.
@@ -321,52 +275,42 @@ export class GlowLayer extends EffectLayer {
321
275
  * @returns true if it should render otherwise false
322
276
  */
323
277
  _shouldRenderMesh(mesh) {
324
- return this.hasMesh(mesh);
278
+ return this._thinGlowLayer._shouldRenderMesh(mesh);
325
279
  }
326
280
  /**
327
281
  * Adds specific effects defines.
328
282
  * @param defines The defines to add specifics to.
329
283
  */
330
284
  _addCustomEffectDefines(defines) {
331
- defines.push("#define GLOW");
285
+ this._thinGlowLayer._addCustomEffectDefines(defines);
332
286
  }
333
287
  /**
334
288
  * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
335
289
  * @param mesh The mesh to exclude from the glow layer
336
290
  */
337
291
  addExcludedMesh(mesh) {
338
- if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
339
- this._excludedMeshes.push(mesh.uniqueId);
340
- }
292
+ this._thinGlowLayer.addExcludedMesh(mesh);
341
293
  }
342
294
  /**
343
295
  * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
344
296
  * @param mesh The mesh to remove
345
297
  */
346
298
  removeExcludedMesh(mesh) {
347
- const index = this._excludedMeshes.indexOf(mesh.uniqueId);
348
- if (index !== -1) {
349
- this._excludedMeshes.splice(index, 1);
350
- }
299
+ this._thinGlowLayer.removeExcludedMesh(mesh);
351
300
  }
352
301
  /**
353
302
  * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
354
303
  * @param mesh The mesh to include in the glow layer
355
304
  */
356
305
  addIncludedOnlyMesh(mesh) {
357
- if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
358
- this._includedOnlyMeshes.push(mesh.uniqueId);
359
- }
306
+ this._thinGlowLayer.addIncludedOnlyMesh(mesh);
360
307
  }
361
308
  /**
362
309
  * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
363
310
  * @param mesh The mesh to remove
364
311
  */
365
312
  removeIncludedOnlyMesh(mesh) {
366
- const index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
367
- if (index !== -1) {
368
- this._includedOnlyMeshes.splice(index, 1);
369
- }
313
+ this._thinGlowLayer.removeIncludedOnlyMesh(mesh);
370
314
  }
371
315
  /**
372
316
  * Determine if a given mesh will be used in the glow layer
@@ -374,18 +318,7 @@ export class GlowLayer extends EffectLayer {
374
318
  * @returns true if the mesh will be highlighted by the current glow layer
375
319
  */
376
320
  hasMesh(mesh) {
377
- if (!super.hasMesh(mesh)) {
378
- return false;
379
- }
380
- // Included Mesh
381
- if (this._includedOnlyMeshes.length) {
382
- return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
383
- }
384
- // Excluded Mesh
385
- if (this._excludedMeshes.length) {
386
- return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
387
- }
388
- return true;
321
+ return this._thinGlowLayer.hasMesh(mesh);
389
322
  }
390
323
  /**
391
324
  * Defines whether the current material of the mesh should be use to render the effect.
@@ -393,37 +326,21 @@ export class GlowLayer extends EffectLayer {
393
326
  * @returns true if the material of the mesh should be use to render the effect
394
327
  */
395
328
  _useMeshMaterial(mesh) {
396
- // Specific case of material supporting glow directly
397
- if (mesh.material?._supportGlowLayer) {
398
- return true;
399
- }
400
- if (this._meshesUsingTheirOwnMaterials.length == 0) {
401
- return false;
402
- }
403
- return this._meshesUsingTheirOwnMaterials.indexOf(mesh.uniqueId) > -1;
329
+ return this._thinGlowLayer._useMeshMaterial(mesh);
404
330
  }
405
331
  /**
406
332
  * Add a mesh to be rendered through its own material and not with emissive only.
407
333
  * @param mesh The mesh for which we need to use its material
408
334
  */
409
335
  referenceMeshToUseItsOwnMaterial(mesh) {
410
- mesh.resetDrawCache(this._mainTexture.renderPassId);
411
- this._meshesUsingTheirOwnMaterials.push(mesh.uniqueId);
412
- mesh.onDisposeObservable.add(() => {
413
- this._disposeMesh(mesh);
414
- });
336
+ this._thinGlowLayer.referenceMeshToUseItsOwnMaterial(mesh);
415
337
  }
416
338
  /**
417
339
  * Remove a mesh from being rendered through its own material and not with emissive only.
418
340
  * @param mesh The mesh for which we need to not use its material
419
341
  */
420
342
  unReferenceMeshFromUsingItsOwnMaterial(mesh) {
421
- let index = this._meshesUsingTheirOwnMaterials.indexOf(mesh.uniqueId);
422
- while (index >= 0) {
423
- this._meshesUsingTheirOwnMaterials.splice(index, 1);
424
- index = this._meshesUsingTheirOwnMaterials.indexOf(mesh.uniqueId);
425
- }
426
- mesh.resetDrawCache(this._mainTexture.renderPassId);
343
+ this._thinGlowLayer.unReferenceMeshFromUsingItsOwnMaterial(mesh, this._mainTexture.renderPassId);
427
344
  }
428
345
  /**
429
346
  * Free any resources and references associated to a mesh.
@@ -432,8 +349,7 @@ export class GlowLayer extends EffectLayer {
432
349
  * @internal
433
350
  */
434
351
  _disposeMesh(mesh) {
435
- this.removeIncludedOnlyMesh(mesh);
436
- this.removeExcludedMesh(mesh);
352
+ this._thinGlowLayer._disposeMesh(mesh);
437
353
  }
438
354
  /**
439
355
  * Gets the class name of the effect layer
@@ -452,9 +368,10 @@ export class GlowLayer extends EffectLayer {
452
368
  let index;
453
369
  // Included meshes
454
370
  serializationObject.includedMeshes = [];
455
- if (this._includedOnlyMeshes.length) {
456
- for (index = 0; index < this._includedOnlyMeshes.length; index++) {
457
- const mesh = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[index]);
371
+ const includedOnlyMeshes = this._thinGlowLayer._includedOnlyMeshes;
372
+ if (includedOnlyMeshes.length) {
373
+ for (index = 0; index < includedOnlyMeshes.length; index++) {
374
+ const mesh = this._scene.getMeshByUniqueId(includedOnlyMeshes[index]);
458
375
  if (mesh) {
459
376
  serializationObject.includedMeshes.push(mesh.id);
460
377
  }
@@ -462,9 +379,10 @@ export class GlowLayer extends EffectLayer {
462
379
  }
463
380
  // Excluded meshes
464
381
  serializationObject.excludedMeshes = [];
465
- if (this._excludedMeshes.length) {
466
- for (index = 0; index < this._excludedMeshes.length; index++) {
467
- const mesh = this._scene.getMeshByUniqueId(this._excludedMeshes[index]);
382
+ const excludedMeshes = this._thinGlowLayer._excludedMeshes;
383
+ if (excludedMeshes.length) {
384
+ for (index = 0; index < excludedMeshes.length; index++) {
385
+ const mesh = this._scene.getMeshByUniqueId(excludedMeshes[index]);
468
386
  if (mesh) {
469
387
  serializationObject.excludedMeshes.push(mesh.id);
470
388
  }
@@ -499,10 +417,6 @@ export class GlowLayer extends EffectLayer {
499
417
  return gl;
500
418
  }
501
419
  }
502
- /**
503
- * Effect Name of the layer.
504
- */
505
- GlowLayer.EffectName = "GlowLayer";
506
420
  /**
507
421
  * The default blur kernel size used for the glow.
508
422
  */