12345678910111213141516 |
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-procedural-textures"]=e(require("babylonjs")):t.PROCEDURALTEXTURES=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=23)}({0:function(e,r){e.exports=t},1:function(t,e,r){"use strict";r.d(e,"b",function(){return o}),r.d(e,"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 n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function o(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function i(t,e,r,n){var o,i=arguments.length,a=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,r,a):o(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}},2:function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},23:function(t,e,r){"use strict";r.r(e),function(t){var n=r(7);r.d(e,"StarfieldProceduralTexture",function(){return n.StarfieldProceduralTexture});var o=void 0!==t?t:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in n)o.BABYLON[i]=n[i]}.call(this,r(2))},7:function(t,e,r){"use strict";r.r(e);var n=r(1),o=r(0),i="precision highp float;\n\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float time;\nuniform float alpha;\nuniform float beta;\nuniform float zoom;\nuniform float formuparam;\nuniform float stepsize;\nuniform float tile;\nuniform float brightness;\nuniform float darkmatter;\nuniform float distfading;\nuniform float saturation;\nvoid main()\n{\nvec3 dir=vec3(vUV*zoom,1.);\nfloat localTime=time*0.0001;\n\nmat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));\nmat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));\ndir.xz*=rot1;\ndir.xy*=rot2;\nvec3 from=vec3(1.,.5,0.5);\nfrom+=vec3(-2.,localTime*2.,localTime);\nfrom.xz*=rot1;\nfrom.xy*=rot2;\n\nfloat s=0.1,fade=1.;\nvec3 v=vec3(0.);\nfor (int r=0; r<volsteps; r++) {\nvec3 p=from+s*dir*.5;\np=abs(vec3(tile)-mod(p,vec3(tile*2.)));\nfloat pa,a=pa=0.;\nfor (int i=0; i<iterations; i++) {\np=abs(p)/dot(p,p)-formuparam;\na+=abs(length(p)-pa);\npa=length(p);\n}\nfloat dm=max(0.,darkmatter-a*a*.001);\na*=a*a;\nif (r>6) fade*=1.-dm;\n\nv+=fade;\nv+=vec3(s,s*s,s*s*s*s)*a*brightness*fade;\nfade*=distfading;\ns+=stepsize;\n}\nv=mix(vec3(length(v)),v,saturation);\ngl_FragColor=vec4(v*.01,1.);\n}";o.Effect.ShadersStore.starfieldProceduralTexturePixelShader=i;var a=function(t){function e(e,r,n,o,i){var a=t.call(this,e,r,"starfieldProceduralTexture",n,o,i)||this;return a._time=1,a._alpha=.5,a._beta=.8,a._zoom=.8,a._formuparam=.53,a._stepsize=.1,a._tile=.85,a._brightness=.0015,a._darkmatter=.4,a._distfading=.73,a._saturation=.85,a.updateShaderUniforms(),a}return Object(n.b)(e,t),e.prototype.updateShaderUniforms=function(){this.setFloat("time",this._time),this.setFloat("alpha",this._alpha),this.setFloat("beta",this._beta),this.setFloat("zoom",this._zoom),this.setFloat("formuparam",this._formuparam),this.setFloat("stepsize",this._stepsize),this.setFloat("tile",this._tile),this.setFloat("brightness",this._brightness),this.setFloat("darkmatter",this._darkmatter),this.setFloat("distfading",this._distfading),this.setFloat("saturation",this._saturation)},Object.defineProperty(e.prototype,"time",{get:function(){return this._time},set:function(t){this._time=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"beta",{get:function(){return this._beta},set:function(t){this._beta=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formuparam",{get:function(){return this._formuparam},set:function(t){this._formuparam=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stepsize",{get:function(){return this._stepsize},set:function(t){this._stepsize=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoom",{get:function(){return this._zoom},set:function(t){this._zoom=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tile",{get:function(){return this._tile},set:function(t){this._tile=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"brightness",{get:function(){return this._brightness},set:function(t){this._brightness=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"darkmatter",{get:function(){return this._darkmatter},set:function(t){this._darkmatter=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"distfading",{get:function(){return this._distfading},set:function(t){this._distfading=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"saturation",{get:function(){return this._saturation},set:function(t){this._saturation=t,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),e.prototype.serialize=function(){var e=o.SerializationHelper.Serialize(this,t.prototype.serialize.call(this));return e.customType="BABYLON.StarfieldProceduralTexture",e},e.Parse=function(t,r,n){return o.SerializationHelper.Parse(function(){return new e(t.name,t._size,r,void 0,t._generateMipMaps)},t,r,n)},Object(n.a)([Object(o.serialize)()],e.prototype,"time",null),Object(n.a)([Object(o.serialize)()],e.prototype,"alpha",null),Object(n.a)([Object(o.serialize)()],e.prototype,"beta",null),Object(n.a)([Object(o.serialize)()],e.prototype,"formuparam",null),Object(n.a)([Object(o.serialize)()],e.prototype,"stepsize",null),Object(n.a)([Object(o.serialize)()],e.prototype,"zoom",null),Object(n.a)([Object(o.serialize)()],e.prototype,"tile",null),Object(n.a)([Object(o.serialize)()],e.prototype,"brightness",null),Object(n.a)([Object(o.serialize)()],e.prototype,"darkmatter",null),Object(n.a)([Object(o.serialize)()],e.prototype,"distfading",null),Object(n.a)([Object(o.serialize)()],e.prototype,"saturation",null),e}(o.ProceduralTexture);o._TypeStore.RegisteredTypes["BABYLON.StarfieldProceduralTexture"]=a,r.d(e,"StarfieldProceduralTexture",function(){return a})}})});
|