babylon.cloudProceduralTexture.min.js 5.2 KB

12345678910111213141516
  1. !function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],o):"object"==typeof exports?exports["babylonjs-procedural-textures"]=o(require("babylonjs")):e.PROCEDURALTEXTURES=o(e.BABYLON)}(window,function(e){return function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="",r(r.s=16)}({0:function(o,r){o.exports=e},1:function(e,o,r){"use strict";r.d(o,"b",function(){return n}),r.d(o,"a",function(){return i});
  2. /*! *****************************************************************************
  3. Copyright (c) Microsoft Corporation. All rights reserved.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  5. this file except in compliance with the License. You may obtain a copy of the
  6. License at http://www.apache.org/licenses/LICENSE-2.0
  7. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  9. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10. MERCHANTABLITY OR NON-INFRINGEMENT.
  11. See the Apache Version 2.0 License for specific language governing permissions
  12. and limitations under the License.
  13. ***************************************************************************** */
  14. var t=function(e,o){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])})(e,o)};function n(e,o){function r(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}function i(e,o,r,t){var n,i=arguments.length,u=i<3?o:null===t?t=Object.getOwnPropertyDescriptor(o,r):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,o,r,t);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(u=(i<3?n(u):i>3?n(o,r,u):n(o,r))||u);return i>3&&u&&Object.defineProperty(o,r,u),u}},16:function(e,o,r){"use strict";r.r(o),function(e){var t=r(4);r.d(o,"CloudProceduralTexture",function(){return t.CloudProceduralTexture});var n=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==n)for(var i in t)n.BABYLON[i]=t[i]}.call(this,r(2))},2:function(e,o){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},4:function(e,o,r){"use strict";r.r(o);var t=r(1),n=r(0),i="precision highp float;\nvarying vec2 vUV;\nuniform vec4 skyColor;\nuniform vec4 cloudColor;\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat fbm(vec2 n) {\nfloat total=0.0,amplitude=1.0;\nfor (int i=0; i<4; i++) {\ntotal+=noise(n)*amplitude;\nn+=n;\namplitude*=0.5;\n}\nreturn total;\n}\nvoid main() {\nvec2 p=vUV*12.0;\nvec4 c=mix(skyColor,cloudColor,fbm(p));\ngl_FragColor=c;\n}\n";n.Effect.ShadersStore.cloudProceduralTexturePixelShader=i;var u=function(e){function o(o,r,t,i,u){var c=e.call(this,o,r,"cloudProceduralTexture",t,i,u)||this;return c._skyColor=new n.Color4(.15,.68,1,1),c._cloudColor=new n.Color4(1,1,1,1),c.updateShaderUniforms(),c}return t.b(o,e),o.prototype.updateShaderUniforms=function(){this.setColor4("skyColor",this._skyColor),this.setColor4("cloudColor",this._cloudColor)},Object.defineProperty(o.prototype,"skyColor",{get:function(){return this._skyColor},set:function(e){this._skyColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"cloudColor",{get:function(){return this._cloudColor},set:function(e){this._cloudColor=e,this.updateShaderUniforms()},enumerable:!0,configurable:!0}),o.prototype.serialize=function(){var o=n.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return o.customType="BABYLON.CloudProceduralTexture",o},o.Parse=function(e,r,t){return n.SerializationHelper.Parse(function(){return new o(e.name,e._size,r,void 0,e._generateMipMaps)},e,r,t)},t.a([Object(n.serializeAsColor4)()],o.prototype,"skyColor",null),t.a([Object(n.serializeAsColor4)()],o.prototype,"cloudColor",null),o}(n.ProceduralTexture);n._TypeStore.RegisteredTypes["BABYLON.CloudProceduralTexture"]=u,r.d(o,"CloudProceduralTexture",function(){return u})}})});