babylon.customMaterial.js 47 KB

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