babylonjs.postProcess.js 24 KB

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