| 1 |
- var BABYLON;!(function(e){var n=(function(e){function n(){var n=e.call(this)||this;return n.CLIPPLANE=!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 __extends(n,e),n})(e.MaterialDefines),i=(function(i){function t(t,r){var o=i.call(this,t,r)||this;return o._worldViewProjectionMatrix=e.Matrix.Zero(),o._scaledDiffuse=new e.Color3,o._defines=new n,o._cachedDefines=new n,o._cachedDefines.BonesPerMesh=-1,o}return __extends(t,i),t.prototype.needAlphaBlending=function(){return!0},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype._checkCache=function(e,n,i){return!n||(this._defines.INSTANCES,!1)},t.prototype.isReady=function(n,i){if(this.checkReadyOnlyOnce&&this._wasPreviouslyReady)return!0;var t=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===t.getRenderId()&&this._checkCache(t,n,i))return!0;var r=(t.getEngine(),!1);if(this._defines.reset(),t.clipPlane&&(this._defines.CLIPPLANE=!0),(this.pointsCloud||t.forcePointsCloud)&&(this._defines.POINTSIZE=!0),t.fogEnabled&&n&&n.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),t.lightsEnabled&&(r=e.MaterialHelper.PrepareDefinesForLights(t,n,this._defines,1)),n&&(r&&n.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),n.useBones&&n.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=n.numBoneInfluencers,this._defines.BonesPerMesh=n.skeleton.bones.length+1),i&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),t.resetCachedMaterial();var o=new e.EffectFallbacks;this._defines.FOG&&o.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,o,1),this._defines.NUM_BONE_INFLUENCERS>0&&o.addCPUSkinningFallback(0,n);var a=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&a.push(e.VertexBuffer.NormalKind),e.MaterialHelper.PrepareAttributesForBones(a,n,this._defines,o),e.MaterialHelper.PrepareAttributesForInstances(a,this._defines);var s=this._defines.toString(),l=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","depthValues"],d=[];e.MaterialHelper.PrepareUniformsAndSamplersList(l,d,this._defines,1),this._effect=t.getEngine().createEffect("shadowOnly",a,l,d,s,o,this.onCompiled,this.onError,{maxSimultaneousLights:1})}return!!this._effect.isReady()&&(this._renderId=t.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},t.prototype.bind=function(n,t){var r=this.getScene();this.bindOnlyWorldMatrix(n),this._effect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._effect),r.getCachedMaterial()!==this&&(e.MaterialHelper.BindClipPlane(this._effect,r),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._effect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),r.lightsEnabled&&e.MaterialHelper.BindLights(r,t,this._effect,this._defines,1),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._effect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._effect),i.prototype.bind.call(this,n,t)},t.prototype.clone=function(n){var i=this;return e.SerializationHelper.Clone((function(){return new t(n,i.getScene())}),this)},t.prototype.serialize=function(){var n=e.SerializationHelper.Serialize(this);return n.customType="BABYLON.ShadowOnlyMaterial",n},t.Parse=function(n,i,r){return e.SerializationHelper.Parse((function(){return new t(n.name,i)}),n,i,r)},t})(e.Material);__decorate([e.serialize()],i.prototype,"_worldViewProjectionMatrix",void 0),e.ShadowOnlyMaterial=i})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.shadowOnlyVertexShader="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<shadowsVertexDeclaration>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\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",BABYLON.Effect.ShadersStore.shadowOnlyPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<lightFragmentDeclaration>[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(0.,0.,0.,1.0-clamp(shadow,0.,1.));\n#include<fogFragment>\ngl_FragColor=color;\n}";
|