babylonjs.postProcess.min.js 13 KB

12
  1. !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-postProcessesLibrary",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-postProcessesLibrary"]=e(require("babylonjs")):t.PPLIB=e(t.BABYLON)}(window,function(t){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e,n){"use strict";function o(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),o(n(4)),o(n(7))},function(e,n){e.exports=t},function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),i=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var r in o)i.BABYLON[r]=o[r];!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0))}).call(this,n(3))},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(5))},function(t,e,n){"use strict";var o=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),i=this&&this.__decorate||function(t,e,n,o){var i,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(a=(r<3?i(a):r>3?i(e,n,a):i(e,n))||a);return r>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);r.Effect.ShadersStore.asciiartPixelShader=n(6);var a=function(t){function e(e,n,o,i){void 0===i&&(i=null);var a=t.call(this,i)||this;if(!(i=a.getScene()))return a;a.name=e,a._text,a._font,a.wrapU=r.Texture.CLAMP_ADDRESSMODE,a.wrapV=r.Texture.CLAMP_ADDRESSMODE;var l=a.getFontHeight(n),c=a.getFontWidth(n);a._charSize=Math.max(l.height,c);var f=Math.ceil(a._charSize*o.length),u=a._charSize;a._texture=i.getEngine().createDynamicTexture(f,u,!1,r.Texture.NEAREST_SAMPLINGMODE);var s=a.getSize(),g=document.createElement("canvas");g.width=s.width,g.height=s.height;var h=g.getContext("2d");h.textBaseline="top",h.font=n,h.fillStyle="white",h.imageSmoothingEnabled=!1;for(var d=0;d<o.length;d++)h.fillText(o[d],d*a._charSize,-l.offset);return i.getEngine().updateDynamicTexture(a._texture,g,!1,!0),a}return o(e,t),Object.defineProperty(e.prototype,"charSize",{get:function(){return this._charSize},enumerable:!0,configurable:!0}),e.prototype.getFontWidth=function(t){var e=document.createElement("canvas").getContext("2d");return e.fillStyle="white",e.font=t,e.measureText("W").width},e.prototype.getFontHeight=function(t){var e=document.createElement("canvas"),n=e.getContext("2d");n.fillRect(0,0,e.width,e.height),n.textBaseline="top",n.fillStyle="white",n.font=t,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,e.width,e.height).data,i=-1,r=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==o[4*(a*e.width+l)]){-1===i&&(i=a);break}if(l===e.width-1&&-1!==i){r=a,a=e.height;break}}return{height:r-i+1,offset:i-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,n){return r.SerializationHelper.Parse(function(){return new e(t.name,t.font,t.text,n)},t,n,null)},i([r.serialize("font")],e.prototype,"_font",void 0),i([r.serialize("text")],e.prototype,"_text",void 0),e}(r.BaseTexture);e.AsciiArtFontTexture=a;var l=function(t){function e(e,n,o){var i=t.call(this,e,"asciiart",["asciiArtFontInfos","asciiArtOptions"],["asciiArtFont"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,r.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;i.mixToTile=0,i.mixToNormal=0;var l="40px Monospace",c=" `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";o&&("string"==typeof o?l=o:(l=o.font||l,c=o.characterSet||c,i.mixToTile=o.mixToTile||i.mixToTile,i.mixToNormal=o.mixToNormal||i.mixToNormal)),i._asciiArtFontTexture=new a(e,l,c,n.getScene());var f=i._asciiArtFontTexture.getSize();return i.onApply=function(t){t.setTexture("asciiArtFont",i._asciiArtFontTexture),t.setFloat4("asciiArtFontInfos",i._asciiArtFontTexture.charSize,c.length,f.width,f.height),t.setFloat4("asciiArtOptions",i.width,i.height,i.mixToNormal,i.mixToTile)},i}return o(e,t),e}(r.PostProcess);e.AsciiArtPostProcess=l},function(t,e){t.exports="\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}"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(8))},function(t,e,n){"use strict";var o=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),i=this&&this.__decorate||function(t,e,n,o){var i,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(i=t[l])&&(a=(r<3?i(a):r>3?i(e,n,a):i(e,n))||a);return r>3&&a&&Object.defineProperty(e,n,a),a};Object.defineProperty(e,"__esModule",{value:!0});var r=n(1);r.Effect.ShadersStore.digitalrainPixelShader=n(9);var a=function(t){function e(e,n,o,i){void 0===i&&(i=null);var a=t.call(this,i)||this;if(!(i=a.getScene()))return a;a.name=e,a._text,a._font,a.wrapU=r.Texture.CLAMP_ADDRESSMODE,a.wrapV=r.Texture.CLAMP_ADDRESSMODE;var l=a.getFontHeight(n),c=a.getFontWidth(n);a._charSize=Math.max(l.height,c);var f=a._charSize,u=Math.ceil(a._charSize*o.length);a._texture=i.getEngine().createDynamicTexture(f,u,!1,r.Texture.NEAREST_SAMPLINGMODE);var s=a.getSize(),g=document.createElement("canvas");g.width=s.width,g.height=s.height;var h=g.getContext("2d");h.textBaseline="top",h.font=n,h.fillStyle="white",h.imageSmoothingEnabled=!1;for(var d=0;d<o.length;d++)h.fillText(o[d],0,d*a._charSize-l.offset);return i.getEngine().updateDynamicTexture(a._texture,g,!1,!0),a}return o(e,t),Object.defineProperty(e.prototype,"charSize",{get:function(){return this._charSize},enumerable:!0,configurable:!0}),e.prototype.getFontWidth=function(t){var e=document.createElement("canvas").getContext("2d");return e.fillStyle="white",e.font=t,e.measureText("W").width},e.prototype.getFontHeight=function(t){var e=document.createElement("canvas"),n=e.getContext("2d");n.fillRect(0,0,e.width,e.height),n.textBaseline="top",n.fillStyle="white",n.font=t,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,e.width,e.height).data,i=-1,r=-1,a=0;a<e.height;a++)for(var l=0;l<e.width;l++){if(0!==o[4*(a*e.width+l)]){-1===i&&(i=a);break}if(l===e.width-1&&-1!==i){r=a,a=e.height;break}}return{height:r-i+1,offset:i-1}},e.prototype.clone=function(){return new e(this.name,this._font,this._text,this.getScene())},e.Parse=function(t,n){return r.SerializationHelper.Parse(function(){return new e(t.name,t.font,t.text,n)},t,n,null)},i([r.serialize("font")],e.prototype,"_font",void 0),i([r.serialize("text")],e.prototype,"_text",void 0),e}(r.BaseTexture);e.DigitalRainFontTexture=a;var l=function(t){function e(e,n,o){var i=t.call(this,e,"digitalrain",["digitalRainFontInfos","digitalRainOptions","cosTimeZeroOne","matrixSpeed"],["digitalRainFont"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,r.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;i.mixToTile=0,i.mixToNormal=0;var l="15px Monospace",c="古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";o&&("string"==typeof o?l=o:(l=o.font||l,i.mixToTile=o.mixToTile||i.mixToTile,i.mixToNormal=o.mixToNormal||i.mixToNormal)),i._digitalRainFontTexture=new a(e,l,c,n.getScene());for(var f=i._digitalRainFontTexture.getSize(),u=0,s=0,g=new r.Matrix,h=0;h<16;h++)g.m[h]=Math.random();return i.onApply=function(t){t.setTexture("digitalRainFont",i._digitalRainFontTexture),t.setFloat4("digitalRainFontInfos",i._digitalRainFontTexture.charSize,c.length,f.width,f.height),t.setFloat4("digitalRainOptions",i.width,i.height,i.mixToNormal,i.mixToTile),t.setMatrix("matrixSpeed",g),s=u+=.003,t.setFloat("cosTimeZeroOne",s)},i}return o(e,t),e}(r.PostProcess);e.DigitalRainPostProcess=l},function(t,e){t.exports="\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}"}])});
  2. //# sourceMappingURL=babylonjs.postProcess.min.js.map