babylonjs.proceduralTextures.js 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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. /**
  58. * Serializes this wood procedural texture
  59. * @returns a serialized wood procedural texture object
  60. */
  61. WoodProceduralTexture.prototype.serialize = function () {
  62. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  63. serializationObject.customType = "BABYLON.WoodProceduralTexture";
  64. return serializationObject;
  65. };
  66. /**
  67. * Creates a Wood Procedural Texture from parsed wood procedural texture data
  68. * @param parsedTexture defines parsed texture data
  69. * @param scene defines the current scene
  70. * @param rootUrl defines the root URL containing wood procedural texture information
  71. * @returns a parsed Wood Procedural Texture
  72. */
  73. WoodProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  74. var texture = BABYLON.SerializationHelper.Parse(function () { return new WoodProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  75. return texture;
  76. };
  77. __decorate([
  78. BABYLON.serialize()
  79. ], WoodProceduralTexture.prototype, "ampScale", null);
  80. __decorate([
  81. BABYLON.serializeAsColor3()
  82. ], WoodProceduralTexture.prototype, "woodColor", null);
  83. return WoodProceduralTexture;
  84. }(BABYLON.ProceduralTexture));
  85. BABYLON.WoodProceduralTexture = WoodProceduralTexture;
  86. })(BABYLON || (BABYLON = {}));
  87. //# sourceMappingURL=babylon.woodProceduralTexture.js.map
  88. 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}";
  89. var BABYLON;
  90. (function (BABYLON) {
  91. var FireProceduralTexture = /** @class */ (function (_super) {
  92. __extends(FireProceduralTexture, _super);
  93. function FireProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  94. var _this = _super.call(this, name, size, "fireProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  95. _this._time = 0.0;
  96. _this._speed = new BABYLON.Vector2(0.5, 0.3);
  97. _this._autoGenerateTime = true;
  98. _this._alphaThreshold = 0.5;
  99. _this._fireColors = FireProceduralTexture.RedFireColors;
  100. _this.updateShaderUniforms();
  101. return _this;
  102. }
  103. FireProceduralTexture.prototype.updateShaderUniforms = function () {
  104. this.setFloat("time", this._time);
  105. this.setVector2("speed", this._speed);
  106. this.setColor3("c1", this._fireColors[0]);
  107. this.setColor3("c2", this._fireColors[1]);
  108. this.setColor3("c3", this._fireColors[2]);
  109. this.setColor3("c4", this._fireColors[3]);
  110. this.setColor3("c5", this._fireColors[4]);
  111. this.setColor3("c6", this._fireColors[5]);
  112. this.setFloat("alphaThreshold", this._alphaThreshold);
  113. };
  114. FireProceduralTexture.prototype.render = function (useCameraPostProcess) {
  115. var scene = this.getScene();
  116. if (this._autoGenerateTime && scene) {
  117. this._time += scene.getAnimationRatio() * 0.03;
  118. this.updateShaderUniforms();
  119. }
  120. _super.prototype.render.call(this, useCameraPostProcess);
  121. };
  122. Object.defineProperty(FireProceduralTexture, "PurpleFireColors", {
  123. get: function () {
  124. return [
  125. new BABYLON.Color3(0.5, 0.0, 1.0),
  126. new BABYLON.Color3(0.9, 0.0, 1.0),
  127. new BABYLON.Color3(0.2, 0.0, 1.0),
  128. new BABYLON.Color3(1.0, 0.9, 1.0),
  129. new BABYLON.Color3(0.1, 0.1, 1.0),
  130. new BABYLON.Color3(0.9, 0.9, 1.0)
  131. ];
  132. },
  133. enumerable: true,
  134. configurable: true
  135. });
  136. Object.defineProperty(FireProceduralTexture, "GreenFireColors", {
  137. get: function () {
  138. return [
  139. new BABYLON.Color3(0.5, 1.0, 0.0),
  140. new BABYLON.Color3(0.5, 1.0, 0.0),
  141. new BABYLON.Color3(0.3, 0.4, 0.0),
  142. new BABYLON.Color3(0.5, 1.0, 0.0),
  143. new BABYLON.Color3(0.2, 0.0, 0.0),
  144. new BABYLON.Color3(0.5, 1.0, 0.0)
  145. ];
  146. },
  147. enumerable: true,
  148. configurable: true
  149. });
  150. Object.defineProperty(FireProceduralTexture, "RedFireColors", {
  151. get: function () {
  152. return [
  153. new BABYLON.Color3(0.5, 0.0, 0.1),
  154. new BABYLON.Color3(0.9, 0.0, 0.0),
  155. new BABYLON.Color3(0.2, 0.0, 0.0),
  156. new BABYLON.Color3(1.0, 0.9, 0.0),
  157. new BABYLON.Color3(0.1, 0.1, 0.1),
  158. new BABYLON.Color3(0.9, 0.9, 0.9)
  159. ];
  160. },
  161. enumerable: true,
  162. configurable: true
  163. });
  164. Object.defineProperty(FireProceduralTexture, "BlueFireColors", {
  165. get: function () {
  166. return [
  167. new BABYLON.Color3(0.1, 0.0, 0.5),
  168. new BABYLON.Color3(0.0, 0.0, 0.5),
  169. new BABYLON.Color3(0.1, 0.0, 0.2),
  170. new BABYLON.Color3(0.0, 0.0, 1.0),
  171. new BABYLON.Color3(0.1, 0.2, 0.3),
  172. new BABYLON.Color3(0.0, 0.2, 0.9)
  173. ];
  174. },
  175. enumerable: true,
  176. configurable: true
  177. });
  178. Object.defineProperty(FireProceduralTexture.prototype, "fireColors", {
  179. get: function () {
  180. return this._fireColors;
  181. },
  182. set: function (value) {
  183. this._fireColors = value;
  184. this.updateShaderUniforms();
  185. },
  186. enumerable: true,
  187. configurable: true
  188. });
  189. Object.defineProperty(FireProceduralTexture.prototype, "time", {
  190. get: function () {
  191. return this._time;
  192. },
  193. set: function (value) {
  194. this._time = value;
  195. this.updateShaderUniforms();
  196. },
  197. enumerable: true,
  198. configurable: true
  199. });
  200. Object.defineProperty(FireProceduralTexture.prototype, "speed", {
  201. get: function () {
  202. return this._speed;
  203. },
  204. set: function (value) {
  205. this._speed = value;
  206. this.updateShaderUniforms();
  207. },
  208. enumerable: true,
  209. configurable: true
  210. });
  211. Object.defineProperty(FireProceduralTexture.prototype, "alphaThreshold", {
  212. get: function () {
  213. return this._alphaThreshold;
  214. },
  215. set: function (value) {
  216. this._alphaThreshold = value;
  217. this.updateShaderUniforms();
  218. },
  219. enumerable: true,
  220. configurable: true
  221. });
  222. /**
  223. * Serializes this fire procedural texture
  224. * @returns a serialized fire procedural texture object
  225. */
  226. FireProceduralTexture.prototype.serialize = function () {
  227. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  228. serializationObject.customType = "BABYLON.FireProceduralTexture";
  229. return serializationObject;
  230. };
  231. /**
  232. * Creates a Fire Procedural Texture from parsed fire procedural texture data
  233. * @param parsedTexture defines parsed texture data
  234. * @param scene defines the current scene
  235. * @param rootUrl defines the root URL containing fire procedural texture information
  236. * @returns a parsed Fire Procedural Texture
  237. */
  238. FireProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  239. var texture = BABYLON.SerializationHelper.Parse(function () { return new FireProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  240. return texture;
  241. };
  242. __decorate([
  243. BABYLON.serializeAsColor3()
  244. ], FireProceduralTexture.prototype, "fireColors", null);
  245. __decorate([
  246. BABYLON.serialize()
  247. ], FireProceduralTexture.prototype, "time", null);
  248. __decorate([
  249. BABYLON.serializeAsVector2()
  250. ], FireProceduralTexture.prototype, "speed", null);
  251. __decorate([
  252. BABYLON.serialize()
  253. ], FireProceduralTexture.prototype, "alphaThreshold", null);
  254. return FireProceduralTexture;
  255. }(BABYLON.ProceduralTexture));
  256. BABYLON.FireProceduralTexture = FireProceduralTexture;
  257. })(BABYLON || (BABYLON = {}));
  258. //# sourceMappingURL=babylon.fireProceduralTexture.js.map
  259. 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}";
  260. var BABYLON;
  261. (function (BABYLON) {
  262. var CloudProceduralTexture = /** @class */ (function (_super) {
  263. __extends(CloudProceduralTexture, _super);
  264. function CloudProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  265. var _this = _super.call(this, name, size, "cloudProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  266. _this._skyColor = new BABYLON.Color4(0.15, 0.68, 1.0, 1.0);
  267. _this._cloudColor = new BABYLON.Color4(1, 1, 1, 1.0);
  268. _this.updateShaderUniforms();
  269. return _this;
  270. }
  271. CloudProceduralTexture.prototype.updateShaderUniforms = function () {
  272. this.setColor4("skyColor", this._skyColor);
  273. this.setColor4("cloudColor", this._cloudColor);
  274. };
  275. Object.defineProperty(CloudProceduralTexture.prototype, "skyColor", {
  276. get: function () {
  277. return this._skyColor;
  278. },
  279. set: function (value) {
  280. this._skyColor = value;
  281. this.updateShaderUniforms();
  282. },
  283. enumerable: true,
  284. configurable: true
  285. });
  286. Object.defineProperty(CloudProceduralTexture.prototype, "cloudColor", {
  287. get: function () {
  288. return this._cloudColor;
  289. },
  290. set: function (value) {
  291. this._cloudColor = value;
  292. this.updateShaderUniforms();
  293. },
  294. enumerable: true,
  295. configurable: true
  296. });
  297. /**
  298. * Serializes this cloud procedural texture
  299. * @returns a serialized cloud procedural texture object
  300. */
  301. CloudProceduralTexture.prototype.serialize = function () {
  302. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  303. serializationObject.customType = "BABYLON.CloudProceduralTexture";
  304. return serializationObject;
  305. };
  306. /**
  307. * Creates a Cloud Procedural Texture from parsed cloud procedural texture data
  308. * @param parsedTexture defines parsed texture data
  309. * @param scene defines the current scene
  310. * @param rootUrl defines the root URL containing cloud procedural texture information
  311. * @returns a parsed Cloud Procedural Texture
  312. */
  313. CloudProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  314. var texture = BABYLON.SerializationHelper.Parse(function () { return new CloudProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  315. return texture;
  316. };
  317. __decorate([
  318. BABYLON.serializeAsColor4()
  319. ], CloudProceduralTexture.prototype, "skyColor", null);
  320. __decorate([
  321. BABYLON.serializeAsColor4()
  322. ], CloudProceduralTexture.prototype, "cloudColor", null);
  323. return CloudProceduralTexture;
  324. }(BABYLON.ProceduralTexture));
  325. BABYLON.CloudProceduralTexture = CloudProceduralTexture;
  326. })(BABYLON || (BABYLON = {}));
  327. //# sourceMappingURL=babylon.cloudProceduralTexture.js.map
  328. 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";
  329. var BABYLON;
  330. (function (BABYLON) {
  331. var GrassProceduralTexture = /** @class */ (function (_super) {
  332. __extends(GrassProceduralTexture, _super);
  333. function GrassProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  334. var _this = _super.call(this, name, size, "grassProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  335. _this._groundColor = new BABYLON.Color3(1, 1, 1);
  336. _this._grassColors = [
  337. new BABYLON.Color3(0.29, 0.38, 0.02),
  338. new BABYLON.Color3(0.36, 0.49, 0.09),
  339. new BABYLON.Color3(0.51, 0.6, 0.28)
  340. ];
  341. _this.updateShaderUniforms();
  342. return _this;
  343. }
  344. GrassProceduralTexture.prototype.updateShaderUniforms = function () {
  345. this.setColor3("herb1Color", this._grassColors[0]);
  346. this.setColor3("herb2Color", this._grassColors[1]);
  347. this.setColor3("herb3Color", this._grassColors[2]);
  348. this.setColor3("groundColor", this._groundColor);
  349. };
  350. Object.defineProperty(GrassProceduralTexture.prototype, "grassColors", {
  351. get: function () {
  352. return this._grassColors;
  353. },
  354. set: function (value) {
  355. this._grassColors = value;
  356. this.updateShaderUniforms();
  357. },
  358. enumerable: true,
  359. configurable: true
  360. });
  361. Object.defineProperty(GrassProceduralTexture.prototype, "groundColor", {
  362. get: function () {
  363. return this._groundColor;
  364. },
  365. set: function (value) {
  366. this._groundColor = value;
  367. this.updateShaderUniforms();
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Serializes this grass procedural texture
  374. * @returns a serialized grass procedural texture object
  375. */
  376. GrassProceduralTexture.prototype.serialize = function () {
  377. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  378. serializationObject.customType = "BABYLON.GrassProceduralTexture";
  379. return serializationObject;
  380. };
  381. /**
  382. * Creates a Grass Procedural Texture from parsed grass procedural texture data
  383. * @param parsedTexture defines parsed texture data
  384. * @param scene defines the current scene
  385. * @param rootUrl defines the root URL containing grass procedural texture information
  386. * @returns a parsed Grass Procedural Texture
  387. */
  388. GrassProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  389. var texture = BABYLON.SerializationHelper.Parse(function () { return new GrassProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  390. return texture;
  391. };
  392. __decorate([
  393. BABYLON.serializeAsColor3()
  394. ], GrassProceduralTexture.prototype, "grassColors", null);
  395. __decorate([
  396. BABYLON.serializeAsColor3()
  397. ], GrassProceduralTexture.prototype, "groundColor", null);
  398. return GrassProceduralTexture;
  399. }(BABYLON.ProceduralTexture));
  400. BABYLON.GrassProceduralTexture = GrassProceduralTexture;
  401. })(BABYLON || (BABYLON = {}));
  402. //# sourceMappingURL=babylon.grassProceduralTexture.js.map
  403. 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}";
  404. var BABYLON;
  405. (function (BABYLON) {
  406. var RoadProceduralTexture = /** @class */ (function (_super) {
  407. __extends(RoadProceduralTexture, _super);
  408. function RoadProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  409. var _this = _super.call(this, name, size, "roadProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  410. _this._roadColor = new BABYLON.Color3(0.53, 0.53, 0.53);
  411. _this.updateShaderUniforms();
  412. return _this;
  413. }
  414. RoadProceduralTexture.prototype.updateShaderUniforms = function () {
  415. this.setColor3("roadColor", this._roadColor);
  416. };
  417. Object.defineProperty(RoadProceduralTexture.prototype, "roadColor", {
  418. get: function () {
  419. return this._roadColor;
  420. },
  421. set: function (value) {
  422. this._roadColor = value;
  423. this.updateShaderUniforms();
  424. },
  425. enumerable: true,
  426. configurable: true
  427. });
  428. /**
  429. * Serializes this road procedural texture
  430. * @returns a serialized road procedural texture object
  431. */
  432. RoadProceduralTexture.prototype.serialize = function () {
  433. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  434. serializationObject.customType = "BABYLON.RoadProceduralTexture";
  435. return serializationObject;
  436. };
  437. /**
  438. * Creates a Road Procedural Texture from parsed road procedural texture data
  439. * @param parsedTexture defines parsed texture data
  440. * @param scene defines the current scene
  441. * @param rootUrl defines the root URL containing road procedural texture information
  442. * @returns a parsed Road Procedural Texture
  443. */
  444. RoadProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  445. var texture = BABYLON.SerializationHelper.Parse(function () { return new RoadProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  446. return texture;
  447. };
  448. __decorate([
  449. BABYLON.serializeAsColor3()
  450. ], RoadProceduralTexture.prototype, "roadColor", null);
  451. return RoadProceduralTexture;
  452. }(BABYLON.ProceduralTexture));
  453. BABYLON.RoadProceduralTexture = RoadProceduralTexture;
  454. })(BABYLON || (BABYLON = {}));
  455. //# sourceMappingURL=babylon.roadProceduralTexture.js.map
  456. 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}";
  457. var BABYLON;
  458. (function (BABYLON) {
  459. var BrickProceduralTexture = /** @class */ (function (_super) {
  460. __extends(BrickProceduralTexture, _super);
  461. function BrickProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  462. var _this = _super.call(this, name, size, "brickProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  463. _this._numberOfBricksHeight = 15;
  464. _this._numberOfBricksWidth = 5;
  465. _this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  466. _this._brickColor = new BABYLON.Color3(0.77, 0.47, 0.40);
  467. _this.updateShaderUniforms();
  468. return _this;
  469. }
  470. BrickProceduralTexture.prototype.updateShaderUniforms = function () {
  471. this.setFloat("numberOfBricksHeight", this._numberOfBricksHeight);
  472. this.setFloat("numberOfBricksWidth", this._numberOfBricksWidth);
  473. this.setColor3("brickColor", this._brickColor);
  474. this.setColor3("jointColor", this._jointColor);
  475. };
  476. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksHeight", {
  477. get: function () {
  478. return this._numberOfBricksHeight;
  479. },
  480. set: function (value) {
  481. this._numberOfBricksHeight = value;
  482. this.updateShaderUniforms();
  483. },
  484. enumerable: true,
  485. configurable: true
  486. });
  487. Object.defineProperty(BrickProceduralTexture.prototype, "numberOfBricksWidth", {
  488. get: function () {
  489. return this._numberOfBricksWidth;
  490. },
  491. set: function (value) {
  492. this._numberOfBricksWidth = value;
  493. this.updateShaderUniforms();
  494. },
  495. enumerable: true,
  496. configurable: true
  497. });
  498. Object.defineProperty(BrickProceduralTexture.prototype, "jointColor", {
  499. get: function () {
  500. return this._jointColor;
  501. },
  502. set: function (value) {
  503. this._jointColor = value;
  504. this.updateShaderUniforms();
  505. },
  506. enumerable: true,
  507. configurable: true
  508. });
  509. Object.defineProperty(BrickProceduralTexture.prototype, "brickColor", {
  510. get: function () {
  511. return this._brickColor;
  512. },
  513. set: function (value) {
  514. this._brickColor = value;
  515. this.updateShaderUniforms();
  516. },
  517. enumerable: true,
  518. configurable: true
  519. });
  520. /**
  521. * Serializes this brick procedural texture
  522. * @returns a serialized brick procedural texture object
  523. */
  524. BrickProceduralTexture.prototype.serialize = function () {
  525. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  526. serializationObject.customType = "BABYLON.BrickProceduralTexture";
  527. return serializationObject;
  528. };
  529. /**
  530. * Creates a Brick Procedural Texture from parsed brick procedural texture data
  531. * @param parsedTexture defines parsed texture data
  532. * @param scene defines the current scene
  533. * @param rootUrl defines the root URL containing brick procedural texture information
  534. * @returns a parsed Brick Procedural Texture
  535. */
  536. BrickProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  537. var texture = BABYLON.SerializationHelper.Parse(function () { return new BrickProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  538. return texture;
  539. };
  540. __decorate([
  541. BABYLON.serialize()
  542. ], BrickProceduralTexture.prototype, "numberOfBricksHeight", null);
  543. __decorate([
  544. BABYLON.serialize()
  545. ], BrickProceduralTexture.prototype, "numberOfBricksWidth", null);
  546. __decorate([
  547. BABYLON.serializeAsColor3()
  548. ], BrickProceduralTexture.prototype, "jointColor", null);
  549. __decorate([
  550. BABYLON.serializeAsColor3()
  551. ], BrickProceduralTexture.prototype, "brickColor", null);
  552. return BrickProceduralTexture;
  553. }(BABYLON.ProceduralTexture));
  554. BABYLON.BrickProceduralTexture = BrickProceduralTexture;
  555. })(BABYLON || (BABYLON = {}));
  556. //# sourceMappingURL=babylon.brickProceduralTexture.js.map
  557. 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}";
  558. var BABYLON;
  559. (function (BABYLON) {
  560. var MarbleProceduralTexture = /** @class */ (function (_super) {
  561. __extends(MarbleProceduralTexture, _super);
  562. function MarbleProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  563. var _this = _super.call(this, name, size, "marbleProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  564. _this._numberOfTilesHeight = 3;
  565. _this._numberOfTilesWidth = 3;
  566. _this._amplitude = 9.0;
  567. _this._jointColor = new BABYLON.Color3(0.72, 0.72, 0.72);
  568. _this.updateShaderUniforms();
  569. return _this;
  570. }
  571. MarbleProceduralTexture.prototype.updateShaderUniforms = function () {
  572. this.setFloat("numberOfTilesHeight", this._numberOfTilesHeight);
  573. this.setFloat("numberOfTilesWidth", this._numberOfTilesWidth);
  574. this.setFloat("amplitude", this._amplitude);
  575. this.setColor3("jointColor", this._jointColor);
  576. };
  577. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesHeight", {
  578. get: function () {
  579. return this._numberOfTilesHeight;
  580. },
  581. set: function (value) {
  582. this._numberOfTilesHeight = value;
  583. this.updateShaderUniforms();
  584. },
  585. enumerable: true,
  586. configurable: true
  587. });
  588. Object.defineProperty(MarbleProceduralTexture.prototype, "amplitude", {
  589. get: function () {
  590. return this._amplitude;
  591. },
  592. set: function (value) {
  593. this._amplitude = value;
  594. this.updateShaderUniforms();
  595. },
  596. enumerable: true,
  597. configurable: true
  598. });
  599. Object.defineProperty(MarbleProceduralTexture.prototype, "numberOfTilesWidth", {
  600. get: function () {
  601. return this._numberOfTilesWidth;
  602. },
  603. set: function (value) {
  604. this._numberOfTilesWidth = value;
  605. this.updateShaderUniforms();
  606. },
  607. enumerable: true,
  608. configurable: true
  609. });
  610. Object.defineProperty(MarbleProceduralTexture.prototype, "jointColor", {
  611. get: function () {
  612. return this._jointColor;
  613. },
  614. set: function (value) {
  615. this._jointColor = value;
  616. this.updateShaderUniforms();
  617. },
  618. enumerable: true,
  619. configurable: true
  620. });
  621. /**
  622. * Serializes this marble procedural texture
  623. * @returns a serialized marble procedural texture object
  624. */
  625. MarbleProceduralTexture.prototype.serialize = function () {
  626. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  627. serializationObject.customType = "BABYLON.MarbleProceduralTexture";
  628. return serializationObject;
  629. };
  630. /**
  631. * Creates a Marble Procedural Texture from parsed marble procedural texture data
  632. * @param parsedTexture defines parsed texture data
  633. * @param scene defines the current scene
  634. * @param rootUrl defines the root URL containing marble procedural texture information
  635. * @returns a parsed Marble Procedural Texture
  636. */
  637. MarbleProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  638. var texture = BABYLON.SerializationHelper.Parse(function () { return new MarbleProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  639. return texture;
  640. };
  641. __decorate([
  642. BABYLON.serialize()
  643. ], MarbleProceduralTexture.prototype, "numberOfTilesHeight", null);
  644. __decorate([
  645. BABYLON.serialize()
  646. ], MarbleProceduralTexture.prototype, "amplitude", null);
  647. __decorate([
  648. BABYLON.serialize()
  649. ], MarbleProceduralTexture.prototype, "numberOfTilesWidth", null);
  650. __decorate([
  651. BABYLON.serialize()
  652. ], MarbleProceduralTexture.prototype, "jointColor", null);
  653. return MarbleProceduralTexture;
  654. }(BABYLON.ProceduralTexture));
  655. BABYLON.MarbleProceduralTexture = MarbleProceduralTexture;
  656. })(BABYLON || (BABYLON = {}));
  657. //# sourceMappingURL=babylon.marbleProceduralTexture.js.map
  658. 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}";
  659. var BABYLON;
  660. (function (BABYLON) {
  661. var StarfieldProceduralTexture = /** @class */ (function (_super) {
  662. __extends(StarfieldProceduralTexture, _super);
  663. function StarfieldProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  664. var _this = _super.call(this, name, size, "starfieldProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  665. _this._time = 1;
  666. _this._alpha = 0.5;
  667. _this._beta = 0.8;
  668. _this._zoom = 0.8;
  669. _this._formuparam = 0.53;
  670. _this._stepsize = 0.1;
  671. _this._tile = 0.850;
  672. _this._brightness = 0.0015;
  673. _this._darkmatter = 0.400;
  674. _this._distfading = 0.730;
  675. _this._saturation = 0.850;
  676. _this.updateShaderUniforms();
  677. return _this;
  678. }
  679. StarfieldProceduralTexture.prototype.updateShaderUniforms = function () {
  680. this.setFloat("time", this._time);
  681. this.setFloat("alpha", this._alpha);
  682. this.setFloat("beta", this._beta);
  683. this.setFloat("zoom", this._zoom);
  684. this.setFloat("formuparam", this._formuparam);
  685. this.setFloat("stepsize", this._stepsize);
  686. this.setFloat("tile", this._tile);
  687. this.setFloat("brightness", this._brightness);
  688. this.setFloat("darkmatter", this._darkmatter);
  689. this.setFloat("distfading", this._distfading);
  690. this.setFloat("saturation", this._saturation);
  691. };
  692. Object.defineProperty(StarfieldProceduralTexture.prototype, "time", {
  693. get: function () {
  694. return this._time;
  695. },
  696. set: function (value) {
  697. this._time = value;
  698. this.updateShaderUniforms();
  699. },
  700. enumerable: true,
  701. configurable: true
  702. });
  703. Object.defineProperty(StarfieldProceduralTexture.prototype, "alpha", {
  704. get: function () {
  705. return this._alpha;
  706. },
  707. set: function (value) {
  708. this._alpha = value;
  709. this.updateShaderUniforms();
  710. },
  711. enumerable: true,
  712. configurable: true
  713. });
  714. Object.defineProperty(StarfieldProceduralTexture.prototype, "beta", {
  715. get: function () {
  716. return this._beta;
  717. },
  718. set: function (value) {
  719. this._beta = value;
  720. this.updateShaderUniforms();
  721. },
  722. enumerable: true,
  723. configurable: true
  724. });
  725. Object.defineProperty(StarfieldProceduralTexture.prototype, "formuparam", {
  726. get: function () {
  727. return this._formuparam;
  728. },
  729. set: function (value) {
  730. this._formuparam = value;
  731. this.updateShaderUniforms();
  732. },
  733. enumerable: true,
  734. configurable: true
  735. });
  736. Object.defineProperty(StarfieldProceduralTexture.prototype, "stepsize", {
  737. get: function () {
  738. return this._stepsize;
  739. },
  740. set: function (value) {
  741. this._stepsize = value;
  742. this.updateShaderUniforms();
  743. },
  744. enumerable: true,
  745. configurable: true
  746. });
  747. Object.defineProperty(StarfieldProceduralTexture.prototype, "zoom", {
  748. get: function () {
  749. return this._zoom;
  750. },
  751. set: function (value) {
  752. this._zoom = value;
  753. this.updateShaderUniforms();
  754. },
  755. enumerable: true,
  756. configurable: true
  757. });
  758. Object.defineProperty(StarfieldProceduralTexture.prototype, "tile", {
  759. get: function () {
  760. return this._tile;
  761. },
  762. set: function (value) {
  763. this._tile = value;
  764. this.updateShaderUniforms();
  765. },
  766. enumerable: true,
  767. configurable: true
  768. });
  769. Object.defineProperty(StarfieldProceduralTexture.prototype, "brightness", {
  770. get: function () {
  771. return this._brightness;
  772. },
  773. set: function (value) {
  774. this._brightness = value;
  775. this.updateShaderUniforms();
  776. },
  777. enumerable: true,
  778. configurable: true
  779. });
  780. Object.defineProperty(StarfieldProceduralTexture.prototype, "darkmatter", {
  781. get: function () {
  782. return this._darkmatter;
  783. },
  784. set: function (value) {
  785. this._darkmatter = value;
  786. this.updateShaderUniforms();
  787. },
  788. enumerable: true,
  789. configurable: true
  790. });
  791. Object.defineProperty(StarfieldProceduralTexture.prototype, "distfading", {
  792. get: function () {
  793. return this._distfading;
  794. },
  795. set: function (value) {
  796. this._distfading = value;
  797. this.updateShaderUniforms();
  798. },
  799. enumerable: true,
  800. configurable: true
  801. });
  802. Object.defineProperty(StarfieldProceduralTexture.prototype, "saturation", {
  803. get: function () {
  804. return this._saturation;
  805. },
  806. set: function (value) {
  807. this._saturation = value;
  808. this.updateShaderUniforms();
  809. },
  810. enumerable: true,
  811. configurable: true
  812. });
  813. /**
  814. * Serializes this starfield procedural texture
  815. * @returns a serialized starfield procedural texture object
  816. */
  817. StarfieldProceduralTexture.prototype.serialize = function () {
  818. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  819. serializationObject.customType = "BABYLON.StarfieldProceduralTexture";
  820. return serializationObject;
  821. };
  822. /**
  823. * Creates a Starfield Procedural Texture from parsed startfield procedural texture data
  824. * @param parsedTexture defines parsed texture data
  825. * @param scene defines the current scene
  826. * @param rootUrl defines the root URL containing startfield procedural texture information
  827. * @returns a parsed Starfield Procedural Texture
  828. */
  829. StarfieldProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  830. var texture = BABYLON.SerializationHelper.Parse(function () { return new StarfieldProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  831. return texture;
  832. };
  833. __decorate([
  834. BABYLON.serialize()
  835. ], StarfieldProceduralTexture.prototype, "time", null);
  836. __decorate([
  837. BABYLON.serialize()
  838. ], StarfieldProceduralTexture.prototype, "alpha", null);
  839. __decorate([
  840. BABYLON.serialize()
  841. ], StarfieldProceduralTexture.prototype, "beta", null);
  842. __decorate([
  843. BABYLON.serialize()
  844. ], StarfieldProceduralTexture.prototype, "formuparam", null);
  845. __decorate([
  846. BABYLON.serialize()
  847. ], StarfieldProceduralTexture.prototype, "stepsize", null);
  848. __decorate([
  849. BABYLON.serialize()
  850. ], StarfieldProceduralTexture.prototype, "zoom", null);
  851. __decorate([
  852. BABYLON.serialize()
  853. ], StarfieldProceduralTexture.prototype, "tile", null);
  854. __decorate([
  855. BABYLON.serialize()
  856. ], StarfieldProceduralTexture.prototype, "brightness", null);
  857. __decorate([
  858. BABYLON.serialize()
  859. ], StarfieldProceduralTexture.prototype, "darkmatter", null);
  860. __decorate([
  861. BABYLON.serialize()
  862. ], StarfieldProceduralTexture.prototype, "distfading", null);
  863. __decorate([
  864. BABYLON.serialize()
  865. ], StarfieldProceduralTexture.prototype, "saturation", null);
  866. return StarfieldProceduralTexture;
  867. }(BABYLON.ProceduralTexture));
  868. BABYLON.StarfieldProceduralTexture = StarfieldProceduralTexture;
  869. })(BABYLON || (BABYLON = {}));
  870. //# sourceMappingURL=babylon.starfieldProceduralTexture.js.map
  871. 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}";
  872. var BABYLON;
  873. (function (BABYLON) {
  874. var NormalMapProceduralTexture = /** @class */ (function (_super) {
  875. __extends(NormalMapProceduralTexture, _super);
  876. function NormalMapProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  877. var _this = _super.call(this, name, size, "normalMapProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  878. _this.updateShaderUniforms();
  879. return _this;
  880. }
  881. NormalMapProceduralTexture.prototype.updateShaderUniforms = function () {
  882. this.setTexture("baseSampler", this._baseTexture);
  883. this.setFloat("size", this.getRenderSize());
  884. };
  885. NormalMapProceduralTexture.prototype.render = function (useCameraPostProcess) {
  886. _super.prototype.render.call(this, useCameraPostProcess);
  887. };
  888. NormalMapProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  889. _super.prototype.resize.call(this, size, generateMipMaps);
  890. // We need to update the "size" uniform
  891. this.updateShaderUniforms();
  892. };
  893. Object.defineProperty(NormalMapProceduralTexture.prototype, "baseTexture", {
  894. get: function () {
  895. return this._baseTexture;
  896. },
  897. set: function (texture) {
  898. this._baseTexture = texture;
  899. this.updateShaderUniforms();
  900. },
  901. enumerable: true,
  902. configurable: true
  903. });
  904. /**
  905. * Serializes this normal map procedural texture
  906. * @returns a serialized normal map procedural texture object
  907. */
  908. NormalMapProceduralTexture.prototype.serialize = function () {
  909. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  910. serializationObject.customType = "BABYLON.NormalMapProceduralTexture";
  911. return serializationObject;
  912. };
  913. /**
  914. * Creates a Normal Map Procedural Texture from parsed normal map procedural texture data
  915. * @param parsedTexture defines parsed texture data
  916. * @param scene defines the current scene
  917. * @param rootUrl defines the root URL containing normal map procedural texture information
  918. * @returns a parsed Normal Map Procedural Texture
  919. */
  920. NormalMapProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  921. var texture = BABYLON.SerializationHelper.Parse(function () { return new NormalMapProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  922. return texture;
  923. };
  924. __decorate([
  925. BABYLON.serializeAsTexture()
  926. ], NormalMapProceduralTexture.prototype, "baseTexture", null);
  927. return NormalMapProceduralTexture;
  928. }(BABYLON.ProceduralTexture));
  929. BABYLON.NormalMapProceduralTexture = NormalMapProceduralTexture;
  930. })(BABYLON || (BABYLON = {}));
  931. //# sourceMappingURL=babylon.normalMapProceduralTexture.js.map
  932. 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";
  933. var BABYLON;
  934. (function (BABYLON) {
  935. var PerlinNoiseProceduralTexture = /** @class */ (function (_super) {
  936. __extends(PerlinNoiseProceduralTexture, _super);
  937. function PerlinNoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  938. var _this = _super.call(this, name, size, "perlinNoiseProceduralTexture", scene, fallbackTexture, generateMipMaps) || this;
  939. _this.time = 0.0;
  940. _this.speed = 1.0;
  941. _this.translationSpeed = 1.0;
  942. _this._currentTranslation = 0;
  943. _this.updateShaderUniforms();
  944. return _this;
  945. }
  946. PerlinNoiseProceduralTexture.prototype.updateShaderUniforms = function () {
  947. this.setFloat("size", this.getRenderSize());
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. var deltaTime = scene.getEngine().getDeltaTime();
  953. this.time += deltaTime;
  954. this.setFloat("time", this.time * this.speed / 1000);
  955. this._currentTranslation += deltaTime * this.translationSpeed / 1000.0;
  956. this.setFloat("translationSpeed", this._currentTranslation);
  957. };
  958. PerlinNoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  959. this.updateShaderUniforms();
  960. _super.prototype.render.call(this, useCameraPostProcess);
  961. };
  962. PerlinNoiseProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  963. _super.prototype.resize.call(this, size, generateMipMaps);
  964. };
  965. /**
  966. * Serializes this perlin noise procedural texture
  967. * @returns a serialized perlin noise procedural texture object
  968. */
  969. PerlinNoiseProceduralTexture.prototype.serialize = function () {
  970. var serializationObject = BABYLON.SerializationHelper.Serialize(this, _super.prototype.serialize.call(this));
  971. serializationObject.customType = "BABYLON.PerlinNoiseProceduralTexture";
  972. return serializationObject;
  973. };
  974. /**
  975. * Creates a Perlin Noise Procedural Texture from parsed perlin noise procedural texture data
  976. * @param parsedTexture defines parsed texture data
  977. * @param scene defines the current scene
  978. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  979. * @returns a parsed Perlin Noise Procedural Texture
  980. */
  981. PerlinNoiseProceduralTexture.Parse = function (parsedTexture, scene, rootUrl) {
  982. var texture = BABYLON.SerializationHelper.Parse(function () { return new PerlinNoiseProceduralTexture(parsedTexture.name, parsedTexture._size, scene, undefined, parsedTexture._generateMipMaps); }, parsedTexture, scene, rootUrl);
  983. return texture;
  984. };
  985. __decorate([
  986. BABYLON.serialize()
  987. ], PerlinNoiseProceduralTexture.prototype, "time", void 0);
  988. __decorate([
  989. BABYLON.serialize()
  990. ], PerlinNoiseProceduralTexture.prototype, "speed", void 0);
  991. __decorate([
  992. BABYLON.serialize()
  993. ], PerlinNoiseProceduralTexture.prototype, "translationSpeed", void 0);
  994. return PerlinNoiseProceduralTexture;
  995. }(BABYLON.ProceduralTexture));
  996. BABYLON.PerlinNoiseProceduralTexture = PerlinNoiseProceduralTexture;
  997. })(BABYLON || (BABYLON = {}));
  998. //# sourceMappingURL=babylon.perlinNoiseProceduralTexture.js.map
  999. 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";
  1000. return BABYLON;
  1001. });