babylonjs.proceduralTextures.js 40 KB

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