@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.
- package/Animations/animation.js +1 -1
- package/Animations/animation.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +3 -4
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js +27 -64
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.js +3 -2
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.d.ts +1 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +5 -0
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +6 -1
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.d.ts +64 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +147 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +0 -15
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +4 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +9 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +1 -6
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +0 -13
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +0 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.js +17 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +0 -8
- package/FrameGraph/Passes/renderPass.js +0 -10
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Layers/glowLayerTask.d.ts +57 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js +173 -0
- package/FrameGraph/Tasks/Layers/glowLayerTask.js.map +1 -0
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +7 -0
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldBlurTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +5 -5
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +12 -4
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +0 -8
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +1 -17
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -6
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +20 -22
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +7 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +21 -5
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +4 -6
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +22 -11
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +2 -1
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +11 -1
- package/FrameGraph/frameGraphTask.js +8 -0
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +8 -2
- package/FrameGraph/frameGraphTextureManager.js +10 -4
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Layers/effectLayer.d.ts +32 -33
- package/Layers/effectLayer.js +144 -530
- package/Layers/effectLayer.js.map +1 -1
- package/Layers/glowLayer.d.ts +14 -41
- package/Layers/glowLayer.js +92 -178
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.d.ts +0 -1
- package/Layers/highlightLayer.js +0 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Layers/index.d.ts +2 -0
- package/Layers/index.js +2 -0
- package/Layers/index.js.map +1 -1
- package/Layers/thinEffectLayer.d.ts +230 -0
- package/Layers/thinEffectLayer.js +734 -0
- package/Layers/thinEffectLayer.js.map +1 -0
- package/Layers/thinGlowLayer.d.ts +141 -0
- package/Layers/thinGlowLayer.js +292 -0
- package/Layers/thinGlowLayer.js.map +1 -0
- package/Lights/Shadows/shadowGenerator.js +40 -19
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +17 -11
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +18 -12
- package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +34 -2
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +34 -24
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +10 -0
- package/Materials/Node/nodeMaterial.js +12 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +5 -0
- package/Materials/PBR/pbrBaseMaterial.js +5 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +12 -0
- package/Materials/Textures/renderTargetTexture.js +29 -8
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +17 -1
- package/Materials/materialHelper.functions.js +76 -4
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +5 -4
- package/Materials/shaderMaterial.js +28 -51
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.d.ts +5 -0
- package/Materials/standardMaterial.js +5 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +22 -22
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -0
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -2
- package/Meshes/abstractMesh.js +1 -2
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/linesMesh.js +2 -2
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +30 -3
- package/Meshes/mesh.js +56 -29
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/subMesh.js +16 -3
- package/Meshes/subMesh.js.map +1 -1
- package/Misc/fileTools.js +14 -7
- package/Misc/fileTools.js.map +1 -1
- package/Morph/morphTargetManager.d.ts +20 -0
- package/Morph/morphTargetManager.js +31 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +15 -16
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +13 -15
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +13 -15
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +9 -2
- package/Rendering/objectRenderer.js +44 -7
- package/Rendering/objectRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +13 -15
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertex.js +16 -4
- package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +17 -5
- package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
- package/assetContainer.d.ts +43 -0
- package/assetContainer.js +67 -0
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +10 -3
- package/scene.js.map +1 -1
package/Layers/effectLayer.js
CHANGED
|
@@ -2,19 +2,13 @@ import { __decorate } from "../tslib.es6.js";
|
|
|
2
2
|
import { serialize, serializeAsColor4, serializeAsCameraReference } from "../Misc/decorators.js";
|
|
3
3
|
import { Tools } from "../Misc/tools.js";
|
|
4
4
|
import { Observable } from "../Misc/observable.js";
|
|
5
|
-
import { Color4 } from "../Maths/math.color.js";
|
|
6
5
|
import { EngineStore } from "../Engines/engineStore.js";
|
|
7
|
-
import { VertexBuffer } from "../Buffers/buffer.js";
|
|
8
6
|
import { Texture } from "../Materials/Textures/texture.js";
|
|
9
7
|
import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
|
|
10
|
-
import { Material } from "../Materials/material.js";
|
|
11
8
|
|
|
12
9
|
import { _WarnImport } from "../Misc/devTools.js";
|
|
13
|
-
import { EffectFallbacks } from "../Materials/effectFallbacks.js";
|
|
14
|
-
import { DrawWrapper } from "../Materials/drawWrapper.js";
|
|
15
|
-
import { addClipPlaneUniforms, bindClipPlane, prepareStringDefinesForClipPlanes } from "../Materials/clipPlaneMaterialHelper.js";
|
|
16
|
-
import { BindMorphTargetParameters, PrepareAttributesForMorphTargetsInfluencers, PushAttributesForInstances } from "../Materials/materialHelper.functions.js";
|
|
17
10
|
import { GetExponentOfTwo } from "../Misc/tools.functions.js";
|
|
11
|
+
import { ThinEffectLayer } from "./thinEffectLayer.js";
|
|
18
12
|
/**
|
|
19
13
|
* The effect layer Helps adding post process effect blended with the main pass.
|
|
20
14
|
*
|
|
@@ -24,20 +18,84 @@ import { GetExponentOfTwo } from "../Misc/tools.functions.js";
|
|
|
24
18
|
* customized per effects.
|
|
25
19
|
*/
|
|
26
20
|
export class EffectLayer {
|
|
21
|
+
get _shouldRender() {
|
|
22
|
+
return this._thinEffectLayer._shouldRender;
|
|
23
|
+
}
|
|
24
|
+
set _shouldRender(value) {
|
|
25
|
+
this._thinEffectLayer._shouldRender = value;
|
|
26
|
+
}
|
|
27
|
+
get _emissiveTextureAndColor() {
|
|
28
|
+
return this._thinEffectLayer._emissiveTextureAndColor;
|
|
29
|
+
}
|
|
30
|
+
set _emissiveTextureAndColor(value) {
|
|
31
|
+
this._thinEffectLayer._emissiveTextureAndColor = value;
|
|
32
|
+
}
|
|
33
|
+
get _effectIntensity() {
|
|
34
|
+
return this._thinEffectLayer._effectIntensity;
|
|
35
|
+
}
|
|
36
|
+
set _effectIntensity(value) {
|
|
37
|
+
this._thinEffectLayer._effectIntensity = value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Force all the effect layers to compile to glsl even on WebGPU engines.
|
|
41
|
+
* False by default. This is mostly meant for backward compatibility.
|
|
42
|
+
*/
|
|
43
|
+
static get ForceGLSL() {
|
|
44
|
+
return ThinEffectLayer.ForceGLSL;
|
|
45
|
+
}
|
|
46
|
+
static set ForceGLSL(value) {
|
|
47
|
+
ThinEffectLayer.ForceGLSL = value;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The name of the layer
|
|
51
|
+
*/
|
|
52
|
+
get name() {
|
|
53
|
+
return this._thinEffectLayer.name;
|
|
54
|
+
}
|
|
55
|
+
set name(value) {
|
|
56
|
+
this._thinEffectLayer.name = value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The clear color of the texture used to generate the glow map.
|
|
60
|
+
*/
|
|
61
|
+
get neutralColor() {
|
|
62
|
+
return this._thinEffectLayer.neutralColor;
|
|
63
|
+
}
|
|
64
|
+
set neutralColor(value) {
|
|
65
|
+
this._thinEffectLayer.neutralColor = value;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Specifies whether the highlight layer is enabled or not.
|
|
69
|
+
*/
|
|
70
|
+
get isEnabled() {
|
|
71
|
+
return this._thinEffectLayer.isEnabled;
|
|
72
|
+
}
|
|
73
|
+
set isEnabled(value) {
|
|
74
|
+
this._thinEffectLayer.isEnabled = value;
|
|
75
|
+
}
|
|
27
76
|
/**
|
|
28
77
|
* Gets the camera attached to the layer.
|
|
29
78
|
*/
|
|
30
79
|
get camera() {
|
|
31
|
-
return this.
|
|
80
|
+
return this._thinEffectLayer.camera;
|
|
32
81
|
}
|
|
33
82
|
/**
|
|
34
83
|
* Gets the rendering group id the layer should render in.
|
|
35
84
|
*/
|
|
36
85
|
get renderingGroupId() {
|
|
37
|
-
return this.
|
|
86
|
+
return this._thinEffectLayer.renderingGroupId;
|
|
38
87
|
}
|
|
39
88
|
set renderingGroupId(renderingGroupId) {
|
|
40
|
-
this.
|
|
89
|
+
this._thinEffectLayer.renderingGroupId = renderingGroupId;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
|
|
93
|
+
*/
|
|
94
|
+
get disableBoundingBoxesFromEffectLayer() {
|
|
95
|
+
return this._thinEffectLayer.disableBoundingBoxesFromEffectLayer;
|
|
96
|
+
}
|
|
97
|
+
set disableBoundingBoxesFromEffectLayer(value) {
|
|
98
|
+
this._thinEffectLayer.disableBoundingBoxesFromEffectLayer = value;
|
|
41
99
|
}
|
|
42
100
|
/**
|
|
43
101
|
* Gets the main texture where the effect is rendered
|
|
@@ -45,11 +103,14 @@ export class EffectLayer {
|
|
|
45
103
|
get mainTexture() {
|
|
46
104
|
return this._mainTexture;
|
|
47
105
|
}
|
|
106
|
+
get _shaderLanguage() {
|
|
107
|
+
return this._thinEffectLayer.shaderLanguage;
|
|
108
|
+
}
|
|
48
109
|
/**
|
|
49
110
|
* Gets the shader language used in this material.
|
|
50
111
|
*/
|
|
51
112
|
get shaderLanguage() {
|
|
52
|
-
return this.
|
|
113
|
+
return this._thinEffectLayer.shaderLanguage;
|
|
53
114
|
}
|
|
54
115
|
/**
|
|
55
116
|
* Sets a specific material to be used to render a mesh/a list of meshes in the layer
|
|
@@ -57,26 +118,7 @@ export class EffectLayer {
|
|
|
57
118
|
* @param material material to use by the layer when rendering the mesh(es). If undefined is passed, the specific material created by the layer will be used.
|
|
58
119
|
*/
|
|
59
120
|
setMaterialForRendering(mesh, material) {
|
|
60
|
-
this.
|
|
61
|
-
if (Array.isArray(mesh)) {
|
|
62
|
-
for (let i = 0; i < mesh.length; ++i) {
|
|
63
|
-
const currentMesh = mesh[i];
|
|
64
|
-
if (!material) {
|
|
65
|
-
delete this._materialForRendering[currentMesh.uniqueId];
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this._materialForRendering[currentMesh.uniqueId] = [currentMesh, material];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
if (!material) {
|
|
74
|
-
delete this._materialForRendering[mesh.uniqueId];
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
this._materialForRendering[mesh.uniqueId] = [mesh, material];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
121
|
+
this._thinEffectLayer.setMaterialForRendering(mesh, material);
|
|
80
122
|
}
|
|
81
123
|
/**
|
|
82
124
|
* Gets the intensity of the effect for a specific mesh.
|
|
@@ -84,7 +126,7 @@ export class EffectLayer {
|
|
|
84
126
|
* @returns The intensity of the effect for the mesh
|
|
85
127
|
*/
|
|
86
128
|
getEffectIntensity(mesh) {
|
|
87
|
-
return this.
|
|
129
|
+
return this._thinEffectLayer.getEffectIntensity(mesh);
|
|
88
130
|
}
|
|
89
131
|
/**
|
|
90
132
|
* Sets the intensity of the effect for a specific mesh.
|
|
@@ -92,37 +134,22 @@ export class EffectLayer {
|
|
|
92
134
|
* @param intensity The intensity of the effect for the mesh
|
|
93
135
|
*/
|
|
94
136
|
setEffectIntensity(mesh, intensity) {
|
|
95
|
-
this.
|
|
137
|
+
this._thinEffectLayer.setEffectIntensity(mesh, intensity);
|
|
96
138
|
}
|
|
97
139
|
/**
|
|
98
140
|
* Instantiates a new effect Layer and references it in the scene.
|
|
99
141
|
* @param name The name of the layer
|
|
100
142
|
* @param scene The scene to use the layer in
|
|
101
143
|
* @param forceGLSL Use the GLSL code generation for the shader (even on WebGPU). Default is false
|
|
144
|
+
* @param thinEffectLayer The thin instance of the effect layer (optional)
|
|
102
145
|
*/
|
|
103
146
|
constructor(
|
|
104
147
|
/** The Friendly of the effect in the scene */
|
|
105
|
-
name, scene, forceGLSL = false) {
|
|
106
|
-
this._vertexBuffers = {};
|
|
148
|
+
name, scene, forceGLSL = false, thinEffectLayer) {
|
|
107
149
|
this._maxSize = 0;
|
|
108
150
|
this._mainTextureDesiredSize = { width: 0, height: 0 };
|
|
109
|
-
this._shouldRender = true;
|
|
110
151
|
this._postProcesses = [];
|
|
111
152
|
this._textures = [];
|
|
112
|
-
this._emissiveTextureAndColor = { texture: null, color: new Color4() };
|
|
113
|
-
this._effectIntensity = {};
|
|
114
|
-
/**
|
|
115
|
-
* The clear color of the texture used to generate the glow map.
|
|
116
|
-
*/
|
|
117
|
-
this.neutralColor = new Color4();
|
|
118
|
-
/**
|
|
119
|
-
* Specifies whether the highlight layer is enabled or not.
|
|
120
|
-
*/
|
|
121
|
-
this.isEnabled = true;
|
|
122
|
-
/**
|
|
123
|
-
* Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
|
|
124
|
-
*/
|
|
125
|
-
this.disableBoundingBoxesFromEffectLayer = false;
|
|
126
153
|
/**
|
|
127
154
|
* An event triggered when the effect layer has been disposed.
|
|
128
155
|
*/
|
|
@@ -151,31 +178,61 @@ export class EffectLayer {
|
|
|
151
178
|
* An event triggered when the effect layer changes its size.
|
|
152
179
|
*/
|
|
153
180
|
this.onSizeChangedObservable = new Observable();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
181
|
+
this._internalThinEffectLayer = !thinEffectLayer;
|
|
182
|
+
if (!thinEffectLayer) {
|
|
183
|
+
thinEffectLayer = new ThinEffectLayer(name, scene, forceGLSL, false, this._importShadersAsync.bind(this));
|
|
184
|
+
thinEffectLayer.getEffectName = this.getEffectName.bind(this);
|
|
185
|
+
thinEffectLayer.isReady = this.isReady.bind(this);
|
|
186
|
+
thinEffectLayer._createMergeEffect = this._createMergeEffect.bind(this);
|
|
187
|
+
thinEffectLayer._createTextureAndPostProcesses = this._createTextureAndPostProcesses.bind(this);
|
|
188
|
+
thinEffectLayer._internalCompose = this._internalRender.bind(this);
|
|
189
|
+
thinEffectLayer._setEmissiveTextureAndColor = this._setEmissiveTextureAndColor.bind(this);
|
|
190
|
+
thinEffectLayer._numInternalDraws = this._numInternalDraws.bind(this);
|
|
191
|
+
thinEffectLayer._addCustomEffectDefines = this._addCustomEffectDefines.bind(this);
|
|
192
|
+
thinEffectLayer.hasMesh = this.hasMesh.bind(this);
|
|
193
|
+
thinEffectLayer.shouldRender = this.shouldRender.bind(this);
|
|
194
|
+
thinEffectLayer._shouldRenderMesh = this._shouldRenderMesh.bind(this);
|
|
195
|
+
thinEffectLayer._canRenderMesh = this._canRenderMesh.bind(this);
|
|
196
|
+
thinEffectLayer._useMeshMaterial = this._useMeshMaterial.bind(this);
|
|
197
|
+
}
|
|
198
|
+
this._thinEffectLayer = thinEffectLayer;
|
|
158
199
|
this.name = name;
|
|
159
200
|
this._scene = scene || EngineStore.LastCreatedScene;
|
|
160
201
|
EffectLayer._SceneComponentInitialization(this._scene);
|
|
161
|
-
const engine = this._scene.getEngine();
|
|
162
|
-
if (engine.isWebGPU && !forceGLSL && !EffectLayer.ForceGLSL) {
|
|
163
|
-
this._shaderLanguage = 1 /* ShaderLanguage.WGSL */;
|
|
164
|
-
}
|
|
165
202
|
this._engine = this._scene.getEngine();
|
|
166
203
|
this._maxSize = this._engine.getCaps().maxTextureSize;
|
|
167
204
|
this._scene.effectLayers.push(this);
|
|
168
|
-
this.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.
|
|
205
|
+
this._thinEffectLayer.onDisposeObservable.add(() => {
|
|
206
|
+
this.onDisposeObservable.notifyObservers(this);
|
|
207
|
+
});
|
|
208
|
+
this._thinEffectLayer.onBeforeRenderLayerObservable.add(() => {
|
|
209
|
+
this.onBeforeRenderMainTextureObservable.notifyObservers(this);
|
|
210
|
+
});
|
|
211
|
+
this._thinEffectLayer.onBeforeComposeObservable.add(() => {
|
|
212
|
+
this.onBeforeComposeObservable.notifyObservers(this);
|
|
213
|
+
});
|
|
214
|
+
this._thinEffectLayer.onBeforeRenderMeshToEffect.add((mesh) => {
|
|
215
|
+
this.onBeforeRenderMeshToEffect.notifyObservers(mesh);
|
|
216
|
+
});
|
|
217
|
+
this._thinEffectLayer.onAfterRenderMeshToEffect.add((mesh) => {
|
|
218
|
+
this.onAfterRenderMeshToEffect.notifyObservers(mesh);
|
|
219
|
+
});
|
|
220
|
+
this._thinEffectLayer.onAfterComposeObservable.add(() => {
|
|
221
|
+
this.onAfterComposeObservable.notifyObservers(this);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
get _shadersLoaded() {
|
|
225
|
+
return this._thinEffectLayer._shadersLoaded;
|
|
226
|
+
}
|
|
227
|
+
set _shadersLoaded(value) {
|
|
228
|
+
this._thinEffectLayer._shadersLoaded = value;
|
|
172
229
|
}
|
|
173
230
|
/**
|
|
174
231
|
* Number of times _internalRender will be called. Some effect layers need to render the mesh several times, so they should override this method with the number of times the mesh should be rendered
|
|
175
232
|
* @returns Number of times a mesh must be rendered in the layer
|
|
176
233
|
*/
|
|
177
234
|
_numInternalDraws() {
|
|
178
|
-
return 1;
|
|
235
|
+
return this._internalThinEffectLayer ? 1 : this._thinEffectLayer._numInternalDraws();
|
|
179
236
|
}
|
|
180
237
|
/**
|
|
181
238
|
* Initializes the effect layer with the required options.
|
|
@@ -193,36 +250,10 @@ export class EffectLayer {
|
|
|
193
250
|
...options,
|
|
194
251
|
};
|
|
195
252
|
this._setMainTextureSize();
|
|
253
|
+
this._thinEffectLayer._init(options);
|
|
196
254
|
this._createMainTexture();
|
|
197
255
|
this._createTextureAndPostProcesses();
|
|
198
256
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Generates the index buffer of the full screen quad blending to the main canvas.
|
|
201
|
-
*/
|
|
202
|
-
_generateIndexBuffer() {
|
|
203
|
-
// Indices
|
|
204
|
-
const indices = [];
|
|
205
|
-
indices.push(0);
|
|
206
|
-
indices.push(1);
|
|
207
|
-
indices.push(2);
|
|
208
|
-
indices.push(0);
|
|
209
|
-
indices.push(2);
|
|
210
|
-
indices.push(3);
|
|
211
|
-
this._indexBuffer = this._engine.createIndexBuffer(indices);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Generates the vertex buffer of the full screen quad blending to the main canvas.
|
|
215
|
-
*/
|
|
216
|
-
_generateVertexBuffer() {
|
|
217
|
-
// VBO
|
|
218
|
-
const vertices = [];
|
|
219
|
-
vertices.push(1, 1);
|
|
220
|
-
vertices.push(-1, 1);
|
|
221
|
-
vertices.push(-1, -1);
|
|
222
|
-
vertices.push(1, -1);
|
|
223
|
-
const vertexBuffer = new VertexBuffer(this._engine, vertices, VertexBuffer.PositionKind, false, false, 2);
|
|
224
|
-
this._vertexBuffers[VertexBuffer.PositionKind] = vertexBuffer;
|
|
225
|
-
}
|
|
226
257
|
/**
|
|
227
258
|
* Sets the main texture desired size which is the closest power of two
|
|
228
259
|
* of the engine canvas size.
|
|
@@ -252,7 +283,12 @@ export class EffectLayer {
|
|
|
252
283
|
this._mainTexture = new RenderTargetTexture("EffectLayerMainRTT", {
|
|
253
284
|
width: this._mainTextureDesiredSize.width,
|
|
254
285
|
height: this._mainTextureDesiredSize.height,
|
|
255
|
-
}, this._scene,
|
|
286
|
+
}, this._scene, {
|
|
287
|
+
type: this._effectLayerOptions.mainTextureType,
|
|
288
|
+
samplingMode: Texture.TRILINEAR_SAMPLINGMODE,
|
|
289
|
+
generateStencilBuffer: this._effectLayerOptions.generateStencilBuffer,
|
|
290
|
+
existingObjectRenderer: this._thinEffectLayer.objectRenderer,
|
|
291
|
+
});
|
|
256
292
|
this._mainTexture.activeCamera = this._effectLayerOptions.camera;
|
|
257
293
|
this._mainTexture.wrapU = Texture.CLAMP_ADDRESSMODE;
|
|
258
294
|
this._mainTexture.wrapV = Texture.CLAMP_ADDRESSMODE;
|
|
@@ -261,74 +297,9 @@ export class EffectLayer {
|
|
|
261
297
|
this._mainTexture.renderParticles = false;
|
|
262
298
|
this._mainTexture.renderList = null;
|
|
263
299
|
this._mainTexture.ignoreCameraViewport = true;
|
|
264
|
-
for (const id in this._materialForRendering) {
|
|
265
|
-
const [mesh, material] = this._materialForRendering[id];
|
|
266
|
-
this._mainTexture.setMaterialForRendering(mesh, material);
|
|
267
|
-
}
|
|
268
|
-
this._mainTexture.customIsReadyFunction = (mesh, refreshRate, preWarm) => {
|
|
269
|
-
if ((preWarm || refreshRate === 0) && mesh.subMeshes) {
|
|
270
|
-
for (let i = 0; i < mesh.subMeshes.length; ++i) {
|
|
271
|
-
const subMesh = mesh.subMeshes[i];
|
|
272
|
-
const material = subMesh.getMaterial();
|
|
273
|
-
const renderingMesh = subMesh.getRenderingMesh();
|
|
274
|
-
if (!material) {
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
const batch = renderingMesh._getInstancesRenderList(subMesh._id, !!subMesh.getReplacementMesh());
|
|
278
|
-
const hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id] || renderingMesh.hasThinInstances;
|
|
279
|
-
this._setEmissiveTextureAndColor(renderingMesh, subMesh, material);
|
|
280
|
-
if (!this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return true;
|
|
286
|
-
};
|
|
287
|
-
// Custom render function
|
|
288
|
-
this._mainTexture.customRenderFunction = (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) => {
|
|
289
|
-
this.onBeforeRenderMainTextureObservable.notifyObservers(this);
|
|
290
|
-
let index;
|
|
291
|
-
const engine = this._scene.getEngine();
|
|
292
|
-
if (depthOnlySubMeshes.length) {
|
|
293
|
-
engine.setColorWrite(false);
|
|
294
|
-
for (index = 0; index < depthOnlySubMeshes.length; index++) {
|
|
295
|
-
this._renderSubMesh(depthOnlySubMeshes.data[index]);
|
|
296
|
-
}
|
|
297
|
-
engine.setColorWrite(true);
|
|
298
|
-
}
|
|
299
|
-
for (index = 0; index < opaqueSubMeshes.length; index++) {
|
|
300
|
-
this._renderSubMesh(opaqueSubMeshes.data[index]);
|
|
301
|
-
}
|
|
302
|
-
for (index = 0; index < alphaTestSubMeshes.length; index++) {
|
|
303
|
-
this._renderSubMesh(alphaTestSubMeshes.data[index]);
|
|
304
|
-
}
|
|
305
|
-
const previousAlphaMode = engine.getAlphaMode();
|
|
306
|
-
for (index = 0; index < transparentSubMeshes.length; index++) {
|
|
307
|
-
const subMesh = transparentSubMeshes.data[index];
|
|
308
|
-
const material = subMesh.getMaterial();
|
|
309
|
-
if (material && material.needDepthPrePass) {
|
|
310
|
-
const engine = material.getScene().getEngine();
|
|
311
|
-
engine.setColorWrite(false);
|
|
312
|
-
this._renderSubMesh(subMesh);
|
|
313
|
-
engine.setColorWrite(true);
|
|
314
|
-
}
|
|
315
|
-
this._renderSubMesh(subMesh, true);
|
|
316
|
-
}
|
|
317
|
-
engine.setAlphaMode(previousAlphaMode);
|
|
318
|
-
};
|
|
319
300
|
this._mainTexture.onClearObservable.add((engine) => {
|
|
320
301
|
engine.clear(this.neutralColor, true, true, true);
|
|
321
302
|
});
|
|
322
|
-
// Prevent package size in es6 (getBoundingBoxRenderer might not be present)
|
|
323
|
-
if (this._scene.getBoundingBoxRenderer) {
|
|
324
|
-
const boundingBoxRendererEnabled = this._scene.getBoundingBoxRenderer().enabled;
|
|
325
|
-
this._mainTexture.onBeforeBindObservable.add(() => {
|
|
326
|
-
this._scene.getBoundingBoxRenderer().enabled = !this.disableBoundingBoxesFromEffectLayer && boundingBoxRendererEnabled;
|
|
327
|
-
});
|
|
328
|
-
this._mainTexture.onAfterUnbindObservable.add(() => {
|
|
329
|
-
this._scene.getBoundingBoxRenderer().enabled = boundingBoxRendererEnabled;
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
303
|
}
|
|
333
304
|
/**
|
|
334
305
|
* Adds specific effects defines.
|
|
@@ -346,219 +317,21 @@ export class EffectLayer {
|
|
|
346
317
|
* @returns true if ready otherwise, false
|
|
347
318
|
*/
|
|
348
319
|
_isReady(subMesh, useInstances, emissiveTexture) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
if (renderingMaterial) {
|
|
353
|
-
return renderingMaterial.isReadyForSubMesh(mesh, subMesh, useInstances);
|
|
354
|
-
}
|
|
355
|
-
const material = subMesh.getMaterial();
|
|
356
|
-
if (!material) {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
if (this._useMeshMaterial(subMesh.getRenderingMesh())) {
|
|
360
|
-
return material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances);
|
|
361
|
-
}
|
|
362
|
-
const defines = [];
|
|
363
|
-
const attribs = [VertexBuffer.PositionKind];
|
|
364
|
-
let uv1 = false;
|
|
365
|
-
let uv2 = false;
|
|
366
|
-
// Diffuse
|
|
367
|
-
if (material) {
|
|
368
|
-
const needAlphaTest = material.needAlphaTesting();
|
|
369
|
-
const diffuseTexture = material.getAlphaTestTexture();
|
|
370
|
-
const needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha && (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
|
|
371
|
-
if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
|
|
372
|
-
defines.push("#define DIFFUSE");
|
|
373
|
-
if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind) && diffuseTexture.coordinatesIndex === 1) {
|
|
374
|
-
defines.push("#define DIFFUSEUV2");
|
|
375
|
-
uv2 = true;
|
|
376
|
-
}
|
|
377
|
-
else if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
378
|
-
defines.push("#define DIFFUSEUV1");
|
|
379
|
-
uv1 = true;
|
|
380
|
-
}
|
|
381
|
-
if (needAlphaTest) {
|
|
382
|
-
defines.push("#define ALPHATEST");
|
|
383
|
-
defines.push("#define ALPHATESTVALUE 0.4");
|
|
384
|
-
}
|
|
385
|
-
if (!diffuseTexture.gammaSpace) {
|
|
386
|
-
defines.push("#define DIFFUSE_ISLINEAR");
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
const opacityTexture = material.opacityTexture;
|
|
390
|
-
if (opacityTexture) {
|
|
391
|
-
defines.push("#define OPACITY");
|
|
392
|
-
if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind) && opacityTexture.coordinatesIndex === 1) {
|
|
393
|
-
defines.push("#define OPACITYUV2");
|
|
394
|
-
uv2 = true;
|
|
395
|
-
}
|
|
396
|
-
else if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
397
|
-
defines.push("#define OPACITYUV1");
|
|
398
|
-
uv1 = true;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
// Emissive
|
|
403
|
-
if (emissiveTexture) {
|
|
404
|
-
defines.push("#define EMISSIVE");
|
|
405
|
-
if (mesh.isVerticesDataPresent(VertexBuffer.UV2Kind) && emissiveTexture.coordinatesIndex === 1) {
|
|
406
|
-
defines.push("#define EMISSIVEUV2");
|
|
407
|
-
uv2 = true;
|
|
408
|
-
}
|
|
409
|
-
else if (mesh.isVerticesDataPresent(VertexBuffer.UVKind)) {
|
|
410
|
-
defines.push("#define EMISSIVEUV1");
|
|
411
|
-
uv1 = true;
|
|
412
|
-
}
|
|
413
|
-
if (!emissiveTexture.gammaSpace) {
|
|
414
|
-
defines.push("#define EMISSIVE_ISLINEAR");
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
// Vertex
|
|
418
|
-
if (mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind) && mesh.hasVertexAlpha && material.transparencyMode !== Material.MATERIAL_OPAQUE) {
|
|
419
|
-
attribs.push(VertexBuffer.ColorKind);
|
|
420
|
-
defines.push("#define VERTEXALPHA");
|
|
421
|
-
}
|
|
422
|
-
if (uv1) {
|
|
423
|
-
attribs.push(VertexBuffer.UVKind);
|
|
424
|
-
defines.push("#define UV1");
|
|
425
|
-
}
|
|
426
|
-
if (uv2) {
|
|
427
|
-
attribs.push(VertexBuffer.UV2Kind);
|
|
428
|
-
defines.push("#define UV2");
|
|
429
|
-
}
|
|
430
|
-
// Bones
|
|
431
|
-
const fallbacks = new EffectFallbacks();
|
|
432
|
-
if (mesh.useBones && mesh.computeBonesUsingShaders) {
|
|
433
|
-
attribs.push(VertexBuffer.MatricesIndicesKind);
|
|
434
|
-
attribs.push(VertexBuffer.MatricesWeightsKind);
|
|
435
|
-
if (mesh.numBoneInfluencers > 4) {
|
|
436
|
-
attribs.push(VertexBuffer.MatricesIndicesExtraKind);
|
|
437
|
-
attribs.push(VertexBuffer.MatricesWeightsExtraKind);
|
|
438
|
-
}
|
|
439
|
-
defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
|
|
440
|
-
const skeleton = mesh.skeleton;
|
|
441
|
-
if (skeleton && skeleton.isUsingTextureForMatrices) {
|
|
442
|
-
defines.push("#define BONETEXTURE");
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
defines.push("#define BonesPerMesh " + (skeleton ? skeleton.bones.length + 1 : 0));
|
|
446
|
-
}
|
|
447
|
-
if (mesh.numBoneInfluencers > 0) {
|
|
448
|
-
fallbacks.addCPUSkinningFallback(0, mesh);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
defines.push("#define NUM_BONE_INFLUENCERS 0");
|
|
453
|
-
}
|
|
454
|
-
// Morph targets
|
|
455
|
-
const manager = mesh.morphTargetManager;
|
|
456
|
-
let morphInfluencers = 0;
|
|
457
|
-
if (manager) {
|
|
458
|
-
morphInfluencers = manager.numMaxInfluencers || manager.numInfluencers;
|
|
459
|
-
if (morphInfluencers > 0) {
|
|
460
|
-
defines.push("#define MORPHTARGETS");
|
|
461
|
-
defines.push("#define MORPHTARGETS_POSITION");
|
|
462
|
-
defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
|
|
463
|
-
if (manager.isUsingTextureForTargets) {
|
|
464
|
-
defines.push("#define MORPHTARGETS_TEXTURE");
|
|
465
|
-
}
|
|
466
|
-
PrepareAttributesForMorphTargetsInfluencers(attribs, mesh, morphInfluencers);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
// Instances
|
|
470
|
-
if (useInstances) {
|
|
471
|
-
defines.push("#define INSTANCES");
|
|
472
|
-
PushAttributesForInstances(attribs);
|
|
473
|
-
if (subMesh.getRenderingMesh().hasThinInstances) {
|
|
474
|
-
defines.push("#define THIN_INSTANCES");
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
// ClipPlanes
|
|
478
|
-
prepareStringDefinesForClipPlanes(material, this._scene, defines);
|
|
479
|
-
this._addCustomEffectDefines(defines);
|
|
480
|
-
// Get correct effect
|
|
481
|
-
const drawWrapper = subMesh._getDrawWrapper(undefined, true);
|
|
482
|
-
const cachedDefines = drawWrapper.defines;
|
|
483
|
-
const join = defines.join("\n");
|
|
484
|
-
if (cachedDefines !== join) {
|
|
485
|
-
const uniforms = [
|
|
486
|
-
"world",
|
|
487
|
-
"mBones",
|
|
488
|
-
"viewProjection",
|
|
489
|
-
"glowColor",
|
|
490
|
-
"morphTargetInfluences",
|
|
491
|
-
"morphTargetCount",
|
|
492
|
-
"boneTextureWidth",
|
|
493
|
-
"diffuseMatrix",
|
|
494
|
-
"emissiveMatrix",
|
|
495
|
-
"opacityMatrix",
|
|
496
|
-
"opacityIntensity",
|
|
497
|
-
"morphTargetTextureInfo",
|
|
498
|
-
"morphTargetTextureIndices",
|
|
499
|
-
"glowIntensity",
|
|
500
|
-
];
|
|
501
|
-
addClipPlaneUniforms(uniforms);
|
|
502
|
-
drawWrapper.setEffect(this._engine.createEffect("glowMapGeneration", attribs, uniforms, ["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"], join, fallbacks, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers }, this._shaderLanguage, this._shadersLoaded
|
|
503
|
-
? undefined
|
|
504
|
-
: async () => {
|
|
505
|
-
await this._importShadersAsync();
|
|
506
|
-
this._shadersLoaded = true;
|
|
507
|
-
}), join);
|
|
508
|
-
}
|
|
509
|
-
const effectIsReady = drawWrapper.effect.isReady();
|
|
510
|
-
return this._arePostProcessAndMergeReady() && effectIsReady;
|
|
511
|
-
}
|
|
512
|
-
async _importShadersAsync() {
|
|
513
|
-
if (this._shaderLanguage === 1 /* ShaderLanguage.WGSL */) {
|
|
514
|
-
await Promise.all([import("../ShadersWGSL/glowMapGeneration.vertex.js"), import("../ShadersWGSL/glowMapGeneration.fragment.js")]);
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
await Promise.all([import("../Shaders/glowMapGeneration.vertex.js"), import("../Shaders/glowMapGeneration.fragment.js")]);
|
|
518
|
-
}
|
|
320
|
+
return this._internalThinEffectLayer
|
|
321
|
+
? this._thinEffectLayer._internalIsSubMeshReady(subMesh, useInstances, emissiveTexture)
|
|
322
|
+
: this._thinEffectLayer._isSubMeshReady(subMesh, useInstances, emissiveTexture);
|
|
519
323
|
}
|
|
324
|
+
async _importShadersAsync() { }
|
|
520
325
|
_arePostProcessAndMergeReady() {
|
|
521
|
-
|
|
522
|
-
for (let i = 0; i < this._postProcesses.length; i++) {
|
|
523
|
-
isReady = this._postProcesses[i].isReady() && isReady;
|
|
524
|
-
}
|
|
525
|
-
const numDraws = this._numInternalDraws();
|
|
526
|
-
for (let i = 0; i < numDraws; ++i) {
|
|
527
|
-
let currentEffect = this._mergeDrawWrapper[i];
|
|
528
|
-
if (!currentEffect) {
|
|
529
|
-
currentEffect = this._mergeDrawWrapper[i] = new DrawWrapper(this._engine);
|
|
530
|
-
currentEffect.setEffect(this._createMergeEffect());
|
|
531
|
-
}
|
|
532
|
-
isReady = currentEffect.effect.isReady() && isReady;
|
|
533
|
-
}
|
|
534
|
-
return isReady;
|
|
326
|
+
return this._internalThinEffectLayer ? this._thinEffectLayer._internalIsLayerReady() : this._thinEffectLayer.isLayerReady();
|
|
535
327
|
}
|
|
536
328
|
/**
|
|
537
329
|
* Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
|
|
538
330
|
*/
|
|
539
331
|
render() {
|
|
540
|
-
if (!this.
|
|
332
|
+
if (!this._thinEffectLayer.compose()) {
|
|
541
333
|
return;
|
|
542
334
|
}
|
|
543
|
-
const engine = this._scene.getEngine();
|
|
544
|
-
const numDraws = this._numInternalDraws();
|
|
545
|
-
this.onBeforeComposeObservable.notifyObservers(this);
|
|
546
|
-
const previousAlphaMode = engine.getAlphaMode();
|
|
547
|
-
for (let i = 0; i < numDraws; ++i) {
|
|
548
|
-
const currentEffect = this._mergeDrawWrapper[i];
|
|
549
|
-
// Render
|
|
550
|
-
engine.enableEffect(currentEffect);
|
|
551
|
-
engine.setState(false);
|
|
552
|
-
// VBOs
|
|
553
|
-
engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect.effect);
|
|
554
|
-
// Go Blend.
|
|
555
|
-
engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
|
|
556
|
-
// Blends the map on the main canvas.
|
|
557
|
-
this._internalRender(currentEffect.effect, i);
|
|
558
|
-
}
|
|
559
|
-
// Restore Alpha
|
|
560
|
-
engine.setAlphaMode(previousAlphaMode);
|
|
561
|
-
this.onAfterComposeObservable.notifyObservers(this);
|
|
562
335
|
// Handle size changes.
|
|
563
336
|
const size = this._mainTexture.getSize();
|
|
564
337
|
this._setMainTextureSize();
|
|
@@ -578,17 +351,14 @@ export class EffectLayer {
|
|
|
578
351
|
* @returns true if the mesh will be used
|
|
579
352
|
*/
|
|
580
353
|
hasMesh(mesh) {
|
|
581
|
-
|
|
582
|
-
return true;
|
|
583
|
-
}
|
|
584
|
-
return false;
|
|
354
|
+
return this._internalThinEffectLayer ? this._thinEffectLayer._internalHasMesh(mesh) : this._thinEffectLayer.hasMesh(mesh);
|
|
585
355
|
}
|
|
586
356
|
/**
|
|
587
357
|
* Returns true if the layer contains information to display, otherwise false.
|
|
588
358
|
* @returns true if the glow layer should be rendered
|
|
589
359
|
*/
|
|
590
360
|
shouldRender() {
|
|
591
|
-
return this.
|
|
361
|
+
return this._internalThinEffectLayer ? this._thinEffectLayer._internalShouldRender() : this._thinEffectLayer.shouldRender();
|
|
592
362
|
}
|
|
593
363
|
/**
|
|
594
364
|
* Returns true if the mesh should render, otherwise false.
|
|
@@ -597,7 +367,7 @@ export class EffectLayer {
|
|
|
597
367
|
*/
|
|
598
368
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
599
369
|
_shouldRenderMesh(mesh) {
|
|
600
|
-
return true;
|
|
370
|
+
return this._internalThinEffectLayer ? true : this._thinEffectLayer._shouldRenderMesh(mesh);
|
|
601
371
|
}
|
|
602
372
|
/**
|
|
603
373
|
* Returns true if the mesh can be rendered, otherwise false.
|
|
@@ -606,7 +376,7 @@ export class EffectLayer {
|
|
|
606
376
|
* @returns true if it can be rendered otherwise false
|
|
607
377
|
*/
|
|
608
378
|
_canRenderMesh(mesh, material) {
|
|
609
|
-
return
|
|
379
|
+
return this._internalThinEffectLayer ? this._thinEffectLayer._internalCanRenderMesh(mesh, material) : this._thinEffectLayer._canRenderMesh(mesh, material);
|
|
610
380
|
}
|
|
611
381
|
/**
|
|
612
382
|
* Returns true if the mesh should render, otherwise false.
|
|
@@ -615,140 +385,6 @@ export class EffectLayer {
|
|
|
615
385
|
_shouldRenderEmissiveTextureForMesh() {
|
|
616
386
|
return true;
|
|
617
387
|
}
|
|
618
|
-
/**
|
|
619
|
-
* Renders the submesh passed in parameter to the generation map.
|
|
620
|
-
* @param subMesh
|
|
621
|
-
* @param enableAlphaMode
|
|
622
|
-
*/
|
|
623
|
-
_renderSubMesh(subMesh, enableAlphaMode = false) {
|
|
624
|
-
if (!this.shouldRender()) {
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
const material = subMesh.getMaterial();
|
|
628
|
-
const ownerMesh = subMesh.getMesh();
|
|
629
|
-
const replacementMesh = subMesh.getReplacementMesh();
|
|
630
|
-
const renderingMesh = subMesh.getRenderingMesh();
|
|
631
|
-
const effectiveMesh = subMesh.getEffectiveMesh();
|
|
632
|
-
const scene = this._scene;
|
|
633
|
-
const engine = scene.getEngine();
|
|
634
|
-
effectiveMesh._internalAbstractMeshDataInfo._isActiveIntermediate = false;
|
|
635
|
-
if (!material) {
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
// Do not block in blend mode.
|
|
639
|
-
if (!this._canRenderMesh(renderingMesh, material)) {
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
// Culling
|
|
643
|
-
let sideOrientation = material._getEffectiveOrientation(renderingMesh);
|
|
644
|
-
const mainDeterminant = effectiveMesh._getWorldMatrixDeterminant();
|
|
645
|
-
if (mainDeterminant < 0) {
|
|
646
|
-
sideOrientation = sideOrientation === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
|
|
647
|
-
}
|
|
648
|
-
const reverse = sideOrientation === Material.ClockWiseSideOrientation;
|
|
649
|
-
engine.setState(material.backFaceCulling, material.zOffset, undefined, reverse, material.cullBackFaces, undefined, material.zOffsetUnits);
|
|
650
|
-
// Managing instances
|
|
651
|
-
const batch = renderingMesh._getInstancesRenderList(subMesh._id, !!replacementMesh);
|
|
652
|
-
if (batch.mustReturn) {
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
// Early Exit per mesh
|
|
656
|
-
if (!this._shouldRenderMesh(renderingMesh)) {
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
const hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id] || renderingMesh.hasThinInstances;
|
|
660
|
-
this._setEmissiveTextureAndColor(renderingMesh, subMesh, material);
|
|
661
|
-
this.onBeforeRenderMeshToEffect.notifyObservers(ownerMesh);
|
|
662
|
-
if (this._useMeshMaterial(renderingMesh)) {
|
|
663
|
-
subMesh.getMaterial()._glowModeEnabled = true;
|
|
664
|
-
renderingMesh.render(subMesh, enableAlphaMode, replacementMesh || undefined);
|
|
665
|
-
subMesh.getMaterial()._glowModeEnabled = false;
|
|
666
|
-
}
|
|
667
|
-
else if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
|
|
668
|
-
const renderingMaterial = effectiveMesh._internalAbstractMeshDataInfo._materialForRenderPass?.[engine.currentRenderPassId];
|
|
669
|
-
let drawWrapper = subMesh._getDrawWrapper();
|
|
670
|
-
if (!drawWrapper && renderingMaterial) {
|
|
671
|
-
drawWrapper = renderingMaterial._getDrawWrapper();
|
|
672
|
-
}
|
|
673
|
-
if (!drawWrapper) {
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
const effect = drawWrapper.effect;
|
|
677
|
-
engine.enableEffect(drawWrapper);
|
|
678
|
-
if (!hardwareInstancedRendering) {
|
|
679
|
-
renderingMesh._bind(subMesh, effect, material.fillMode);
|
|
680
|
-
}
|
|
681
|
-
if (!renderingMaterial) {
|
|
682
|
-
effect.setMatrix("viewProjection", scene.getTransformMatrix());
|
|
683
|
-
effect.setMatrix("world", effectiveMesh.getWorldMatrix());
|
|
684
|
-
effect.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
|
|
685
|
-
}
|
|
686
|
-
else {
|
|
687
|
-
renderingMaterial.bindForSubMesh(effectiveMesh.getWorldMatrix(), effectiveMesh, subMesh);
|
|
688
|
-
}
|
|
689
|
-
if (!renderingMaterial) {
|
|
690
|
-
const needAlphaTest = material.needAlphaTesting();
|
|
691
|
-
const diffuseTexture = material.getAlphaTestTexture();
|
|
692
|
-
const needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha && (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
|
|
693
|
-
if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
|
|
694
|
-
effect.setTexture("diffuseSampler", diffuseTexture);
|
|
695
|
-
const textureMatrix = diffuseTexture.getTextureMatrix();
|
|
696
|
-
if (textureMatrix) {
|
|
697
|
-
effect.setMatrix("diffuseMatrix", textureMatrix);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
const opacityTexture = material.opacityTexture;
|
|
701
|
-
if (opacityTexture) {
|
|
702
|
-
effect.setTexture("opacitySampler", opacityTexture);
|
|
703
|
-
effect.setFloat("opacityIntensity", opacityTexture.level);
|
|
704
|
-
const textureMatrix = opacityTexture.getTextureMatrix();
|
|
705
|
-
if (textureMatrix) {
|
|
706
|
-
effect.setMatrix("opacityMatrix", textureMatrix);
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
// Glow emissive only
|
|
710
|
-
if (this._emissiveTextureAndColor.texture) {
|
|
711
|
-
effect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
|
|
712
|
-
effect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
|
|
713
|
-
}
|
|
714
|
-
// Bones
|
|
715
|
-
if (renderingMesh.useBones && renderingMesh.computeBonesUsingShaders && renderingMesh.skeleton) {
|
|
716
|
-
const skeleton = renderingMesh.skeleton;
|
|
717
|
-
if (skeleton.isUsingTextureForMatrices) {
|
|
718
|
-
const boneTexture = skeleton.getTransformMatrixTexture(renderingMesh);
|
|
719
|
-
if (!boneTexture) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
effect.setTexture("boneSampler", boneTexture);
|
|
723
|
-
effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
|
|
724
|
-
}
|
|
725
|
-
else {
|
|
726
|
-
effect.setMatrices("mBones", skeleton.getTransformMatrices(renderingMesh));
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
// Morph targets
|
|
730
|
-
BindMorphTargetParameters(renderingMesh, effect);
|
|
731
|
-
if (renderingMesh.morphTargetManager && renderingMesh.morphTargetManager.isUsingTextureForTargets) {
|
|
732
|
-
renderingMesh.morphTargetManager._bind(effect);
|
|
733
|
-
}
|
|
734
|
-
// Alpha mode
|
|
735
|
-
if (enableAlphaMode) {
|
|
736
|
-
engine.setAlphaMode(material.alphaMode);
|
|
737
|
-
}
|
|
738
|
-
// Intensity of effect
|
|
739
|
-
effect.setFloat("glowIntensity", this.getEffectIntensity(renderingMesh));
|
|
740
|
-
// Clip planes
|
|
741
|
-
bindClipPlane(effect, material, scene);
|
|
742
|
-
}
|
|
743
|
-
// Draw
|
|
744
|
-
renderingMesh._processRendering(effectiveMesh, subMesh, effect, material.fillMode, batch, hardwareInstancedRendering, (isInstance, world) => effect.setMatrix("world", world));
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
// Need to reset refresh rate of the main map
|
|
748
|
-
this._mainTexture.resetRefreshCounter();
|
|
749
|
-
}
|
|
750
|
-
this.onAfterRenderMeshToEffect.notifyObservers(ownerMesh);
|
|
751
|
-
}
|
|
752
388
|
/**
|
|
753
389
|
* Defines whether the current material of the mesh should be use to render the effect.
|
|
754
390
|
* @param mesh defines the current mesh to render
|
|
@@ -756,18 +392,14 @@ export class EffectLayer {
|
|
|
756
392
|
*/
|
|
757
393
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
758
394
|
_useMeshMaterial(mesh) {
|
|
759
|
-
return false;
|
|
395
|
+
return this._internalThinEffectLayer ? false : this._thinEffectLayer._useMeshMaterial(mesh);
|
|
760
396
|
}
|
|
761
397
|
/**
|
|
762
398
|
* Rebuild the required buffers.
|
|
763
399
|
* @internal Internal use only.
|
|
764
400
|
*/
|
|
765
401
|
_rebuild() {
|
|
766
|
-
|
|
767
|
-
if (vb) {
|
|
768
|
-
vb._rebuild();
|
|
769
|
-
}
|
|
770
|
-
this._generateIndexBuffer();
|
|
402
|
+
this._thinEffectLayer._rebuild();
|
|
771
403
|
}
|
|
772
404
|
/**
|
|
773
405
|
* Dispose only the render target textures and post process.
|
|
@@ -791,19 +423,7 @@ export class EffectLayer {
|
|
|
791
423
|
* Dispose the highlight layer and free resources.
|
|
792
424
|
*/
|
|
793
425
|
dispose() {
|
|
794
|
-
|
|
795
|
-
if (vertexBuffer) {
|
|
796
|
-
vertexBuffer.dispose();
|
|
797
|
-
this._vertexBuffers[VertexBuffer.PositionKind] = null;
|
|
798
|
-
}
|
|
799
|
-
if (this._indexBuffer) {
|
|
800
|
-
this._scene.getEngine()._releaseBuffer(this._indexBuffer);
|
|
801
|
-
this._indexBuffer = null;
|
|
802
|
-
}
|
|
803
|
-
for (const drawWrapper of this._mergeDrawWrapper) {
|
|
804
|
-
drawWrapper.dispose();
|
|
805
|
-
}
|
|
806
|
-
this._mergeDrawWrapper = [];
|
|
426
|
+
this._thinEffectLayer.dispose();
|
|
807
427
|
// Clean textures and post processes
|
|
808
428
|
this._disposeTextureAndPostProcesses();
|
|
809
429
|
// Remove from scene
|
|
@@ -812,7 +432,6 @@ export class EffectLayer {
|
|
|
812
432
|
this._scene.effectLayers.splice(index, 1);
|
|
813
433
|
}
|
|
814
434
|
// Callback
|
|
815
|
-
this.onDisposeObservable.notifyObservers(this);
|
|
816
435
|
this.onDisposeObservable.clear();
|
|
817
436
|
this.onBeforeRenderMainTextureObservable.clear();
|
|
818
437
|
this.onBeforeComposeObservable.clear();
|
|
@@ -840,11 +459,6 @@ export class EffectLayer {
|
|
|
840
459
|
return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
|
|
841
460
|
}
|
|
842
461
|
}
|
|
843
|
-
/**
|
|
844
|
-
* Force all the effect layers to compile to glsl even on WebGPU engines.
|
|
845
|
-
* False by default. This is mostly meant for backward compatibility.
|
|
846
|
-
*/
|
|
847
|
-
EffectLayer.ForceGLSL = false;
|
|
848
462
|
/**
|
|
849
463
|
* @internal
|
|
850
464
|
*/
|
|
@@ -853,13 +467,13 @@ EffectLayer._SceneComponentInitialization = (_) => {
|
|
|
853
467
|
};
|
|
854
468
|
__decorate([
|
|
855
469
|
serialize()
|
|
856
|
-
], EffectLayer.prototype, "name",
|
|
470
|
+
], EffectLayer.prototype, "name", null);
|
|
857
471
|
__decorate([
|
|
858
472
|
serializeAsColor4()
|
|
859
|
-
], EffectLayer.prototype, "neutralColor",
|
|
473
|
+
], EffectLayer.prototype, "neutralColor", null);
|
|
860
474
|
__decorate([
|
|
861
475
|
serialize()
|
|
862
|
-
], EffectLayer.prototype, "isEnabled",
|
|
476
|
+
], EffectLayer.prototype, "isEnabled", null);
|
|
863
477
|
__decorate([
|
|
864
478
|
serializeAsCameraReference()
|
|
865
479
|
], EffectLayer.prototype, "camera", null);
|
|
@@ -868,5 +482,5 @@ __decorate([
|
|
|
868
482
|
], EffectLayer.prototype, "renderingGroupId", null);
|
|
869
483
|
__decorate([
|
|
870
484
|
serialize()
|
|
871
|
-
], EffectLayer.prototype, "disableBoundingBoxesFromEffectLayer",
|
|
485
|
+
], EffectLayer.prototype, "disableBoundingBoxesFromEffectLayer", null);
|
|
872
486
|
//# sourceMappingURL=effectLayer.js.map
|