12345678910111213141516 |
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-post-process",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-post-process"]=t(require("babylonjs")):e.POSTPROCESSES=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.d(t,"b",function(){return r}),n.d(t,"a",function(){return i});
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function r(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function i(e,t,n,o){var r,i=arguments.length,a=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n(0),i="\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}";r.Effect.ShadersStore.digitalrainPixelShader=i;var a=function(e){function t(t,n,o,i){void 0===i&&(i=null);var a=e.call(this,i)||this;if(!(i=a.getScene()))return a;a.name=t,a._text,a._font,a.wrapU=r.Texture.CLAMP_ADDRESSMODE,a.wrapV=r.Texture.CLAMP_ADDRESSMODE;var c=a.getFontHeight(n),l=a.getFontWidth(n);a._charSize=Math.max(c.height,l);var f=a._charSize,s=Math.ceil(a._charSize*o.length);a._texture=i.getEngine().createDynamicTexture(f,s,!1,r.Texture.NEAREST_SAMPLINGMODE);var u=a.getSize(),m=document.createElement("canvas");m.width=u.width,m.height=u.height;var d=m.getContext("2d");d.textBaseline="top",d.font=n,d.fillStyle="white",d.imageSmoothingEnabled=!1;for(var p=0;p<o.length;p++)d.fillText(o[p],0,p*a._charSize-c.offset);return i.getEngine().updateDynamicTexture(a._texture,m,!1,!0),a}return Object(o.b)(t,e),Object.defineProperty(t.prototype,"charSize",{get:function(){return this._charSize},enumerable:!0,configurable:!0}),t.prototype.getFontWidth=function(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="white",t.font=e,t.measureText("W").width},t.prototype.getFontHeight=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");n.fillRect(0,0,t.width,t.height),n.textBaseline="top",n.fillStyle="white",n.font=e,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,t.width,t.height).data,r=-1,i=-1,a=0;a<t.height;a++)for(var c=0;c<t.width;c++){if(0!==o[4*(a*t.width+c)]){-1===r&&(r=a);break}if(c===t.width-1&&-1!==r){i=a,a=t.height;break}}return{height:i-r+1,offset:r-1}},t.prototype.clone=function(){return new t(this.name,this._font,this._text,this.getScene())},t.Parse=function(e,n){return r.SerializationHelper.Parse(function(){return new t(e.name,e.font,e.text,n)},e,n,null)},Object(o.a)([Object(r.serialize)("font")],t.prototype,"_font",void 0),Object(o.a)([Object(r.serialize)("text")],t.prototype,"_text",void 0),t}(r.BaseTexture),c=function(e){function t(t,n,o){var i=e.call(this,t,"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 c="15px Monospace",l="古池や蛙飛び込む水の音ふるいけやかわずとびこむみずのおと初しぐれ猿も小蓑をほしげ也はつしぐれさるもこみのをほしげなり江戸の雨何石呑んだ時鳥えどのあめなんごくのんだほととぎす";o&&("string"==typeof o?c=o:(c=o.font||c,i.mixToTile=o.mixToTile||i.mixToTile,i.mixToNormal=o.mixToNormal||i.mixToNormal)),i._digitalRainFontTexture=new a(t,c,l,n.getScene());var f=i._digitalRainFontTexture.getSize(),s=0,u=0,m=r.Matrix.FromValues(Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random(),Math.random());return i.onApply=function(e){e.setTexture("digitalRainFont",i._digitalRainFontTexture),e.setFloat4("digitalRainFontInfos",i._digitalRainFontTexture.charSize,l.length,f.width,f.height),e.setFloat4("digitalRainOptions",i.width,i.height,i.mixToNormal,i.mixToTile),e.setMatrix("matrixSpeed",m),u=s+=.003,e.setFloat("cosTimeZeroOne",u)},i}return Object(o.b)(t,e),t}(r.PostProcess);n.d(t,"DigitalRainFontTexture",function(){return a}),n.d(t,"DigitalRainPostProcess",function(){return c})},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n(0),i="\n\nuniform sampler2D textureSampler;\nuniform sampler2D positionSampler;\n#ifdef REFLECTION_ENABLED\nuniform sampler2D reflectionSampler;\n#endif\n#ifdef REFRACTION_ENABLED\nuniform sampler2D refractionSampler;\n#endif\nuniform float time;\nuniform vec2 resolution;\nuniform vec3 cameraRotation;\nuniform vec3 cameraPosition;\n\nvarying vec2 vUV;\n\nconst int NUM_STEPS=8;\nconst float PI=3.141592;\nconst float EPSILON=1e-3;\n#define EPSILON_NRM (0.1/resolution.x)\n\nconst int ITER_GEOMETRY=8;\nconst int ITER_FRAGMENT=5;\nconst float SEA_HEIGHT=0.6;\nconst float SEA_CHOPPY=4.0;\nconst float SEA_SPEED=0.8;\nconst float SEA_FREQ=0.16;\nconst vec3 SEA_BASE=vec3(0.1,0.19,0.22);\nconst vec3 SEA_WATER_COLOR=vec3(0.8,0.9,0.6);\n#define SEA_TIME (1.0+time*SEA_SPEED)\nconst mat2 octave_m=mat2(1.6,1.2,-1.2,1.6);\n\nmat3 fromEuler(vec3 ang)\n{\nvec2 a1=vec2(sin(ang.x),cos(ang.x));\nvec2 a2=vec2(sin(ang.y),cos(ang.y));\nvec2 a3=vec2(sin(ang.z),cos(ang.z));\nmat3 m;\nm[0]=vec3(a1.y*a3.y+a1.x*a2.x*a3.x,a1.y*a2.x*a3.x+a3.y*a1.x,-a2.y*a3.x);\nm[1]=vec3(-a2.y*a1.x,a1.y*a2.y,a2.x);\nm[2]=vec3(a3.y*a1.x*a2.x+a1.y*a3.x,a1.x*a3.x-a1.y*a3.y*a2.x,a2.y*a3.y);\nreturn m;\n}\nfloat hash( vec2 p )\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn fract(sin(h)*43758.5453123);\n}\nfloat noise( in vec2 p )\n{\nvec2 i=floor( p );\nvec2 f=fract( p );\nvec2 u=f*f*(3.0-2.0*f);\nreturn -1.0+2.0*mix( mix( hash( i+vec2(0.0,0.0) ),\nhash( i+vec2(1.0,0.0) ),u.x),\nmix( hash( i+vec2(0.0,1.0) ),\nhash( i+vec2(1.0,1.0) ),u.x),u.y);\n}\n\nfloat diffuse(vec3 n,vec3 l,float p)\n{\nreturn pow(dot(n,l)*0.4+0.6,p);\n}\nfloat specular(vec3 n,vec3 l,vec3 e,float s)\n{\nfloat nrm=(s+8.0)/(PI*8.0);\nreturn pow(max(dot(reflect(e,n),l),0.0),s)*nrm;\n}\n\nfloat sea_octave(vec2 uv,float choppy)\n{\nuv+=noise(uv);\nvec2 wv=1.0-abs(sin(uv));\nvec2 swv=abs(cos(uv));\nwv=mix(wv,swv,wv);\nreturn pow(1.0-pow(wv.x*wv.y,0.65),choppy);\n}\nfloat map(vec3 p)\n{\nfloat freq=SEA_FREQ;\nfloat amp=SEA_HEIGHT;\nfloat choppy=SEA_CHOPPY;\nvec2 uv=p.xz; uv.x*=0.75;\nfloat d,h=0.0;\nfor(int i=0; i<ITER_GEOMETRY; i++)\n{\nd=sea_octave((uv+SEA_TIME)*freq,choppy);\nd+=sea_octave((uv-SEA_TIME)*freq,choppy);\nh+=d*amp;\nuv*=octave_m; freq*=1.9; amp*=0.22;\nchoppy=mix(choppy,1.0,0.2);\n}\nreturn p.y-h;\n}\nfloat map_detailed(vec3 p)\n{\nfloat freq=SEA_FREQ;\nfloat amp=SEA_HEIGHT;\nfloat choppy=SEA_CHOPPY;\nvec2 uv=p.xz; uv.x*=0.75;\nfloat d,h=0.0;\nfor(int i=0; i<ITER_FRAGMENT; i++)\n{\nd=sea_octave((uv+SEA_TIME)*freq,choppy);\nd+=sea_octave((uv-SEA_TIME)*freq,choppy);\nh+=d*amp;\nuv*=octave_m; freq*=1.9; amp*=0.22;\nchoppy=mix(choppy,1.0,0.2);\n}\nreturn p.y-h;\n}\nvec3 getSeaColor(vec3 p,vec3 n,vec3 l,vec3 eye,vec3 dist)\n{\nfloat fresnel=clamp(1.0-dot(n,-eye),0.0,1.0);\nfresnel=pow(fresnel,3.0)*0.65;\n#if defined(REFLECTION_ENABLED) || defined(REFRACTION_ENABLED)\nvec2 reflectionUv=vec2(vUV.x,vUV.y+normalize(n).y);\n#endif\n#ifdef REFLECTION_ENABLED\nvec3 reflected=texture2D(reflectionSampler,reflectionUv).rgb*(1.0-fresnel);\n#else\nvec3 eyeNormal=reflect(eye,n);\neyeNormal.y=max(eyeNormal.y,0.0);\nvec3 reflected=vec3(pow(1.0-eyeNormal.y,2.0),1.0-eyeNormal.y,0.6+(1.0-eyeNormal.y)*0.4);\n#endif\n#ifdef REFRACTION_ENABLED\nvec3 refracted=SEA_BASE+diffuse(n,l,80.0)*SEA_WATER_COLOR*0.12;\nrefracted+=(texture2D(refractionSampler,reflectionUv).rgb*fresnel);\n#else\nvec3 refracted=SEA_BASE+diffuse(n,l,80.0)*SEA_WATER_COLOR*0.12;\n#endif\nvec3 color=mix(refracted,reflected,fresnel);\nfloat atten=max(1.0-dot(dist,dist)*0.001,0.0);\ncolor+=SEA_WATER_COLOR*(p.y-SEA_HEIGHT)*0.18*atten;\ncolor+=vec3(specular(n,l,eye,60.0));\nreturn color;\n}\n\nvec3 getNormal(vec3 p,float eps)\n{\nvec3 n;\nn.y=map_detailed(p);\nn.x=map_detailed(vec3(p.x+eps,p.y,p.z))-n.y;\nn.z=map_detailed(vec3(p.x,p.y,p.z+eps))-n.y;\nn.y=eps;\nreturn normalize(n);\n}\nfloat heightMapTracing(vec3 ori,vec3 dir,out vec3 p)\n{\nfloat tm=0.0;\nfloat tx=1000.0;\nfloat hx=map(ori+dir*tx);\nif(hx>0.0) return tx;\nfloat hm=map(ori+dir*tm);\nfloat tmid=0.0;\nfor(int i=0; i<NUM_STEPS; i++)\n{\ntmid=mix(tm,tx,hm/(hm-hx));\np=ori+dir*tmid;\nfloat hmid=map(p);\nif(hmid<0.0)\n{\ntx=tmid;\nhx=hmid;\n}\nelse\n{\ntm=tmid;\nhm=hmid;\n}\n}\nreturn tmid;\n}\n\nvoid main()\n{\n#ifdef NOT_SUPPORTED\n\ngl_FragColor=texture2D(textureSampler,vUV);\n#else\nvec2 uv=vUV;\nuv=uv*2.0-1.0;\nuv.x*=resolution.x/resolution.y;\n\nvec3 ang=vec3(cameraRotation.z,cameraRotation.x,cameraRotation.y);\nvec3 ori=vec3(cameraPosition.x,cameraPosition.y,-cameraPosition.z);\nvec3 dir=normalize(vec3(uv.xy,-3.0));\ndir=normalize(dir)*fromEuler(ang);\n\nvec3 p;\nheightMapTracing(ori,dir,p);\nvec3 dist=p-ori;\nvec3 n=getNormal(p,dot(dist,dist)*EPSILON_NRM);\nvec3 light=normalize(vec3(0.0,1.0,0.8));\n\nfloat seaFact=clamp(max(ori.y,0.0),0.0,1.0);\nvec3 position=texture2D(positionSampler,vUV).rgb;\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 color=baseColor;\nif (max(position.y,0.0)<p.y)\n{\n\ncolor=mix(\nbaseColor,\ngetSeaColor(p,n,light,dir,dist),\npow(smoothstep(0.0,-0.05,dir.y),0.3)\n)*seaFact;\n}\ncolor=mix(\ncolor,\nbaseColor*SEA_BASE+diffuse(n,n,80.0)*SEA_WATER_COLOR*0.12,\n1.0-seaFact\n);\n\ngl_FragColor=vec4(pow(color,vec3(0.75)),1.0);\n#endif\n}\n";r.Effect.ShadersStore.oceanPostProcessPixelShader=i;var a=function(e){function t(t,n,o){void 0===o&&(o={});var i=e.call(this,t,"oceanPostProcess",["time","resolution","cameraPosition","cameraRotation"],["positionSampler","reflectionSampler","refractionSampler"],{width:n.getEngine().getRenderWidth(),height:n.getEngine().getRenderHeight()},n,r.Texture.TRILINEAR_SAMPLINGMODE,n.getEngine(),!0)||this;return i._time=0,i._cameraRotation=r.Vector3.Zero(),i._cameraViewMatrix=r.Matrix.Identity(),i._reflectionEnabled=!1,i._refractionEnabled=!1,i._geometryRenderer=n.getScene().enableGeometryBufferRenderer(1),i._geometryRenderer&&i._geometryRenderer.isSupported?(i._geometryRenderer.enablePosition=!0,i.reflectionTexture=new r.MirrorTexture("oceanPostProcessReflection",o.reflectionSize||{width:512,height:512},n.getScene()),i.reflectionTexture.mirrorPlane=r.Plane.FromPositionAndNormal(r.Vector3.Zero(),new r.Vector3(0,-1,0)),i.refractionTexture=new r.RenderTargetTexture("oceanPostProcessRefraction",o.refractionSize||{width:512,height:512},n.getScene())):i.updateEffect("#define NOT_SUPPORTED\n"),i.onApply=function(e){if(i._geometryRenderer&&i._geometryRenderer.isSupported){var t=n.getEngine(),o=n.getScene();i._time+=.001*t.getDeltaTime(),e.setFloat("time",i._time),e.setVector2("resolution",new r.Vector2(t.getRenderWidth(),t.getRenderHeight())),o&&(e.setVector3("cameraPosition",n.globalPosition),i._computeCameraRotation(n),e.setVector3("cameraRotation",i._cameraRotation),e.setTexture("positionSampler",i._geometryRenderer.getGBuffer().textures[2]),i._reflectionEnabled&&e.setTexture("reflectionSampler",i.reflectionTexture),i._refractionEnabled&&e.setTexture("refractionSampler",i.refractionTexture))}},i}return Object(o.b)(t,e),Object.defineProperty(t.prototype,"reflectionEnabled",{get:function(){return this._reflectionEnabled},set:function(e){if(this._reflectionEnabled!==e){this._reflectionEnabled=e,this.updateEffect(this._getDefines());var t=this.getCamera().getScene().customRenderTargets;if(e)t.push(this.reflectionTexture);else{var n=t.indexOf(this.reflectionTexture);-1!==n&&t.splice(n,1)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"refractionEnabled",{get:function(){return this._refractionEnabled},set:function(e){if(this._refractionEnabled!==e){this._refractionEnabled=e,this.updateEffect(this._getDefines());var t=this.getCamera().getScene().customRenderTargets;if(e)t.push(this.refractionTexture);else{var n=t.indexOf(this.refractionTexture);-1!==n&&t.splice(n,1)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSupported",{get:function(){return null!==this._geometryRenderer&&this._geometryRenderer.isSupported},enumerable:!0,configurable:!0}),t.prototype._getDefines=function(){var e=[];return this._reflectionEnabled&&e.push("#define REFLECTION_ENABLED"),this._refractionEnabled&&e.push("#define REFRACTION_ENABLED"),e.join("\n")},t.prototype._computeCameraRotation=function(e){e.upVector.normalize();var t=e.getTarget();e._initialFocalDistance=t.subtract(e.position).length(),e.position.z===t.z&&(e.position.z+=r.Epsilon);var n=t.subtract(e.position);e._viewMatrix.invertToRef(this._cameraViewMatrix),this._cameraRotation.x=Math.atan(this._cameraViewMatrix.m[6]/this._cameraViewMatrix.m[10]),n.x>=0?this._cameraRotation.y=-Math.atan(n.z/n.x)+Math.PI/2:this._cameraRotation.y=-Math.atan(n.z/n.x)-Math.PI/2,this._cameraRotation.z=0,isNaN(this._cameraRotation.x)&&(this._cameraRotation.x=0),isNaN(this._cameraRotation.y)&&(this._cameraRotation.y=0),isNaN(this._cameraRotation.z)&&(this._cameraRotation.z=0)},t}(r.PostProcess);n.d(t,"OceanPostProcess",function(){return a})},function(e,t,n){"use strict";n.r(t);var o=n(1),r=n(0),i="\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}";r.Effect.ShadersStore.asciiartPixelShader=i;var a=function(e){function t(t,n,o,i){void 0===i&&(i=null);var a=e.call(this,i)||this;if(!(i=a.getScene()))return a;a.name=t,a._text,a._font,a.wrapU=r.Texture.CLAMP_ADDRESSMODE,a.wrapV=r.Texture.CLAMP_ADDRESSMODE;var c=a.getFontHeight(n),l=a.getFontWidth(n);a._charSize=Math.max(c.height,l);var f=Math.ceil(a._charSize*o.length),s=a._charSize;a._texture=i.getEngine().createDynamicTexture(f,s,!1,r.Texture.NEAREST_SAMPLINGMODE);var u=a.getSize(),m=document.createElement("canvas");m.width=u.width,m.height=u.height;var d=m.getContext("2d");d.textBaseline="top",d.font=n,d.fillStyle="white",d.imageSmoothingEnabled=!1;for(var p=0;p<o.length;p++)d.fillText(o[p],p*a._charSize,-c.offset);return i.getEngine().updateDynamicTexture(a._texture,m,!1,!0),a}return Object(o.b)(t,e),Object.defineProperty(t.prototype,"charSize",{get:function(){return this._charSize},enumerable:!0,configurable:!0}),t.prototype.getFontWidth=function(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="white",t.font=e,t.measureText("W").width},t.prototype.getFontHeight=function(e){var t=document.createElement("canvas"),n=t.getContext("2d");n.fillRect(0,0,t.width,t.height),n.textBaseline="top",n.fillStyle="white",n.font=e,n.fillText("jH|",0,0);for(var o=n.getImageData(0,0,t.width,t.height).data,r=-1,i=-1,a=0;a<t.height;a++)for(var c=0;c<t.width;c++){if(0!==o[4*(a*t.width+c)]){-1===r&&(r=a);break}if(c===t.width-1&&-1!==r){i=a,a=t.height;break}}return{height:i-r+1,offset:r-1}},t.prototype.clone=function(){return new t(this.name,this._font,this._text,this.getScene())},t.Parse=function(e,n){return r.SerializationHelper.Parse(function(){return new t(e.name,e.font,e.text,n)},e,n,null)},Object(o.a)([Object(r.serialize)("font")],t.prototype,"_font",void 0),Object(o.a)([Object(r.serialize)("text")],t.prototype,"_text",void 0),t}(r.BaseTexture),c=function(e){function t(t,n,o){var i=e.call(this,t,"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 c="40px Monospace",l=" `-.'_:,\"=^;<+!*?/cL\\zrs7TivJtC{3F)Il(xZfY5S2eajo14[nuyE]P6V9kXpKwGhqAUbOd8#HRDB0$mgMW&Q%N@";o&&("string"==typeof o?c=o:(c=o.font||c,l=o.characterSet||l,i.mixToTile=o.mixToTile||i.mixToTile,i.mixToNormal=o.mixToNormal||i.mixToNormal)),i._asciiArtFontTexture=new a(t,c,l,n.getScene());var f=i._asciiArtFontTexture.getSize();return i.onApply=function(e){e.setTexture("asciiArtFont",i._asciiArtFontTexture),e.setFloat4("asciiArtFontInfos",i._asciiArtFontTexture.charSize,l.length,f.width,f.height),e.setFloat4("asciiArtOptions",i.width,i.height,i.mixToNormal,i.mixToTile)},i}return Object(o.b)(t,e),t}(r.PostProcess);n.d(t,"AsciiArtFontTexture",function(){return a}),n.d(t,"AsciiArtPostProcess",function(){return c})},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);var o=n(4);n.d(t,"AsciiArtFontTexture",function(){return o.AsciiArtFontTexture}),n.d(t,"AsciiArtPostProcess",function(){return o.AsciiArtPostProcess});var r=n(2);n.d(t,"DigitalRainFontTexture",function(){return r.DigitalRainFontTexture}),n.d(t,"DigitalRainPostProcess",function(){return r.DigitalRainPostProcess});var i=n(3);n.d(t,"OceanPostProcess",function(){return i.OceanPostProcess})},function(e,t,n){"use strict";n.r(t),function(e){var o=n(6);n.d(t,"AsciiArtFontTexture",function(){return o.AsciiArtFontTexture}),n.d(t,"AsciiArtPostProcess",function(){return o.AsciiArtPostProcess}),n.d(t,"DigitalRainFontTexture",function(){return o.DigitalRainFontTexture}),n.d(t,"DigitalRainPostProcess",function(){return o.DigitalRainPostProcess}),n.d(t,"OceanPostProcess",function(){return o.OceanPostProcess});var r=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var i in o)r.BABYLON[i]=o[i]}.call(this,n(5))}])});
|