12345678910111213141516 |
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-materials"]=n(require("babylonjs")):e.MATERIALS=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var n={};function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=n,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,n){if(1&n&&(e=i(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)i.d(t,r,function(n){return e[n]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="",i(i.s=20)}({0:function(n,i){n.exports=e},1:function(e,n,i){"use strict";i.d(n,"b",function(){return r}),i.d(n,"a",function(){return o});
- /*! *****************************************************************************
- 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 t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var i in n)n.hasOwnProperty(i)&&(e[i]=n[i])})(e,n)};function r(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}function o(e,n,i,t){var r,o=arguments.length,s=o<3?n:null===t?t=Object.getOwnPropertyDescriptor(n,i):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,n,i,t);else for(var f=e.length-1;f>=0;f--)(r=e[f])&&(s=(o<3?r(s):o>3?r(n,i,s):r(n,i))||s);return o>3&&s&&Object.defineProperty(n,i,s),s}},10:function(e,n,i){"use strict";i.r(n);var t=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";r.Effect.ShadersStore.cellPixelShader=o;var s="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.cellVertexShader=s;var f=function(e){function n(){var n=e.call(this)||this;return n.DIFFUSE=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.ALPHATEST=!1,n.POINTSIZE=!1,n.FOG=!1,n.NORMAL=!1,n.UV1=!1,n.UV2=!1,n.VERTEXCOLOR=!1,n.VERTEXALPHA=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.NDOTL=!0,n.CUSTOMUSERLIGHTING=!0,n.CELLBASIC=!0,n.DEPTHPREPASS=!1,n.rebuild(),n}return Object(t.b)(n,e),n}(r.MaterialDefines),a=function(e){function n(n,i){var t=e.call(this,n,i)||this;return t.diffuseColor=new r.Color3(1,1,1),t._computeHighLevel=!1,t._disableLighting=!1,t._maxSimultaneousLights=4,t}return Object(t.b)(n,e),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(e,n,i){if(this.isFrozen&&n.effect&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new f);var t=n._materialDefines,o=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===o.getRenderId())return!0;var s=o.getEngine();if(t._areTexturesDirty&&(t._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;t._needUVs=!0,t.DIFFUSE=!0}if(t.CELLBASIC=!this.computeHighLevel,r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),t),t._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,t,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,s,t,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,t,!0,!0),t.isDirty){t.markAsProcessed(),o.resetCachedMaterial();var a=new r.EffectFallbacks;t.FOG&&a.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(t,a,this.maxSimultaneousLights),t.NUM_BONE_INFLUENCERS>0&&a.addCPUSkinningFallback(0,e);var l=[r.VertexBuffer.PositionKind];t.NORMAL&&l.push(r.VertexBuffer.NormalKind),t.UV1&&l.push(r.VertexBuffer.UVKind),t.UV2&&l.push(r.VertexBuffer.UV2Kind),t.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,t,a),r.MaterialHelper.PrepareAttributesForInstances(l,t);var u=t.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],c=["diffuseSampler"],v=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:v,samplers:c,defines:t,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(o.getEngine().createEffect("cell",{attributes:l,uniformsNames:d,uniformBuffersNames:v,samplers:c,defines:u,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},s),t)}return!(!n.effect||!n.effect.isReady())&&(this._renderId=o.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(e,n,i){var t=this.getScene(),o=i._materialDefines;if(o){var s=i.effect;s&&(this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",t.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(n,this._activeEffect),this._mustRebind(t,s)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,t),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(s,t)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*n.visibility),t.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(t,n,this._activeEffect,o,this._maxSimultaneousLights),t.fogEnabled&&n.applyFog&&t.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",t.getViewMatrix()),r.MaterialHelper.BindFogParameters(t,n,this._activeEffect),this._afterBind(n,this._activeEffect))}},n.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},n.prototype.getActiveTextures=function(){var n=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&n.push(this._diffuseTexture),n},n.prototype.hasTexture=function(n){return!!e.prototype.hasTexture.call(this,n)||this._diffuseTexture===n},n.prototype.dispose=function(n){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,n)},n.prototype.getClassName=function(){return"CellMaterial"},n.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone(function(){return new n(e,i.getScene())},this)},n.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.CellMaterial",e},n.Parse=function(e,i,t){return r.SerializationHelper.Parse(function(){return new n(e.name,i)},e,i,t)},Object(t.a)([Object(r.serializeAsTexture)("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),Object(t.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),Object(t.a)([Object(r.serializeAsColor3)("diffuse")],n.prototype,"diffuseColor",void 0),Object(t.a)([Object(r.serialize)("computeHighLevel")],n.prototype,"_computeHighLevel",void 0),Object(t.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],n.prototype,"computeHighLevel",void 0),Object(t.a)([Object(r.serialize)("disableLighting")],n.prototype,"_disableLighting",void 0),Object(t.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),Object(t.a)([Object(r.serialize)("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),Object(t.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.CellMaterial"]=a,i.d(n,"CellMaterial",function(){return a})},2:function(e,n){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},20:function(e,n,i){"use strict";i.r(n),function(e){var t=i(10);i.d(n,"CellMaterial",function(){return t.CellMaterial});var r=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var o in t)r.BABYLON[o]=t[o]}.call(this,i(2))}})});
|