babylonjs.postProcess.js 24 KB

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