babylonjs.proceduralTextures.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. (function universalModuleDefinition(root, factory) {
  2. var amdDependencies = [];
  3. var BABYLON = root.BABYLON || this.BABYLON;
  4. if(typeof exports === 'object' && typeof module === 'object') {
  5. BABYLON = BABYLON || require("babylonjs");
  6. module.exports = factory(BABYLON);
  7. } else if(typeof define === 'function' && define.amd) {
  8. amdDependencies.push("babylonjs");
  9. define("babylonjs-procedural-textures", amdDependencies, factory);
  10. } else if(typeof exports === 'object') {
  11. BABYLON = BABYLON || require("babylonjs");
  12. exports["babylonjs-procedural-textures"] = factory(BABYLON);
  13. } else {
  14. root["BABYLON"] = factory(BABYLON);
  15. }
  16. })(this, function(BABYLON) {
  17. BABYLON = BABYLON || this.BABYLON;
  18. var __decorate=this&&this.__decorate||function(e,t,r,c){var o,f=arguments.length,n=f<3?t:null===c?c=Object.getOwnPropertyDescriptor(t,r):c;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,r,c);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(n=(f<3?o(n):f>3?o(t,r,n):o(t,r))||n);return f>3&&n&&Object.defineProperty(t,r,n),n};
  19. var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)o.hasOwnProperty(n)&&(t[n]=o[n])};return function(o,n){function r(){this.constructor=o}t(o,n),o.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();
  20. "use strict";
  21. var BABYLON;
  22. (function (BABYLON) {
  23. var WoodProceduralTexture = /** @class */ (function (_super) {
  24. __extends(WoodProceduralTexture, _super);
  25. function WoodProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  26. var _this = _super.call(this, name, size, "woodProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  27. _this._ampScale = 100.0;
  28. _this._woodColor = new BABYLON.Color3(0.32, 0.17, 0.09);
  29. _this.updateShaderUniforms();
  30. return _this;
  31. }
  32. WoodProceduralTexture.prototype.updateShaderUniforms = function () {
  33. this.setFloat("ampScale", this._ampScale);
  34. this.setColor3("woodColor", this._woodColor);
  35. };
  36. Object.defineProperty(WoodProceduralTexture.prototype, "ampScale", {
  37. get: function () {
  38. return this._ampScale;
  39. },
  40. set: function (value) {
  41. this._ampScale = value;
  42. this.updateShaderUniforms();
  43. },
  44. enumerable: true,
  45. configurable: true
  46. });
  47. Object.defineProperty(WoodProceduralTexture.prototype, "woodColor", {
  48. get: function () {
  49. return this._woodColor;
  50. },
  51. set: function (value) {
  52. this._woodColor = value;
  53. this.updateShaderUniforms();
  54. },
  55. enumerable: true,
  56. configurable: true
  57. });
  58. return WoodProceduralTexture;
  59. }(BABYLON.ProceduralTexture));
  60. BABYLON.WoodProceduralTexture = WoodProceduralTexture;
  61. })(BABYLON || (BABYLON = {}));
  62. //# sourceMappingURL=babylon.woodProceduralTexture.js.map
  63. BABYLON.Effect.ShadersStore['woodProceduralTexturePixelShader'] = "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}";
  64. "use strict";
  65. var BABYLON;
  66. (function (BABYLON) {
  67. var FireProceduralTexture = /** @class */ (function (_super) {
  68. __extends(FireProceduralTexture, _super);
  69. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  70. var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  71. _this._time = 0.0;
  72. _this._speed = new BABYLON.Vector2(0.5, 0.3);
  73. _this._autoGenerateTime = true;
  74. _this._alphaThreshold = 0.5;
  75. _this._fireColors = FireProceduralTexture.RedFireColors;
  76. _this.updateShaderUniforms();
  77. return _this;
  78. }
  79. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  80. this.setFloat("time", this._time);
  81. this.setVector2("speed", this._speed);
  82. this.setColor3("c1", this._fireColors[0]);
  83. this.setColor3("c2", this._fireColors[1]);
  84. this.setColor3("c3", this._fireColors[2]);
  85. this.setColor3("c4", this._fireColors[3]);
  86. this.setColor3("c5", this._fireColors[4]);
  87. this.setColor3("c6", this._fireColors[5]);
  88. this.setFloat("alphaThreshold", this._alphaThreshold);
  89. };
  90. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  91. var scene = this.getScene();
  92. if (this._autoGenerateTime && scene) {
  93. this._time += scene.getAnimationRatio() * 0.03;
  94. this.updateShaderUniforms();
  95. }
  96. _super.prototype.render.call(this, useCameraPostProcess);
  97. };
  98. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  99. get: function () {
  100. return [
  101. new BABYLON.Color3(0.5, 0.0, 1.0),
  102. new BABYLON.Color3(0.9, 0.0, 1.0),
  103. new BABYLON.Color3(0.2, 0.0, 1.0),
  104. new BABYLON.Color3(1.0, 0.9, 1.0),
  105. new BABYLON.Color3(0.1, 0.1, 1.0),
  106. new BABYLON.Color3(0.9, 0.9, 1.0)
  107. ];
  108. },
  109. enumerable: true,
  110. configurable: true
  111. });
  112. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  113. get: function () {
  114. return [
  115. new BABYLON.Color3(0.5, 1.0, 0.0),
  116. new BABYLON.Color3(0.5, 1.0, 0.0),
  117. new BABYLON.Color3(0.3, 0.4, 0.0),
  118. new BABYLON.Color3(0.5, 1.0, 0.0),
  119. new BABYLON.Color3(0.2, 0.0, 0.0),
  120. new BABYLON.Color3(0.5, 1.0, 0.0)
  121. ];
  122. },
  123. enumerable: true,
  124. configurable: true
  125. });
  126. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  127. get: function () {
  128. return [
  129. new BABYLON.Color3(0.5, 0.0, 0.1),
  130. new BABYLON.Color3(0.9, 0.0, 0.0),
  131. new BABYLON.Color3(0.2, 0.0, 0.0),
  132. new BABYLON.Color3(1.0, 0.9, 0.0),
  133. new BABYLON.Color3(0.1, 0.1, 0.1),
  134. new BABYLON.Color3(0.9, 0.9, 0.9)
  135. ];
  136. },
  137. enumerable: true,
  138. configurable: true
  139. });
  140. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  141. get: function () {
  142. return [
  143. new BABYLON.Color3(0.1, 0.0, 0.5),
  144. new BABYLON.Color3(0.0, 0.0, 0.5),
  145. new BABYLON.Color3(0.1, 0.0, 0.2),
  146. new BABYLON.Color3(0.0, 0.0, 1.0),
  147. new BABYLON.Color3(0.1, 0.2, 0.3),
  148. new BABYLON.Color3(0.0, 0.2, 0.9)
  149. ];
  150. },
  151. enumerable: true,
  152. configurable: true
  153. });
  154. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  155. get: function () {
  156. return this._fireColors;
  157. },
  158. set: function (value) {
  159. this._fireColors = value;
  160. this.updateShaderUniforms();
  161. },
  162. enumerable: true,
  163. configurable: true
  164. });
  165. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  166. get: function () {
  167. return this._time;
  168. },
  169. set: function (value) {
  170. this._time = value;
  171. this.updateShaderUniforms();
  172. },
  173. enumerable: true,
  174. configurable: true
  175. });
  176. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  177. get: function () {
  178. return this._speed;
  179. },
  180. set: function (value) {
  181. this._speed = value;
  182. this.updateShaderUniforms();
  183. },
  184. enumerable: true,
  185. configurable: true
  186. });
  187. Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
  188. get: function () {
  189. return this._alphaThreshold;
  190. },
  191. set: function (value) {
  192. this._alphaThreshold = value;
  193. this.updateShaderUniforms();
  194. },
  195. enumerable: true,
  196. configurable: true
  197. });
  198. return FireProceduralTexture;
  199. }(BABYLON.ProceduralTexture));
  200. BABYLON.FireProceduralTexture = FireProceduralTexture;
  201. })(BABYLON || (BABYLON = {}));
  202. //# sourceMappingURL=babylon.fireProceduralTexture.js.map
  203. BABYLON.Effect.ShadersStore['fireProceduralTexturePixelShader'] = "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}";
  204. "use strict";
  205. var BABYLON;
  206. (function (BABYLON) {
  207. var CloudProceduralTexture = /** @class */ (function (_super) {
  208. __extends(CloudProceduralTexture, _super);
  209. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  210. var _this = _super.call(this, name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  211. _this._skyColor = new BABYLON.Color4(0.15, 0.68, 1.0, 1.0);
  212. _this._cloudColor = new BABYLON.Color4(1, 1, 1, 1.0);
  213. _this.updateShaderUniforms();
  214. return _this;
  215. }
  216. CloudProceduralTexture.prototype.updateShaderUniforms = function () {
  217. this.setColor4("skyColor", this._skyColor);
  218. this.setColor4("cloudColor", this._cloudColor);
  219. };
  220. Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
  221. get: function () {
  222. return this._skyColor;
  223. },
  224. set: function (value) {
  225. this._skyColor = value;
  226. this.updateShaderUniforms();
  227. },
  228. enumerable: true,
  229. configurable: true
  230. });
  231. Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
  232. get: function () {
  233. return this._cloudColor;
  234. },
  235. set: function (value) {
  236. this._cloudColor = value;
  237. this.updateShaderUniforms();
  238. },
  239. enumerable: true,
  240. configurable: true
  241. });
  242. return CloudProceduralTexture;
  243. }(BABYLON.ProceduralTexture));
  244. BABYLON.CloudProceduralTexture = CloudProceduralTexture;
  245. })(BABYLON || (BABYLON = {}));
  246. //# sourceMappingURL=babylon.cloudProceduralTexture.js.map
  247. BABYLON.Effect.ShadersStore['cloudProceduralTexturePixelShader'] = "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";
  248. "use strict";
  249. var BABYLON;
  250. (function (BABYLON) {
  251. var GrassProceduralTexture = /** @class */ (function (_super) {
  252. __extends(GrassProceduralTexture, _super);
  253. function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  254. var _this = _super.call(this, name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  255. _this._groundColor = new BABYLON.Color3(1, 1, 1);
  256. _this._grassColors = [
  257. new BABYLON.Color3(0.29, 0.38, 0.02),
  258. new BABYLON.Color3(0.36, 0.49, 0.09),
  259. new BABYLON.Color3(0.51, 0.6, 0.28)
  260. ];
  261. _this.updateShaderUniforms();
  262. return _this;
  263. }
  264. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  265. this.setColor3("herb1Color", this._grassColors[0]);
  266. this.setColor3("herb2Color", this._grassColors[1]);
  267. this.setColor3("herb3Color", this._grassColors[2]);
  268. this.setColor3("groundColor", this._groundColor);
  269. };
  270. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  271. get: function () {
  272. return this._grassColors;
  273. },
  274. set: function (value) {
  275. this._grassColors = value;
  276. this.updateShaderUniforms();
  277. },
  278. enumerable: true,
  279. configurable: true
  280. });
  281. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  282. get: function () {
  283. return this._groundColor;
  284. },
  285. set: function (value) {
  286. this._groundColor = value;
  287. this.updateShaderUniforms();
  288. },
  289. enumerable: true,
  290. configurable: true
  291. });
  292. return GrassProceduralTexture;
  293. }(BABYLON.ProceduralTexture));
  294. BABYLON.GrassProceduralTexture = GrassProceduralTexture;
  295. })(BABYLON || (BABYLON = {}));
  296. //# sourceMappingURL=babylon.grassProceduralTexture.js.map
  297. BABYLON.Effect.ShadersStore['grassProceduralTexturePixelShader'] = "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}";
  298. "use strict";
  299. var BABYLON;
  300. (function (BABYLON) {
  301. var RoadProceduralTexture = /** @class */ (function (_super) {
  302. __extends(RoadProceduralTexture, _super);
  303. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  304. var _this = _super.call(this, name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  305. _this._roadColor = new BABYLON.Color3(0.53, 0.53, 0.53);
  306. _this.updateShaderUniforms();
  307. return _this;
  308. }
  309. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  310. this.setColor3("roadColor", this._roadColor);
  311. };
  312. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  313. get: function () {
  314. return this._roadColor;
  315. },
  316. set: function (value) {
  317. this._roadColor = value;
  318. this.updateShaderUniforms();
  319. },
  320. enumerable: true,
  321. configurable: true
  322. });
  323. return RoadProceduralTexture;
  324. }(BABYLON.ProceduralTexture));
  325. BABYLON.RoadProceduralTexture = RoadProceduralTexture;
  326. })(BABYLON || (BABYLON = {}));
  327. //# sourceMappingURL=babylon.roadProceduralTexture.js.map
  328. BABYLON.Effect.ShadersStore['roadProceduralTexturePixelShader'] = "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}";
  329. "use strict";
  330. var BABYLON;
  331. (function (BABYLON) {
  332. var BrickProceduralTexture = /** @class */ (function (_super) {
  333. __extends(BrickProceduralTexture, _super);
  334. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  335. var _this = _super.call(this, name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  336. _this._numberOfBricksHeight = 15;
  337. _this._numberOfBricksWidth = 5;
  338. _this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  339. _this._brickColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  340. _this.updateShaderUniforms();
  341. return _this;
  342. }
  343. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  344. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  345. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  346. this.setColor3("brickColor", this._brickColor);
  347. this.setColor3("jointColor", this._jointColor);
  348. };
  349. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  350. get: function () {
  351. return this._numberOfBricksHeight;
  352. },
  353. set: function (value) {
  354. this._numberOfBricksHeight = value;
  355. this.updateShaderUniforms();
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  361. get: function () {
  362. return this._numberOfBricksWidth;
  363. },
  364. set: function (value) {
  365. this._numberOfBricksWidth = value;
  366. this.updateShaderUniforms();
  367. },
  368. enumerable: true,
  369. configurable: true
  370. });
  371. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  372. get: function () {
  373. return this._jointColor;
  374. },
  375. set: function (value) {
  376. this._jointColor = value;
  377. this.updateShaderUniforms();
  378. },
  379. enumerable: true,
  380. configurable: true
  381. });
  382. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  383. get: function () {
  384. return this._brickColor;
  385. },
  386. set: function (value) {
  387. this._brickColor = value;
  388. this.updateShaderUniforms();
  389. },
  390. enumerable: true,
  391. configurable: true
  392. });
  393. return BrickProceduralTexture;
  394. }(BABYLON.ProceduralTexture));
  395. BABYLON.BrickProceduralTexture = BrickProceduralTexture;
  396. })(BABYLON || (BABYLON = {}));
  397. //# sourceMappingURL=babylon.brickProceduralTexture.js.map
  398. BABYLON.Effect.ShadersStore['brickProceduralTexturePixelShader'] = "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}";
  399. "use strict";
  400. var BABYLON;
  401. (function (BABYLON) {
  402. var MarbleProceduralTexture = /** @class */ (function (_super) {
  403. __extends(MarbleProceduralTexture, _super);
  404. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  405. var _this = _super.call(this, name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  406. _this._numberOfTilesHeight = 3;
  407. _this._numberOfTilesWidth = 3;
  408. _this._amplitude = 9.0;
  409. _this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  410. _this.updateShaderUniforms();
  411. return _this;
  412. }
  413. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  414. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  415. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  416. this.setFloat("amplitude", this._amplitude);
  417. this.setColor3("jointColor", this._jointColor);
  418. };
  419. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  420. get: function () {
  421. return this._numberOfTilesHeight;
  422. },
  423. set: function (value) {
  424. this._numberOfTilesHeight = value;
  425. this.updateShaderUniforms();
  426. },
  427. enumerable: true,
  428. configurable: true
  429. });
  430. Object.defineProperty(MarbleProceduralTexture.prototype, "amplitude", {
  431. get: function () {
  432. return this._amplitude;
  433. },
  434. set: function (value) {
  435. this._amplitude = value;
  436. this.updateShaderUniforms();
  437. },
  438. enumerable: true,
  439. configurable: true
  440. });
  441. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  442. get: function () {
  443. return this._numberOfTilesWidth;
  444. },
  445. set: function (value) {
  446. this._numberOfTilesWidth = value;
  447. this.updateShaderUniforms();
  448. },
  449. enumerable: true,
  450. configurable: true
  451. });
  452. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  453. get: function () {
  454. return this._jointColor;
  455. },
  456. set: function (value) {
  457. this._jointColor = value;
  458. this.updateShaderUniforms();
  459. },
  460. enumerable: true,
  461. configurable: true
  462. });
  463. return MarbleProceduralTexture;
  464. }(BABYLON.ProceduralTexture));
  465. BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
  466. })(BABYLON || (BABYLON = {}));
  467. //# sourceMappingURL=babylon.marbleProceduralTexture.js.map
  468. BABYLON.Effect.ShadersStore['marbleProceduralTexturePixelShader'] = "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}";
  469. "use strict";
  470. var BABYLON;
  471. (function (BABYLON) {
  472. var StarfieldProceduralTexture = /** @class */ (function (_super) {
  473. __extends(StarfieldProceduralTexture, _super);
  474. function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  475. var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  476. _this._time = 1;
  477. _this._alpha = 0.5;
  478. _this._beta = 0.8;
  479. _this._zoom = 0.8;
  480. _this._formuparam = 0.53;
  481. _this._stepsize = 0.1;
  482. _this._tile = 0.850;
  483. _this._brightness = 0.0015;
  484. _this._darkmatter = 0.400;
  485. _this._distfading = 0.730;
  486. _this._saturation = 0.850;
  487. _this.updateShaderUniforms();
  488. return _this;
  489. }
  490. StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
  491. this.setFloat("time", this._time);
  492. this.setFloat("alpha", this._alpha);
  493. this.setFloat("beta", this._beta);
  494. this.setFloat("zoom", this._zoom);
  495. this.setFloat("formuparam", this._formuparam);
  496. this.setFloat("stepsize", this._stepsize);
  497. this.setFloat("tile", this._tile);
  498. this.setFloat("brightness", this._brightness);
  499. this.setFloat("darkmatter", this._darkmatter);
  500. this.setFloat("distfading", this._distfading);
  501. this.setFloat("saturation", this._saturation);
  502. };
  503. Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
  504. get: function () {
  505. return this._time;
  506. },
  507. set: function (value) {
  508. this._time = value;
  509. this.updateShaderUniforms();
  510. },
  511. enumerable: true,
  512. configurable: true
  513. });
  514. Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
  515. get: function () {
  516. return this._alpha;
  517. },
  518. set: function (value) {
  519. this._alpha = value;
  520. this.updateShaderUniforms();
  521. },
  522. enumerable: true,
  523. configurable: true
  524. });
  525. Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
  526. get: function () {
  527. return this._beta;
  528. },
  529. set: function (value) {
  530. this._beta = value;
  531. this.updateShaderUniforms();
  532. },
  533. enumerable: true,
  534. configurable: true
  535. });
  536. Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
  537. get: function () {
  538. return this._formuparam;
  539. },
  540. set: function (value) {
  541. this._formuparam = value;
  542. this.updateShaderUniforms();
  543. },
  544. enumerable: true,
  545. configurable: true
  546. });
  547. Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
  548. get: function () {
  549. return this._stepsize;
  550. },
  551. set: function (value) {
  552. this._stepsize = value;
  553. this.updateShaderUniforms();
  554. },
  555. enumerable: true,
  556. configurable: true
  557. });
  558. Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
  559. get: function () {
  560. return this._zoom;
  561. },
  562. set: function (value) {
  563. this._zoom = value;
  564. this.updateShaderUniforms();
  565. },
  566. enumerable: true,
  567. configurable: true
  568. });
  569. Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
  570. get: function () {
  571. return this._tile;
  572. },
  573. set: function (value) {
  574. this._tile = value;
  575. this.updateShaderUniforms();
  576. },
  577. enumerable: true,
  578. configurable: true
  579. });
  580. Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
  581. get: function () {
  582. return this._brightness;
  583. },
  584. set: function (value) {
  585. this._brightness = value;
  586. this.updateShaderUniforms();
  587. },
  588. enumerable: true,
  589. configurable: true
  590. });
  591. Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
  592. get: function () {
  593. return this._darkmatter;
  594. },
  595. set: function (value) {
  596. this._darkmatter = value;
  597. this.updateShaderUniforms();
  598. },
  599. enumerable: true,
  600. configurable: true
  601. });
  602. Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
  603. get: function () {
  604. return this._distfading;
  605. },
  606. set: function (value) {
  607. this._distfading = value;
  608. this.updateShaderUniforms();
  609. },
  610. enumerable: true,
  611. configurable: true
  612. });
  613. Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
  614. get: function () {
  615. return this._saturation;
  616. },
  617. set: function (value) {
  618. this._saturation = value;
  619. this.updateShaderUniforms();
  620. },
  621. enumerable: true,
  622. configurable: true
  623. });
  624. return StarfieldProceduralTexture;
  625. }(BABYLON.ProceduralTexture));
  626. BABYLON.StarfieldProceduralTexture = StarfieldProceduralTexture;
  627. })(BABYLON || (BABYLON = {}));
  628. //# sourceMappingURL=babylon.starfieldProceduralTexture.js.map
  629. BABYLON.Effect.ShadersStore['starfieldProceduralTexturePixelShader'] = "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}";
  630. "use strict";
  631. var BABYLON;
  632. (function (BABYLON) {
  633. var NormalMapProceduralTexture = /** @class */ (function (_super) {
  634. __extends(NormalMapProceduralTexture, _super);
  635. function NormalMapProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  636. var _this = _super.call(this, name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  637. _this.updateShaderUniforms();
  638. return _this;
  639. }
  640. NormalMapProceduralTexture.prototype.updateShaderUniforms = function () {
  641. this.setTexture("baseSampler", this._baseTexture);
  642. this.setFloat("size", this.getRenderSize());
  643. };
  644. NormalMapProceduralTexture.prototype.render = function (useCameraPostProcess) {
  645. _super.prototype.render.call(this, useCameraPostProcess);
  646. };
  647. NormalMapProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  648. _super.prototype.resize.call(this, size, generateMipMaps);
  649. // We need to update the "size" uniform
  650. this.updateShaderUniforms();
  651. };
  652. Object.defineProperty(NormalMapProceduralTexture.prototype, "baseTexture", {
  653. get: function () {
  654. return this._baseTexture;
  655. },
  656. set: function (texture) {
  657. this._baseTexture = texture;
  658. this.updateShaderUniforms();
  659. },
  660. enumerable: true,
  661. configurable: true
  662. });
  663. return NormalMapProceduralTexture;
  664. }(BABYLON.ProceduralTexture));
  665. BABYLON.NormalMapProceduralTexture = NormalMapProceduralTexture;
  666. })(BABYLON || (BABYLON = {}));
  667. //# sourceMappingURL=babylon.normalMapProceduralTexture.js.map
  668. BABYLON.Effect.ShadersStore['normalMapProceduralTexturePixelShader'] = "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";
  669. "use strict";
  670. var BABYLON;
  671. (function (BABYLON) {
  672. var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
  673. __extends(PerlinNoiseProceduralTexture, _super);
  674. function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  675. var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  676. _this.time = 0.0;
  677. _this.speed = 1.0;
  678. _this.translationSpeed = 1.0;
  679. _this._currentTranslation = 0;
  680. _this.updateShaderUniforms();
  681. return _this;
  682. }
  683. PerlinNoiseProceduralTexture.prototype.updateShaderUniforms = function () {
  684. this.setFloat("size", this.getRenderSize());
  685. var scene = this.getScene();
  686. if (!scene) {
  687. return;
  688. }
  689. var deltaTime = scene.getEngine().getDeltaTime();
  690. this.time += deltaTime;
  691. this.setFloat("time", this.time * this.speed / 1000);
  692. this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
  693. this.setFloat("translationSpeed", this._currentTranslation);
  694. };
  695. PerlinNoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  696. this.updateShaderUniforms();
  697. _super.prototype.render.call(this, useCameraPostProcess);
  698. };
  699. PerlinNoiseProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  700. _super.prototype.resize.call(this, size, generateMipMaps);
  701. };
  702. return PerlinNoiseProceduralTexture;
  703. }(BABYLON.ProceduralTexture));
  704. BABYLON.PerlinNoiseProceduralTexture = PerlinNoiseProceduralTexture;
  705. })(BABYLON || (BABYLON = {}));
  706. //# sourceMappingURL=babylon.perlinNoiseProceduralTexture.js.map
  707. BABYLON.Effect.ShadersStore['perlinNoiseProceduralTexturePixelShader'] = "\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";
  708. return BABYLON;
  709. });