babylonjs.postProcess.js 24 KB

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