babylonjs.proceduralTextures.js 57 KB

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