!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-procedural-textures"]=n(require("babylonjs")):e.PROCEDURALTEXTURES=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=21)}({0:function(n,t){n.exports=e},1:function(e,n,t){"use strict";t.d(n,"b",function(){return o}),t.d(n,"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 r=function(e,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t])})(e,n)};function o(e,n){function t(){this.constructor=e}r(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}function i(e,n,t,r){var o,i=arguments.length,c=i<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,n,t,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(c=(i<3?o(c):i>3?o(n,t,c):o(n,t))||c);return i>3&&c&&Object.defineProperty(n,t,c),c}},11:function(e,n,t){"use strict";t.r(n);var r=t(1),o=t(0),i="\nprecision highp float;\n\nuniform float size;\nuniform float time;\nuniform float translationSpeed;\n\nvarying vec2 vUV;\n\nfloat r(float n)\n{\nreturn fract(cos(n*89.42)*343.42);\n}\nvec2 r(vec2 n)\n{\nreturn vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89));\n}\nfloat worley(vec2 n,float s)\n{\nfloat dis=1.0;\nfor(int x=-1; x<=1; x++)\n{\nfor(int y=-1; y<=1; y++)\n{\nvec2 p=floor(n/s)+vec2(x,y);\nfloat d=length(r(p)+vec2(x,y)-fract(n/s));\nif (dis>d)\ndis=d;\n}\n}\nreturn 1.0-dis;\n}\nvec3 hash33(vec3 p3)\n{\np3=fract(p3*vec3(0.1031,0.11369,0.13787));\np3+=dot(p3,p3.yxz+19.19);\nreturn -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));\n}\nfloat perlinNoise(vec3 p)\n{\nvec3 pi=floor(p);\nvec3 pf=p-pi;\nvec3 w=pf*pf*(3.0-2.0*pf);\nreturn mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),\nw.x\n),\nw.z\n),\nmix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),\nw.x\n),\nmix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),\nw.x\n),\nw.z\n),\nw.y\n);\n}\n\nvoid main(void)\n{\nvec2 uv=gl_FragCoord.xy+translationSpeed;\nfloat dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n*(1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);\ngl_FragColor=vec4(vec3(dis/4.0),1.0);\n}\n";o.Effect.ShadersStore.perlinNoiseProceduralTexturePixelShader=i;var c=function(e){function n(n,t,r,o,i){var c=e.call(this,n,t,"perlinNoiseProceduralTexture",r,o,i)||this;return c.time=0,c.timeScale=1,c.translationSpeed=1,c._currentTranslation=0,c.updateShaderUniforms(),c}return r.b(n,e),n.prototype.updateShaderUniforms=function(){this.setFloat("size",this.getRenderSize());var e=this.getScene();if(e){var n=e.getEngine().getDeltaTime();this.time+=n,this.setFloat("time",this.time*this.timeScale/1e3),this._currentTranslation+=n*this.translationSpeed/1e3,this.setFloat("translationSpeed",this._currentTranslation)}},n.prototype.render=function(n){this.updateShaderUniforms(),e.prototype.render.call(this,n)},n.prototype.resize=function(n,t){e.prototype.resize.call(this,n,t)},n.prototype.serialize=function(){var n=o.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return n.customType="BABYLON.PerlinNoiseProceduralTexture",n},n.Parse=function(e,t,r){return o.SerializationHelper.Parse(function(){return new n(e.name,e._size,t,void 0,e._generateMipMaps)},e,t,r)},r.a([Object(o.serialize)()],n.prototype,"time",void 0),r.a([Object(o.serialize)()],n.prototype,"timeScale",void 0),r.a([Object(o.serialize)()],n.prototype,"translationSpeed",void 0),n}(o.ProceduralTexture);o._TypeStore.RegisteredTypes["BABYLON.PerlinNoiseProceduralTexture"]=c,t.d(n,"PerlinNoiseProceduralTexture",function(){return c})},2:function(e,n){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},21:function(e,n,t){"use strict";t.r(n),function(e){var r=t(11);t.d(n,"PerlinNoiseProceduralTexture",function(){return r.PerlinNoiseProceduralTexture});var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in r)o.BABYLON[i]=r[i]}.call(this,t(2))}})});