@babylonjs/materials 5.0.0-rc.5 → 5.0.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/cell/cell.fragment.d.ts +17 -17
  2. package/cell/cell.fragment.js +20 -20
  3. package/cell/cell.vertex.d.ts +18 -18
  4. package/cell/cell.vertex.js +21 -21
  5. package/cell/cellMaterial.d.ts +37 -37
  6. package/cell/cellMaterial.js +304 -304
  7. package/cell/index.d.ts +1 -1
  8. package/cell/index.js +1 -1
  9. package/custom/customMaterial.d.ts +69 -69
  10. package/custom/customMaterial.js +216 -216
  11. package/custom/index.d.ts +2 -2
  12. package/custom/index.js +2 -2
  13. package/custom/pbrCustomMaterial.d.ts +71 -71
  14. package/custom/pbrCustomMaterial.js +241 -241
  15. package/fire/fire.fragment.d.ts +11 -11
  16. package/fire/fire.fragment.js +14 -14
  17. package/fire/fire.vertex.d.ts +15 -15
  18. package/fire/fire.vertex.js +18 -18
  19. package/fire/fireMaterial.d.ts +38 -38
  20. package/fire/fireMaterial.js +342 -342
  21. package/fire/index.d.ts +1 -1
  22. package/fire/index.js +1 -1
  23. package/fur/fur.fragment.d.ts +17 -17
  24. package/fur/fur.fragment.js +20 -20
  25. package/fur/fur.vertex.d.ts +18 -18
  26. package/fur/fur.vertex.js +21 -21
  27. package/fur/furMaterial.d.ts +56 -56
  28. package/fur/furMaterial.js +500 -500
  29. package/fur/index.d.ts +1 -1
  30. package/fur/index.js +1 -1
  31. package/gradient/gradient.fragment.d.ts +17 -17
  32. package/gradient/gradient.fragment.js +20 -20
  33. package/gradient/gradient.vertex.d.ts +18 -18
  34. package/gradient/gradient.vertex.js +21 -21
  35. package/gradient/gradientMaterial.d.ts +37 -37
  36. package/gradient/gradientMaterial.js +275 -275
  37. package/gradient/index.d.ts +1 -1
  38. package/gradient/index.js +1 -1
  39. package/grid/grid.fragment.d.ts +8 -8
  40. package/grid/grid.fragment.js +11 -11
  41. package/grid/grid.vertex.d.ts +9 -9
  42. package/grid/grid.vertex.js +12 -12
  43. package/grid/gridMaterial.d.ts +77 -77
  44. package/grid/gridMaterial.js +276 -276
  45. package/grid/index.d.ts +1 -1
  46. package/grid/index.js +1 -1
  47. package/index.d.ts +15 -15
  48. package/index.js +15 -15
  49. package/lava/index.d.ts +1 -1
  50. package/lava/index.js +1 -1
  51. package/lava/lava.fragment.d.ts +17 -17
  52. package/lava/lava.fragment.js +20 -20
  53. package/lava/lava.vertex.d.ts +18 -18
  54. package/lava/lava.vertex.js +21 -21
  55. package/lava/lavaMaterial.d.ts +45 -45
  56. package/lava/lavaMaterial.js +394 -394
  57. package/legacy/legacy-cell.d.ts +1 -1
  58. package/legacy/legacy-cell.js +12 -12
  59. package/legacy/legacy-custom.d.ts +1 -1
  60. package/legacy/legacy-custom.js +12 -12
  61. package/legacy/legacy-fire.d.ts +1 -1
  62. package/legacy/legacy-fire.js +12 -12
  63. package/legacy/legacy-fur.d.ts +1 -1
  64. package/legacy/legacy-fur.js +12 -12
  65. package/legacy/legacy-gradient.d.ts +1 -1
  66. package/legacy/legacy-gradient.js +12 -12
  67. package/legacy/legacy-grid.d.ts +1 -1
  68. package/legacy/legacy-grid.js +12 -12
  69. package/legacy/legacy-lava.d.ts +1 -1
  70. package/legacy/legacy-lava.js +12 -12
  71. package/legacy/legacy-mix.d.ts +1 -1
  72. package/legacy/legacy-mix.js +12 -12
  73. package/legacy/legacy-normal.d.ts +1 -1
  74. package/legacy/legacy-normal.js +12 -12
  75. package/legacy/legacy-shadowOnly.d.ts +1 -1
  76. package/legacy/legacy-shadowOnly.js +12 -12
  77. package/legacy/legacy-simple.d.ts +1 -1
  78. package/legacy/legacy-simple.js +12 -12
  79. package/legacy/legacy-sky.d.ts +1 -1
  80. package/legacy/legacy-sky.js +12 -12
  81. package/legacy/legacy-terrain.d.ts +1 -1
  82. package/legacy/legacy-terrain.js +12 -12
  83. package/legacy/legacy-triPlanar.d.ts +1 -1
  84. package/legacy/legacy-triPlanar.js +12 -12
  85. package/legacy/legacy-water.d.ts +1 -1
  86. package/legacy/legacy-water.js +12 -12
  87. package/legacy/legacy.d.ts +1 -1
  88. package/legacy/legacy.js +15 -15
  89. package/mix/index.d.ts +1 -1
  90. package/mix/index.js +1 -1
  91. package/mix/mix.fragment.d.ts +17 -17
  92. package/mix/mix.fragment.js +20 -20
  93. package/mix/mix.vertex.d.ts +18 -18
  94. package/mix/mix.vertex.js +21 -21
  95. package/mix/mixMaterial.d.ts +65 -65
  96. package/mix/mixMaterial.js +510 -510
  97. package/normal/index.d.ts +1 -1
  98. package/normal/index.js +1 -1
  99. package/normal/normal.fragment.d.ts +17 -17
  100. package/normal/normal.fragment.js +20 -20
  101. package/normal/normal.vertex.d.ts +18 -18
  102. package/normal/normal.vertex.js +21 -21
  103. package/normal/normalMaterial.d.ts +36 -36
  104. package/normal/normalMaterial.js +336 -336
  105. package/package.json +2 -2
  106. package/shadowOnly/index.d.ts +1 -1
  107. package/shadowOnly/index.js +1 -1
  108. package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
  109. package/shadowOnly/shadowOnly.fragment.js +19 -19
  110. package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
  111. package/shadowOnly/shadowOnly.vertex.js +21 -21
  112. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
  113. package/shadowOnly/shadowOnlyMaterial.js +254 -254
  114. package/simple/index.d.ts +1 -1
  115. package/simple/index.js +1 -1
  116. package/simple/simple.fragment.d.ts +17 -17
  117. package/simple/simple.fragment.js +20 -20
  118. package/simple/simple.vertex.d.ts +18 -18
  119. package/simple/simple.vertex.js +21 -21
  120. package/simple/simpleMaterial.d.ts +35 -35
  121. package/simple/simpleMaterial.js +295 -295
  122. package/sky/index.d.ts +1 -1
  123. package/sky/index.js +1 -1
  124. package/sky/sky.fragment.d.ts +10 -10
  125. package/sky/sky.fragment.js +13 -13
  126. package/sky/sky.vertex.d.ts +9 -9
  127. package/sky/sky.vertex.js +12 -12
  128. package/sky/skyMaterial.d.ts +146 -146
  129. package/sky/skyMaterial.js +359 -359
  130. package/terrain/index.d.ts +1 -1
  131. package/terrain/index.js +1 -1
  132. package/terrain/terrain.fragment.d.ts +17 -17
  133. package/terrain/terrain.fragment.js +20 -20
  134. package/terrain/terrain.vertex.d.ts +18 -18
  135. package/terrain/terrain.vertex.js +21 -21
  136. package/terrain/terrainMaterial.d.ts +50 -50
  137. package/terrain/terrainMaterial.js +426 -426
  138. package/triPlanar/index.d.ts +1 -1
  139. package/triPlanar/index.js +1 -1
  140. package/triPlanar/triPlanarMaterial.d.ts +49 -49
  141. package/triPlanar/triPlanarMaterial.js +403 -403
  142. package/triPlanar/triplanar.fragment.d.ts +17 -17
  143. package/triPlanar/triplanar.fragment.js +20 -20
  144. package/triPlanar/triplanar.vertex.d.ts +18 -18
  145. package/triPlanar/triplanar.vertex.js +21 -21
  146. package/water/index.d.ts +1 -1
  147. package/water/index.js +1 -1
  148. package/water/water.fragment.d.ts +19 -19
  149. package/water/water.fragment.js +22 -22
  150. package/water/water.vertex.d.ts +20 -20
  151. package/water/water.vertex.js +23 -23
  152. package/water/waterMaterial.d.ts +135 -135
  153. package/water/waterMaterial.js +736 -736
@@ -1,255 +1,255 @@
1
- import { __extends } from "tslib";
2
- import { SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
- import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
- import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
- import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
- import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
- import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
8
- import { Scene } from "@babylonjs/core/scene.js";
9
- import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
10
- import "./shadowOnly.fragment.js";
11
- import "./shadowOnly.vertex.js";
12
- import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
13
- var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
14
- __extends(ShadowOnlyMaterialDefines, _super);
15
- function ShadowOnlyMaterialDefines() {
16
- var _this = _super.call(this) || this;
17
- _this.CLIPPLANE = false;
18
- _this.CLIPPLANE2 = false;
19
- _this.CLIPPLANE3 = false;
20
- _this.CLIPPLANE4 = false;
21
- _this.CLIPPLANE5 = false;
22
- _this.CLIPPLANE6 = false;
23
- _this.POINTSIZE = false;
24
- _this.FOG = false;
25
- _this.NORMAL = false;
26
- _this.NUM_BONE_INFLUENCERS = 0;
27
- _this.BonesPerMesh = 0;
28
- _this.INSTANCES = false;
29
- _this.IMAGEPROCESSINGPOSTPROCESS = false;
30
- _this.SKIPFINALCOLORCLAMP = false;
31
- _this.rebuild();
32
- return _this;
33
- }
34
- return ShadowOnlyMaterialDefines;
35
- }(MaterialDefines));
36
- var ShadowOnlyMaterial = /** @class */ (function (_super) {
37
- __extends(ShadowOnlyMaterial, _super);
38
- function ShadowOnlyMaterial(name, scene) {
39
- var _this = _super.call(this, name, scene) || this;
40
- _this._needAlphaBlending = true;
41
- _this.shadowColor = Color3.Black();
42
- return _this;
43
- }
44
- ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
45
- return this._needAlphaBlending;
46
- };
47
- ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
48
- return false;
49
- };
50
- ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
51
- return null;
52
- };
53
- Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
54
- get: function () {
55
- return this._activeLight;
56
- },
57
- set: function (light) {
58
- this._activeLight = light;
59
- },
60
- enumerable: false,
61
- configurable: true
62
- });
63
- ShadowOnlyMaterial.prototype._getFirstShadowLightForMesh = function (mesh) {
64
- for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
65
- var light = _a[_i];
66
- if (light.shadowEnabled) {
67
- return light;
68
- }
69
- }
70
- return null;
71
- };
72
- // Methods
73
- ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
74
- var _a;
75
- if (this.isFrozen) {
76
- if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
77
- return true;
78
- }
79
- }
80
- if (!subMesh.materialDefines) {
81
- subMesh.materialDefines = new ShadowOnlyMaterialDefines();
82
- }
83
- var defines = subMesh.materialDefines;
84
- var scene = this.getScene();
85
- if (this._isReadyForSubMesh(subMesh)) {
86
- return true;
87
- }
88
- var engine = scene.getEngine();
89
- // Ensure that active light is the first shadow light
90
- if (this._activeLight) {
91
- for (var _i = 0, _b = mesh.lightSources; _i < _b.length; _i++) {
92
- var light = _b[_i];
93
- if (light.shadowEnabled) {
94
- if (this._activeLight === light) {
95
- break; // We are good
96
- }
97
- var lightPosition = mesh.lightSources.indexOf(this._activeLight);
98
- if (lightPosition !== -1) {
99
- mesh.lightSources.splice(lightPosition, 1);
100
- mesh.lightSources.splice(0, 0, this._activeLight);
101
- }
102
- break;
103
- }
104
- }
105
- }
106
- MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
107
- MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
108
- defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
109
- var shadowGenerator = (_a = this._getFirstShadowLightForMesh(mesh)) === null || _a === void 0 ? void 0 : _a.getShadowGenerator();
110
- this._needAlphaBlending = true;
111
- if (shadowGenerator && shadowGenerator.getClassName && shadowGenerator.getClassName() === "CascadedShadowGenerator") {
112
- var csg = shadowGenerator;
113
- this._needAlphaBlending = !csg.autoCalcDepthBounds;
114
- }
115
- // Attribs
116
- MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
117
- // Get correct effect
118
- if (defines.isDirty) {
119
- defines.markAsProcessed();
120
- scene.resetCachedMaterial();
121
- // Fallbacks
122
- var fallbacks = new EffectFallbacks();
123
- if (defines.FOG) {
124
- fallbacks.addFallback(1, "FOG");
125
- }
126
- MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, 1);
127
- if (defines.NUM_BONE_INFLUENCERS > 0) {
128
- fallbacks.addCPUSkinningFallback(0, mesh);
129
- }
130
- defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
131
- //Attributes
132
- var attribs = [VertexBuffer.PositionKind];
133
- if (defines.NORMAL) {
134
- attribs.push(VertexBuffer.NormalKind);
135
- }
136
- MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
137
- MaterialHelper.PrepareAttributesForInstances(attribs, defines);
138
- var shaderName = "shadowOnly";
139
- var join = defines.toString();
140
- var uniforms = [
141
- "world",
142
- "view",
143
- "viewProjection",
144
- "vEyePosition",
145
- "vLightsType",
146
- "vFogInfos",
147
- "vFogColor",
148
- "pointSize",
149
- "alpha",
150
- "shadowColor",
151
- "mBones",
152
- "vClipPlane",
153
- "vClipPlane2",
154
- "vClipPlane3",
155
- "vClipPlane4",
156
- "vClipPlane5",
157
- "vClipPlane6",
158
- ];
159
- var samplers = new Array();
160
- var uniformBuffers = new Array();
161
- MaterialHelper.PrepareUniformsAndSamplersList({
162
- uniformsNames: uniforms,
163
- uniformBuffersNames: uniformBuffers,
164
- samplers: samplers,
165
- defines: defines,
166
- maxSimultaneousLights: 1,
167
- });
168
- subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
169
- attributes: attribs,
170
- uniformsNames: uniforms,
171
- uniformBuffersNames: uniformBuffers,
172
- samplers: samplers,
173
- defines: join,
174
- fallbacks: fallbacks,
175
- onCompiled: this.onCompiled,
176
- onError: this.onError,
177
- indexParameters: { maxSimultaneousLights: 1 },
178
- }, engine), defines, this._materialContext);
179
- }
180
- if (!subMesh.effect || !subMesh.effect.isReady()) {
181
- return false;
182
- }
183
- defines._renderId = scene.getRenderId();
184
- subMesh.effect._wasPreviouslyReady = true;
185
- return true;
186
- };
187
- ShadowOnlyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
188
- var scene = this.getScene();
189
- var defines = subMesh.materialDefines;
190
- if (!defines) {
191
- return;
192
- }
193
- var effect = subMesh.effect;
194
- if (!effect) {
195
- return;
196
- }
197
- this._activeEffect = effect;
198
- // Matrices
199
- this.bindOnlyWorldMatrix(world);
200
- this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
201
- // Bones
202
- MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
203
- if (this._mustRebind(scene, effect)) {
204
- // Clip plane
205
- MaterialHelper.BindClipPlane(this._activeEffect, scene);
206
- // Point size
207
- if (this.pointsCloud) {
208
- this._activeEffect.setFloat("pointSize", this.pointSize);
209
- }
210
- this._activeEffect.setFloat("alpha", this.alpha);
211
- this._activeEffect.setColor3("shadowColor", this.shadowColor);
212
- scene.bindEyePosition(effect);
213
- }
214
- // Lights
215
- if (scene.lightsEnabled) {
216
- MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, 1);
217
- var light = this._getFirstShadowLightForMesh(mesh);
218
- if (light) {
219
- // Make sure the uniforms for this light will be rebound for other materials using this light when rendering the current frame.
220
- // Indeed, there is an optimization in Light that binds the light uniforms only once per frame for a given light (if using ubo).
221
- // Doing this way assumes that all uses of this light are the same, meaning all parameters passed to Light._bindLlight
222
- // are the same, notably useSpecular. However, isReadyForSubMesh (see above) is passing false for this parameter, which may not be
223
- // the value the other materials may pass.
224
- light._renderId = -1;
225
- }
226
- }
227
- // View
228
- if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) || defines["SHADOWCSM0"]) {
229
- this._activeEffect.setMatrix("view", scene.getViewMatrix());
230
- }
231
- // Fog
232
- MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
233
- this._afterBind(mesh, this._activeEffect);
234
- };
235
- ShadowOnlyMaterial.prototype.clone = function (name) {
236
- var _this = this;
237
- return SerializationHelper.Clone(function () { return new ShadowOnlyMaterial(name, _this.getScene()); }, this);
238
- };
239
- ShadowOnlyMaterial.prototype.serialize = function () {
240
- var serializationObject = _super.prototype.serialize.call(this);
241
- serializationObject.customType = "BABYLON.ShadowOnlyMaterial";
242
- return serializationObject;
243
- };
244
- ShadowOnlyMaterial.prototype.getClassName = function () {
245
- return "ShadowOnlyMaterial";
246
- };
247
- // Statics
248
- ShadowOnlyMaterial.Parse = function (source, scene, rootUrl) {
249
- return SerializationHelper.Parse(function () { return new ShadowOnlyMaterial(source.name, scene); }, source, scene, rootUrl);
250
- };
251
- return ShadowOnlyMaterial;
252
- }(PushMaterial));
253
- export { ShadowOnlyMaterial };
254
- RegisterClass("BABYLON.ShadowOnlyMaterial", ShadowOnlyMaterial);
1
+ import { __extends } from "tslib";
2
+ import { SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
3
+ import { Color3 } from "@babylonjs/core/Maths/math.color.js";
4
+ import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
5
+ import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
6
+ import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
7
+ import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
8
+ import { Scene } from "@babylonjs/core/scene.js";
9
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
10
+ import "./shadowOnly.fragment";
11
+ import "./shadowOnly.vertex";
12
+ import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
13
+ var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
14
+ __extends(ShadowOnlyMaterialDefines, _super);
15
+ function ShadowOnlyMaterialDefines() {
16
+ var _this = _super.call(this) || this;
17
+ _this.CLIPPLANE = false;
18
+ _this.CLIPPLANE2 = false;
19
+ _this.CLIPPLANE3 = false;
20
+ _this.CLIPPLANE4 = false;
21
+ _this.CLIPPLANE5 = false;
22
+ _this.CLIPPLANE6 = false;
23
+ _this.POINTSIZE = false;
24
+ _this.FOG = false;
25
+ _this.NORMAL = false;
26
+ _this.NUM_BONE_INFLUENCERS = 0;
27
+ _this.BonesPerMesh = 0;
28
+ _this.INSTANCES = false;
29
+ _this.IMAGEPROCESSINGPOSTPROCESS = false;
30
+ _this.SKIPFINALCOLORCLAMP = false;
31
+ _this.rebuild();
32
+ return _this;
33
+ }
34
+ return ShadowOnlyMaterialDefines;
35
+ }(MaterialDefines));
36
+ var ShadowOnlyMaterial = /** @class */ (function (_super) {
37
+ __extends(ShadowOnlyMaterial, _super);
38
+ function ShadowOnlyMaterial(name, scene) {
39
+ var _this = _super.call(this, name, scene) || this;
40
+ _this._needAlphaBlending = true;
41
+ _this.shadowColor = Color3.Black();
42
+ return _this;
43
+ }
44
+ ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
45
+ return this._needAlphaBlending;
46
+ };
47
+ ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
48
+ return false;
49
+ };
50
+ ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
51
+ return null;
52
+ };
53
+ Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
54
+ get: function () {
55
+ return this._activeLight;
56
+ },
57
+ set: function (light) {
58
+ this._activeLight = light;
59
+ },
60
+ enumerable: false,
61
+ configurable: true
62
+ });
63
+ ShadowOnlyMaterial.prototype._getFirstShadowLightForMesh = function (mesh) {
64
+ for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
65
+ var light = _a[_i];
66
+ if (light.shadowEnabled) {
67
+ return light;
68
+ }
69
+ }
70
+ return null;
71
+ };
72
+ // Methods
73
+ ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
74
+ var _a;
75
+ if (this.isFrozen) {
76
+ if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
77
+ return true;
78
+ }
79
+ }
80
+ if (!subMesh.materialDefines) {
81
+ subMesh.materialDefines = new ShadowOnlyMaterialDefines();
82
+ }
83
+ var defines = subMesh.materialDefines;
84
+ var scene = this.getScene();
85
+ if (this._isReadyForSubMesh(subMesh)) {
86
+ return true;
87
+ }
88
+ var engine = scene.getEngine();
89
+ // Ensure that active light is the first shadow light
90
+ if (this._activeLight) {
91
+ for (var _i = 0, _b = mesh.lightSources; _i < _b.length; _i++) {
92
+ var light = _b[_i];
93
+ if (light.shadowEnabled) {
94
+ if (this._activeLight === light) {
95
+ break; // We are good
96
+ }
97
+ var lightPosition = mesh.lightSources.indexOf(this._activeLight);
98
+ if (lightPosition !== -1) {
99
+ mesh.lightSources.splice(lightPosition, 1);
100
+ mesh.lightSources.splice(0, 0, this._activeLight);
101
+ }
102
+ break;
103
+ }
104
+ }
105
+ }
106
+ MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
107
+ MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
108
+ defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
109
+ var shadowGenerator = (_a = this._getFirstShadowLightForMesh(mesh)) === null || _a === void 0 ? void 0 : _a.getShadowGenerator();
110
+ this._needAlphaBlending = true;
111
+ if (shadowGenerator && shadowGenerator.getClassName && shadowGenerator.getClassName() === "CascadedShadowGenerator") {
112
+ var csg = shadowGenerator;
113
+ this._needAlphaBlending = !csg.autoCalcDepthBounds;
114
+ }
115
+ // Attribs
116
+ MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
117
+ // Get correct effect
118
+ if (defines.isDirty) {
119
+ defines.markAsProcessed();
120
+ scene.resetCachedMaterial();
121
+ // Fallbacks
122
+ var fallbacks = new EffectFallbacks();
123
+ if (defines.FOG) {
124
+ fallbacks.addFallback(1, "FOG");
125
+ }
126
+ MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, 1);
127
+ if (defines.NUM_BONE_INFLUENCERS > 0) {
128
+ fallbacks.addCPUSkinningFallback(0, mesh);
129
+ }
130
+ defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
131
+ //Attributes
132
+ var attribs = [VertexBuffer.PositionKind];
133
+ if (defines.NORMAL) {
134
+ attribs.push(VertexBuffer.NormalKind);
135
+ }
136
+ MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
137
+ MaterialHelper.PrepareAttributesForInstances(attribs, defines);
138
+ var shaderName = "shadowOnly";
139
+ var join = defines.toString();
140
+ var uniforms = [
141
+ "world",
142
+ "view",
143
+ "viewProjection",
144
+ "vEyePosition",
145
+ "vLightsType",
146
+ "vFogInfos",
147
+ "vFogColor",
148
+ "pointSize",
149
+ "alpha",
150
+ "shadowColor",
151
+ "mBones",
152
+ "vClipPlane",
153
+ "vClipPlane2",
154
+ "vClipPlane3",
155
+ "vClipPlane4",
156
+ "vClipPlane5",
157
+ "vClipPlane6",
158
+ ];
159
+ var samplers = new Array();
160
+ var uniformBuffers = new Array();
161
+ MaterialHelper.PrepareUniformsAndSamplersList({
162
+ uniformsNames: uniforms,
163
+ uniformBuffersNames: uniformBuffers,
164
+ samplers: samplers,
165
+ defines: defines,
166
+ maxSimultaneousLights: 1,
167
+ });
168
+ subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
169
+ attributes: attribs,
170
+ uniformsNames: uniforms,
171
+ uniformBuffersNames: uniformBuffers,
172
+ samplers: samplers,
173
+ defines: join,
174
+ fallbacks: fallbacks,
175
+ onCompiled: this.onCompiled,
176
+ onError: this.onError,
177
+ indexParameters: { maxSimultaneousLights: 1 },
178
+ }, engine), defines, this._materialContext);
179
+ }
180
+ if (!subMesh.effect || !subMesh.effect.isReady()) {
181
+ return false;
182
+ }
183
+ defines._renderId = scene.getRenderId();
184
+ subMesh.effect._wasPreviouslyReady = true;
185
+ return true;
186
+ };
187
+ ShadowOnlyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
188
+ var scene = this.getScene();
189
+ var defines = subMesh.materialDefines;
190
+ if (!defines) {
191
+ return;
192
+ }
193
+ var effect = subMesh.effect;
194
+ if (!effect) {
195
+ return;
196
+ }
197
+ this._activeEffect = effect;
198
+ // Matrices
199
+ this.bindOnlyWorldMatrix(world);
200
+ this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
201
+ // Bones
202
+ MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
203
+ if (this._mustRebind(scene, effect)) {
204
+ // Clip plane
205
+ MaterialHelper.BindClipPlane(this._activeEffect, scene);
206
+ // Point size
207
+ if (this.pointsCloud) {
208
+ this._activeEffect.setFloat("pointSize", this.pointSize);
209
+ }
210
+ this._activeEffect.setFloat("alpha", this.alpha);
211
+ this._activeEffect.setColor3("shadowColor", this.shadowColor);
212
+ scene.bindEyePosition(effect);
213
+ }
214
+ // Lights
215
+ if (scene.lightsEnabled) {
216
+ MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, 1);
217
+ var light = this._getFirstShadowLightForMesh(mesh);
218
+ if (light) {
219
+ // Make sure the uniforms for this light will be rebound for other materials using this light when rendering the current frame.
220
+ // Indeed, there is an optimization in Light that binds the light uniforms only once per frame for a given light (if using ubo).
221
+ // Doing this way assumes that all uses of this light are the same, meaning all parameters passed to Light._bindLlight
222
+ // are the same, notably useSpecular. However, isReadyForSubMesh (see above) is passing false for this parameter, which may not be
223
+ // the value the other materials may pass.
224
+ light._renderId = -1;
225
+ }
226
+ }
227
+ // View
228
+ if ((scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) || defines["SHADOWCSM0"]) {
229
+ this._activeEffect.setMatrix("view", scene.getViewMatrix());
230
+ }
231
+ // Fog
232
+ MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
233
+ this._afterBind(mesh, this._activeEffect);
234
+ };
235
+ ShadowOnlyMaterial.prototype.clone = function (name) {
236
+ var _this = this;
237
+ return SerializationHelper.Clone(function () { return new ShadowOnlyMaterial(name, _this.getScene()); }, this);
238
+ };
239
+ ShadowOnlyMaterial.prototype.serialize = function () {
240
+ var serializationObject = _super.prototype.serialize.call(this);
241
+ serializationObject.customType = "BABYLON.ShadowOnlyMaterial";
242
+ return serializationObject;
243
+ };
244
+ ShadowOnlyMaterial.prototype.getClassName = function () {
245
+ return "ShadowOnlyMaterial";
246
+ };
247
+ // Statics
248
+ ShadowOnlyMaterial.Parse = function (source, scene, rootUrl) {
249
+ return SerializationHelper.Parse(function () { return new ShadowOnlyMaterial(source.name, scene); }, source, scene, rootUrl);
250
+ };
251
+ return ShadowOnlyMaterial;
252
+ }(PushMaterial));
253
+ export { ShadowOnlyMaterial };
254
+ RegisterClass("BABYLON.ShadowOnlyMaterial", ShadowOnlyMaterial);
255
255
  //# sourceMappingURL=shadowOnlyMaterial.js.map
package/simple/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./simpleMaterial";
1
+ export * from "./simpleMaterial";
package/simple/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./simpleMaterial.js";
1
+ export * from "./simpleMaterial";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,17 +1,17 @@
1
- import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
2
- import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
4
- import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
5
- import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
6
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
7
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
8
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
9
- import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
10
- import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
11
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
12
- import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
13
- /** @hidden */
14
- export declare const simplePixelShader: {
15
- name: string;
16
- shader: string;
17
- };
1
+ import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
13
+ /** @hidden */
14
+ export declare const simplePixelShader: {
15
+ name: string;
16
+ shader: string;
17
+ };
@@ -1,21 +1,21 @@
1
- // Do not edit.
2
- import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
4
- import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
5
- import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
6
- import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
7
- import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
8
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
9
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
10
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
11
- import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
12
- import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
13
- import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
14
- import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
15
- var name = "simplePixelShader";
16
- var shader = "precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
17
- // Sideeffect
18
- ShaderStore.ShadersStore[name] = shader;
19
- /** @hidden */
20
- export var simplePixelShader = { name: name, shader: shader };
1
+ // Do not edit.
2
+ import { ShaderStore } from "@babylonjs/core/Engines/shaderStore.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/helperFunctions.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/lightsFragmentFunctions.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsFragmentFunctions.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragmentDeclaration.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneFragment.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/depthPrePass.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragment.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/fogFragment.js";
14
+ import "@babylonjs/core/Shaders/ShadersInclude/imageProcessingCompatibility.js";
15
+ var name = "simplePixelShader";
16
+ var shader = "precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
17
+ // Sideeffect
18
+ ShaderStore.ShadersStore[name] = shader;
19
+ /** @hidden */
20
+ export var simplePixelShader = { name: name, shader: shader };
21
21
  //# sourceMappingURL=simple.fragment.js.map
@@ -1,18 +1,18 @@
1
- import "@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.js";
2
- import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js";
3
- import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
4
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js";
5
- import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
6
- import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
7
- import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
8
- import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
9
- import "@babylonjs/core/Shaders/ShadersInclude/bonesVertex.js";
10
- import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.js";
11
- import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
12
- import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
13
- import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
14
- /** @hidden */
15
- export declare const simpleVertexShader: {
16
- name: string;
17
- shader: string;
18
- };
1
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesDeclaration.js";
2
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimationDeclaration.js";
3
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesDeclaration.js";
4
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertexDeclaration.js";
5
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertexDeclaration.js";
6
+ import "@babylonjs/core/Shaders/ShadersInclude/lightFragmentDeclaration.js";
7
+ import "@babylonjs/core/Shaders/ShadersInclude/lightUboDeclaration.js";
8
+ import "@babylonjs/core/Shaders/ShadersInclude/instancesVertex.js";
9
+ import "@babylonjs/core/Shaders/ShadersInclude/bonesVertex.js";
10
+ import "@babylonjs/core/Shaders/ShadersInclude/bakedVertexAnimation.js";
11
+ import "@babylonjs/core/Shaders/ShadersInclude/clipPlaneVertex.js";
12
+ import "@babylonjs/core/Shaders/ShadersInclude/fogVertex.js";
13
+ import "@babylonjs/core/Shaders/ShadersInclude/shadowsVertex.js";
14
+ /** @hidden */
15
+ export declare const simpleVertexShader: {
16
+ name: string;
17
+ shader: string;
18
+ };