Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AroriaNetwork
GitHub Repository: AroriaNetwork/3kho-backup
Path: blob/main/projects/temple-run-2/assets/babylonjs/babylonjs.materials.js
1834 views
1
(function webpackUniversalModuleDefinition(root, factory) {
2
if(typeof exports === 'object' && typeof module === 'object')
3
module.exports = factory(require("babylonjs"));
4
else if(typeof define === 'function' && define.amd)
5
define("babylonjs-materials", ["babylonjs"], factory);
6
else if(typeof exports === 'object')
7
exports["babylonjs-materials"] = factory(require("babylonjs"));
8
else
9
root["MATERIALS"] = factory(root["BABYLON"]);
10
})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__) {
11
return /******/ (function(modules) { // webpackBootstrap
12
/******/ // The module cache
13
/******/ var installedModules = {};
14
/******/
15
/******/ // The require function
16
/******/ function __webpack_require__(moduleId) {
17
/******/
18
/******/ // Check if module is in cache
19
/******/ if(installedModules[moduleId]) {
20
/******/ return installedModules[moduleId].exports;
21
/******/ }
22
/******/ // Create a new module (and put it into the cache)
23
/******/ var module = installedModules[moduleId] = {
24
/******/ i: moduleId,
25
/******/ l: false,
26
/******/ exports: {}
27
/******/ };
28
/******/
29
/******/ // Execute the module function
30
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
/******/
32
/******/ // Flag the module as loaded
33
/******/ module.l = true;
34
/******/
35
/******/ // Return the exports of the module
36
/******/ return module.exports;
37
/******/ }
38
/******/
39
/******/
40
/******/ // expose the modules object (__webpack_modules__)
41
/******/ __webpack_require__.m = modules;
42
/******/
43
/******/ // expose the module cache
44
/******/ __webpack_require__.c = installedModules;
45
/******/
46
/******/ // define getter function for harmony exports
47
/******/ __webpack_require__.d = function(exports, name, getter) {
48
/******/ if(!__webpack_require__.o(exports, name)) {
49
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
50
/******/ }
51
/******/ };
52
/******/
53
/******/ // define __esModule on exports
54
/******/ __webpack_require__.r = function(exports) {
55
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
56
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
57
/******/ }
58
/******/ Object.defineProperty(exports, '__esModule', { value: true });
59
/******/ };
60
/******/
61
/******/ // create a fake namespace object
62
/******/ // mode & 1: value is a module id, require it
63
/******/ // mode & 2: merge all properties of value into the ns
64
/******/ // mode & 4: return value when already ns object
65
/******/ // mode & 8|1: behave like require
66
/******/ __webpack_require__.t = function(value, mode) {
67
/******/ if(mode & 1) value = __webpack_require__(value);
68
/******/ if(mode & 8) return value;
69
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
70
/******/ var ns = Object.create(null);
71
/******/ __webpack_require__.r(ns);
72
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
73
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
74
/******/ return ns;
75
/******/ };
76
/******/
77
/******/ // getDefaultExport function for compatibility with non-harmony modules
78
/******/ __webpack_require__.n = function(module) {
79
/******/ var getter = module && module.__esModule ?
80
/******/ function getDefault() { return module['default']; } :
81
/******/ function getModuleExports() { return module; };
82
/******/ __webpack_require__.d(getter, 'a', getter);
83
/******/ return getter;
84
/******/ };
85
/******/
86
/******/ // Object.prototype.hasOwnProperty.call
87
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
88
/******/
89
/******/ // __webpack_public_path__
90
/******/ __webpack_require__.p = "";
91
/******/
92
/******/
93
/******/ // Load entry module and return exports
94
/******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
95
/******/ })
96
/************************************************************************/
97
/******/ ({
98
99
/***/ "../../node_modules/tslib/tslib.es6.js":
100
/*!***********************************************************!*\
101
!*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
102
\***********************************************************/
103
/*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
104
/***/ (function(module, __webpack_exports__, __webpack_require__) {
105
106
"use strict";
107
__webpack_require__.r(__webpack_exports__);
108
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
109
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
110
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
111
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
112
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
113
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
114
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
115
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
116
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
117
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
118
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
119
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
120
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
121
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
122
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArray", function() { return __spreadArray; });
123
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
124
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
125
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
126
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
127
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
128
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
129
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
130
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
131
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
132
/*! *****************************************************************************
133
Copyright (c) Microsoft Corporation.
134
135
Permission to use, copy, modify, and/or distribute this software for any
136
purpose with or without fee is hereby granted.
137
138
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
139
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
140
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
141
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
142
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
143
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
144
PERFORMANCE OF THIS SOFTWARE.
145
***************************************************************************** */
146
/* global Reflect, Promise */
147
148
var extendStatics = function(d, b) {
149
extendStatics = Object.setPrototypeOf ||
150
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
151
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
152
return extendStatics(d, b);
153
};
154
155
function __extends(d, b) {
156
if (typeof b !== "function" && b !== null)
157
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
158
extendStatics(d, b);
159
function __() { this.constructor = d; }
160
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
161
}
162
163
var __assign = function() {
164
__assign = Object.assign || function __assign(t) {
165
for (var s, i = 1, n = arguments.length; i < n; i++) {
166
s = arguments[i];
167
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
168
}
169
return t;
170
}
171
return __assign.apply(this, arguments);
172
}
173
174
function __rest(s, e) {
175
var t = {};
176
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
177
t[p] = s[p];
178
if (s != null && typeof Object.getOwnPropertySymbols === "function")
179
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
180
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
181
t[p[i]] = s[p[i]];
182
}
183
return t;
184
}
185
186
function __decorate(decorators, target, key, desc) {
187
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
188
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
189
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
190
return c > 3 && r && Object.defineProperty(target, key, r), r;
191
}
192
193
function __param(paramIndex, decorator) {
194
return function (target, key) { decorator(target, key, paramIndex); }
195
}
196
197
function __metadata(metadataKey, metadataValue) {
198
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
199
}
200
201
function __awaiter(thisArg, _arguments, P, generator) {
202
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
203
return new (P || (P = Promise))(function (resolve, reject) {
204
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
205
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
206
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
207
step((generator = generator.apply(thisArg, _arguments || [])).next());
208
});
209
}
210
211
function __generator(thisArg, body) {
212
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
213
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
214
function verb(n) { return function (v) { return step([n, v]); }; }
215
function step(op) {
216
if (f) throw new TypeError("Generator is already executing.");
217
while (_) try {
218
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
219
if (y = 0, t) op = [op[0] & 2, t.value];
220
switch (op[0]) {
221
case 0: case 1: t = op; break;
222
case 4: _.label++; return { value: op[1], done: false };
223
case 5: _.label++; y = op[1]; op = [0]; continue;
224
case 7: op = _.ops.pop(); _.trys.pop(); continue;
225
default:
226
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
227
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
228
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
229
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
230
if (t[2]) _.ops.pop();
231
_.trys.pop(); continue;
232
}
233
op = body.call(thisArg, _);
234
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
235
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
236
}
237
}
238
239
var __createBinding = Object.create ? (function(o, m, k, k2) {
240
if (k2 === undefined) k2 = k;
241
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
242
}) : (function(o, m, k, k2) {
243
if (k2 === undefined) k2 = k;
244
o[k2] = m[k];
245
});
246
247
function __exportStar(m, o) {
248
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
249
}
250
251
function __values(o) {
252
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
253
if (m) return m.call(o);
254
if (o && typeof o.length === "number") return {
255
next: function () {
256
if (o && i >= o.length) o = void 0;
257
return { value: o && o[i++], done: !o };
258
}
259
};
260
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
261
}
262
263
function __read(o, n) {
264
var m = typeof Symbol === "function" && o[Symbol.iterator];
265
if (!m) return o;
266
var i = m.call(o), r, ar = [], e;
267
try {
268
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
269
}
270
catch (error) { e = { error: error }; }
271
finally {
272
try {
273
if (r && !r.done && (m = i["return"])) m.call(i);
274
}
275
finally { if (e) throw e.error; }
276
}
277
return ar;
278
}
279
280
/** @deprecated */
281
function __spread() {
282
for (var ar = [], i = 0; i < arguments.length; i++)
283
ar = ar.concat(__read(arguments[i]));
284
return ar;
285
}
286
287
/** @deprecated */
288
function __spreadArrays() {
289
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
290
for (var r = Array(s), k = 0, i = 0; i < il; i++)
291
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
292
r[k] = a[j];
293
return r;
294
}
295
296
function __spreadArray(to, from, pack) {
297
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
298
if (ar || !(i in from)) {
299
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
300
ar[i] = from[i];
301
}
302
}
303
return to.concat(ar || Array.prototype.slice.call(from));
304
}
305
306
function __await(v) {
307
return this instanceof __await ? (this.v = v, this) : new __await(v);
308
}
309
310
function __asyncGenerator(thisArg, _arguments, generator) {
311
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
312
var g = generator.apply(thisArg, _arguments || []), i, q = [];
313
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
314
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
315
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
316
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
317
function fulfill(value) { resume("next", value); }
318
function reject(value) { resume("throw", value); }
319
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
320
}
321
322
function __asyncDelegator(o) {
323
var i, p;
324
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
325
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
326
}
327
328
function __asyncValues(o) {
329
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
330
var m = o[Symbol.asyncIterator], i;
331
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
332
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
333
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
334
}
335
336
function __makeTemplateObject(cooked, raw) {
337
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
338
return cooked;
339
};
340
341
var __setModuleDefault = Object.create ? (function(o, v) {
342
Object.defineProperty(o, "default", { enumerable: true, value: v });
343
}) : function(o, v) {
344
o["default"] = v;
345
};
346
347
function __importStar(mod) {
348
if (mod && mod.__esModule) return mod;
349
var result = {};
350
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
351
__setModuleDefault(result, mod);
352
return result;
353
}
354
355
function __importDefault(mod) {
356
return (mod && mod.__esModule) ? mod : { default: mod };
357
}
358
359
function __classPrivateFieldGet(receiver, state, kind, f) {
360
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
361
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
362
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
363
}
364
365
function __classPrivateFieldSet(receiver, state, value, kind, f) {
366
if (kind === "m") throw new TypeError("Private method is not writable");
367
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
368
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
369
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
370
}
371
372
373
/***/ }),
374
375
/***/ "../../node_modules/webpack/buildin/global.js":
376
/*!***********************************!*\
377
!*** (webpack)/buildin/global.js ***!
378
\***********************************/
379
/*! no static exports found */
380
/***/ (function(module, exports) {
381
382
var g;
383
384
// This works in non-strict mode
385
g = (function() {
386
return this;
387
})();
388
389
try {
390
// This works if eval is allowed (see CSP)
391
g = g || new Function("return this")();
392
} catch (e) {
393
// This works if the window reference is available
394
if (typeof window === "object") g = window;
395
}
396
397
// g can still be undefined, but nothing to do about it...
398
// We return undefined, instead of nothing here, so it's
399
// easier to handle this case. if(!global) { ...}
400
401
module.exports = g;
402
403
404
/***/ }),
405
406
/***/ "./cell/cell.fragment.ts":
407
/*!*******************************!*\
408
!*** ./cell/cell.fragment.ts ***!
409
\*******************************/
410
/*! exports provided: cellPixelShader */
411
/***/ (function(module, __webpack_exports__, __webpack_require__) {
412
413
"use strict";
414
__webpack_require__.r(__webpack_exports__);
415
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cellPixelShader", function() { return cellPixelShader; });
416
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
417
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
418
419
420
421
422
423
424
425
426
427
428
429
430
431
var name = 'cellPixelShader';
432
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
433
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
434
/** @hidden */
435
var cellPixelShader = { name: name, shader: shader };
436
437
438
/***/ }),
439
440
/***/ "./cell/cell.vertex.ts":
441
/*!*****************************!*\
442
!*** ./cell/cell.vertex.ts ***!
443
\*****************************/
444
/*! exports provided: cellVertexShader */
445
/***/ (function(module, __webpack_exports__, __webpack_require__) {
446
447
"use strict";
448
__webpack_require__.r(__webpack_exports__);
449
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cellVertexShader", function() { return cellVertexShader; });
450
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
451
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
452
453
454
455
456
457
458
459
460
461
462
463
464
var name = 'cellVertexShader';
465
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
466
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
467
/** @hidden */
468
var cellVertexShader = { name: name, shader: shader };
469
470
471
/***/ }),
472
473
/***/ "./cell/cellMaterial.ts":
474
/*!******************************!*\
475
!*** ./cell/cellMaterial.ts ***!
476
\******************************/
477
/*! exports provided: CellMaterial */
478
/***/ (function(module, __webpack_exports__, __webpack_require__) {
479
480
"use strict";
481
__webpack_require__.r(__webpack_exports__);
482
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CellMaterial", function() { return CellMaterial; });
483
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
484
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
485
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
486
/* harmony import */ var _cell_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cell.fragment */ "./cell/cell.fragment.ts");
487
/* harmony import */ var _cell_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./cell.vertex */ "./cell/cell.vertex.ts");
488
489
490
491
492
493
494
495
496
497
498
499
500
501
var CellMaterialDefines = /** @class */ (function (_super) {
502
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CellMaterialDefines, _super);
503
function CellMaterialDefines() {
504
var _this = _super.call(this) || this;
505
_this.DIFFUSE = false;
506
_this.CLIPPLANE = false;
507
_this.CLIPPLANE2 = false;
508
_this.CLIPPLANE3 = false;
509
_this.CLIPPLANE4 = false;
510
_this.CLIPPLANE5 = false;
511
_this.CLIPPLANE6 = false;
512
_this.ALPHATEST = false;
513
_this.POINTSIZE = false;
514
_this.FOG = false;
515
_this.NORMAL = false;
516
_this.UV1 = false;
517
_this.UV2 = false;
518
_this.VERTEXCOLOR = false;
519
_this.VERTEXALPHA = false;
520
_this.NUM_BONE_INFLUENCERS = 0;
521
_this.BonesPerMesh = 0;
522
_this.INSTANCES = false;
523
_this.NDOTL = true;
524
_this.CUSTOMUSERLIGHTING = true;
525
_this.CELLBASIC = true;
526
_this.DEPTHPREPASS = false;
527
_this.IMAGEPROCESSINGPOSTPROCESS = false;
528
_this.rebuild();
529
return _this;
530
}
531
return CellMaterialDefines;
532
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
533
var CellMaterial = /** @class */ (function (_super) {
534
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CellMaterial, _super);
535
function CellMaterial(name, scene) {
536
var _this = _super.call(this, name, scene) || this;
537
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
538
_this._computeHighLevel = false;
539
_this._disableLighting = false;
540
_this._maxSimultaneousLights = 4;
541
return _this;
542
}
543
CellMaterial.prototype.needAlphaBlending = function () {
544
return (this.alpha < 1.0);
545
};
546
CellMaterial.prototype.needAlphaTesting = function () {
547
return false;
548
};
549
CellMaterial.prototype.getAlphaTestTexture = function () {
550
return null;
551
};
552
// Methods
553
CellMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
554
if (this.isFrozen) {
555
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
556
return true;
557
}
558
}
559
if (!subMesh._materialDefines) {
560
subMesh.materialDefines = new CellMaterialDefines();
561
}
562
var defines = subMesh._materialDefines;
563
var scene = this.getScene();
564
if (this._isReadyForSubMesh(subMesh)) {
565
return true;
566
}
567
var engine = scene.getEngine();
568
// Textures
569
if (defines._areTexturesDirty) {
570
defines._needUVs = false;
571
if (scene.texturesEnabled) {
572
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
573
if (!this._diffuseTexture.isReady()) {
574
return false;
575
}
576
else {
577
defines._needUVs = true;
578
defines.DIFFUSE = true;
579
}
580
}
581
}
582
}
583
// High level
584
defines.CELLBASIC = !this.computeHighLevel;
585
// Misc.
586
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
587
// Lights
588
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
589
// Values that need to be evaluated on every frame
590
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
591
// Attribs
592
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
593
// Get correct effect
594
if (defines.isDirty) {
595
defines.markAsProcessed();
596
scene.resetCachedMaterial();
597
// Fallbacks
598
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
599
if (defines.FOG) {
600
fallbacks.addFallback(1, "FOG");
601
}
602
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
603
if (defines.NUM_BONE_INFLUENCERS > 0) {
604
fallbacks.addCPUSkinningFallback(0, mesh);
605
}
606
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
607
//Attributes
608
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
609
if (defines.NORMAL) {
610
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
611
}
612
if (defines.UV1) {
613
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
614
}
615
if (defines.UV2) {
616
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
617
}
618
if (defines.VERTEXCOLOR) {
619
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
620
}
621
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
622
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
623
var shaderName = "cell";
624
var join = defines.toString();
625
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
626
"vFogInfos", "vFogColor", "pointSize",
627
"vDiffuseInfos",
628
"mBones",
629
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
630
];
631
var samplers = ["diffuseSampler"];
632
var uniformBuffers = new Array();
633
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
634
uniformsNames: uniforms,
635
uniformBuffersNames: uniformBuffers,
636
samplers: samplers,
637
defines: defines,
638
maxSimultaneousLights: this.maxSimultaneousLights
639
});
640
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
641
attributes: attribs,
642
uniformsNames: uniforms,
643
uniformBuffersNames: uniformBuffers,
644
samplers: samplers,
645
defines: join,
646
fallbacks: fallbacks,
647
onCompiled: this.onCompiled,
648
onError: this.onError,
649
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 }
650
}, engine), defines, this._materialContext);
651
}
652
if (!subMesh.effect || !subMesh.effect.isReady()) {
653
return false;
654
}
655
defines._renderId = scene.getRenderId();
656
subMesh.effect._wasPreviouslyReady = true;
657
return true;
658
};
659
CellMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
660
var scene = this.getScene();
661
var defines = subMesh._materialDefines;
662
if (!defines) {
663
return;
664
}
665
var effect = subMesh.effect;
666
if (!effect) {
667
return;
668
}
669
this._activeEffect = effect;
670
// Matrices
671
this.bindOnlyWorldMatrix(world);
672
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
673
// Bones
674
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
675
if (this._mustRebind(scene, effect)) {
676
// Textures
677
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
678
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
679
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
680
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
681
}
682
// Clip plane
683
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
684
// Point size
685
if (this.pointsCloud) {
686
this._activeEffect.setFloat("pointSize", this.pointSize);
687
}
688
scene.bindEyePosition(effect);
689
}
690
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
691
// Lights
692
if (scene.lightsEnabled && !this.disableLighting) {
693
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
694
}
695
// View
696
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
697
this._activeEffect.setMatrix("view", scene.getViewMatrix());
698
}
699
// Fog
700
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
701
this._afterBind(mesh, this._activeEffect);
702
};
703
CellMaterial.prototype.getAnimatables = function () {
704
var results = [];
705
if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
706
results.push(this._diffuseTexture);
707
}
708
return results;
709
};
710
CellMaterial.prototype.getActiveTextures = function () {
711
var activeTextures = _super.prototype.getActiveTextures.call(this);
712
if (this._diffuseTexture) {
713
activeTextures.push(this._diffuseTexture);
714
}
715
return activeTextures;
716
};
717
CellMaterial.prototype.hasTexture = function (texture) {
718
if (_super.prototype.hasTexture.call(this, texture)) {
719
return true;
720
}
721
return this._diffuseTexture === texture;
722
};
723
CellMaterial.prototype.dispose = function (forceDisposeEffect) {
724
if (this._diffuseTexture) {
725
this._diffuseTexture.dispose();
726
}
727
_super.prototype.dispose.call(this, forceDisposeEffect);
728
};
729
CellMaterial.prototype.getClassName = function () {
730
return "CellMaterial";
731
};
732
CellMaterial.prototype.clone = function (name) {
733
var _this = this;
734
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new CellMaterial(name, _this.getScene()); }, this);
735
};
736
CellMaterial.prototype.serialize = function () {
737
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
738
serializationObject.customType = "BABYLON.CellMaterial";
739
return serializationObject;
740
};
741
// Statics
742
CellMaterial.Parse = function (source, scene, rootUrl) {
743
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new CellMaterial(source.name, scene); }, source, scene, rootUrl);
744
};
745
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
746
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
747
], CellMaterial.prototype, "_diffuseTexture", void 0);
748
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
749
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
750
], CellMaterial.prototype, "diffuseTexture", void 0);
751
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
752
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
753
], CellMaterial.prototype, "diffuseColor", void 0);
754
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
755
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("computeHighLevel")
756
], CellMaterial.prototype, "_computeHighLevel", void 0);
757
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
758
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
759
], CellMaterial.prototype, "computeHighLevel", void 0);
760
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
761
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
762
], CellMaterial.prototype, "_disableLighting", void 0);
763
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
764
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
765
], CellMaterial.prototype, "disableLighting", void 0);
766
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
767
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
768
], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
769
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
770
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
771
], CellMaterial.prototype, "maxSimultaneousLights", void 0);
772
return CellMaterial;
773
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
774
775
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.CellMaterial"] = CellMaterial;
776
777
778
/***/ }),
779
780
/***/ "./cell/index.ts":
781
/*!***********************!*\
782
!*** ./cell/index.ts ***!
783
\***********************/
784
/*! exports provided: CellMaterial */
785
/***/ (function(module, __webpack_exports__, __webpack_require__) {
786
787
"use strict";
788
__webpack_require__.r(__webpack_exports__);
789
/* harmony import */ var _cellMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cellMaterial */ "./cell/cellMaterial.ts");
790
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CellMaterial", function() { return _cellMaterial__WEBPACK_IMPORTED_MODULE_0__["CellMaterial"]; });
791
792
793
794
795
/***/ }),
796
797
/***/ "./custom/customMaterial.ts":
798
/*!**********************************!*\
799
!*** ./custom/customMaterial.ts ***!
800
\**********************************/
801
/*! exports provided: CustomShaderStructure, ShaderSpecialParts, CustomMaterial */
802
/***/ (function(module, __webpack_exports__, __webpack_require__) {
803
804
"use strict";
805
__webpack_require__.r(__webpack_exports__);
806
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return CustomShaderStructure; });
807
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return ShaderSpecialParts; });
808
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return CustomMaterial; });
809
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
810
/* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
811
/* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__);
812
813
814
815
816
var CustomShaderStructure = /** @class */ (function () {
817
function CustomShaderStructure() {
818
}
819
return CustomShaderStructure;
820
}());
821
822
var ShaderSpecialParts = /** @class */ (function () {
823
function ShaderSpecialParts() {
824
}
825
return ShaderSpecialParts;
826
}());
827
828
var CustomMaterial = /** @class */ (function (_super) {
829
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CustomMaterial, _super);
830
function CustomMaterial(name, scene) {
831
var _this = _super.call(this, name, scene) || this;
832
_this.CustomParts = new ShaderSpecialParts();
833
_this.customShaderNameResolve = _this.Builder;
834
_this.FragmentShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["defaultPixelShader"];
835
_this.VertexShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["defaultVertexShader"];
836
return _this;
837
}
838
CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
839
if (this._newUniformInstances) {
840
for (var el in this._newUniformInstances) {
841
var ea = el.toString().split('-');
842
if (ea[0] == 'vec2') {
843
effect.setVector2(ea[1], this._newUniformInstances[el]);
844
}
845
else if (ea[0] == 'vec3') {
846
effect.setVector3(ea[1], this._newUniformInstances[el]);
847
}
848
else if (ea[0] == 'vec4') {
849
effect.setVector4(ea[1], this._newUniformInstances[el]);
850
}
851
else if (ea[0] == 'mat4') {
852
effect.setMatrix(ea[1], this._newUniformInstances[el]);
853
}
854
else if (ea[0] == 'float') {
855
effect.setFloat(ea[1], this._newUniformInstances[el]);
856
}
857
}
858
}
859
if (this._newSamplerInstances) {
860
for (var el in this._newSamplerInstances) {
861
var ea = el.toString().split('-');
862
if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
863
effect.setTexture(ea[1], this._newSamplerInstances[el]);
864
}
865
}
866
}
867
};
868
CustomMaterial.prototype.ReviewUniform = function (name, arr) {
869
if (name == "uniform" && this._newUniforms) {
870
for (var ind = 0; ind < this._newUniforms.length; ind++) {
871
if (this._customUniform[ind].indexOf('sampler') == -1) {
872
arr.push(this._newUniforms[ind]);
873
}
874
}
875
}
876
if (name == "sampler" && this._newUniforms) {
877
for (var ind = 0; ind < this._newUniforms.length; ind++) {
878
if (this._customUniform[ind].indexOf('sampler') != -1) {
879
arr.push(this._newUniforms[ind]);
880
}
881
}
882
}
883
return arr;
884
};
885
CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines, attributes) {
886
var _this = this;
887
if (attributes && this._customAttributes && this._customAttributes.length > 0) {
888
attributes.push.apply(attributes, this._customAttributes);
889
}
890
this.ReviewUniform("uniform", uniforms);
891
this.ReviewUniform("sampler", samplers);
892
if (this._isCreatedShader) {
893
return this._createdShaderName;
894
}
895
this._isCreatedShader = false;
896
CustomMaterial.ShaderIndexer++;
897
var name = "custom_" + CustomMaterial.ShaderIndexer;
898
var fn_afterBind = this._afterBind.bind(this);
899
this._afterBind = function (m, e) {
900
if (!e) {
901
return;
902
}
903
_this.AttachAfterBind(m, e);
904
try {
905
fn_afterBind(m, e);
906
}
907
catch (e) { }
908
};
909
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = this.VertexShader
910
.replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
911
.replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
912
.replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
913
.replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
914
.replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""))
915
.replace('#define CUSTOM_VERTEX_MAIN_END', (this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : ""));
916
if (this.CustomParts.Vertex_After_WorldPosComputed) {
917
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"].replace('#define CUSTOM_VERTEX_UPDATE_WORLDPOS', this.CustomParts.Vertex_After_WorldPosComputed);
918
}
919
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = this.FragmentShader
920
.replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
921
.replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
922
.replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
923
.replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
924
.replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
925
.replace('#define CUSTOM_FRAGMENT_BEFORE_LIGHTS', (this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : ""))
926
.replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
927
if (this.CustomParts.Fragment_Before_Fog) {
928
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"].replace('#define CUSTOM_FRAGMENT_BEFORE_FOG', this.CustomParts.Fragment_Before_Fog);
929
}
930
this._isCreatedShader = true;
931
this._createdShaderName = name;
932
return name;
933
};
934
CustomMaterial.prototype.AddUniform = function (name, kind, param) {
935
if (!this._customUniform) {
936
this._customUniform = new Array();
937
this._newUniforms = new Array();
938
this._newSamplerInstances = {};
939
this._newUniformInstances = {};
940
}
941
if (param) {
942
if (kind.indexOf("sampler") != -1) {
943
this._newSamplerInstances[kind + "-" + name] = param;
944
}
945
else {
946
this._newUniformInstances[kind + "-" + name] = param;
947
}
948
}
949
this._customUniform.push("uniform " + kind + " " + name + ";");
950
this._newUniforms.push(name);
951
return this;
952
};
953
CustomMaterial.prototype.AddAttribute = function (name) {
954
if (!this._customAttributes) {
955
this._customAttributes = [];
956
}
957
this._customAttributes.push(name);
958
return this;
959
};
960
CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
961
this.CustomParts.Fragment_Begin = shaderPart;
962
return this;
963
};
964
CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
965
this.CustomParts.Fragment_Definitions = shaderPart;
966
return this;
967
};
968
CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
969
this.CustomParts.Fragment_MainBegin = shaderPart;
970
return this;
971
};
972
CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
973
this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
974
return this;
975
};
976
CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
977
this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
978
return this;
979
};
980
CustomMaterial.prototype.Fragment_Before_Lights = function (shaderPart) {
981
this.CustomParts.Fragment_Before_Lights = shaderPart;
982
return this;
983
};
984
CustomMaterial.prototype.Fragment_Before_Fog = function (shaderPart) {
985
this.CustomParts.Fragment_Before_Fog = shaderPart;
986
return this;
987
};
988
CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
989
this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
990
return this;
991
};
992
CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
993
this.CustomParts.Vertex_Begin = shaderPart;
994
return this;
995
};
996
CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
997
this.CustomParts.Vertex_Definitions = shaderPart;
998
return this;
999
};
1000
CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
1001
this.CustomParts.Vertex_MainBegin = shaderPart;
1002
return this;
1003
};
1004
CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
1005
this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
1006
return this;
1007
};
1008
CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
1009
this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
1010
return this;
1011
};
1012
CustomMaterial.prototype.Vertex_After_WorldPosComputed = function (shaderPart) {
1013
this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;
1014
return this;
1015
};
1016
CustomMaterial.prototype.Vertex_MainEnd = function (shaderPart) {
1017
this.CustomParts.Vertex_MainEnd = shaderPart;
1018
return this;
1019
};
1020
CustomMaterial.ShaderIndexer = 1;
1021
return CustomMaterial;
1022
}(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]));
1023
1024
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.CustomMaterial"] = CustomMaterial;
1025
1026
1027
/***/ }),
1028
1029
/***/ "./custom/index.ts":
1030
/*!*************************!*\
1031
!*** ./custom/index.ts ***!
1032
\*************************/
1033
/*! exports provided: CustomShaderStructure, ShaderSpecialParts, CustomMaterial, ShaderAlebdoParts, PBRCustomMaterial */
1034
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1035
1036
"use strict";
1037
__webpack_require__.r(__webpack_exports__);
1038
/* harmony import */ var _customMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customMaterial */ "./custom/customMaterial.ts");
1039
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["CustomShaderStructure"]; });
1040
1041
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["ShaderSpecialParts"]; });
1042
1043
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["CustomMaterial"]; });
1044
1045
/* harmony import */ var _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrCustomMaterial */ "./custom/pbrCustomMaterial.ts");
1046
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__["ShaderAlebdoParts"]; });
1047
1048
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRCustomMaterial"]; });
1049
1050
1051
1052
1053
1054
/***/ }),
1055
1056
/***/ "./custom/pbrCustomMaterial.ts":
1057
/*!*************************************!*\
1058
!*** ./custom/pbrCustomMaterial.ts ***!
1059
\*************************************/
1060
/*! exports provided: ShaderAlebdoParts, PBRCustomMaterial */
1061
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1062
1063
"use strict";
1064
__webpack_require__.r(__webpack_exports__);
1065
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return ShaderAlebdoParts; });
1066
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return PBRCustomMaterial; });
1067
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
1068
/* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/decorators");
1069
/* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__);
1070
1071
1072
1073
1074
1075
var ShaderAlebdoParts = /** @class */ (function () {
1076
function ShaderAlebdoParts() {
1077
}
1078
return ShaderAlebdoParts;
1079
}());
1080
1081
var PBRCustomMaterial = /** @class */ (function (_super) {
1082
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PBRCustomMaterial, _super);
1083
function PBRCustomMaterial(name, scene) {
1084
var _this = _super.call(this, name, scene) || this;
1085
_this.CustomParts = new ShaderAlebdoParts();
1086
_this.customShaderNameResolve = _this.Builder;
1087
_this.FragmentShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["pbrPixelShader"];
1088
_this.VertexShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["pbrVertexShader"];
1089
_this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockAlbedoOpacity"]);
1090
_this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockReflectivity"]);
1091
_this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockFinalColorComposition"]);
1092
return _this;
1093
}
1094
PBRCustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
1095
if (this._newUniformInstances) {
1096
for (var el in this._newUniformInstances) {
1097
var ea = el.toString().split('-');
1098
if (ea[0] == 'vec2') {
1099
effect.setVector2(ea[1], this._newUniformInstances[el]);
1100
}
1101
else if (ea[0] == 'vec3') {
1102
effect.setVector3(ea[1], this._newUniformInstances[el]);
1103
}
1104
else if (ea[0] == 'vec4') {
1105
effect.setVector4(ea[1], this._newUniformInstances[el]);
1106
}
1107
else if (ea[0] == 'mat4') {
1108
effect.setMatrix(ea[1], this._newUniformInstances[el]);
1109
}
1110
else if (ea[0] == 'float') {
1111
effect.setFloat(ea[1], this._newUniformInstances[el]);
1112
}
1113
}
1114
}
1115
if (this._newSamplerInstances) {
1116
for (var el in this._newSamplerInstances) {
1117
var ea = el.toString().split('-');
1118
if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
1119
effect.setTexture(ea[1], this._newSamplerInstances[el]);
1120
}
1121
}
1122
}
1123
};
1124
PBRCustomMaterial.prototype.ReviewUniform = function (name, arr) {
1125
if (name == "uniform" && this._newUniforms) {
1126
for (var ind = 0; ind < this._newUniforms.length; ind++) {
1127
if (this._customUniform[ind].indexOf('sampler') == -1) {
1128
arr.push(this._newUniforms[ind]);
1129
}
1130
}
1131
}
1132
if (name == "sampler" && this._newUniforms) {
1133
for (var ind = 0; ind < this._newUniforms.length; ind++) {
1134
if (this._customUniform[ind].indexOf('sampler') != -1) {
1135
arr.push(this._newUniforms[ind]);
1136
}
1137
}
1138
}
1139
return arr;
1140
};
1141
PBRCustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines, attributes, options) {
1142
var _this = this;
1143
if (options) {
1144
var currentProcessing_1 = options.processFinalCode;
1145
options.processFinalCode = function (type, code) {
1146
if (type === "vertex") {
1147
return currentProcessing_1 ? currentProcessing_1(type, code) : code;
1148
}
1149
var sci = new babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["ShaderCodeInliner"](code);
1150
sci.inlineToken = "#define pbr_inline";
1151
sci.processCode();
1152
return currentProcessing_1 ? currentProcessing_1(type, sci.code) : sci.code;
1153
};
1154
}
1155
if (attributes && this._customAttributes && this._customAttributes.length > 0) {
1156
attributes.push.apply(attributes, this._customAttributes);
1157
}
1158
this.ReviewUniform("uniform", uniforms);
1159
this.ReviewUniform("sampler", samplers);
1160
if (this._isCreatedShader) {
1161
return this._createdShaderName;
1162
}
1163
this._isCreatedShader = false;
1164
PBRCustomMaterial.ShaderIndexer++;
1165
var name = "custom_" + PBRCustomMaterial.ShaderIndexer;
1166
var fn_afterBind = this._afterBind.bind(this);
1167
this._afterBind = function (m, e) {
1168
if (!e) {
1169
return;
1170
}
1171
_this.AttachAfterBind(m, e);
1172
try {
1173
fn_afterBind(m, e);
1174
}
1175
catch (e) { }
1176
};
1177
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = this.VertexShader
1178
.replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
1179
.replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
1180
.replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
1181
.replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
1182
.replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""))
1183
.replace('#define CUSTOM_VERTEX_MAIN_END', (this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : ""));
1184
if (this.CustomParts.Vertex_After_WorldPosComputed) {
1185
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"].replace('#define CUSTOM_VERTEX_UPDATE_WORLDPOS', this.CustomParts.Vertex_After_WorldPosComputed);
1186
}
1187
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = this.FragmentShader
1188
.replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
1189
.replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
1190
.replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
1191
.replace('#define CUSTOM_FRAGMENT_UPDATE_ALBEDO', (this.CustomParts.Fragment_Custom_Albedo ? this.CustomParts.Fragment_Custom_Albedo : ""))
1192
.replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
1193
.replace('#define CUSTOM_FRAGMENT_BEFORE_LIGHTS', (this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : ""))
1194
.replace('#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS', (this.CustomParts.Fragment_Custom_MetallicRoughness ? this.CustomParts.Fragment_Custom_MetallicRoughness : ""))
1195
.replace('#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE', (this.CustomParts.Fragment_Custom_MicroSurface ? this.CustomParts.Fragment_Custom_MicroSurface : ""))
1196
.replace('#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION', (this.CustomParts.Fragment_Before_FinalColorComposition ? this.CustomParts.Fragment_Before_FinalColorComposition : ""))
1197
.replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
1198
if (this.CustomParts.Fragment_Before_Fog) {
1199
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"].replace('#define CUSTOM_FRAGMENT_BEFORE_FOG', this.CustomParts.Fragment_Before_Fog);
1200
}
1201
this._isCreatedShader = true;
1202
this._createdShaderName = name;
1203
return name;
1204
};
1205
PBRCustomMaterial.prototype.AddUniform = function (name, kind, param) {
1206
if (!this._customUniform) {
1207
this._customUniform = new Array();
1208
this._newUniforms = new Array();
1209
this._newSamplerInstances = {};
1210
this._newUniformInstances = {};
1211
}
1212
if (param) {
1213
if (kind.indexOf("sampler") != -1) {
1214
this._newSamplerInstances[kind + "-" + name] = param;
1215
}
1216
else {
1217
this._newUniformInstances[kind + "-" + name] = param;
1218
}
1219
}
1220
this._customUniform.push("uniform " + kind + " " + name + ";");
1221
this._newUniforms.push(name);
1222
return this;
1223
};
1224
PBRCustomMaterial.prototype.AddAttribute = function (name) {
1225
if (!this._customAttributes) {
1226
this._customAttributes = [];
1227
}
1228
this._customAttributes.push(name);
1229
return this;
1230
};
1231
PBRCustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
1232
this.CustomParts.Fragment_Begin = shaderPart;
1233
return this;
1234
};
1235
PBRCustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
1236
this.CustomParts.Fragment_Definitions = shaderPart;
1237
return this;
1238
};
1239
PBRCustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
1240
this.CustomParts.Fragment_MainBegin = shaderPart;
1241
return this;
1242
};
1243
PBRCustomMaterial.prototype.Fragment_Custom_Albedo = function (shaderPart) {
1244
this.CustomParts.Fragment_Custom_Albedo = shaderPart.replace("result", "surfaceAlbedo");
1245
return this;
1246
};
1247
PBRCustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
1248
this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
1249
return this;
1250
};
1251
PBRCustomMaterial.prototype.Fragment_Before_Lights = function (shaderPart) {
1252
this.CustomParts.Fragment_Before_Lights = shaderPart;
1253
return this;
1254
};
1255
PBRCustomMaterial.prototype.Fragment_Custom_MetallicRoughness = function (shaderPart) {
1256
this.CustomParts.Fragment_Custom_MetallicRoughness = shaderPart;
1257
return this;
1258
};
1259
PBRCustomMaterial.prototype.Fragment_Custom_MicroSurface = function (shaderPart) {
1260
this.CustomParts.Fragment_Custom_MicroSurface = shaderPart;
1261
return this;
1262
};
1263
PBRCustomMaterial.prototype.Fragment_Before_Fog = function (shaderPart) {
1264
this.CustomParts.Fragment_Before_Fog = shaderPart;
1265
return this;
1266
};
1267
PBRCustomMaterial.prototype.Fragment_Before_FinalColorComposition = function (shaderPart) {
1268
this.CustomParts.Fragment_Before_FinalColorComposition = shaderPart;
1269
return this;
1270
};
1271
PBRCustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
1272
this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
1273
return this;
1274
};
1275
PBRCustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
1276
this.CustomParts.Vertex_Begin = shaderPart;
1277
return this;
1278
};
1279
PBRCustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
1280
this.CustomParts.Vertex_Definitions = shaderPart;
1281
return this;
1282
};
1283
PBRCustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
1284
this.CustomParts.Vertex_MainBegin = shaderPart;
1285
return this;
1286
};
1287
PBRCustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
1288
this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
1289
return this;
1290
};
1291
PBRCustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
1292
this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
1293
return this;
1294
};
1295
PBRCustomMaterial.prototype.Vertex_After_WorldPosComputed = function (shaderPart) {
1296
this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;
1297
return this;
1298
};
1299
PBRCustomMaterial.prototype.Vertex_MainEnd = function (shaderPart) {
1300
this.CustomParts.Vertex_MainEnd = shaderPart;
1301
return this;
1302
};
1303
PBRCustomMaterial.ShaderIndexer = 1;
1304
return PBRCustomMaterial;
1305
}(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["PBRMaterial"]));
1306
1307
babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.PBRCustomMaterial"] = PBRCustomMaterial;
1308
1309
1310
/***/ }),
1311
1312
/***/ "./fire/fire.fragment.ts":
1313
/*!*******************************!*\
1314
!*** ./fire/fire.fragment.ts ***!
1315
\*******************************/
1316
/*! exports provided: firePixelShader */
1317
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1318
1319
"use strict";
1320
__webpack_require__.r(__webpack_exports__);
1321
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "firePixelShader", function() { return firePixelShader; });
1322
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
1323
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
1324
1325
1326
1327
1328
1329
1330
1331
var name = 'firePixelShader';
1332
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\nuniform sampler2D distortionSampler;\nuniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{\nreturn vec4(2.0)*x-vec4(1.0);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\n\nfloat alpha=1.0;\n#ifdef DIFFUSE\n\nconst float distortionAmount0=0.092;\nconst float distortionAmount1=0.092;\nconst float distortionAmount2=0.092;\nvec2 heightAttenuation=vec2(0.3,0.39);\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\nbaseColor*=opacityColor;\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
1333
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
1334
/** @hidden */
1335
var firePixelShader = { name: name, shader: shader };
1336
1337
1338
/***/ }),
1339
1340
/***/ "./fire/fire.vertex.ts":
1341
/*!*****************************!*\
1342
!*** ./fire/fire.vertex.ts ***!
1343
\*****************************/
1344
/*! exports provided: fireVertexShader */
1345
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1346
1347
"use strict";
1348
__webpack_require__.r(__webpack_exports__);
1349
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fireVertexShader", function() { return fireVertexShader; });
1350
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
1351
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
var name = 'fireVertexShader';
1362
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n\nuniform float time;\nuniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n\n#ifdef DIFFUSE\nvDiffuseUV=uv;\nvDiffuseUV.y-=0.2;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\n\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\nvDistortionCoords1.x=uv.x;\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\nvDistortionCoords2.x=uv.x;\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\nvDistortionCoords3.x=uv.x;\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n}\n";
1363
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
1364
/** @hidden */
1365
var fireVertexShader = { name: name, shader: shader };
1366
1367
1368
/***/ }),
1369
1370
/***/ "./fire/fireMaterial.ts":
1371
/*!******************************!*\
1372
!*** ./fire/fireMaterial.ts ***!
1373
\******************************/
1374
/*! exports provided: FireMaterial */
1375
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1376
1377
"use strict";
1378
__webpack_require__.r(__webpack_exports__);
1379
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FireMaterial", function() { return FireMaterial; });
1380
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
1381
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
1382
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
1383
/* harmony import */ var _fire_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fire.fragment */ "./fire/fire.fragment.ts");
1384
/* harmony import */ var _fire_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fire.vertex */ "./fire/fire.vertex.ts");
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
var FireMaterialDefines = /** @class */ (function (_super) {
1401
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FireMaterialDefines, _super);
1402
function FireMaterialDefines() {
1403
var _this = _super.call(this) || this;
1404
_this.DIFFUSE = false;
1405
_this.CLIPPLANE = false;
1406
_this.CLIPPLANE2 = false;
1407
_this.CLIPPLANE3 = false;
1408
_this.CLIPPLANE4 = false;
1409
_this.CLIPPLANE5 = false;
1410
_this.CLIPPLANE6 = false;
1411
_this.ALPHATEST = false;
1412
_this.DEPTHPREPASS = false;
1413
_this.POINTSIZE = false;
1414
_this.FOG = false;
1415
_this.UV1 = false;
1416
_this.VERTEXCOLOR = false;
1417
_this.VERTEXALPHA = false;
1418
_this.BonesPerMesh = 0;
1419
_this.NUM_BONE_INFLUENCERS = 0;
1420
_this.INSTANCES = false;
1421
_this.IMAGEPROCESSINGPOSTPROCESS = false;
1422
_this.rebuild();
1423
return _this;
1424
}
1425
return FireMaterialDefines;
1426
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
1427
var FireMaterial = /** @class */ (function (_super) {
1428
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FireMaterial, _super);
1429
function FireMaterial(name, scene) {
1430
var _this = _super.call(this, name, scene) || this;
1431
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
1432
_this.speed = 1.0;
1433
_this._scaledDiffuse = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
1434
_this._lastTime = 0;
1435
return _this;
1436
}
1437
FireMaterial.prototype.needAlphaBlending = function () {
1438
return false;
1439
};
1440
FireMaterial.prototype.needAlphaTesting = function () {
1441
return true;
1442
};
1443
FireMaterial.prototype.getAlphaTestTexture = function () {
1444
return null;
1445
};
1446
// Methods
1447
FireMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
1448
if (this.isFrozen) {
1449
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
1450
return true;
1451
}
1452
}
1453
if (!subMesh._materialDefines) {
1454
subMesh.materialDefines = new FireMaterialDefines();
1455
}
1456
var defines = subMesh._materialDefines;
1457
var scene = this.getScene();
1458
if (this._isReadyForSubMesh(subMesh)) {
1459
return true;
1460
}
1461
var engine = scene.getEngine();
1462
// Textures
1463
if (defines._areTexturesDirty) {
1464
defines._needUVs = false;
1465
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
1466
if (!this._diffuseTexture.isReady()) {
1467
return false;
1468
}
1469
else {
1470
defines._needUVs = true;
1471
defines.DIFFUSE = true;
1472
}
1473
}
1474
}
1475
defines.ALPHATEST = this._opacityTexture ? true : false;
1476
// Misc.
1477
if (defines._areMiscDirty) {
1478
defines.POINTSIZE = (this.pointsCloud || scene.forcePointsCloud);
1479
defines.FOG = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && this.fogEnabled);
1480
}
1481
// Values that need to be evaluated on every frame
1482
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
1483
// Attribs
1484
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true);
1485
// Get correct effect
1486
if (defines.isDirty) {
1487
defines.markAsProcessed();
1488
scene.resetCachedMaterial();
1489
// Fallbacks
1490
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
1491
if (defines.FOG) {
1492
fallbacks.addFallback(1, "FOG");
1493
}
1494
if (defines.NUM_BONE_INFLUENCERS > 0) {
1495
fallbacks.addCPUSkinningFallback(0, mesh);
1496
}
1497
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
1498
//Attributes
1499
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
1500
if (defines.UV1) {
1501
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
1502
}
1503
if (defines.VERTEXCOLOR) {
1504
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
1505
}
1506
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
1507
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
1508
// Legacy browser patch
1509
var shaderName = "fire";
1510
var join = defines.toString();
1511
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
1512
attributes: attribs,
1513
uniformsNames: ["world", "view", "viewProjection", "vEyePosition",
1514
"vFogInfos", "vFogColor", "pointSize",
1515
"vDiffuseInfos",
1516
"mBones",
1517
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
1518
// Fire
1519
"time", "speed"
1520
],
1521
uniformBuffersNames: [],
1522
samplers: ["diffuseSampler",
1523
// Fire
1524
"distortionSampler", "opacitySampler"
1525
],
1526
defines: join,
1527
fallbacks: fallbacks,
1528
onCompiled: this.onCompiled,
1529
onError: this.onError,
1530
indexParameters: null,
1531
maxSimultaneousLights: 4,
1532
transformFeedbackVaryings: null
1533
}, engine), defines, this._materialContext);
1534
}
1535
if (!subMesh.effect || !subMesh.effect.isReady()) {
1536
return false;
1537
}
1538
defines._renderId = scene.getRenderId();
1539
subMesh.effect._wasPreviouslyReady = true;
1540
return true;
1541
};
1542
FireMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
1543
var scene = this.getScene();
1544
var defines = subMesh._materialDefines;
1545
if (!defines) {
1546
return;
1547
}
1548
var effect = subMesh.effect;
1549
if (!effect) {
1550
return;
1551
}
1552
this._activeEffect = effect;
1553
// Matrices
1554
this.bindOnlyWorldMatrix(world);
1555
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
1556
// Bones
1557
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
1558
if (this._mustRebind(scene, effect)) {
1559
// Textures
1560
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
1561
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
1562
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
1563
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
1564
this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
1565
this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
1566
}
1567
// Clip plane
1568
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
1569
// Point size
1570
if (this.pointsCloud) {
1571
this._activeEffect.setFloat("pointSize", this.pointSize);
1572
}
1573
scene.bindEyePosition(effect);
1574
}
1575
this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
1576
// View
1577
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
1578
this._activeEffect.setMatrix("view", scene.getViewMatrix());
1579
}
1580
// Fog
1581
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
1582
// Time
1583
this._lastTime += scene.getEngine().getDeltaTime();
1584
this._activeEffect.setFloat("time", this._lastTime);
1585
// Speed
1586
this._activeEffect.setFloat("speed", this.speed);
1587
this._afterBind(mesh, this._activeEffect);
1588
};
1589
FireMaterial.prototype.getAnimatables = function () {
1590
var results = [];
1591
if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
1592
results.push(this._diffuseTexture);
1593
}
1594
if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
1595
results.push(this._distortionTexture);
1596
}
1597
if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
1598
results.push(this._opacityTexture);
1599
}
1600
return results;
1601
};
1602
FireMaterial.prototype.getActiveTextures = function () {
1603
var activeTextures = _super.prototype.getActiveTextures.call(this);
1604
if (this._diffuseTexture) {
1605
activeTextures.push(this._diffuseTexture);
1606
}
1607
if (this._distortionTexture) {
1608
activeTextures.push(this._distortionTexture);
1609
}
1610
if (this._opacityTexture) {
1611
activeTextures.push(this._opacityTexture);
1612
}
1613
return activeTextures;
1614
};
1615
FireMaterial.prototype.hasTexture = function (texture) {
1616
if (_super.prototype.hasTexture.call(this, texture)) {
1617
return true;
1618
}
1619
if (this._diffuseTexture === texture) {
1620
return true;
1621
}
1622
if (this._distortionTexture === texture) {
1623
return true;
1624
}
1625
if (this._opacityTexture === texture) {
1626
return true;
1627
}
1628
return false;
1629
};
1630
FireMaterial.prototype.getClassName = function () {
1631
return "FireMaterial";
1632
};
1633
FireMaterial.prototype.dispose = function (forceDisposeEffect) {
1634
if (this._diffuseTexture) {
1635
this._diffuseTexture.dispose();
1636
}
1637
if (this._distortionTexture) {
1638
this._distortionTexture.dispose();
1639
}
1640
_super.prototype.dispose.call(this, forceDisposeEffect);
1641
};
1642
FireMaterial.prototype.clone = function (name) {
1643
var _this = this;
1644
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FireMaterial(name, _this.getScene()); }, this);
1645
};
1646
FireMaterial.prototype.serialize = function () {
1647
var serializationObject = _super.prototype.serialize.call(this);
1648
serializationObject.customType = "BABYLON.FireMaterial";
1649
serializationObject.diffuseColor = this.diffuseColor.asArray();
1650
serializationObject.speed = this.speed;
1651
if (this._diffuseTexture) {
1652
serializationObject._diffuseTexture = this._diffuseTexture.serialize();
1653
}
1654
if (this._distortionTexture) {
1655
serializationObject._distortionTexture = this._distortionTexture.serialize();
1656
}
1657
if (this._opacityTexture) {
1658
serializationObject._opacityTexture = this._opacityTexture.serialize();
1659
}
1660
return serializationObject;
1661
};
1662
FireMaterial.Parse = function (source, scene, rootUrl) {
1663
var material = new FireMaterial(source.name, scene);
1664
material.diffuseColor = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(source.diffuseColor);
1665
material.speed = source.speed;
1666
material.alpha = source.alpha;
1667
material.id = source.id;
1668
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tags"].AddTagsTo(material, source.tags);
1669
material.backFaceCulling = source.backFaceCulling;
1670
material.wireframe = source.wireframe;
1671
if (source._diffuseTexture) {
1672
material._diffuseTexture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].Parse(source._diffuseTexture, scene, rootUrl);
1673
}
1674
if (source._distortionTexture) {
1675
material._distortionTexture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].Parse(source._distortionTexture, scene, rootUrl);
1676
}
1677
if (source._opacityTexture) {
1678
material._opacityTexture = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].Parse(source._opacityTexture, scene, rootUrl);
1679
}
1680
return material;
1681
};
1682
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1683
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
1684
], FireMaterial.prototype, "_diffuseTexture", void 0);
1685
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1686
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
1687
], FireMaterial.prototype, "diffuseTexture", void 0);
1688
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1689
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("distortionTexture")
1690
], FireMaterial.prototype, "_distortionTexture", void 0);
1691
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1692
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
1693
], FireMaterial.prototype, "distortionTexture", void 0);
1694
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1695
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
1696
], FireMaterial.prototype, "_opacityTexture", void 0);
1697
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1698
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
1699
], FireMaterial.prototype, "opacityTexture", void 0);
1700
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1701
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
1702
], FireMaterial.prototype, "diffuseColor", void 0);
1703
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
1704
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
1705
], FireMaterial.prototype, "speed", void 0);
1706
return FireMaterial;
1707
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
1708
1709
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.FireMaterial"] = FireMaterial;
1710
1711
1712
/***/ }),
1713
1714
/***/ "./fire/index.ts":
1715
/*!***********************!*\
1716
!*** ./fire/index.ts ***!
1717
\***********************/
1718
/*! exports provided: FireMaterial */
1719
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1720
1721
"use strict";
1722
__webpack_require__.r(__webpack_exports__);
1723
/* harmony import */ var _fireMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fireMaterial */ "./fire/fireMaterial.ts");
1724
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FireMaterial", function() { return _fireMaterial__WEBPACK_IMPORTED_MODULE_0__["FireMaterial"]; });
1725
1726
1727
1728
1729
/***/ }),
1730
1731
/***/ "./fur/fur.fragment.ts":
1732
/*!*****************************!*\
1733
!*** ./fur/fur.fragment.ts ***!
1734
\*****************************/
1735
/*! exports provided: furPixelShader */
1736
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1737
1738
"use strict";
1739
__webpack_require__.r(__webpack_exports__);
1740
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "furPixelShader", function() { return furPixelShader; });
1741
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
1742
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
var name = 'furPixelShader';
1757
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 furColor;\nuniform float furLength;\nvarying vec3 vPositionW;\nvarying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform float furOcclusion;\nuniform sampler2D furTexture;\nvarying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=furColor;\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\n\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));\nif (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {\ndiscard;\n}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);\nbaseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;\nvec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
1758
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
1759
/** @hidden */
1760
var furPixelShader = { name: name, shader: shader };
1761
1762
1763
/***/ }),
1764
1765
/***/ "./fur/fur.vertex.ts":
1766
/*!***************************!*\
1767
!*** ./fur/fur.vertex.ts ***!
1768
\***************************/
1769
/*! exports provided: furVertexShader */
1770
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1771
1772
"use strict";
1773
__webpack_require__.r(__webpack_exports__);
1774
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "furVertexShader", function() { return furVertexShader; });
1775
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
1776
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
var name = 'furVertexShader';
1790
var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\nuniform float furLength;\nuniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform vec3 furGravity;\nuniform float furTime;\nuniform float furSpacing;\nuniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else\nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);\nvec3 tangent2=vec3(-normal.z,0,normal.x);\nr=Rand(tangent1*r);\nfloat J=(2.0+4.0*r);\nr=Rand(tangent2*r);\nfloat K=(2.0+2.0*r);\ntangent1=tangent1*J+tangent2*K;\ntangent1=normalize(tangent1);\nvec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\n\nvec3 forceDirection=vec3(0.0,0.0,0.0);\nforceDirection.x=sin(furTime+position.x*0.05)*0.2;\nforceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;\nforceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;\nvec3 displacement=vec3(0.0,0.0,0.0);\ndisplacement=furGravity+forceDirection;\nfloat displacementFactor=pow(furOffset,3.0);\nvec3 aNormal=normal;\naNormal.xyz+=displacement*displacementFactor;\nnewPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
1791
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
1792
/** @hidden */
1793
var furVertexShader = { name: name, shader: shader };
1794
1795
1796
/***/ }),
1797
1798
/***/ "./fur/furMaterial.ts":
1799
/*!****************************!*\
1800
!*** ./fur/furMaterial.ts ***!
1801
\****************************/
1802
/*! exports provided: FurMaterial */
1803
/***/ (function(module, __webpack_exports__, __webpack_require__) {
1804
1805
"use strict";
1806
__webpack_require__.r(__webpack_exports__);
1807
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FurMaterial", function() { return FurMaterial; });
1808
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
1809
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
1810
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
1811
/* harmony import */ var _fur_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fur.fragment */ "./fur/fur.fragment.ts");
1812
/* harmony import */ var _fur_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fur.vertex */ "./fur/fur.vertex.ts");
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
var FurMaterialDefines = /** @class */ (function (_super) {
1831
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FurMaterialDefines, _super);
1832
function FurMaterialDefines() {
1833
var _this = _super.call(this) || this;
1834
_this.DIFFUSE = false;
1835
_this.HEIGHTMAP = false;
1836
_this.CLIPPLANE = false;
1837
_this.CLIPPLANE2 = false;
1838
_this.CLIPPLANE3 = false;
1839
_this.CLIPPLANE4 = false;
1840
_this.CLIPPLANE5 = false;
1841
_this.CLIPPLANE6 = false;
1842
_this.ALPHATEST = false;
1843
_this.DEPTHPREPASS = false;
1844
_this.POINTSIZE = false;
1845
_this.FOG = false;
1846
_this.NORMAL = false;
1847
_this.UV1 = false;
1848
_this.UV2 = false;
1849
_this.VERTEXCOLOR = false;
1850
_this.VERTEXALPHA = false;
1851
_this.NUM_BONE_INFLUENCERS = 0;
1852
_this.BonesPerMesh = 0;
1853
_this.INSTANCES = false;
1854
_this.HIGHLEVEL = false;
1855
_this.IMAGEPROCESSINGPOSTPROCESS = false;
1856
_this.rebuild();
1857
return _this;
1858
}
1859
return FurMaterialDefines;
1860
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
1861
var FurMaterial = /** @class */ (function (_super) {
1862
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FurMaterial, _super);
1863
function FurMaterial(name, scene) {
1864
var _this = _super.call(this, name, scene) || this;
1865
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
1866
_this.furLength = 1;
1867
_this.furAngle = 0;
1868
_this.furColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.44, 0.21, 0.02);
1869
_this.furOffset = 0.0;
1870
_this.furSpacing = 12;
1871
_this.furGravity = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
1872
_this.furSpeed = 100;
1873
_this.furDensity = 20;
1874
_this.furOcclusion = 0.0;
1875
_this._disableLighting = false;
1876
_this._maxSimultaneousLights = 4;
1877
_this.highLevelFur = true;
1878
_this._furTime = 0;
1879
return _this;
1880
}
1881
Object.defineProperty(FurMaterial.prototype, "furTime", {
1882
get: function () {
1883
return this._furTime;
1884
},
1885
set: function (furTime) {
1886
this._furTime = furTime;
1887
},
1888
enumerable: false,
1889
configurable: true
1890
});
1891
FurMaterial.prototype.needAlphaBlending = function () {
1892
return (this.alpha < 1.0);
1893
};
1894
FurMaterial.prototype.needAlphaTesting = function () {
1895
return false;
1896
};
1897
FurMaterial.prototype.getAlphaTestTexture = function () {
1898
return null;
1899
};
1900
FurMaterial.prototype.updateFur = function () {
1901
for (var i = 1; i < this._meshes.length; i++) {
1902
var offsetFur = this._meshes[i].material;
1903
offsetFur.furLength = this.furLength;
1904
offsetFur.furAngle = this.furAngle;
1905
offsetFur.furGravity = this.furGravity;
1906
offsetFur.furSpacing = this.furSpacing;
1907
offsetFur.furSpeed = this.furSpeed;
1908
offsetFur.furColor = this.furColor;
1909
offsetFur.diffuseTexture = this.diffuseTexture;
1910
offsetFur.furTexture = this.furTexture;
1911
offsetFur.highLevelFur = this.highLevelFur;
1912
offsetFur.furTime = this.furTime;
1913
offsetFur.furDensity = this.furDensity;
1914
}
1915
};
1916
// Methods
1917
FurMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
1918
if (this.isFrozen) {
1919
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
1920
return true;
1921
}
1922
}
1923
if (!subMesh._materialDefines) {
1924
subMesh.materialDefines = new FurMaterialDefines();
1925
}
1926
var defines = subMesh._materialDefines;
1927
var scene = this.getScene();
1928
if (this._isReadyForSubMesh(subMesh)) {
1929
return true;
1930
}
1931
var engine = scene.getEngine();
1932
// Textures
1933
if (defines._areTexturesDirty) {
1934
if (scene.texturesEnabled) {
1935
if (this.diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
1936
if (!this.diffuseTexture.isReady()) {
1937
return false;
1938
}
1939
else {
1940
defines._needUVs = true;
1941
defines.DIFFUSE = true;
1942
}
1943
}
1944
if (this.heightTexture && engine.getCaps().maxVertexTextureImageUnits) {
1945
if (!this.heightTexture.isReady()) {
1946
return false;
1947
}
1948
else {
1949
defines._needUVs = true;
1950
defines.HEIGHTMAP = true;
1951
}
1952
}
1953
}
1954
}
1955
// High level
1956
if (this.highLevelFur !== defines.HIGHLEVEL) {
1957
defines.HIGHLEVEL = true;
1958
defines.markAsUnprocessed();
1959
}
1960
// Misc.
1961
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
1962
// Lights
1963
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
1964
// Values that need to be evaluated on every frame
1965
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
1966
// Attribs
1967
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
1968
// Get correct effect
1969
if (defines.isDirty) {
1970
defines.markAsProcessed();
1971
scene.resetCachedMaterial();
1972
// Fallbacks
1973
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
1974
if (defines.FOG) {
1975
fallbacks.addFallback(1, "FOG");
1976
}
1977
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
1978
if (defines.NUM_BONE_INFLUENCERS > 0) {
1979
fallbacks.addCPUSkinningFallback(0, mesh);
1980
}
1981
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
1982
//Attributes
1983
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
1984
if (defines.NORMAL) {
1985
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
1986
}
1987
if (defines.UV1) {
1988
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
1989
}
1990
if (defines.UV2) {
1991
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
1992
}
1993
if (defines.VERTEXCOLOR) {
1994
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
1995
}
1996
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
1997
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
1998
// Legacy browser patch
1999
var shaderName = "fur";
2000
var join = defines.toString();
2001
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
2002
"vFogInfos", "vFogColor", "pointSize",
2003
"vDiffuseInfos",
2004
"mBones",
2005
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
2006
"furLength", "furAngle", "furColor", "furOffset", "furGravity", "furTime", "furSpacing", "furDensity", "furOcclusion"
2007
];
2008
var samplers = ["diffuseSampler",
2009
"heightTexture", "furTexture"
2010
];
2011
var uniformBuffers = new Array();
2012
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
2013
uniformsNames: uniforms,
2014
uniformBuffersNames: uniformBuffers,
2015
samplers: samplers,
2016
defines: defines,
2017
maxSimultaneousLights: this.maxSimultaneousLights
2018
});
2019
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
2020
attributes: attribs,
2021
uniformsNames: uniforms,
2022
uniformBuffersNames: uniformBuffers,
2023
samplers: samplers,
2024
defines: join,
2025
fallbacks: fallbacks,
2026
onCompiled: this.onCompiled,
2027
onError: this.onError,
2028
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
2029
}, engine), defines, this._materialContext);
2030
}
2031
if (!subMesh.effect || !subMesh.effect.isReady()) {
2032
return false;
2033
}
2034
defines._renderId = scene.getRenderId();
2035
subMesh.effect._wasPreviouslyReady = true;
2036
return true;
2037
};
2038
FurMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
2039
var scene = this.getScene();
2040
var defines = subMesh._materialDefines;
2041
if (!defines) {
2042
return;
2043
}
2044
var effect = subMesh.effect;
2045
if (!effect) {
2046
return;
2047
}
2048
this._activeEffect = effect;
2049
// Matrices
2050
this.bindOnlyWorldMatrix(world);
2051
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
2052
// Bones
2053
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
2054
if (scene.getCachedMaterial() !== this) {
2055
// Textures
2056
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
2057
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
2058
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
2059
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
2060
}
2061
if (this._heightTexture) {
2062
this._activeEffect.setTexture("heightTexture", this._heightTexture);
2063
}
2064
// Clip plane
2065
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
2066
// Point size
2067
if (this.pointsCloud) {
2068
this._activeEffect.setFloat("pointSize", this.pointSize);
2069
}
2070
scene.bindEyePosition(effect);
2071
}
2072
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
2073
if (scene.lightsEnabled && !this.disableLighting) {
2074
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
2075
}
2076
// View
2077
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
2078
this._activeEffect.setMatrix("view", scene.getViewMatrix());
2079
}
2080
// Fog
2081
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
2082
this._activeEffect.setFloat("furLength", this.furLength);
2083
this._activeEffect.setFloat("furAngle", this.furAngle);
2084
this._activeEffect.setColor4("furColor", this.furColor, 1.0);
2085
if (this.highLevelFur) {
2086
this._activeEffect.setVector3("furGravity", this.furGravity);
2087
this._activeEffect.setFloat("furOffset", this.furOffset);
2088
this._activeEffect.setFloat("furSpacing", this.furSpacing);
2089
this._activeEffect.setFloat("furDensity", this.furDensity);
2090
this._activeEffect.setFloat("furOcclusion", this.furOcclusion);
2091
this._furTime += this.getScene().getEngine().getDeltaTime() / this.furSpeed;
2092
this._activeEffect.setFloat("furTime", this._furTime);
2093
this._activeEffect.setTexture("furTexture", this.furTexture);
2094
}
2095
this._afterBind(mesh, this._activeEffect);
2096
};
2097
FurMaterial.prototype.getAnimatables = function () {
2098
var results = [];
2099
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
2100
results.push(this.diffuseTexture);
2101
}
2102
if (this.heightTexture && this.heightTexture.animations && this.heightTexture.animations.length > 0) {
2103
results.push(this.heightTexture);
2104
}
2105
return results;
2106
};
2107
FurMaterial.prototype.getActiveTextures = function () {
2108
var activeTextures = _super.prototype.getActiveTextures.call(this);
2109
if (this._diffuseTexture) {
2110
activeTextures.push(this._diffuseTexture);
2111
}
2112
if (this._heightTexture) {
2113
activeTextures.push(this._heightTexture);
2114
}
2115
return activeTextures;
2116
};
2117
FurMaterial.prototype.hasTexture = function (texture) {
2118
if (_super.prototype.hasTexture.call(this, texture)) {
2119
return true;
2120
}
2121
if (this.diffuseTexture === texture) {
2122
return true;
2123
}
2124
if (this._heightTexture === texture) {
2125
return true;
2126
}
2127
return false;
2128
};
2129
FurMaterial.prototype.dispose = function (forceDisposeEffect) {
2130
if (this.diffuseTexture) {
2131
this.diffuseTexture.dispose();
2132
}
2133
if (this._meshes) {
2134
for (var i = 1; i < this._meshes.length; i++) {
2135
var mat = this._meshes[i].material;
2136
if (mat) {
2137
mat.dispose(forceDisposeEffect);
2138
}
2139
this._meshes[i].dispose();
2140
}
2141
}
2142
_super.prototype.dispose.call(this, forceDisposeEffect);
2143
};
2144
FurMaterial.prototype.clone = function (name) {
2145
var _this = this;
2146
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FurMaterial(name, _this.getScene()); }, this);
2147
};
2148
FurMaterial.prototype.serialize = function () {
2149
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
2150
serializationObject.customType = "BABYLON.FurMaterial";
2151
if (this._meshes) {
2152
serializationObject.sourceMeshName = this._meshes[0].name;
2153
serializationObject.quality = this._meshes.length;
2154
}
2155
return serializationObject;
2156
};
2157
FurMaterial.prototype.getClassName = function () {
2158
return "FurMaterial";
2159
};
2160
// Statics
2161
FurMaterial.Parse = function (source, scene, rootUrl) {
2162
var material = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FurMaterial(source.name, scene); }, source, scene, rootUrl);
2163
if (source.sourceMeshName && material.highLevelFur) {
2164
scene.executeWhenReady(function () {
2165
var sourceMesh = scene.getMeshByName(source.sourceMeshName);
2166
if (sourceMesh) {
2167
var furTexture = FurMaterial.GenerateTexture("Fur Texture", scene);
2168
material.furTexture = furTexture;
2169
FurMaterial.FurifyMesh(sourceMesh, source.quality);
2170
}
2171
});
2172
}
2173
return material;
2174
};
2175
FurMaterial.GenerateTexture = function (name, scene) {
2176
// Generate fur textures
2177
var texture = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]("FurTexture " + name, 256, scene, true);
2178
var context = texture.getContext();
2179
for (var i = 0; i < 20000; ++i) {
2180
context.fillStyle = "rgba(255, " + Math.floor(Math.random() * 255) + ", " + Math.floor(Math.random() * 255) + ", 1)";
2181
context.fillRect((Math.random() * texture.getSize().width), (Math.random() * texture.getSize().height), 2, 2);
2182
}
2183
texture.update(false);
2184
texture.wrapU = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
2185
texture.wrapV = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
2186
return texture;
2187
};
2188
// Creates and returns an array of meshes used as shells for the Fur Material
2189
// that can be disposed later in your code
2190
// The quality is in interval [0, 100]
2191
FurMaterial.FurifyMesh = function (sourceMesh, quality) {
2192
var meshes = [sourceMesh];
2193
var mat = sourceMesh.material;
2194
var i;
2195
if (!(mat instanceof FurMaterial)) {
2196
throw "The material of the source mesh must be a Fur Material";
2197
}
2198
for (i = 1; i < quality; i++) {
2199
var offsetFur = new FurMaterial(mat.name + i, sourceMesh.getScene());
2200
sourceMesh.getScene().materials.pop();
2201
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tags"].EnableFor(offsetFur);
2202
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Tags"].AddTagsTo(offsetFur, "furShellMaterial");
2203
offsetFur.furLength = mat.furLength;
2204
offsetFur.furAngle = mat.furAngle;
2205
offsetFur.furGravity = mat.furGravity;
2206
offsetFur.furSpacing = mat.furSpacing;
2207
offsetFur.furSpeed = mat.furSpeed;
2208
offsetFur.furColor = mat.furColor;
2209
offsetFur.diffuseTexture = mat.diffuseTexture;
2210
offsetFur.furOffset = i / quality;
2211
offsetFur.furTexture = mat.furTexture;
2212
offsetFur.highLevelFur = mat.highLevelFur;
2213
offsetFur.furTime = mat.furTime;
2214
offsetFur.furDensity = mat.furDensity;
2215
var offsetMesh = sourceMesh.clone(sourceMesh.name + i);
2216
offsetMesh.material = offsetFur;
2217
offsetMesh.skeleton = sourceMesh.skeleton;
2218
offsetMesh.position = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
2219
meshes.push(offsetMesh);
2220
}
2221
for (i = 1; i < meshes.length; i++) {
2222
meshes[i].parent = sourceMesh;
2223
}
2224
sourceMesh.material._meshes = meshes;
2225
return meshes;
2226
};
2227
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2228
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
2229
], FurMaterial.prototype, "_diffuseTexture", void 0);
2230
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2231
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
2232
], FurMaterial.prototype, "diffuseTexture", void 0);
2233
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2234
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("heightTexture")
2235
], FurMaterial.prototype, "_heightTexture", void 0);
2236
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2237
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
2238
], FurMaterial.prototype, "heightTexture", void 0);
2239
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2240
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2241
], FurMaterial.prototype, "diffuseColor", void 0);
2242
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2243
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2244
], FurMaterial.prototype, "furLength", void 0);
2245
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2246
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2247
], FurMaterial.prototype, "furAngle", void 0);
2248
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2249
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2250
], FurMaterial.prototype, "furColor", void 0);
2251
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2252
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2253
], FurMaterial.prototype, "furOffset", void 0);
2254
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2255
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2256
], FurMaterial.prototype, "furSpacing", void 0);
2257
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2258
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
2259
], FurMaterial.prototype, "furGravity", void 0);
2260
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2261
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2262
], FurMaterial.prototype, "furSpeed", void 0);
2263
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2264
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2265
], FurMaterial.prototype, "furDensity", void 0);
2266
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2267
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2268
], FurMaterial.prototype, "furOcclusion", void 0);
2269
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2270
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
2271
], FurMaterial.prototype, "_disableLighting", void 0);
2272
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2273
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
2274
], FurMaterial.prototype, "disableLighting", void 0);
2275
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2276
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
2277
], FurMaterial.prototype, "_maxSimultaneousLights", void 0);
2278
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2279
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
2280
], FurMaterial.prototype, "maxSimultaneousLights", void 0);
2281
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2282
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2283
], FurMaterial.prototype, "highLevelFur", void 0);
2284
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2285
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2286
], FurMaterial.prototype, "furTime", null);
2287
return FurMaterial;
2288
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
2289
2290
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.FurMaterial"] = FurMaterial;
2291
2292
2293
/***/ }),
2294
2295
/***/ "./fur/index.ts":
2296
/*!**********************!*\
2297
!*** ./fur/index.ts ***!
2298
\**********************/
2299
/*! exports provided: FurMaterial */
2300
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2301
2302
"use strict";
2303
__webpack_require__.r(__webpack_exports__);
2304
/* harmony import */ var _furMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./furMaterial */ "./fur/furMaterial.ts");
2305
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FurMaterial", function() { return _furMaterial__WEBPACK_IMPORTED_MODULE_0__["FurMaterial"]; });
2306
2307
2308
2309
2310
/***/ }),
2311
2312
/***/ "./gradient/gradient.fragment.ts":
2313
/*!***************************************!*\
2314
!*** ./gradient/gradient.fragment.ts ***!
2315
\***************************************/
2316
/*! exports provided: gradientPixelShader */
2317
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2318
2319
"use strict";
2320
__webpack_require__.r(__webpack_exports__);
2321
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gradientPixelShader", function() { return gradientPixelShader; });
2322
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
2323
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
var name = 'gradientPixelShader';
2338
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\n\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float scale;\nuniform float smoothness;\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nfloat h=vPosition.y*scale+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\n\nvec3 diffuseColor=baseColor.rgb;\n\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\n#ifdef EMISSIVE\nvec3 diffuseBase=baseColor.rgb;\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);\n#endif\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";
2339
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
2340
/** @hidden */
2341
var gradientPixelShader = { name: name, shader: shader };
2342
2343
2344
/***/ }),
2345
2346
/***/ "./gradient/gradient.vertex.ts":
2347
/*!*************************************!*\
2348
!*** ./gradient/gradient.vertex.ts ***!
2349
\*************************************/
2350
/*! exports provided: gradientVertexShader */
2351
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2352
2353
"use strict";
2354
__webpack_require__.r(__webpack_exports__);
2355
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gradientVertexShader", function() { return gradientVertexShader; });
2356
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
2357
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
var name = 'gradientVertexShader';
2371
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\nvPosition=position;\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
2372
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
2373
/** @hidden */
2374
var gradientVertexShader = { name: name, shader: shader };
2375
2376
2377
/***/ }),
2378
2379
/***/ "./gradient/gradientMaterial.ts":
2380
/*!**************************************!*\
2381
!*** ./gradient/gradientMaterial.ts ***!
2382
\**************************************/
2383
/*! exports provided: GradientMaterial */
2384
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2385
2386
"use strict";
2387
__webpack_require__.r(__webpack_exports__);
2388
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GradientMaterial", function() { return GradientMaterial; });
2389
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
2390
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
2391
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
2392
/* harmony import */ var _gradient_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gradient.fragment */ "./gradient/gradient.fragment.ts");
2393
/* harmony import */ var _gradient_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gradient.vertex */ "./gradient/gradient.vertex.ts");
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
var GradientMaterialDefines = /** @class */ (function (_super) {
2407
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GradientMaterialDefines, _super);
2408
function GradientMaterialDefines() {
2409
var _this = _super.call(this) || this;
2410
_this.EMISSIVE = false;
2411
_this.CLIPPLANE = false;
2412
_this.CLIPPLANE2 = false;
2413
_this.CLIPPLANE3 = false;
2414
_this.CLIPPLANE4 = false;
2415
_this.CLIPPLANE5 = false;
2416
_this.CLIPPLANE6 = false;
2417
_this.ALPHATEST = false;
2418
_this.DEPTHPREPASS = false;
2419
_this.POINTSIZE = false;
2420
_this.FOG = false;
2421
_this.NORMAL = false;
2422
_this.UV1 = false;
2423
_this.UV2 = false;
2424
_this.VERTEXCOLOR = false;
2425
_this.VERTEXALPHA = false;
2426
_this.NUM_BONE_INFLUENCERS = 0;
2427
_this.BonesPerMesh = 0;
2428
_this.INSTANCES = false;
2429
_this.IMAGEPROCESSINGPOSTPROCESS = false;
2430
_this.rebuild();
2431
return _this;
2432
}
2433
return GradientMaterialDefines;
2434
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
2435
var GradientMaterial = /** @class */ (function (_super) {
2436
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GradientMaterial, _super);
2437
function GradientMaterial(name, scene) {
2438
var _this = _super.call(this, name, scene) || this;
2439
_this._maxSimultaneousLights = 4;
2440
// The gradient top color, red by default
2441
_this.topColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 0, 0);
2442
_this.topColorAlpha = 1.0;
2443
// The gradient top color, blue by default
2444
_this.bottomColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0, 0, 1);
2445
_this.bottomColorAlpha = 1.0;
2446
// Gradient offset
2447
_this.offset = 0;
2448
_this.scale = 1.0;
2449
_this.smoothness = 1.0;
2450
_this._disableLighting = false;
2451
return _this;
2452
}
2453
GradientMaterial.prototype.needAlphaBlending = function () {
2454
return (this.alpha < 1.0 || this.topColorAlpha < 1.0 || this.bottomColorAlpha < 1.0);
2455
};
2456
GradientMaterial.prototype.needAlphaTesting = function () {
2457
return true;
2458
};
2459
GradientMaterial.prototype.getAlphaTestTexture = function () {
2460
return null;
2461
};
2462
// Methods
2463
GradientMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
2464
if (this.isFrozen) {
2465
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
2466
return true;
2467
}
2468
}
2469
if (!subMesh._materialDefines) {
2470
subMesh.materialDefines = new GradientMaterialDefines();
2471
}
2472
var defines = subMesh._materialDefines;
2473
var scene = this.getScene();
2474
if (this._isReadyForSubMesh(subMesh)) {
2475
return true;
2476
}
2477
var engine = scene.getEngine();
2478
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
2479
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
2480
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
2481
defines.EMISSIVE = this._disableLighting;
2482
// Attribs
2483
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true);
2484
// Get correct effect
2485
if (defines.isDirty) {
2486
defines.markAsProcessed();
2487
scene.resetCachedMaterial();
2488
// Fallbacks
2489
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
2490
if (defines.FOG) {
2491
fallbacks.addFallback(1, "FOG");
2492
}
2493
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks);
2494
if (defines.NUM_BONE_INFLUENCERS > 0) {
2495
fallbacks.addCPUSkinningFallback(0, mesh);
2496
}
2497
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
2498
//Attributes
2499
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
2500
if (defines.NORMAL) {
2501
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
2502
}
2503
if (defines.UV1) {
2504
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
2505
}
2506
if (defines.UV2) {
2507
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
2508
}
2509
if (defines.VERTEXCOLOR) {
2510
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
2511
}
2512
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
2513
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
2514
// Legacy browser patch
2515
var shaderName = "gradient";
2516
var join = defines.toString();
2517
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
2518
"vFogInfos", "vFogColor", "pointSize",
2519
"mBones",
2520
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
2521
"topColor", "bottomColor", "offset", "smoothness", "scale"
2522
];
2523
var samplers = [];
2524
var uniformBuffers = new Array();
2525
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
2526
uniformsNames: uniforms,
2527
uniformBuffersNames: uniformBuffers,
2528
samplers: samplers,
2529
defines: defines,
2530
maxSimultaneousLights: 4
2531
});
2532
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
2533
attributes: attribs,
2534
uniformsNames: uniforms,
2535
uniformBuffersNames: uniformBuffers,
2536
samplers: samplers,
2537
defines: join,
2538
fallbacks: fallbacks,
2539
onCompiled: this.onCompiled,
2540
onError: this.onError,
2541
indexParameters: { maxSimultaneousLights: 4 }
2542
}, engine), defines, this._materialContext);
2543
}
2544
if (!subMesh.effect || !subMesh.effect.isReady()) {
2545
return false;
2546
}
2547
defines._renderId = scene.getRenderId();
2548
subMesh.effect._wasPreviouslyReady = true;
2549
return true;
2550
};
2551
GradientMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
2552
var scene = this.getScene();
2553
var defines = subMesh._materialDefines;
2554
if (!defines) {
2555
return;
2556
}
2557
var effect = subMesh.effect;
2558
if (!effect) {
2559
return;
2560
}
2561
this._activeEffect = effect;
2562
// Matrices
2563
this.bindOnlyWorldMatrix(world);
2564
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
2565
// Bones
2566
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, effect);
2567
if (this._mustRebind(scene, effect)) {
2568
// Clip plane
2569
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(effect, scene);
2570
// Point size
2571
if (this.pointsCloud) {
2572
this._activeEffect.setFloat("pointSize", this.pointSize);
2573
}
2574
scene.bindEyePosition(effect);
2575
}
2576
if (scene.lightsEnabled && !this.disableLighting) {
2577
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
2578
}
2579
// View
2580
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
2581
this._activeEffect.setMatrix("view", scene.getViewMatrix());
2582
}
2583
// Fog
2584
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
2585
this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
2586
this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
2587
this._activeEffect.setFloat("offset", this.offset);
2588
this._activeEffect.setFloat("scale", this.scale);
2589
this._activeEffect.setFloat("smoothness", this.smoothness);
2590
this._afterBind(mesh, this._activeEffect);
2591
};
2592
GradientMaterial.prototype.getAnimatables = function () {
2593
return [];
2594
};
2595
GradientMaterial.prototype.dispose = function (forceDisposeEffect) {
2596
_super.prototype.dispose.call(this, forceDisposeEffect);
2597
};
2598
GradientMaterial.prototype.clone = function (name) {
2599
var _this = this;
2600
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new GradientMaterial(name, _this.getScene()); }, this);
2601
};
2602
GradientMaterial.prototype.serialize = function () {
2603
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
2604
serializationObject.customType = "BABYLON.GradientMaterial";
2605
return serializationObject;
2606
};
2607
GradientMaterial.prototype.getClassName = function () {
2608
return "GradientMaterial";
2609
};
2610
// Statics
2611
GradientMaterial.Parse = function (source, scene, rootUrl) {
2612
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GradientMaterial(source.name, scene); }, source, scene, rootUrl);
2613
};
2614
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2615
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
2616
], GradientMaterial.prototype, "_maxSimultaneousLights", void 0);
2617
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2618
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
2619
], GradientMaterial.prototype, "maxSimultaneousLights", void 0);
2620
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2621
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2622
], GradientMaterial.prototype, "topColor", void 0);
2623
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2624
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2625
], GradientMaterial.prototype, "topColorAlpha", void 0);
2626
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2627
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2628
], GradientMaterial.prototype, "bottomColor", void 0);
2629
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2630
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2631
], GradientMaterial.prototype, "bottomColorAlpha", void 0);
2632
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2633
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2634
], GradientMaterial.prototype, "offset", void 0);
2635
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2636
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2637
], GradientMaterial.prototype, "scale", void 0);
2638
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2639
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2640
], GradientMaterial.prototype, "smoothness", void 0);
2641
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2642
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
2643
], GradientMaterial.prototype, "_disableLighting", void 0);
2644
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2645
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
2646
], GradientMaterial.prototype, "disableLighting", void 0);
2647
return GradientMaterial;
2648
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
2649
2650
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GradientMaterial"] = GradientMaterial;
2651
2652
2653
/***/ }),
2654
2655
/***/ "./gradient/index.ts":
2656
/*!***************************!*\
2657
!*** ./gradient/index.ts ***!
2658
\***************************/
2659
/*! exports provided: GradientMaterial */
2660
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2661
2662
"use strict";
2663
__webpack_require__.r(__webpack_exports__);
2664
/* harmony import */ var _gradientMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gradientMaterial */ "./gradient/gradientMaterial.ts");
2665
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientMaterial", function() { return _gradientMaterial__WEBPACK_IMPORTED_MODULE_0__["GradientMaterial"]; });
2666
2667
2668
2669
2670
/***/ }),
2671
2672
/***/ "./grid/grid.fragment.ts":
2673
/*!*******************************!*\
2674
!*** ./grid/grid.fragment.ts ***!
2675
\*******************************/
2676
/*! exports provided: gridPixelShader */
2677
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2678
2679
"use strict";
2680
__webpack_require__.r(__webpack_exports__);
2681
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gridPixelShader", function() { return gridPixelShader; });
2682
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
2683
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
2684
2685
2686
2687
2688
var name = 'gridPixelShader';
2689
var shader = "#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform float visibility;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\n\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\n\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {\n\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n}\nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5);\nfractionPartOfPosition/=differentialLength;\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI);\nreturn result;\n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2;\n\nfloat result=isPointOnLine(position,differentialLength);\n\nfloat dynamicVisibility=getDynamicVisibility(position);\nresult*=dynamicVisibility;\n\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\nvoid main(void) {\n\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\n\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\n\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n\nfloat grid=clamp(x+y+z,0.,1.);\n\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif\n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif\n\ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n#endif\n#include<imageProcessingCompatibility>\n}";
2690
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
2691
/** @hidden */
2692
var gridPixelShader = { name: name, shader: shader };
2693
2694
2695
/***/ }),
2696
2697
/***/ "./grid/grid.vertex.ts":
2698
/*!*****************************!*\
2699
!*** ./grid/grid.vertex.ts ***!
2700
\*****************************/
2701
/*! exports provided: gridVertexShader */
2702
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2703
2704
"use strict";
2705
__webpack_require__.r(__webpack_exports__);
2706
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gridVertexShader", function() { return gridVertexShader; });
2707
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
2708
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
2709
2710
2711
2712
2713
2714
var name = 'gridVertexShader';
2715
var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#include<instancesDeclaration>\n\nuniform mat4 projection;\nuniform mat4 view;\n\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\nvoid main(void) {\n#include<instancesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<fogVertex>\nvec4 cameraSpacePosition=view*worldPos;\ngl_Position=projection*cameraSpacePosition;\n#ifdef OPACITY\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\nvPosition=position;\nvNormal=normal;\n}";
2716
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
2717
/** @hidden */
2718
var gridVertexShader = { name: name, shader: shader };
2719
2720
2721
/***/ }),
2722
2723
/***/ "./grid/gridMaterial.ts":
2724
/*!******************************!*\
2725
!*** ./grid/gridMaterial.ts ***!
2726
\******************************/
2727
/*! exports provided: GridMaterial */
2728
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2729
2730
"use strict";
2731
__webpack_require__.r(__webpack_exports__);
2732
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GridMaterial", function() { return GridMaterial; });
2733
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
2734
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
2735
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
2736
/* harmony import */ var _grid_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./grid.fragment */ "./grid/grid.fragment.ts");
2737
/* harmony import */ var _grid_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./grid.vertex */ "./grid/grid.vertex.ts");
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
var GridMaterialDefines = /** @class */ (function (_super) {
2751
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GridMaterialDefines, _super);
2752
function GridMaterialDefines() {
2753
var _this = _super.call(this) || this;
2754
_this.OPACITY = false;
2755
_this.TRANSPARENT = false;
2756
_this.FOG = false;
2757
_this.PREMULTIPLYALPHA = false;
2758
_this.UV1 = false;
2759
_this.UV2 = false;
2760
_this.INSTANCES = false;
2761
_this.THIN_INSTANCES = false;
2762
_this.IMAGEPROCESSINGPOSTPROCESS = false;
2763
_this.rebuild();
2764
return _this;
2765
}
2766
return GridMaterialDefines;
2767
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
2768
/**
2769
* The grid materials allows you to wrap any shape with a grid.
2770
* Colors are customizable.
2771
*/
2772
var GridMaterial = /** @class */ (function (_super) {
2773
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GridMaterial, _super);
2774
/**
2775
* constructor
2776
* @param name The name given to the material in order to identify it afterwards.
2777
* @param scene The scene the material is used in.
2778
*/
2779
function GridMaterial(name, scene) {
2780
var _this = _super.call(this, name, scene) || this;
2781
/**
2782
* Main color of the grid (e.g. between lines)
2783
*/
2784
_this.mainColor = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
2785
/**
2786
* Color of the grid lines.
2787
*/
2788
_this.lineColor = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"].Teal();
2789
/**
2790
* The scale of the grid compared to unit.
2791
*/
2792
_this.gridRatio = 1.0;
2793
/**
2794
* Allows setting an offset for the grid lines.
2795
*/
2796
_this.gridOffset = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
2797
/**
2798
* The frequency of thicker lines.
2799
*/
2800
_this.majorUnitFrequency = 10;
2801
/**
2802
* The visibility of minor units in the grid.
2803
*/
2804
_this.minorUnitVisibility = 0.33;
2805
/**
2806
* The grid opacity outside of the lines.
2807
*/
2808
_this.opacity = 1.0;
2809
/**
2810
* Determine RBG output is premultiplied by alpha value.
2811
*/
2812
_this.preMultiplyAlpha = false;
2813
_this._gridControl = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector4"](_this.gridRatio, _this.majorUnitFrequency, _this.minorUnitVisibility, _this.opacity);
2814
return _this;
2815
}
2816
/**
2817
* Returns wehter or not the grid requires alpha blending.
2818
*/
2819
GridMaterial.prototype.needAlphaBlending = function () {
2820
return this.opacity < 1.0 || this._opacityTexture && this._opacityTexture.isReady();
2821
};
2822
GridMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
2823
return mesh.visibility < 1.0 || this.needAlphaBlending();
2824
};
2825
GridMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
2826
if (this.isFrozen) {
2827
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
2828
return true;
2829
}
2830
}
2831
if (!subMesh._materialDefines) {
2832
subMesh.materialDefines = new GridMaterialDefines();
2833
}
2834
var defines = subMesh._materialDefines;
2835
var scene = this.getScene();
2836
if (this._isReadyForSubMesh(subMesh)) {
2837
return true;
2838
}
2839
if (defines.TRANSPARENT !== (this.opacity < 1.0)) {
2840
defines.TRANSPARENT = !defines.TRANSPARENT;
2841
defines.markAsUnprocessed();
2842
}
2843
if (defines.PREMULTIPLYALPHA != this.preMultiplyAlpha) {
2844
defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
2845
defines.markAsUnprocessed();
2846
}
2847
// Textures
2848
if (defines._areTexturesDirty) {
2849
defines._needUVs = false;
2850
if (scene.texturesEnabled) {
2851
if (this._opacityTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].OpacityTextureEnabled) {
2852
if (!this._opacityTexture.isReady()) {
2853
return false;
2854
}
2855
else {
2856
defines._needUVs = true;
2857
defines.OPACITY = true;
2858
}
2859
}
2860
}
2861
}
2862
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
2863
// Values that need to be evaluated on every frame
2864
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, scene.getEngine(), defines, !!useInstances);
2865
// Get correct effect
2866
if (defines.isDirty) {
2867
defines.markAsProcessed();
2868
scene.resetCachedMaterial();
2869
// Attributes
2870
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, false);
2871
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
2872
if (defines.UV1) {
2873
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
2874
}
2875
if (defines.UV2) {
2876
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
2877
}
2878
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
2879
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
2880
// Defines
2881
var join = defines.toString();
2882
subMesh.setEffect(scene.getEngine().createEffect("grid", attribs, ["projection", "mainColor", "lineColor", "gridControl", "gridOffset", "vFogInfos", "vFogColor", "world", "view",
2883
"opacityMatrix", "vOpacityInfos", "visibility"], ["opacitySampler"], join, undefined, this.onCompiled, this.onError), defines, this._materialContext);
2884
}
2885
if (!subMesh.effect || !subMesh.effect.isReady()) {
2886
return false;
2887
}
2888
defines._renderId = scene.getRenderId();
2889
subMesh.effect._wasPreviouslyReady = true;
2890
return true;
2891
};
2892
GridMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
2893
var scene = this.getScene();
2894
var defines = subMesh._materialDefines;
2895
if (!defines) {
2896
return;
2897
}
2898
var effect = subMesh.effect;
2899
if (!effect) {
2900
return;
2901
}
2902
this._activeEffect = effect;
2903
this._activeEffect.setFloat("visibility", mesh.visibility);
2904
// Matrices
2905
if (!defines.INSTANCES || defines.THIN_INSTANCE) {
2906
this.bindOnlyWorldMatrix(world);
2907
}
2908
this._activeEffect.setMatrix("view", scene.getViewMatrix());
2909
this._activeEffect.setMatrix("projection", scene.getProjectionMatrix());
2910
// Uniforms
2911
if (this._mustRebind(scene, effect)) {
2912
this._activeEffect.setColor3("mainColor", this.mainColor);
2913
this._activeEffect.setColor3("lineColor", this.lineColor);
2914
this._activeEffect.setVector3("gridOffset", this.gridOffset);
2915
this._gridControl.x = this.gridRatio;
2916
this._gridControl.y = Math.round(this.majorUnitFrequency);
2917
this._gridControl.z = this.minorUnitVisibility;
2918
this._gridControl.w = this.opacity;
2919
this._activeEffect.setVector4("gridControl", this._gridControl);
2920
if (this._opacityTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].OpacityTextureEnabled) {
2921
this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
2922
this._activeEffect.setFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
2923
this._activeEffect.setMatrix("opacityMatrix", this._opacityTexture.getTextureMatrix());
2924
}
2925
}
2926
// Fog
2927
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
2928
this._afterBind(mesh, this._activeEffect);
2929
};
2930
/**
2931
* Dispose the material and its associated resources.
2932
* @param forceDisposeEffect will also dispose the used effect when true
2933
*/
2934
GridMaterial.prototype.dispose = function (forceDisposeEffect) {
2935
_super.prototype.dispose.call(this, forceDisposeEffect);
2936
};
2937
GridMaterial.prototype.clone = function (name) {
2938
var _this = this;
2939
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new GridMaterial(name, _this.getScene()); }, this);
2940
};
2941
GridMaterial.prototype.serialize = function () {
2942
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
2943
serializationObject.customType = "BABYLON.GridMaterial";
2944
return serializationObject;
2945
};
2946
GridMaterial.prototype.getClassName = function () {
2947
return "GridMaterial";
2948
};
2949
GridMaterial.Parse = function (source, scene, rootUrl) {
2950
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GridMaterial(source.name, scene); }, source, scene, rootUrl);
2951
};
2952
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2953
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2954
], GridMaterial.prototype, "mainColor", void 0);
2955
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2956
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
2957
], GridMaterial.prototype, "lineColor", void 0);
2958
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2959
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2960
], GridMaterial.prototype, "gridRatio", void 0);
2961
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2962
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
2963
], GridMaterial.prototype, "gridOffset", void 0);
2964
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2965
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2966
], GridMaterial.prototype, "majorUnitFrequency", void 0);
2967
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2968
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2969
], GridMaterial.prototype, "minorUnitVisibility", void 0);
2970
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2971
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2972
], GridMaterial.prototype, "opacity", void 0);
2973
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2974
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
2975
], GridMaterial.prototype, "preMultiplyAlpha", void 0);
2976
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2977
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
2978
], GridMaterial.prototype, "_opacityTexture", void 0);
2979
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
2980
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
2981
], GridMaterial.prototype, "opacityTexture", void 0);
2982
return GridMaterial;
2983
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
2984
2985
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GridMaterial"] = GridMaterial;
2986
2987
2988
/***/ }),
2989
2990
/***/ "./grid/index.ts":
2991
/*!***********************!*\
2992
!*** ./grid/index.ts ***!
2993
\***********************/
2994
/*! exports provided: GridMaterial */
2995
/***/ (function(module, __webpack_exports__, __webpack_require__) {
2996
2997
"use strict";
2998
__webpack_require__.r(__webpack_exports__);
2999
/* harmony import */ var _gridMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gridMaterial */ "./grid/gridMaterial.ts");
3000
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GridMaterial", function() { return _gridMaterial__WEBPACK_IMPORTED_MODULE_0__["GridMaterial"]; });
3001
3002
3003
3004
3005
/***/ }),
3006
3007
/***/ "./index.ts":
3008
/*!******************!*\
3009
!*** ./index.ts ***!
3010
\******************/
3011
/*! exports provided: CellMaterial, CustomShaderStructure, ShaderSpecialParts, CustomMaterial, ShaderAlebdoParts, PBRCustomMaterial, FireMaterial, FurMaterial, GradientMaterial, GridMaterial, LavaMaterial, MixMaterial, NormalMaterial, ShadowOnlyMaterial, SimpleMaterial, SkyMaterial, TerrainMaterial, TriPlanarMaterial, WaterMaterial */
3012
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3013
3014
"use strict";
3015
__webpack_require__.r(__webpack_exports__);
3016
/* harmony import */ var _cell__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cell */ "./cell/index.ts");
3017
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CellMaterial", function() { return _cell__WEBPACK_IMPORTED_MODULE_0__["CellMaterial"]; });
3018
3019
/* harmony import */ var _custom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./custom */ "./custom/index.ts");
3020
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return _custom__WEBPACK_IMPORTED_MODULE_1__["CustomShaderStructure"]; });
3021
3022
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return _custom__WEBPACK_IMPORTED_MODULE_1__["ShaderSpecialParts"]; });
3023
3024
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return _custom__WEBPACK_IMPORTED_MODULE_1__["CustomMaterial"]; });
3025
3026
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return _custom__WEBPACK_IMPORTED_MODULE_1__["ShaderAlebdoParts"]; });
3027
3028
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return _custom__WEBPACK_IMPORTED_MODULE_1__["PBRCustomMaterial"]; });
3029
3030
/* harmony import */ var _fire__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fire */ "./fire/index.ts");
3031
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FireMaterial", function() { return _fire__WEBPACK_IMPORTED_MODULE_2__["FireMaterial"]; });
3032
3033
/* harmony import */ var _fur__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fur */ "./fur/index.ts");
3034
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FurMaterial", function() { return _fur__WEBPACK_IMPORTED_MODULE_3__["FurMaterial"]; });
3035
3036
/* harmony import */ var _gradient__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gradient */ "./gradient/index.ts");
3037
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientMaterial", function() { return _gradient__WEBPACK_IMPORTED_MODULE_4__["GradientMaterial"]; });
3038
3039
/* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./grid */ "./grid/index.ts");
3040
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GridMaterial", function() { return _grid__WEBPACK_IMPORTED_MODULE_5__["GridMaterial"]; });
3041
3042
/* harmony import */ var _lava__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./lava */ "./lava/index.ts");
3043
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LavaMaterial", function() { return _lava__WEBPACK_IMPORTED_MODULE_6__["LavaMaterial"]; });
3044
3045
/* harmony import */ var _mix__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./mix */ "./mix/index.ts");
3046
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return _mix__WEBPACK_IMPORTED_MODULE_7__["MixMaterial"]; });
3047
3048
/* harmony import */ var _normal__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./normal */ "./normal/index.ts");
3049
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NormalMaterial", function() { return _normal__WEBPACK_IMPORTED_MODULE_8__["NormalMaterial"]; });
3050
3051
/* harmony import */ var _shadowOnly__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shadowOnly */ "./shadowOnly/index.ts");
3052
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowOnlyMaterial", function() { return _shadowOnly__WEBPACK_IMPORTED_MODULE_9__["ShadowOnlyMaterial"]; });
3053
3054
/* harmony import */ var _simple__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./simple */ "./simple/index.ts");
3055
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimpleMaterial", function() { return _simple__WEBPACK_IMPORTED_MODULE_10__["SimpleMaterial"]; });
3056
3057
/* harmony import */ var _sky__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./sky */ "./sky/index.ts");
3058
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkyMaterial", function() { return _sky__WEBPACK_IMPORTED_MODULE_11__["SkyMaterial"]; });
3059
3060
/* harmony import */ var _terrain__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./terrain */ "./terrain/index.ts");
3061
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TerrainMaterial", function() { return _terrain__WEBPACK_IMPORTED_MODULE_12__["TerrainMaterial"]; });
3062
3063
/* harmony import */ var _triPlanar__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./triPlanar */ "./triPlanar/index.ts");
3064
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TriPlanarMaterial", function() { return _triPlanar__WEBPACK_IMPORTED_MODULE_13__["TriPlanarMaterial"]; });
3065
3066
/* harmony import */ var _water__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./water */ "./water/index.ts");
3067
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WaterMaterial", function() { return _water__WEBPACK_IMPORTED_MODULE_14__["WaterMaterial"]; });
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
/***/ }),
3087
3088
/***/ "./lava/index.ts":
3089
/*!***********************!*\
3090
!*** ./lava/index.ts ***!
3091
\***********************/
3092
/*! exports provided: LavaMaterial */
3093
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3094
3095
"use strict";
3096
__webpack_require__.r(__webpack_exports__);
3097
/* harmony import */ var _lavaMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lavaMaterial */ "./lava/lavaMaterial.ts");
3098
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LavaMaterial", function() { return _lavaMaterial__WEBPACK_IMPORTED_MODULE_0__["LavaMaterial"]; });
3099
3100
3101
3102
3103
/***/ }),
3104
3105
/***/ "./lava/lava.fragment.ts":
3106
/*!*******************************!*\
3107
!*** ./lava/lava.fragment.ts ***!
3108
\*******************************/
3109
/*! exports provided: lavaPixelShader */
3110
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3111
3112
"use strict";
3113
__webpack_require__.r(__webpack_exports__);
3114
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lavaPixelShader", function() { return lavaPixelShader; });
3115
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
3116
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
var name = 'lavaPixelShader';
3131
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n\nuniform float time;\nuniform float speed;\nuniform float movingSpeed;\nuniform vec3 fogColor;\nuniform sampler2D noiseTexture;\nuniform float fogDensity;\n\nvarying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\n}\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\n\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\nT1.x+=noiseTex.x*2.0;\nT1.y+=noiseTex.y*2.0;\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\nbaseColor=temp;\nfloat depth=gl_FragCoord.z*4.0;\nconst float LOG2=1.442695;\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\ndiffuseColor=baseColor.rgb;\n\n\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
3132
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
3133
/** @hidden */
3134
var lavaPixelShader = { name: name, shader: shader };
3135
3136
3137
/***/ }),
3138
3139
/***/ "./lava/lava.vertex.ts":
3140
/*!*****************************!*\
3141
!*** ./lava/lava.vertex.ts ***!
3142
\*****************************/
3143
/*! exports provided: lavaVertexShader */
3144
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3145
3146
"use strict";
3147
__webpack_require__.r(__webpack_exports__);
3148
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lavaVertexShader", function() { return lavaVertexShader; });
3149
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
3150
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
var name = 'lavaVertexShader';
3164
var shader = "precision highp float;\n\nuniform float time;\nuniform float lowFrequencySpeed;\n\nvarying float noise;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n\n\nvec3 mod289(vec3 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 mod289(vec4 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 permute(vec4 x)\n{\nreturn mod289(((x*34.0)+1.0)*x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\nreturn 1.79284291400159-0.85373472095314*r;\n}\nvec3 fade(vec3 t) {\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat pnoise(vec3 P,vec3 rep)\n{\nvec3 Pi0=mod(floor(P),rep);\nvec3 Pi1=mod(Pi0+vec3(1.0),rep);\nPi0=mod289(Pi0);\nPi1=mod289(Pi1);\nvec3 Pf0=fract(P);\nvec3 Pf1=Pf0-vec3(1.0);\nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\nvec4 iz0=Pi0.zzzz;\nvec4 iz1=Pi1.zzzz;\nvec4 ixy=permute(permute(ix)+iy);\nvec4 ixy0=permute(ixy+iz0);\nvec4 ixy1=permute(ixy+iz1);\nvec4 gx0=ixy0*(1.0/7.0);\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\ngx0=fract(gx0);\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\nvec4 sz0=step(gz0,vec4(0.0));\ngx0-=sz0*(step(0.0,gx0)-0.5);\ngy0-=sz0*(step(0.0,gy0)-0.5);\nvec4 gx1=ixy1*(1.0/7.0);\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\ngx1=fract(gx1);\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\nvec4 sz1=step(gz1,vec4(0.0));\ngx1-=sz1*(step(0.0,gx1)-0.5);\ngy1-=sz1*(step(0.0,gy1)-0.5);\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\ng000*=norm0.x;\ng010*=norm0.y;\ng100*=norm0.z;\ng110*=norm0.w;\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\ng001*=norm1.x;\ng011*=norm1.y;\ng101*=norm1.z;\ng111*=norm1.w;\nfloat n000=dot(g000,Pf0);\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\nfloat n111=dot(g111,Pf1);\nvec3 fade_xyz=fade(Pf0);\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\nreturn 2.2*n_xyz;\n}\n\nfloat turbulence( vec3 p ) {\nfloat w=100.0;\nfloat t=-.5;\nfor (float f=1.0 ; f<=10.0 ; f++ ){\nfloat power=pow( 2.0,f );\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\n}\nreturn t;\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef NORMAL\n\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\n\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\n\nfloat displacement =-1.5*noise+b;\n\nvec3 newPosition=position+normal*displacement;\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}";
3165
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
3166
/** @hidden */
3167
var lavaVertexShader = { name: name, shader: shader };
3168
3169
3170
/***/ }),
3171
3172
/***/ "./lava/lavaMaterial.ts":
3173
/*!******************************!*\
3174
!*** ./lava/lavaMaterial.ts ***!
3175
\******************************/
3176
/*! exports provided: LavaMaterial */
3177
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3178
3179
"use strict";
3180
__webpack_require__.r(__webpack_exports__);
3181
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LavaMaterial", function() { return LavaMaterial; });
3182
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
3183
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
3184
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
3185
/* harmony import */ var _lava_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lava.fragment */ "./lava/lava.fragment.ts");
3186
/* harmony import */ var _lava_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lava.vertex */ "./lava/lava.vertex.ts");
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
var LavaMaterialDefines = /** @class */ (function (_super) {
3201
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LavaMaterialDefines, _super);
3202
function LavaMaterialDefines() {
3203
var _this = _super.call(this) || this;
3204
_this.DIFFUSE = false;
3205
_this.CLIPPLANE = false;
3206
_this.CLIPPLANE2 = false;
3207
_this.CLIPPLANE3 = false;
3208
_this.CLIPPLANE4 = false;
3209
_this.CLIPPLANE5 = false;
3210
_this.CLIPPLANE6 = false;
3211
_this.ALPHATEST = false;
3212
_this.DEPTHPREPASS = false;
3213
_this.POINTSIZE = false;
3214
_this.FOG = false;
3215
_this.LIGHT0 = false;
3216
_this.LIGHT1 = false;
3217
_this.LIGHT2 = false;
3218
_this.LIGHT3 = false;
3219
_this.SPOTLIGHT0 = false;
3220
_this.SPOTLIGHT1 = false;
3221
_this.SPOTLIGHT2 = false;
3222
_this.SPOTLIGHT3 = false;
3223
_this.HEMILIGHT0 = false;
3224
_this.HEMILIGHT1 = false;
3225
_this.HEMILIGHT2 = false;
3226
_this.HEMILIGHT3 = false;
3227
_this.DIRLIGHT0 = false;
3228
_this.DIRLIGHT1 = false;
3229
_this.DIRLIGHT2 = false;
3230
_this.DIRLIGHT3 = false;
3231
_this.POINTLIGHT0 = false;
3232
_this.POINTLIGHT1 = false;
3233
_this.POINTLIGHT2 = false;
3234
_this.POINTLIGHT3 = false;
3235
_this.SHADOW0 = false;
3236
_this.SHADOW1 = false;
3237
_this.SHADOW2 = false;
3238
_this.SHADOW3 = false;
3239
_this.SHADOWS = false;
3240
_this.SHADOWESM0 = false;
3241
_this.SHADOWESM1 = false;
3242
_this.SHADOWESM2 = false;
3243
_this.SHADOWESM3 = false;
3244
_this.SHADOWPOISSON0 = false;
3245
_this.SHADOWPOISSON1 = false;
3246
_this.SHADOWPOISSON2 = false;
3247
_this.SHADOWPOISSON3 = false;
3248
_this.SHADOWPCF0 = false;
3249
_this.SHADOWPCF1 = false;
3250
_this.SHADOWPCF2 = false;
3251
_this.SHADOWPCF3 = false;
3252
_this.SHADOWPCSS0 = false;
3253
_this.SHADOWPCSS1 = false;
3254
_this.SHADOWPCSS2 = false;
3255
_this.SHADOWPCSS3 = false;
3256
_this.NORMAL = false;
3257
_this.UV1 = false;
3258
_this.UV2 = false;
3259
_this.VERTEXCOLOR = false;
3260
_this.VERTEXALPHA = false;
3261
_this.NUM_BONE_INFLUENCERS = 0;
3262
_this.BonesPerMesh = 0;
3263
_this.INSTANCES = false;
3264
_this.UNLIT = false;
3265
_this.IMAGEPROCESSINGPOSTPROCESS = false;
3266
_this.rebuild();
3267
return _this;
3268
}
3269
return LavaMaterialDefines;
3270
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
3271
var LavaMaterial = /** @class */ (function (_super) {
3272
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LavaMaterial, _super);
3273
function LavaMaterial(name, scene) {
3274
var _this = _super.call(this, name, scene) || this;
3275
_this.speed = 1;
3276
_this.movingSpeed = 1;
3277
_this.lowFrequencySpeed = 1;
3278
_this.fogDensity = 0.15;
3279
_this._lastTime = 0;
3280
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
3281
_this._disableLighting = false;
3282
_this._unlit = false;
3283
_this._maxSimultaneousLights = 4;
3284
_this._scaledDiffuse = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
3285
return _this;
3286
}
3287
LavaMaterial.prototype.needAlphaBlending = function () {
3288
return (this.alpha < 1.0);
3289
};
3290
LavaMaterial.prototype.needAlphaTesting = function () {
3291
return false;
3292
};
3293
LavaMaterial.prototype.getAlphaTestTexture = function () {
3294
return null;
3295
};
3296
// Methods
3297
LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
3298
if (this.isFrozen) {
3299
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
3300
return true;
3301
}
3302
}
3303
if (!subMesh._materialDefines) {
3304
subMesh.materialDefines = new LavaMaterialDefines();
3305
}
3306
var defines = subMesh._materialDefines;
3307
var scene = this.getScene();
3308
if (this._isReadyForSubMesh(subMesh)) {
3309
return true;
3310
}
3311
var engine = scene.getEngine();
3312
// Textures
3313
if (defines._areTexturesDirty) {
3314
defines._needUVs = false;
3315
if (scene.texturesEnabled) {
3316
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
3317
if (!this._diffuseTexture.isReady()) {
3318
return false;
3319
}
3320
else {
3321
defines._needUVs = true;
3322
defines.DIFFUSE = true;
3323
}
3324
}
3325
}
3326
}
3327
// Misc.
3328
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
3329
// Lights
3330
defines._needNormals = true;
3331
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
3332
// Values that need to be evaluated on every frame
3333
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
3334
// Attribs
3335
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
3336
// Get correct effect
3337
if (defines.isDirty) {
3338
defines.markAsProcessed();
3339
scene.resetCachedMaterial();
3340
// Fallbacks
3341
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
3342
if (defines.FOG) {
3343
fallbacks.addFallback(1, "FOG");
3344
}
3345
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks);
3346
if (defines.NUM_BONE_INFLUENCERS > 0) {
3347
fallbacks.addCPUSkinningFallback(0, mesh);
3348
}
3349
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
3350
//Attributes
3351
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
3352
if (defines.NORMAL) {
3353
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
3354
}
3355
if (defines.UV1) {
3356
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
3357
}
3358
if (defines.UV2) {
3359
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
3360
}
3361
if (defines.VERTEXCOLOR) {
3362
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
3363
}
3364
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
3365
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
3366
// Legacy browser patch
3367
var shaderName = "lava";
3368
var join = defines.toString();
3369
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
3370
"vFogInfos", "vFogColor", "pointSize",
3371
"vDiffuseInfos",
3372
"mBones",
3373
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
3374
"time", "speed", "movingSpeed",
3375
"fogColor", "fogDensity", "lowFrequencySpeed"
3376
];
3377
var samplers = ["diffuseSampler",
3378
"noiseTexture"
3379
];
3380
var uniformBuffers = new Array();
3381
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
3382
uniformsNames: uniforms,
3383
uniformBuffersNames: uniformBuffers,
3384
samplers: samplers,
3385
defines: defines,
3386
maxSimultaneousLights: this.maxSimultaneousLights
3387
});
3388
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
3389
attributes: attribs,
3390
uniformsNames: uniforms,
3391
uniformBuffersNames: uniformBuffers,
3392
samplers: samplers,
3393
defines: join,
3394
fallbacks: fallbacks,
3395
onCompiled: this.onCompiled,
3396
onError: this.onError,
3397
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
3398
}, engine), defines, this._materialContext);
3399
}
3400
if (!subMesh.effect || !subMesh.effect.isReady()) {
3401
return false;
3402
}
3403
defines._renderId = scene.getRenderId();
3404
subMesh.effect._wasPreviouslyReady = true;
3405
return true;
3406
};
3407
LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
3408
var scene = this.getScene();
3409
var defines = subMesh._materialDefines;
3410
if (!defines) {
3411
return;
3412
}
3413
var effect = subMesh.effect;
3414
if (!effect) {
3415
return;
3416
}
3417
this._activeEffect = effect;
3418
defines.UNLIT = this._unlit;
3419
// Matrices
3420
this.bindOnlyWorldMatrix(world);
3421
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
3422
// Bones
3423
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
3424
if (this._mustRebind(scene, effect)) {
3425
// Textures
3426
if (this.diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
3427
this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
3428
this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
3429
this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
3430
}
3431
if (this.noiseTexture) {
3432
this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
3433
}
3434
// Clip plane
3435
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
3436
// Point size
3437
if (this.pointsCloud) {
3438
this._activeEffect.setFloat("pointSize", this.pointSize);
3439
}
3440
scene.bindEyePosition(effect);
3441
}
3442
this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
3443
if (scene.lightsEnabled && !this.disableLighting) {
3444
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines);
3445
}
3446
// View
3447
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
3448
this._activeEffect.setMatrix("view", scene.getViewMatrix());
3449
}
3450
// Fog
3451
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
3452
this._lastTime += scene.getEngine().getDeltaTime();
3453
this._activeEffect.setFloat("time", this._lastTime * this.speed / 1000);
3454
if (!this.fogColor) {
3455
this.fogColor = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
3456
}
3457
this._activeEffect.setColor3("fogColor", this.fogColor);
3458
this._activeEffect.setFloat("fogDensity", this.fogDensity);
3459
this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
3460
this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
3461
this._afterBind(mesh, this._activeEffect);
3462
};
3463
LavaMaterial.prototype.getAnimatables = function () {
3464
var results = [];
3465
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
3466
results.push(this.diffuseTexture);
3467
}
3468
if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
3469
results.push(this.noiseTexture);
3470
}
3471
return results;
3472
};
3473
LavaMaterial.prototype.getActiveTextures = function () {
3474
var activeTextures = _super.prototype.getActiveTextures.call(this);
3475
if (this._diffuseTexture) {
3476
activeTextures.push(this._diffuseTexture);
3477
}
3478
return activeTextures;
3479
};
3480
LavaMaterial.prototype.hasTexture = function (texture) {
3481
if (_super.prototype.hasTexture.call(this, texture)) {
3482
return true;
3483
}
3484
if (this.diffuseTexture === texture) {
3485
return true;
3486
}
3487
return false;
3488
};
3489
LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
3490
if (this.diffuseTexture) {
3491
this.diffuseTexture.dispose();
3492
}
3493
if (this.noiseTexture) {
3494
this.noiseTexture.dispose();
3495
}
3496
_super.prototype.dispose.call(this, forceDisposeEffect);
3497
};
3498
LavaMaterial.prototype.clone = function (name) {
3499
var _this = this;
3500
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
3501
};
3502
LavaMaterial.prototype.serialize = function () {
3503
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
3504
serializationObject.customType = "BABYLON.LavaMaterial";
3505
return serializationObject;
3506
};
3507
LavaMaterial.prototype.getClassName = function () {
3508
return "LavaMaterial";
3509
};
3510
// Statics
3511
LavaMaterial.Parse = function (source, scene, rootUrl) {
3512
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
3513
};
3514
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3515
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
3516
], LavaMaterial.prototype, "_diffuseTexture", void 0);
3517
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3518
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
3519
], LavaMaterial.prototype, "diffuseTexture", void 0);
3520
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3521
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
3522
], LavaMaterial.prototype, "noiseTexture", void 0);
3523
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3524
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
3525
], LavaMaterial.prototype, "fogColor", void 0);
3526
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3527
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
3528
], LavaMaterial.prototype, "speed", void 0);
3529
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3530
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
3531
], LavaMaterial.prototype, "movingSpeed", void 0);
3532
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3533
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
3534
], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
3535
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3536
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
3537
], LavaMaterial.prototype, "fogDensity", void 0);
3538
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3539
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
3540
], LavaMaterial.prototype, "diffuseColor", void 0);
3541
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3542
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
3543
], LavaMaterial.prototype, "_disableLighting", void 0);
3544
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3545
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
3546
], LavaMaterial.prototype, "disableLighting", void 0);
3547
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3548
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("unlit")
3549
], LavaMaterial.prototype, "_unlit", void 0);
3550
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3551
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
3552
], LavaMaterial.prototype, "unlit", void 0);
3553
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3554
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
3555
], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
3556
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
3557
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
3558
], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
3559
return LavaMaterial;
3560
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
3561
3562
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.LavaMaterial"] = LavaMaterial;
3563
3564
3565
/***/ }),
3566
3567
/***/ "./legacy/legacy.ts":
3568
/*!**************************!*\
3569
!*** ./legacy/legacy.ts ***!
3570
\**************************/
3571
/*! exports provided: CellMaterial, CustomShaderStructure, ShaderSpecialParts, CustomMaterial, ShaderAlebdoParts, PBRCustomMaterial, FireMaterial, FurMaterial, GradientMaterial, GridMaterial, LavaMaterial, MixMaterial, NormalMaterial, ShadowOnlyMaterial, SimpleMaterial, SkyMaterial, TerrainMaterial, TriPlanarMaterial, WaterMaterial */
3572
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3573
3574
"use strict";
3575
__webpack_require__.r(__webpack_exports__);
3576
/* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
3577
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CellMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CellMaterial"]; });
3578
3579
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomShaderStructure"]; });
3580
3581
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderSpecialParts"]; });
3582
3583
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomMaterial"]; });
3584
3585
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderAlebdoParts"]; });
3586
3587
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRCustomMaterial"]; });
3588
3589
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FireMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FireMaterial"]; });
3590
3591
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FurMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FurMaterial"]; });
3592
3593
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GradientMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GradientMaterial"]; });
3594
3595
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GridMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GridMaterial"]; });
3596
3597
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LavaMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LavaMaterial"]; });
3598
3599
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MixMaterial"]; });
3600
3601
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NormalMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NormalMaterial"]; });
3602
3603
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowOnlyMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowOnlyMaterial"]; });
3604
3605
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimpleMaterial"]; });
3606
3607
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkyMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkyMaterial"]; });
3608
3609
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TerrainMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TerrainMaterial"]; });
3610
3611
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TriPlanarMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TriPlanarMaterial"]; });
3612
3613
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WaterMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WaterMaterial"]; });
3614
3615
3616
/**
3617
* Legacy support, defining window.BABYLON.GridMaterial... (global variable).
3618
*
3619
* This is the entry point for the UMD module.
3620
* The entry point for a future ESM package should be index.ts
3621
*/
3622
var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
3623
if (typeof globalObject !== "undefined") {
3624
globalObject.BABYLON = globalObject.BABYLON || {};
3625
for (var mat in _index__WEBPACK_IMPORTED_MODULE_0__) {
3626
globalObject.BABYLON[mat] = _index__WEBPACK_IMPORTED_MODULE_0__[mat];
3627
}
3628
}
3629
3630
3631
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
3632
3633
/***/ }),
3634
3635
/***/ "./mix/index.ts":
3636
/*!**********************!*\
3637
!*** ./mix/index.ts ***!
3638
\**********************/
3639
/*! exports provided: MixMaterial */
3640
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3641
3642
"use strict";
3643
__webpack_require__.r(__webpack_exports__);
3644
/* harmony import */ var _mixMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mixMaterial */ "./mix/mixMaterial.ts");
3645
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return _mixMaterial__WEBPACK_IMPORTED_MODULE_0__["MixMaterial"]; });
3646
3647
3648
3649
3650
/***/ }),
3651
3652
/***/ "./mix/mix.fragment.ts":
3653
/*!*****************************!*\
3654
!*** ./mix/mix.fragment.ts ***!
3655
\*****************************/
3656
/*! exports provided: mixPixelShader */
3657
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3658
3659
"use strict";
3660
__webpack_require__.r(__webpack_exports__);
3661
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixPixelShader", function() { return mixPixelShader; });
3662
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
3663
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
var name = 'mixPixelShader';
3678
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D mixMap1Sampler;\nuniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform sampler2D diffuse4Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\nuniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;\nuniform sampler2D diffuse6Sampler;\nuniform sampler2D diffuse7Sampler;\nuniform sampler2D diffuse8Sampler;\nuniform vec2 diffuse5Infos;\nuniform vec2 diffuse6Infos;\nuniform vec2 diffuse7Infos;\nuniform vec2 diffuse8Infos;\n#endif\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\ndiffuse1Color.rgb*=mixColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";
3679
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
3680
/** @hidden */
3681
var mixPixelShader = { name: name, shader: shader };
3682
3683
3684
/***/ }),
3685
3686
/***/ "./mix/mix.vertex.ts":
3687
/*!***************************!*\
3688
!*** ./mix/mix.vertex.ts ***!
3689
\***************************/
3690
/*! exports provided: mixVertexShader */
3691
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3692
3693
"use strict";
3694
__webpack_require__.r(__webpack_exports__);
3695
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mixVertexShader", function() { return mixVertexShader; });
3696
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
3697
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
var name = 'mixVertexShader';
3711
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
3712
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
3713
/** @hidden */
3714
var mixVertexShader = { name: name, shader: shader };
3715
3716
3717
/***/ }),
3718
3719
/***/ "./mix/mixMaterial.ts":
3720
/*!****************************!*\
3721
!*** ./mix/mixMaterial.ts ***!
3722
\****************************/
3723
/*! exports provided: MixMaterial */
3724
/***/ (function(module, __webpack_exports__, __webpack_require__) {
3725
3726
"use strict";
3727
__webpack_require__.r(__webpack_exports__);
3728
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MixMaterial", function() { return MixMaterial; });
3729
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
3730
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
3731
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
3732
/* harmony import */ var _mix_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./mix.fragment */ "./mix/mix.fragment.ts");
3733
/* harmony import */ var _mix_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mix.vertex */ "./mix/mix.vertex.ts");
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
var MixMaterialDefines = /** @class */ (function (_super) {
3748
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MixMaterialDefines, _super);
3749
function MixMaterialDefines() {
3750
var _this = _super.call(this) || this;
3751
_this.DIFFUSE = false;
3752
_this.CLIPPLANE = false;
3753
_this.CLIPPLANE2 = false;
3754
_this.CLIPPLANE3 = false;
3755
_this.CLIPPLANE4 = false;
3756
_this.CLIPPLANE5 = false;
3757
_this.CLIPPLANE6 = false;
3758
_this.ALPHATEST = false;
3759
_this.DEPTHPREPASS = false;
3760
_this.POINTSIZE = false;
3761
_this.FOG = false;
3762
_this.SPECULARTERM = false;
3763
_this.NORMAL = false;
3764
_this.UV1 = false;
3765
_this.UV2 = false;
3766
_this.VERTEXCOLOR = false;
3767
_this.VERTEXALPHA = false;
3768
_this.NUM_BONE_INFLUENCERS = 0;
3769
_this.BonesPerMesh = 0;
3770
_this.INSTANCES = false;
3771
_this.MIXMAP2 = false;
3772
_this.IMAGEPROCESSINGPOSTPROCESS = false;
3773
_this.rebuild();
3774
return _this;
3775
}
3776
return MixMaterialDefines;
3777
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
3778
var MixMaterial = /** @class */ (function (_super) {
3779
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MixMaterial, _super);
3780
function MixMaterial(name, scene) {
3781
var _this = _super.call(this, name, scene) || this;
3782
/**
3783
* Uniforms
3784
*/
3785
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
3786
_this.specularColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0, 0, 0);
3787
_this.specularPower = 64;
3788
_this._disableLighting = false;
3789
_this._maxSimultaneousLights = 4;
3790
return _this;
3791
}
3792
MixMaterial.prototype.needAlphaBlending = function () {
3793
return (this.alpha < 1.0);
3794
};
3795
MixMaterial.prototype.needAlphaTesting = function () {
3796
return false;
3797
};
3798
MixMaterial.prototype.getAlphaTestTexture = function () {
3799
return null;
3800
};
3801
// Methods
3802
MixMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
3803
if (this.isFrozen) {
3804
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
3805
return true;
3806
}
3807
}
3808
if (!subMesh._materialDefines) {
3809
subMesh.materialDefines = new MixMaterialDefines();
3810
}
3811
var defines = subMesh._materialDefines;
3812
var scene = this.getScene();
3813
if (this._isReadyForSubMesh(subMesh)) {
3814
return true;
3815
}
3816
var engine = scene.getEngine();
3817
// Textures
3818
if (scene.texturesEnabled) {
3819
if (!this._mixTexture1 || !this._mixTexture1.isReady()) {
3820
return false;
3821
}
3822
defines._needUVs = true;
3823
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
3824
if (!this._diffuseTexture1 || !this._diffuseTexture1.isReady()) {
3825
return false;
3826
}
3827
defines.DIFFUSE = true;
3828
if (!this._diffuseTexture2 || !this._diffuseTexture2.isReady()) {
3829
return false;
3830
}
3831
if (!this._diffuseTexture3 || !this._diffuseTexture3.isReady()) {
3832
return false;
3833
}
3834
if (!this._diffuseTexture4 || !this._diffuseTexture4.isReady()) {
3835
return false;
3836
}
3837
if (this._mixTexture2) {
3838
if (!this._mixTexture2.isReady()) {
3839
return false;
3840
}
3841
defines.MIXMAP2 = true;
3842
if (!this._diffuseTexture5 || !this._diffuseTexture5.isReady()) {
3843
return false;
3844
}
3845
if (!this._diffuseTexture6 || !this._diffuseTexture6.isReady()) {
3846
return false;
3847
}
3848
if (!this._diffuseTexture7 || !this._diffuseTexture7.isReady()) {
3849
return false;
3850
}
3851
if (!this._diffuseTexture8 || !this._diffuseTexture8.isReady()) {
3852
return false;
3853
}
3854
}
3855
}
3856
}
3857
// Misc.
3858
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
3859
// Lights
3860
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
3861
// Values that need to be evaluated on every frame
3862
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
3863
// Attribs
3864
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
3865
// Get correct effect
3866
if (defines.isDirty) {
3867
defines.markAsProcessed();
3868
scene.resetCachedMaterial();
3869
// Fallbacks
3870
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
3871
if (defines.FOG) {
3872
fallbacks.addFallback(1, "FOG");
3873
}
3874
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
3875
if (defines.NUM_BONE_INFLUENCERS > 0) {
3876
fallbacks.addCPUSkinningFallback(0, mesh);
3877
}
3878
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
3879
//Attributes
3880
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
3881
if (defines.NORMAL) {
3882
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
3883
}
3884
if (defines.UV1) {
3885
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
3886
}
3887
if (defines.UV2) {
3888
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
3889
}
3890
if (defines.VERTEXCOLOR) {
3891
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
3892
}
3893
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
3894
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
3895
// Legacy browser patch
3896
var shaderName = "mix";
3897
var join = defines.toString();
3898
var uniforms = [
3899
"world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
3900
"vFogInfos", "vFogColor", "pointSize",
3901
"vTextureInfos",
3902
"mBones",
3903
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMatrix",
3904
"diffuse1Infos", "diffuse2Infos", "diffuse3Infos", "diffuse4Infos",
3905
"diffuse5Infos", "diffuse6Infos", "diffuse7Infos", "diffuse8Infos"
3906
];
3907
var samplers = [
3908
"mixMap1Sampler", "mixMap2Sampler",
3909
"diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "diffuse4Sampler",
3910
"diffuse5Sampler", "diffuse6Sampler", "diffuse7Sampler", "diffuse8Sampler"
3911
];
3912
var uniformBuffers = new Array();
3913
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
3914
uniformsNames: uniforms,
3915
uniformBuffersNames: uniformBuffers,
3916
samplers: samplers,
3917
defines: defines,
3918
maxSimultaneousLights: this.maxSimultaneousLights
3919
});
3920
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
3921
attributes: attribs,
3922
uniformsNames: uniforms,
3923
uniformBuffersNames: uniformBuffers,
3924
samplers: samplers,
3925
defines: join,
3926
fallbacks: fallbacks,
3927
onCompiled: this.onCompiled,
3928
onError: this.onError,
3929
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
3930
}, engine), defines, this._materialContext);
3931
}
3932
if (!subMesh.effect || !subMesh.effect.isReady()) {
3933
return false;
3934
}
3935
defines._renderId = scene.getRenderId();
3936
subMesh.effect._wasPreviouslyReady = true;
3937
return true;
3938
};
3939
MixMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
3940
var scene = this.getScene();
3941
var defines = subMesh._materialDefines;
3942
if (!defines) {
3943
return;
3944
}
3945
var effect = subMesh.effect;
3946
if (!effect) {
3947
return;
3948
}
3949
this._activeEffect = effect;
3950
// Matrices
3951
this.bindOnlyWorldMatrix(world);
3952
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
3953
// Bones
3954
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
3955
if (this._mustRebind(scene, effect)) {
3956
// Textures
3957
if (this._mixTexture1) {
3958
this._activeEffect.setTexture("mixMap1Sampler", this._mixTexture1);
3959
this._activeEffect.setFloat2("vTextureInfos", this._mixTexture1.coordinatesIndex, this._mixTexture1.level);
3960
this._activeEffect.setMatrix("textureMatrix", this._mixTexture1.getTextureMatrix());
3961
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
3962
if (this._diffuseTexture1) {
3963
this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
3964
this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
3965
}
3966
if (this._diffuseTexture2) {
3967
this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
3968
this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
3969
}
3970
if (this._diffuseTexture3) {
3971
this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
3972
this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
3973
}
3974
if (this._diffuseTexture4) {
3975
this._activeEffect.setTexture("diffuse4Sampler", this._diffuseTexture4);
3976
this._activeEffect.setFloat2("diffuse4Infos", this._diffuseTexture4.uScale, this._diffuseTexture4.vScale);
3977
}
3978
}
3979
}
3980
if (this._mixTexture2) {
3981
this._activeEffect.setTexture("mixMap2Sampler", this._mixTexture2);
3982
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
3983
if (this._diffuseTexture5) {
3984
this._activeEffect.setTexture("diffuse5Sampler", this._diffuseTexture5);
3985
this._activeEffect.setFloat2("diffuse5Infos", this._diffuseTexture5.uScale, this._diffuseTexture5.vScale);
3986
}
3987
if (this._diffuseTexture6) {
3988
this._activeEffect.setTexture("diffuse6Sampler", this._diffuseTexture6);
3989
this._activeEffect.setFloat2("diffuse6Infos", this._diffuseTexture6.uScale, this._diffuseTexture6.vScale);
3990
}
3991
if (this._diffuseTexture7) {
3992
this._activeEffect.setTexture("diffuse7Sampler", this._diffuseTexture7);
3993
this._activeEffect.setFloat2("diffuse7Infos", this._diffuseTexture7.uScale, this._diffuseTexture7.vScale);
3994
}
3995
if (this._diffuseTexture8) {
3996
this._activeEffect.setTexture("diffuse8Sampler", this._diffuseTexture8);
3997
this._activeEffect.setFloat2("diffuse8Infos", this._diffuseTexture8.uScale, this._diffuseTexture8.vScale);
3998
}
3999
}
4000
}
4001
// Clip plane
4002
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
4003
// Point size
4004
if (this.pointsCloud) {
4005
this._activeEffect.setFloat("pointSize", this.pointSize);
4006
}
4007
scene.bindEyePosition(effect);
4008
}
4009
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
4010
if (defines.SPECULARTERM) {
4011
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
4012
}
4013
if (scene.lightsEnabled && !this.disableLighting) {
4014
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
4015
}
4016
// View
4017
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
4018
this._activeEffect.setMatrix("view", scene.getViewMatrix());
4019
}
4020
// Fog
4021
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
4022
this._afterBind(mesh, this._activeEffect);
4023
};
4024
MixMaterial.prototype.getAnimatables = function () {
4025
var results = [];
4026
if (this._mixTexture1 && this._mixTexture1.animations && this._mixTexture1.animations.length > 0) {
4027
results.push(this._mixTexture1);
4028
}
4029
if (this._mixTexture2 && this._mixTexture2.animations && this._mixTexture2.animations.length > 0) {
4030
results.push(this._mixTexture2);
4031
}
4032
return results;
4033
};
4034
MixMaterial.prototype.getActiveTextures = function () {
4035
var activeTextures = _super.prototype.getActiveTextures.call(this);
4036
// Mix map 1
4037
if (this._mixTexture1) {
4038
activeTextures.push(this._mixTexture1);
4039
}
4040
if (this._diffuseTexture1) {
4041
activeTextures.push(this._diffuseTexture1);
4042
}
4043
if (this._diffuseTexture2) {
4044
activeTextures.push(this._diffuseTexture2);
4045
}
4046
if (this._diffuseTexture3) {
4047
activeTextures.push(this._diffuseTexture3);
4048
}
4049
if (this._diffuseTexture4) {
4050
activeTextures.push(this._diffuseTexture4);
4051
}
4052
// Mix map 2
4053
if (this._mixTexture2) {
4054
activeTextures.push(this._mixTexture2);
4055
}
4056
if (this._diffuseTexture5) {
4057
activeTextures.push(this._diffuseTexture5);
4058
}
4059
if (this._diffuseTexture6) {
4060
activeTextures.push(this._diffuseTexture6);
4061
}
4062
if (this._diffuseTexture7) {
4063
activeTextures.push(this._diffuseTexture7);
4064
}
4065
if (this._diffuseTexture8) {
4066
activeTextures.push(this._diffuseTexture8);
4067
}
4068
return activeTextures;
4069
};
4070
MixMaterial.prototype.hasTexture = function (texture) {
4071
if (_super.prototype.hasTexture.call(this, texture)) {
4072
return true;
4073
}
4074
// Mix map 1
4075
if (this._mixTexture1 === texture) {
4076
return true;
4077
}
4078
if (this._diffuseTexture1 === texture) {
4079
return true;
4080
}
4081
if (this._diffuseTexture2 === texture) {
4082
return true;
4083
}
4084
if (this._diffuseTexture3 === texture) {
4085
return true;
4086
}
4087
if (this._diffuseTexture4 === texture) {
4088
return true;
4089
}
4090
// Mix map 2
4091
if (this._mixTexture2 === texture) {
4092
return true;
4093
}
4094
if (this._diffuseTexture5 === texture) {
4095
return true;
4096
}
4097
if (this._diffuseTexture6 === texture) {
4098
return true;
4099
}
4100
if (this._diffuseTexture7 === texture) {
4101
return true;
4102
}
4103
if (this._diffuseTexture8 === texture) {
4104
return true;
4105
}
4106
return false;
4107
};
4108
MixMaterial.prototype.dispose = function (forceDisposeEffect) {
4109
if (this._mixTexture1) {
4110
this._mixTexture1.dispose();
4111
}
4112
_super.prototype.dispose.call(this, forceDisposeEffect);
4113
};
4114
MixMaterial.prototype.clone = function (name) {
4115
var _this = this;
4116
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new MixMaterial(name, _this.getScene()); }, this);
4117
};
4118
MixMaterial.prototype.serialize = function () {
4119
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
4120
serializationObject.customType = "BABYLON.MixMaterial";
4121
return serializationObject;
4122
};
4123
MixMaterial.prototype.getClassName = function () {
4124
return "MixMaterial";
4125
};
4126
// Statics
4127
MixMaterial.Parse = function (source, scene, rootUrl) {
4128
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new MixMaterial(source.name, scene); }, source, scene, rootUrl);
4129
};
4130
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4131
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("mixTexture1")
4132
], MixMaterial.prototype, "_mixTexture1", void 0);
4133
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4134
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4135
], MixMaterial.prototype, "mixTexture1", void 0);
4136
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4137
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("mixTexture2")
4138
], MixMaterial.prototype, "_mixTexture2", void 0);
4139
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4140
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4141
], MixMaterial.prototype, "mixTexture2", void 0);
4142
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4143
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture1")
4144
], MixMaterial.prototype, "_diffuseTexture1", void 0);
4145
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4146
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4147
], MixMaterial.prototype, "diffuseTexture1", void 0);
4148
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4149
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture2")
4150
], MixMaterial.prototype, "_diffuseTexture2", void 0);
4151
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4152
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4153
], MixMaterial.prototype, "diffuseTexture2", void 0);
4154
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4155
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture3")
4156
], MixMaterial.prototype, "_diffuseTexture3", void 0);
4157
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4158
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4159
], MixMaterial.prototype, "diffuseTexture3", void 0);
4160
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4161
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture4")
4162
], MixMaterial.prototype, "_diffuseTexture4", void 0);
4163
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4164
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4165
], MixMaterial.prototype, "diffuseTexture4", void 0);
4166
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4167
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture1")
4168
], MixMaterial.prototype, "_diffuseTexture5", void 0);
4169
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4170
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4171
], MixMaterial.prototype, "diffuseTexture5", void 0);
4172
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4173
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture2")
4174
], MixMaterial.prototype, "_diffuseTexture6", void 0);
4175
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4176
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4177
], MixMaterial.prototype, "diffuseTexture6", void 0);
4178
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4179
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture3")
4180
], MixMaterial.prototype, "_diffuseTexture7", void 0);
4181
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4182
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4183
], MixMaterial.prototype, "diffuseTexture7", void 0);
4184
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4185
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture4")
4186
], MixMaterial.prototype, "_diffuseTexture8", void 0);
4187
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4188
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4189
], MixMaterial.prototype, "diffuseTexture8", void 0);
4190
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4191
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
4192
], MixMaterial.prototype, "diffuseColor", void 0);
4193
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4194
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
4195
], MixMaterial.prototype, "specularColor", void 0);
4196
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4197
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
4198
], MixMaterial.prototype, "specularPower", void 0);
4199
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4200
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
4201
], MixMaterial.prototype, "_disableLighting", void 0);
4202
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4203
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
4204
], MixMaterial.prototype, "disableLighting", void 0);
4205
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4206
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
4207
], MixMaterial.prototype, "_maxSimultaneousLights", void 0);
4208
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4209
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
4210
], MixMaterial.prototype, "maxSimultaneousLights", void 0);
4211
return MixMaterial;
4212
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
4213
4214
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.MixMaterial"] = MixMaterial;
4215
4216
4217
/***/ }),
4218
4219
/***/ "./normal/index.ts":
4220
/*!*************************!*\
4221
!*** ./normal/index.ts ***!
4222
\*************************/
4223
/*! exports provided: NormalMaterial */
4224
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4225
4226
"use strict";
4227
__webpack_require__.r(__webpack_exports__);
4228
/* harmony import */ var _normalMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./normalMaterial */ "./normal/normalMaterial.ts");
4229
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NormalMaterial", function() { return _normalMaterial__WEBPACK_IMPORTED_MODULE_0__["NormalMaterial"]; });
4230
4231
4232
4233
4234
/***/ }),
4235
4236
/***/ "./normal/normal.fragment.ts":
4237
/*!***********************************!*\
4238
!*** ./normal/normal.fragment.ts ***!
4239
\***********************************/
4240
/*! exports provided: normalPixelShader */
4241
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4242
4243
"use strict";
4244
__webpack_require__.r(__webpack_exports__);
4245
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalPixelShader", function() { return normalPixelShader; });
4246
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
4247
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
var name = 'normalPixelShader';
4262
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef LIGHTING\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef NORMAL\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\n#ifdef LIGHTING\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=baseColor.rgb;\n#endif\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
4263
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
4264
/** @hidden */
4265
var normalPixelShader = { name: name, shader: shader };
4266
4267
4268
/***/ }),
4269
4270
/***/ "./normal/normal.vertex.ts":
4271
/*!*********************************!*\
4272
!*** ./normal/normal.vertex.ts ***!
4273
\*********************************/
4274
/*! exports provided: normalVertexShader */
4275
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4276
4277
"use strict";
4278
__webpack_require__.r(__webpack_exports__);
4279
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "normalVertexShader", function() { return normalVertexShader; });
4280
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
4281
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
var name = 'normalVertexShader';
4295
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
4296
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
4297
/** @hidden */
4298
var normalVertexShader = { name: name, shader: shader };
4299
4300
4301
/***/ }),
4302
4303
/***/ "./normal/normalMaterial.ts":
4304
/*!**********************************!*\
4305
!*** ./normal/normalMaterial.ts ***!
4306
\**********************************/
4307
/*! exports provided: NormalMaterial */
4308
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4309
4310
"use strict";
4311
__webpack_require__.r(__webpack_exports__);
4312
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NormalMaterial", function() { return NormalMaterial; });
4313
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
4314
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
4315
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
4316
/* harmony import */ var _normal_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./normal.fragment */ "./normal/normal.fragment.ts");
4317
/* harmony import */ var _normal_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./normal.vertex */ "./normal/normal.vertex.ts");
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
var NormalMaterialDefines = /** @class */ (function (_super) {
4332
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(NormalMaterialDefines, _super);
4333
function NormalMaterialDefines() {
4334
var _this = _super.call(this) || this;
4335
_this.DIFFUSE = false;
4336
_this.CLIPPLANE = false;
4337
_this.CLIPPLANE2 = false;
4338
_this.CLIPPLANE3 = false;
4339
_this.CLIPPLANE4 = false;
4340
_this.CLIPPLANE5 = false;
4341
_this.CLIPPLANE6 = false;
4342
_this.ALPHATEST = false;
4343
_this.DEPTHPREPASS = false;
4344
_this.POINTSIZE = false;
4345
_this.FOG = false;
4346
_this.LIGHT0 = false;
4347
_this.LIGHT1 = false;
4348
_this.LIGHT2 = false;
4349
_this.LIGHT3 = false;
4350
_this.SPOTLIGHT0 = false;
4351
_this.SPOTLIGHT1 = false;
4352
_this.SPOTLIGHT2 = false;
4353
_this.SPOTLIGHT3 = false;
4354
_this.HEMILIGHT0 = false;
4355
_this.HEMILIGHT1 = false;
4356
_this.HEMILIGHT2 = false;
4357
_this.HEMILIGHT3 = false;
4358
_this.DIRLIGHT0 = false;
4359
_this.DIRLIGHT1 = false;
4360
_this.DIRLIGHT2 = false;
4361
_this.DIRLIGHT3 = false;
4362
_this.POINTLIGHT0 = false;
4363
_this.POINTLIGHT1 = false;
4364
_this.POINTLIGHT2 = false;
4365
_this.POINTLIGHT3 = false;
4366
_this.SHADOW0 = false;
4367
_this.SHADOW1 = false;
4368
_this.SHADOW2 = false;
4369
_this.SHADOW3 = false;
4370
_this.SHADOWS = false;
4371
_this.SHADOWESM0 = false;
4372
_this.SHADOWESM1 = false;
4373
_this.SHADOWESM2 = false;
4374
_this.SHADOWESM3 = false;
4375
_this.SHADOWPOISSON0 = false;
4376
_this.SHADOWPOISSON1 = false;
4377
_this.SHADOWPOISSON2 = false;
4378
_this.SHADOWPOISSON3 = false;
4379
_this.SHADOWPCF0 = false;
4380
_this.SHADOWPCF1 = false;
4381
_this.SHADOWPCF2 = false;
4382
_this.SHADOWPCF3 = false;
4383
_this.SHADOWPCSS0 = false;
4384
_this.SHADOWPCSS1 = false;
4385
_this.SHADOWPCSS2 = false;
4386
_this.SHADOWPCSS3 = false;
4387
_this.NORMAL = false;
4388
_this.UV1 = false;
4389
_this.UV2 = false;
4390
_this.NUM_BONE_INFLUENCERS = 0;
4391
_this.BonesPerMesh = 0;
4392
_this.INSTANCES = false;
4393
_this.LIGHTING = false;
4394
_this.IMAGEPROCESSINGPOSTPROCESS = false;
4395
_this.rebuild();
4396
return _this;
4397
}
4398
return NormalMaterialDefines;
4399
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
4400
var NormalMaterial = /** @class */ (function (_super) {
4401
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(NormalMaterial, _super);
4402
function NormalMaterial(name, scene) {
4403
var _this = _super.call(this, name, scene) || this;
4404
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
4405
_this._disableLighting = false;
4406
_this._maxSimultaneousLights = 4;
4407
return _this;
4408
}
4409
NormalMaterial.prototype.needAlphaBlending = function () {
4410
return (this.alpha < 1.0);
4411
};
4412
NormalMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
4413
return this.needAlphaBlending() || (mesh.visibility < 1.0);
4414
};
4415
NormalMaterial.prototype.needAlphaTesting = function () {
4416
return false;
4417
};
4418
NormalMaterial.prototype.getAlphaTestTexture = function () {
4419
return null;
4420
};
4421
// Methods
4422
NormalMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
4423
if (this.isFrozen) {
4424
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
4425
return true;
4426
}
4427
}
4428
if (!subMesh._materialDefines) {
4429
subMesh.materialDefines = new NormalMaterialDefines();
4430
}
4431
var defines = subMesh.materialDefines;
4432
var scene = this.getScene();
4433
if (this._isReadyForSubMesh(subMesh)) {
4434
return true;
4435
}
4436
var engine = scene.getEngine();
4437
// Textures
4438
if (defines._areTexturesDirty) {
4439
defines._needUVs = false;
4440
if (scene.texturesEnabled) {
4441
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
4442
if (!this._diffuseTexture.isReady()) {
4443
return false;
4444
}
4445
else {
4446
defines._needUVs = true;
4447
defines.DIFFUSE = true;
4448
}
4449
}
4450
}
4451
}
4452
// Misc.
4453
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
4454
// Lights
4455
defines._needNormals = true;
4456
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
4457
// Values that need to be evaluated on every frame
4458
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
4459
defines.LIGHTING = !this._disableLighting;
4460
// Attribs
4461
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
4462
// Get correct effect
4463
if (defines.isDirty) {
4464
defines.markAsProcessed();
4465
scene.resetCachedMaterial();
4466
// Fallbacks
4467
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
4468
if (defines.FOG) {
4469
fallbacks.addFallback(1, "FOG");
4470
}
4471
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks);
4472
if (defines.NUM_BONE_INFLUENCERS > 0) {
4473
fallbacks.addCPUSkinningFallback(0, mesh);
4474
}
4475
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
4476
//Attributes
4477
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
4478
if (defines.NORMAL) {
4479
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
4480
}
4481
if (defines.UV1) {
4482
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
4483
}
4484
if (defines.UV2) {
4485
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
4486
}
4487
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
4488
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
4489
var shaderName = "normal";
4490
var join = defines.toString();
4491
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
4492
"vFogInfos", "vFogColor", "pointSize",
4493
"vDiffuseInfos",
4494
"mBones",
4495
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
4496
];
4497
var samplers = ["diffuseSampler"];
4498
var uniformBuffers = new Array();
4499
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
4500
uniformsNames: uniforms,
4501
uniformBuffersNames: uniformBuffers,
4502
samplers: samplers,
4503
defines: defines,
4504
maxSimultaneousLights: 4
4505
});
4506
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
4507
attributes: attribs,
4508
uniformsNames: uniforms,
4509
uniformBuffersNames: uniformBuffers,
4510
samplers: samplers,
4511
defines: join,
4512
fallbacks: fallbacks,
4513
onCompiled: this.onCompiled,
4514
onError: this.onError,
4515
indexParameters: { maxSimultaneousLights: 4 }
4516
}, engine), defines, this._materialContext);
4517
}
4518
if (!subMesh.effect || !subMesh.effect.isReady()) {
4519
return false;
4520
}
4521
defines._renderId = scene.getRenderId();
4522
subMesh.effect._wasPreviouslyReady = true;
4523
return true;
4524
};
4525
NormalMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
4526
var scene = this.getScene();
4527
var defines = subMesh._materialDefines;
4528
if (!defines) {
4529
return;
4530
}
4531
var effect = subMesh.effect;
4532
if (!effect) {
4533
return;
4534
}
4535
this._activeEffect = effect;
4536
// Matrices
4537
this.bindOnlyWorldMatrix(world);
4538
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
4539
// Bones
4540
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
4541
if (this._mustRebind(scene, effect)) {
4542
// Textures
4543
if (this.diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
4544
this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
4545
this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
4546
this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
4547
}
4548
// Clip plane
4549
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
4550
// Point size
4551
if (this.pointsCloud) {
4552
this._activeEffect.setFloat("pointSize", this.pointSize);
4553
}
4554
scene.bindEyePosition(effect);
4555
}
4556
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
4557
// Lights
4558
if (scene.lightsEnabled && !this.disableLighting) {
4559
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines);
4560
}
4561
// View
4562
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
4563
this._activeEffect.setMatrix("view", scene.getViewMatrix());
4564
}
4565
// Fog
4566
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
4567
this._afterBind(mesh, this._activeEffect);
4568
};
4569
NormalMaterial.prototype.getAnimatables = function () {
4570
var results = [];
4571
if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
4572
results.push(this.diffuseTexture);
4573
}
4574
return results;
4575
};
4576
NormalMaterial.prototype.getActiveTextures = function () {
4577
var activeTextures = _super.prototype.getActiveTextures.call(this);
4578
if (this._diffuseTexture) {
4579
activeTextures.push(this._diffuseTexture);
4580
}
4581
return activeTextures;
4582
};
4583
NormalMaterial.prototype.hasTexture = function (texture) {
4584
if (_super.prototype.hasTexture.call(this, texture)) {
4585
return true;
4586
}
4587
if (this.diffuseTexture === texture) {
4588
return true;
4589
}
4590
return false;
4591
};
4592
NormalMaterial.prototype.dispose = function (forceDisposeEffect) {
4593
if (this.diffuseTexture) {
4594
this.diffuseTexture.dispose();
4595
}
4596
_super.prototype.dispose.call(this, forceDisposeEffect);
4597
};
4598
NormalMaterial.prototype.clone = function (name) {
4599
var _this = this;
4600
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new NormalMaterial(name, _this.getScene()); }, this);
4601
};
4602
NormalMaterial.prototype.serialize = function () {
4603
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
4604
serializationObject.customType = "BABYLON.NormalMaterial";
4605
return serializationObject;
4606
};
4607
NormalMaterial.prototype.getClassName = function () {
4608
return "NormalMaterial";
4609
};
4610
// Statics
4611
NormalMaterial.Parse = function (source, scene, rootUrl) {
4612
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new NormalMaterial(source.name, scene); }, source, scene, rootUrl);
4613
};
4614
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4615
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
4616
], NormalMaterial.prototype, "_diffuseTexture", void 0);
4617
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4618
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
4619
], NormalMaterial.prototype, "diffuseTexture", void 0);
4620
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4621
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
4622
], NormalMaterial.prototype, "diffuseColor", void 0);
4623
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4624
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
4625
], NormalMaterial.prototype, "_disableLighting", void 0);
4626
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4627
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
4628
], NormalMaterial.prototype, "disableLighting", void 0);
4629
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4630
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
4631
], NormalMaterial.prototype, "_maxSimultaneousLights", void 0);
4632
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
4633
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
4634
], NormalMaterial.prototype, "maxSimultaneousLights", void 0);
4635
return NormalMaterial;
4636
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
4637
4638
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.NormalMaterial"] = NormalMaterial;
4639
4640
4641
/***/ }),
4642
4643
/***/ "./shadowOnly/index.ts":
4644
/*!*****************************!*\
4645
!*** ./shadowOnly/index.ts ***!
4646
\*****************************/
4647
/*! exports provided: ShadowOnlyMaterial */
4648
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4649
4650
"use strict";
4651
__webpack_require__.r(__webpack_exports__);
4652
/* harmony import */ var _shadowOnlyMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowOnlyMaterial */ "./shadowOnly/shadowOnlyMaterial.ts");
4653
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowOnlyMaterial", function() { return _shadowOnlyMaterial__WEBPACK_IMPORTED_MODULE_0__["ShadowOnlyMaterial"]; });
4654
4655
4656
4657
4658
/***/ }),
4659
4660
/***/ "./shadowOnly/shadowOnly.fragment.ts":
4661
/*!*******************************************!*\
4662
!*** ./shadowOnly/shadowOnly.fragment.ts ***!
4663
\*******************************************/
4664
/*! exports provided: shadowOnlyPixelShader */
4665
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4666
4667
"use strict";
4668
__webpack_require__.r(__webpack_exports__);
4669
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowOnlyPixelShader", function() { return shadowOnlyPixelShader; });
4670
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
4671
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
var name = 'shadowOnlyPixelShader';
4685
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\n\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
4686
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
4687
/** @hidden */
4688
var shadowOnlyPixelShader = { name: name, shader: shader };
4689
4690
4691
/***/ }),
4692
4693
/***/ "./shadowOnly/shadowOnly.vertex.ts":
4694
/*!*****************************************!*\
4695
!*** ./shadowOnly/shadowOnly.vertex.ts ***!
4696
\*****************************************/
4697
/*! exports provided: shadowOnlyVertexShader */
4698
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4699
4700
"use strict";
4701
__webpack_require__.r(__webpack_exports__);
4702
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowOnlyVertexShader", function() { return shadowOnlyVertexShader; });
4703
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
4704
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
var name = 'shadowOnlyVertexShader';
4718
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
4719
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
4720
/** @hidden */
4721
var shadowOnlyVertexShader = { name: name, shader: shader };
4722
4723
4724
/***/ }),
4725
4726
/***/ "./shadowOnly/shadowOnlyMaterial.ts":
4727
/*!******************************************!*\
4728
!*** ./shadowOnly/shadowOnlyMaterial.ts ***!
4729
\******************************************/
4730
/*! exports provided: ShadowOnlyMaterial */
4731
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4732
4733
"use strict";
4734
__webpack_require__.r(__webpack_exports__);
4735
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowOnlyMaterial", function() { return ShadowOnlyMaterial; });
4736
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
4737
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
4738
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
4739
/* harmony import */ var _shadowOnly_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shadowOnly.fragment */ "./shadowOnly/shadowOnly.fragment.ts");
4740
/* harmony import */ var _shadowOnly_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shadowOnly.vertex */ "./shadowOnly/shadowOnly.vertex.ts");
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
4754
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ShadowOnlyMaterialDefines, _super);
4755
function ShadowOnlyMaterialDefines() {
4756
var _this = _super.call(this) || this;
4757
_this.CLIPPLANE = false;
4758
_this.CLIPPLANE2 = false;
4759
_this.CLIPPLANE3 = false;
4760
_this.CLIPPLANE4 = false;
4761
_this.CLIPPLANE5 = false;
4762
_this.CLIPPLANE6 = false;
4763
_this.POINTSIZE = false;
4764
_this.FOG = false;
4765
_this.NORMAL = false;
4766
_this.NUM_BONE_INFLUENCERS = 0;
4767
_this.BonesPerMesh = 0;
4768
_this.INSTANCES = false;
4769
_this.IMAGEPROCESSINGPOSTPROCESS = false;
4770
_this.rebuild();
4771
return _this;
4772
}
4773
return ShadowOnlyMaterialDefines;
4774
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
4775
var ShadowOnlyMaterial = /** @class */ (function (_super) {
4776
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ShadowOnlyMaterial, _super);
4777
function ShadowOnlyMaterial(name, scene) {
4778
var _this = _super.call(this, name, scene) || this;
4779
_this._needAlphaBlending = true;
4780
_this.shadowColor = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
4781
return _this;
4782
}
4783
ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
4784
return this._needAlphaBlending;
4785
};
4786
ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
4787
return false;
4788
};
4789
ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
4790
return null;
4791
};
4792
Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
4793
get: function () {
4794
return this._activeLight;
4795
},
4796
set: function (light) {
4797
this._activeLight = light;
4798
},
4799
enumerable: false,
4800
configurable: true
4801
});
4802
ShadowOnlyMaterial.prototype._getFirstShadowLightForMesh = function (mesh) {
4803
for (var _i = 0, _a = mesh.lightSources; _i < _a.length; _i++) {
4804
var light = _a[_i];
4805
if (light.shadowEnabled) {
4806
return light;
4807
}
4808
}
4809
return null;
4810
};
4811
// Methods
4812
ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
4813
var _a;
4814
if (this.isFrozen) {
4815
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
4816
return true;
4817
}
4818
}
4819
if (!subMesh._materialDefines) {
4820
subMesh.materialDefines = new ShadowOnlyMaterialDefines();
4821
}
4822
var defines = subMesh._materialDefines;
4823
var scene = this.getScene();
4824
if (this._isReadyForSubMesh(subMesh)) {
4825
return true;
4826
}
4827
var engine = scene.getEngine();
4828
// Ensure that active light is the first shadow light
4829
if (this._activeLight) {
4830
for (var _i = 0, _b = mesh.lightSources; _i < _b.length; _i++) {
4831
var light = _b[_i];
4832
if (light.shadowEnabled) {
4833
if (this._activeLight === light) {
4834
break; // We are good
4835
}
4836
var lightPosition = mesh.lightSources.indexOf(this._activeLight);
4837
if (lightPosition !== -1) {
4838
mesh.lightSources.splice(lightPosition, 1);
4839
mesh.lightSources.splice(0, 0, this._activeLight);
4840
}
4841
break;
4842
}
4843
}
4844
}
4845
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
4846
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
4847
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, 1);
4848
var shadowGenerator = (_a = this._getFirstShadowLightForMesh(mesh)) === null || _a === void 0 ? void 0 : _a.getShadowGenerator();
4849
this._needAlphaBlending = true;
4850
if (shadowGenerator && shadowGenerator.getClassName && shadowGenerator.getClassName() === 'CascadedShadowGenerator') {
4851
var csg = shadowGenerator;
4852
this._needAlphaBlending = !csg.autoCalcDepthBounds;
4853
}
4854
// Attribs
4855
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true);
4856
// Get correct effect
4857
if (defines.isDirty) {
4858
defines.markAsProcessed();
4859
scene.resetCachedMaterial();
4860
// Fallbacks
4861
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
4862
if (defines.FOG) {
4863
fallbacks.addFallback(1, "FOG");
4864
}
4865
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, 1);
4866
if (defines.NUM_BONE_INFLUENCERS > 0) {
4867
fallbacks.addCPUSkinningFallback(0, mesh);
4868
}
4869
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
4870
//Attributes
4871
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
4872
if (defines.NORMAL) {
4873
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
4874
}
4875
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
4876
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
4877
var shaderName = "shadowOnly";
4878
var join = defines.toString();
4879
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
4880
"vFogInfos", "vFogColor", "pointSize", "alpha", "shadowColor",
4881
"mBones",
4882
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6"
4883
];
4884
var samplers = new Array();
4885
var uniformBuffers = new Array();
4886
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
4887
uniformsNames: uniforms,
4888
uniformBuffersNames: uniformBuffers,
4889
samplers: samplers,
4890
defines: defines,
4891
maxSimultaneousLights: 1
4892
});
4893
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
4894
attributes: attribs,
4895
uniformsNames: uniforms,
4896
uniformBuffersNames: uniformBuffers,
4897
samplers: samplers,
4898
defines: join,
4899
fallbacks: fallbacks,
4900
onCompiled: this.onCompiled,
4901
onError: this.onError,
4902
indexParameters: { maxSimultaneousLights: 1 }
4903
}, engine), defines, this._materialContext);
4904
}
4905
if (!subMesh.effect || !subMesh.effect.isReady()) {
4906
return false;
4907
}
4908
defines._renderId = scene.getRenderId();
4909
subMesh.effect._wasPreviouslyReady = true;
4910
return true;
4911
};
4912
ShadowOnlyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
4913
var scene = this.getScene();
4914
var defines = subMesh._materialDefines;
4915
if (!defines) {
4916
return;
4917
}
4918
var effect = subMesh.effect;
4919
if (!effect) {
4920
return;
4921
}
4922
this._activeEffect = effect;
4923
// Matrices
4924
this.bindOnlyWorldMatrix(world);
4925
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
4926
// Bones
4927
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
4928
if (this._mustRebind(scene, effect)) {
4929
// Clip plane
4930
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
4931
// Point size
4932
if (this.pointsCloud) {
4933
this._activeEffect.setFloat("pointSize", this.pointSize);
4934
}
4935
this._activeEffect.setFloat("alpha", this.alpha);
4936
this._activeEffect.setColor3("shadowColor", this.shadowColor);
4937
scene.bindEyePosition(effect);
4938
}
4939
// Lights
4940
if (scene.lightsEnabled) {
4941
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, 1);
4942
var light = this._getFirstShadowLightForMesh(mesh);
4943
if (light) {
4944
// Make sure the uniforms for this light will be rebound for other materials using this light when rendering the current frame.
4945
// Indeed, there is an optimization in Light that binds the light uniforms only once per frame for a given light (if using ubo).
4946
// Doing this way assumes that all uses of this light are the same, meaning all parameters passed to Light._bindLlight
4947
// are the same, notably useSpecular. However, isReadyForSubMesh (see above) is passing false for this parameter, which may not be
4948
// the value the other materials may pass.
4949
light._renderId = -1;
4950
}
4951
}
4952
// View
4953
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE || defines["SHADOWCSM0"]) {
4954
this._activeEffect.setMatrix("view", scene.getViewMatrix());
4955
}
4956
// Fog
4957
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
4958
this._afterBind(mesh, this._activeEffect);
4959
};
4960
ShadowOnlyMaterial.prototype.clone = function (name) {
4961
var _this = this;
4962
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ShadowOnlyMaterial(name, _this.getScene()); }, this);
4963
};
4964
ShadowOnlyMaterial.prototype.serialize = function () {
4965
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
4966
serializationObject.customType = "BABYLON.ShadowOnlyMaterial";
4967
return serializationObject;
4968
};
4969
ShadowOnlyMaterial.prototype.getClassName = function () {
4970
return "ShadowOnlyMaterial";
4971
};
4972
// Statics
4973
ShadowOnlyMaterial.Parse = function (source, scene, rootUrl) {
4974
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShadowOnlyMaterial(source.name, scene); }, source, scene, rootUrl);
4975
};
4976
return ShadowOnlyMaterial;
4977
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
4978
4979
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.ShadowOnlyMaterial"] = ShadowOnlyMaterial;
4980
4981
4982
/***/ }),
4983
4984
/***/ "./simple/index.ts":
4985
/*!*************************!*\
4986
!*** ./simple/index.ts ***!
4987
\*************************/
4988
/*! exports provided: SimpleMaterial */
4989
/***/ (function(module, __webpack_exports__, __webpack_require__) {
4990
4991
"use strict";
4992
__webpack_require__.r(__webpack_exports__);
4993
/* harmony import */ var _simpleMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./simpleMaterial */ "./simple/simpleMaterial.ts");
4994
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimpleMaterial", function() { return _simpleMaterial__WEBPACK_IMPORTED_MODULE_0__["SimpleMaterial"]; });
4995
4996
4997
4998
4999
/***/ }),
5000
5001
/***/ "./simple/simple.fragment.ts":
5002
/*!***********************************!*\
5003
!*** ./simple/simple.fragment.ts ***!
5004
\***********************************/
5005
/*! exports provided: simplePixelShader */
5006
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5007
5008
"use strict";
5009
__webpack_require__.r(__webpack_exports__);
5010
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "simplePixelShader", function() { return simplePixelShader; });
5011
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5012
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
var name = 'simplePixelShader';
5027
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";
5028
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5029
/** @hidden */
5030
var simplePixelShader = { name: name, shader: shader };
5031
5032
5033
/***/ }),
5034
5035
/***/ "./simple/simple.vertex.ts":
5036
/*!*********************************!*\
5037
!*** ./simple/simple.vertex.ts ***!
5038
\*********************************/
5039
/*! exports provided: simpleVertexShader */
5040
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5041
5042
"use strict";
5043
__webpack_require__.r(__webpack_exports__);
5044
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "simpleVertexShader", function() { return simpleVertexShader; });
5045
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5046
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
var name = 'simpleVertexShader';
5060
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
5061
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5062
/** @hidden */
5063
var simpleVertexShader = { name: name, shader: shader };
5064
5065
5066
/***/ }),
5067
5068
/***/ "./simple/simpleMaterial.ts":
5069
/*!**********************************!*\
5070
!*** ./simple/simpleMaterial.ts ***!
5071
\**********************************/
5072
/*! exports provided: SimpleMaterial */
5073
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5074
5075
"use strict";
5076
__webpack_require__.r(__webpack_exports__);
5077
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimpleMaterial", function() { return SimpleMaterial; });
5078
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
5079
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
5080
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
5081
/* harmony import */ var _simple_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./simple.fragment */ "./simple/simple.fragment.ts");
5082
/* harmony import */ var _simple_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./simple.vertex */ "./simple/simple.vertex.ts");
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
var SimpleMaterialDefines = /** @class */ (function (_super) {
5097
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SimpleMaterialDefines, _super);
5098
function SimpleMaterialDefines() {
5099
var _this = _super.call(this) || this;
5100
_this.DIFFUSE = false;
5101
_this.CLIPPLANE = false;
5102
_this.CLIPPLANE2 = false;
5103
_this.CLIPPLANE3 = false;
5104
_this.CLIPPLANE4 = false;
5105
_this.CLIPPLANE5 = false;
5106
_this.CLIPPLANE6 = false;
5107
_this.ALPHATEST = false;
5108
_this.DEPTHPREPASS = false;
5109
_this.POINTSIZE = false;
5110
_this.FOG = false;
5111
_this.NORMAL = false;
5112
_this.UV1 = false;
5113
_this.UV2 = false;
5114
_this.VERTEXCOLOR = false;
5115
_this.VERTEXALPHA = false;
5116
_this.NUM_BONE_INFLUENCERS = 0;
5117
_this.BonesPerMesh = 0;
5118
_this.INSTANCES = false;
5119
_this.IMAGEPROCESSINGPOSTPROCESS = false;
5120
_this.rebuild();
5121
return _this;
5122
}
5123
return SimpleMaterialDefines;
5124
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
5125
var SimpleMaterial = /** @class */ (function (_super) {
5126
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SimpleMaterial, _super);
5127
function SimpleMaterial(name, scene) {
5128
var _this = _super.call(this, name, scene) || this;
5129
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
5130
_this._disableLighting = false;
5131
_this._maxSimultaneousLights = 4;
5132
return _this;
5133
}
5134
SimpleMaterial.prototype.needAlphaBlending = function () {
5135
return (this.alpha < 1.0);
5136
};
5137
SimpleMaterial.prototype.needAlphaTesting = function () {
5138
return false;
5139
};
5140
SimpleMaterial.prototype.getAlphaTestTexture = function () {
5141
return null;
5142
};
5143
// Methods
5144
SimpleMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
5145
if (this.isFrozen) {
5146
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
5147
return true;
5148
}
5149
}
5150
if (!subMesh._materialDefines) {
5151
subMesh.materialDefines = new SimpleMaterialDefines();
5152
}
5153
var defines = subMesh._materialDefines;
5154
var scene = this.getScene();
5155
if (this._isReadyForSubMesh(subMesh)) {
5156
return true;
5157
}
5158
var engine = scene.getEngine();
5159
// Textures
5160
if (defines._areTexturesDirty) {
5161
defines._needUVs = false;
5162
if (scene.texturesEnabled) {
5163
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
5164
if (!this._diffuseTexture.isReady()) {
5165
return false;
5166
}
5167
else {
5168
defines._needUVs = true;
5169
defines.DIFFUSE = true;
5170
}
5171
}
5172
}
5173
}
5174
// Misc.
5175
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
5176
// Lights
5177
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
5178
// Values that need to be evaluated on every frame
5179
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
5180
// Attribs
5181
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
5182
// Get correct effect
5183
if (defines.isDirty) {
5184
defines.markAsProcessed();
5185
scene.resetCachedMaterial();
5186
// Fallbacks
5187
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
5188
if (defines.FOG) {
5189
fallbacks.addFallback(1, "FOG");
5190
}
5191
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
5192
if (defines.NUM_BONE_INFLUENCERS > 0) {
5193
fallbacks.addCPUSkinningFallback(0, mesh);
5194
}
5195
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
5196
//Attributes
5197
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
5198
if (defines.NORMAL) {
5199
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
5200
}
5201
if (defines.UV1) {
5202
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
5203
}
5204
if (defines.UV2) {
5205
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
5206
}
5207
if (defines.VERTEXCOLOR) {
5208
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
5209
}
5210
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
5211
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
5212
var shaderName = "simple";
5213
var join = defines.toString();
5214
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
5215
"vFogInfos", "vFogColor", "pointSize",
5216
"vDiffuseInfos",
5217
"mBones",
5218
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
5219
];
5220
var samplers = ["diffuseSampler"];
5221
var uniformBuffers = new Array();
5222
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
5223
uniformsNames: uniforms,
5224
uniformBuffersNames: uniformBuffers,
5225
samplers: samplers,
5226
defines: defines,
5227
maxSimultaneousLights: this.maxSimultaneousLights
5228
});
5229
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
5230
attributes: attribs,
5231
uniformsNames: uniforms,
5232
uniformBuffersNames: uniformBuffers,
5233
samplers: samplers,
5234
defines: join,
5235
fallbacks: fallbacks,
5236
onCompiled: this.onCompiled,
5237
onError: this.onError,
5238
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights - 1 }
5239
}, engine), defines, this._materialContext);
5240
}
5241
if (!subMesh.effect || !subMesh.effect.isReady()) {
5242
return false;
5243
}
5244
defines._renderId = scene.getRenderId();
5245
subMesh.effect._wasPreviouslyReady = true;
5246
return true;
5247
};
5248
SimpleMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
5249
var scene = this.getScene();
5250
var defines = subMesh._materialDefines;
5251
if (!defines) {
5252
return;
5253
}
5254
var effect = subMesh.effect;
5255
if (!effect) {
5256
return;
5257
}
5258
this._activeEffect = effect;
5259
// Matrices
5260
this.bindOnlyWorldMatrix(world);
5261
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
5262
// Bones
5263
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
5264
if (this._mustRebind(scene, effect)) {
5265
// Textures
5266
if (this._diffuseTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
5267
this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
5268
this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
5269
this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
5270
}
5271
// Clip plane
5272
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
5273
// Point size
5274
if (this.pointsCloud) {
5275
this._activeEffect.setFloat("pointSize", this.pointSize);
5276
}
5277
scene.bindEyePosition(effect);
5278
}
5279
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
5280
// Lights
5281
if (scene.lightsEnabled && !this.disableLighting) {
5282
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
5283
}
5284
// View
5285
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
5286
this._activeEffect.setMatrix("view", scene.getViewMatrix());
5287
}
5288
// Fog
5289
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
5290
this._afterBind(mesh, this._activeEffect);
5291
};
5292
SimpleMaterial.prototype.getAnimatables = function () {
5293
var results = [];
5294
if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
5295
results.push(this._diffuseTexture);
5296
}
5297
return results;
5298
};
5299
SimpleMaterial.prototype.getActiveTextures = function () {
5300
var activeTextures = _super.prototype.getActiveTextures.call(this);
5301
if (this._diffuseTexture) {
5302
activeTextures.push(this._diffuseTexture);
5303
}
5304
return activeTextures;
5305
};
5306
SimpleMaterial.prototype.hasTexture = function (texture) {
5307
if (_super.prototype.hasTexture.call(this, texture)) {
5308
return true;
5309
}
5310
if (this.diffuseTexture === texture) {
5311
return true;
5312
}
5313
return false;
5314
};
5315
SimpleMaterial.prototype.dispose = function (forceDisposeEffect) {
5316
if (this._diffuseTexture) {
5317
this._diffuseTexture.dispose();
5318
}
5319
_super.prototype.dispose.call(this, forceDisposeEffect);
5320
};
5321
SimpleMaterial.prototype.clone = function (name) {
5322
var _this = this;
5323
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new SimpleMaterial(name, _this.getScene()); }, this);
5324
};
5325
SimpleMaterial.prototype.serialize = function () {
5326
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
5327
serializationObject.customType = "BABYLON.SimpleMaterial";
5328
return serializationObject;
5329
};
5330
SimpleMaterial.prototype.getClassName = function () {
5331
return "SimpleMaterial";
5332
};
5333
// Statics
5334
SimpleMaterial.Parse = function (source, scene, rootUrl) {
5335
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new SimpleMaterial(source.name, scene); }, source, scene, rootUrl);
5336
};
5337
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5338
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
5339
], SimpleMaterial.prototype, "_diffuseTexture", void 0);
5340
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5341
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
5342
], SimpleMaterial.prototype, "diffuseTexture", void 0);
5343
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5344
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
5345
], SimpleMaterial.prototype, "diffuseColor", void 0);
5346
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5347
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
5348
], SimpleMaterial.prototype, "_disableLighting", void 0);
5349
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5350
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
5351
], SimpleMaterial.prototype, "disableLighting", void 0);
5352
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5353
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
5354
], SimpleMaterial.prototype, "_maxSimultaneousLights", void 0);
5355
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5356
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
5357
], SimpleMaterial.prototype, "maxSimultaneousLights", void 0);
5358
return SimpleMaterial;
5359
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
5360
5361
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.SimpleMaterial"] = SimpleMaterial;
5362
5363
5364
/***/ }),
5365
5366
/***/ "./sky/index.ts":
5367
/*!**********************!*\
5368
!*** ./sky/index.ts ***!
5369
\**********************/
5370
/*! exports provided: SkyMaterial */
5371
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5372
5373
"use strict";
5374
__webpack_require__.r(__webpack_exports__);
5375
/* harmony import */ var _skyMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./skyMaterial */ "./sky/skyMaterial.ts");
5376
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkyMaterial", function() { return _skyMaterial__WEBPACK_IMPORTED_MODULE_0__["SkyMaterial"]; });
5377
5378
5379
5380
5381
/***/ }),
5382
5383
/***/ "./sky/sky.fragment.ts":
5384
/*!*****************************!*\
5385
!*** ./sky/sky.fragment.ts ***!
5386
\*****************************/
5387
/*! exports provided: skyPixelShader */
5388
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5389
5390
"use strict";
5391
__webpack_require__.r(__webpack_exports__);
5392
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "skyPixelShader", function() { return skyPixelShader; });
5393
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5394
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5395
5396
5397
5398
5399
5400
5401
var name = 'skyPixelShader';
5402
var shader = "precision highp float;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\nuniform vec3 cameraPosition;\nuniform vec3 cameraOffset;\nuniform vec3 up;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n\n#include<fogFragmentDeclaration>\n\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{\nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\n\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0);\ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance;\nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled);\nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\n\n\n\nvec3 retColor=curr*whiteScale;\n\n\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";
5403
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5404
/** @hidden */
5405
var skyPixelShader = { name: name, shader: shader };
5406
5407
5408
/***/ }),
5409
5410
/***/ "./sky/sky.vertex.ts":
5411
/*!***************************!*\
5412
!*** ./sky/sky.vertex.ts ***!
5413
\***************************/
5414
/*! exports provided: skyVertexShader */
5415
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5416
5417
"use strict";
5418
__webpack_require__.r(__webpack_exports__);
5419
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "skyVertexShader", function() { return skyVertexShader; });
5420
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5421
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5422
5423
5424
5425
5426
5427
var name = 'skyVertexShader';
5428
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nvoid main(void) {\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
5429
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5430
/** @hidden */
5431
var skyVertexShader = { name: name, shader: shader };
5432
5433
5434
/***/ }),
5435
5436
/***/ "./sky/skyMaterial.ts":
5437
/*!****************************!*\
5438
!*** ./sky/skyMaterial.ts ***!
5439
\****************************/
5440
/*! exports provided: SkyMaterial */
5441
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5442
5443
"use strict";
5444
__webpack_require__.r(__webpack_exports__);
5445
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkyMaterial", function() { return SkyMaterial; });
5446
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
5447
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
5448
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
5449
/* harmony import */ var _sky_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sky.fragment */ "./sky/sky.fragment.ts");
5450
/* harmony import */ var _sky_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sky.vertex */ "./sky/sky.vertex.ts");
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
/** @hidden */
5464
var SkyMaterialDefines = /** @class */ (function (_super) {
5465
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SkyMaterialDefines, _super);
5466
function SkyMaterialDefines() {
5467
var _this = _super.call(this) || this;
5468
_this.CLIPPLANE = false;
5469
_this.CLIPPLANE2 = false;
5470
_this.CLIPPLANE3 = false;
5471
_this.CLIPPLANE4 = false;
5472
_this.CLIPPLANE5 = false;
5473
_this.CLIPPLANE6 = false;
5474
_this.POINTSIZE = false;
5475
_this.FOG = false;
5476
_this.VERTEXCOLOR = false;
5477
_this.VERTEXALPHA = false;
5478
_this.IMAGEPROCESSINGPOSTPROCESS = false;
5479
_this.rebuild();
5480
return _this;
5481
}
5482
return SkyMaterialDefines;
5483
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
5484
/**
5485
* This is the sky material which allows to create dynamic and texture free effects for skyboxes.
5486
* @see https://doc.babylonjs.com/extensions/sky
5487
*/
5488
var SkyMaterial = /** @class */ (function (_super) {
5489
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SkyMaterial, _super);
5490
/**
5491
* Instantiates a new sky material.
5492
* This material allows to create dynamic and texture free
5493
* effects for skyboxes by taking care of the atmosphere state.
5494
* @see https://doc.babylonjs.com/extensions/sky
5495
* @param name Define the name of the material in the scene
5496
* @param scene Define the scene the material belong to
5497
*/
5498
function SkyMaterial(name, scene) {
5499
var _this = _super.call(this, name, scene) || this;
5500
/**
5501
* Defines the overall luminance of sky in interval ]0, 1[.
5502
*/
5503
_this.luminance = 1.0;
5504
/**
5505
* Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
5506
*/
5507
_this.turbidity = 10.0;
5508
/**
5509
* Defines the sky appearance (light intensity).
5510
*/
5511
_this.rayleigh = 2.0;
5512
/**
5513
* Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
5514
*/
5515
_this.mieCoefficient = 0.005;
5516
/**
5517
* Defines the amount of haze particles following the Mie scattering theory.
5518
*/
5519
_this.mieDirectionalG = 0.8;
5520
/**
5521
* Defines the distance of the sun according to the active scene camera.
5522
*/
5523
_this.distance = 500;
5524
/**
5525
* Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
5526
* "inclined".
5527
*/
5528
_this.inclination = 0.49;
5529
/**
5530
* Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
5531
* an object direction and a reference direction.
5532
*/
5533
_this.azimuth = 0.25;
5534
/**
5535
* Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
5536
* the property is overriden by the inclination and the azimuth and can be read at any moment.
5537
*/
5538
_this.sunPosition = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 100, 0);
5539
/**
5540
* Defines if the sun position should be computed (inclination and azimuth) according to the given
5541
* .sunPosition property.
5542
*/
5543
_this.useSunPosition = false;
5544
/**
5545
* Defines an offset vector used to get a horizon offset.
5546
* @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
5547
*/
5548
_this.cameraOffset = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
5549
/**
5550
* Defines the vector the skyMaterial should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
5551
*/
5552
_this.up = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
5553
// Private members
5554
_this._cameraPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
5555
_this._skyOrientation = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
5556
return _this;
5557
}
5558
/**
5559
* Specifies if the material will require alpha blending
5560
* @returns a boolean specifying if alpha blending is needed
5561
*/
5562
SkyMaterial.prototype.needAlphaBlending = function () {
5563
return (this.alpha < 1.0);
5564
};
5565
/**
5566
* Specifies if this material should be rendered in alpha test mode
5567
* @returns false as the sky material doesn't need alpha testing.
5568
*/
5569
SkyMaterial.prototype.needAlphaTesting = function () {
5570
return false;
5571
};
5572
/**
5573
* Get the texture used for alpha test purpose.
5574
* @returns null as the sky material has no texture.
5575
*/
5576
SkyMaterial.prototype.getAlphaTestTexture = function () {
5577
return null;
5578
};
5579
/**
5580
* Get if the submesh is ready to be used and all its information available.
5581
* Child classes can use it to update shaders
5582
* @param mesh defines the mesh to check
5583
* @param subMesh defines which submesh to check
5584
* @param useInstances specifies that instances should be used
5585
* @returns a boolean indicating that the submesh is ready or not
5586
*/
5587
SkyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
5588
if (this.isFrozen) {
5589
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
5590
return true;
5591
}
5592
}
5593
if (!subMesh._materialDefines) {
5594
subMesh.materialDefines = new SkyMaterialDefines();
5595
}
5596
var defines = subMesh._materialDefines;
5597
var scene = this.getScene();
5598
if (this._isReadyForSubMesh(subMesh)) {
5599
return true;
5600
}
5601
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
5602
// Attribs
5603
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, false);
5604
if (defines.IMAGEPROCESSINGPOSTPROCESS !== scene.imageProcessingConfiguration.applyByPostProcess) {
5605
defines.markAsMiscDirty();
5606
}
5607
// Get correct effect
5608
if (defines.isDirty) {
5609
defines.markAsProcessed();
5610
scene.resetCachedMaterial();
5611
// Fallbacks
5612
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
5613
if (defines.FOG) {
5614
fallbacks.addFallback(1, "FOG");
5615
}
5616
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
5617
//Attributes
5618
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
5619
if (defines.VERTEXCOLOR) {
5620
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
5621
}
5622
var shaderName = "sky";
5623
var join = defines.toString();
5624
subMesh.setEffect(scene.getEngine().createEffect(shaderName, attribs, ["world", "viewProjection", "view",
5625
"vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
5626
"luminance", "turbidity", "rayleigh", "mieCoefficient", "mieDirectionalG", "sunPosition",
5627
"cameraPosition", "cameraOffset", "up"
5628
], [], join, fallbacks, this.onCompiled, this.onError), defines, this._materialContext);
5629
}
5630
if (!subMesh.effect || !subMesh.effect.isReady()) {
5631
return false;
5632
}
5633
defines._renderId = scene.getRenderId();
5634
subMesh.effect._wasPreviouslyReady = true;
5635
return true;
5636
};
5637
/**
5638
* Binds the submesh to this material by preparing the effect and shader to draw
5639
* @param world defines the world transformation matrix
5640
* @param mesh defines the mesh containing the submesh
5641
* @param subMesh defines the submesh to bind the material to
5642
*/
5643
SkyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
5644
var scene = this.getScene();
5645
var defines = subMesh._materialDefines;
5646
if (!defines) {
5647
return;
5648
}
5649
var effect = subMesh.effect;
5650
if (!effect) {
5651
return;
5652
}
5653
this._activeEffect = effect;
5654
// Matrices
5655
this.bindOnlyWorldMatrix(world);
5656
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
5657
if (this._mustRebind(scene, effect)) {
5658
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
5659
// Point size
5660
if (this.pointsCloud) {
5661
this._activeEffect.setFloat("pointSize", this.pointSize);
5662
}
5663
}
5664
// View
5665
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
5666
this._activeEffect.setMatrix("view", scene.getViewMatrix());
5667
}
5668
// Fog
5669
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
5670
// Sky
5671
var camera = scene.activeCamera;
5672
if (camera) {
5673
var cameraWorldMatrix = camera.getWorldMatrix();
5674
this._cameraPosition.x = cameraWorldMatrix.m[12];
5675
this._cameraPosition.y = cameraWorldMatrix.m[13];
5676
this._cameraPosition.z = cameraWorldMatrix.m[14];
5677
this._activeEffect.setVector3("cameraPosition", this._cameraPosition);
5678
}
5679
this._activeEffect.setVector3("cameraOffset", this.cameraOffset);
5680
this._activeEffect.setVector3("up", this.up);
5681
if (this.luminance > 0) {
5682
this._activeEffect.setFloat("luminance", this.luminance);
5683
}
5684
this._activeEffect.setFloat("turbidity", this.turbidity);
5685
this._activeEffect.setFloat("rayleigh", this.rayleigh);
5686
this._activeEffect.setFloat("mieCoefficient", this.mieCoefficient);
5687
this._activeEffect.setFloat("mieDirectionalG", this.mieDirectionalG);
5688
if (!this.useSunPosition) {
5689
var theta = Math.PI * (this.inclination - 0.5);
5690
var phi = 2 * Math.PI * (this.azimuth - 0.5);
5691
this.sunPosition.x = this.distance * Math.cos(phi);
5692
this.sunPosition.y = this.distance * Math.sin(phi) * Math.sin(theta);
5693
this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);
5694
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromUnitVectorsToRef(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].UpReadOnly, this.up, this._skyOrientation);
5695
this.sunPosition.rotateByQuaternionToRef(this._skyOrientation, this.sunPosition);
5696
}
5697
this._activeEffect.setVector3("sunPosition", this.sunPosition);
5698
this._afterBind(mesh, this._activeEffect);
5699
};
5700
/**
5701
* Get the list of animatables in the material.
5702
* @returns the list of animatables object used in the material
5703
*/
5704
SkyMaterial.prototype.getAnimatables = function () {
5705
return [];
5706
};
5707
/**
5708
* Disposes the material
5709
* @param forceDisposeEffect specifies if effects should be forcefully disposed
5710
*/
5711
SkyMaterial.prototype.dispose = function (forceDisposeEffect) {
5712
_super.prototype.dispose.call(this, forceDisposeEffect);
5713
};
5714
/**
5715
* Makes a duplicate of the material, and gives it a new name
5716
* @param name defines the new name for the duplicated material
5717
* @returns the cloned material
5718
*/
5719
SkyMaterial.prototype.clone = function (name) {
5720
var _this = this;
5721
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new SkyMaterial(name, _this.getScene()); }, this);
5722
};
5723
/**
5724
* Serializes this material in a JSON representation
5725
* @returns the serialized material object
5726
*/
5727
SkyMaterial.prototype.serialize = function () {
5728
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
5729
serializationObject.customType = "BABYLON.SkyMaterial";
5730
return serializationObject;
5731
};
5732
/**
5733
* Gets the current class name of the material e.g. "SkyMaterial"
5734
* Mainly use in serialization.
5735
* @returns the class name
5736
*/
5737
SkyMaterial.prototype.getClassName = function () {
5738
return "SkyMaterial";
5739
};
5740
/**
5741
* Creates a sky material from parsed material data
5742
* @param source defines the JSON representation of the material
5743
* @param scene defines the hosting scene
5744
* @param rootUrl defines the root URL to use to load textures and relative dependencies
5745
* @returns a new sky material
5746
*/
5747
SkyMaterial.Parse = function (source, scene, rootUrl) {
5748
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new SkyMaterial(source.name, scene); }, source, scene, rootUrl);
5749
};
5750
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5751
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5752
], SkyMaterial.prototype, "luminance", void 0);
5753
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5754
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5755
], SkyMaterial.prototype, "turbidity", void 0);
5756
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5757
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5758
], SkyMaterial.prototype, "rayleigh", void 0);
5759
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5760
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5761
], SkyMaterial.prototype, "mieCoefficient", void 0);
5762
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5763
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5764
], SkyMaterial.prototype, "mieDirectionalG", void 0);
5765
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5766
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5767
], SkyMaterial.prototype, "distance", void 0);
5768
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5769
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5770
], SkyMaterial.prototype, "inclination", void 0);
5771
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5772
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5773
], SkyMaterial.prototype, "azimuth", void 0);
5774
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5775
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
5776
], SkyMaterial.prototype, "sunPosition", void 0);
5777
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5778
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
5779
], SkyMaterial.prototype, "useSunPosition", void 0);
5780
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5781
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
5782
], SkyMaterial.prototype, "cameraOffset", void 0);
5783
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
5784
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
5785
], SkyMaterial.prototype, "up", void 0);
5786
return SkyMaterial;
5787
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
5788
5789
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.SkyMaterial"] = SkyMaterial;
5790
5791
5792
/***/ }),
5793
5794
/***/ "./terrain/index.ts":
5795
/*!**************************!*\
5796
!*** ./terrain/index.ts ***!
5797
\**************************/
5798
/*! exports provided: TerrainMaterial */
5799
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5800
5801
"use strict";
5802
__webpack_require__.r(__webpack_exports__);
5803
/* harmony import */ var _terrainMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./terrainMaterial */ "./terrain/terrainMaterial.ts");
5804
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TerrainMaterial", function() { return _terrainMaterial__WEBPACK_IMPORTED_MODULE_0__["TerrainMaterial"]; });
5805
5806
5807
5808
5809
/***/ }),
5810
5811
/***/ "./terrain/terrain.fragment.ts":
5812
/*!*************************************!*\
5813
!*** ./terrain/terrain.fragment.ts ***!
5814
\*************************************/
5815
/*! exports provided: terrainPixelShader */
5816
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5817
5818
"use strict";
5819
__webpack_require__.r(__webpack_exports__);
5820
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "terrainPixelShader", function() { return terrainPixelShader; });
5821
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5822
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
var name = 'terrainPixelShader';
5837
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{\nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";
5838
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5839
/** @hidden */
5840
var terrainPixelShader = { name: name, shader: shader };
5841
5842
5843
/***/ }),
5844
5845
/***/ "./terrain/terrain.vertex.ts":
5846
/*!***********************************!*\
5847
!*** ./terrain/terrain.vertex.ts ***!
5848
\***********************************/
5849
/*! exports provided: terrainVertexShader */
5850
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5851
5852
"use strict";
5853
__webpack_require__.r(__webpack_exports__);
5854
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "terrainVertexShader", function() { return terrainVertexShader; });
5855
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
5856
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
var name = 'terrainVertexShader';
5870
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
5871
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
5872
/** @hidden */
5873
var terrainVertexShader = { name: name, shader: shader };
5874
5875
5876
/***/ }),
5877
5878
/***/ "./terrain/terrainMaterial.ts":
5879
/*!************************************!*\
5880
!*** ./terrain/terrainMaterial.ts ***!
5881
\************************************/
5882
/*! exports provided: TerrainMaterial */
5883
/***/ (function(module, __webpack_exports__, __webpack_require__) {
5884
5885
"use strict";
5886
__webpack_require__.r(__webpack_exports__);
5887
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TerrainMaterial", function() { return TerrainMaterial; });
5888
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
5889
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
5890
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
5891
/* harmony import */ var _terrain_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./terrain.fragment */ "./terrain/terrain.fragment.ts");
5892
/* harmony import */ var _terrain_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./terrain.vertex */ "./terrain/terrain.vertex.ts");
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
var TerrainMaterialDefines = /** @class */ (function (_super) {
5907
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TerrainMaterialDefines, _super);
5908
function TerrainMaterialDefines() {
5909
var _this = _super.call(this) || this;
5910
_this.DIFFUSE = false;
5911
_this.BUMP = false;
5912
_this.CLIPPLANE = false;
5913
_this.CLIPPLANE2 = false;
5914
_this.CLIPPLANE3 = false;
5915
_this.CLIPPLANE4 = false;
5916
_this.CLIPPLANE5 = false;
5917
_this.CLIPPLANE6 = false;
5918
_this.ALPHATEST = false;
5919
_this.DEPTHPREPASS = false;
5920
_this.POINTSIZE = false;
5921
_this.FOG = false;
5922
_this.SPECULARTERM = false;
5923
_this.NORMAL = false;
5924
_this.UV1 = false;
5925
_this.UV2 = false;
5926
_this.VERTEXCOLOR = false;
5927
_this.VERTEXALPHA = false;
5928
_this.NUM_BONE_INFLUENCERS = 0;
5929
_this.BonesPerMesh = 0;
5930
_this.INSTANCES = false;
5931
_this.IMAGEPROCESSINGPOSTPROCESS = false;
5932
_this.rebuild();
5933
return _this;
5934
}
5935
return TerrainMaterialDefines;
5936
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
5937
var TerrainMaterial = /** @class */ (function (_super) {
5938
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TerrainMaterial, _super);
5939
function TerrainMaterial(name, scene) {
5940
var _this = _super.call(this, name, scene) || this;
5941
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
5942
_this.specularColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0, 0, 0);
5943
_this.specularPower = 64;
5944
_this._disableLighting = false;
5945
_this._maxSimultaneousLights = 4;
5946
return _this;
5947
}
5948
TerrainMaterial.prototype.needAlphaBlending = function () {
5949
return (this.alpha < 1.0);
5950
};
5951
TerrainMaterial.prototype.needAlphaTesting = function () {
5952
return false;
5953
};
5954
TerrainMaterial.prototype.getAlphaTestTexture = function () {
5955
return null;
5956
};
5957
// Methods
5958
TerrainMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
5959
if (this.isFrozen) {
5960
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
5961
return true;
5962
}
5963
}
5964
if (!subMesh._materialDefines) {
5965
subMesh.materialDefines = new TerrainMaterialDefines();
5966
}
5967
var defines = subMesh._materialDefines;
5968
var scene = this.getScene();
5969
if (this._isReadyForSubMesh(subMesh)) {
5970
return true;
5971
}
5972
var engine = scene.getEngine();
5973
// Textures
5974
if (scene.texturesEnabled) {
5975
if (!this.mixTexture || !this.mixTexture.isReady()) {
5976
return false;
5977
}
5978
defines._needUVs = true;
5979
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
5980
if (!this.diffuseTexture1 || !this.diffuseTexture1.isReady()) {
5981
return false;
5982
}
5983
if (!this.diffuseTexture2 || !this.diffuseTexture2.isReady()) {
5984
return false;
5985
}
5986
if (!this.diffuseTexture3 || !this.diffuseTexture3.isReady()) {
5987
return false;
5988
}
5989
defines.DIFFUSE = true;
5990
}
5991
if (this.bumpTexture1 && this.bumpTexture2 && this.bumpTexture3 && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].BumpTextureEnabled) {
5992
if (!this.bumpTexture1.isReady()) {
5993
return false;
5994
}
5995
if (!this.bumpTexture2.isReady()) {
5996
return false;
5997
}
5998
if (!this.bumpTexture3.isReady()) {
5999
return false;
6000
}
6001
defines._needNormals = true;
6002
defines.BUMP = true;
6003
}
6004
}
6005
// Misc.
6006
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
6007
// Lights
6008
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
6009
// Values that need to be evaluated on every frame
6010
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
6011
// Attribs
6012
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
6013
// Get correct effect
6014
if (defines.isDirty) {
6015
defines.markAsProcessed();
6016
scene.resetCachedMaterial();
6017
// Fallbacks
6018
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
6019
if (defines.FOG) {
6020
fallbacks.addFallback(1, "FOG");
6021
}
6022
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
6023
if (defines.NUM_BONE_INFLUENCERS > 0) {
6024
fallbacks.addCPUSkinningFallback(0, mesh);
6025
}
6026
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
6027
//Attributes
6028
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
6029
if (defines.NORMAL) {
6030
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
6031
}
6032
if (defines.UV1) {
6033
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
6034
}
6035
if (defines.UV2) {
6036
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
6037
}
6038
if (defines.VERTEXCOLOR) {
6039
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
6040
}
6041
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
6042
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
6043
// Legacy browser patch
6044
var shaderName = "terrain";
6045
var join = defines.toString();
6046
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
6047
"vFogInfos", "vFogColor", "pointSize",
6048
"vTextureInfos",
6049
"mBones",
6050
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMatrix",
6051
"diffuse1Infos", "diffuse2Infos", "diffuse3Infos"
6052
];
6053
var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler",
6054
"bump1Sampler", "bump2Sampler", "bump3Sampler"
6055
];
6056
var uniformBuffers = new Array();
6057
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
6058
uniformsNames: uniforms,
6059
uniformBuffersNames: uniformBuffers,
6060
samplers: samplers,
6061
defines: defines,
6062
maxSimultaneousLights: this.maxSimultaneousLights
6063
});
6064
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
6065
attributes: attribs,
6066
uniformsNames: uniforms,
6067
uniformBuffersNames: uniformBuffers,
6068
samplers: samplers,
6069
defines: join,
6070
fallbacks: fallbacks,
6071
onCompiled: this.onCompiled,
6072
onError: this.onError,
6073
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
6074
}, engine), defines, this._materialContext);
6075
}
6076
if (!subMesh.effect || !subMesh.effect.isReady()) {
6077
return false;
6078
}
6079
defines._renderId = scene.getRenderId();
6080
subMesh.effect._wasPreviouslyReady = true;
6081
return true;
6082
};
6083
TerrainMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
6084
var scene = this.getScene();
6085
var defines = subMesh._materialDefines;
6086
if (!defines) {
6087
return;
6088
}
6089
var effect = subMesh.effect;
6090
if (!effect) {
6091
return;
6092
}
6093
this._activeEffect = effect;
6094
// Matrices
6095
this.bindOnlyWorldMatrix(world);
6096
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
6097
// Bones
6098
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
6099
if (this._mustRebind(scene, effect)) {
6100
// Textures
6101
if (this.mixTexture) {
6102
this._activeEffect.setTexture("textureSampler", this._mixTexture);
6103
this._activeEffect.setFloat2("vTextureInfos", this._mixTexture.coordinatesIndex, this._mixTexture.level);
6104
this._activeEffect.setMatrix("textureMatrix", this._mixTexture.getTextureMatrix());
6105
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
6106
if (this._diffuseTexture1) {
6107
this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
6108
this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
6109
}
6110
if (this._diffuseTexture2) {
6111
this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
6112
this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
6113
}
6114
if (this._diffuseTexture3) {
6115
this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
6116
this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
6117
}
6118
}
6119
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {
6120
if (this._bumpTexture1) {
6121
this._activeEffect.setTexture("bump1Sampler", this._bumpTexture1);
6122
}
6123
if (this._bumpTexture2) {
6124
this._activeEffect.setTexture("bump2Sampler", this._bumpTexture2);
6125
}
6126
if (this._bumpTexture3) {
6127
this._activeEffect.setTexture("bump3Sampler", this._bumpTexture3);
6128
}
6129
}
6130
}
6131
// Clip plane
6132
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
6133
// Point size
6134
if (this.pointsCloud) {
6135
this._activeEffect.setFloat("pointSize", this.pointSize);
6136
}
6137
scene.bindEyePosition(effect);
6138
}
6139
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
6140
if (defines.SPECULARTERM) {
6141
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
6142
}
6143
if (scene.lightsEnabled && !this.disableLighting) {
6144
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
6145
}
6146
// View
6147
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
6148
this._activeEffect.setMatrix("view", scene.getViewMatrix());
6149
}
6150
// Fog
6151
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
6152
this._afterBind(mesh, this._activeEffect);
6153
};
6154
TerrainMaterial.prototype.getAnimatables = function () {
6155
var results = [];
6156
if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
6157
results.push(this.mixTexture);
6158
}
6159
return results;
6160
};
6161
TerrainMaterial.prototype.getActiveTextures = function () {
6162
var activeTextures = _super.prototype.getActiveTextures.call(this);
6163
if (this._mixTexture) {
6164
activeTextures.push(this._mixTexture);
6165
}
6166
if (this._diffuseTexture1) {
6167
activeTextures.push(this._diffuseTexture1);
6168
}
6169
if (this._diffuseTexture2) {
6170
activeTextures.push(this._diffuseTexture2);
6171
}
6172
if (this._diffuseTexture3) {
6173
activeTextures.push(this._diffuseTexture3);
6174
}
6175
if (this._bumpTexture1) {
6176
activeTextures.push(this._bumpTexture1);
6177
}
6178
if (this._bumpTexture2) {
6179
activeTextures.push(this._bumpTexture2);
6180
}
6181
if (this._bumpTexture3) {
6182
activeTextures.push(this._bumpTexture3);
6183
}
6184
return activeTextures;
6185
};
6186
TerrainMaterial.prototype.hasTexture = function (texture) {
6187
if (_super.prototype.hasTexture.call(this, texture)) {
6188
return true;
6189
}
6190
if (this._mixTexture === texture) {
6191
return true;
6192
}
6193
if (this._diffuseTexture1 === texture) {
6194
return true;
6195
}
6196
if (this._diffuseTexture2 === texture) {
6197
return true;
6198
}
6199
if (this._diffuseTexture3 === texture) {
6200
return true;
6201
}
6202
if (this._bumpTexture1 === texture) {
6203
return true;
6204
}
6205
if (this._bumpTexture2 === texture) {
6206
return true;
6207
}
6208
if (this._bumpTexture3 === texture) {
6209
return true;
6210
}
6211
return false;
6212
};
6213
TerrainMaterial.prototype.dispose = function (forceDisposeEffect) {
6214
if (this.mixTexture) {
6215
this.mixTexture.dispose();
6216
}
6217
_super.prototype.dispose.call(this, forceDisposeEffect);
6218
};
6219
TerrainMaterial.prototype.clone = function (name) {
6220
var _this = this;
6221
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TerrainMaterial(name, _this.getScene()); }, this);
6222
};
6223
TerrainMaterial.prototype.serialize = function () {
6224
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
6225
serializationObject.customType = "BABYLON.TerrainMaterial";
6226
return serializationObject;
6227
};
6228
TerrainMaterial.prototype.getClassName = function () {
6229
return "TerrainMaterial";
6230
};
6231
// Statics
6232
TerrainMaterial.Parse = function (source, scene, rootUrl) {
6233
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TerrainMaterial(source.name, scene); }, source, scene, rootUrl);
6234
};
6235
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6236
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("mixTexture")
6237
], TerrainMaterial.prototype, "_mixTexture", void 0);
6238
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6239
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6240
], TerrainMaterial.prototype, "mixTexture", void 0);
6241
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6242
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture1")
6243
], TerrainMaterial.prototype, "_diffuseTexture1", void 0);
6244
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6245
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6246
], TerrainMaterial.prototype, "diffuseTexture1", void 0);
6247
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6248
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture2")
6249
], TerrainMaterial.prototype, "_diffuseTexture2", void 0);
6250
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6251
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6252
], TerrainMaterial.prototype, "diffuseTexture2", void 0);
6253
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6254
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture3")
6255
], TerrainMaterial.prototype, "_diffuseTexture3", void 0);
6256
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6257
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6258
], TerrainMaterial.prototype, "diffuseTexture3", void 0);
6259
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6260
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture1")
6261
], TerrainMaterial.prototype, "_bumpTexture1", void 0);
6262
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6263
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6264
], TerrainMaterial.prototype, "bumpTexture1", void 0);
6265
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6266
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture2")
6267
], TerrainMaterial.prototype, "_bumpTexture2", void 0);
6268
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6269
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6270
], TerrainMaterial.prototype, "bumpTexture2", void 0);
6271
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6272
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture3")
6273
], TerrainMaterial.prototype, "_bumpTexture3", void 0);
6274
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6275
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6276
], TerrainMaterial.prototype, "bumpTexture3", void 0);
6277
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6278
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
6279
], TerrainMaterial.prototype, "diffuseColor", void 0);
6280
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6281
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
6282
], TerrainMaterial.prototype, "specularColor", void 0);
6283
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6284
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
6285
], TerrainMaterial.prototype, "specularPower", void 0);
6286
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6287
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
6288
], TerrainMaterial.prototype, "_disableLighting", void 0);
6289
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6290
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
6291
], TerrainMaterial.prototype, "disableLighting", void 0);
6292
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6293
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
6294
], TerrainMaterial.prototype, "_maxSimultaneousLights", void 0);
6295
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6296
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
6297
], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
6298
return TerrainMaterial;
6299
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
6300
6301
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.TerrainMaterial"] = TerrainMaterial;
6302
6303
6304
/***/ }),
6305
6306
/***/ "./triPlanar/index.ts":
6307
/*!****************************!*\
6308
!*** ./triPlanar/index.ts ***!
6309
\****************************/
6310
/*! exports provided: TriPlanarMaterial */
6311
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6312
6313
"use strict";
6314
__webpack_require__.r(__webpack_exports__);
6315
/* harmony import */ var _triPlanarMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./triPlanarMaterial */ "./triPlanar/triPlanarMaterial.ts");
6316
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TriPlanarMaterial", function() { return _triPlanarMaterial__WEBPACK_IMPORTED_MODULE_0__["TriPlanarMaterial"]; });
6317
6318
6319
6320
6321
/***/ }),
6322
6323
/***/ "./triPlanar/triPlanarMaterial.ts":
6324
/*!****************************************!*\
6325
!*** ./triPlanar/triPlanarMaterial.ts ***!
6326
\****************************************/
6327
/*! exports provided: TriPlanarMaterial */
6328
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6329
6330
"use strict";
6331
__webpack_require__.r(__webpack_exports__);
6332
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TriPlanarMaterial", function() { return TriPlanarMaterial; });
6333
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
6334
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
6335
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
6336
/* harmony import */ var _triplanar_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./triplanar.fragment */ "./triPlanar/triplanar.fragment.ts");
6337
/* harmony import */ var _triplanar_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./triplanar.vertex */ "./triPlanar/triplanar.vertex.ts");
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
var TriPlanarMaterialDefines = /** @class */ (function (_super) {
6352
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TriPlanarMaterialDefines, _super);
6353
function TriPlanarMaterialDefines() {
6354
var _this = _super.call(this) || this;
6355
_this.DIFFUSEX = false;
6356
_this.DIFFUSEY = false;
6357
_this.DIFFUSEZ = false;
6358
_this.BUMPX = false;
6359
_this.BUMPY = false;
6360
_this.BUMPZ = false;
6361
_this.CLIPPLANE = false;
6362
_this.CLIPPLANE2 = false;
6363
_this.CLIPPLANE3 = false;
6364
_this.CLIPPLANE4 = false;
6365
_this.CLIPPLANE5 = false;
6366
_this.CLIPPLANE6 = false;
6367
_this.ALPHATEST = false;
6368
_this.DEPTHPREPASS = false;
6369
_this.POINTSIZE = false;
6370
_this.FOG = false;
6371
_this.SPECULARTERM = false;
6372
_this.NORMAL = false;
6373
_this.VERTEXCOLOR = false;
6374
_this.VERTEXALPHA = false;
6375
_this.NUM_BONE_INFLUENCERS = 0;
6376
_this.BonesPerMesh = 0;
6377
_this.INSTANCES = false;
6378
_this.IMAGEPROCESSINGPOSTPROCESS = false;
6379
_this.rebuild();
6380
return _this;
6381
}
6382
return TriPlanarMaterialDefines;
6383
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
6384
var TriPlanarMaterial = /** @class */ (function (_super) {
6385
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TriPlanarMaterial, _super);
6386
function TriPlanarMaterial(name, scene) {
6387
var _this = _super.call(this, name, scene) || this;
6388
_this.tileSize = 1;
6389
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
6390
_this.specularColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.2, 0.2, 0.2);
6391
_this.specularPower = 64;
6392
_this._disableLighting = false;
6393
_this._maxSimultaneousLights = 4;
6394
return _this;
6395
}
6396
TriPlanarMaterial.prototype.needAlphaBlending = function () {
6397
return (this.alpha < 1.0);
6398
};
6399
TriPlanarMaterial.prototype.needAlphaTesting = function () {
6400
return false;
6401
};
6402
TriPlanarMaterial.prototype.getAlphaTestTexture = function () {
6403
return null;
6404
};
6405
// Methods
6406
TriPlanarMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
6407
if (this.isFrozen) {
6408
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
6409
return true;
6410
}
6411
}
6412
if (!subMesh._materialDefines) {
6413
subMesh.materialDefines = new TriPlanarMaterialDefines();
6414
}
6415
var defines = subMesh._materialDefines;
6416
var scene = this.getScene();
6417
if (this._isReadyForSubMesh(subMesh)) {
6418
return true;
6419
}
6420
var engine = scene.getEngine();
6421
// Textures
6422
if (defines._areTexturesDirty) {
6423
if (scene.texturesEnabled) {
6424
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].DiffuseTextureEnabled) {
6425
var textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];
6426
var textureDefines = ["DIFFUSEX", "DIFFUSEY", "DIFFUSEZ"];
6427
for (var i = 0; i < textures.length; i++) {
6428
if (textures[i]) {
6429
if (!textures[i].isReady()) {
6430
return false;
6431
}
6432
else {
6433
defines[textureDefines[i]] = true;
6434
}
6435
}
6436
}
6437
}
6438
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].BumpTextureEnabled) {
6439
var textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];
6440
var textureDefines = ["BUMPX", "BUMPY", "BUMPZ"];
6441
for (var i = 0; i < textures.length; i++) {
6442
if (textures[i]) {
6443
if (!textures[i].isReady()) {
6444
return false;
6445
}
6446
else {
6447
defines[textureDefines[i]] = true;
6448
}
6449
}
6450
}
6451
}
6452
}
6453
}
6454
// Misc.
6455
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
6456
// Lights
6457
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
6458
// Values that need to be evaluated on every frame
6459
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
6460
// Attribs
6461
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
6462
// Get correct effect
6463
if (defines.isDirty) {
6464
defines.markAsProcessed();
6465
scene.resetCachedMaterial();
6466
// Fallbacks
6467
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
6468
if (defines.FOG) {
6469
fallbacks.addFallback(1, "FOG");
6470
}
6471
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
6472
if (defines.NUM_BONE_INFLUENCERS > 0) {
6473
fallbacks.addCPUSkinningFallback(0, mesh);
6474
}
6475
defines.IMAGEPROCESSINGPOSTPROCESS = scene.imageProcessingConfiguration.applyByPostProcess;
6476
//Attributes
6477
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
6478
if (defines.NORMAL) {
6479
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
6480
}
6481
if (defines.VERTEXCOLOR) {
6482
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
6483
}
6484
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
6485
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
6486
// Legacy browser patch
6487
var shaderName = "triplanar";
6488
var join = defines.toString();
6489
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
6490
"vFogInfos", "vFogColor", "pointSize",
6491
"mBones",
6492
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
6493
"tileSize"
6494
];
6495
var samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ",
6496
"normalSamplerX", "normalSamplerY", "normalSamplerZ"
6497
];
6498
var uniformBuffers = new Array();
6499
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
6500
uniformsNames: uniforms,
6501
uniformBuffersNames: uniformBuffers,
6502
samplers: samplers,
6503
defines: defines,
6504
maxSimultaneousLights: this.maxSimultaneousLights
6505
});
6506
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
6507
attributes: attribs,
6508
uniformsNames: uniforms,
6509
uniformBuffersNames: uniformBuffers,
6510
samplers: samplers,
6511
defines: join,
6512
fallbacks: fallbacks,
6513
onCompiled: this.onCompiled,
6514
onError: this.onError,
6515
indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
6516
}, engine), defines, this._materialContext);
6517
}
6518
if (!subMesh.effect || !subMesh.effect.isReady()) {
6519
return false;
6520
}
6521
defines._renderId = scene.getRenderId();
6522
subMesh.effect._wasPreviouslyReady = true;
6523
return true;
6524
};
6525
TriPlanarMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
6526
var scene = this.getScene();
6527
var defines = subMesh._materialDefines;
6528
if (!defines) {
6529
return;
6530
}
6531
var effect = subMesh.effect;
6532
if (!effect) {
6533
return;
6534
}
6535
this._activeEffect = effect;
6536
// Matrices
6537
this.bindOnlyWorldMatrix(world);
6538
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
6539
// Bones
6540
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
6541
this._activeEffect.setFloat("tileSize", this.tileSize);
6542
if (scene.getCachedMaterial() !== this) {
6543
// Textures
6544
if (this.diffuseTextureX) {
6545
this._activeEffect.setTexture("diffuseSamplerX", this.diffuseTextureX);
6546
}
6547
if (this.diffuseTextureY) {
6548
this._activeEffect.setTexture("diffuseSamplerY", this.diffuseTextureY);
6549
}
6550
if (this.diffuseTextureZ) {
6551
this._activeEffect.setTexture("diffuseSamplerZ", this.diffuseTextureZ);
6552
}
6553
if (this.normalTextureX) {
6554
this._activeEffect.setTexture("normalSamplerX", this.normalTextureX);
6555
}
6556
if (this.normalTextureY) {
6557
this._activeEffect.setTexture("normalSamplerY", this.normalTextureY);
6558
}
6559
if (this.normalTextureZ) {
6560
this._activeEffect.setTexture("normalSamplerZ", this.normalTextureZ);
6561
}
6562
// Clip plane
6563
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
6564
// Point size
6565
if (this.pointsCloud) {
6566
this._activeEffect.setFloat("pointSize", this.pointSize);
6567
}
6568
scene.bindEyePosition(effect);
6569
}
6570
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
6571
if (defines.SPECULARTERM) {
6572
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
6573
}
6574
if (scene.lightsEnabled && !this.disableLighting) {
6575
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
6576
}
6577
// View
6578
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
6579
this._activeEffect.setMatrix("view", scene.getViewMatrix());
6580
}
6581
// Fog
6582
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
6583
this._afterBind(mesh, this._activeEffect);
6584
};
6585
TriPlanarMaterial.prototype.getAnimatables = function () {
6586
var results = [];
6587
if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
6588
results.push(this.mixTexture);
6589
}
6590
return results;
6591
};
6592
TriPlanarMaterial.prototype.getActiveTextures = function () {
6593
var activeTextures = _super.prototype.getActiveTextures.call(this);
6594
if (this._diffuseTextureX) {
6595
activeTextures.push(this._diffuseTextureX);
6596
}
6597
if (this._diffuseTextureY) {
6598
activeTextures.push(this._diffuseTextureY);
6599
}
6600
if (this._diffuseTextureZ) {
6601
activeTextures.push(this._diffuseTextureZ);
6602
}
6603
if (this._normalTextureX) {
6604
activeTextures.push(this._normalTextureX);
6605
}
6606
if (this._normalTextureY) {
6607
activeTextures.push(this._normalTextureY);
6608
}
6609
if (this._normalTextureZ) {
6610
activeTextures.push(this._normalTextureZ);
6611
}
6612
return activeTextures;
6613
};
6614
TriPlanarMaterial.prototype.hasTexture = function (texture) {
6615
if (_super.prototype.hasTexture.call(this, texture)) {
6616
return true;
6617
}
6618
if (this._diffuseTextureX === texture) {
6619
return true;
6620
}
6621
if (this._diffuseTextureY === texture) {
6622
return true;
6623
}
6624
if (this._diffuseTextureZ === texture) {
6625
return true;
6626
}
6627
if (this._normalTextureX === texture) {
6628
return true;
6629
}
6630
if (this._normalTextureY === texture) {
6631
return true;
6632
}
6633
if (this._normalTextureZ === texture) {
6634
return true;
6635
}
6636
return false;
6637
};
6638
TriPlanarMaterial.prototype.dispose = function (forceDisposeEffect) {
6639
if (this.mixTexture) {
6640
this.mixTexture.dispose();
6641
}
6642
_super.prototype.dispose.call(this, forceDisposeEffect);
6643
};
6644
TriPlanarMaterial.prototype.clone = function (name) {
6645
var _this = this;
6646
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TriPlanarMaterial(name, _this.getScene()); }, this);
6647
};
6648
TriPlanarMaterial.prototype.serialize = function () {
6649
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
6650
serializationObject.customType = "BABYLON.TriPlanarMaterial";
6651
return serializationObject;
6652
};
6653
TriPlanarMaterial.prototype.getClassName = function () {
6654
return "TriPlanarMaterial";
6655
};
6656
// Statics
6657
TriPlanarMaterial.Parse = function (source, scene, rootUrl) {
6658
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TriPlanarMaterial(source.name, scene); }, source, scene, rootUrl);
6659
};
6660
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6661
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
6662
], TriPlanarMaterial.prototype, "mixTexture", void 0);
6663
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6664
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTextureX")
6665
], TriPlanarMaterial.prototype, "_diffuseTextureX", void 0);
6666
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6667
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6668
], TriPlanarMaterial.prototype, "diffuseTextureX", void 0);
6669
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6670
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexturY")
6671
], TriPlanarMaterial.prototype, "_diffuseTextureY", void 0);
6672
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6673
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6674
], TriPlanarMaterial.prototype, "diffuseTextureY", void 0);
6675
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6676
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTextureZ")
6677
], TriPlanarMaterial.prototype, "_diffuseTextureZ", void 0);
6678
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6679
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6680
], TriPlanarMaterial.prototype, "diffuseTextureZ", void 0);
6681
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6682
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("normalTextureX")
6683
], TriPlanarMaterial.prototype, "_normalTextureX", void 0);
6684
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6685
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6686
], TriPlanarMaterial.prototype, "normalTextureX", void 0);
6687
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6688
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("normalTextureY")
6689
], TriPlanarMaterial.prototype, "_normalTextureY", void 0);
6690
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6691
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6692
], TriPlanarMaterial.prototype, "normalTextureY", void 0);
6693
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6694
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("normalTextureZ")
6695
], TriPlanarMaterial.prototype, "_normalTextureZ", void 0);
6696
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6697
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
6698
], TriPlanarMaterial.prototype, "normalTextureZ", void 0);
6699
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6700
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
6701
], TriPlanarMaterial.prototype, "tileSize", void 0);
6702
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6703
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
6704
], TriPlanarMaterial.prototype, "diffuseColor", void 0);
6705
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6706
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
6707
], TriPlanarMaterial.prototype, "specularColor", void 0);
6708
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6709
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
6710
], TriPlanarMaterial.prototype, "specularPower", void 0);
6711
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6712
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
6713
], TriPlanarMaterial.prototype, "_disableLighting", void 0);
6714
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6715
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
6716
], TriPlanarMaterial.prototype, "disableLighting", void 0);
6717
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6718
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
6719
], TriPlanarMaterial.prototype, "_maxSimultaneousLights", void 0);
6720
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
6721
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
6722
], TriPlanarMaterial.prototype, "maxSimultaneousLights", void 0);
6723
return TriPlanarMaterial;
6724
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
6725
6726
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.TriPlanarMaterial"] = TriPlanarMaterial;
6727
6728
6729
/***/ }),
6730
6731
/***/ "./triPlanar/triplanar.fragment.ts":
6732
/*!*****************************************!*\
6733
!*** ./triPlanar/triplanar.fragment.ts ***!
6734
\*****************************************/
6735
/*! exports provided: triplanarPixelShader */
6736
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6737
6738
"use strict";
6739
__webpack_require__.r(__webpack_exports__);
6740
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "triplanarPixelShader", function() { return triplanarPixelShader; });
6741
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
6742
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
var name = 'triplanarPixelShader';
6757
var shader = "precision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";
6758
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
6759
/** @hidden */
6760
var triplanarPixelShader = { name: name, shader: shader };
6761
6762
6763
/***/ }),
6764
6765
/***/ "./triPlanar/triplanar.vertex.ts":
6766
/*!***************************************!*\
6767
!*** ./triPlanar/triplanar.vertex.ts ***!
6768
\***************************************/
6769
/*! exports provided: triplanarVertexShader */
6770
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6771
6772
"use strict";
6773
__webpack_require__.r(__webpack_exports__);
6774
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "triplanarVertexShader", function() { return triplanarVertexShader; });
6775
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
6776
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
var name = 'triplanarVertexShader';
6790
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,0.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,0.0)).xyz;\nvec3 worldNormal=(world*vec4(normalize(normal),0.0)).xyz;\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
6791
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
6792
/** @hidden */
6793
var triplanarVertexShader = { name: name, shader: shader };
6794
6795
6796
/***/ }),
6797
6798
/***/ "./water/index.ts":
6799
/*!************************!*\
6800
!*** ./water/index.ts ***!
6801
\************************/
6802
/*! exports provided: WaterMaterial */
6803
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6804
6805
"use strict";
6806
__webpack_require__.r(__webpack_exports__);
6807
/* harmony import */ var _waterMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./waterMaterial */ "./water/waterMaterial.ts");
6808
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WaterMaterial", function() { return _waterMaterial__WEBPACK_IMPORTED_MODULE_0__["WaterMaterial"]; });
6809
6810
6811
6812
6813
/***/ }),
6814
6815
/***/ "./water/water.fragment.ts":
6816
/*!*********************************!*\
6817
!*** ./water/water.fragment.ts ***!
6818
\*********************************/
6819
/*! exports provided: waterPixelShader */
6820
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6821
6822
"use strict";
6823
__webpack_require__.r(__webpack_exports__);
6824
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "waterPixelShader", function() { return waterPixelShader; });
6825
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
6826
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
var name = 'waterPixelShader';
6843
var shader = "#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform sampler2D normalSampler;\nuniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;\nuniform sampler2D reflectionSampler;\n\nconst float LOG2=1.442695;\nuniform vec3 cameraPosition;\nuniform vec4 waterColor;\nuniform float colorBlendFactor;\nuniform vec4 waterColor2;\nuniform float colorBlendFactor2;\nuniform float bumpHeight;\nuniform float time;\n\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvarying vec3 vPosition;\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef BUMP\n#ifdef BUMPSUPERIMPOSE\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\n#else\nbaseColor=texture2D(normalSampler,vNormalUV);\n#endif\nvec3 bumpColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vNormalInfos.y;\n#else\nvec3 bumpColor=vec3(1.0);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\n#ifdef BUMPAFFECTSREFLECTION\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\nif (normalW.y<0.0) {\nnormalW.y=-normalW.y;\n}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\n\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=clamp(abs(pow(dot(viewDirectionW,upVector),3.0)),0.05,0.65);\nfloat IfresnelTerm=1.0-fresnelTerm;\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\nbaseColor=combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#else\n#ifdef REFLECTION\n\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=max(dot(viewDirectionW,upVector),0.0);\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#elif defined(IMAGEPROCESSING)\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\ngl_FragColor=color;\n}\n";
6844
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
6845
/** @hidden */
6846
var waterPixelShader = { name: name, shader: shader };
6847
6848
6849
/***/ }),
6850
6851
/***/ "./water/water.vertex.ts":
6852
/*!*******************************!*\
6853
!*** ./water/water.vertex.ts ***!
6854
\*******************************/
6855
/*! exports provided: waterVertexShader */
6856
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6857
6858
"use strict";
6859
__webpack_require__.r(__webpack_exports__);
6860
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "waterVertexShader", function() { return waterVertexShader; });
6861
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Engines/shaderStore */ "babylonjs/Misc/decorators");
6862
/* harmony import */ var babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__);
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
var name = 'waterVertexShader';
6878
var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;\nuniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\n\nuniform mat4 worldReflectionViewProjection;\nuniform vec2 windDirection;\nuniform float waveLength;\nuniform float time;\nuniform float windForce;\nuniform float waveHeight;\nuniform float waveSpeed;\nuniform float waveCount;\n\nvarying vec3 vPosition;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef BUMP\nif (vNormalInfos.x == 0.)\n{\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\n#endif\n}\nelse\n{\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\n#endif\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\nfloat finalWaveCount=1.0/(waveCount*0.5);\nvec3 p=position;\nfloat newY=(sin(((p.x/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+(cos(((p.z/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.y*5.0);\np.y+=abs(newY);\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#ifdef REFLECTION\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\n\nvPosition=position;\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvRefractionMapTexCoord.z=worldPos.w;\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n}\n";
6879
babylonjs_Engines_shaderStore__WEBPACK_IMPORTED_MODULE_0__["ShaderStore"].ShadersStore[name] = shader;
6880
/** @hidden */
6881
var waterVertexShader = { name: name, shader: shader };
6882
6883
6884
/***/ }),
6885
6886
/***/ "./water/waterMaterial.ts":
6887
/*!********************************!*\
6888
!*** ./water/waterMaterial.ts ***!
6889
\********************************/
6890
/*! exports provided: WaterMaterial */
6891
/***/ (function(module, __webpack_exports__, __webpack_require__) {
6892
6893
"use strict";
6894
__webpack_require__.r(__webpack_exports__);
6895
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WaterMaterial", function() { return WaterMaterial; });
6896
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
6897
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/decorators");
6898
/* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
6899
/* harmony import */ var _water_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./water.fragment */ "./water/water.fragment.ts");
6900
/* harmony import */ var _water_vertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./water.vertex */ "./water/water.vertex.ts");
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
var WaterMaterialDefines = /** @class */ (function (_super) {
6922
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WaterMaterialDefines, _super);
6923
function WaterMaterialDefines() {
6924
var _this = _super.call(this) || this;
6925
_this.BUMP = false;
6926
_this.REFLECTION = false;
6927
_this.CLIPPLANE = false;
6928
_this.CLIPPLANE2 = false;
6929
_this.CLIPPLANE3 = false;
6930
_this.CLIPPLANE4 = false;
6931
_this.CLIPPLANE5 = false;
6932
_this.CLIPPLANE6 = false;
6933
_this.ALPHATEST = false;
6934
_this.DEPTHPREPASS = false;
6935
_this.POINTSIZE = false;
6936
_this.FOG = false;
6937
_this.NORMAL = false;
6938
_this.UV1 = false;
6939
_this.UV2 = false;
6940
_this.VERTEXCOLOR = false;
6941
_this.VERTEXALPHA = false;
6942
_this.NUM_BONE_INFLUENCERS = 0;
6943
_this.BonesPerMesh = 0;
6944
_this.INSTANCES = false;
6945
_this.SPECULARTERM = false;
6946
_this.LOGARITHMICDEPTH = false;
6947
_this.USE_REVERSE_DEPTHBUFFER = false;
6948
_this.FRESNELSEPARATE = false;
6949
_this.BUMPSUPERIMPOSE = false;
6950
_this.BUMPAFFECTSREFLECTION = false;
6951
_this.IMAGEPROCESSING = false;
6952
_this.VIGNETTE = false;
6953
_this.VIGNETTEBLENDMODEMULTIPLY = false;
6954
_this.VIGNETTEBLENDMODEOPAQUE = false;
6955
_this.TONEMAPPING = false;
6956
_this.TONEMAPPING_ACES = false;
6957
_this.CONTRAST = false;
6958
_this.EXPOSURE = false;
6959
_this.COLORCURVES = false;
6960
_this.COLORGRADING = false;
6961
_this.COLORGRADING3D = false;
6962
_this.SAMPLER3DGREENDEPTH = false;
6963
_this.SAMPLER3DBGRMAP = false;
6964
_this.IMAGEPROCESSINGPOSTPROCESS = false;
6965
_this.rebuild();
6966
return _this;
6967
}
6968
return WaterMaterialDefines;
6969
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
6970
var WaterMaterial = /** @class */ (function (_super) {
6971
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(WaterMaterial, _super);
6972
/**
6973
* Constructor
6974
*/
6975
function WaterMaterial(name, scene, renderTargetSize) {
6976
if (renderTargetSize === void 0) { renderTargetSize = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector2"](512, 512); }
6977
var _this = _super.call(this, name, scene) || this;
6978
_this.renderTargetSize = renderTargetSize;
6979
_this.diffuseColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
6980
_this.specularColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0, 0, 0);
6981
_this.specularPower = 64;
6982
_this._disableLighting = false;
6983
_this._maxSimultaneousLights = 4;
6984
/**
6985
* Defines the wind force.
6986
*/
6987
_this.windForce = 6;
6988
/**
6989
* Defines the direction of the wind in the plane (X, Z).
6990
*/
6991
_this.windDirection = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 1);
6992
/**
6993
* Defines the height of the waves.
6994
*/
6995
_this.waveHeight = 0.4;
6996
/**
6997
* Defines the bump height related to the bump map.
6998
*/
6999
_this.bumpHeight = 0.4;
7000
/**
7001
* Defines wether or not: to add a smaller moving bump to less steady waves.
7002
*/
7003
_this._bumpSuperimpose = false;
7004
/**
7005
* Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
7006
*/
7007
_this._fresnelSeparate = false;
7008
/**
7009
* Defines wether or not bump Wwves modify the reflection.
7010
*/
7011
_this._bumpAffectsReflection = false;
7012
/**
7013
* Defines the water color blended with the refraction (near).
7014
*/
7015
_this.waterColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.6);
7016
/**
7017
* Defines the blend factor related to the water color.
7018
*/
7019
_this.colorBlendFactor = 0.2;
7020
/**
7021
* Defines the water color blended with the reflection (far).
7022
*/
7023
_this.waterColor2 = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.6);
7024
/**
7025
* Defines the blend factor related to the water color (reflection, far).
7026
*/
7027
_this.colorBlendFactor2 = 0.2;
7028
/**
7029
* Defines the maximum length of a wave.
7030
*/
7031
_this.waveLength = 0.1;
7032
/**
7033
* Defines the waves speed.
7034
*/
7035
_this.waveSpeed = 1.0;
7036
/**
7037
* 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.
7038
*/
7039
_this.waveCount = 20;
7040
/**
7041
* Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
7042
* will avoid calculating useless pixels in the pixel shader of the water material.
7043
*/
7044
_this.disableClipPlane = false;
7045
_this._renderTargets = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](16);
7046
/*
7047
* Private members
7048
*/
7049
_this._mesh = null;
7050
_this._reflectionTransform = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
7051
_this._lastTime = 0;
7052
_this._lastDeltaTime = 0;
7053
_this._createRenderTargets(scene, renderTargetSize);
7054
// Create render targets
7055
_this.getRenderTargetTextures = function () {
7056
_this._renderTargets.reset();
7057
_this._renderTargets.push(_this._reflectionRTT);
7058
_this._renderTargets.push(_this._refractionRTT);
7059
return _this._renderTargets;
7060
};
7061
_this._imageProcessingConfiguration = _this.getScene().imageProcessingConfiguration;
7062
if (_this._imageProcessingConfiguration) {
7063
_this._imageProcessingObserver = _this._imageProcessingConfiguration.onUpdateParameters.add(function () {
7064
_this._markAllSubMeshesAsImageProcessingDirty();
7065
});
7066
}
7067
return _this;
7068
}
7069
Object.defineProperty(WaterMaterial.prototype, "hasRenderTargetTextures", {
7070
/**
7071
* Gets a boolean indicating that current material needs to register RTT
7072
*/
7073
get: function () {
7074
return true;
7075
},
7076
enumerable: false,
7077
configurable: true
7078
});
7079
Object.defineProperty(WaterMaterial.prototype, "useLogarithmicDepth", {
7080
get: function () {
7081
return this._useLogarithmicDepth;
7082
},
7083
set: function (value) {
7084
this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
7085
this._markAllSubMeshesAsMiscDirty();
7086
},
7087
enumerable: false,
7088
configurable: true
7089
});
7090
Object.defineProperty(WaterMaterial.prototype, "refractionTexture", {
7091
// Get / Set
7092
get: function () {
7093
return this._refractionRTT;
7094
},
7095
enumerable: false,
7096
configurable: true
7097
});
7098
Object.defineProperty(WaterMaterial.prototype, "reflectionTexture", {
7099
get: function () {
7100
return this._reflectionRTT;
7101
},
7102
enumerable: false,
7103
configurable: true
7104
});
7105
// Methods
7106
WaterMaterial.prototype.addToRenderList = function (node) {
7107
if (this._refractionRTT && this._refractionRTT.renderList) {
7108
this._refractionRTT.renderList.push(node);
7109
}
7110
if (this._reflectionRTT && this._reflectionRTT.renderList) {
7111
this._reflectionRTT.renderList.push(node);
7112
}
7113
};
7114
WaterMaterial.prototype.enableRenderTargets = function (enable) {
7115
var refreshRate = enable ? 1 : 0;
7116
if (this._refractionRTT) {
7117
this._refractionRTT.refreshRate = refreshRate;
7118
}
7119
if (this._reflectionRTT) {
7120
this._reflectionRTT.refreshRate = refreshRate;
7121
}
7122
};
7123
WaterMaterial.prototype.getRenderList = function () {
7124
return this._refractionRTT ? this._refractionRTT.renderList : [];
7125
};
7126
Object.defineProperty(WaterMaterial.prototype, "renderTargetsEnabled", {
7127
get: function () {
7128
return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
7129
},
7130
enumerable: false,
7131
configurable: true
7132
});
7133
WaterMaterial.prototype.needAlphaBlending = function () {
7134
return (this.alpha < 1.0);
7135
};
7136
WaterMaterial.prototype.needAlphaTesting = function () {
7137
return false;
7138
};
7139
WaterMaterial.prototype.getAlphaTestTexture = function () {
7140
return null;
7141
};
7142
WaterMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
7143
if (this.isFrozen) {
7144
if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
7145
return true;
7146
}
7147
}
7148
if (!subMesh._materialDefines) {
7149
subMesh.materialDefines = new WaterMaterialDefines();
7150
}
7151
var defines = subMesh._materialDefines;
7152
var scene = this.getScene();
7153
if (this._isReadyForSubMesh(subMesh)) {
7154
return true;
7155
}
7156
var engine = scene.getEngine();
7157
// Textures
7158
if (defines._areTexturesDirty) {
7159
defines._needUVs = false;
7160
if (scene.texturesEnabled) {
7161
if (this.bumpTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].BumpTextureEnabled) {
7162
if (!this.bumpTexture.isReady()) {
7163
return false;
7164
}
7165
else {
7166
defines._needUVs = true;
7167
defines.BUMP = true;
7168
}
7169
}
7170
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].ReflectionTextureEnabled) {
7171
defines.REFLECTION = true;
7172
}
7173
}
7174
}
7175
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
7176
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
7177
if (defines._areMiscDirty) {
7178
if (this._fresnelSeparate) {
7179
defines.FRESNELSEPARATE = true;
7180
}
7181
if (this._bumpSuperimpose) {
7182
defines.BUMPSUPERIMPOSE = true;
7183
}
7184
if (this._bumpAffectsReflection) {
7185
defines.BUMPAFFECTSREFLECTION = true;
7186
}
7187
}
7188
// Lights
7189
defines._needNormals = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
7190
// Image processing
7191
if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
7192
if (!this._imageProcessingConfiguration.isReady()) {
7193
return false;
7194
}
7195
this._imageProcessingConfiguration.prepareDefines(defines);
7196
defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
7197
defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
7198
}
7199
// Attribs
7200
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true);
7201
// Configure this
7202
this._mesh = mesh;
7203
if (this._waitingRenderList) {
7204
for (var i = 0; i < this._waitingRenderList.length; i++) {
7205
this.addToRenderList(scene.getNodeById(this._waitingRenderList[i]));
7206
}
7207
this._waitingRenderList = null;
7208
}
7209
// Get correct effect
7210
if (defines.isDirty) {
7211
defines.markAsProcessed();
7212
scene.resetCachedMaterial();
7213
// Fallbacks
7214
var fallbacks = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["EffectFallbacks"]();
7215
if (defines.FOG) {
7216
fallbacks.addFallback(1, "FOG");
7217
}
7218
if (defines.LOGARITHMICDEPTH) {
7219
fallbacks.addFallback(0, "LOGARITHMICDEPTH");
7220
}
7221
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
7222
if (defines.NUM_BONE_INFLUENCERS > 0) {
7223
fallbacks.addCPUSkinningFallback(0, mesh);
7224
}
7225
//Attributes
7226
var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
7227
if (defines.NORMAL) {
7228
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
7229
}
7230
if (defines.UV1) {
7231
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
7232
}
7233
if (defines.UV2) {
7234
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
7235
}
7236
if (defines.VERTEXCOLOR) {
7237
attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
7238
}
7239
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
7240
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
7241
// Legacy browser patch
7242
var shaderName = "water";
7243
var join = defines.toString();
7244
var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
7245
"vFogInfos", "vFogColor", "pointSize",
7246
"vNormalInfos",
7247
"mBones",
7248
"vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "normalMatrix",
7249
"logarithmicDepthConstant",
7250
// Water
7251
"worldReflectionViewProjection", "windDirection", "waveLength", "time", "windForce",
7252
"cameraPosition", "bumpHeight", "waveHeight", "waterColor", "waterColor2", "colorBlendFactor", "colorBlendFactor2", "waveSpeed",
7253
"waveCount"
7254
];
7255
var samplers = ["normalSampler",
7256
// Water
7257
"refractionSampler", "reflectionSampler"
7258
];
7259
var uniformBuffers = new Array();
7260
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfiguration"]) {
7261
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
7262
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
7263
}
7264
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
7265
uniformsNames: uniforms,
7266
uniformBuffersNames: uniformBuffers,
7267
samplers: samplers,
7268
defines: defines,
7269
maxSimultaneousLights: this.maxSimultaneousLights
7270
});
7271
subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
7272
attributes: attribs,
7273
uniformsNames: uniforms,
7274
uniformBuffersNames: uniformBuffers,
7275
samplers: samplers,
7276
defines: join,
7277
fallbacks: fallbacks,
7278
onCompiled: this.onCompiled,
7279
onError: this.onError,
7280
indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
7281
}, engine), defines, this._materialContext);
7282
}
7283
if (!subMesh.effect || !subMesh.effect.isReady()) {
7284
return false;
7285
}
7286
defines._renderId = scene.getRenderId();
7287
subMesh.effect._wasPreviouslyReady = true;
7288
return true;
7289
};
7290
WaterMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
7291
var scene = this.getScene();
7292
var defines = subMesh._materialDefines;
7293
if (!defines) {
7294
return;
7295
}
7296
var effect = subMesh.effect;
7297
if (!effect || !this._mesh) {
7298
return;
7299
}
7300
this._activeEffect = effect;
7301
// Matrices
7302
this.bindOnlyWorldMatrix(world);
7303
this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
7304
// Bones
7305
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
7306
if (this._mustRebind(scene, effect)) {
7307
// Textures
7308
if (this.bumpTexture && babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].BumpTextureEnabled) {
7309
this._activeEffect.setTexture("normalSampler", this.bumpTexture);
7310
this._activeEffect.setFloat2("vNormalInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
7311
this._activeEffect.setMatrix("normalMatrix", this.bumpTexture.getTextureMatrix());
7312
}
7313
// Clip plane
7314
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
7315
// Point size
7316
if (this.pointsCloud) {
7317
this._activeEffect.setFloat("pointSize", this.pointSize);
7318
}
7319
scene.bindEyePosition(effect);
7320
}
7321
this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
7322
if (defines.SPECULARTERM) {
7323
this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
7324
}
7325
if (scene.lightsEnabled && !this.disableLighting) {
7326
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
7327
}
7328
// View
7329
if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
7330
this._activeEffect.setMatrix("view", scene.getViewMatrix());
7331
}
7332
// Fog
7333
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect);
7334
// Log. depth
7335
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
7336
// Water
7337
if (babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialFlags"].ReflectionTextureEnabled) {
7338
this._activeEffect.setTexture("refractionSampler", this._refractionRTT);
7339
this._activeEffect.setTexture("reflectionSampler", this._reflectionRTT);
7340
}
7341
var wrvp = this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(scene.getProjectionMatrix());
7342
// Add delta time. Prevent adding delta time if it hasn't changed.
7343
var deltaTime = scene.getEngine().getDeltaTime();
7344
if (deltaTime !== this._lastDeltaTime) {
7345
this._lastDeltaTime = deltaTime;
7346
this._lastTime += this._lastDeltaTime;
7347
}
7348
this._activeEffect.setMatrix("worldReflectionViewProjection", wrvp);
7349
this._activeEffect.setVector2("windDirection", this.windDirection);
7350
this._activeEffect.setFloat("waveLength", this.waveLength);
7351
this._activeEffect.setFloat("time", this._lastTime / 100000);
7352
this._activeEffect.setFloat("windForce", this.windForce);
7353
this._activeEffect.setFloat("waveHeight", this.waveHeight);
7354
this._activeEffect.setFloat("bumpHeight", this.bumpHeight);
7355
this._activeEffect.setColor4("waterColor", this.waterColor, 1.0);
7356
this._activeEffect.setFloat("colorBlendFactor", this.colorBlendFactor);
7357
this._activeEffect.setColor4("waterColor2", this.waterColor2, 1.0);
7358
this._activeEffect.setFloat("colorBlendFactor2", this.colorBlendFactor2);
7359
this._activeEffect.setFloat("waveSpeed", this.waveSpeed);
7360
this._activeEffect.setFloat("waveCount", this.waveCount);
7361
// image processing
7362
if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
7363
this._imageProcessingConfiguration.bind(this._activeEffect);
7364
}
7365
this._afterBind(mesh, this._activeEffect);
7366
};
7367
WaterMaterial.prototype._createRenderTargets = function (scene, renderTargetSize) {
7368
var _this = this;
7369
// Render targets
7370
this._refractionRTT = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"](name + "_refraction", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
7371
this._refractionRTT.wrapU = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
7372
this._refractionRTT.wrapV = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
7373
this._refractionRTT.ignoreCameraViewport = true;
7374
this._reflectionRTT = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"](name + "_reflection", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
7375
this._reflectionRTT.wrapU = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
7376
this._reflectionRTT.wrapV = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
7377
this._reflectionRTT.ignoreCameraViewport = true;
7378
var isVisible;
7379
var clipPlane = null;
7380
var savedViewMatrix;
7381
var mirrorMatrix = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
7382
this._refractionRTT.onBeforeRender = function () {
7383
if (_this._mesh) {
7384
isVisible = _this._mesh.isVisible;
7385
_this._mesh.isVisible = false;
7386
}
7387
// Clip plane
7388
if (!_this.disableClipPlane) {
7389
clipPlane = scene.clipPlane;
7390
var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
7391
scene.clipPlane = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Plane"].FromPositionAndNormal(new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, positiony + 0.05, 0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0));
7392
}
7393
};
7394
this._refractionRTT.onAfterRender = function () {
7395
if (_this._mesh) {
7396
_this._mesh.isVisible = isVisible;
7397
}
7398
// Clip plane
7399
if (!_this.disableClipPlane) {
7400
scene.clipPlane = clipPlane;
7401
}
7402
};
7403
this._reflectionRTT.onBeforeRender = function () {
7404
if (_this._mesh) {
7405
isVisible = _this._mesh.isVisible;
7406
_this._mesh.isVisible = false;
7407
}
7408
// Clip plane
7409
if (!_this.disableClipPlane) {
7410
clipPlane = scene.clipPlane;
7411
var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
7412
scene.clipPlane = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Plane"].FromPositionAndNormal(new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, positiony - 0.05, 0), new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, -1, 0));
7413
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(scene.clipPlane, mirrorMatrix);
7414
}
7415
// Transform
7416
savedViewMatrix = scene.getViewMatrix();
7417
mirrorMatrix.multiplyToRef(savedViewMatrix, _this._reflectionTransform);
7418
scene.setTransformMatrix(_this._reflectionTransform, scene.getProjectionMatrix());
7419
scene.getEngine().cullBackFaces = false;
7420
scene._mirroredCameraPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.position, mirrorMatrix);
7421
};
7422
this._reflectionRTT.onAfterRender = function () {
7423
if (_this._mesh) {
7424
_this._mesh.isVisible = isVisible;
7425
}
7426
// Clip plane
7427
scene.clipPlane = clipPlane;
7428
// Transform
7429
scene.setTransformMatrix(savedViewMatrix, scene.getProjectionMatrix());
7430
scene.getEngine().cullBackFaces = null;
7431
scene._mirroredCameraPosition = null;
7432
};
7433
};
7434
WaterMaterial.prototype.getAnimatables = function () {
7435
var results = [];
7436
if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
7437
results.push(this.bumpTexture);
7438
}
7439
if (this._reflectionRTT && this._reflectionRTT.animations && this._reflectionRTT.animations.length > 0) {
7440
results.push(this._reflectionRTT);
7441
}
7442
if (this._refractionRTT && this._refractionRTT.animations && this._refractionRTT.animations.length > 0) {
7443
results.push(this._refractionRTT);
7444
}
7445
return results;
7446
};
7447
WaterMaterial.prototype.getActiveTextures = function () {
7448
var activeTextures = _super.prototype.getActiveTextures.call(this);
7449
if (this._bumpTexture) {
7450
activeTextures.push(this._bumpTexture);
7451
}
7452
return activeTextures;
7453
};
7454
WaterMaterial.prototype.hasTexture = function (texture) {
7455
if (_super.prototype.hasTexture.call(this, texture)) {
7456
return true;
7457
}
7458
if (this._bumpTexture === texture) {
7459
return true;
7460
}
7461
return false;
7462
};
7463
WaterMaterial.prototype.dispose = function (forceDisposeEffect) {
7464
if (this.bumpTexture) {
7465
this.bumpTexture.dispose();
7466
}
7467
var index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
7468
if (index != -1) {
7469
this.getScene().customRenderTargets.splice(index, 1);
7470
}
7471
index = -1;
7472
index = this.getScene().customRenderTargets.indexOf(this._reflectionRTT);
7473
if (index != -1) {
7474
this.getScene().customRenderTargets.splice(index, 1);
7475
}
7476
if (this._reflectionRTT) {
7477
this._reflectionRTT.dispose();
7478
}
7479
if (this._refractionRTT) {
7480
this._refractionRTT.dispose();
7481
}
7482
// Remove image-processing observer
7483
if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
7484
this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
7485
}
7486
_super.prototype.dispose.call(this, forceDisposeEffect);
7487
};
7488
WaterMaterial.prototype.clone = function (name) {
7489
var _this = this;
7490
return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new WaterMaterial(name, _this.getScene()); }, this);
7491
};
7492
WaterMaterial.prototype.serialize = function () {
7493
var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
7494
serializationObject.customType = "BABYLON.WaterMaterial";
7495
serializationObject.renderList = [];
7496
if (this._refractionRTT && this._refractionRTT.renderList) {
7497
for (var i = 0; i < this._refractionRTT.renderList.length; i++) {
7498
serializationObject.renderList.push(this._refractionRTT.renderList[i].id);
7499
}
7500
}
7501
return serializationObject;
7502
};
7503
WaterMaterial.prototype.getClassName = function () {
7504
return "WaterMaterial";
7505
};
7506
// Statics
7507
WaterMaterial.Parse = function (source, scene, rootUrl) {
7508
var mat = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new WaterMaterial(source.name, scene); }, source, scene, rootUrl);
7509
mat._waitingRenderList = source.renderList;
7510
return mat;
7511
};
7512
WaterMaterial.CreateDefaultMesh = function (name, scene) {
7513
var mesh = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround(name, 512, 512, 32, scene, false);
7514
return mesh;
7515
};
7516
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7517
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
7518
], WaterMaterial.prototype, "_bumpTexture", void 0);
7519
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7520
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
7521
], WaterMaterial.prototype, "bumpTexture", void 0);
7522
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7523
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
7524
], WaterMaterial.prototype, "diffuseColor", void 0);
7525
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7526
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
7527
], WaterMaterial.prototype, "specularColor", void 0);
7528
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7529
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7530
], WaterMaterial.prototype, "specularPower", void 0);
7531
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7532
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
7533
], WaterMaterial.prototype, "_disableLighting", void 0);
7534
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7535
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
7536
], WaterMaterial.prototype, "disableLighting", void 0);
7537
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7538
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
7539
], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
7540
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7541
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
7542
], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
7543
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7544
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7545
], WaterMaterial.prototype, "windForce", void 0);
7546
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7547
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
7548
], WaterMaterial.prototype, "windDirection", void 0);
7549
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7550
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7551
], WaterMaterial.prototype, "waveHeight", void 0);
7552
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7553
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7554
], WaterMaterial.prototype, "bumpHeight", void 0);
7555
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7556
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("bumpSuperimpose")
7557
], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
7558
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7559
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
7560
], WaterMaterial.prototype, "bumpSuperimpose", void 0);
7561
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7562
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fresnelSeparate")
7563
], WaterMaterial.prototype, "_fresnelSeparate", void 0);
7564
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7565
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
7566
], WaterMaterial.prototype, "fresnelSeparate", void 0);
7567
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7568
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("bumpAffectsReflection")
7569
], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
7570
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7571
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
7572
], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
7573
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7574
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
7575
], WaterMaterial.prototype, "waterColor", void 0);
7576
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7577
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7578
], WaterMaterial.prototype, "colorBlendFactor", void 0);
7579
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7580
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
7581
], WaterMaterial.prototype, "waterColor2", void 0);
7582
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7583
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7584
], WaterMaterial.prototype, "colorBlendFactor2", void 0);
7585
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7586
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7587
], WaterMaterial.prototype, "waveLength", void 0);
7588
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7589
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7590
], WaterMaterial.prototype, "waveSpeed", void 0);
7591
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7592
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7593
], WaterMaterial.prototype, "waveCount", void 0);
7594
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7595
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7596
], WaterMaterial.prototype, "disableClipPlane", void 0);
7597
Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
7598
Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
7599
], WaterMaterial.prototype, "useLogarithmicDepth", null);
7600
return WaterMaterial;
7601
}(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
7602
7603
babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.WaterMaterial"] = WaterMaterial;
7604
7605
7606
/***/ }),
7607
7608
/***/ "babylonjs/Misc/decorators":
7609
/*!****************************************************************************************************!*\
7610
!*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
7611
\****************************************************************************************************/
7612
/*! no static exports found */
7613
/***/ (function(module, exports) {
7614
7615
module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_decorators__;
7616
7617
/***/ })
7618
7619
/******/ });
7620
});
7621
//# sourceMappingURL=babylonjs.materials.js.map
7622