@babylonjs/materials 5.0.0-rc.6 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) 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/cellMaterial.js.map +1 -1
  8. package/cell/index.d.ts +1 -1
  9. package/cell/index.js +1 -1
  10. package/custom/customMaterial.d.ts +69 -69
  11. package/custom/customMaterial.js +216 -216
  12. package/custom/customMaterial.js.map +1 -1
  13. package/custom/index.d.ts +2 -2
  14. package/custom/index.js +2 -2
  15. package/custom/pbrCustomMaterial.d.ts +71 -71
  16. package/custom/pbrCustomMaterial.js +241 -241
  17. package/custom/pbrCustomMaterial.js.map +1 -1
  18. package/fire/fire.fragment.d.ts +11 -11
  19. package/fire/fire.fragment.js +14 -14
  20. package/fire/fire.vertex.d.ts +15 -15
  21. package/fire/fire.vertex.js +18 -18
  22. package/fire/fireMaterial.d.ts +38 -38
  23. package/fire/fireMaterial.js +342 -342
  24. package/fire/fireMaterial.js.map +1 -1
  25. package/fire/index.d.ts +1 -1
  26. package/fire/index.js +1 -1
  27. package/fur/fur.fragment.d.ts +17 -17
  28. package/fur/fur.fragment.js +20 -20
  29. package/fur/fur.vertex.d.ts +18 -18
  30. package/fur/fur.vertex.js +21 -21
  31. package/fur/furMaterial.d.ts +57 -56
  32. package/fur/furMaterial.js +500 -500
  33. package/fur/furMaterial.js.map +1 -1
  34. package/fur/index.d.ts +1 -1
  35. package/fur/index.js +1 -1
  36. package/gradient/gradient.fragment.d.ts +17 -17
  37. package/gradient/gradient.fragment.js +20 -20
  38. package/gradient/gradient.vertex.d.ts +18 -18
  39. package/gradient/gradient.vertex.js +21 -21
  40. package/gradient/gradientMaterial.d.ts +37 -37
  41. package/gradient/gradientMaterial.js +275 -275
  42. package/gradient/gradientMaterial.js.map +1 -1
  43. package/gradient/index.d.ts +1 -1
  44. package/gradient/index.js +1 -1
  45. package/grid/grid.fragment.d.ts +8 -8
  46. package/grid/grid.fragment.js +11 -11
  47. package/grid/grid.vertex.d.ts +9 -9
  48. package/grid/grid.vertex.js +12 -12
  49. package/grid/gridMaterial.d.ts +78 -77
  50. package/grid/gridMaterial.js +276 -276
  51. package/grid/gridMaterial.js.map +1 -1
  52. package/grid/index.d.ts +1 -1
  53. package/grid/index.js +1 -1
  54. package/index.d.ts +15 -15
  55. package/index.js +16 -15
  56. package/index.js.map +1 -1
  57. package/lava/index.d.ts +1 -1
  58. package/lava/index.js +1 -1
  59. package/lava/lava.fragment.d.ts +17 -17
  60. package/lava/lava.fragment.js +20 -20
  61. package/lava/lava.vertex.d.ts +18 -18
  62. package/lava/lava.vertex.js +21 -21
  63. package/lava/lavaMaterial.d.ts +45 -45
  64. package/lava/lavaMaterial.js +394 -394
  65. package/lava/lavaMaterial.js.map +1 -1
  66. package/legacy/legacy-cell.d.ts +1 -1
  67. package/legacy/legacy-cell.js +13 -12
  68. package/legacy/legacy-cell.js.map +1 -1
  69. package/legacy/legacy-custom.d.ts +1 -1
  70. package/legacy/legacy-custom.js +13 -12
  71. package/legacy/legacy-custom.js.map +1 -1
  72. package/legacy/legacy-fire.d.ts +1 -1
  73. package/legacy/legacy-fire.js +13 -12
  74. package/legacy/legacy-fire.js.map +1 -1
  75. package/legacy/legacy-fur.d.ts +1 -1
  76. package/legacy/legacy-fur.js +13 -12
  77. package/legacy/legacy-fur.js.map +1 -1
  78. package/legacy/legacy-gradient.d.ts +1 -1
  79. package/legacy/legacy-gradient.js +13 -12
  80. package/legacy/legacy-gradient.js.map +1 -1
  81. package/legacy/legacy-grid.d.ts +1 -1
  82. package/legacy/legacy-grid.js +13 -12
  83. package/legacy/legacy-grid.js.map +1 -1
  84. package/legacy/legacy-lava.d.ts +1 -1
  85. package/legacy/legacy-lava.js +13 -12
  86. package/legacy/legacy-lava.js.map +1 -1
  87. package/legacy/legacy-mix.d.ts +1 -1
  88. package/legacy/legacy-mix.js +13 -12
  89. package/legacy/legacy-mix.js.map +1 -1
  90. package/legacy/legacy-normal.d.ts +1 -1
  91. package/legacy/legacy-normal.js +13 -12
  92. package/legacy/legacy-normal.js.map +1 -1
  93. package/legacy/legacy-shadowOnly.d.ts +1 -1
  94. package/legacy/legacy-shadowOnly.js +13 -12
  95. package/legacy/legacy-shadowOnly.js.map +1 -1
  96. package/legacy/legacy-simple.d.ts +1 -1
  97. package/legacy/legacy-simple.js +13 -12
  98. package/legacy/legacy-simple.js.map +1 -1
  99. package/legacy/legacy-sky.d.ts +1 -1
  100. package/legacy/legacy-sky.js +13 -12
  101. package/legacy/legacy-sky.js.map +1 -1
  102. package/legacy/legacy-terrain.d.ts +1 -1
  103. package/legacy/legacy-terrain.js +13 -12
  104. package/legacy/legacy-terrain.js.map +1 -1
  105. package/legacy/legacy-triPlanar.d.ts +1 -1
  106. package/legacy/legacy-triPlanar.js +13 -12
  107. package/legacy/legacy-triPlanar.js.map +1 -1
  108. package/legacy/legacy-water.d.ts +1 -1
  109. package/legacy/legacy-water.js +13 -12
  110. package/legacy/legacy-water.js.map +1 -1
  111. package/legacy/legacy.d.ts +1 -1
  112. package/legacy/legacy.js +16 -15
  113. package/legacy/legacy.js.map +1 -1
  114. package/license.md +71 -0
  115. package/mix/index.d.ts +1 -1
  116. package/mix/index.js +1 -1
  117. package/mix/mix.fragment.d.ts +17 -17
  118. package/mix/mix.fragment.js +20 -20
  119. package/mix/mix.vertex.d.ts +18 -18
  120. package/mix/mix.vertex.js +21 -21
  121. package/mix/mixMaterial.d.ts +65 -65
  122. package/mix/mixMaterial.js +510 -510
  123. package/mix/mixMaterial.js.map +1 -1
  124. package/normal/index.d.ts +1 -1
  125. package/normal/index.js +1 -1
  126. package/normal/normal.fragment.d.ts +17 -17
  127. package/normal/normal.fragment.js +20 -20
  128. package/normal/normal.vertex.d.ts +18 -18
  129. package/normal/normal.vertex.js +21 -21
  130. package/normal/normalMaterial.d.ts +36 -36
  131. package/normal/normalMaterial.js +336 -336
  132. package/normal/normalMaterial.js.map +1 -1
  133. package/package.json +24 -5
  134. package/shadowOnly/index.d.ts +1 -1
  135. package/shadowOnly/index.js +1 -1
  136. package/shadowOnly/shadowOnly.fragment.d.ts +16 -16
  137. package/shadowOnly/shadowOnly.fragment.js +19 -19
  138. package/shadowOnly/shadowOnly.vertex.d.ts +18 -18
  139. package/shadowOnly/shadowOnly.vertex.js +21 -21
  140. package/shadowOnly/shadowOnlyMaterial.d.ts +30 -30
  141. package/shadowOnly/shadowOnlyMaterial.js +254 -254
  142. package/shadowOnly/shadowOnlyMaterial.js.map +1 -1
  143. package/simple/index.d.ts +1 -1
  144. package/simple/index.js +1 -1
  145. package/simple/simple.fragment.d.ts +17 -17
  146. package/simple/simple.fragment.js +20 -20
  147. package/simple/simple.vertex.d.ts +18 -18
  148. package/simple/simple.vertex.js +21 -21
  149. package/simple/simpleMaterial.d.ts +35 -35
  150. package/simple/simpleMaterial.js +295 -295
  151. package/simple/simpleMaterial.js.map +1 -1
  152. package/sky/index.d.ts +1 -1
  153. package/sky/index.js +1 -1
  154. package/sky/sky.fragment.d.ts +10 -10
  155. package/sky/sky.fragment.js +13 -13
  156. package/sky/sky.vertex.d.ts +9 -9
  157. package/sky/sky.vertex.js +12 -12
  158. package/sky/skyMaterial.d.ts +147 -146
  159. package/sky/skyMaterial.js +359 -359
  160. package/sky/skyMaterial.js.map +1 -1
  161. package/terrain/index.d.ts +1 -1
  162. package/terrain/index.js +1 -1
  163. package/terrain/terrain.fragment.d.ts +17 -17
  164. package/terrain/terrain.fragment.js +20 -20
  165. package/terrain/terrain.vertex.d.ts +18 -18
  166. package/terrain/terrain.vertex.js +21 -21
  167. package/terrain/terrainMaterial.d.ts +50 -50
  168. package/terrain/terrainMaterial.js +426 -426
  169. package/terrain/terrainMaterial.js.map +1 -1
  170. package/triPlanar/index.d.ts +1 -1
  171. package/triPlanar/index.js +1 -1
  172. package/triPlanar/triPlanarMaterial.d.ts +49 -49
  173. package/triPlanar/triPlanarMaterial.js +403 -403
  174. package/triPlanar/triPlanarMaterial.js.map +1 -1
  175. package/triPlanar/triplanar.fragment.d.ts +17 -17
  176. package/triPlanar/triplanar.fragment.js +20 -20
  177. package/triPlanar/triplanar.vertex.d.ts +18 -18
  178. package/triPlanar/triplanar.vertex.js +21 -21
  179. package/water/index.d.ts +1 -1
  180. package/water/index.js +1 -1
  181. package/water/water.fragment.d.ts +19 -19
  182. package/water/water.fragment.js +22 -22
  183. package/water/water.vertex.d.ts +20 -20
  184. package/water/water.vertex.js +23 -23
  185. package/water/waterMaterial.d.ts +135 -135
  186. package/water/waterMaterial.js +736 -736
  187. package/water/waterMaterial.js.map +1 -1
@@ -1,737 +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 "@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.js";
18
- import "./water.vertex.js";
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);
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.js";
18
+ import "./water.vertex.js";
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);
737
737
  //# sourceMappingURL=waterMaterial.js.map