babylon.shadowOnlyMaterial.min.js 9.2 KB

12345678910111213141516
  1. !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 t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},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 i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(i,r,function(n){return e[n]}.bind(null,r));return i},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=29)}({0:function(n,t){n.exports=e},1:function(e,n,t){"use strict";t.d(n,"b",function(){return r}),t.d(n,"a",function(){return o});
  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 i=function(e,n){return(i=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 r(e,n){function t(){this.constructor=e}i(e,n),e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)}function o(e,n,t,i){var r,o=arguments.length,a=o<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,t):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,n,t,i);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(o<3?r(a):o>3?r(n,t,a):r(n,t))||a);return o>3&&a&&Object.defineProperty(n,t,a),a}},14:function(e,n,t){"use strict";t.r(n);var i=t(1),r=t(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\n\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";r.Effect.ShadersStore.shadowOnlyPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\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#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.shadowOnlyVertexShader=a;var l=function(e){function n(){var n=e.call(this)||this;return n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.POINTSIZE=!1,n.FOG=!1,n.NORMAL=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.INSTANCES=!1,n.rebuild(),n}return Object(i.b)(n,e),n}(r.MaterialDefines),s=function(e){function n(n,t){var i=e.call(this,n,t)||this;return i.shadowColor=r.Color3.Black(),i}return Object(i.b)(n,e),n.prototype.needAlphaBlending=function(){return!0},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(n.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!0,configurable:!0}),n.prototype.isReadyForSubMesh=function(e,n,t){if(this.isFrozen&&n.effect&&n.effect._wasPreviouslyReady)return!0;n._materialDefines||(n._materialDefines=new l);var i=n._materialDefines,o=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===o.getRenderId())return!0;var a=o.getEngine();if(this._activeLight)for(var s=0,f=e.lightSources;s<f.length;s++){var c=f[s];if(c.shadowEnabled){if(this._activeLight===c)break;var u=e.lightSources.indexOf(this._activeLight);-1!==u&&(e.lightSources.splice(u,1),e.lightSources.splice(0,0,this._activeLight));break}}if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,i,!!t),r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),i),i._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,i,!1,1),r.MaterialHelper.PrepareDefinesForAttributes(e,i,!1,!0),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var d=new r.EffectFallbacks;i.FOG&&d.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(i,d,1),i.NUM_BONE_INFLUENCERS>0&&d.addCPUSkinningFallback(0,e);var p=[r.VertexBuffer.PositionKind];i.NORMAL&&p.push(r.VertexBuffer.NormalKind),r.MaterialHelper.PrepareAttributesForBones(p,e,i,d),r.MaterialHelper.PrepareAttributesForInstances(p,i);var h=i.toString(),v=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6"],g=new Array,m=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:v,uniformBuffersNames:m,samplers:g,defines:i,maxSimultaneousLights:1}),n.setEffect(o.getEngine().createEffect("shadowOnly",{attributes:p,uniformsNames:v,uniformBuffersNames:m,samplers:g,defines:h,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},a),i)}return!(!n.effect||!n.effect.isReady())&&(this._renderId=o.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(e,n,t){var i=this.getScene(),o=t._materialDefines;if(o){var a=t.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",i.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(n,this._activeEffect),this._mustRebind(i,a)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,i),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),r.MaterialHelper.BindEyePosition(a,i)),i.lightsEnabled&&r.MaterialHelper.BindLights(i,n,this._activeEffect,o,1),i.fogEnabled&&n.applyFog&&i.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",i.getViewMatrix()),r.MaterialHelper.BindFogParameters(i,n,this._activeEffect),this._afterBind(n,this._activeEffect))}},n.prototype.clone=function(e){var t=this;return r.SerializationHelper.Clone(function(){return new n(e,t.getScene())},this)},n.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.ShadowOnlyMaterial",e},n.prototype.getClassName=function(){return"ShadowOnlyMaterial"},n.Parse=function(e,t,i){return r.SerializationHelper.Parse(function(){return new n(e.name,t)},e,t,i)},n}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.ShadowOnlyMaterial"]=s,t.d(n,"ShadowOnlyMaterial",function(){return s})},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},29:function(e,n,t){"use strict";t.r(n),function(e){var i=t(14);t.d(n,"ShadowOnlyMaterial",function(){return i.ShadowOnlyMaterial});var r=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var o in i)r.BABYLON[o]=i[o]}.call(this,t(2))}})});