babylonjs.postProcess.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. 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};
  2. 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)}}();
  3. (function universalModuleDefinition(root, factory) {
  4. var amdDependencies = [];
  5. var BABYLON = root. BABYLON;
  6. if(!BABYLON) {
  7. if(typeof exports === 'object') {
  8. BABYLON = require("babylonjs");
  9. } else if(typeof define === 'function' && define.amd) {
  10. amdDependencies.push("babylonjs");
  11. }
  12. } else {
  13. if(typeof define === 'function' && define.amd) {
  14. if(!(require.specified && require.specified("' + dep.module + '"))) {
  15. try { define("babylonjs", [], function () { return BABYLON; }); } catch(e) { }
  16. }
  17. amdDependencies.push("babylonjs");
  18. }
  19. }
  20. if(typeof exports === 'object' && typeof module === 'object')
  21. module.exports = factory(BABYLON);
  22. else if(typeof define === 'function' && define.amd)
  23. define("babylonjs-post-process", amdDependencies, factory);
  24. else if(typeof exports === 'object')
  25. exports["babylonjs-post-process"] = factory(BABYLON);
  26. else {
  27. root["BABYLON"] = factory(BABYLON);
  28. }
  29. })(this, function(BABYLON) {
  30. "use strict";
  31. var BABYLON;
  32. (function (BABYLON) {
  33. /**
  34. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  35. *
  36. * It basically takes care rendering the font front the given font size to a texture.
  37. * This is used later on in the postprocess.
  38. */
  39. var AsciiArtFontTexture = /** @class */ (function (_super) {
  40. __extends(AsciiArtFontTexture, _super);
  41. /**
  42. * Create a new instance of the Ascii Art FontTexture class
  43. * @param name the name of the texture
  44. * @param font the font to use, use the W3C CSS notation
  45. * @param text the caracter set to use in the rendering.
  46. * @param scene the scene that owns the texture
  47. */
  48. function AsciiArtFontTexture(name, font, text, scene) {
  49. if (scene === void 0) { scene = null; }
  50. var _this = _super.call(this, scene) || this;
  51. scene = _this.getScene();
  52. if (!scene) {
  53. return _this;
  54. }
  55. _this.name = name;
  56. _this._text == text;
  57. _this._font == font;
  58. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  59. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  60. //this.anisotropicFilteringLevel = 1;
  61. // Get the font specific info.
  62. var maxCharHeight = _this.getFontHeight(font);
  63. var maxCharWidth = _this.getFontWidth(font);
  64. _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
  65. // This is an approximate size, but should always be able to fit at least the maxCharCount.
  66. var textureWidth = Math.ceil(_this._charSize * text.length);
  67. var textureHeight = _this._charSize;
  68. // Create the texture that will store the font characters.
  69. _this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
  70. //scene.getEngine().setclamp
  71. var textureSize = _this.getSize();
  72. // Create a canvas with the final size: the one matching the texture.
  73. var canvas = document.createElement("canvas");
  74. canvas.width = textureSize.width;
  75. canvas.height = textureSize.height;
  76. var context = canvas.getContext("2d");
  77. context.textBaseline = "top";
  78. context.font = font;
  79. context.fillStyle = "white";
  80. context.imageSmoothingEnabled = false;
  81. // Sets the text in the texture.
  82. for (var i = 0; i < text.length; i++) {
  83. context.fillText(text[i], i * _this._charSize, -maxCharHeight.offset);
  84. }
  85. // Flush the text in the dynamic texture.
  86. scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
  87. return _this;
  88. }
  89. Object.defineProperty(AsciiArtFontTexture.prototype, "charSize", {
  90. /**
  91. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92. */
  93. get: function () {
  94. return this._charSize;
  95. },
  96. enumerable: true,
  97. configurable: true
  98. });
  99. /**
  100. * Gets the max char width of a font.
  101. * @param font the font to use, use the W3C CSS notation
  102. * @return the max char width
  103. */
  104. AsciiArtFontTexture.prototype.getFontWidth = function (font) {
  105. var fontDraw = document.createElement("canvas");
  106. var ctx = fontDraw.getContext('2d');
  107. ctx.fillStyle = 'white';
  108. ctx.font = font;
  109. return ctx.measureText("W").width;
  110. };
  111. // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
  112. /**
  113. * Gets the max char height of a font.
  114. * @param font the font to use, use the W3C CSS notation
  115. * @return the max char height
  116. */
  117. AsciiArtFontTexture.prototype.getFontHeight = function (font) {
  118. var fontDraw = document.createElement("canvas");
  119. var ctx = fontDraw.getContext('2d');
  120. ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
  121. ctx.textBaseline = 'top';
  122. ctx.fillStyle = 'white';
  123. ctx.font = font;
  124. ctx.fillText('jH|', 0, 0);
  125. var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
  126. var start = -1;
  127. var end = -1;
  128. for (var row = 0; row < fontDraw.height; row++) {
  129. for (var column = 0; column < fontDraw.width; column++) {
  130. var index = (row * fontDraw.width + column) * 4;
  131. if (pixels[index] === 0) {
  132. if (column === fontDraw.width - 1 && start !== -1) {
  133. end = row;
  134. row = fontDraw.height;
  135. break;
  136. }
  137. continue;
  138. }
  139. else {
  140. if (start === -1) {
  141. start = row;
  142. }
  143. break;
  144. }
  145. }
  146. }
  147. return { height: (end - start) + 1, offset: start - 1 };
  148. };
  149. /**
  150. * Clones the current AsciiArtTexture.
  151. * @return the clone of the texture.
  152. */
  153. AsciiArtFontTexture.prototype.clone = function () {
  154. return new AsciiArtFontTexture(this.name, this._font, this._text, this.getScene());
  155. };
  156. /**
  157. * Parses a json object representing the texture and returns an instance of it.
  158. * @param source the source JSON representation
  159. * @param scene the scene to create the texture for
  160. * @return the parsed texture
  161. */
  162. AsciiArtFontTexture.Parse = function (source, scene) {
  163. var texture = BABYLON.SerializationHelper.Parse(function () { return new AsciiArtFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
  164. return texture;
  165. };
  166. __decorate([
  167. BABYLON.serialize("font")
  168. ], AsciiArtFontTexture.prototype, "_font", void 0);
  169. __decorate([
  170. BABYLON.serialize("text")
  171. ], AsciiArtFontTexture.prototype, "_text", void 0);
  172. return AsciiArtFontTexture;
  173. }(BABYLON.BaseTexture));
  174. BABYLON.AsciiArtFontTexture = AsciiArtFontTexture;
  175. /**
  176. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  177. *
  178. * Simmply add it to your scene and let the nerd that lives in you have fun.
  179. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  180. */
  181. var AsciiArtPostProcess = /** @class */ (function (_super) {
  182. __extends(AsciiArtPostProcess, _super);
  183. /**
  184. * Instantiates a new Ascii Art Post Process.
  185. * @param name the name to give to the postprocess
  186. * @camera the camera to apply the post process to.
  187. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  188. */
  189. function AsciiArtPostProcess(name, camera, options) {
  190. var _this = _super.call(this, name, 'asciiart', ['asciiArtFontInfos', 'asciiArtOptions'], ['asciiArtFont'], {
  191. width: camera.getEngine().getRenderWidth(),
  192. height: camera.getEngine().getRenderHeight()
  193. }, camera, BABYLON.Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
  194. /**
  195. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  196. * This number is defined between 0 and 1;
  197. */
  198. _this.mixToTile = 0;
  199. /**
  200. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  201. * This number is defined between 0 and 1;
  202. */
  203. _this.mixToNormal = 0;
  204. // Default values.
  205. var font = "40px Monospace";
  206. var characterSet = " `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";
  207. // Use options.
  208. if (options) {
  209. if (typeof (options) === "string") {
  210. font = options;
  211. }
  212. else {
  213. font = options.font || font;
  214. characterSet = options.characterSet || characterSet;
  215. _this.mixToTile = options.mixToTile || _this.mixToTile;
  216. _this.mixToNormal = options.mixToNormal || _this.mixToNormal;
  217. }
  218. }
  219. _this._asciiArtFontTexture = new AsciiArtFontTexture(name, font, characterSet, camera.getScene());
  220. var textureSize = _this._asciiArtFontTexture.getSize();
  221. _this.onApply = function (effect) {
  222. effect.setTexture("asciiArtFont", _this._asciiArtFontTexture);
  223. effect.setFloat4("asciiArtFontInfos", _this._asciiArtFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
  224. effect.setFloat4("asciiArtOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
  225. };
  226. return _this;
  227. }
  228. return AsciiArtPostProcess;
  229. }(BABYLON.PostProcess));
  230. BABYLON.AsciiArtPostProcess = AsciiArtPostProcess;
  231. })(BABYLON || (BABYLON = {}));
  232. //# sourceMappingURL=babylon.asciiArtPostProcess.js.map
  233. BABYLON.Effect.ShadersStore['asciiartPixelShader'] = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D asciiArtFont;\n\nuniform vec4 asciiArtFontInfos;\nuniform vec4 asciiArtOptions;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\nvoid main(void) \n{\nfloat caracterSize=asciiArtFontInfos.x;\nfloat numChar=asciiArtFontInfos.y-1.0;\nfloat fontx=asciiArtFontInfos.z;\nfloat fonty=asciiArtFontInfos.w;\nfloat screenx=asciiArtOptions.x;\nfloat screeny=asciiArtOptions.y;\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nfloat offsetx=(float(floor(tileLuminance*numChar)))*caracterSize/fontx;\nfloat offsety=0.0;\nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(gl_FragCoord.y,caracterSize))/fonty;\nvec4 finalColor=texture2D(asciiArtFont,vec2(offsetx+x,offsety+(caracterSize/fonty-y)));\nfinalColor.rgb*=tileColor.rgb;\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,asciiArtOptions.w);\nfinalColor=mix(finalColor,baseColor,asciiArtOptions.z);\ngl_FragColor=finalColor;\n}";
  234. "use strict";
  235. var BABYLON;
  236. (function (BABYLON) {
  237. /**
  238. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  239. *
  240. * It basically takes care rendering the font front the given font size to a texture.
  241. * This is used later on in the postprocess.
  242. */
  243. var DigitalRainFontTexture = /** @class */ (function (_super) {
  244. __extends(DigitalRainFontTexture, _super);
  245. /**
  246. * Create a new instance of the Digital Rain FontTexture class
  247. * @param name the name of the texture
  248. * @param font the font to use, use the W3C CSS notation
  249. * @param text the caracter set to use in the rendering.
  250. * @param scene the scene that owns the texture
  251. */
  252. function DigitalRainFontTexture(name, font, text, scene) {
  253. if (scene === void 0) { scene = null; }
  254. var _this = _super.call(this, scene) || this;
  255. scene = _this.getScene();
  256. if (!scene) {
  257. return _this;
  258. }
  259. _this.name = name;
  260. _this._text == text;
  261. _this._font == font;
  262. _this.wrapU = BABYLON.Texture.CLAMP_ADDRESSMODE;
  263. _this.wrapV = BABYLON.Texture.CLAMP_ADDRESSMODE;
  264. //this.anisotropicFilteringLevel = 1;
  265. // Get the font specific info.
  266. var maxCharHeight = _this.getFontHeight(font);
  267. var maxCharWidth = _this.getFontWidth(font);
  268. _this._charSize = Math.max(maxCharHeight.height, maxCharWidth);
  269. // This is an approximate size, but should always be able to fit at least the maxCharCount.
  270. var textureWidth = _this._charSize;
  271. var textureHeight = Math.ceil(_this._charSize * text.length);
  272. // Create the texture that will store the font characters.
  273. _this._texture = scene.getEngine().createDynamicTexture(textureWidth, textureHeight, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
  274. //scene.getEngine().setclamp
  275. var textureSize = _this.getSize();
  276. // Create a canvas with the final size: the one matching the texture.
  277. var canvas = document.createElement("canvas");
  278. canvas.width = textureSize.width;
  279. canvas.height = textureSize.height;
  280. var context = canvas.getContext("2d");
  281. context.textBaseline = "top";
  282. context.font = font;
  283. context.fillStyle = "white";
  284. context.imageSmoothingEnabled = false;
  285. // Sets the text in the texture.
  286. for (var i = 0; i < text.length; i++) {
  287. context.fillText(text[i], 0, i * _this._charSize - maxCharHeight.offset);
  288. }
  289. // Flush the text in the dynamic texture.
  290. scene.getEngine().updateDynamicTexture(_this._texture, canvas, false, true);
  291. return _this;
  292. }
  293. Object.defineProperty(DigitalRainFontTexture.prototype, "charSize", {
  294. /**
  295. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  296. */
  297. get: function () {
  298. return this._charSize;
  299. },
  300. enumerable: true,
  301. configurable: true
  302. });
  303. /**
  304. * Gets the max char width of a font.
  305. * @param font the font to use, use the W3C CSS notation
  306. * @return the max char width
  307. */
  308. DigitalRainFontTexture.prototype.getFontWidth = function (font) {
  309. var fontDraw = document.createElement("canvas");
  310. var ctx = fontDraw.getContext('2d');
  311. ctx.fillStyle = 'white';
  312. ctx.font = font;
  313. return ctx.measureText("W").width;
  314. };
  315. // More info here: https://videlais.com/2014/03/16/the-many-and-varied-problems-with-measuring-font-height-for-html5-canvas/
  316. /**
  317. * Gets the max char height of a font.
  318. * @param font the font to use, use the W3C CSS notation
  319. * @return the max char height
  320. */
  321. DigitalRainFontTexture.prototype.getFontHeight = function (font) {
  322. var fontDraw = document.createElement("canvas");
  323. var ctx = fontDraw.getContext('2d');
  324. ctx.fillRect(0, 0, fontDraw.width, fontDraw.height);
  325. ctx.textBaseline = 'top';
  326. ctx.fillStyle = 'white';
  327. ctx.font = font;
  328. ctx.fillText('jH|', 0, 0);
  329. var pixels = ctx.getImageData(0, 0, fontDraw.width, fontDraw.height).data;
  330. var start = -1;
  331. var end = -1;
  332. for (var row = 0; row < fontDraw.height; row++) {
  333. for (var column = 0; column < fontDraw.width; column++) {
  334. var index = (row * fontDraw.width + column) * 4;
  335. if (pixels[index] === 0) {
  336. if (column === fontDraw.width - 1 && start !== -1) {
  337. end = row;
  338. row = fontDraw.height;
  339. break;
  340. }
  341. continue;
  342. }
  343. else {
  344. if (start === -1) {
  345. start = row;
  346. }
  347. break;
  348. }
  349. }
  350. }
  351. return { height: (end - start) + 1, offset: start - 1 };
  352. };
  353. /**
  354. * Clones the current DigitalRainFontTexture.
  355. * @return the clone of the texture.
  356. */
  357. DigitalRainFontTexture.prototype.clone = function () {
  358. return new DigitalRainFontTexture(this.name, this._font, this._text, this.getScene());
  359. };
  360. /**
  361. * Parses a json object representing the texture and returns an instance of it.
  362. * @param source the source JSON representation
  363. * @param scene the scene to create the texture for
  364. * @return the parsed texture
  365. */
  366. DigitalRainFontTexture.Parse = function (source, scene) {
  367. var texture = BABYLON.SerializationHelper.Parse(function () { return new DigitalRainFontTexture(source.name, source.font, source.text, scene); }, source, scene, null);
  368. return texture;
  369. };
  370. __decorate([
  371. BABYLON.serialize("font")
  372. ], DigitalRainFontTexture.prototype, "_font", void 0);
  373. __decorate([
  374. BABYLON.serialize("text")
  375. ], DigitalRainFontTexture.prototype, "_text", void 0);
  376. return DigitalRainFontTexture;
  377. }(BABYLON.BaseTexture));
  378. BABYLON.DigitalRainFontTexture = DigitalRainFontTexture;
  379. /**
  380. * DigitalRainPostProcess helps rendering everithing in digital rain.
  381. *
  382. * Simmply add it to your scene and let the nerd that lives in you have fun.
  383. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  384. */
  385. var DigitalRainPostProcess = /** @class */ (function (_super) {
  386. __extends(DigitalRainPostProcess, _super);
  387. /**
  388. * Instantiates a new Digital Rain Post Process.
  389. * @param name the name to give to the postprocess
  390. * @camera the camera to apply the post process to.
  391. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  392. */
  393. function DigitalRainPostProcess(name, camera, options) {
  394. var _this = _super.call(this, name, 'digitalrain', ['digitalRainFontInfos', 'digitalRainOptions', 'cosTimeZeroOne', 'matrixSpeed'], ['digitalRainFont'], {
  395. width: camera.getEngine().getRenderWidth(),
  396. height: camera.getEngine().getRenderHeight()
  397. }, camera, BABYLON.Texture.TRILINEAR_SAMPLINGMODE, camera.getEngine(), true) || this;
  398. /**
  399. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  400. * This number is defined between 0 and 1;
  401. */
  402. _this.mixToTile = 0;
  403. /**
  404. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  405. * This number is defined between 0 and 1;
  406. */
  407. _this.mixToNormal = 0;
  408. // Default values.
  409. var font = "15px Monospace";
  410. var characterSet = "古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";
  411. // Use options.
  412. if (options) {
  413. if (typeof (options) === "string") {
  414. font = options;
  415. }
  416. else {
  417. font = options.font || font;
  418. _this.mixToTile = options.mixToTile || _this.mixToTile;
  419. _this.mixToNormal = options.mixToNormal || _this.mixToNormal;
  420. }
  421. }
  422. _this._digitalRainFontTexture = new DigitalRainFontTexture(name, font, characterSet, camera.getScene());
  423. var textureSize = _this._digitalRainFontTexture.getSize();
  424. var alpha = 0.0;
  425. var cosTimeZeroOne = 0.0;
  426. var matrix = new BABYLON.Matrix();
  427. for (var i = 0; i < 16; i++) {
  428. matrix.m[i] = Math.random();
  429. }
  430. _this.onApply = function (effect) {
  431. effect.setTexture("digitalRainFont", _this._digitalRainFontTexture);
  432. effect.setFloat4("digitalRainFontInfos", _this._digitalRainFontTexture.charSize, characterSet.length, textureSize.width, textureSize.height);
  433. effect.setFloat4("digitalRainOptions", _this.width, _this.height, _this.mixToNormal, _this.mixToTile);
  434. effect.setMatrix("matrixSpeed", matrix);
  435. alpha += 0.003;
  436. cosTimeZeroOne = alpha;
  437. effect.setFloat('cosTimeZeroOne', cosTimeZeroOne);
  438. };
  439. return _this;
  440. }
  441. return DigitalRainPostProcess;
  442. }(BABYLON.PostProcess));
  443. BABYLON.DigitalRainPostProcess = DigitalRainPostProcess;
  444. })(BABYLON || (BABYLON = {}));
  445. //# sourceMappingURL=babylon.digitalRainPostProcess.js.map
  446. BABYLON.Effect.ShadersStore['digitalrainPixelShader'] = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D digitalRainFont;\n\nuniform vec4 digitalRainFontInfos;\nuniform vec4 digitalRainOptions;\nuniform mat4 matrixSpeed;\nuniform float cosTimeZeroOne;\n\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\n\nvoid main(void) \n{\nfloat caracterSize=digitalRainFontInfos.x;\nfloat numChar=digitalRainFontInfos.y-1.0;\nfloat fontx=digitalRainFontInfos.z;\nfloat fonty=digitalRainFontInfos.w;\nfloat screenx=digitalRainOptions.x;\nfloat screeny=digitalRainOptions.y;\nfloat ratio=screeny/fonty;\nfloat columnx=float(floor((gl_FragCoord.x)/caracterSize));\nfloat tileX=float(floor((gl_FragCoord.x)/caracterSize))*caracterSize/screenx;\nfloat tileY=float(floor((gl_FragCoord.y)/caracterSize))*caracterSize/screeny;\nvec2 tileUV=vec2(tileX,tileY);\nvec4 tileColor=texture2D(textureSampler,tileUV);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat tileLuminance=getLuminance(tileColor.rgb);\nint st=int(mod(columnx,4.0));\nfloat speed=cosTimeZeroOne*(sin(tileX*314.5)*0.5+0.6); \nfloat x=float(mod(gl_FragCoord.x,caracterSize))/fontx;\nfloat y=float(mod(speed+gl_FragCoord.y/screeny,1.0));\ny*=ratio;\nvec4 finalColor=texture2D(digitalRainFont,vec2(x,1.0-y));\nvec3 high=finalColor.rgb*(vec3(1.2,1.2,1.2)*pow(1.0-y,30.0));\nfinalColor.rgb*=vec3(pow(tileLuminance,5.0),pow(tileLuminance,1.5),pow(tileLuminance,3.0));\nfinalColor.rgb+=high;\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\nfinalColor.a=1.0;\nfinalColor=mix(finalColor,tileColor,digitalRainOptions.w);\nfinalColor=mix(finalColor,baseColor,digitalRainOptions.z);\ngl_FragColor=finalColor;\n}";
  447. return BABYLON;
  448. });