babylonjs.proceduralTextures.js 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800
  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-procedural-textures", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-procedural-textures"] = factory(require("babylonjs"));
  8. else
  9. root["PTLIB"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
  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 = "./src/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/webpack/buildin/global.js":
  99. /*!*************************************************!*\
  100. !*** ../node_modules/webpack/buildin/global.js ***!
  101. \*************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || Function("return this")() || (1, eval)("this");
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "./src/brick/brickProceduralTexture.fragment.fx":
  122. /*!******************************************************!*\
  123. !*** ./src/brick/brickProceduralTexture.fragment.fx ***!
  124. \******************************************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports) {
  127. module.exports = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfBricksHeight;\nuniform float numberOfBricksWidth;\nuniform vec3 brickColor;\nuniform vec3 jointColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvoid main(void)\n{\nfloat brickW=1.0/numberOfBricksWidth;\nfloat brickH=1.0/numberOfBricksHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.05;\nvec3 color=brickColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0) == 0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat brickColorSwitch=mod(floor(yi)+floor(xi),3.0);\nif (brickColorSwitch == 0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);\nelse if (brickColorSwitch == 2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);\n}\ngl_FragColor=vec4(color,1.0);\n}"
  128. /***/ }),
  129. /***/ "./src/brick/brickProceduralTexture.ts":
  130. /*!*********************************************!*\
  131. !*** ./src/brick/brickProceduralTexture.ts ***!
  132. \*********************************************/
  133. /*! no static exports found */
  134. /***/ (function(module, exports, __webpack_require__) {
  135. "use strict";
  136. var __extends = (this && this.__extends) || (function () {
  137. var extendStatics = function (d, b) {
  138. extendStatics = Object.setPrototypeOf ||
  139. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  140. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  141. return extendStatics(d, b);
  142. }
  143. return function (d, b) {
  144. extendStatics(d, b);
  145. function __() { this.constructor = d; }
  146. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  147. };
  148. })();
  149. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  150. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  151. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  152. 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;
  153. return c > 3 && r && Object.defineProperty(target, key, r), r;
  154. };
  155. Object.defineProperty(exports, "__esModule", { value: true });
  156. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  157. babylonjs_1.Effect.ShadersStore["brickProceduralTexturePixelShader"] = __webpack_require__(/*! ./brickProceduralTexture.fragment.fx */ "./src/brick/brickProceduralTexture.fragment.fx");
  158. var BrickProceduralTexture = /** @class */ (function (_super) {
  159. __extends(BrickProceduralTexture, _super);
  160. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  161. var _this = _super.call(this, name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  162. _this._numberOfBricksHeight = 15;
  163. _this._numberOfBricksWidth = 5;
  164. _this._jointColor = new babylonjs_1.Color3(0.72, 0.72, 0.72);
  165. _this._brickColor = new babylonjs_1.Color3(0.77, 0.47, 0.40);
  166. _this.updateShaderUniforms();
  167. return _this;
  168. }
  169. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  170. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  171. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  172. this.setColor3("brickColor", this._brickColor);
  173. this.setColor3("jointColor", this._jointColor);
  174. };
  175. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  176. get: function () {
  177. return this._numberOfBricksHeight;
  178. },
  179. set: function (value) {
  180. this._numberOfBricksHeight = value;
  181. this.updateShaderUniforms();
  182. },
  183. enumerable: true,
  184. configurable: true
  185. });
  186. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  187. get: function () {
  188. return this._numberOfBricksWidth;
  189. },
  190. set: function (value) {
  191. this._numberOfBricksWidth = value;
  192. this.updateShaderUniforms();
  193. },
  194. enumerable: true,
  195. configurable: true
  196. });
  197. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  198. get: function () {
  199. return this._jointColor;
  200. },
  201. set: function (value) {
  202. this._jointColor = value;
  203. this.updateShaderUniforms();
  204. },
  205. enumerable: true,
  206. configurable: true
  207. });
  208. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  209. get: function () {
  210. return this._brickColor;
  211. },
  212. set: function (value) {
  213. this._brickColor = value;
  214. this.updateShaderUniforms();
  215. },
  216. enumerable: true,
  217. configurable: true
  218. });
  219. /**
  220. * Serializes this brick procedural texture
  221. * @returns a serialized brick procedural texture object
  222. */
  223. BrickProceduralTexture.prototype.serialize = function () {
  224. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  225. serializationObject.customType = "BABYLON.BrickProceduralTexture";
  226. return serializationObject;
  227. };
  228. /**
  229. * Creates a Brick Procedural Texture from parsed brick procedural texture data
  230. * @param parsedTexture defines parsed texture data
  231. * @param scene defines the current scene
  232. * @param rootUrl defines the root URL containing brick procedural texture information
  233. * @returns a parsed Brick Procedural Texture
  234. */
  235. BrickProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  236. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  237. return texture;
  238. };
  239. __decorate([
  240. babylonjs_1.serialize()
  241. ], BrickProceduralTexture.prototype, "numberOfBricksHeight", null);
  242. __decorate([
  243. babylonjs_1.serialize()
  244. ], BrickProceduralTexture.prototype, "numberOfBricksWidth", null);
  245. __decorate([
  246. babylonjs_1.serializeAsColor3()
  247. ], BrickProceduralTexture.prototype, "jointColor", null);
  248. __decorate([
  249. babylonjs_1.serializeAsColor3()
  250. ], BrickProceduralTexture.prototype, "brickColor", null);
  251. return BrickProceduralTexture;
  252. }(babylonjs_1.ProceduralTexture));
  253. exports.BrickProceduralTexture = BrickProceduralTexture;
  254. /***/ }),
  255. /***/ "./src/brick/index.ts":
  256. /*!****************************!*\
  257. !*** ./src/brick/index.ts ***!
  258. \****************************/
  259. /*! no static exports found */
  260. /***/ (function(module, exports, __webpack_require__) {
  261. "use strict";
  262. function __export(m) {
  263. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  264. }
  265. Object.defineProperty(exports, "__esModule", { value: true });
  266. __export(__webpack_require__(/*! ./brickProceduralTexture */ "./src/brick/brickProceduralTexture.ts"));
  267. /***/ }),
  268. /***/ "./src/cloud/cloudProceduralTexture.fragment.fx":
  269. /*!******************************************************!*\
  270. !*** ./src/cloud/cloudProceduralTexture.fragment.fx ***!
  271. \******************************************************/
  272. /*! no static exports found */
  273. /***/ (function(module, exports) {
  274. module.exports = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 skyColor;\nuniform vec4 cloudColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*12.0;\nvec4 c=mix(skyColor,cloudColor,fbm(p));\ngl_FragColor=c;\n}\n"
  275. /***/ }),
  276. /***/ "./src/cloud/cloudProceduralTexture.ts":
  277. /*!*********************************************!*\
  278. !*** ./src/cloud/cloudProceduralTexture.ts ***!
  279. \*********************************************/
  280. /*! no static exports found */
  281. /***/ (function(module, exports, __webpack_require__) {
  282. "use strict";
  283. var __extends = (this && this.__extends) || (function () {
  284. var extendStatics = function (d, b) {
  285. extendStatics = Object.setPrototypeOf ||
  286. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  287. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  288. return extendStatics(d, b);
  289. }
  290. return function (d, b) {
  291. extendStatics(d, b);
  292. function __() { this.constructor = d; }
  293. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  294. };
  295. })();
  296. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  297. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  298. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  299. 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;
  300. return c > 3 && r && Object.defineProperty(target, key, r), r;
  301. };
  302. Object.defineProperty(exports, "__esModule", { value: true });
  303. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  304. babylonjs_1.Effect.ShadersStore["cloudProceduralTexturePixelShader"] = __webpack_require__(/*! ./cloudProceduralTexture.fragment.fx */ "./src/cloud/cloudProceduralTexture.fragment.fx");
  305. var CloudProceduralTexture = /** @class */ (function (_super) {
  306. __extends(CloudProceduralTexture, _super);
  307. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  308. var _this = _super.call(this, name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  309. _this._skyColor = new babylonjs_1.Color4(0.15, 0.68, 1.0, 1.0);
  310. _this._cloudColor = new babylonjs_1.Color4(1, 1, 1, 1.0);
  311. _this.updateShaderUniforms();
  312. return _this;
  313. }
  314. CloudProceduralTexture.prototype.updateShaderUniforms = function () {
  315. this.setColor4("skyColor", this._skyColor);
  316. this.setColor4("cloudColor", this._cloudColor);
  317. };
  318. Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
  319. get: function () {
  320. return this._skyColor;
  321. },
  322. set: function (value) {
  323. this._skyColor = value;
  324. this.updateShaderUniforms();
  325. },
  326. enumerable: true,
  327. configurable: true
  328. });
  329. Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
  330. get: function () {
  331. return this._cloudColor;
  332. },
  333. set: function (value) {
  334. this._cloudColor = value;
  335. this.updateShaderUniforms();
  336. },
  337. enumerable: true,
  338. configurable: true
  339. });
  340. /**
  341. * Serializes this cloud procedural texture
  342. * @returns a serialized cloud procedural texture object
  343. */
  344. CloudProceduralTexture.prototype.serialize = function () {
  345. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  346. serializationObject.customType = "BABYLON.CloudProceduralTexture";
  347. return serializationObject;
  348. };
  349. /**
  350. * Creates a Cloud Procedural Texture from parsed cloud procedural texture data
  351. * @param parsedTexture defines parsed texture data
  352. * @param scene defines the current scene
  353. * @param rootUrl defines the root URL containing cloud procedural texture information
  354. * @returns a parsed Cloud Procedural Texture
  355. */
  356. CloudProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  357. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  358. return texture;
  359. };
  360. __decorate([
  361. babylonjs_1.serializeAsColor4()
  362. ], CloudProceduralTexture.prototype, "skyColor", null);
  363. __decorate([
  364. babylonjs_1.serializeAsColor4()
  365. ], CloudProceduralTexture.prototype, "cloudColor", null);
  366. return CloudProceduralTexture;
  367. }(babylonjs_1.ProceduralTexture));
  368. exports.CloudProceduralTexture = CloudProceduralTexture;
  369. /***/ }),
  370. /***/ "./src/cloud/index.ts":
  371. /*!****************************!*\
  372. !*** ./src/cloud/index.ts ***!
  373. \****************************/
  374. /*! no static exports found */
  375. /***/ (function(module, exports, __webpack_require__) {
  376. "use strict";
  377. function __export(m) {
  378. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  379. }
  380. Object.defineProperty(exports, "__esModule", { value: true });
  381. __export(__webpack_require__(/*! ./cloudProceduralTexture */ "./src/cloud/cloudProceduralTexture.ts"));
  382. /***/ }),
  383. /***/ "./src/fire/fireProceduralTexture.fragment.fx":
  384. /*!****************************************************!*\
  385. !*** ./src/fire/fireProceduralTexture.fragment.fx ***!
  386. \****************************************************/
  387. /*! no static exports found */
  388. /***/ (function(module, exports) {
  389. module.exports = "precision highp float;\nuniform float time;\nuniform vec3 c1;\nuniform vec3 c2;\nuniform vec3 c3;\nuniform vec3 c4;\nuniform vec3 c5;\nuniform vec3 c6;\nuniform vec2 speed;\nuniform float shift;\nuniform float alphaThreshold;\nvarying vec2 vUV;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*8.0;\nfloat q=fbm(p-time*0.1);\nvec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));\nvec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);\nvec3 color=c*cos(shift*vUV.y);\nfloat luminance=dot(color.rgb,vec3(0.3,0.59,0.11));\ngl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));\n}"
  390. /***/ }),
  391. /***/ "./src/fire/fireProceduralTexture.ts":
  392. /*!*******************************************!*\
  393. !*** ./src/fire/fireProceduralTexture.ts ***!
  394. \*******************************************/
  395. /*! no static exports found */
  396. /***/ (function(module, exports, __webpack_require__) {
  397. "use strict";
  398. var __extends = (this && this.__extends) || (function () {
  399. var extendStatics = function (d, b) {
  400. extendStatics = Object.setPrototypeOf ||
  401. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  402. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  403. return extendStatics(d, b);
  404. }
  405. return function (d, b) {
  406. extendStatics(d, b);
  407. function __() { this.constructor = d; }
  408. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  409. };
  410. })();
  411. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  412. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  413. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  414. 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;
  415. return c > 3 && r && Object.defineProperty(target, key, r), r;
  416. };
  417. Object.defineProperty(exports, "__esModule", { value: true });
  418. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  419. babylonjs_1.Effect.ShadersStore["fireProceduralTexturePixelShader"] = __webpack_require__(/*! ./fireProceduralTexture.fragment.fx */ "./src/fire/fireProceduralTexture.fragment.fx");
  420. var FireProceduralTexture = /** @class */ (function (_super) {
  421. __extends(FireProceduralTexture, _super);
  422. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  423. var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  424. _this._time = 0.0;
  425. _this._speed = new babylonjs_1.Vector2(0.5, 0.3);
  426. _this._autoGenerateTime = true;
  427. _this._alphaThreshold = 0.5;
  428. _this._fireColors = FireProceduralTexture.RedFireColors;
  429. _this.updateShaderUniforms();
  430. return _this;
  431. }
  432. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  433. this.setFloat("time", this._time);
  434. this.setVector2("speed", this._speed);
  435. this.setColor3("c1", this._fireColors[0]);
  436. this.setColor3("c2", this._fireColors[1]);
  437. this.setColor3("c3", this._fireColors[2]);
  438. this.setColor3("c4", this._fireColors[3]);
  439. this.setColor3("c5", this._fireColors[4]);
  440. this.setColor3("c6", this._fireColors[5]);
  441. this.setFloat("alphaThreshold", this._alphaThreshold);
  442. };
  443. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  444. var scene = this.getScene();
  445. if (this._autoGenerateTime && scene) {
  446. this._time += scene.getAnimationRatio() * 0.03;
  447. this.updateShaderUniforms();
  448. }
  449. _super.prototype.render.call(this, useCameraPostProcess);
  450. };
  451. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  452. get: function () {
  453. return [
  454. new babylonjs_1.Color3(0.5, 0.0, 1.0),
  455. new babylonjs_1.Color3(0.9, 0.0, 1.0),
  456. new babylonjs_1.Color3(0.2, 0.0, 1.0),
  457. new babylonjs_1.Color3(1.0, 0.9, 1.0),
  458. new babylonjs_1.Color3(0.1, 0.1, 1.0),
  459. new babylonjs_1.Color3(0.9, 0.9, 1.0)
  460. ];
  461. },
  462. enumerable: true,
  463. configurable: true
  464. });
  465. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  466. get: function () {
  467. return [
  468. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  469. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  470. new babylonjs_1.Color3(0.3, 0.4, 0.0),
  471. new babylonjs_1.Color3(0.5, 1.0, 0.0),
  472. new babylonjs_1.Color3(0.2, 0.0, 0.0),
  473. new babylonjs_1.Color3(0.5, 1.0, 0.0)
  474. ];
  475. },
  476. enumerable: true,
  477. configurable: true
  478. });
  479. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  480. get: function () {
  481. return [
  482. new babylonjs_1.Color3(0.5, 0.0, 0.1),
  483. new babylonjs_1.Color3(0.9, 0.0, 0.0),
  484. new babylonjs_1.Color3(0.2, 0.0, 0.0),
  485. new babylonjs_1.Color3(1.0, 0.9, 0.0),
  486. new babylonjs_1.Color3(0.1, 0.1, 0.1),
  487. new babylonjs_1.Color3(0.9, 0.9, 0.9)
  488. ];
  489. },
  490. enumerable: true,
  491. configurable: true
  492. });
  493. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  494. get: function () {
  495. return [
  496. new babylonjs_1.Color3(0.1, 0.0, 0.5),
  497. new babylonjs_1.Color3(0.0, 0.0, 0.5),
  498. new babylonjs_1.Color3(0.1, 0.0, 0.2),
  499. new babylonjs_1.Color3(0.0, 0.0, 1.0),
  500. new babylonjs_1.Color3(0.1, 0.2, 0.3),
  501. new babylonjs_1.Color3(0.0, 0.2, 0.9)
  502. ];
  503. },
  504. enumerable: true,
  505. configurable: true
  506. });
  507. Object.defineProperty(FireProceduralTexture.prototype, "autoGenerateTime", {
  508. get: function () {
  509. return this._autoGenerateTime;
  510. },
  511. set: function (value) {
  512. this._autoGenerateTime = value;
  513. },
  514. enumerable: true,
  515. configurable: true
  516. });
  517. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  518. get: function () {
  519. return this._fireColors;
  520. },
  521. set: function (value) {
  522. this._fireColors = value;
  523. this.updateShaderUniforms();
  524. },
  525. enumerable: true,
  526. configurable: true
  527. });
  528. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  529. get: function () {
  530. return this._time;
  531. },
  532. set: function (value) {
  533. this._time = value;
  534. this.updateShaderUniforms();
  535. },
  536. enumerable: true,
  537. configurable: true
  538. });
  539. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  540. get: function () {
  541. return this._speed;
  542. },
  543. set: function (value) {
  544. this._speed = value;
  545. this.updateShaderUniforms();
  546. },
  547. enumerable: true,
  548. configurable: true
  549. });
  550. Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
  551. get: function () {
  552. return this._alphaThreshold;
  553. },
  554. set: function (value) {
  555. this._alphaThreshold = value;
  556. this.updateShaderUniforms();
  557. },
  558. enumerable: true,
  559. configurable: true
  560. });
  561. /**
  562. * Serializes this fire procedural texture
  563. * @returns a serialized fire procedural texture object
  564. */
  565. FireProceduralTexture.prototype.serialize = function () {
  566. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  567. serializationObject.customType = "BABYLON.FireProceduralTexture";
  568. serializationObject.fireColors = [];
  569. for (var i = 0; i < this._fireColors.length; i++) {
  570. serializationObject.fireColors.push(this._fireColors[i].asArray());
  571. }
  572. return serializationObject;
  573. };
  574. /**
  575. * Creates a Fire Procedural Texture from parsed fire procedural texture data
  576. * @param parsedTexture defines parsed texture data
  577. * @param scene defines the current scene
  578. * @param rootUrl defines the root URL containing fire procedural texture information
  579. * @returns a parsed Fire Procedural Texture
  580. */
  581. FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  582. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  583. var colors = [];
  584. for (var i = 0; i < parsedTexture.fireColors.length; i++) {
  585. colors.push(babylonjs_1.Color3.FromArray(parsedTexture.fireColors[i]));
  586. }
  587. texture.fireColors = colors;
  588. return texture;
  589. };
  590. __decorate([
  591. babylonjs_1.serialize()
  592. ], FireProceduralTexture.prototype, "autoGenerateTime", null);
  593. __decorate([
  594. babylonjs_1.serialize()
  595. ], FireProceduralTexture.prototype, "time", null);
  596. __decorate([
  597. babylonjs_1.serializeAsVector2()
  598. ], FireProceduralTexture.prototype, "speed", null);
  599. __decorate([
  600. babylonjs_1.serialize()
  601. ], FireProceduralTexture.prototype, "alphaThreshold", null);
  602. return FireProceduralTexture;
  603. }(babylonjs_1.ProceduralTexture));
  604. exports.FireProceduralTexture = FireProceduralTexture;
  605. /***/ }),
  606. /***/ "./src/fire/index.ts":
  607. /*!***************************!*\
  608. !*** ./src/fire/index.ts ***!
  609. \***************************/
  610. /*! no static exports found */
  611. /***/ (function(module, exports, __webpack_require__) {
  612. "use strict";
  613. function __export(m) {
  614. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  615. }
  616. Object.defineProperty(exports, "__esModule", { value: true });
  617. __export(__webpack_require__(/*! ./fireProceduralTexture */ "./src/fire/fireProceduralTexture.ts"));
  618. /***/ }),
  619. /***/ "./src/grass/grassProceduralTexture.fragment.fx":
  620. /*!******************************************************!*\
  621. !*** ./src/grass/grassProceduralTexture.fragment.fx ***!
  622. \******************************************************/
  623. /*! no static exports found */
  624. /***/ (function(module, exports) {
  625. module.exports = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform vec3 herb1Color;\nuniform vec3 herb2Color;\nuniform vec3 herb3Color;\nuniform vec3 groundColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nvec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));\ncolor=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));\ncolor=mix(color,herb3Color,rand(gl_FragCoord.xy));\ncolor=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));\ngl_FragColor=vec4(color,1.0);\n}"
  626. /***/ }),
  627. /***/ "./src/grass/grassProceduralTexture.ts":
  628. /*!*********************************************!*\
  629. !*** ./src/grass/grassProceduralTexture.ts ***!
  630. \*********************************************/
  631. /*! no static exports found */
  632. /***/ (function(module, exports, __webpack_require__) {
  633. "use strict";
  634. var __extends = (this && this.__extends) || (function () {
  635. var extendStatics = function (d, b) {
  636. extendStatics = Object.setPrototypeOf ||
  637. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  638. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  639. return extendStatics(d, b);
  640. }
  641. return function (d, b) {
  642. extendStatics(d, b);
  643. function __() { this.constructor = d; }
  644. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  645. };
  646. })();
  647. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  648. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  649. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  650. 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;
  651. return c > 3 && r && Object.defineProperty(target, key, r), r;
  652. };
  653. Object.defineProperty(exports, "__esModule", { value: true });
  654. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  655. babylonjs_1.Effect.ShadersStore["grassProceduralTexturePixelShader"] = __webpack_require__(/*! ./grassProceduralTexture.fragment.fx */ "./src/grass/grassProceduralTexture.fragment.fx");
  656. var GrassProceduralTexture = /** @class */ (function (_super) {
  657. __extends(GrassProceduralTexture, _super);
  658. function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  659. var _this = _super.call(this, name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  660. _this._groundColor = new babylonjs_1.Color3(1, 1, 1);
  661. _this._grassColors = [
  662. new babylonjs_1.Color3(0.29, 0.38, 0.02),
  663. new babylonjs_1.Color3(0.36, 0.49, 0.09),
  664. new babylonjs_1.Color3(0.51, 0.6, 0.28)
  665. ];
  666. _this.updateShaderUniforms();
  667. return _this;
  668. }
  669. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  670. this.setColor3("herb1Color", this._grassColors[0]);
  671. this.setColor3("herb2Color", this._grassColors[1]);
  672. this.setColor3("herb3Color", this._grassColors[2]);
  673. this.setColor3("groundColor", this._groundColor);
  674. };
  675. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  676. get: function () {
  677. return this._grassColors;
  678. },
  679. set: function (value) {
  680. this._grassColors = value;
  681. this.updateShaderUniforms();
  682. },
  683. enumerable: true,
  684. configurable: true
  685. });
  686. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  687. get: function () {
  688. return this._groundColor;
  689. },
  690. set: function (value) {
  691. this._groundColor = value;
  692. this.updateShaderUniforms();
  693. },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. /**
  698. * Serializes this grass procedural texture
  699. * @returns a serialized grass procedural texture object
  700. */
  701. GrassProceduralTexture.prototype.serialize = function () {
  702. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  703. serializationObject.customType = "BABYLON.GrassProceduralTexture";
  704. serializationObject.grassColors = [];
  705. for (var i = 0; i < this._grassColors.length; i++) {
  706. serializationObject.grassColors.push(this._grassColors[i].asArray());
  707. }
  708. return serializationObject;
  709. };
  710. /**
  711. * Creates a Grass Procedural Texture from parsed grass procedural texture data
  712. * @param parsedTexture defines parsed texture data
  713. * @param scene defines the current scene
  714. * @param rootUrl defines the root URL containing grass procedural texture information
  715. * @returns a parsed Grass Procedural Texture
  716. */
  717. GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  718. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  719. var colors = [];
  720. for (var i = 0; i < parsedTexture.grassColors.length; i++) {
  721. colors.push(babylonjs_1.Color3.FromArray(parsedTexture.grassColors[i]));
  722. }
  723. texture.grassColors = colors;
  724. return texture;
  725. };
  726. __decorate([
  727. babylonjs_1.serializeAsColor3()
  728. ], GrassProceduralTexture.prototype, "groundColor", null);
  729. return GrassProceduralTexture;
  730. }(babylonjs_1.ProceduralTexture));
  731. exports.GrassProceduralTexture = GrassProceduralTexture;
  732. /***/ }),
  733. /***/ "./src/grass/index.ts":
  734. /*!****************************!*\
  735. !*** ./src/grass/index.ts ***!
  736. \****************************/
  737. /*! no static exports found */
  738. /***/ (function(module, exports, __webpack_require__) {
  739. "use strict";
  740. function __export(m) {
  741. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  742. }
  743. Object.defineProperty(exports, "__esModule", { value: true });
  744. __export(__webpack_require__(/*! ./grassProceduralTexture */ "./src/grass/grassProceduralTexture.ts"));
  745. /***/ }),
  746. /***/ "./src/index.ts":
  747. /*!**********************!*\
  748. !*** ./src/index.ts ***!
  749. \**********************/
  750. /*! no static exports found */
  751. /***/ (function(module, exports, __webpack_require__) {
  752. "use strict";
  753. function __export(m) {
  754. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  755. }
  756. Object.defineProperty(exports, "__esModule", { value: true });
  757. __export(__webpack_require__(/*! ./brick */ "./src/brick/index.ts"));
  758. __export(__webpack_require__(/*! ./cloud */ "./src/cloud/index.ts"));
  759. __export(__webpack_require__(/*! ./fire */ "./src/fire/index.ts"));
  760. __export(__webpack_require__(/*! ./grass */ "./src/grass/index.ts"));
  761. __export(__webpack_require__(/*! ./marble */ "./src/marble/index.ts"));
  762. __export(__webpack_require__(/*! ./normalMap */ "./src/normalMap/index.ts"));
  763. __export(__webpack_require__(/*! ./perlinNoise */ "./src/perlinNoise/index.ts"));
  764. __export(__webpack_require__(/*! ./road */ "./src/road/index.ts"));
  765. __export(__webpack_require__(/*! ./starfield */ "./src/starfield/index.ts"));
  766. __export(__webpack_require__(/*! ./wood */ "./src/wood/index.ts"));
  767. /***/ }),
  768. /***/ "./src/legacy.ts":
  769. /*!***********************!*\
  770. !*** ./src/legacy.ts ***!
  771. \***********************/
  772. /*! no static exports found */
  773. /***/ (function(module, exports, __webpack_require__) {
  774. "use strict";
  775. /* WEBPACK VAR INJECTION */(function(global) {
  776. function __export(m) {
  777. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  778. }
  779. Object.defineProperty(exports, "__esModule", { value: true });
  780. var ProceduralTexturesLib = __webpack_require__(/*! ./index */ "./src/index.ts");
  781. /**
  782. * Legacy support, defining window.BABYLON.GridMaterial... (global variable).
  783. *
  784. * This is the entry point for the UMD module.
  785. * The entry point for a future ESM package should be index.ts
  786. */
  787. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  788. if (typeof globalObject !== "undefined") {
  789. globalObject.BABYLON = globalObject.BABYLON || {};
  790. for (var mat in ProceduralTexturesLib) {
  791. if (ProceduralTexturesLib.hasOwnProperty(mat)) {
  792. globalObject.BABYLON[mat] = ProceduralTexturesLib[mat];
  793. }
  794. }
  795. }
  796. __export(__webpack_require__(/*! ./index */ "./src/index.ts"));
  797. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  798. /***/ }),
  799. /***/ "./src/marble/index.ts":
  800. /*!*****************************!*\
  801. !*** ./src/marble/index.ts ***!
  802. \*****************************/
  803. /*! no static exports found */
  804. /***/ (function(module, exports, __webpack_require__) {
  805. "use strict";
  806. function __export(m) {
  807. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  808. }
  809. Object.defineProperty(exports, "__esModule", { value: true });
  810. __export(__webpack_require__(/*! ./marbleProceduralTexture */ "./src/marble/marbleProceduralTexture.ts"));
  811. /***/ }),
  812. /***/ "./src/marble/marbleProceduralTexture.fragment.fx":
  813. /*!********************************************************!*\
  814. !*** ./src/marble/marbleProceduralTexture.fragment.fx ***!
  815. \********************************************************/
  816. /*! no static exports found */
  817. /***/ (function(module, exports) {
  818. module.exports = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfTilesHeight;\nuniform float numberOfTilesWidth;\nuniform float amplitude;\nuniform vec3 marbleColor;\nuniform vec3 jointColor;\nconst vec3 tileSize=vec3(1.1,1.0,1.1);\nconst vec3 tilePct=vec3(0.98,1.0,0.98);\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat turbulence(vec2 P)\n{\nfloat val=0.0;\nfloat freq=1.0;\nfor (int i=0; i<4; i++)\n{\nval+=abs(noise(P*freq)/freq);\nfreq*=2.07;\n}\nreturn val;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvec3 marble_color(float x)\n{\nvec3 col;\nx=0.5*(x+1.);\nx=sqrt(x); \nx=sqrt(x);\nx=sqrt(x);\ncol=vec3(.2+.75*x); \ncol.b*=0.95; \nreturn col;\n}\nvoid main()\n{\nfloat brickW=1.0/numberOfTilesWidth;\nfloat brickH=1.0/numberOfTilesHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.01;\nvec3 color=marbleColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0) == 0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));\nt+=amplitude*turbulence(brickvUV.xy);\nt=sin(t);\ncolor=marble_color(t);\n}\ngl_FragColor=vec4(color,0.0);\n}"
  819. /***/ }),
  820. /***/ "./src/marble/marbleProceduralTexture.ts":
  821. /*!***********************************************!*\
  822. !*** ./src/marble/marbleProceduralTexture.ts ***!
  823. \***********************************************/
  824. /*! no static exports found */
  825. /***/ (function(module, exports, __webpack_require__) {
  826. "use strict";
  827. var __extends = (this && this.__extends) || (function () {
  828. var extendStatics = function (d, b) {
  829. extendStatics = Object.setPrototypeOf ||
  830. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  831. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  832. return extendStatics(d, b);
  833. }
  834. return function (d, b) {
  835. extendStatics(d, b);
  836. function __() { this.constructor = d; }
  837. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  838. };
  839. })();
  840. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  841. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  842. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  843. 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;
  844. return c > 3 && r && Object.defineProperty(target, key, r), r;
  845. };
  846. Object.defineProperty(exports, "__esModule", { value: true });
  847. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  848. babylonjs_1.Effect.ShadersStore["marbleProceduralTexturePixelShader"] = __webpack_require__(/*! ./marbleProceduralTexture.fragment.fx */ "./src/marble/marbleProceduralTexture.fragment.fx");
  849. var MarbleProceduralTexture = /** @class */ (function (_super) {
  850. __extends(MarbleProceduralTexture, _super);
  851. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  852. var _this = _super.call(this, name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  853. _this._numberOfTilesHeight = 3;
  854. _this._numberOfTilesWidth = 3;
  855. _this._amplitude = 9.0;
  856. _this._jointColor = new babylonjs_1.Color3(0.72, 0.72, 0.72);
  857. _this.updateShaderUniforms();
  858. return _this;
  859. }
  860. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  861. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  862. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  863. this.setFloat("amplitude", this._amplitude);
  864. this.setColor3("jointColor", this._jointColor);
  865. };
  866. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  867. get: function () {
  868. return this._numberOfTilesHeight;
  869. },
  870. set: function (value) {
  871. this._numberOfTilesHeight = value;
  872. this.updateShaderUniforms();
  873. },
  874. enumerable: true,
  875. configurable: true
  876. });
  877. Object.defineProperty(MarbleProceduralTexture.prototype, "amplitude", {
  878. get: function () {
  879. return this._amplitude;
  880. },
  881. set: function (value) {
  882. this._amplitude = value;
  883. this.updateShaderUniforms();
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  889. get: function () {
  890. return this._numberOfTilesWidth;
  891. },
  892. set: function (value) {
  893. this._numberOfTilesWidth = value;
  894. this.updateShaderUniforms();
  895. },
  896. enumerable: true,
  897. configurable: true
  898. });
  899. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  900. get: function () {
  901. return this._jointColor;
  902. },
  903. set: function (value) {
  904. this._jointColor = value;
  905. this.updateShaderUniforms();
  906. },
  907. enumerable: true,
  908. configurable: true
  909. });
  910. /**
  911. * Serializes this marble procedural texture
  912. * @returns a serialized marble procedural texture object
  913. */
  914. MarbleProceduralTexture.prototype.serialize = function () {
  915. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  916. serializationObject.customType = "BABYLON.MarbleProceduralTexture";
  917. return serializationObject;
  918. };
  919. /**
  920. * Creates a Marble Procedural Texture from parsed marble procedural texture data
  921. * @param parsedTexture defines parsed texture data
  922. * @param scene defines the current scene
  923. * @param rootUrl defines the root URL containing marble procedural texture information
  924. * @returns a parsed Marble Procedural Texture
  925. */
  926. MarbleProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  927. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new MarbleProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  928. return texture;
  929. };
  930. __decorate([
  931. babylonjs_1.serialize()
  932. ], MarbleProceduralTexture.prototype, "numberOfTilesHeight", null);
  933. __decorate([
  934. babylonjs_1.serialize()
  935. ], MarbleProceduralTexture.prototype, "amplitude", null);
  936. __decorate([
  937. babylonjs_1.serialize()
  938. ], MarbleProceduralTexture.prototype, "numberOfTilesWidth", null);
  939. __decorate([
  940. babylonjs_1.serialize()
  941. ], MarbleProceduralTexture.prototype, "jointColor", null);
  942. return MarbleProceduralTexture;
  943. }(babylonjs_1.ProceduralTexture));
  944. exports.MarbleProceduralTexture = MarbleProceduralTexture;
  945. /***/ }),
  946. /***/ "./src/normalMap/index.ts":
  947. /*!********************************!*\
  948. !*** ./src/normalMap/index.ts ***!
  949. \********************************/
  950. /*! no static exports found */
  951. /***/ (function(module, exports, __webpack_require__) {
  952. "use strict";
  953. function __export(m) {
  954. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  955. }
  956. Object.defineProperty(exports, "__esModule", { value: true });
  957. __export(__webpack_require__(/*! ./normalMapProceduralTexture */ "./src/normalMap/normalMapProceduralTexture.ts"));
  958. /***/ }),
  959. /***/ "./src/normalMap/normalMapProceduralTexture.fragment.fx":
  960. /*!**************************************************************!*\
  961. !*** ./src/normalMap/normalMapProceduralTexture.fragment.fx ***!
  962. \**************************************************************/
  963. /*! no static exports found */
  964. /***/ (function(module, exports) {
  965. module.exports = "precision highp float;\n\nuniform sampler2D baseSampler;\nuniform float size;\n\nvarying vec2 vUV;\n\nconst vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);\nfloat lumaAtCoord(vec2 coord)\n{\nvec3 pixel=texture2D(baseSampler,coord).rgb;\nfloat luma=dot(pixel,LUMA_COEFFICIENT);\nreturn luma;\n}\nvoid main()\n{\nfloat lumaU0=lumaAtCoord(vUV+vec2(-1.0,0.0)/size);\nfloat lumaU1=lumaAtCoord(vUV+vec2( 1.0,0.0)/size);\nfloat lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);\nfloat lumaV1=lumaAtCoord(vUV+vec2( 0.0,1.0)/size);\nvec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;\ngl_FragColor=vec4(slope,1.0,1.0);\n}\n"
  966. /***/ }),
  967. /***/ "./src/normalMap/normalMapProceduralTexture.ts":
  968. /*!*****************************************************!*\
  969. !*** ./src/normalMap/normalMapProceduralTexture.ts ***!
  970. \*****************************************************/
  971. /*! no static exports found */
  972. /***/ (function(module, exports, __webpack_require__) {
  973. "use strict";
  974. var __extends = (this && this.__extends) || (function () {
  975. var extendStatics = function (d, b) {
  976. extendStatics = Object.setPrototypeOf ||
  977. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  978. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  979. return extendStatics(d, b);
  980. }
  981. return function (d, b) {
  982. extendStatics(d, b);
  983. function __() { this.constructor = d; }
  984. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  985. };
  986. })();
  987. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  988. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  989. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  990. 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;
  991. return c > 3 && r && Object.defineProperty(target, key, r), r;
  992. };
  993. Object.defineProperty(exports, "__esModule", { value: true });
  994. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  995. babylonjs_1.Effect.ShadersStore["normalMapProceduralTexturePixelShader"] = __webpack_require__(/*! ./normalMapProceduralTexture.fragment.fx */ "./src/normalMap/normalMapProceduralTexture.fragment.fx");
  996. var NormalMapProceduralTexture = /** @class */ (function (_super) {
  997. __extends(NormalMapProceduralTexture, _super);
  998. function NormalMapProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  999. var _this = _super.call(this, name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1000. _this.updateShaderUniforms();
  1001. return _this;
  1002. }
  1003. NormalMapProceduralTexture.prototype.updateShaderUniforms = function () {
  1004. this.setTexture("baseSampler", this._baseTexture);
  1005. this.setFloat("size", this.getRenderSize());
  1006. };
  1007. NormalMapProceduralTexture.prototype.render = function (useCameraPostProcess) {
  1008. _super.prototype.render.call(this, useCameraPostProcess);
  1009. };
  1010. NormalMapProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  1011. _super.prototype.resize.call(this, size, generateMipMaps);
  1012. // We need to update the "size" uniform
  1013. this.updateShaderUniforms();
  1014. };
  1015. Object.defineProperty(NormalMapProceduralTexture.prototype, "baseTexture", {
  1016. get: function () {
  1017. return this._baseTexture;
  1018. },
  1019. set: function (texture) {
  1020. this._baseTexture = texture;
  1021. this.updateShaderUniforms();
  1022. },
  1023. enumerable: true,
  1024. configurable: true
  1025. });
  1026. /**
  1027. * Serializes this normal map procedural texture
  1028. * @returns a serialized normal map procedural texture object
  1029. */
  1030. NormalMapProceduralTexture.prototype.serialize = function () {
  1031. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1032. serializationObject.customType = "BABYLON.NormalMapProceduralTexture";
  1033. return serializationObject;
  1034. };
  1035. /**
  1036. * Creates a Normal Map Procedural Texture from parsed normal map procedural texture data
  1037. * @param parsedTexture defines parsed texture data
  1038. * @param scene defines the current scene
  1039. * @param rootUrl defines the root URL containing normal map procedural texture information
  1040. * @returns a parsed Normal Map Procedural Texture
  1041. */
  1042. NormalMapProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1043. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new NormalMapProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1044. return texture;
  1045. };
  1046. __decorate([
  1047. babylonjs_1.serializeAsTexture()
  1048. ], NormalMapProceduralTexture.prototype, "baseTexture", null);
  1049. return NormalMapProceduralTexture;
  1050. }(babylonjs_1.ProceduralTexture));
  1051. exports.NormalMapProceduralTexture = NormalMapProceduralTexture;
  1052. /***/ }),
  1053. /***/ "./src/perlinNoise/index.ts":
  1054. /*!**********************************!*\
  1055. !*** ./src/perlinNoise/index.ts ***!
  1056. \**********************************/
  1057. /*! no static exports found */
  1058. /***/ (function(module, exports, __webpack_require__) {
  1059. "use strict";
  1060. function __export(m) {
  1061. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1062. }
  1063. Object.defineProperty(exports, "__esModule", { value: true });
  1064. __export(__webpack_require__(/*! ./perlinNoiseProceduralTexture */ "./src/perlinNoise/perlinNoiseProceduralTexture.ts"));
  1065. /***/ }),
  1066. /***/ "./src/perlinNoise/perlinNoiseProceduralTexture.fragment.fx":
  1067. /*!******************************************************************!*\
  1068. !*** ./src/perlinNoise/perlinNoiseProceduralTexture.fragment.fx ***!
  1069. \******************************************************************/
  1070. /*! no static exports found */
  1071. /***/ (function(module, exports) {
  1072. module.exports = "\nprecision highp float;\n\nuniform float size;\nuniform float time;\nuniform float translationSpeed;\n\nvarying vec2 vUV;\n\nfloat r(float n)\n{\nreturn fract(cos(n*89.42)*343.42);\n}\nvec2 r(vec2 n)\n{\nreturn vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); \n}\nfloat worley(vec2 n,float s)\n{\nfloat dis=1.0;\nfor(int x=-1; x<=1; x++)\n{\nfor(int y=-1; y<=1; y++)\n{\nvec2 p=floor(n/s)+vec2(x,y);\nfloat d=length(r(p)+vec2(x,y)-fract(n/s));\nif (dis>d)\ndis=d;\n}\n}\nreturn 1.0-dis;\n}\nvec3 hash33(vec3 p3)\n{\np3=fract(p3*vec3(0.1031,0.11369,0.13787));\np3+=dot(p3,p3.yxz+19.19);\nreturn -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));\n}\nfloat perlinNoise(vec3 p)\n{\nvec3 pi=floor(p);\nvec3 pf=p-pi;\nvec3 w=pf*pf*(3.0-2.0*pf);\nreturn mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),\nw.x\n),\nw.z\n),\nmix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),\nw.x\n),\nw.z\n),\nw.y\n);\n}\n\nvoid main(void)\n{\nvec2 uv=gl_FragCoord.xy+translationSpeed;\nfloat dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n*(1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);\ngl_FragColor=vec4(vec3(dis/4.0),1.0);\n}\n"
  1073. /***/ }),
  1074. /***/ "./src/perlinNoise/perlinNoiseProceduralTexture.ts":
  1075. /*!*********************************************************!*\
  1076. !*** ./src/perlinNoise/perlinNoiseProceduralTexture.ts ***!
  1077. \*********************************************************/
  1078. /*! no static exports found */
  1079. /***/ (function(module, exports, __webpack_require__) {
  1080. "use strict";
  1081. var __extends = (this && this.__extends) || (function () {
  1082. var extendStatics = function (d, b) {
  1083. extendStatics = Object.setPrototypeOf ||
  1084. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1085. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1086. return extendStatics(d, b);
  1087. }
  1088. return function (d, b) {
  1089. extendStatics(d, b);
  1090. function __() { this.constructor = d; }
  1091. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1092. };
  1093. })();
  1094. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1095. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1096. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1097. 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;
  1098. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1099. };
  1100. Object.defineProperty(exports, "__esModule", { value: true });
  1101. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1102. babylonjs_1.Effect.ShadersStore["perlinNoiseProceduralTexturePixelShader"] = __webpack_require__(/*! ./perlinNoiseProceduralTexture.fragment.fx */ "./src/perlinNoise/perlinNoiseProceduralTexture.fragment.fx");
  1103. var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
  1104. __extends(PerlinNoiseProceduralTexture, _super);
  1105. function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1106. var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1107. _this.time = 0.0;
  1108. _this.timeScale = 1.0;
  1109. _this.translationSpeed = 1.0;
  1110. _this._currentTranslation = 0;
  1111. _this.updateShaderUniforms();
  1112. return _this;
  1113. }
  1114. PerlinNoiseProceduralTexture.prototype.updateShaderUniforms = function () {
  1115. this.setFloat("size", this.getRenderSize());
  1116. var scene = this.getScene();
  1117. if (!scene) {
  1118. return;
  1119. }
  1120. var deltaTime = scene.getEngine().getDeltaTime();
  1121. this.time += deltaTime;
  1122. this.setFloat("time", this.time * this.timeScale / 1000);
  1123. this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
  1124. this.setFloat("translationSpeed", this._currentTranslation);
  1125. };
  1126. PerlinNoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  1127. this.updateShaderUniforms();
  1128. _super.prototype.render.call(this, useCameraPostProcess);
  1129. };
  1130. PerlinNoiseProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  1131. _super.prototype.resize.call(this, size, generateMipMaps);
  1132. };
  1133. /**
  1134. * Serializes this perlin noise procedural texture
  1135. * @returns a serialized perlin noise procedural texture object
  1136. */
  1137. PerlinNoiseProceduralTexture.prototype.serialize = function () {
  1138. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1139. serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
  1140. return serializationObject;
  1141. };
  1142. /**
  1143. * Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
  1144. * @param parsedTexture defines parsed texture data
  1145. * @param scene defines the current scene
  1146. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  1147. * @returns a parsed Perlin Noise Procedural Texture
  1148. */
  1149. PerlinNoiseProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1150. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1151. return texture;
  1152. };
  1153. __decorate([
  1154. babylonjs_1.serialize()
  1155. ], PerlinNoiseProceduralTexture.prototype, "time", void 0);
  1156. __decorate([
  1157. babylonjs_1.serialize()
  1158. ], PerlinNoiseProceduralTexture.prototype, "timeScale", void 0);
  1159. __decorate([
  1160. babylonjs_1.serialize()
  1161. ], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);
  1162. return PerlinNoiseProceduralTexture;
  1163. }(babylonjs_1.ProceduralTexture));
  1164. exports.PerlinNoiseProceduralTexture = PerlinNoiseProceduralTexture;
  1165. /***/ }),
  1166. /***/ "./src/road/index.ts":
  1167. /*!***************************!*\
  1168. !*** ./src/road/index.ts ***!
  1169. \***************************/
  1170. /*! no static exports found */
  1171. /***/ (function(module, exports, __webpack_require__) {
  1172. "use strict";
  1173. function __export(m) {
  1174. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1175. }
  1176. Object.defineProperty(exports, "__esModule", { value: true });
  1177. __export(__webpack_require__(/*! ./roadProceduralTexture */ "./src/road/roadProceduralTexture.ts"));
  1178. /***/ }),
  1179. /***/ "./src/road/roadProceduralTexture.fragment.fx":
  1180. /*!****************************************************!*\
  1181. !*** ./src/road/roadProceduralTexture.fragment.fx ***!
  1182. \****************************************************/
  1183. /*! no static exports found */
  1184. /***/ (function(module, exports) {
  1185. module.exports = "precision highp float;\nvarying vec2 vUV; \nuniform vec3 roadColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nfloat ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));\nvec3 color=roadColor*ratioy;\ngl_FragColor=vec4(color,1.0);\n}"
  1186. /***/ }),
  1187. /***/ "./src/road/roadProceduralTexture.ts":
  1188. /*!*******************************************!*\
  1189. !*** ./src/road/roadProceduralTexture.ts ***!
  1190. \*******************************************/
  1191. /*! no static exports found */
  1192. /***/ (function(module, exports, __webpack_require__) {
  1193. "use strict";
  1194. var __extends = (this && this.__extends) || (function () {
  1195. var extendStatics = function (d, b) {
  1196. extendStatics = Object.setPrototypeOf ||
  1197. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1198. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1199. return extendStatics(d, b);
  1200. }
  1201. return function (d, b) {
  1202. extendStatics(d, b);
  1203. function __() { this.constructor = d; }
  1204. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1205. };
  1206. })();
  1207. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1208. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1209. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1210. 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;
  1211. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1212. };
  1213. Object.defineProperty(exports, "__esModule", { value: true });
  1214. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1215. babylonjs_1.Effect.ShadersStore["roadProceduralTexturePixelShader"] = __webpack_require__(/*! ./roadProceduralTexture.fragment.fx */ "./src/road/roadProceduralTexture.fragment.fx");
  1216. var RoadProceduralTexture = /** @class */ (function (_super) {
  1217. __extends(RoadProceduralTexture, _super);
  1218. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1219. var _this = _super.call(this, name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1220. _this._roadColor = new babylonjs_1.Color3(0.53, 0.53, 0.53);
  1221. _this.updateShaderUniforms();
  1222. return _this;
  1223. }
  1224. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  1225. this.setColor3("roadColor", this._roadColor);
  1226. };
  1227. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  1228. get: function () {
  1229. return this._roadColor;
  1230. },
  1231. set: function (value) {
  1232. this._roadColor = value;
  1233. this.updateShaderUniforms();
  1234. },
  1235. enumerable: true,
  1236. configurable: true
  1237. });
  1238. /**
  1239. * Serializes this road procedural texture
  1240. * @returns a serialized road procedural texture object
  1241. */
  1242. RoadProceduralTexture.prototype.serialize = function () {
  1243. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1244. serializationObject.customType = "BABYLON.RoadProceduralTexture";
  1245. return serializationObject;
  1246. };
  1247. /**
  1248. * Creates a Road Procedural Texture from parsed road procedural texture data
  1249. * @param parsedTexture defines parsed texture data
  1250. * @param scene defines the current scene
  1251. * @param rootUrl defines the root URL containing road procedural texture information
  1252. * @returns a parsed Road Procedural Texture
  1253. */
  1254. RoadProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1255. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1256. return texture;
  1257. };
  1258. __decorate([
  1259. babylonjs_1.serializeAsColor3()
  1260. ], RoadProceduralTexture.prototype, "roadColor", null);
  1261. return RoadProceduralTexture;
  1262. }(babylonjs_1.ProceduralTexture));
  1263. exports.RoadProceduralTexture = RoadProceduralTexture;
  1264. /***/ }),
  1265. /***/ "./src/starfield/index.ts":
  1266. /*!********************************!*\
  1267. !*** ./src/starfield/index.ts ***!
  1268. \********************************/
  1269. /*! no static exports found */
  1270. /***/ (function(module, exports, __webpack_require__) {
  1271. "use strict";
  1272. function __export(m) {
  1273. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1274. }
  1275. Object.defineProperty(exports, "__esModule", { value: true });
  1276. __export(__webpack_require__(/*! ./starfieldProceduralTexture */ "./src/starfield/starfieldProceduralTexture.ts"));
  1277. /***/ }),
  1278. /***/ "./src/starfield/starfieldProceduralTexture.fragment.fx":
  1279. /*!**************************************************************!*\
  1280. !*** ./src/starfield/starfieldProceduralTexture.fragment.fx ***!
  1281. \**************************************************************/
  1282. /*! no static exports found */
  1283. /***/ (function(module, exports) {
  1284. module.exports = "precision highp float;\n\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float time;\nuniform float alpha;\nuniform float beta;\nuniform float zoom;\nuniform float formuparam;\nuniform float stepsize;\nuniform float tile;\nuniform float brightness;\nuniform float darkmatter;\nuniform float distfading;\nuniform float saturation;\nvoid main()\n{\nvec3 dir=vec3(vUV*zoom,1.);\nfloat localTime=time*0.0001;\n\nmat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));\nmat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));\ndir.xz*=rot1;\ndir.xy*=rot2;\nvec3 from=vec3(1.,.5,0.5);\nfrom+=vec3(-2.,localTime*2.,localTime);\nfrom.xz*=rot1;\nfrom.xy*=rot2;\n\nfloat s=0.1,fade=1.;\nvec3 v=vec3(0.);\nfor (int r=0; r<volsteps; r++) {\nvec3 p=from+s*dir*.5;\np=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;\nfor (int i=0; i<iterations; i++) {\np=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);\n}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \n\nv+=fade;\nv+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;\n}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);\n}"
  1285. /***/ }),
  1286. /***/ "./src/starfield/starfieldProceduralTexture.ts":
  1287. /*!*****************************************************!*\
  1288. !*** ./src/starfield/starfieldProceduralTexture.ts ***!
  1289. \*****************************************************/
  1290. /*! no static exports found */
  1291. /***/ (function(module, exports, __webpack_require__) {
  1292. "use strict";
  1293. var __extends = (this && this.__extends) || (function () {
  1294. var extendStatics = function (d, b) {
  1295. extendStatics = Object.setPrototypeOf ||
  1296. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1297. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1298. return extendStatics(d, b);
  1299. }
  1300. return function (d, b) {
  1301. extendStatics(d, b);
  1302. function __() { this.constructor = d; }
  1303. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1304. };
  1305. })();
  1306. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1307. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1308. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1309. 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;
  1310. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1311. };
  1312. Object.defineProperty(exports, "__esModule", { value: true });
  1313. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1314. babylonjs_1.Effect.ShadersStore["starfieldProceduralTexturePixelShader"] = __webpack_require__(/*! ./starfieldProceduralTexture.fragment.fx */ "./src/starfield/starfieldProceduralTexture.fragment.fx");
  1315. var StarfieldProceduralTexture = /** @class */ (function (_super) {
  1316. __extends(StarfieldProceduralTexture, _super);
  1317. function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1318. var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1319. _this._time = 1;
  1320. _this._alpha = 0.5;
  1321. _this._beta = 0.8;
  1322. _this._zoom = 0.8;
  1323. _this._formuparam = 0.53;
  1324. _this._stepsize = 0.1;
  1325. _this._tile = 0.850;
  1326. _this._brightness = 0.0015;
  1327. _this._darkmatter = 0.400;
  1328. _this._distfading = 0.730;
  1329. _this._saturation = 0.850;
  1330. _this.updateShaderUniforms();
  1331. return _this;
  1332. }
  1333. StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
  1334. this.setFloat("time", this._time);
  1335. this.setFloat("alpha", this._alpha);
  1336. this.setFloat("beta", this._beta);
  1337. this.setFloat("zoom", this._zoom);
  1338. this.setFloat("formuparam", this._formuparam);
  1339. this.setFloat("stepsize", this._stepsize);
  1340. this.setFloat("tile", this._tile);
  1341. this.setFloat("brightness", this._brightness);
  1342. this.setFloat("darkmatter", this._darkmatter);
  1343. this.setFloat("distfading", this._distfading);
  1344. this.setFloat("saturation", this._saturation);
  1345. };
  1346. Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
  1347. get: function () {
  1348. return this._time;
  1349. },
  1350. set: function (value) {
  1351. this._time = value;
  1352. this.updateShaderUniforms();
  1353. },
  1354. enumerable: true,
  1355. configurable: true
  1356. });
  1357. Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
  1358. get: function () {
  1359. return this._alpha;
  1360. },
  1361. set: function (value) {
  1362. this._alpha = value;
  1363. this.updateShaderUniforms();
  1364. },
  1365. enumerable: true,
  1366. configurable: true
  1367. });
  1368. Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
  1369. get: function () {
  1370. return this._beta;
  1371. },
  1372. set: function (value) {
  1373. this._beta = value;
  1374. this.updateShaderUniforms();
  1375. },
  1376. enumerable: true,
  1377. configurable: true
  1378. });
  1379. Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
  1380. get: function () {
  1381. return this._formuparam;
  1382. },
  1383. set: function (value) {
  1384. this._formuparam = value;
  1385. this.updateShaderUniforms();
  1386. },
  1387. enumerable: true,
  1388. configurable: true
  1389. });
  1390. Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
  1391. get: function () {
  1392. return this._stepsize;
  1393. },
  1394. set: function (value) {
  1395. this._stepsize = value;
  1396. this.updateShaderUniforms();
  1397. },
  1398. enumerable: true,
  1399. configurable: true
  1400. });
  1401. Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
  1402. get: function () {
  1403. return this._zoom;
  1404. },
  1405. set: function (value) {
  1406. this._zoom = value;
  1407. this.updateShaderUniforms();
  1408. },
  1409. enumerable: true,
  1410. configurable: true
  1411. });
  1412. Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
  1413. get: function () {
  1414. return this._tile;
  1415. },
  1416. set: function (value) {
  1417. this._tile = value;
  1418. this.updateShaderUniforms();
  1419. },
  1420. enumerable: true,
  1421. configurable: true
  1422. });
  1423. Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
  1424. get: function () {
  1425. return this._brightness;
  1426. },
  1427. set: function (value) {
  1428. this._brightness = value;
  1429. this.updateShaderUniforms();
  1430. },
  1431. enumerable: true,
  1432. configurable: true
  1433. });
  1434. Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
  1435. get: function () {
  1436. return this._darkmatter;
  1437. },
  1438. set: function (value) {
  1439. this._darkmatter = value;
  1440. this.updateShaderUniforms();
  1441. },
  1442. enumerable: true,
  1443. configurable: true
  1444. });
  1445. Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
  1446. get: function () {
  1447. return this._distfading;
  1448. },
  1449. set: function (value) {
  1450. this._distfading = value;
  1451. this.updateShaderUniforms();
  1452. },
  1453. enumerable: true,
  1454. configurable: true
  1455. });
  1456. Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
  1457. get: function () {
  1458. return this._saturation;
  1459. },
  1460. set: function (value) {
  1461. this._saturation = value;
  1462. this.updateShaderUniforms();
  1463. },
  1464. enumerable: true,
  1465. configurable: true
  1466. });
  1467. /**
  1468. * Serializes this starfield procedural texture
  1469. * @returns a serialized starfield procedural texture object
  1470. */
  1471. StarfieldProceduralTexture.prototype.serialize = function () {
  1472. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1473. serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
  1474. return serializationObject;
  1475. };
  1476. /**
  1477. * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
  1478. * @param parsedTexture defines parsed texture data
  1479. * @param scene defines the current scene
  1480. * @param rootUrl defines the root URL containing startfield procedural texture information
  1481. * @returns a parsed Starfield Procedural Texture
  1482. */
  1483. StarfieldProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1484. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1485. return texture;
  1486. };
  1487. __decorate([
  1488. babylonjs_1.serialize()
  1489. ], StarfieldProceduralTexture.prototype, "time", null);
  1490. __decorate([
  1491. babylonjs_1.serialize()
  1492. ], StarfieldProceduralTexture.prototype, "alpha", null);
  1493. __decorate([
  1494. babylonjs_1.serialize()
  1495. ], StarfieldProceduralTexture.prototype, "beta", null);
  1496. __decorate([
  1497. babylonjs_1.serialize()
  1498. ], StarfieldProceduralTexture.prototype, "formuparam", null);
  1499. __decorate([
  1500. babylonjs_1.serialize()
  1501. ], StarfieldProceduralTexture.prototype, "stepsize", null);
  1502. __decorate([
  1503. babylonjs_1.serialize()
  1504. ], StarfieldProceduralTexture.prototype, "zoom", null);
  1505. __decorate([
  1506. babylonjs_1.serialize()
  1507. ], StarfieldProceduralTexture.prototype, "tile", null);
  1508. __decorate([
  1509. babylonjs_1.serialize()
  1510. ], StarfieldProceduralTexture.prototype, "brightness", null);
  1511. __decorate([
  1512. babylonjs_1.serialize()
  1513. ], StarfieldProceduralTexture.prototype, "darkmatter", null);
  1514. __decorate([
  1515. babylonjs_1.serialize()
  1516. ], StarfieldProceduralTexture.prototype, "distfading", null);
  1517. __decorate([
  1518. babylonjs_1.serialize()
  1519. ], StarfieldProceduralTexture.prototype, "saturation", null);
  1520. return StarfieldProceduralTexture;
  1521. }(babylonjs_1.ProceduralTexture));
  1522. exports.StarfieldProceduralTexture = StarfieldProceduralTexture;
  1523. /***/ }),
  1524. /***/ "./src/wood/index.ts":
  1525. /*!***************************!*\
  1526. !*** ./src/wood/index.ts ***!
  1527. \***************************/
  1528. /*! no static exports found */
  1529. /***/ (function(module, exports, __webpack_require__) {
  1530. "use strict";
  1531. function __export(m) {
  1532. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1533. }
  1534. Object.defineProperty(exports, "__esModule", { value: true });
  1535. __export(__webpack_require__(/*! ./woodProceduralTexture */ "./src/wood/woodProceduralTexture.ts"));
  1536. /***/ }),
  1537. /***/ "./src/wood/woodProceduralTexture.fragment.fx":
  1538. /*!****************************************************!*\
  1539. !*** ./src/wood/woodProceduralTexture.fragment.fx ***!
  1540. \****************************************************/
  1541. /*! no static exports found */
  1542. /***/ (function(module, exports) {
  1543. module.exports = "precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float ampScale;\nuniform vec3 woodColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main(void) {\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));\nvec3 wood=woodColor*ratioy;\ngl_FragColor=vec4(wood,1.0);\n}"
  1544. /***/ }),
  1545. /***/ "./src/wood/woodProceduralTexture.ts":
  1546. /*!*******************************************!*\
  1547. !*** ./src/wood/woodProceduralTexture.ts ***!
  1548. \*******************************************/
  1549. /*! no static exports found */
  1550. /***/ (function(module, exports, __webpack_require__) {
  1551. "use strict";
  1552. var __extends = (this && this.__extends) || (function () {
  1553. var extendStatics = function (d, b) {
  1554. extendStatics = Object.setPrototypeOf ||
  1555. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1556. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1557. return extendStatics(d, b);
  1558. }
  1559. return function (d, b) {
  1560. extendStatics(d, b);
  1561. function __() { this.constructor = d; }
  1562. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1563. };
  1564. })();
  1565. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1566. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1567. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1568. 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;
  1569. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1570. };
  1571. Object.defineProperty(exports, "__esModule", { value: true });
  1572. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1573. babylonjs_1.Effect.ShadersStore["woodProceduralTexturePixelShader"] = __webpack_require__(/*! ./woodProceduralTexture.fragment.fx */ "./src/wood/woodProceduralTexture.fragment.fx");
  1574. var WoodProceduralTexture = /** @class */ (function (_super) {
  1575. __extends(WoodProceduralTexture, _super);
  1576. function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  1577. var _this = _super.call(this, name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  1578. _this._ampScale = 100.0;
  1579. _this._woodColor = new babylonjs_1.Color3(0.32, 0.17, 0.09);
  1580. _this.updateShaderUniforms();
  1581. return _this;
  1582. }
  1583. WoodProceduralTexture.prototype.updateShaderUniforms = function () {
  1584. this.setFloat("ampScale", this._ampScale);
  1585. this.setColor3("woodColor", this._woodColor);
  1586. };
  1587. Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
  1588. get: function () {
  1589. return this._ampScale;
  1590. },
  1591. set: function (value) {
  1592. this._ampScale = value;
  1593. this.updateShaderUniforms();
  1594. },
  1595. enumerable: true,
  1596. configurable: true
  1597. });
  1598. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
  1599. get: function () {
  1600. return this._woodColor;
  1601. },
  1602. set: function (value) {
  1603. this._woodColor = value;
  1604. this.updateShaderUniforms();
  1605. },
  1606. enumerable: true,
  1607. configurable: true
  1608. });
  1609. /**
  1610. * Serializes this wood procedural texture
  1611. * @returns a serialized wood procedural texture object
  1612. */
  1613. WoodProceduralTexture.prototype.serialize = function () {
  1614. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  1615. serializationObject.customType = "BABYLON.WoodProceduralTexture";
  1616. return serializationObject;
  1617. };
  1618. /**
  1619. * Creates a Wood Procedural Texture from parsed wood procedural texture data
  1620. * @param parsedTexture defines parsed texture data
  1621. * @param scene defines the current scene
  1622. * @param rootUrl defines the root URL containing wood procedural texture information
  1623. * @returns a parsed Wood Procedural Texture
  1624. */
  1625. WoodProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  1626. var texture = babylonjs_1.SerializationHelper.Parse(function () { return new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  1627. return texture;
  1628. };
  1629. __decorate([
  1630. babylonjs_1.serialize()
  1631. ], WoodProceduralTexture.prototype, "ampScale", null);
  1632. __decorate([
  1633. babylonjs_1.serializeAsColor3()
  1634. ], WoodProceduralTexture.prototype, "woodColor", null);
  1635. return WoodProceduralTexture;
  1636. }(babylonjs_1.ProceduralTexture));
  1637. exports.WoodProceduralTexture = WoodProceduralTexture;
  1638. /***/ }),
  1639. /***/ "babylonjs":
  1640. /*!****************************************************************************************************!*\
  1641. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  1642. \****************************************************************************************************/
  1643. /*! no static exports found */
  1644. /***/ (function(module, exports) {
  1645. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  1646. /***/ })
  1647. /******/ });
  1648. });
  1649. //# sourceMappingURL=babylonjs.proceduralTextures.js.map