babylonjs.proceduralTextures.js 41 KB

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