babylon.customMaterial.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  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_Materials_effect__) {
  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-custom.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. 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;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. 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;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, exports) {
  230. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. 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); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. 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; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. 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);
  294. 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); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./custom/customMaterial.ts":
  354. /*!**********************************!*\
  355. !*** ./custom/customMaterial.ts ***!
  356. \**********************************/
  357. /*! exports provided: CustomShaderStructure, ShaderSpecialParts, CustomMaterial */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return CustomShaderStructure; });
  362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return ShaderSpecialParts; });
  363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return CustomMaterial; });
  364. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  365. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Materials/effect");
  366. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__);
  367. var CustomShaderStructure = /** @class */ (function () {
  368. function CustomShaderStructure() {
  369. }
  370. return CustomShaderStructure;
  371. }());
  372. var ShaderSpecialParts = /** @class */ (function () {
  373. function ShaderSpecialParts() {
  374. }
  375. return ShaderSpecialParts;
  376. }());
  377. var CustomMaterial = /** @class */ (function (_super) {
  378. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CustomMaterial, _super);
  379. function CustomMaterial(name, scene) {
  380. var _this = _super.call(this, name, scene) || this;
  381. _this.CustomParts = new ShaderSpecialParts();
  382. _this.customShaderNameResolve = _this.Builder;
  383. _this.FragmentShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["defaultPixelShader"];
  384. _this.VertexShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["defaultVertexShader"];
  385. return _this;
  386. }
  387. CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
  388. if (this._newUniformInstances) {
  389. for (var el in this._newUniformInstances) {
  390. var ea = el.toString().split('-');
  391. if (ea[0] == 'vec2') {
  392. effect.setVector2(ea[1], this._newUniformInstances[el]);
  393. }
  394. else if (ea[0] == 'vec3') {
  395. effect.setVector3(ea[1], this._newUniformInstances[el]);
  396. }
  397. else if (ea[0] == 'vec4') {
  398. effect.setVector4(ea[1], this._newUniformInstances[el]);
  399. }
  400. else if (ea[0] == 'mat4') {
  401. effect.setMatrix(ea[1], this._newUniformInstances[el]);
  402. }
  403. else if (ea[0] == 'float') {
  404. effect.setFloat(ea[1], this._newUniformInstances[el]);
  405. }
  406. }
  407. }
  408. if (this._newSamplerInstances) {
  409. for (var el in this._newSamplerInstances) {
  410. var ea = el.toString().split('-');
  411. if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
  412. effect.setTexture(ea[1], this._newSamplerInstances[el]);
  413. }
  414. }
  415. }
  416. };
  417. CustomMaterial.prototype.ReviewUniform = function (name, arr) {
  418. if (name == "uniform" && this._newUniforms) {
  419. for (var ind = 0; ind < this._newUniforms.length; ind++) {
  420. if (this._customUniform[ind].indexOf('sampler') == -1) {
  421. arr.push(this._newUniforms[ind]);
  422. }
  423. }
  424. }
  425. if (name == "sampler" && this._newUniforms) {
  426. for (var ind = 0; ind < this._newUniforms.length; ind++) {
  427. if (this._customUniform[ind].indexOf('sampler') != -1) {
  428. arr.push(this._newUniforms[ind]);
  429. }
  430. }
  431. }
  432. return arr;
  433. };
  434. CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines, attributes) {
  435. var _this = this;
  436. if (attributes && this._customAttributes && this._customAttributes.length > 0) {
  437. attributes.push.apply(attributes, this._customAttributes);
  438. }
  439. this.ReviewUniform("uniform", uniforms);
  440. this.ReviewUniform("sampler", samplers);
  441. if (this._isCreatedShader) {
  442. return this._createdShaderName;
  443. }
  444. this._isCreatedShader = false;
  445. CustomMaterial.ShaderIndexer++;
  446. var name = "custom_" + CustomMaterial.ShaderIndexer;
  447. var fn_afterBind = this._afterBind.bind(this);
  448. this._afterBind = function (m, e) {
  449. if (!e) {
  450. return;
  451. }
  452. _this.AttachAfterBind(m, e);
  453. try {
  454. fn_afterBind(m, e);
  455. }
  456. catch (e) { }
  457. };
  458. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = this.VertexShader
  459. .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
  460. .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
  461. .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
  462. .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
  463. .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""))
  464. .replace('#define CUSTOM_VERTEX_MAIN_END', (this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : ""));
  465. if (this.CustomParts.Vertex_After_WorldPosComputed) {
  466. 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);
  467. }
  468. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = this.FragmentShader
  469. .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
  470. .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
  471. .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
  472. .replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
  473. .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
  474. .replace('#define CUSTOM_FRAGMENT_BEFORE_LIGHTS', (this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : ""))
  475. .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
  476. if (this.CustomParts.Fragment_Before_Fog) {
  477. 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);
  478. }
  479. this._isCreatedShader = true;
  480. this._createdShaderName = name;
  481. return name;
  482. };
  483. CustomMaterial.prototype.AddUniform = function (name, kind, param) {
  484. if (!this._customUniform) {
  485. this._customUniform = new Array();
  486. this._newUniforms = new Array();
  487. this._newSamplerInstances = {};
  488. this._newUniformInstances = {};
  489. }
  490. if (param) {
  491. if (kind.indexOf("sampler") != -1) {
  492. this._newSamplerInstances[kind + "-" + name] = param;
  493. }
  494. else {
  495. this._newUniformInstances[kind + "-" + name] = param;
  496. }
  497. }
  498. this._customUniform.push("uniform " + kind + " " + name + ";");
  499. this._newUniforms.push(name);
  500. return this;
  501. };
  502. CustomMaterial.prototype.AddAttribute = function (name) {
  503. if (!this._customAttributes) {
  504. this._customAttributes = [];
  505. }
  506. this._customAttributes.push(name);
  507. return this;
  508. };
  509. CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
  510. this.CustomParts.Fragment_Begin = shaderPart;
  511. return this;
  512. };
  513. CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
  514. this.CustomParts.Fragment_Definitions = shaderPart;
  515. return this;
  516. };
  517. CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
  518. this.CustomParts.Fragment_MainBegin = shaderPart;
  519. return this;
  520. };
  521. CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
  522. this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
  523. return this;
  524. };
  525. CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
  526. this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
  527. return this;
  528. };
  529. CustomMaterial.prototype.Fragment_Before_Lights = function (shaderPart) {
  530. this.CustomParts.Fragment_Before_Lights = shaderPart;
  531. return this;
  532. };
  533. CustomMaterial.prototype.Fragment_Before_Fog = function (shaderPart) {
  534. this.CustomParts.Fragment_Before_Fog = shaderPart;
  535. return this;
  536. };
  537. CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
  538. this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
  539. return this;
  540. };
  541. CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
  542. this.CustomParts.Vertex_Begin = shaderPart;
  543. return this;
  544. };
  545. CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
  546. this.CustomParts.Vertex_Definitions = shaderPart;
  547. return this;
  548. };
  549. CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
  550. this.CustomParts.Vertex_MainBegin = shaderPart;
  551. return this;
  552. };
  553. CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
  554. this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
  555. return this;
  556. };
  557. CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
  558. this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
  559. return this;
  560. };
  561. CustomMaterial.prototype.Vertex_After_WorldPosComputed = function (shaderPart) {
  562. this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;
  563. return this;
  564. };
  565. CustomMaterial.prototype.Vertex_MainEnd = function (shaderPart) {
  566. this.CustomParts.Vertex_MainEnd = shaderPart;
  567. return this;
  568. };
  569. CustomMaterial.ShaderIndexer = 1;
  570. return CustomMaterial;
  571. }(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]));
  572. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.CustomMaterial"] = CustomMaterial;
  573. /***/ }),
  574. /***/ "./custom/index.ts":
  575. /*!*************************!*\
  576. !*** ./custom/index.ts ***!
  577. \*************************/
  578. /*! exports provided: CustomShaderStructure, ShaderSpecialParts, CustomMaterial, ShaderAlebdoParts, PBRCustomMaterial */
  579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  580. "use strict";
  581. __webpack_require__.r(__webpack_exports__);
  582. /* harmony import */ var _customMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customMaterial */ "./custom/customMaterial.ts");
  583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["CustomShaderStructure"]; });
  584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["ShaderSpecialParts"]; });
  585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return _customMaterial__WEBPACK_IMPORTED_MODULE_0__["CustomMaterial"]; });
  586. /* harmony import */ var _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrCustomMaterial */ "./custom/pbrCustomMaterial.ts");
  587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__["ShaderAlebdoParts"]; });
  588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return _pbrCustomMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRCustomMaterial"]; });
  589. /***/ }),
  590. /***/ "./custom/pbrCustomMaterial.ts":
  591. /*!*************************************!*\
  592. !*** ./custom/pbrCustomMaterial.ts ***!
  593. \*************************************/
  594. /*! exports provided: ShaderAlebdoParts, PBRCustomMaterial */
  595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  596. "use strict";
  597. __webpack_require__.r(__webpack_exports__);
  598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return ShaderAlebdoParts; });
  599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return PBRCustomMaterial; });
  600. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  601. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Materials/effect");
  602. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__);
  603. var ShaderAlebdoParts = /** @class */ (function () {
  604. function ShaderAlebdoParts() {
  605. }
  606. return ShaderAlebdoParts;
  607. }());
  608. var PBRCustomMaterial = /** @class */ (function (_super) {
  609. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PBRCustomMaterial, _super);
  610. function PBRCustomMaterial(name, scene) {
  611. var _this = _super.call(this, name, scene) || this;
  612. _this.CustomParts = new ShaderAlebdoParts();
  613. _this.customShaderNameResolve = _this.Builder;
  614. _this.FragmentShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["pbrPixelShader"];
  615. _this.VertexShader = babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["pbrVertexShader"];
  616. _this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockAlbedoOpacity"]);
  617. _this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockReflectivity>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockReflectivity"]);
  618. _this.FragmentShader = _this.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g, babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].IncludesShadersStore["pbrBlockFinalColorComposition"]);
  619. return _this;
  620. }
  621. PBRCustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
  622. if (this._newUniformInstances) {
  623. for (var el in this._newUniformInstances) {
  624. var ea = el.toString().split('-');
  625. if (ea[0] == 'vec2') {
  626. effect.setVector2(ea[1], this._newUniformInstances[el]);
  627. }
  628. else if (ea[0] == 'vec3') {
  629. effect.setVector3(ea[1], this._newUniformInstances[el]);
  630. }
  631. else if (ea[0] == 'vec4') {
  632. effect.setVector4(ea[1], this._newUniformInstances[el]);
  633. }
  634. else if (ea[0] == 'mat4') {
  635. effect.setMatrix(ea[1], this._newUniformInstances[el]);
  636. }
  637. else if (ea[0] == 'float') {
  638. effect.setFloat(ea[1], this._newUniformInstances[el]);
  639. }
  640. }
  641. }
  642. if (this._newSamplerInstances) {
  643. for (var el in this._newSamplerInstances) {
  644. var ea = el.toString().split('-');
  645. if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
  646. effect.setTexture(ea[1], this._newSamplerInstances[el]);
  647. }
  648. }
  649. }
  650. };
  651. PBRCustomMaterial.prototype.ReviewUniform = function (name, arr) {
  652. if (name == "uniform" && this._newUniforms) {
  653. for (var ind = 0; ind < this._newUniforms.length; ind++) {
  654. if (this._customUniform[ind].indexOf('sampler') == -1) {
  655. arr.push(this._newUniforms[ind]);
  656. }
  657. }
  658. }
  659. if (name == "sampler" && this._newUniforms) {
  660. for (var ind = 0; ind < this._newUniforms.length; ind++) {
  661. if (this._customUniform[ind].indexOf('sampler') != -1) {
  662. arr.push(this._newUniforms[ind]);
  663. }
  664. }
  665. }
  666. return arr;
  667. };
  668. PBRCustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines, attributes) {
  669. var _this = this;
  670. if (attributes && this._customAttributes && this._customAttributes.length > 0) {
  671. attributes.push.apply(attributes, this._customAttributes);
  672. }
  673. this.ReviewUniform("uniform", uniforms);
  674. this.ReviewUniform("sampler", samplers);
  675. if (this._isCreatedShader) {
  676. return this._createdShaderName;
  677. }
  678. this._isCreatedShader = false;
  679. PBRCustomMaterial.ShaderIndexer++;
  680. var name = "custom_" + PBRCustomMaterial.ShaderIndexer;
  681. var fn_afterBind = this._afterBind.bind(this);
  682. this._afterBind = function (m, e) {
  683. if (!e) {
  684. return;
  685. }
  686. _this.AttachAfterBind(m, e);
  687. try {
  688. fn_afterBind(m, e);
  689. }
  690. catch (e) { }
  691. };
  692. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "VertexShader"] = this.VertexShader
  693. .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
  694. .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
  695. .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
  696. .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
  697. .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""))
  698. .replace('#define CUSTOM_VERTEX_MAIN_END', (this.CustomParts.Vertex_MainEnd ? this.CustomParts.Vertex_MainEnd : ""));
  699. if (this.CustomParts.Vertex_After_WorldPosComputed) {
  700. 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);
  701. }
  702. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[name + "PixelShader"] = this.FragmentShader
  703. .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
  704. .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
  705. .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
  706. .replace('#define CUSTOM_FRAGMENT_UPDATE_ALBEDO', (this.CustomParts.Fragment_Custom_Albedo ? this.CustomParts.Fragment_Custom_Albedo : ""))
  707. .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
  708. .replace('#define CUSTOM_FRAGMENT_BEFORE_LIGHTS', (this.CustomParts.Fragment_Before_Lights ? this.CustomParts.Fragment_Before_Lights : ""))
  709. .replace('#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS', (this.CustomParts.Fragment_Custom_MetallicRoughness ? this.CustomParts.Fragment_Custom_MetallicRoughness : ""))
  710. .replace('#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE', (this.CustomParts.Fragment_Custom_MicroSurface ? this.CustomParts.Fragment_Custom_MicroSurface : ""))
  711. .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
  712. if (this.CustomParts.Fragment_Before_Fog) {
  713. 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);
  714. }
  715. this._isCreatedShader = true;
  716. this._createdShaderName = name;
  717. return name;
  718. };
  719. PBRCustomMaterial.prototype.AddUniform = function (name, kind, param) {
  720. if (!this._customUniform) {
  721. this._customUniform = new Array();
  722. this._newUniforms = new Array();
  723. this._newSamplerInstances = {};
  724. this._newUniformInstances = {};
  725. }
  726. if (param) {
  727. if (kind.indexOf("sampler") != -1) {
  728. this._newSamplerInstances[kind + "-" + name] = param;
  729. }
  730. else {
  731. this._newUniformInstances[kind + "-" + name] = param;
  732. }
  733. }
  734. this._customUniform.push("uniform " + kind + " " + name + ";");
  735. this._newUniforms.push(name);
  736. return this;
  737. };
  738. PBRCustomMaterial.prototype.AddAttribute = function (name) {
  739. if (!this._customAttributes) {
  740. this._customAttributes = [];
  741. }
  742. this._customAttributes.push(name);
  743. return this;
  744. };
  745. PBRCustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
  746. this.CustomParts.Fragment_Begin = shaderPart;
  747. return this;
  748. };
  749. PBRCustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
  750. this.CustomParts.Fragment_Definitions = shaderPart;
  751. return this;
  752. };
  753. PBRCustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
  754. this.CustomParts.Fragment_MainBegin = shaderPart;
  755. return this;
  756. };
  757. PBRCustomMaterial.prototype.Fragment_Custom_Albedo = function (shaderPart) {
  758. this.CustomParts.Fragment_Custom_Albedo = shaderPart.replace("result", "surfaceAlbedo");
  759. return this;
  760. };
  761. PBRCustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
  762. this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
  763. return this;
  764. };
  765. PBRCustomMaterial.prototype.Fragment_Before_Lights = function (shaderPart) {
  766. this.CustomParts.Fragment_Before_Lights = shaderPart;
  767. return this;
  768. };
  769. PBRCustomMaterial.prototype.Fragment_Custom_MetallicRoughness = function (shaderPart) {
  770. this.CustomParts.Fragment_Custom_MetallicRoughness = shaderPart;
  771. return this;
  772. };
  773. PBRCustomMaterial.prototype.Fragment_Custom_MicroSurface = function (shaderPart) {
  774. this.CustomParts.Fragment_Custom_MicroSurface = shaderPart;
  775. return this;
  776. };
  777. PBRCustomMaterial.prototype.Fragment_Before_Fog = function (shaderPart) {
  778. this.CustomParts.Fragment_Before_Fog = shaderPart;
  779. return this;
  780. };
  781. PBRCustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
  782. this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
  783. return this;
  784. };
  785. PBRCustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
  786. this.CustomParts.Vertex_Begin = shaderPart;
  787. return this;
  788. };
  789. PBRCustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
  790. this.CustomParts.Vertex_Definitions = shaderPart;
  791. return this;
  792. };
  793. PBRCustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
  794. this.CustomParts.Vertex_MainBegin = shaderPart;
  795. return this;
  796. };
  797. PBRCustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
  798. this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
  799. return this;
  800. };
  801. PBRCustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
  802. this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
  803. return this;
  804. };
  805. PBRCustomMaterial.prototype.Vertex_After_WorldPosComputed = function (shaderPart) {
  806. this.CustomParts.Vertex_After_WorldPosComputed = shaderPart;
  807. return this;
  808. };
  809. PBRCustomMaterial.prototype.Vertex_MainEnd = function (shaderPart) {
  810. this.CustomParts.Vertex_MainEnd = shaderPart;
  811. return this;
  812. };
  813. PBRCustomMaterial.ShaderIndexer = 1;
  814. return PBRCustomMaterial;
  815. }(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["PBRMaterial"]));
  816. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.PBRCustomMaterial"] = PBRCustomMaterial;
  817. /***/ }),
  818. /***/ "./legacy/legacy-custom.ts":
  819. /*!*********************************!*\
  820. !*** ./legacy/legacy-custom.ts ***!
  821. \*********************************/
  822. /*! exports provided: CustomShaderStructure, ShaderSpecialParts, CustomMaterial, ShaderAlebdoParts, PBRCustomMaterial */
  823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  824. "use strict";
  825. __webpack_require__.r(__webpack_exports__);
  826. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _custom_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../custom/index */ "./custom/index.ts");
  827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomShaderStructure", function() { return _custom_index__WEBPACK_IMPORTED_MODULE_0__["CustomShaderStructure"]; });
  828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderSpecialParts", function() { return _custom_index__WEBPACK_IMPORTED_MODULE_0__["ShaderSpecialParts"]; });
  829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomMaterial", function() { return _custom_index__WEBPACK_IMPORTED_MODULE_0__["CustomMaterial"]; });
  830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderAlebdoParts", function() { return _custom_index__WEBPACK_IMPORTED_MODULE_0__["ShaderAlebdoParts"]; });
  831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRCustomMaterial", function() { return _custom_index__WEBPACK_IMPORTED_MODULE_0__["PBRCustomMaterial"]; });
  832. /**
  833. * This is the entry point for the UMD module.
  834. * The entry point for a future ESM package should be index.ts
  835. */
  836. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  837. if (typeof globalObject !== "undefined") {
  838. for (var key in _custom_index__WEBPACK_IMPORTED_MODULE_0__) {
  839. globalObject.BABYLON[key] = _custom_index__WEBPACK_IMPORTED_MODULE_0__[key];
  840. }
  841. }
  842. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  843. /***/ }),
  844. /***/ "babylonjs/Materials/effect":
  845. /*!****************************************************************************************************!*\
  846. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  847. \****************************************************************************************************/
  848. /*! no static exports found */
  849. /***/ (function(module, exports) {
  850. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Materials_effect__;
  851. /***/ })
  852. /******/ });
  853. });
  854. //# sourceMappingURL=babylon.customMaterial.js.map