@babylonjs/materials 5.0.0-rc.0 → 5.0.0-rc.11
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/cell/cell.fragment.d.ts +17 -17
- package/cell/cell.fragment.js +20 -18
- package/cell/cell.fragment.js.map +1 -1
- package/cell/cell.vertex.d.ts +18 -18
- package/cell/cell.vertex.js +21 -19
- package/cell/cell.vertex.js.map +1 -1
- package/cell/cellMaterial.d.ts +37 -37
- package/cell/cellMaterial.js +304 -290
- package/cell/cellMaterial.js.map +1 -1
- package/cell/index.d.ts +1 -1
- package/cell/index.js +1 -1
- package/cell/index.js.map +1 -1
- package/custom/customMaterial.d.ts +69 -69
- package/custom/customMaterial.js +216 -218
- package/custom/customMaterial.js.map +1 -1
- package/custom/index.d.ts +2 -2
- package/custom/index.js +2 -2
- package/custom/index.js.map +1 -1
- package/custom/pbrCustomMaterial.d.ts +71 -71
- package/custom/pbrCustomMaterial.js +241 -243
- package/custom/pbrCustomMaterial.js.map +1 -1
- package/fire/fire.fragment.d.ts +11 -11
- package/fire/fire.fragment.js +14 -12
- package/fire/fire.fragment.js.map +1 -1
- package/fire/fire.vertex.d.ts +15 -15
- package/fire/fire.vertex.js +18 -16
- package/fire/fire.vertex.js.map +1 -1
- package/fire/fireMaterial.d.ts +38 -38
- package/fire/fireMaterial.js +342 -327
- package/fire/fireMaterial.js.map +1 -1
- package/fire/index.d.ts +1 -1
- package/fire/index.js +1 -1
- package/fire/index.js.map +1 -1
- package/fur/fur.fragment.d.ts +17 -17
- package/fur/fur.fragment.js +20 -18
- package/fur/fur.fragment.js.map +1 -1
- package/fur/fur.vertex.d.ts +18 -18
- package/fur/fur.vertex.js +21 -19
- package/fur/fur.vertex.js.map +1 -1
- package/fur/furMaterial.d.ts +57 -56
- package/fur/furMaterial.js +500 -480
- package/fur/furMaterial.js.map +1 -1
- package/fur/index.d.ts +1 -1
- package/fur/index.js +1 -1
- package/fur/index.js.map +1 -1
- package/gradient/gradient.fragment.d.ts +17 -17
- package/gradient/gradient.fragment.js +20 -18
- package/gradient/gradient.fragment.js.map +1 -1
- package/gradient/gradient.vertex.d.ts +18 -18
- package/gradient/gradient.vertex.js +21 -19
- package/gradient/gradient.vertex.js.map +1 -1
- package/gradient/gradientMaterial.d.ts +37 -37
- package/gradient/gradientMaterial.js +275 -259
- package/gradient/gradientMaterial.js.map +1 -1
- package/gradient/index.d.ts +1 -1
- package/gradient/index.js +1 -1
- package/gradient/index.js.map +1 -1
- package/grid/grid.fragment.d.ts +8 -8
- package/grid/grid.fragment.js +11 -9
- package/grid/grid.fragment.js.map +1 -1
- package/grid/grid.vertex.d.ts +9 -9
- package/grid/grid.vertex.js +12 -10
- package/grid/grid.vertex.js.map +1 -1
- package/grid/gridMaterial.d.ts +78 -77
- package/grid/gridMaterial.js +276 -261
- package/grid/gridMaterial.js.map +1 -1
- package/grid/index.d.ts +1 -1
- package/grid/index.js +1 -1
- package/grid/index.js.map +1 -1
- package/index.d.ts +15 -15
- package/index.js +16 -15
- package/index.js.map +1 -1
- package/lava/index.d.ts +1 -1
- package/lava/index.js +1 -1
- package/lava/index.js.map +1 -1
- package/lava/lava.fragment.d.ts +17 -17
- package/lava/lava.fragment.js +20 -18
- package/lava/lava.fragment.js.map +1 -1
- package/lava/lava.vertex.d.ts +18 -18
- package/lava/lava.vertex.js +21 -19
- package/lava/lava.vertex.js.map +1 -1
- package/lava/lavaMaterial.d.ts +45 -45
- package/lava/lavaMaterial.js +394 -378
- package/lava/lavaMaterial.js.map +1 -1
- package/legacy/legacy-cell.d.ts +1 -1
- package/legacy/legacy-cell.js +13 -12
- package/legacy/legacy-cell.js.map +1 -1
- package/legacy/legacy-custom.d.ts +1 -1
- package/legacy/legacy-custom.js +13 -12
- package/legacy/legacy-custom.js.map +1 -1
- package/legacy/legacy-fire.d.ts +1 -1
- package/legacy/legacy-fire.js +13 -12
- package/legacy/legacy-fire.js.map +1 -1
- package/legacy/legacy-fur.d.ts +1 -1
- package/legacy/legacy-fur.js +13 -12
- package/legacy/legacy-fur.js.map +1 -1
- package/legacy/legacy-gradient.d.ts +1 -1
- package/legacy/legacy-gradient.js +13 -12
- package/legacy/legacy-gradient.js.map +1 -1
- package/legacy/legacy-grid.d.ts +1 -1
- package/legacy/legacy-grid.js +13 -12
- package/legacy/legacy-grid.js.map +1 -1
- package/legacy/legacy-lava.d.ts +1 -1
- package/legacy/legacy-lava.js +13 -12
- package/legacy/legacy-lava.js.map +1 -1
- package/legacy/legacy-mix.d.ts +1 -1
- package/legacy/legacy-mix.js +13 -12
- package/legacy/legacy-mix.js.map +1 -1
- package/legacy/legacy-normal.d.ts +1 -1
- package/legacy/legacy-normal.js +13 -12
- package/legacy/legacy-normal.js.map +1 -1
- package/legacy/legacy-shadowOnly.d.ts +1 -1
- package/legacy/legacy-shadowOnly.js +13 -12
- package/legacy/legacy-shadowOnly.js.map +1 -1
- package/legacy/legacy-simple.d.ts +1 -1
- package/legacy/legacy-simple.js +13 -12
- package/legacy/legacy-simple.js.map +1 -1
- package/legacy/legacy-sky.d.ts +1 -1
- package/legacy/legacy-sky.js +13 -12
- package/legacy/legacy-sky.js.map +1 -1
- package/legacy/legacy-terrain.d.ts +1 -1
- package/legacy/legacy-terrain.js +13 -12
- package/legacy/legacy-terrain.js.map +1 -1
- package/legacy/legacy-triPlanar.d.ts +1 -1
- package/legacy/legacy-triPlanar.js +13 -12
- package/legacy/legacy-triPlanar.js.map +1 -1
- package/legacy/legacy-water.d.ts +1 -1
- package/legacy/legacy-water.js +13 -12
- package/legacy/legacy-water.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +16 -15
- package/legacy/legacy.js.map +1 -1
- package/mix/index.d.ts +1 -1
- package/mix/index.js +1 -1
- package/mix/index.js.map +1 -1
- package/mix/mix.fragment.d.ts +17 -17
- package/mix/mix.fragment.js +20 -18
- package/mix/mix.fragment.js.map +1 -1
- package/mix/mix.vertex.d.ts +18 -18
- package/mix/mix.vertex.js +21 -19
- package/mix/mix.vertex.js.map +1 -1
- package/mix/mixMaterial.d.ts +65 -65
- package/mix/mixMaterial.js +510 -483
- package/mix/mixMaterial.js.map +1 -1
- package/normal/index.d.ts +1 -1
- package/normal/index.js +1 -1
- package/normal/index.js.map +1 -1
- package/normal/normal.fragment.d.ts +17 -17
- package/normal/normal.fragment.js +20 -18
- package/normal/normal.fragment.js.map +1 -1
- package/normal/normal.vertex.d.ts +18 -18
- package/normal/normal.vertex.js +21 -19
- package/normal/normal.vertex.js.map +1 -1
- package/normal/normalMaterial.d.ts +36 -36
- package/normal/normalMaterial.js +336 -322
- package/normal/normalMaterial.js.map +1 -1
- package/package.json +22 -254
- package/readme.md +2 -2
- package/shadowOnly/index.d.ts +1 -1
- package/shadowOnly/index.js +1 -1
- package/shadowOnly/index.js.map +1 -1
- package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
- package/shadowOnly/shadowOnly.fragment.js +19 -17
- package/shadowOnly/shadowOnly.fragment.js.map +1 -1
- package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
- package/shadowOnly/shadowOnly.vertex.js +21 -19
- package/shadowOnly/shadowOnly.vertex.js.map +1 -1
- package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
- package/shadowOnly/shadowOnlyMaterial.js +254 -240
- package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
- package/simple/index.d.ts +1 -1
- package/simple/index.js +1 -1
- package/simple/index.js.map +1 -1
- package/simple/simple.fragment.d.ts +17 -17
- package/simple/simple.fragment.js +20 -18
- package/simple/simple.fragment.js.map +1 -1
- package/simple/simple.vertex.d.ts +18 -18
- package/simple/simple.vertex.js +21 -19
- package/simple/simple.vertex.js.map +1 -1
- package/simple/simpleMaterial.d.ts +35 -35
- package/simple/simpleMaterial.js +295 -281
- package/simple/simpleMaterial.js.map +1 -1
- package/sky/index.d.ts +1 -1
- package/sky/index.js +1 -1
- package/sky/index.js.map +1 -1
- package/sky/sky.fragment.d.ts +10 -10
- package/sky/sky.fragment.js +13 -11
- package/sky/sky.fragment.js.map +1 -1
- package/sky/sky.vertex.d.ts +9 -9
- package/sky/sky.vertex.js +12 -10
- package/sky/sky.vertex.js.map +1 -1
- package/sky/skyMaterial.d.ts +147 -147
- package/sky/skyMaterial.js +359 -340
- package/sky/skyMaterial.js.map +1 -1
- package/terrain/index.d.ts +1 -1
- package/terrain/index.js +1 -1
- package/terrain/index.js.map +1 -1
- package/terrain/terrain.fragment.d.ts +17 -17
- package/terrain/terrain.fragment.js +20 -18
- package/terrain/terrain.fragment.js.map +1 -1
- package/terrain/terrain.vertex.d.ts +18 -18
- package/terrain/terrain.vertex.js +21 -19
- package/terrain/terrain.vertex.js.map +1 -1
- package/terrain/terrainMaterial.d.ts +50 -50
- package/terrain/terrainMaterial.js +426 -411
- package/terrain/terrainMaterial.js.map +1 -1
- package/triPlanar/index.d.ts +1 -1
- package/triPlanar/index.js +1 -1
- package/triPlanar/index.js.map +1 -1
- package/triPlanar/triPlanarMaterial.d.ts +49 -49
- package/triPlanar/triPlanarMaterial.js +403 -391
- package/triPlanar/triPlanarMaterial.js.map +1 -1
- package/triPlanar/triplanar.fragment.d.ts +17 -17
- package/triPlanar/triplanar.fragment.js +20 -18
- package/triPlanar/triplanar.fragment.js.map +1 -1
- package/triPlanar/triplanar.vertex.d.ts +18 -18
- package/triPlanar/triplanar.vertex.js +21 -19
- package/triPlanar/triplanar.vertex.js.map +1 -1
- package/water/index.d.ts +1 -1
- package/water/index.js +1 -1
- package/water/index.js.map +1 -1
- package/water/water.fragment.d.ts +19 -19
- package/water/water.fragment.js +22 -20
- package/water/water.fragment.js.map +1 -1
- package/water/water.vertex.d.ts +20 -20
- package/water/water.vertex.js +23 -21
- package/water/water.vertex.js.map +1 -1
- package/water/waterMaterial.d.ts +135 -132
- package/water/waterMaterial.js +736 -705
- package/water/waterMaterial.js.map +1 -1
package/water/waterMaterial.js
CHANGED
@@ -1,706 +1,737 @@
|
|
1
|
-
import { __decorate, __extends } from "tslib";
|
2
|
-
import { serializeAsVector2, serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
-
import { Matrix, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
4
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
5
|
-
import { Plane } from
|
6
|
-
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
7
|
-
import { SmartArray } from "@babylonjs/core/Misc/smartArray.js";
|
8
|
-
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture.js";
|
9
|
-
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
10
|
-
import { ImageProcessingConfiguration } from "@babylonjs/core/Materials/imageProcessingConfiguration.js";
|
11
|
-
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
12
|
-
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
13
|
-
import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
|
14
|
-
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
15
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
16
|
-
import { RegisterClass } from
|
17
|
-
import "./water.fragment
|
18
|
-
import "./water.vertex
|
19
|
-
import { EffectFallbacks } from
|
20
|
-
import { CreateGround } from "@babylonjs/core/Meshes/Builders/groundBuilder.js";
|
21
|
-
var WaterMaterialDefines = /** @class */ (function (_super) {
|
22
|
-
__extends(WaterMaterialDefines, _super);
|
23
|
-
function WaterMaterialDefines() {
|
24
|
-
var _this = _super.call(this) || this;
|
25
|
-
_this.BUMP = false;
|
26
|
-
_this.REFLECTION = false;
|
27
|
-
_this.CLIPPLANE = false;
|
28
|
-
_this.CLIPPLANE2 = false;
|
29
|
-
_this.CLIPPLANE3 = false;
|
30
|
-
_this.CLIPPLANE4 = false;
|
31
|
-
_this.CLIPPLANE5 = false;
|
32
|
-
_this.CLIPPLANE6 = false;
|
33
|
-
_this.ALPHATEST = false;
|
34
|
-
_this.DEPTHPREPASS = false;
|
35
|
-
_this.POINTSIZE = false;
|
36
|
-
_this.FOG = false;
|
37
|
-
_this.NORMAL = false;
|
38
|
-
_this.UV1 = false;
|
39
|
-
_this.UV2 = false;
|
40
|
-
_this.VERTEXCOLOR = false;
|
41
|
-
_this.VERTEXALPHA = false;
|
42
|
-
_this.NUM_BONE_INFLUENCERS = 0;
|
43
|
-
_this.BonesPerMesh = 0;
|
44
|
-
_this.INSTANCES = false;
|
45
|
-
_this.INSTANCESCOLOR = false;
|
46
|
-
_this.SPECULARTERM = false;
|
47
|
-
_this.LOGARITHMICDEPTH = false;
|
48
|
-
_this.USE_REVERSE_DEPTHBUFFER = false;
|
49
|
-
_this.FRESNELSEPARATE = false;
|
50
|
-
_this.BUMPSUPERIMPOSE = false;
|
51
|
-
_this.BUMPAFFECTSREFLECTION = false;
|
52
|
-
_this.IMAGEPROCESSING = false;
|
53
|
-
_this.VIGNETTE = false;
|
54
|
-
_this.VIGNETTEBLENDMODEMULTIPLY = false;
|
55
|
-
_this.VIGNETTEBLENDMODEOPAQUE = false;
|
56
|
-
_this.TONEMAPPING = false;
|
57
|
-
_this.TONEMAPPING_ACES = false;
|
58
|
-
_this.CONTRAST = false;
|
59
|
-
_this.EXPOSURE = false;
|
60
|
-
_this.COLORCURVES = false;
|
61
|
-
_this.COLORGRADING = false;
|
62
|
-
_this.COLORGRADING3D = false;
|
63
|
-
_this.SAMPLER3DGREENDEPTH = false;
|
64
|
-
_this.SAMPLER3DBGRMAP = false;
|
65
|
-
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
66
|
-
_this.SKIPFINALCOLORCLAMP = false;
|
67
|
-
_this.rebuild();
|
68
|
-
return _this;
|
69
|
-
}
|
70
|
-
return WaterMaterialDefines;
|
71
|
-
}(MaterialDefines));
|
72
|
-
var WaterMaterial = /** @class */ (function (_super) {
|
73
|
-
__extends(WaterMaterial, _super);
|
74
|
-
/**
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
_this
|
83
|
-
_this.
|
84
|
-
_this.
|
85
|
-
_this.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
_this.
|
155
|
-
_this.
|
156
|
-
|
157
|
-
_this.
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
this._useLogarithmicDepth
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
if (this.
|
213
|
-
this.
|
214
|
-
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
if (this.
|
222
|
-
this.
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
};
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
};
|
238
|
-
WaterMaterial.prototype.
|
239
|
-
return
|
240
|
-
};
|
241
|
-
WaterMaterial.prototype.
|
242
|
-
return
|
243
|
-
};
|
244
|
-
WaterMaterial.prototype.
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
}
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
}
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
if (this.
|
284
|
-
defines.
|
285
|
-
}
|
286
|
-
if (this.
|
287
|
-
defines.
|
288
|
-
}
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
this._imageProcessingConfiguration.
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
this._waitingRenderList
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
if (defines.
|
321
|
-
fallbacks.addFallback(
|
322
|
-
}
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
if (defines.
|
333
|
-
attribs.push(VertexBuffer.
|
334
|
-
}
|
335
|
-
if (defines.
|
336
|
-
attribs.push(VertexBuffer.
|
337
|
-
}
|
338
|
-
if (defines.
|
339
|
-
attribs.push(VertexBuffer.
|
340
|
-
}
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
"
|
351
|
-
"
|
352
|
-
|
353
|
-
"
|
354
|
-
"
|
355
|
-
"
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
"
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
this.
|
412
|
-
|
413
|
-
this.
|
414
|
-
}
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
//
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
if (
|
440
|
-
|
441
|
-
this.
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
this.
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
this._activeEffect.
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
this.
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
this.
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
this.
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
if (
|
576
|
-
|
577
|
-
}
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
_super.prototype.
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
1
|
+
import { __decorate, __extends } from "tslib";
|
2
|
+
import { serializeAsVector2, serializeAsTexture, serialize, expandToProperty, serializeAsColor3, SerializationHelper } from "@babylonjs/core/Misc/decorators.js";
|
3
|
+
import { Matrix, Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
4
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
5
|
+
import { Plane } from "@babylonjs/core/Maths/math.plane.js";
|
6
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
7
|
+
import { SmartArray } from "@babylonjs/core/Misc/smartArray.js";
|
8
|
+
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture.js";
|
9
|
+
import { MaterialDefines } from "@babylonjs/core/Materials/materialDefines.js";
|
10
|
+
import { ImageProcessingConfiguration } from "@babylonjs/core/Materials/imageProcessingConfiguration.js";
|
11
|
+
import { MaterialHelper } from "@babylonjs/core/Materials/materialHelper.js";
|
12
|
+
import { PushMaterial } from "@babylonjs/core/Materials/pushMaterial.js";
|
13
|
+
import { MaterialFlags } from "@babylonjs/core/Materials/materialFlags.js";
|
14
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
15
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
16
|
+
import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
|
17
|
+
import "./water.fragment";
|
18
|
+
import "./water.vertex";
|
19
|
+
import { EffectFallbacks } from "@babylonjs/core/Materials/effectFallbacks.js";
|
20
|
+
import { CreateGround } from "@babylonjs/core/Meshes/Builders/groundBuilder.js";
|
21
|
+
var WaterMaterialDefines = /** @class */ (function (_super) {
|
22
|
+
__extends(WaterMaterialDefines, _super);
|
23
|
+
function WaterMaterialDefines() {
|
24
|
+
var _this = _super.call(this) || this;
|
25
|
+
_this.BUMP = false;
|
26
|
+
_this.REFLECTION = false;
|
27
|
+
_this.CLIPPLANE = false;
|
28
|
+
_this.CLIPPLANE2 = false;
|
29
|
+
_this.CLIPPLANE3 = false;
|
30
|
+
_this.CLIPPLANE4 = false;
|
31
|
+
_this.CLIPPLANE5 = false;
|
32
|
+
_this.CLIPPLANE6 = false;
|
33
|
+
_this.ALPHATEST = false;
|
34
|
+
_this.DEPTHPREPASS = false;
|
35
|
+
_this.POINTSIZE = false;
|
36
|
+
_this.FOG = false;
|
37
|
+
_this.NORMAL = false;
|
38
|
+
_this.UV1 = false;
|
39
|
+
_this.UV2 = false;
|
40
|
+
_this.VERTEXCOLOR = false;
|
41
|
+
_this.VERTEXALPHA = false;
|
42
|
+
_this.NUM_BONE_INFLUENCERS = 0;
|
43
|
+
_this.BonesPerMesh = 0;
|
44
|
+
_this.INSTANCES = false;
|
45
|
+
_this.INSTANCESCOLOR = false;
|
46
|
+
_this.SPECULARTERM = false;
|
47
|
+
_this.LOGARITHMICDEPTH = false;
|
48
|
+
_this.USE_REVERSE_DEPTHBUFFER = false;
|
49
|
+
_this.FRESNELSEPARATE = false;
|
50
|
+
_this.BUMPSUPERIMPOSE = false;
|
51
|
+
_this.BUMPAFFECTSREFLECTION = false;
|
52
|
+
_this.IMAGEPROCESSING = false;
|
53
|
+
_this.VIGNETTE = false;
|
54
|
+
_this.VIGNETTEBLENDMODEMULTIPLY = false;
|
55
|
+
_this.VIGNETTEBLENDMODEOPAQUE = false;
|
56
|
+
_this.TONEMAPPING = false;
|
57
|
+
_this.TONEMAPPING_ACES = false;
|
58
|
+
_this.CONTRAST = false;
|
59
|
+
_this.EXPOSURE = false;
|
60
|
+
_this.COLORCURVES = false;
|
61
|
+
_this.COLORGRADING = false;
|
62
|
+
_this.COLORGRADING3D = false;
|
63
|
+
_this.SAMPLER3DGREENDEPTH = false;
|
64
|
+
_this.SAMPLER3DBGRMAP = false;
|
65
|
+
_this.IMAGEPROCESSINGPOSTPROCESS = false;
|
66
|
+
_this.SKIPFINALCOLORCLAMP = false;
|
67
|
+
_this.rebuild();
|
68
|
+
return _this;
|
69
|
+
}
|
70
|
+
return WaterMaterialDefines;
|
71
|
+
}(MaterialDefines));
|
72
|
+
var WaterMaterial = /** @class */ (function (_super) {
|
73
|
+
__extends(WaterMaterial, _super);
|
74
|
+
/**
|
75
|
+
* Constructor
|
76
|
+
* @param name
|
77
|
+
* @param scene
|
78
|
+
* @param renderTargetSize
|
79
|
+
*/
|
80
|
+
function WaterMaterial(name, scene, renderTargetSize) {
|
81
|
+
if (renderTargetSize === void 0) { renderTargetSize = new Vector2(512, 512); }
|
82
|
+
var _this = _super.call(this, name, scene) || this;
|
83
|
+
_this.renderTargetSize = renderTargetSize;
|
84
|
+
_this.diffuseColor = new Color3(1, 1, 1);
|
85
|
+
_this.specularColor = new Color3(0, 0, 0);
|
86
|
+
_this.specularPower = 64;
|
87
|
+
_this._disableLighting = false;
|
88
|
+
_this._maxSimultaneousLights = 4;
|
89
|
+
/**
|
90
|
+
* Defines the wind force.
|
91
|
+
*/
|
92
|
+
_this.windForce = 6;
|
93
|
+
/**
|
94
|
+
* Defines the direction of the wind in the plane (X, Z).
|
95
|
+
*/
|
96
|
+
_this.windDirection = new Vector2(0, 1);
|
97
|
+
/**
|
98
|
+
* Defines the height of the waves.
|
99
|
+
*/
|
100
|
+
_this.waveHeight = 0.4;
|
101
|
+
/**
|
102
|
+
* Defines the bump height related to the bump map.
|
103
|
+
*/
|
104
|
+
_this.bumpHeight = 0.4;
|
105
|
+
/**
|
106
|
+
* Defines wether or not: to add a smaller moving bump to less steady waves.
|
107
|
+
*/
|
108
|
+
_this._bumpSuperimpose = false;
|
109
|
+
/**
|
110
|
+
* Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
|
111
|
+
*/
|
112
|
+
_this._fresnelSeparate = false;
|
113
|
+
/**
|
114
|
+
* Defines wether or not bump Wwves modify the reflection.
|
115
|
+
*/
|
116
|
+
_this._bumpAffectsReflection = false;
|
117
|
+
/**
|
118
|
+
* Defines the water color blended with the refraction (near).
|
119
|
+
*/
|
120
|
+
_this.waterColor = new Color3(0.1, 0.1, 0.6);
|
121
|
+
/**
|
122
|
+
* Defines the blend factor related to the water color.
|
123
|
+
*/
|
124
|
+
_this.colorBlendFactor = 0.2;
|
125
|
+
/**
|
126
|
+
* Defines the water color blended with the reflection (far).
|
127
|
+
*/
|
128
|
+
_this.waterColor2 = new Color3(0.1, 0.1, 0.6);
|
129
|
+
/**
|
130
|
+
* Defines the blend factor related to the water color (reflection, far).
|
131
|
+
*/
|
132
|
+
_this.colorBlendFactor2 = 0.2;
|
133
|
+
/**
|
134
|
+
* Defines the maximum length of a wave.
|
135
|
+
*/
|
136
|
+
_this.waveLength = 0.1;
|
137
|
+
/**
|
138
|
+
* Defines the waves speed.
|
139
|
+
*/
|
140
|
+
_this.waveSpeed = 1.0;
|
141
|
+
/**
|
142
|
+
* Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
|
143
|
+
*/
|
144
|
+
_this.waveCount = 20;
|
145
|
+
/**
|
146
|
+
* Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
|
147
|
+
* will avoid calculating useless pixels in the pixel shader of the water material.
|
148
|
+
*/
|
149
|
+
_this.disableClipPlane = false;
|
150
|
+
_this._renderTargets = new SmartArray(16);
|
151
|
+
/*
|
152
|
+
* Private members
|
153
|
+
*/
|
154
|
+
_this._mesh = null;
|
155
|
+
_this._reflectionTransform = Matrix.Zero();
|
156
|
+
_this._lastTime = 0;
|
157
|
+
_this._lastDeltaTime = 0;
|
158
|
+
_this._createRenderTargets(_this.getScene(), renderTargetSize);
|
159
|
+
// Create render targets
|
160
|
+
_this.getRenderTargetTextures = function () {
|
161
|
+
_this._renderTargets.reset();
|
162
|
+
_this._renderTargets.push(_this._reflectionRTT);
|
163
|
+
_this._renderTargets.push(_this._refractionRTT);
|
164
|
+
return _this._renderTargets;
|
165
|
+
};
|
166
|
+
_this._imageProcessingConfiguration = _this.getScene().imageProcessingConfiguration;
|
167
|
+
if (_this._imageProcessingConfiguration) {
|
168
|
+
_this._imageProcessingObserver = _this._imageProcessingConfiguration.onUpdateParameters.add(function () {
|
169
|
+
_this._markAllSubMeshesAsImageProcessingDirty();
|
170
|
+
});
|
171
|
+
}
|
172
|
+
return _this;
|
173
|
+
}
|
174
|
+
Object.defineProperty(WaterMaterial.prototype, "hasRenderTargetTextures", {
|
175
|
+
/**
|
176
|
+
* Gets a boolean indicating that current material needs to register RTT
|
177
|
+
*/
|
178
|
+
get: function () {
|
179
|
+
return true;
|
180
|
+
},
|
181
|
+
enumerable: false,
|
182
|
+
configurable: true
|
183
|
+
});
|
184
|
+
Object.defineProperty(WaterMaterial.prototype, "useLogarithmicDepth", {
|
185
|
+
get: function () {
|
186
|
+
return this._useLogarithmicDepth;
|
187
|
+
},
|
188
|
+
set: function (value) {
|
189
|
+
this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
|
190
|
+
this._markAllSubMeshesAsMiscDirty();
|
191
|
+
},
|
192
|
+
enumerable: false,
|
193
|
+
configurable: true
|
194
|
+
});
|
195
|
+
Object.defineProperty(WaterMaterial.prototype, "refractionTexture", {
|
196
|
+
// Get / Set
|
197
|
+
get: function () {
|
198
|
+
return this._refractionRTT;
|
199
|
+
},
|
200
|
+
enumerable: false,
|
201
|
+
configurable: true
|
202
|
+
});
|
203
|
+
Object.defineProperty(WaterMaterial.prototype, "reflectionTexture", {
|
204
|
+
get: function () {
|
205
|
+
return this._reflectionRTT;
|
206
|
+
},
|
207
|
+
enumerable: false,
|
208
|
+
configurable: true
|
209
|
+
});
|
210
|
+
// Methods
|
211
|
+
WaterMaterial.prototype.addToRenderList = function (node) {
|
212
|
+
if (this._refractionRTT && this._refractionRTT.renderList) {
|
213
|
+
this._refractionRTT.renderList.push(node);
|
214
|
+
}
|
215
|
+
if (this._reflectionRTT && this._reflectionRTT.renderList) {
|
216
|
+
this._reflectionRTT.renderList.push(node);
|
217
|
+
}
|
218
|
+
};
|
219
|
+
WaterMaterial.prototype.enableRenderTargets = function (enable) {
|
220
|
+
var refreshRate = enable ? 1 : 0;
|
221
|
+
if (this._refractionRTT) {
|
222
|
+
this._refractionRTT.refreshRate = refreshRate;
|
223
|
+
}
|
224
|
+
if (this._reflectionRTT) {
|
225
|
+
this._reflectionRTT.refreshRate = refreshRate;
|
226
|
+
}
|
227
|
+
};
|
228
|
+
WaterMaterial.prototype.getRenderList = function () {
|
229
|
+
return this._refractionRTT ? this._refractionRTT.renderList : [];
|
230
|
+
};
|
231
|
+
Object.defineProperty(WaterMaterial.prototype, "renderTargetsEnabled", {
|
232
|
+
get: function () {
|
233
|
+
return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
|
234
|
+
},
|
235
|
+
enumerable: false,
|
236
|
+
configurable: true
|
237
|
+
});
|
238
|
+
WaterMaterial.prototype.needAlphaBlending = function () {
|
239
|
+
return this.alpha < 1.0;
|
240
|
+
};
|
241
|
+
WaterMaterial.prototype.needAlphaTesting = function () {
|
242
|
+
return false;
|
243
|
+
};
|
244
|
+
WaterMaterial.prototype.getAlphaTestTexture = function () {
|
245
|
+
return null;
|
246
|
+
};
|
247
|
+
WaterMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
|
248
|
+
if (this.isFrozen) {
|
249
|
+
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
|
250
|
+
return true;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
if (!subMesh.materialDefines) {
|
254
|
+
subMesh.materialDefines = new WaterMaterialDefines();
|
255
|
+
}
|
256
|
+
var defines = subMesh.materialDefines;
|
257
|
+
var scene = this.getScene();
|
258
|
+
if (this._isReadyForSubMesh(subMesh)) {
|
259
|
+
return true;
|
260
|
+
}
|
261
|
+
var engine = scene.getEngine();
|
262
|
+
// Textures
|
263
|
+
if (defines._areTexturesDirty) {
|
264
|
+
defines._needUVs = false;
|
265
|
+
if (scene.texturesEnabled) {
|
266
|
+
if (this.bumpTexture && MaterialFlags.BumpTextureEnabled) {
|
267
|
+
if (!this.bumpTexture.isReady()) {
|
268
|
+
return false;
|
269
|
+
}
|
270
|
+
else {
|
271
|
+
defines._needUVs = true;
|
272
|
+
defines.BUMP = true;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
if (MaterialFlags.ReflectionTextureEnabled) {
|
276
|
+
defines.REFLECTION = true;
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
|
281
|
+
MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
|
282
|
+
if (defines._areMiscDirty) {
|
283
|
+
if (this._fresnelSeparate) {
|
284
|
+
defines.FRESNELSEPARATE = true;
|
285
|
+
}
|
286
|
+
if (this._bumpSuperimpose) {
|
287
|
+
defines.BUMPSUPERIMPOSE = true;
|
288
|
+
}
|
289
|
+
if (this._bumpAffectsReflection) {
|
290
|
+
defines.BUMPAFFECTSREFLECTION = true;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
// Lights
|
294
|
+
defines._needNormals = MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
|
295
|
+
// Image processing
|
296
|
+
if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
|
297
|
+
if (!this._imageProcessingConfiguration.isReady()) {
|
298
|
+
return false;
|
299
|
+
}
|
300
|
+
this._imageProcessingConfiguration.prepareDefines(defines);
|
301
|
+
defines.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace;
|
302
|
+
defines.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace;
|
303
|
+
}
|
304
|
+
// Attribs
|
305
|
+
MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
|
306
|
+
// Configure this
|
307
|
+
this._mesh = mesh;
|
308
|
+
if (this._waitingRenderList) {
|
309
|
+
for (var i = 0; i < this._waitingRenderList.length; i++) {
|
310
|
+
this.addToRenderList(scene.getNodeById(this._waitingRenderList[i]));
|
311
|
+
}
|
312
|
+
this._waitingRenderList = null;
|
313
|
+
}
|
314
|
+
// Get correct effect
|
315
|
+
if (defines.isDirty) {
|
316
|
+
defines.markAsProcessed();
|
317
|
+
scene.resetCachedMaterial();
|
318
|
+
// Fallbacks
|
319
|
+
var fallbacks = new EffectFallbacks();
|
320
|
+
if (defines.FOG) {
|
321
|
+
fallbacks.addFallback(1, "FOG");
|
322
|
+
}
|
323
|
+
if (defines.LOGARITHMICDEPTH) {
|
324
|
+
fallbacks.addFallback(0, "LOGARITHMICDEPTH");
|
325
|
+
}
|
326
|
+
MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
|
327
|
+
if (defines.NUM_BONE_INFLUENCERS > 0) {
|
328
|
+
fallbacks.addCPUSkinningFallback(0, mesh);
|
329
|
+
}
|
330
|
+
//Attributes
|
331
|
+
var attribs = [VertexBuffer.PositionKind];
|
332
|
+
if (defines.NORMAL) {
|
333
|
+
attribs.push(VertexBuffer.NormalKind);
|
334
|
+
}
|
335
|
+
if (defines.UV1) {
|
336
|
+
attribs.push(VertexBuffer.UVKind);
|
337
|
+
}
|
338
|
+
if (defines.UV2) {
|
339
|
+
attribs.push(VertexBuffer.UV2Kind);
|
340
|
+
}
|
341
|
+
if (defines.VERTEXCOLOR) {
|
342
|
+
attribs.push(VertexBuffer.ColorKind);
|
343
|
+
}
|
344
|
+
MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
|
345
|
+
MaterialHelper.PrepareAttributesForInstances(attribs, defines);
|
346
|
+
// Legacy browser patch
|
347
|
+
var shaderName = "water";
|
348
|
+
var join = defines.toString();
|
349
|
+
var uniforms = [
|
350
|
+
"world",
|
351
|
+
"view",
|
352
|
+
"viewProjection",
|
353
|
+
"vEyePosition",
|
354
|
+
"vLightsType",
|
355
|
+
"vDiffuseColor",
|
356
|
+
"vSpecularColor",
|
357
|
+
"vFogInfos",
|
358
|
+
"vFogColor",
|
359
|
+
"pointSize",
|
360
|
+
"vNormalInfos",
|
361
|
+
"mBones",
|
362
|
+
"vClipPlane",
|
363
|
+
"vClipPlane2",
|
364
|
+
"vClipPlane3",
|
365
|
+
"vClipPlane4",
|
366
|
+
"vClipPlane5",
|
367
|
+
"vClipPlane6",
|
368
|
+
"normalMatrix",
|
369
|
+
"logarithmicDepthConstant",
|
370
|
+
// Water
|
371
|
+
"worldReflectionViewProjection",
|
372
|
+
"windDirection",
|
373
|
+
"waveLength",
|
374
|
+
"time",
|
375
|
+
"windForce",
|
376
|
+
"cameraPosition",
|
377
|
+
"bumpHeight",
|
378
|
+
"waveHeight",
|
379
|
+
"waterColor",
|
380
|
+
"waterColor2",
|
381
|
+
"colorBlendFactor",
|
382
|
+
"colorBlendFactor2",
|
383
|
+
"waveSpeed",
|
384
|
+
"waveCount",
|
385
|
+
];
|
386
|
+
var samplers = [
|
387
|
+
"normalSampler",
|
388
|
+
// Water
|
389
|
+
"refractionSampler",
|
390
|
+
"reflectionSampler",
|
391
|
+
];
|
392
|
+
var uniformBuffers = new Array();
|
393
|
+
if (ImageProcessingConfiguration) {
|
394
|
+
ImageProcessingConfiguration.PrepareUniforms(uniforms, defines);
|
395
|
+
ImageProcessingConfiguration.PrepareSamplers(samplers, defines);
|
396
|
+
}
|
397
|
+
MaterialHelper.PrepareUniformsAndSamplersList({
|
398
|
+
uniformsNames: uniforms,
|
399
|
+
uniformBuffersNames: uniformBuffers,
|
400
|
+
samplers: samplers,
|
401
|
+
defines: defines,
|
402
|
+
maxSimultaneousLights: this.maxSimultaneousLights,
|
403
|
+
});
|
404
|
+
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
|
405
|
+
attributes: attribs,
|
406
|
+
uniformsNames: uniforms,
|
407
|
+
uniformBuffersNames: uniformBuffers,
|
408
|
+
samplers: samplers,
|
409
|
+
defines: join,
|
410
|
+
fallbacks: fallbacks,
|
411
|
+
onCompiled: this.onCompiled,
|
412
|
+
onError: this.onError,
|
413
|
+
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights },
|
414
|
+
}, engine), defines, this._materialContext);
|
415
|
+
}
|
416
|
+
if (!subMesh.effect || !subMesh.effect.isReady()) {
|
417
|
+
return false;
|
418
|
+
}
|
419
|
+
defines._renderId = scene.getRenderId();
|
420
|
+
subMesh.effect._wasPreviouslyReady = true;
|
421
|
+
return true;
|
422
|
+
};
|
423
|
+
WaterMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
|
424
|
+
var scene = this.getScene();
|
425
|
+
var defines = subMesh.materialDefines;
|
426
|
+
if (!defines) {
|
427
|
+
return;
|
428
|
+
}
|
429
|
+
var effect = subMesh.effect;
|
430
|
+
if (!effect || !this._mesh) {
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
this._activeEffect = effect;
|
434
|
+
// Matrices
|
435
|
+
this.bindOnlyWorldMatrix(world);
|
436
|
+
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
|
437
|
+
// Bones
|
438
|
+
MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
|
439
|
+
if (this._mustRebind(scene, effect)) {
|
440
|
+
// Textures
|
441
|
+
if (this.bumpTexture && MaterialFlags.BumpTextureEnabled) {
|
442
|
+
this._activeEffect.setTexture("normalSampler", this.bumpTexture);
|
443
|
+
this._activeEffect.setFloat2("vNormalInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
|
444
|
+
this._activeEffect.setMatrix("normalMatrix", this.bumpTexture.getTextureMatrix());
|
445
|
+
}
|
446
|
+
// Clip plane
|
447
|
+
MaterialHelper.BindClipPlane(this._activeEffect, scene);
|
448
|
+
// Point size
|
449
|
+
if (this.pointsCloud) {
|
450
|
+
this._activeEffect.setFloat("pointSize", this.pointSize);
|
451
|
+
}
|
452
|
+
scene.bindEyePosition(effect);
|
453
|
+
}
|
454
|
+
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
|
455
|
+
if (defines.SPECULARTERM) {
|
456
|
+
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
|
457
|
+
}
|
458
|
+
if (scene.lightsEnabled && !this.disableLighting) {
|
459
|
+
MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
|
460
|
+
}
|
461
|
+
// View
|
462
|
+
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== Scene.FOGMODE_NONE) {
|
463
|
+
this._activeEffect.setMatrix("view", scene.getViewMatrix());
|
464
|
+
}
|
465
|
+
// Fog
|
466
|
+
MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
|
467
|
+
// Log. depth
|
468
|
+
MaterialHelper.BindLogDepth(defines, this._activeEffect, scene);
|
469
|
+
// Water
|
470
|
+
if (MaterialFlags.ReflectionTextureEnabled) {
|
471
|
+
this._activeEffect.setTexture("refractionSampler", this._refractionRTT);
|
472
|
+
this._activeEffect.setTexture("reflectionSampler", this._reflectionRTT);
|
473
|
+
}
|
474
|
+
var wrvp = this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(scene.getProjectionMatrix());
|
475
|
+
// Add delta time. Prevent adding delta time if it hasn't changed.
|
476
|
+
var deltaTime = scene.getEngine().getDeltaTime();
|
477
|
+
if (deltaTime !== this._lastDeltaTime) {
|
478
|
+
this._lastDeltaTime = deltaTime;
|
479
|
+
this._lastTime += this._lastDeltaTime;
|
480
|
+
}
|
481
|
+
this._activeEffect.setMatrix("worldReflectionViewProjection", wrvp);
|
482
|
+
this._activeEffect.setVector2("windDirection", this.windDirection);
|
483
|
+
this._activeEffect.setFloat("waveLength", this.waveLength);
|
484
|
+
this._activeEffect.setFloat("time", this._lastTime / 100000);
|
485
|
+
this._activeEffect.setFloat("windForce", this.windForce);
|
486
|
+
this._activeEffect.setFloat("waveHeight", this.waveHeight);
|
487
|
+
this._activeEffect.setFloat("bumpHeight", this.bumpHeight);
|
488
|
+
this._activeEffect.setColor4("waterColor", this.waterColor, 1.0);
|
489
|
+
this._activeEffect.setFloat("colorBlendFactor", this.colorBlendFactor);
|
490
|
+
this._activeEffect.setColor4("waterColor2", this.waterColor2, 1.0);
|
491
|
+
this._activeEffect.setFloat("colorBlendFactor2", this.colorBlendFactor2);
|
492
|
+
this._activeEffect.setFloat("waveSpeed", this.waveSpeed);
|
493
|
+
this._activeEffect.setFloat("waveCount", this.waveCount);
|
494
|
+
// image processing
|
495
|
+
if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
|
496
|
+
this._imageProcessingConfiguration.bind(this._activeEffect);
|
497
|
+
}
|
498
|
+
this._afterBind(mesh, this._activeEffect);
|
499
|
+
};
|
500
|
+
WaterMaterial.prototype._createRenderTargets = function (scene, renderTargetSize) {
|
501
|
+
var _this = this;
|
502
|
+
// Render targets
|
503
|
+
this._refractionRTT = new RenderTargetTexture(name + "_refraction", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
|
504
|
+
this._refractionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
505
|
+
this._refractionRTT.wrapV = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
506
|
+
this._refractionRTT.ignoreCameraViewport = true;
|
507
|
+
this._reflectionRTT = new RenderTargetTexture(name + "_reflection", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
|
508
|
+
this._reflectionRTT.wrapU = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
509
|
+
this._reflectionRTT.wrapV = Constants.TEXTURE_MIRROR_ADDRESSMODE;
|
510
|
+
this._reflectionRTT.ignoreCameraViewport = true;
|
511
|
+
var isVisible;
|
512
|
+
var clipPlane = null;
|
513
|
+
var savedViewMatrix;
|
514
|
+
var mirrorMatrix = Matrix.Zero();
|
515
|
+
this._refractionRTT.onBeforeRender = function () {
|
516
|
+
if (_this._mesh) {
|
517
|
+
isVisible = _this._mesh.isVisible;
|
518
|
+
_this._mesh.isVisible = false;
|
519
|
+
}
|
520
|
+
// Clip plane
|
521
|
+
if (!_this.disableClipPlane) {
|
522
|
+
clipPlane = scene.clipPlane;
|
523
|
+
var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
|
524
|
+
scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony + 0.05, 0), new Vector3(0, 1, 0));
|
525
|
+
}
|
526
|
+
};
|
527
|
+
this._refractionRTT.onAfterRender = function () {
|
528
|
+
if (_this._mesh) {
|
529
|
+
_this._mesh.isVisible = isVisible;
|
530
|
+
}
|
531
|
+
// Clip plane
|
532
|
+
if (!_this.disableClipPlane) {
|
533
|
+
scene.clipPlane = clipPlane;
|
534
|
+
}
|
535
|
+
};
|
536
|
+
this._reflectionRTT.onBeforeRender = function () {
|
537
|
+
if (_this._mesh) {
|
538
|
+
isVisible = _this._mesh.isVisible;
|
539
|
+
_this._mesh.isVisible = false;
|
540
|
+
}
|
541
|
+
// Clip plane
|
542
|
+
if (!_this.disableClipPlane) {
|
543
|
+
clipPlane = scene.clipPlane;
|
544
|
+
var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
|
545
|
+
scene.clipPlane = Plane.FromPositionAndNormal(new Vector3(0, positiony - 0.05, 0), new Vector3(0, -1, 0));
|
546
|
+
Matrix.ReflectionToRef(scene.clipPlane, mirrorMatrix);
|
547
|
+
}
|
548
|
+
// Transform
|
549
|
+
savedViewMatrix = scene.getViewMatrix();
|
550
|
+
mirrorMatrix.multiplyToRef(savedViewMatrix, _this._reflectionTransform);
|
551
|
+
scene.setTransformMatrix(_this._reflectionTransform, scene.getProjectionMatrix());
|
552
|
+
scene.getEngine().cullBackFaces = false;
|
553
|
+
scene._mirroredCameraPosition = Vector3.TransformCoordinates(scene.activeCamera.position, mirrorMatrix);
|
554
|
+
};
|
555
|
+
this._reflectionRTT.onAfterRender = function () {
|
556
|
+
if (_this._mesh) {
|
557
|
+
_this._mesh.isVisible = isVisible;
|
558
|
+
}
|
559
|
+
// Clip plane
|
560
|
+
scene.clipPlane = clipPlane;
|
561
|
+
// Transform
|
562
|
+
scene.setTransformMatrix(savedViewMatrix, scene.getProjectionMatrix());
|
563
|
+
scene.getEngine().cullBackFaces = null;
|
564
|
+
scene._mirroredCameraPosition = null;
|
565
|
+
};
|
566
|
+
};
|
567
|
+
WaterMaterial.prototype.getAnimatables = function () {
|
568
|
+
var results = [];
|
569
|
+
if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
|
570
|
+
results.push(this.bumpTexture);
|
571
|
+
}
|
572
|
+
if (this._reflectionRTT && this._reflectionRTT.animations && this._reflectionRTT.animations.length > 0) {
|
573
|
+
results.push(this._reflectionRTT);
|
574
|
+
}
|
575
|
+
if (this._refractionRTT && this._refractionRTT.animations && this._refractionRTT.animations.length > 0) {
|
576
|
+
results.push(this._refractionRTT);
|
577
|
+
}
|
578
|
+
return results;
|
579
|
+
};
|
580
|
+
WaterMaterial.prototype.getActiveTextures = function () {
|
581
|
+
var activeTextures = _super.prototype.getActiveTextures.call(this);
|
582
|
+
if (this._bumpTexture) {
|
583
|
+
activeTextures.push(this._bumpTexture);
|
584
|
+
}
|
585
|
+
return activeTextures;
|
586
|
+
};
|
587
|
+
WaterMaterial.prototype.hasTexture = function (texture) {
|
588
|
+
if (_super.prototype.hasTexture.call(this, texture)) {
|
589
|
+
return true;
|
590
|
+
}
|
591
|
+
if (this._bumpTexture === texture) {
|
592
|
+
return true;
|
593
|
+
}
|
594
|
+
return false;
|
595
|
+
};
|
596
|
+
WaterMaterial.prototype.dispose = function (forceDisposeEffect) {
|
597
|
+
if (this.bumpTexture) {
|
598
|
+
this.bumpTexture.dispose();
|
599
|
+
}
|
600
|
+
var index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
|
601
|
+
if (index != -1) {
|
602
|
+
this.getScene().customRenderTargets.splice(index, 1);
|
603
|
+
}
|
604
|
+
index = -1;
|
605
|
+
index = this.getScene().customRenderTargets.indexOf(this._reflectionRTT);
|
606
|
+
if (index != -1) {
|
607
|
+
this.getScene().customRenderTargets.splice(index, 1);
|
608
|
+
}
|
609
|
+
if (this._reflectionRTT) {
|
610
|
+
this._reflectionRTT.dispose();
|
611
|
+
}
|
612
|
+
if (this._refractionRTT) {
|
613
|
+
this._refractionRTT.dispose();
|
614
|
+
}
|
615
|
+
// Remove image-processing observer
|
616
|
+
if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
|
617
|
+
this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
|
618
|
+
}
|
619
|
+
_super.prototype.dispose.call(this, forceDisposeEffect);
|
620
|
+
};
|
621
|
+
WaterMaterial.prototype.clone = function (name) {
|
622
|
+
var _this = this;
|
623
|
+
return SerializationHelper.Clone(function () { return new WaterMaterial(name, _this.getScene()); }, this);
|
624
|
+
};
|
625
|
+
WaterMaterial.prototype.serialize = function () {
|
626
|
+
var serializationObject = _super.prototype.serialize.call(this);
|
627
|
+
serializationObject.customType = "BABYLON.WaterMaterial";
|
628
|
+
serializationObject.renderList = [];
|
629
|
+
if (this._refractionRTT && this._refractionRTT.renderList) {
|
630
|
+
for (var i = 0; i < this._refractionRTT.renderList.length; i++) {
|
631
|
+
serializationObject.renderList.push(this._refractionRTT.renderList[i].id);
|
632
|
+
}
|
633
|
+
}
|
634
|
+
return serializationObject;
|
635
|
+
};
|
636
|
+
WaterMaterial.prototype.getClassName = function () {
|
637
|
+
return "WaterMaterial";
|
638
|
+
};
|
639
|
+
// Statics
|
640
|
+
WaterMaterial.Parse = function (source, scene, rootUrl) {
|
641
|
+
var mat = SerializationHelper.Parse(function () { return new WaterMaterial(source.name, scene); }, source, scene, rootUrl);
|
642
|
+
mat._waitingRenderList = source.renderList;
|
643
|
+
return mat;
|
644
|
+
};
|
645
|
+
WaterMaterial.CreateDefaultMesh = function (name, scene) {
|
646
|
+
var mesh = CreateGround(name, { width: 512, height: 512, subdivisions: 32, updatable: false }, scene);
|
647
|
+
return mesh;
|
648
|
+
};
|
649
|
+
__decorate([
|
650
|
+
serializeAsTexture("bumpTexture")
|
651
|
+
], WaterMaterial.prototype, "_bumpTexture", void 0);
|
652
|
+
__decorate([
|
653
|
+
expandToProperty("_markAllSubMeshesAsTexturesDirty")
|
654
|
+
], WaterMaterial.prototype, "bumpTexture", void 0);
|
655
|
+
__decorate([
|
656
|
+
serializeAsColor3()
|
657
|
+
], WaterMaterial.prototype, "diffuseColor", void 0);
|
658
|
+
__decorate([
|
659
|
+
serializeAsColor3()
|
660
|
+
], WaterMaterial.prototype, "specularColor", void 0);
|
661
|
+
__decorate([
|
662
|
+
serialize()
|
663
|
+
], WaterMaterial.prototype, "specularPower", void 0);
|
664
|
+
__decorate([
|
665
|
+
serialize("disableLighting")
|
666
|
+
], WaterMaterial.prototype, "_disableLighting", void 0);
|
667
|
+
__decorate([
|
668
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
669
|
+
], WaterMaterial.prototype, "disableLighting", void 0);
|
670
|
+
__decorate([
|
671
|
+
serialize("maxSimultaneousLights")
|
672
|
+
], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
|
673
|
+
__decorate([
|
674
|
+
expandToProperty("_markAllSubMeshesAsLightsDirty")
|
675
|
+
], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
|
676
|
+
__decorate([
|
677
|
+
serialize()
|
678
|
+
], WaterMaterial.prototype, "windForce", void 0);
|
679
|
+
__decorate([
|
680
|
+
serializeAsVector2()
|
681
|
+
], WaterMaterial.prototype, "windDirection", void 0);
|
682
|
+
__decorate([
|
683
|
+
serialize()
|
684
|
+
], WaterMaterial.prototype, "waveHeight", void 0);
|
685
|
+
__decorate([
|
686
|
+
serialize()
|
687
|
+
], WaterMaterial.prototype, "bumpHeight", void 0);
|
688
|
+
__decorate([
|
689
|
+
serialize("bumpSuperimpose")
|
690
|
+
], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
|
691
|
+
__decorate([
|
692
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
693
|
+
], WaterMaterial.prototype, "bumpSuperimpose", void 0);
|
694
|
+
__decorate([
|
695
|
+
serialize("fresnelSeparate")
|
696
|
+
], WaterMaterial.prototype, "_fresnelSeparate", void 0);
|
697
|
+
__decorate([
|
698
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
699
|
+
], WaterMaterial.prototype, "fresnelSeparate", void 0);
|
700
|
+
__decorate([
|
701
|
+
serialize("bumpAffectsReflection")
|
702
|
+
], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
|
703
|
+
__decorate([
|
704
|
+
expandToProperty("_markAllSubMeshesAsMiscDirty")
|
705
|
+
], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
|
706
|
+
__decorate([
|
707
|
+
serializeAsColor3()
|
708
|
+
], WaterMaterial.prototype, "waterColor", void 0);
|
709
|
+
__decorate([
|
710
|
+
serialize()
|
711
|
+
], WaterMaterial.prototype, "colorBlendFactor", void 0);
|
712
|
+
__decorate([
|
713
|
+
serializeAsColor3()
|
714
|
+
], WaterMaterial.prototype, "waterColor2", void 0);
|
715
|
+
__decorate([
|
716
|
+
serialize()
|
717
|
+
], WaterMaterial.prototype, "colorBlendFactor2", void 0);
|
718
|
+
__decorate([
|
719
|
+
serialize()
|
720
|
+
], WaterMaterial.prototype, "waveLength", void 0);
|
721
|
+
__decorate([
|
722
|
+
serialize()
|
723
|
+
], WaterMaterial.prototype, "waveSpeed", void 0);
|
724
|
+
__decorate([
|
725
|
+
serialize()
|
726
|
+
], WaterMaterial.prototype, "waveCount", void 0);
|
727
|
+
__decorate([
|
728
|
+
serialize()
|
729
|
+
], WaterMaterial.prototype, "disableClipPlane", void 0);
|
730
|
+
__decorate([
|
731
|
+
serialize()
|
732
|
+
], WaterMaterial.prototype, "useLogarithmicDepth", null);
|
733
|
+
return WaterMaterial;
|
734
|
+
}(PushMaterial));
|
735
|
+
export { WaterMaterial };
|
736
|
+
RegisterClass("BABYLON.WaterMaterial", WaterMaterial);
|
706
737
|
//# sourceMappingURL=waterMaterial.js.map
|