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