babylonjs.postProcess.js 24 KB

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