!function(c,S){S.un,S.uns;var l=S.static,p=S.class,_=S.getset,v=S.__newvec,i=(laya.ani.AnimationContent,laya.ani.AnimationPlayer),r=(laya.ani.AnimationState,laya.ani.AnimationTemplet),f=laya.maths.Arith,o=laya.webgl.atlas.AtlasResourceManager,t=laya.webgl.shader.BaseShader,x=laya.utils.Browser,s=laya.webgl.utils.Buffer,g=laya.utils.Byte,a=(laya.ani.bone.canvasmesh.CacheAbleSkinMesh,laya.utils.ClassUtils),h=S.Config,n=(laya.events.Event,laya.events.EventDispatcher),D=laya.utils.Handler,W=laya.net.Loader,u=laya.net.LoaderManager,O=laya.maths.MathUtil,d=laya.display.Node,m=laya.renders.Render,E=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.webgl.utils.RenderState2D),T=laya.resource.Resource,M=laya.utils.RunDriver,R=(laya.webgl.shader.Shader,laya.webgl.utils.ShaderCompile),e=laya.display.Sprite,I=laya.utils.Stat,A=laya.utils.StringKey,C=(laya.display.css.Style,laya.resource.Texture,laya.net.URL),y=laya.utils.Utils,N=laya.webgl.WebGL,V=laya.webgl.WebGLContext;laya.webgl.canvas.WebGLContext2D;S.interface("laya.d3.core.IClone"),S.interface("laya.d3.graphics.IVertex"),S.interface("laya.d3.core.render.IUpdate"),S.interface("laya.d3.core.scene.ITreeNode"),S.interface("laya.d3.core.render.IRenderable");var L=(p(w,"laya.d3.animation.AnimationClipParser01"),w.READ_DATA=function(){w._DATA.offset=w._reader.getUint32(),w._DATA.size=w._reader.getUint32()},w.READ_BLOCK=function(){for(var e=w._BLOCK.count=w._reader.getUint16(),t=w._BLOCK.blockStarts=[],n=w._BLOCK.blockLengths=[],i=0;ithis._number?t=n-1:e=n+1}return e},e._addCollider=function(e){0===this._colliders.length&&r._collsionTestList.splice(this._binarySearchIndex(),0,this._number),e._isRigidbody?(this._colliders.unshift(e),this._nonRigidbodyOffset++):this._colliders.push(e)},e._removeCollider=function(e){e=this._colliders.indexOf(e);ee.time&&this._bursts.splice(n,0,e);this._bursts.push(e)},t.removeBurst=function(e){e=this._bursts.indexOf(e);-1!==e&&this._bursts.splice(e,1)},t.removeBurstByIndex=function(e){this._bursts.splice(e,1)},t.clearBurst=function(){this._bursts.length=0},t.cloneTo=function(e){var e=e,t=e._bursts;t.length=this._bursts.length;for(var n=0,i=this._bursts.length;nthis._vbData.length||this._posInIBData+2>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e.x,e.y,e.z,t.x,t.y,t.z,t.w),this.addVertex(n.x,n.y,n.z,i.x,i.y,i.z,i.w),this.addIndexes(this._tempUint0,this._tempUint0+1),this},t.circle=function(e,t,n,i,r,a){for(this._hasBegun&&1===this._primitiveType||this.drawLinesException(),this._tempUint0=2*t,(this._posInVBData+this._tempUint0*this._floatSizePerVer>this._vbData.length||this._posInIBData+2*this._tempUint0>this._ibData.length)&&this.flush(),this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=0,this._tempInt0=0;this._tempNumver0<6.2832;this._tempNumver0=this._tempNumver0+3.1416/t,this._tempInt0++)this.addVertex(Math.sin(this._tempNumver0)*e,Math.cos(this._tempNumver0)*e,0,n,i,r,a),0===this._tempInt0?this.addIndexes(this._tempUint1):this._tempInt0===this._tempUint0-1?(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2,this._tempUint1)):(this._tempUint2=this._tempUint1+this._tempInt0,this.addIndexes(this._tempUint2,this._tempUint2));return this},t.plane=function(e,t,n,i,r,a,o,s,l){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+4*this._floatSizePerVer>this._vbData.length||this._posInIBData+6>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n,a,o,s,l),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n,a,o,s,l),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n,a,o,s,l),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n,a,o,s,l),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint0+3),this},t.box=function(e,t,n,i,r,a,o,s,l,h){return this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+8*this._floatSizePerVer>this._vbData.length||this._posInIBData+36>this._ibData.length)&&this.flush(),this._tempNumver0=i/2,this._tempNumver1=r/2,this._tempNumver2=a/2,this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n+this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t+this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e+this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,o,s,l,h),this.addVertex(e-this._tempNumver0,t-this._tempNumver1,n-this._tempNumver2,o,s,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint2,this._tempUint2,this._tempUint1,this._tempUint3,this._tempUint4,this._tempUint5,this._tempUint6,this._tempUint6,this._tempUint5,this._tempUint7,this._tempUint5,this._tempUint0,this._tempUint7,this._tempUint7,this._tempUint0,this._tempUint2,this._tempUint1,this._tempUint4,this._tempUint3,this._tempUint3,this._tempUint4,this._tempUint6,this._tempUint5,this._tempUint4,this._tempUint0,this._tempUint0,this._tempUint4,this._tempUint1,this._tempUint2,this._tempUint3,this._tempUint7,this._tempUint7,this._tempUint3,this._tempUint6),this},t.cone=function(e,t,n,i,r,a,o){for(this._hasBegun&&4===this._primitiveType||this.drawTrianglesException(),(this._posInVBData+(2*n+2)*this._floatSizePerVer>this._vbData.length||this._posInIBData+6*n>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData,this._tempUint1=this._posInVBData/this._floatSizePerVer,this._tempNumver0=2*Math.PI/n,this.addVertexIndex(0,t,0,i,r,a,o,this._tempUint0),this.addVertexIndex(0,0,0,i,r,a,o,this._tempUint0+this._floatSizePerVer),this._tempInt0=2,this._tempNumver1=0,this._tempInt1=0;this._tempInt1this._vbData.length||this._posInIBData+48>this._ibData.length)&&this.flush(),this._tempUint0=this._posInVBData/this._floatSizePerVer,this.addVertex(e,r,a,o,s,l,h),this.addVertex(i,r,a,o,s,l,h),this.addVertex(e,t,a,o,s,l,h),this.addVertex(i,t,a,o,s,l,h),this.addVertex(i,r,n,o,s,l,h),this.addVertex(e,r,n,o,s,l,h),this.addVertex(i,t,n,o,s,l,h),this.addVertex(e,t,n,o,s,l,h),this._tempUint1=this._tempUint0+1,this._tempUint2=this._tempUint0+2,this._tempUint3=this._tempUint0+3,this._tempUint4=this._tempUint0+4,this._tempUint5=this._tempUint0+5,this._tempUint6=this._tempUint0+6,this._tempUint7=this._tempUint0+7,this.addIndexes(this._tempUint0,this._tempUint1,this._tempUint1,this._tempUint3,this._tempUint3,this._tempUint2,this._tempUint2,this._tempUint0,this._tempUint4,this._tempUint5,this._tempUint5,this._tempUint7,this._tempUint7,this._tempUint6,this._tempUint6,this._tempUint4,this._tempUint5,this._tempUint0,this._tempUint0,this._tempUint2,this._tempUint2,this._tempUint7,this._tempUint7,this._tempUint5,this._tempUint1,this._tempUint4,this._tempUint4,this._tempUint6,this._tempUint6,this._tempUint3,this._tempUint3,this._tempUint1,this._tempUint5,this._tempUint4,this._tempUint4,this._tempUint1,this._tempUint1,this._tempUint0,this._tempUint0,this._tempUint5,this._tempUint2,this._tempUint3,this._tempUint3,this._tempUint6,this._tempUint6,this._tempUint7,this._tempUint7,this._tempUint2),this},t.addVertex=function(e,t,n,i,r,a,o){return this._hasBegun||this.addVertexIndexException(),this._vbData[this._posInVBData]=e,this._vbData[this._posInVBData+1]=t,this._vbData[this._posInVBData+2]=n,this._vbData[this._posInVBData+3]=i,this._vbData[this._posInVBData+4]=r,this._vbData[this._posInVBData+5]=a,this._vbData[this._posInVBData+6]=o,this._posInVBData+=this._floatSizePerVer,this},t.addVertexIndex=function(e,t,n,i,r,a,o,s){return this._hasBegun||this.addVertexIndexException(),this._vbData[s]=e,this._vbData[s+1]=t,this._vbData[s+2]=n,this._vbData[s+3]=i,this._vbData[s+4]=r,this._vbData[s+5]=a,this._vbData[s+6]=o,(s+=this._floatSizePerVer)>this._posInVBData&&(this._posInVBData=s),this},t.addIndexes=function(e){var t=arguments;this._hasBegun||this.addVertexIndexException();for(var n=0;n=qt.zeroTolerance?(this._owner._trailTotalLength+=this._delLength,this._owner._trailSupplementLength=0,this._updateVerticesByPosition(e),e.cloneTo(this._lastFixedVertexPosition),this._verticesCount+=2,this._virtualVerticesCount=0,this._everyGroupVertexBirthTime.push(this._owner._curtime),this._verticesCount==this._maxVerticesCount&&this._onTrailRenderElementFinish()):(this._owner._trailSupplementLength=this._delLength,this._updateVerticesByPosition(e),this._virtualVerticesCount=2)},e._updateVerticesByPosition=function(e){this._pointe=e.elements,this._pointAtoBVector3e=this._pointAtoBVector3.elements,this._curtime=this._owner._curtime,this._owner._hasLifeSubTrail&&0==this._isStart&&(this._pointe=this._owner._curSubTrailFinishPosition.elements,this._pointAtoBVector3e=this._owner._curSubTrailFinishDirection.elements,this._curtime=this._owner._curSubTrailFinishCurTime),this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=-this._pointAtoBVector3e[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._curtime,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=1,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointe[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[0],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[1],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._pointAtoBVector3e[2],this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=this._curtime,this._vertices1[this._verticesIndex1+this._everyAddVerticeCount1++]=0,this._VerticesToTailLength[this._verticesCount/2]=this._owner._trailTotalLength+this._owner._trailSupplementLength,0==this._owner._trailSupplementLength?this._everyVertexToPreVertexDistance[this._verticesCount/2]=this._delLength:this._everyVertexToPreVertexDistance[this._verticesCount/2]=this._isStart?this._owner._trailSupplementLength:0},e._updateVertexBuffer2=function(){for(var e=0,t=0,n=0,n=0,i=(this._verticesCount+this._virtualVerticesCount)/2;n=this._owner.time+qt.zeroTolerance&&(this._curDisappearIndex++,this._owner._trailDeadLength+=this._everyVertexToPreVertexDistance[this._curDisappearIndex],this._curDisappearIndex>=(this._verticesCount+this._virtualVerticesCount)/2&&(this._isDead=!0))},e._beforeRender=function(e){return this._camera=e.camera,null!=this._camera&&(this._owner._owner.transform.position.cloneTo(this._curPosition),!this._isDead&&(this._verticesCountBe.maxVertexCount||c._getIndexBuffer().indexCount+m._getIndexBuffer().indexCount>Be.maxIndexCount?(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),r=p,h=i.combineRenderElementsCount,a=d):(i._addCombineMaterial(r),i._addMaterialToRenderElementOffset(h),i._addCombineRenderObj(a),a=r=null,h=-1,i._addCombineRenderObj(d))):i._addCombineRenderObj(d),!0):(r&&(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),a=r=null,h=-1),l++,!1):(m=this._prepareDynamicBatchCombineElements[_-1],i._addMaterialToRenderElementOffset(i.combineRenderElementsCount),t=m._material,i._addCombineMaterial(t),i._addCombineRenderObj(m),s=!0,t!==(p=d._material)?(r=p,h=i.combineRenderElementsCount,a=d):i._addCombineRenderObj(d),t=p)}r&&(e.getRenderQueue(a._material.renderQueue)._addRenderElement(a),a=r=null,h=-1),this._prepareDynamicBatchCombineElements.length=0},e._clearRenderElements=function(){for(var e in this._dynamicBatches)this._dynamicBatches[e]._clearRenderElements()},e._addToRenderQueue=function(e,t,n,i){for(var r in this._dynamicBatches){r=this._dynamicBatches[r];0a.maxVertexDeclaration)throw new Error("VertexDeclaration: VertexDeclaration count should not large than ",a.maxVertexDeclaration);this._shaderValues=new vn,this._vertexElementsDic={},this._vertexStride=e,this._vertexElements=t;for(var n=0;n=e.length)throw new Error("start"+t+"Must be in the range [0, "+(e.length-1)+"]");if(n<0||t+n>e.length)throw new Error("count"+n+"Must be in the range <= "+e.length+"}");var r=t+n,a=_._tempVector3;a.elements[0]=0,a.elements[1]=0,a.elements[2]=0;for(var o=t;ot[0]||e[0]>i[0])&&(!(n[1]>t[1]||e[1]>i[1])&&!(n[2]>t[2]||e[2]>i[2]))},jt.intersectsBoxAndSphere=function(e,t){var n=t.center,t=t.radius;return hn.Clamp(n,e.min,e.max,jt._tempV30),hn.distanceSquared(n,jt._tempV30)<=t*t},jt.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return hn.distanceSquared(e.center,t.center)<=n*n},jt.boxContainsPoint=function(e,t){var n=e.min.elements,e=e.max.elements,t=t.elements;return n[0]<=t[0]&&e[0]>=t[0]&&n[1]<=t[1]&&e[1]>=t[1]&&n[2]<=t[2]&&e[2]>=t[2]?1:0},jt.boxContainsBox=function(e,t){var n=e.min.elements,i=n[0],r=n[1],a=n[2],o=e.max.elements,s=o[0],l=o[1],h=o[2],_=t.min.elements,u=_[0],n=_[1],e=_[2],o=t.max.elements,_=o[0],t=o[1],o=o[2];return si||hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:hn.scalarLengthSquared(jt._tempV30)>i?2:1},jt.sphereContainsSphere=function(e,t){var n=e.radius,i=t.radius,t=hn.distance(e.center,t.center);return n+iqt.zeroTolerance?(t[2]=Math.atan2(this.elements[1],this.elements[5]),t[0]=Math.atan2(this.elements[8],this.elements[10])):(t[2]=Math.atan2(-this.elements[4],this.elements[0]),t[0]=0)},e.normalize=function(){var e=this.elements,t=e[0],n=e[1],i=e[2],r=Math.sqrt(t*t+n*n+i*i);if(!r)return e[0]=0,e[1]=0,void(e[2]=0);1!=r&&(e[0]=t*(r=1/r),e[1]=n*r,e[2]=i*r)},e.transpose=function(){var e=this.elements,t=e[1];return e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},e.invert=function(e){var t=this.elements,n=e.elements,i=t[0],r=t[1],a=t[2],o=t[3],s=t[4],l=t[5],h=t[6],_=t[7],u=t[8],d=t[9],c=t[10],f=t[11],m=t[12],p=t[13],E=t[14],v=t[15],g=i*l-r*s,T=i*h-a*s,S=i*_-o*s,D=r*h-a*l,x=r*_-o*l,M=a*_-o*h,R=u*p-d*m,I=u*E-c*m,A=u*v-f*m,C=d*E-c*p,y=d*v-f*p,e=c*v-f*E,t=g*e-T*y+S*C+D*A-x*I+M*R;0!==Math.abs(t)&&(n[0]=(l*e-h*y+_*C)*(t=1/t),n[1]=(a*y-r*e-o*C)*t,n[2]=(p*M-E*x+v*D)*t,n[3]=(c*x-d*M-f*D)*t,n[4]=(h*A-s*e-_*I)*t,n[5]=(i*e-a*A+o*I)*t,n[6]=(E*S-m*M-v*T)*t,n[7]=(u*M-c*S+f*T)*t,n[8]=(s*y-l*A+_*R)*t,n[9]=(r*A-i*y-o*R)*t,n[10]=(m*x-p*S+v*g)*t,n[11]=(d*S-u*x-f*g)*t,n[12]=(l*I-s*C-h*R)*t,n[13]=(i*C-r*I+a*R)*t,n[14]=(p*T-m*D-E*g)*t,n[15]=(u*D-d*T+c*g)*t)},e.identity=function(){var e=this.elements;e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0,e[0]=e[5]=e[10]=e[15]=1},e.cloneTo=function(e){var t,n=this.elements,i=e.elements;if(n!==i)for(t=0;t<16;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.getTranslationVector=function(e){var t=this.elements,e=e.elements;e[0]=t[12],e[1]=t[13],e[2]=t[14]},e.setTranslationVector=function(e){var t=this.elements,e=e.elements;t[12]=e[0],t[13]=e[1],t[14]=e[2]},e.getForward=function(e){var t=this.elements,e=e.elements;e[0]=-t[8],e[1]=-t[9],e[2]=-t[10]},e.setForward=function(e){var t=this.elements,e=e.elements;t[8]=-e[0],t[9]=-e[1],t[10]=-e[2]},E.createRotationX=function(e,t){var n=t.elements,t=Math.sin(e),e=Math.cos(e);n[1]=n[2]=n[3]=n[4]=n[7]=n[8]=n[11]=n[12]=n[13]=n[14]=0,n[0]=n[15]=1,n[5]=n[10]=e,n[6]=t,n[9]=-t},E.createRotationY=function(e,t){var n=t.elements,t=Math.sin(e),e=Math.cos(e);n[1]=n[3]=n[4]=n[6]=n[7]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[5]=n[15]=1,n[0]=n[10]=e,n[2]=-t,n[8]=t},E.createRotationZ=function(e,t){var n=t.elements,t=Math.sin(e),e=Math.cos(e);n[2]=n[3]=n[6]=n[7]=n[8]=n[9]=n[11]=n[12]=n[13]=n[14]=0,n[10]=n[15]=1,n[0]=n[5]=e,n[1]=t,n[4]=-t},E.createRotationYawPitchRoll=function(e,t,n,i){rn.createFromYawPitchRoll(e,t,n,E._tempQuaternion),E.createRotationQuaternion(E._tempQuaternion,i)},E.createRotationAxis=function(e,t,n){var i=e.elements,r=i[0],a=i[1],o=i[2],s=Math.cos(t),l=Math.sin(t),h=r*r,_=a*a,u=o*o,e=r*a,i=r*o,t=a*o,n=n.elements;n[3]=n[7]=n[11]=n[12]=n[13]=n[14]=0,n[15]=1,n[0]=h+s*(1-h),n[1]=e-s*e+l*o,n[2]=i-s*i-l*a,n[4]=e-s*e-l*o,n[5]=_+s*(1-_),n[6]=t-s*t+l*r,n[8]=i-s*i+l*a,n[9]=t-s*t-l*r,n[10]=u+s*(1-u)},E.createRotationQuaternion=function(e,t){var n=e.elements,i=t.elements,r=n[0],a=n[1],o=n[2],s=n[3],l=r*r,h=a*a,_=o*o,u=r*a,e=o*s,t=o*r,n=a*s,o=a*o,s=r*s;i[3]=i[7]=i[11]=i[12]=i[13]=i[14]=0,i[15]=1,i[0]=1-2*(h+_),i[1]=2*(u+e),i[2]=2*(t-n),i[4]=2*(u-e),i[5]=1-2*(_+l),i[6]=2*(o+s),i[8]=2*(t+n),i[9]=2*(o-s),i[10]=1-2*(h+l)},E.createTranslate=function(e,t){e=e.elements,t=t.elements;t[4]=t[8]=t[1]=t[9]=t[2]=t[6]=t[3]=t[7]=t[11]=0,t[0]=t[5]=t[10]=t[15]=1,t[12]=e[0],t[13]=e[1],t[14]=e[2]},E.createScaling=function(e,t){e=e.elements,t=t.elements;t[0]=e[0],t[5]=e[1],t[10]=e[2],t[1]=t[4]=t[8]=t[12]=t[9]=t[13]=t[2]=t[6]=t[14]=t[3]=t[7]=t[11]=0,t[15]=1},E.multiply=function(e,t,n){var i,r,a,o,s,l=n.elements,h=e.elements,_=t.elements;if(l===_)for(_=new Float32Array(16),i=0;i<16;++i)_[i]=l[i];for(i=0;i<4;i++)r=h[i],a=h[i+4],o=h[i+8],s=h[i+12],l[i]=r*_[0]+a*_[1]+o*_[2]+s*_[3],l[i+4]=r*_[4]+a*_[5]+o*_[6]+s*_[7],l[i+8]=r*_[8]+a*_[9]+o*_[10]+s*_[11],l[i+12]=r*_[12]+a*_[13]+o*_[14]+s*_[15]},E.createFromQuaternion=function(e,t){var n=t.elements,i=e.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=r+r,h=a+a,_=o+o,t=r*l,e=a*l,i=a*h,r=o*l,a=o*h,o=o*_,l=s*l,h=s*h,_=s*_;n[0]=1-i-o,n[1]=e+_,n[2]=r-h,n[3]=0,n[4]=e-_,n[5]=1-t-o,n[6]=a+l,n[7]=0,n[8]=r+h,n[9]=a-l,n[10]=1-t-i,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},E.createAffineTransformation=function(e,t,n,i){var r=e.elements,a=t.elements,o=n.elements,s=i.elements,l=a[0],h=a[1],_=a[2],u=a[3],d=l+l,c=h+h,e=_+_,t=l*d,n=l*c,i=l*e,a=h*c,l=h*e,h=_*e,_=u*d,d=u*c,c=u*e,u=o[0],e=o[1],o=o[2];s[0]=(1-(a+h))*u,s[1]=(n+c)*u,s[2]=(i-d)*u,s[3]=0,s[4]=(n-c)*e,s[5]=(1-(t+h))*e,s[6]=(l+_)*e,s[7]=0,s[8]=(i+d)*o,s[9]=(l-_)*o,s[10]=(1-(t+a))*o,s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1},E.createLookAt=function(e,t,n,i){var r=i.elements,a=E._tempVector0,o=E._tempVector1,s=E._tempVector2;hn.subtract(e,t,s),hn.normalize(s,s),hn.cross(n,s,a),hn.normalize(a,a),hn.cross(s,a,o),i.identity(),r[0]=a.x,r[4]=a.y,r[8]=a.z,r[1]=o.x,r[5]=o.y,r[9]=o.z,r[2]=s.x,r[6]=s.y,r[10]=s.z,r[12]=-hn.dot(a,e),r[13]=-hn.dot(o,e),r[14]=-hn.dot(s,e)},E.createPerspective=function(e,t,n,i,r){var a=r.elements,r=1/Math.tan(e/2),e=1/(n-i);a[0]=r/t,a[5]=r,a[10]=(i+n)*e,a[11]=-1,a[14]=2*i*n*e,a[1]=a[2]=a[3]=a[4]=a[6]=a[7]=a[8]=a[9]=a[12]=a[13]=a[15]=0},E.createOrthoOffCenterRH=function(e,t,n,i,r,a,o){var s=o.elements,l=1/(e-t),h=1/(n-i),o=1/(r-a);s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=0,s[15]=1,s[0]=-2*l,s[5]=-2*h,s[10]=2*o,s[12]=(e+t)*l,s[13]=(i+n)*h,s[14]=(a+r)*o},E.translation=function(e,t){e=e.elements,t=t.elements;t[0]=t[5]=t[10]=t[15]=1,t[12]=e[0],t[13]=e[1],t[14]=e[2]},l(E,["_tempMatrix4x4",function(){return this._tempMatrix4x4=new E},"_tempVector0",function(){return this._tempVector0=new hn},"_tempVector1",function(){return this._tempVector1=new hn},"_tempVector2",function(){return this._tempVector2=new hn},"_tempQuaternion",function(){return this._tempQuaternion=new rn},"DEFAULT",function(){return this.DEFAULT=new E},"ZERO",function(){return this.ZERO=new E(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}]),E}(),en=function(){function f(e,t){this.extents=null,this.transformation=null,this.extents=e,this.transformation=t}p(f,"laya.d3.math.OrientedBoundBox");var e=f.prototype;return e.getCorners=function(e){var t=f._tempV30.elements,n=f._tempV31.elements,i=f._tempV32.elements,r=this.extents.elements;t[0]=r[0],t[1]=t[2]=0,n[1]=r[1],n[0]=n[2]=0,i[2]=r[2],i[0]=i[1]=0,hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV32,this.transformation,f._tempV32);i=f._tempV33;this.transformation.getTranslationVector(i),e.length=8,hn.add(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[0]),hn.add(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[1]),hn.subtract(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[2]),hn.subtract(i,f._tempV30,f._tempV34),hn.add(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[3]),hn.add(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[4]),hn.add(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[5]),hn.subtract(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.subtract(f._tempV34,f._tempV32,e[6]),hn.subtract(i,f._tempV30,f._tempV34),hn.subtract(f._tempV34,f._tempV31,f._tempV34),hn.add(f._tempV34,f._tempV32,e[7])},e.transform=function(e){Jt.multiply(this.transformation,e,this.transformation)},e.scale=function(e){hn.multiply(this.extents,e,this.extents)},e.translate=function(e){this.transformation.getTranslationVector(f._tempV30),hn.add(f._tempV30,e,f._tempV31),this.transformation.setTranslationVector(f._tempV31)},e.Size=function(e){hn.scale(this.extents,2,e)},e.getSize=function(e){var t=this.extents.elements;f._tempV30.x=t[0],f._tempV31.y=t[1],f._tempV32.z=t[2],hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV31,this.transformation,f._tempV32);e=e.elements;e[0]=hn.scalarLength(f._tempV30),e[1]=hn.scalarLength(f._tempV31),e[2]=hn.scalarLength(f._tempV32)},e.getSizeSquared=function(e){var t=this.extents.elements;f._tempV30.x=t[0],f._tempV31.y=t[1],f._tempV32.z=t[2],hn.TransformNormal(f._tempV30,this.transformation,f._tempV30),hn.TransformNormal(f._tempV31,this.transformation,f._tempV31),hn.TransformNormal(f._tempV31,this.transformation,f._tempV32);e=e.elements;e[0]=hn.scalarLengthSquared(f._tempV30),e[1]=hn.scalarLengthSquared(f._tempV31),e[2]=hn.scalarLengthSquared(f._tempV32)},e.getCenter=function(e){this.transformation.getTranslationVector(e)},e.containsPoint=function(e){var t=this.extents.elements,n=t[0],i=t[1],r=t[2];this.transformation.invert(f._tempM0),hn.transformCoordinate(e,f._tempM0,f._tempV30);var a=f._tempV30.elements,t=Math.abs(a[0]),e=Math.abs(a[1]),a=Math.abs(a[2]);return qt.nearEqual(t,n)&&qt.nearEqual(e,i)&&qt.nearEqual(a,r)?2:tr+n||Math.abs(s)>a+i||Math.abs(t)>o+e||Math.abs(s*_-t*h)>a*e+o*i||Math.abs(u*_-t*l)>r*e+o*n||Math.abs(u*h-s*l)>r*i+a*n?0:2},e.containsBoundBox=function(e){var t=0,n=0,i=e.min,r=e.max;e.getCorners(f._corners);e=this.containsPoints(f._corners);if(0!=e)return e;hn.subtract(r,i,f._tempV30),hn.scale(f._tempV30,.5,f._tempV30),hn.add(i,f._tempV30,f._tempV30),hn.subtract(r,f._tempV30,f._tempV31);var a=this.extents.elements,o=f._tempV31.elements;f._getRows(this.transformation,f._rows1),this.transformation.invert(f._tempM0);for(t=0;t<3;t++)for(n=0;n<3;n++)f._tempM1.setElementByRowColumn(t,n,Math.abs(f._tempM0.getElementByRowColumn(t,n)));this.getCenter(f._tempV35),hn.subtract(f._tempV30,f._tempV35,f._tempV32);var s=f._tempV31.elements;s[0]=hn.dot(f._tempV32,f._rows1[0]),s[1]=hn.dot(f._tempV32,f._rows1[1]),s[2]=hn.dot(f._tempV32,f._rows1[2]);var l=f._tempV33.elements,h=f._tempV34.elements;for(t=0;t<3;t++)if(l[0]=f._tempM1.getElementByRowColumn(t,0),l[1]=f._tempM1.getElementByRowColumn(t,1),l[2]=f._tempM1.getElementByRowColumn(t,2),a[t]+hn.dot(f._tempV31,f._tempV33)=Math.PI&&n[2]>=Math.PI&&(n[1]=0,n[2]=0,n[0]=Math.PI-n[0]);e=e.elements;e[0]=n[1],e[1]=n[0],e[2]=n[2]},e.invert=function(e){var t=e.elements,n=this.elements,i=n[0],r=n[1],a=n[2],e=n[3],n=i*i+r*r+a*a+e*e,n=n?1/n:0;t[0]=-i*n,t[1]=-r*n,t[2]=-a*n,t[3]=e*n},e.identity=function(){var e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=1},e.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2],this.elements[3]=e[t+3]},e.cloneTo=function(e){var t,n=this.elements,i=e.elements;if(n!==i)for(t=0;t<4;++t)i[t]=n[t]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.equals=function(e){var t=this.elements,e=e.elements;return qt.nearEqual(t[0],e[0])&&qt.nearEqual(t[1],e[1])&&qt.nearEqual(t[2],e[2])&&qt.nearEqual(t[3],e[3])},e.lengthSquared=function(){var e=this.elements[0],t=this.elements[1],n=this.elements[2],i=this.elements[3];return e*e+t*t+n*n+i*i},_(0,e,"x",function(){return this.elements[0]}),_(0,e,"y",function(){return this.elements[1]}),_(0,e,"z",function(){return this.elements[2]}),_(0,e,"w",function(){return this.elements[3]}),r.createFromYawPitchRoll=function(e,t,n,i){var r=.5*n,a=.5*t,o=.5*e,n=Math.sin(r),t=Math.cos(r),e=Math.sin(a),r=Math.cos(a),a=Math.sin(o),o=Math.cos(o),i=i.elements;i[0]=o*e*t+a*r*n,i[1]=a*r*t-o*e*n,i[2]=o*r*n-a*e*t,i[3]=o*r*t+a*e*n},r.multiply=function(e,t,n){var i=e.elements,r=t.elements,a=n.elements,o=i[0],s=i[1],l=i[2],h=i[3],_=r[0],u=r[1],e=r[2],t=r[3],n=l*_-o*e,i=o*u-s*_,r=o*_+s*u+l*e;a[0]=o*t+_*h+(s*e-l*u),a[1]=s*t+u*h+n,a[2]=l*t+e*h+i,a[3]=h*t-r},r.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:0r[t=0]&&(t=1),e=((t=r[8]>r[3*t+t]?2:t)+1)%3,a=(t+2)%3,n=Math.sqrt(r[3*t+t]-r[3*e+e]-r[3*a+a]+1),i[t]=.5*n,i[3]=(r[3*e+a]-r[3*a+e])*(n=.5/n),i[e]=(r[3*e+t]+r[3*t+e])*n,i[a]=(r[3*a+t]+r[3*t+a])*n)},r.createFromMatrix4x4=function(e,t){var n,i,r=e.elements,e=t.elements,t=r[0]+r[5]+r[10];0=r[5]&&r[0]>=r[10]?(i=.5/(n=Math.sqrt(1+r[0]-r[5]-r[10])),e[0]=.5*n,e[1]=(r[1]+r[4])*i,e[2]=(r[2]+r[8])*i,e[3]=(r[6]-r[9])*i):r[5]>r[10]?(n=Math.sqrt(1+r[5]-r[0]-r[10]),e[0]=(r[4]+r[1])*(i=.5/n),e[1]=.5*n,e[2]=(r[9]+r[6])*i,e[3]=(r[8]-r[2])*i):(n=Math.sqrt(1+r[10]-r[0]-r[5]),e[0]=(r[8]+r[2])*(i=.5/n),e[1]=(r[9]+r[6])*i,e[2]=.5*n,e[3]=(r[1]-r[4])*i)},r.slerp=function(e,t,n,i){var r,a=e.elements,o=t.elements,s=i.elements,l=a[0],h=a[1],_=a[2],u=a[3],d=o[0],e=o[1],t=o[2],i=o[3],a=l*d+h*e+_*t+u*i;return a<0&&(a=-a,d=-d,e=-e,t=-t,i=-i),n=1e-6<1-a?(o=Math.acos(a),a=Math.sin(o),r=Math.sin((1-n)*o)/a,Math.sin(n*o)/a):(r=1-n,n),s[0]=r*l+n*d,s[1]=r*h+n*e,s[2]=r*_+n*t,s[3]=r*u+n*i,s},r.lerp=function(e,t,n,i){var r=i.elements,a=e.elements,o=t.elements,i=a[0],e=a[1],t=a[2],a=a[3];r[0]=i+n*(o[0]-i),r[1]=e+n*(o[1]-e),r[2]=t+n*(o[2]-t),r[3]=a+n*(o[3]-a)},r.add=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n[3]=e[3]+t[3]},r.dot=function(e,t){e=e.elements,t=t.elements;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},r.rotationLookAt=function(e,t,n){r.lookAt(hn.ZERO,e,t,n)},r.lookAt=function(e,t,n,i){$t.lookAt(e,t,n,r._tempMatrix3x3),r.rotationMatrix(r._tempMatrix3x3,i)},r.invert=function(e,t){var n=e.elements,t=t.elements,e=e.lengthSquared();qt.isZero(e)||(t[0]=-n[0]*(e=1/e),t[1]=-n[1]*e,t[2]=-n[2]*e,t[3]=n[3]*e)},r.rotationMatrix=function(e,t){var n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],h=n[6],_=n[7],u=n[8],d=t.elements,e=NaN,n=NaN,t=i+s+u;0>>19^(this._temp[0]^this._temp[0]>>>8),this.seeds[3]},t.getFloat=function(){return this.getUint(),(8388607&this.seeds[3])*(1/8388607)},t.getSignedFloat=function(){return 2*this.getFloat()-1},_(0,t,"seed",function(){return this.seeds[0]},function(e){this.seeds[0]=e,this.seeds[1]=1812433253*this.seeds[0]+1,this.seeds[2]=1812433253*this.seeds[1]+1,this.seeds[3]=1812433253*this.seeds[2]+1}),e.getFloatFromInt=function(e){return 1/8388607*(8388607&e)},e.getByteFromInt=function(e){return(8388607&e)>>>15},e}(),on=(function(){function n(e){if(this._state0U=NaN,this._state0L=NaN,this._state1U=NaN,this._state1L=NaN,!(e instanceof Array)||4!==e.length)throw new Error("Rand:Seed must be an array with 4 numbers");this._state0U=0|e[0],this._state0L=0|e[1],this._state1U=0|e[2],this._state1L=0|e[3]}p(n,"laya.d3.math.RandX");var e=n.prototype;e.randomint=function(){var e=this._state0U,t=this._state0L,n=this._state1U,i=this._state1L,r=(i>>>0)+(t>>>0),a=n+e+(r/2>>>31)>>>0,o=r>>>0,s=0,r=0;s=(e^=s=e<<23|(-512&t)>>>9)^(this._state0U=n),r=(t^=r=t<<23)^(this._state0L=i);s^=e>>>18,r^=t>>>18|(262143&e)<<14;return r^=i>>>5|(31&n)<<27,this._state1U=s^=n>>>5,this._state1L=r,[a,o]},e.random=function(){var e=this.randomint(),t=e[0],e=0|(e[1]>>>12|(4095&t)<<20);return n._CONVERTION_BUFFER.setUint32(0,1023<<20|t>>>12,!1),n._CONVERTION_BUFFER.setUint32(4,e,!1),an._CONVERTION_BUFFER.getFloat64(0,!1)-1},l(n,["_CONVERTION_BUFFER",function(){return this._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8))},"defaultRand",function(){return this.defaultRand=new an([0,Date.now()/65536,0,Date.now()%65536])}])}(),p(sn,"laya.d3.math.Ray"),sn);function sn(e,t){this.origin=null,this.direction=null,this.origin=e,this.direction=t}var ln=function(){function e(e,t){this.elements=new Float32Array(2),void 0===t&&(t=0);var n=this.elements;n[0]=e=void 0===e?0:e,n[1]=t}p(e,"laya.d3.math.Vector2");var t=e.prototype;return S.imps(t,{"laya.d3.core.IClone":!0}),t.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1]},t.cloneTo=function(e){var t=e.elements,e=this.elements;t[0]=e[0],t[1]=e[1]},t.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},_(0,t,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),_(0,t,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),e.scale=function(e,t,n){n=n.elements,e=e.elements;n[0]=e[0]*t,n[1]=e[1]*t},l(e,["ZERO",function(){return this.ZERO=new e(0,0)},"ONE",function(){return this.ONE=new e(1,1)}]),e}(),hn=function(){function o(e,t,n){this.elements=new Float32Array(3),void 0===t&&(t=0),void 0===n&&(n=0);var i=this.elements;i[0]=e=void 0===e?0:e,i[1]=t,i[2]=n}p(o,"laya.d3.math.Vector3");var e=o.prototype;return S.imps(e,{"laya.d3.core.IClone":!0}),e.fromArray=function(e,t){this.elements[0]=e[(t=void 0===t?0:t)+0],this.elements[1]=e[t+1],this.elements[2]=e[t+2]},e.cloneTo=function(e){var t=e.elements,e=this.elements;t[0]=e[0],t[1]=e[1],t[2]=e[2]},e.clone=function(){var e=new this.constructor;return this.cloneTo(e),e},e.toDefault=function(){this.elements[0]=0,this.elements[1]=0,this.elements[2]=0},_(0,e,"x",function(){return this.elements[0]},function(e){this.elements[0]=e}),_(0,e,"y",function(){return this.elements[1]},function(e){this.elements[1]=e}),_(0,e,"z",function(){return this.elements[2]},function(e){this.elements[2]=e}),o.distanceSquared=function(e,t){var n=e.elements,i=t.elements,e=n[0]-i[0],t=n[1]-i[1],i=n[2]-i[2];return e*e+t*t+i*i},o.distance=function(e,t){var n=e.elements,i=t.elements,e=n[0]-i[0],t=n[1]-i[1],i=n[2]-i[2];return Math.sqrt(e*e+t*t+i*i)},o.min=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2])},o.max=function(e,t,n){n=n.elements,e=e.elements,t=t.elements;n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2])},o.transformQuat=function(e,t,n){var i=n.elements,r=e.elements,a=t.elements,o=r[0],s=r[1],l=r[2],h=a[0],_=a[1],n=a[2],e=a[3],t=e*o+_*l-n*s,r=e*s+n*o-h*l,a=e*l+h*s-_*o,l=-h*o-_*s-n*l;i[0]=t*e+l*-h+r*-n-a*-_,i[1]=r*e+l*-_+a*-h-t*-n,i[2]=a*e+l*-n+t*-_-r*-h},o.scalarLength=function(e){var t=e.elements,n=t[0],e=t[1],t=t[2];return Math.sqrt(n*n+e*e+t*t)},o.scalarLengthSquared=function(e){var t=e.elements,n=t[0],e=t[1],t=t[2];return n*n+e*e+t*t},o.normalize=function(e,t){var n=e.elements,i=t.elements,r=n[0],e=n[1],t=n[2],t=r*r+e*e+t*t;00.0)\n\t{\n\t vec3 v = reflect(-lightVec, normal);\n\t float specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t \n\t dif = diffuseFactor * matDif * dirLight.Diffuse;\n\t spec = specFactor * matSpe.rgb;\n\t}\n\t\n}\n\nvoid computePointLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in PointLight poiLight,in vec3 ambinentColor, in vec3 pos,in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n\tdif=vec3(0.0);\n\tamb=vec3(0.0);\n\tspec=vec3(0.0);\n\tvec3 lightVec = poiLight.Position - pos;\n\t\t\n\tfloat d = length(lightVec);\n\t\n\tif( d > poiLight.Range )\n\t\treturn;\n\t\t\n\tlightVec /= d; \n\t\n\tamb = matAmb*ambinentColor;\t\n\n\tfloat diffuseFactor = dot(lightVec, normal);\n\n\tif( diffuseFactor > 0.0 )\n\t{\n\t\tvec3 v= reflect(-lightVec, normal);\n\t\tfloat specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t\t\t\t\t\n\t\tdif = diffuseFactor * matDif * poiLight.Diffuse;\n\t\tspec = specFactor * matSpe.rgb;\n\t}\n\n\tfloat attenuate = 1.0 / dot(poiLight.Attenuation, vec3(1.0, d, d*d));\n\n\tdif *= attenuate;\n\tspec*= attenuate;\n}\n\nvoid ComputeSpotLight(in vec3 matDif,in vec3 matAmb,in vec4 matSpe,in SpotLight spoLight,in vec3 ambinentColor,in vec3 pos, in vec3 normal,in vec3 toEye,out vec3 dif,out vec3 amb,out vec3 spec)\n{\n\tamb = vec3(0.0);\n\tdif =vec3(0.0);\n\tspec= vec3(0.0);\n\tvec3 lightVec = spoLight.Position - pos;\n\t\t\n\tfloat d = length(lightVec);\n\t\n\tif( d > spoLight.Range)\n\t\treturn;\n\t\t\n\tlightVec /= d; \n\t\n\tamb = matAmb*ambinentColor;\t\n\n\tfloat diffuseFactor = dot(lightVec, normal);\n\n\tif(diffuseFactor > 0.0)\n\t{\n\t\tvec3 v= reflect(-lightVec, normal);\n\t\tfloat specFactor = pow(max(dot(v, toEye), 0.0), matSpe.w);\n\t\t\t\t\t\n\t\tdif = diffuseFactor * matDif * spoLight.Diffuse;\n\t\tspec = specFactor * matSpe.rgb;\n\t}\n\t\n\tfloat spot = pow(max(dot(-lightVec, normalize(spoLight.Direction)), 0.0), spoLight.Spot);\n\n\tfloat attenuate = spot/dot(spoLight.Attenuation, vec3(1.0, d, d*d));\n\n\tamb *= spot;\n\tdif *= attenuate;\n\tspec*= attenuate;\n}\n\n"),Vi.addInclude("Lighting.glsl","\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nstruct PointLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tfloat Range;\n};\n\nstruct SpotLight\n{\n\tvec3 Color;\n\tvec3 Position;\n\tvec3 Direction;\n\tfloat Spot;\n\tfloat Range;\n};\n\n// U3D中使用衰减纹理,此函数模拟并非正确\n//float U3DAttenuation(in vec3 L,in float invLightRadius)\n//{\n//\tfloat fRatio = clamp(length(L) * invLightRadius,0.0,1.0);\n//\tfRatio *= fRatio;\n//\treturn 1.0 / (1.0 + 25.0 * fRatio)* clamp(4.0*(1.0 - fRatio),0.0,1.0); //fade to black as if 4 pixel texture\n//} \n\n// Same as Just Cause 2 and Crysis 2 (you can read GPU Pro 1 book for more information)\nfloat BasicAttenuation(in vec3 L,in float invLightRadius)\n{\n\tvec3 distance = L * invLightRadius;\n\tfloat attenuation = clamp(1.0 - dot(distance, distance),0.0,1.0); // Equals float attenuation = saturate(1.0f - dot(L, L) / (lightRadius * lightRadius)); \t\n\treturn attenuation * attenuation;\n} \n\n// Inspired on http://fools.slindev.com/viewtopic.php?f=11&t=21&view=unread#unread\t\nfloat NaturalAttenuation(in vec3 L,in float invLightRadius)\n{\n\tfloat attenuationFactor = 30.0;\n\tvec3 distance = L * invLightRadius;\n\tfloat attenuation = dot(distance, distance); // Equals float attenuation = dot(L, L) / (lightRadius * lightRadius);\n\tattenuation = 1.0 / (attenuation * attenuationFactor + 1.0);\n\t// Second we move down the function therewith it reaches zero at abscissa 1:\n\tattenuationFactor = 1.0 / (attenuationFactor + 1.0); //attenuationFactor contains now the value we have to subtract\n\tattenuation = max(attenuation - attenuationFactor, 0.0); // The max fixes a bug.\n\t// Finally we expand the equation along the y-axis so that it starts with a function value of 1 again.\n\tattenuation /= 1.0 - attenuationFactor;\n\treturn attenuation;\n} \n\nvoid LayaAirBlinnPhongLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir,in vec3 lightColor, in vec3 lightVec,out vec3 diffuseColor,out vec3 specularColor)\n{\n mediump vec3 h = normalize(viewDir-lightVec);\n lowp float ln = max (0.0, dot (-lightVec,normal));\n float nh = max (0.0, dot (h,normal));\n\tdiffuseColor=lightColor * ln;\n\tspecularColor=lightColor *specColor*pow (nh, specColorIntensity*128.0) * gloss;\n}\n\nvoid LayaAirBlinnPhongDiectionLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec=normalize(light.Direction);\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec,diffuseColor,specularColor);\n}\n\nvoid LayaAirBlinnPhongPointLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in PointLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec = pos-light.Position;\n\t//if( length(lightVec) > light.Range )\n\t//\treturn;\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec/length(lightVec),diffuseColor,specularColor);\n\tfloat attenuate = BasicAttenuation(lightVec, 1.0/light.Range);\n\tdiffuseColor *= attenuate;\n\tspecularColor*= attenuate;\n}\n\nvoid LayaAirBlinnPhongSpotLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in SpotLight light,out vec3 diffuseColor,out vec3 specularColor)\n{\n\tvec3 lightVec = pos-light.Position;\n\t//if( length(lightVec) > light.Range )\n\t//\treturn;\n\tvec3 normalLightVec=lightVec/length(lightVec);\n\tLayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,normalLightVec,diffuseColor,specularColor);\n\tfloat spot = pow(max(dot(normalLightVec, normalize(light.Direction)), 0.0), light.Spot);\n\tfloat attenuate = spot*BasicAttenuation(lightVec, 1.0/light.Range);\n\tdiffuseColor *= attenuate;\n\tspecularColor*= attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal)\n{\n\tvec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\n\t\n\t// Build orthonormal basis.\n\tvec3 N = normalize(unitNormal);\n\tvec3 T = normalize(tangent);\n\tvec3 B = normalize(binormal);\n\tmat3 TBN = mat3(T, B, N);\n\t\n\t// Transform from tangent space to world space.\n\tvec3 bumpedNormal = TBN*normalT;\n\n\treturn bumpedNormal;\n}\n\n\n"),Vi.addInclude("ShadowHelper.glsl","uniform sampler2D u_shadowMap1;\nuniform sampler2D u_shadowMap2;\nuniform sampler2D u_shadowMap3;\nuniform vec2\t u_shadowPCFoffset;\nuniform vec3 u_shadowPSSMDistance;\nvec4 packDepth(const in float depth)\n{\n\tconst vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n\tconst vec4 bitMask\t= vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n\tvec4 res = mod(depth*bitShift*vec4(255), vec4(256))/vec4(255);\n\tres -= res.xxyz * bitMask;\n\treturn res;\n}\nfloat unpackDepth(const in vec4 rgbaDepth)\n{\n\tconst vec4 bitShift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n\tfloat depth = dot(rgbaDepth, bitShift);\n\treturn depth;\n}\nfloat tex2DPCF( sampler2D shadowMap,vec2 texcoord,vec2 invsize,float zRef )\n{\n\tvec2 texelpos =texcoord / invsize;\n\tvec2 lerps = fract( texelpos );\n\tfloat sourcevals[4];\n\tsourcevals[0] = float( unpackDepth(texture2D(shadowMap,texcoord)) > zRef );\n\tsourcevals[1] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x,0))) > zRef );\n\tsourcevals[2] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(0,invsize.y))) > zRef );\n\tsourcevals[3] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x, invsize.y) )) > zRef );\n\treturn mix( mix(sourcevals[0],sourcevals[2],lerps.y),mix(sourcevals[1],sourcevals[3],lerps.y),lerps.x );\n}\nfloat getShadowPSSM3( sampler2D shadowMap1,sampler2D shadowMap2,sampler2D shadowMap3,mat4 lightShadowVP[4],vec3 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\tnPSNum += int(posViewZ>pssmDistance.z);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\telse if( nPSNum == 2 )\n\t{\n\t\tlightVP = lightShadowVP[3];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率,在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t} \n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap3,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 2 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap3,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM2( sampler2D shadowMap1,sampler2D shadowMap2,mat4 lightShadowVP[4],vec3 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tint nPSNum = int(posViewZ>pssmDistance.x);\n\tnPSNum += int(posViewZ>pssmDistance.y);\n\t//真SB,webgl不支持在PS中直接访问数组\n\tmat4 lightVP;\n\tif( nPSNum == 0 )\n\t{\n\t\tlightVP = lightShadowVP[1];\n\t}\n\telse if( nPSNum == 1 )\n\t{\n\t\tlightVP = lightShadowVP[2];\n\t}\n\tvec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n\t//为了效率,在CPU计算/2.0 + 0.5\n\t//vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n\tvec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n\tfloat fMyZ = vText.z - zBias;\n\t/*\n\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\tbool bInFrustum = all( bInFrustumVec );\n\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\tbool bFrustumTest = all( bFrustumTestVec );\n\tif ( bFrustumTest ) \n\t*/\n\tif( fMyZ <= 1.0 )\n\t{\n\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,\tfMyZ );\n\t\t\tvalue = value/4.0;\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF2\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tvec4 color = texture2D( shadowMap2,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n\t\t}\n#endif\n#ifdef SHADOWMAP_PCF_NO\n\t\tvec4 color;\n\t\tif ( nPSNum == 0 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap1,vText.xy );\n\t\t}\n\t\telse if( nPSNum == 1 )\n\t\t{\n\t\t\tcolor = texture2D( shadowMap2,vText.xy );\n\t\t}\n\t\tzdepth = unpackDepth(color);\n\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t}\n\treturn value;\n}\nfloat getShadowPSSM1( sampler2D shadowMap1,vec4 lightMVPPos,vec3 pssmDistance,vec2 shadowPCFOffset,float posViewZ,float zBias )\n{\n\tfloat value = 1.0;\n\tif( posViewZ < pssmDistance.x )\n\t{\n\t\tvec3 vText = lightMVPPos.xyz / lightMVPPos.w;\n\t\tfloat fMyZ = vText.z - zBias;\n\t\t/*\n\t\tbvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n\t\tbool bInFrustum = all( bInFrustumVec );\n\t\tbvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n\t\tbool bFrustumTest = all( bFrustumTestVec );\n\t\t*/\n\t\tif ( fMyZ <= 1.0 ) \n\t\t{\n\t\t\tfloat zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n\t\t\tvalue = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,fMyZ );\n\t\t\tvalue += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,fMyZ );\n\t\t\tvalue = value/4.0;\n#endif\n#ifdef SHADOWMAP_PCF2\t\t\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF1\n\t\t\tvalue = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF_NO\t\t\n\t\t\tvec4 color = texture2D( shadowMap1,vText.xy );\n\t\t\tzdepth = unpackDepth(color);\n\t\t\tvalue = float(fMyZ < zdepth);\n#endif\n\t\t}\n\t}\n\treturn value;\n}"),Vi.addInclude("WaveFunction.glsl","\nuniform vec2 u_WaveInfoD[20];\nuniform vec4 u_WaveInfo[20];\n\nuniform float TEXWAVE_UV_SCALE ;//= 20.0; //每texwidth像素代表的实际距离\n/**\n\t这里的计算都是\n*/\n\n/**\n* 计算一个波形\n* 开始计算的时候都按照z向上,最后输出的时候,颠倒一下。\n* @param tm {float} 毫秒\n*/\nvoid calcGerstnerWave(float curtm, vec3 pos, float deep, vec2 uvpos, out vec3 opos, out vec3 B, out vec3 T, out vec3 N, out float foamS){\n\tfloat tm = curtm/1000.;\n\topos = pos;\n\tvec3 wpos=vec3(0.);\t\t//累加的位置\n\tN=vec3(0.,0.,0.);\t//输出的法线初始化一下\n\tT=vec3(0.,0.,0.);\n\tB=vec3(0.,0.,0.);\n\tvec2 cD ;//= D;\n\t//float deepAtt = max(0.,min(deep,1.0));\n\t//A*=deepAtt; //TODO\n\t\n\tfor( int i=0; i<4; i++){\n\t\tcD = u_WaveInfoD[i];//vec2(wi.winfo[0],wi.winfo[1]);// wi.vDir;\n\t\tfloat Q = u_WaveInfo[i].x;//wi.QorK;\n\t\tfloat A = u_WaveInfo[i].y;//wi.A;\n\t\tfloat W = u_WaveInfo[i].z;//wi.omega;\n\t\tfloat P = u_WaveInfo[i].w;//wi.phi;\n\t\tfloat dop = dot(cD,uvpos);\n\t\tfloat c = cos(dop*W - tm*P);//TODO 优化\n\t\tfloat s = sin(dop*W - tm*P);\n\t\tfloat AWs = A*W*s;\n\t\tfloat AWc = A*W*c;\n\t\tfloat _QxyAWs = -Q*cD.x*cD.y*AWs;\n\t\t\n\t\twpos += vec3(Q*A*cD.x*c,\n\t\t\t\t\tQ*A*cD.y*c,\n\t\t\t\t\tA*s);\n\t\tN += vec3(-cD.x*AWc,\n\t\t\t\t-cD.y*AWc,\n\t\t\t\tQ*AWs);//记得最后1-\n\t\tT += vec3(_QxyAWs,\n\t\t\t\tQ*cD.y*cD.y*AWs,//记得1-\n\t\t\t\tcD.y*AWc\n\t\t\t);\n\t\tB += vec3(Q*cD.x*cD.x*AWs,//记得1-\n\t\t\t\t_QxyAWs,\n\t\t\t\tcD.x*AWc\n\t\t\t);\n\t\t//float v1 = exp(-tan((dop*W - tm*P)/2.+1.07));//除2,+pi/2 这样正好能对齐\n#ifdef USE_FOAM\t\t\n\t\tfloat v1 = 0.5-sin((dop*W - tm*P)/1.+2.0)/2.;\n\t\tfoamS += pow(v1,9.)/4.;\n#endif\n\t}\n\tT.y=1.-T.y; B.x=1.-B.x;N.z=1.-N.z;\n\topos += vec3(wpos.x,wpos.z*min(deep/10.,1.),wpos.y);\n\t//y和z交换一下。现在根据uv计算的位置,所以直接交换yz就行。其他情况下有问题么\n\tT.xyz=T.xzy;\n\tB.xyz=B.xzy;\n\tN.xyz=N.xzy;\n}\n\n\nvoid calcWave(float curtm, vec2 uv, out vec3 B, out vec3 T, out vec3 N){\n\tfloat tm = curtm/1000.;\n\tN=vec3(0.,0.,0.);\t//输出的法线初始化一下\n\tvec2 uvpos = uv*TEXWAVE_UV_SCALE; //TODO 这个范围是什么 就是1?\n\tuvpos.y*=-1.;\n\tvec2 cD;// = D;\n\tconst int NumWaves = 4;\n\tfloat scale = 1./float(NumWaves);\n\tfor( int i=0; i=ismetalinfov){//这时候表示金属度\n\t\tmetaless = (basecolor.a-ismetalinfov)*2.;\n\t\tbasecolor.a = 1.0;\n\t}else{\n\t\tmetaless = 0.;\n\t\tbasecolor.a = basecolor.a*2.0;\n\t}\n\t#ifdef FIX_METALESS\n\tmetaless = u_metaless;\n\t#endif\n\t#ifdef HAS_PBRINFO\t\n\tvec4 pbrinfo = texture2D(texPbrInfo, vUv);\n\tmetaless = pbrinfo.b;\n\trough = pbrinfo.g;\n\t#endif\n const vec3 nonmetalF0 =vec3(0.02);\n vec3 F0 = mix(nonmetalF0, basecolor.rgb, metaless);\n\t\n vec4 PrefilteredColor = texPanoramaLod(texPrefilterdEnv, R, rough*maxlv);\n PrefilteredColor.rgb = _RGBEToRGB(PrefilteredColor);\n vec4 EnvBRDF = texture2D(texBRDFLUT,vec2(rough , NoV));//TODO lod\n vec2 rg = _RGBAToU16(EnvBRDF); \n speccontrib = (F0* rg.x + saturate( 50.0 * PrefilteredColor.g ) * rg.y);\n\tvec3 color_spec = PrefilteredColor.rgb*speccontrib;\n\t\n\tvec3 color_diff=diff_sh9(normal);\n\tvec3 outc = color_diff*mix(basecolor.rgb,vec3(0.),metaless)*(vec3(1.0)-speccontrib)+color_spec;\n\t#ifdef HAS_PBRINFO\n\toutc*=pbrinfo.r;\n\t#endif\n\treturn vec4(outc, basecolor.a);\n}\n\nvec3 oldlight(vec4 normal, float NoV, vec3 R){\n vec4 basecolor = texture2D(texBaseColor,vUv);\n\tconst vec3 lightdir=normalize(vec3(1.,1.,0.));\n\tconst vec3 spcecol = vec3(1.,0.8,0.8);\n\tconst vec3 amb = vec3(0.5);\n\tvec3 diffv = (vec3(saturate(dot(lightdir,normal.xyz)))+amb);\n\t//vec3 spec = spcecol* pow(saturate(dot(R,lightdir)),(1.-pbrinfo.g)*5.);\n\treturn diffv*basecolor.rgb;//+spec;\n}\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\nvarying float v_posViewZ;\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nvoid main() {\n#ifdef CASTSHADOW\n\tgl_FragColor=packDepth(gl_FragCoord.w);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(texBaseColor,vUv).w;\n\t\tif( alpha < u_AlphaTestValue ){\n\t\t\tdiscard;\n\t\t}\n\t#endif\n#else\n\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,vWorldPos.xyz,v_posViewZ,0.0001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,vWorldPos.xyz,v_posViewZ,0.0001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.0001);\n\t\t#endif\n\t#endif\t\n\t\n vec3 normal = normalize(vWorldNorm);\n\tvec4 normtex = texture2D( texNormal, vUv );\n\t#ifdef HAS_TANGENT\t\n\tnormal = applyNormalTex(normtex.xyz, normal);\n\t#endif\n vec3 view = -normalize(vViewDir);\n float NoV = saturate(dot( view, normal ));\n vec3 R = 2. * NoV * normal - view;\n\tfloat roughness = normtex.a;\n\t#ifdef FIX_ROUGHNESS\n\troughness = u_roughness;\n\t#endif\n\t\n\tvec4 pbrl = pbrlight(normal,roughness,NoV,R)*u_hdrexposure;\n gl_FragColor.rgb = pow(pbrl.rgb,vec3(0.45455));\n\t//gl_FragColor.rgb = oldlight(normtex,NoV,R);\n\t#ifdef RECEIVESHADOW\n\tgl_FragColor.rgb *= max(shadowValue,0.7);\n\t#endif\n\t\n gl_FragColor.a = pbrl.a;\n\n#endif\n}\n',e,t),Li.SHADERDEFINE_FIX_METALESS=i.registerMaterialDefine("FIX_METALESS"),Li.SHADERDEFINE_FIX_ROUGHNESS=i.registerMaterialDefine("FIX_ROUGHNESS"),Li.SHADERDEFINE_HAS_TANGENT=i.registerMaterialDefine("HAS_TANGENT"),Li.SHADERDEFINE_HAS_PBRINFO=i.registerMaterialDefine("HAS_PBRINFO"),Li.SHADERDEFINE_USE_GROUNDTRUTH=i.registerMaterialDefine("USE_GROUNDTRUTH"),Li.SHADERDEFINE_TEST_CLIPZ=i.registerMaterialDefine("CLIPZ"),e={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},t={u_Bones:[0,0],u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlphaTestValue:[0,1],u_DiffuseColor:[7,1],u_EmissionColor:[8,1],u_DiffuseTexture:[1,1],u_NormalTexture:[3,1],u_ParallaxTexture:[4,1],u_MetallicGlossTexture:[2,1],u_OcclusionTexture:[5,1],u_EmissionTexture:[6,1],u_metallic:[9,1],u_smoothness:[10,1],u_smoothnessScale:[11,1],u_occlusionStrength:[13,1],u_normalScale:[14,1],u_parallaxScale:[15,1],u_TilingOffset:[17,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};n=Vi.nameKey.add("PBRStandard");i=$n.add(n,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n\t varying vec4 v_lightMVPPos;\n\t uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\t \n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0 = a_Texcoord0;\n\t#endif\n\t\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\tmat3 worldMat;\n\t#ifdef BONE\n\t\tmat4 skinTransform = mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t\tv_PositionWorld = (u_WorldMat * position).xyz;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t\tworldMat = mat3(u_WorldMat);\n\t\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\t#endif\n\t\n\tv_Normal = worldMat * a_Normal;\n\tv_Tangent = worldMat * a_Tangent0.xyz;\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n \n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t#endif\n\t\tv_Texcoord0=vec2(v_Texcoord0.x,1.0 + v_Texcoord0.y);\n \n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n \n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}",'#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\n\nuniform vec3 u_AmbientColor;\nuniform vec4 u_DiffuseColor;\n\n#ifdef DIFFUSETEXTURE\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n#ifdef METALLICGLOSSTEXTURE\n\tuniform sampler2D u_MetallicGlossTexture;\n#endif\n#ifdef NORMALTEXTURE\n\tuniform sampler2D u_NormalTexture;\n\tuniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n\tuniform sampler2D u_ParallaxTexture;\n\tuniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n\tuniform sampler2D u_OcclusionTexture;\n\tuniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n\t#ifdef EMISSIONTEXTURE\n\t\tuniform sampler2D u_EmissionTexture;\n\t#endif\n\tuniform vec4 u_EmissionColor;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\n#include "PBRStandardLighting.glsl"\n#include "ShadowHelper.glsl"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nuniform DirectionLight u_DirectionLight;\n\nvoid main_castShadow()\n{\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\n\nvoid main_normal()\n{\t\n\tvec3 viewDir = normalize(v_ViewDir);\n\t\n\tvec2 uv0 = ParallaxOffset(viewDir);\n\t\n\tvec2 mg;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 diffuseTextureColor = texture2D(u_DiffuseTexture, uv0);\n\t\tvec4 diffuseColor = diffuseTextureColor * u_DiffuseColor;\n\t\tmg = MetallicGloss(diffuseTextureColor.a, uv0);\n\t#else\n\t\tvec4 diffuseColor = u_DiffuseColor;\n\t\tmg = MetallicGloss(1.0, uv0);\n\t#endif\n\t\n\t#ifdef ALPHATEST\n\t\tif(diffuseColor.a < u_AlphaTestValue)\n\t\t\tdiscard;\n\t#endif\n\t\n\tgl_FragColor = diffuseColor;\n\t\n\tvec3 normal = UnpackScaleNormal(uv0);\n \n\tvec3 gi = u_AmbientColor * Occlusion(uv0).rgb;\n \n\tvec4 color = PBRStandardDiectionLight(diffuseColor.rgb, mg.r, mg.g, normal, viewDir, u_DirectionLight, gi);\n\t\n\tcolor.a = diffuseColor.a;\n\t\n\t#ifdef EMISSION\n\t\tvec4 emissionColor = u_EmissionColor;\n\t\t#ifdef EMISSIONTEXTURE\n\t\t\temissionColor *= texture2D(u_EmissionTexture, uv0);\n\t\t#endif\n\t\tcolor.rgb += emissionColor.rgb;\n\t#endif\n\t\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t\t#endif\n\t\tgl_FragColor = vec4(color.rgb * shadowValue, color.a);\n\t#else\n\t\tgl_FragColor = color;\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\t\t\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif \n}\n\n',e,t),Fi.SHADERDEFINE_DIFFUSETEXTURE=i.registerMaterialDefine("DIFFUSETEXTURE"),Fi.SHADERDEFINE_METALLICGLOSSTEXTURE=i.registerMaterialDefine("METALLICGLOSSTEXTURE"),Fi.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=i.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),Fi.SHADERDEFINE_NORMALTEXTURE=i.registerMaterialDefine("NORMALTEXTURE"),Fi.SHADERDEFINE_PARALLAXTEXTURE=i.registerMaterialDefine("PARALLAXTEXTURE"),Fi.SHADERDEFINE_OCCLUSIONTEXTURE=i.registerMaterialDefine("OCCLUSIONTEXTURE"),Fi.SHADERDEFINE_EMISSION=i.registerMaterialDefine("EMISSION"),Fi.SHADERDEFINE_EMISSIONTEXTURE=i.registerMaterialDefine("EMISSIONTEXTURE"),Fi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),e={a_Position:0,a_Normal:3,a_Tangent0:5,a_Texcoord0:2,a_BoneWeights:7,a_BoneIndices:6},t={u_Bones:[0,0],u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlphaTestValue:[0,1],u_DiffuseColor:[7,1],u_SpecularColor:[8,1],u_EmissionColor:[9,1],u_DiffuseTexture:[1,1],u_NormalTexture:[3,1],u_ParallaxTexture:[4,1],u_SpecularTexture:[2,1],u_OcclusionTexture:[5,1],u_EmissionTexture:[6,1],u_smoothness:[10,1],u_smoothnessScale:[11,1],u_occlusionStrength:[13,1],u_normalScale:[14,1],u_parallaxScale:[15,1],u_TilingOffset:[17,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};n=Vi.nameKey.add("PBRSpecular");i=$n.add(n,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n\tuniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n\t varying vec4 v_lightMVPPos;\n\t uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef BONE\n\tconst int c_MaxBoneCount = 24;\n\tattribute vec4 a_BoneIndices;\n\tattribute vec4 a_BoneWeights;\n\tuniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n\t#ifdef BONE\n\t\tmat4 skinTransform=mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t#endif\n\t \n\t//TODO没考虑UV动画呢\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tv_Texcoord0 = a_Texcoord0;\n\t#endif\n\t\tv_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n\tmat3 worldMat;\n\t#ifdef BONE\n\t\tmat4 skinTransform = mat4(0.0);\n\t\tskinTransform += u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n\t\tskinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n\t\tvec4 position = skinTransform * a_Position;\n\t\tgl_Position = u_MvpMatrix * position;\n\t\tworldMat=mat3(u_WorldMat*skinTransform);\n\t\tv_PositionWorld = (u_WorldMat * position).xyz;\n\t#else\n\t\tgl_Position = u_MvpMatrix * a_Position;\n\t\tworldMat = mat3(u_WorldMat);\n\t\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\t#endif\n\t\n\tv_Normal = worldMat * a_Normal;\n\tv_Tangent = worldMat * a_Tangent0.xyz;\n\tv_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n \n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0=(vec2(v_Texcoord0.x,v_Texcoord0.y-1.0)*u_TilingOffset.xy)+u_TilingOffset.zw;\n\t#endif\n\t\tv_Texcoord0=vec2(v_Texcoord0.x,1.0 + v_Texcoord0.y);\n \n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n \n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1 \n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif\n}",'#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\n\nuniform vec3 u_AmbientColor;\nuniform vec4 u_DiffuseColor;\nuniform vec4 u_SpecularColor;\n\n#ifdef DIFFUSETEXTURE\n\tuniform sampler2D u_DiffuseTexture;\n#endif\n#ifdef SPECULARTEXTURE\n\tuniform sampler2D u_SpecularTexture;\n#endif\n#ifdef NORMALTEXTURE\n\tuniform sampler2D u_NormalTexture;\n\tuniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n\tuniform sampler2D u_ParallaxTexture;\n\tuniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n\tuniform sampler2D u_OcclusionTexture;\n\tuniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n\t#ifdef EMISSIONTEXTURE\n\t\tuniform sampler2D u_EmissionTexture;\n\t#endif\n\tuniform vec4 u_EmissionColor;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\n#include "PBRSpecularLighting.glsl"\n#include "ShadowHelper.glsl"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\n\nuniform DirectionLight u_DirectionLight;\n\nvoid main_castShadow()\n{\n\tgl_FragColor=packDepth(v_posViewZ);\n\t#if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n\t\tfloat alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n\t\tif( alpha < u_AlphaTestValue )\n\t\t{\n\t\t\tdiscard;\n\t\t}\n\t#endif\n}\n\nvoid main_normal()\n{\t\n\tvec3 viewDir = normalize(v_ViewDir);\n\t\n\tvec2 uv0 = ParallaxOffset(viewDir);\n\t\n\tvec4 sg;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 diffuseTextureColor = texture2D(u_DiffuseTexture, uv0);\n\t\tvec4 diffuseColor = diffuseTextureColor * u_DiffuseColor;\n\t\tsg = SpecularGloss(diffuseTextureColor.a, uv0);\n\t#else\n\t\tvec4 diffuseColor = u_DiffuseColor;\n\t\tsg = SpecularGloss(1.0, uv0);\n\t#endif\n\t\n\t#ifdef ALPHATEST\n\t\tif(diffuseColor.a < u_AlphaTestValue)\n\t\t\tdiscard;\n\t#endif\n \n\tvec3 normal = UnpackScaleNormal(uv0);\n\t\n\tvec3 gi = u_AmbientColor * Occlusion(uv0).rgb;\n\t\n\t//float a = (sg.r+sg.g+sg.b) / 3.0;\n \n\tvec4 color = PBRSpecularDiectionLight(diffuseColor.rgb, sg.rgb, sg.a, normal,viewDir, u_DirectionLight, gi);\n\t\n\tcolor.a = diffuseColor.a;\n\t\n\t#ifdef EMISSION\n\t\tvec4 emissionColor = u_EmissionColor;\n\t\t#ifdef EMISSIONTEXTURE\n\t\t\temissionColor *= texture2D(u_EmissionTexture, uv0);\n\t\t#endif\n\t\tcolor.rgb += emissionColor.rgb;\n\t#endif\n\t\n\t#ifdef RECEIVESHADOW\n\t\tfloat shadowValue = 1.0;\n\t\t#ifdef SHADOWMAP_PSSM3\n\t\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif\n\t\t#ifdef SHADOWMAP_PSSM2\n\t\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t\t#endif \n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t\t#endif\n\t\tgl_FragColor = vec4(color.rgb * shadowValue, color.a);\n\t#else\n\t\tgl_FragColor = color;\n\t#endif\n}\n\nvoid main()\n{\n\t#ifdef CASTSHADOW\t\t\n\t\tmain_castShadow();\n\t#else\n\t\tmain_normal();\n\t#endif \n}\n\n',e,t),wi.SHADERDEFINE_DIFFUSETEXTURE=i.registerMaterialDefine("DIFFUSETEXTURE"),wi.SHADERDEFINE_SPECULARTEXTURE=i.registerMaterialDefine("SPECULARTEXTURE"),wi.SHADERDEFINE_SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA=i.registerMaterialDefine("SMOOTHNESSSOURCE_DIFFUSETEXTURE_ALPHA"),wi.SHADERDEFINE_NORMALTEXTURE=i.registerMaterialDefine("NORMALTEXTURE"),wi.SHADERDEFINE_PARALLAXTEXTURE=i.registerMaterialDefine("PARALLAXTEXTURE"),wi.SHADERDEFINE_OCCLUSIONTEXTURE=i.registerMaterialDefine("OCCLUSIONTEXTURE"),wi.SHADERDEFINE_EMISSION=i.registerMaterialDefine("EMISSION"),wi.SHADERDEFINE_EMISSIONTEXTURE=i.registerMaterialDefine("EMISSIONTEXTURE"),wi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),e={a_position:0,a_normal:3,uv:2},t={irrad_mat_red:[10,3],irrad_mat_green:[11,3],irrad_mat_blue:[12,3],u_hdrexposure:[13,3],texBaseColor:[1,1],texNormal:[2,1],texSky:[11,1],texUnderWater:[3,1],texPrefilterdEnv:[8,3],texPrefilterDiff:[7,3],texWaterDisp:[4,1],texWaveDetail:[9,1],texDeepColor:[10,1],texWaterInfo:[16,1],texFoam:[17,1],GEOWAVE_UV_SCALE:[18,1],modelMatrix:[0,2],mvp:[1,2],cameraPosition:[0,3],u_curTm:[8,1],u_scrsize:[15,1],u_WaveInfoD:[13,1],u_WaveInfo:[12,1],u_WaveMainDir:[14,1],u_DeepScale:[20,1],u_SeaColor:[19,1],u_View:[1,3],u_Project:[2,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4]};n=Vi.nameKey.add("Water");i=$n.add(n,'\nuniform mat4 modelMatrix;\n//uniform mat4 modelViewMatrix;\n//uniform mat4 projectionMatrix;\nuniform mat4 u_View;\nuniform mat4 u_Project;\nuniform mat4 mvp;\n//uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\nuniform float u_curTm;\n\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 uv;\n//uniform sampler2D texWaterDisp;\n#ifdef USE_VERTEX_DEEPINFO\n#else\nuniform sampler2D texWaterInfo;\nvarying vec4 vWaterInfo;\nuniform float u_DeepScale;//texWaterInfo.r*vDeepScale\n#endif\nuniform float u_WaveMainDir;\t//主波方向\nuniform float GEOWAVE_UV_SCALE ;//= 100.0;\n\n\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTan;\nvarying vec3 vWorldBin;\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\nvarying vec3 vLightDir;\nvarying vec3 vViewDir;\nvarying vec3 vDisp;\nvarying float fDeep;\nvarying mat2 matUVTrans;\nvarying float fFoam;\n\nconst float PI = 3.14159265358979323846264;\n\n#include "WaveFunction.glsl"\n\nvec2 getPosFromUV(vec2 uv){\n\treturn uv*50.;\n}\n\nvoid main() {\n\tvec3 pos = a_position;\n vUv = uv;\n\t\n\t//vDisp = texture2D(texWaterDisp,uv).rgb;\n\t//vec3 disp = vDisp;\n\t\n\t//TODO 这里有个潜规则。\n\tfloat tt = pos.y; pos.y=pos.z; pos.z=-tt;\n\t\n\t#ifdef USE_VERTEX_DEEPINFO\n\tfDeep = -pos.y;\n\tpos.y=0.0;\n\t#else\n\tvWaterInfo = texture2D(texWaterInfo,uv);\n\tfDeep = vWaterInfo.r*u_DeepScale;\n\t#endif\n\t\n\t\n\t//计算波形\n\tmat4 modelMat = modelMatrix;\n\tvec3 opos, T,B,N;\n\tfloat foams=0.;\n\tvec2 uvpos = uv*GEOWAVE_UV_SCALE+vec2(modelMat[3][0],0.);//TODO 如果有旋转缩放怎么办\n\tcalcGerstnerWave(u_curTm, pos,fDeep, uvpos,opos,B,T,N,foams);\n\tfFoam = foams;\n\tgl_Position = mvp*vec4(opos,1.);\n\tvWorldPos = modelMat*vec4(opos,1.);\n\n\tvWorldNorm = normalize((modelMatrix*vec4(N,0.0)).xyz);\n\tvWorldTan = normalize((modelMatrix*vec4(T,0.0)).xyz);\n\tvWorldBin = normalize((modelMatrix*vec4(B,0.0)).xyz);\n vViewDir = vWorldPos.xyz-cameraPosition; //这个不能取normalize,否则会引入非线性\n\t\n\tfloat s = sin(u_WaveMainDir);\n\tfloat c = cos(u_WaveMainDir);\n\tmatUVTrans = mat2(c,-s,s,c);\n}\n',"//#version 300 es\n\nprecision highp float;\nprecision lowp int;\n\nconst float PI = 3.14159265358979323846264;\nconst float _2PI = 6.2831853071796;\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTan;\nvarying vec3 vWorldBin;\nvarying vec3 vViewDir;//入射。pos-cam\nvarying vec4 vViewPos;\nvarying vec4 vWorldPos;\nvarying float fDeep;\nvarying mat2 matUVTrans;\n#ifdef USE_VERTEX_DEEPINFO\n#else\nvarying vec4 vWaterInfo;\n#endif\nmat3 matTBNOff;//\n\n//\nuniform sampler2D texBaseColor;\nuniform sampler2D texNormal;\n#ifdef CUBE_ENV\nuniform samplerCube texSky;\n#else\nuniform sampler2D texSky;\n#endif\nuniform sampler2D texUnderWater;\nuniform sampler2D texWaveDetail;\n//uniform sampler2D texDeepColor;\nuniform sampler2D texFoam;\nvarying float fFoam;\nuniform float u_curTm;\nuniform vec2 u_scrsize;\nuniform vec3 u_SeaColor;//\n\nconst int NumTexWaves=4;\nconst float Amp_over_L = 0.01;\n//const vec3 SEA_COLOR1 = vec3(0.0292,0.672,0.7467);//大洋\n//const vec3 SEA_COLOR2 = vec3(0,0.927,0.43);//近海\n\nconst float _maxu8 = 255.0;\nconst float _maxu16 = 65535.0;\nconst float _shift8 = 256.0; //平移的话是*256而不是255\nvec2 _RGBAToU16(const in vec4 rgba){\n return vec2((rgba.r*_maxu8+rgba.g*_maxu8*_shift8)/_maxu16, (rgba.b*_maxu8+rgba.a*_maxu8*_shift8)/_maxu16);\n}\nvec3 _RGBEToRGB( const in vec4 rgba ){\n float f = pow(2.0, rgba.w * 255.0 - (128.0 + 8.0));\n return rgba.rgb * (255.0 * f);\n}\n\nfloat saturate(float v){\n return min(max(v,0.),1.);\n}\n\n/*\n\t各种 ToneMap\n*/\n//Reinhard\nvec3 ReinhardToneMapping(vec3 color, float adapted_lum) {\n const float MIDDLE_GREY = 1.;\n color *= MIDDLE_GREY / adapted_lum;\n return color / (1.0 + color);\n}\n\n//CE2\nvec3 CEToneMapping(vec3 color, float adapted_lum){\n return 1. - exp(-adapted_lum * color);\n}\n\n//UC2\nvec3 F1(vec3 x){\n\tconst float A = 0.22;\n\tconst float B = 0.30;\n\tconst float C = 0.10;\n\tconst float D = 0.20;\n\tconst float E = 0.01;\n\tconst float F = 0.30;\n \n\treturn ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;\n}\n\nvec3 Uncharted2ToneMapping(vec3 color, float adapted_lum){\n\tconst vec3 WHITE = vec3(11.2);\n\treturn F1(1.6 * adapted_lum * color) / F1(WHITE);\n}\n\n//ACES\nvec3 ACESToneMapping(vec3 color, float adapted_lum){\n\tconst float A = 2.51;\n\tconst float B = 0.03;\n\tconst float C = 2.43;\n\tconst float D = 0.59;\n\tconst float E = 0.14;\n\n\tcolor *= adapted_lum;\n\treturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n\n/*\n* 对一个全景图进行采样。假设x轴指向中心。\n*/\nvec4 texPanorama(sampler2D tex, const in vec3 dir){\n\tfloat envu = atan(dir.z,dir.x)/_2PI+0.5; \t\n\tfloat envv = acos(dir.y)/PI;//(1.0-dir.y)/2.0;\n\treturn texture2D(tex,vec2(envu,envv));\n}\n\n/*\n\t与位于0点的测试棒的相交测试交点\n\t这个是瞎写的,只是为了测试\n*/\nbool hitClydiner(vec3 pos, vec3 dir, out vec3 hitpos, out vec3 hitnormal){\n\tconst float r = 0.5;\n\tfloat a = dir.x*dir.x+dir.z*dir.z;\n\tfloat b = 2.*dir.x*pos.x+2.*dir.z*pos.z;\n\tfloat c = pos.x*pos.x+pos.z*pos.z-r*r;\n\tfloat d = b*b-4.*a*c;\n\tif(d>=0.0){\n\t\tfloat t = (-b+sqrt(d))/2./a;\n\t\tt =min(t, (-b-sqrt(d))/2./a);\n\t\thitpos = pos+dir*t;\n\t\treturn true;\n\t}\n\t/*\n\tvec3 v1 = normalize(cross(dir,vec3(0.,1.,0.)));//公垂线\n\tfloat dist = dot(pos,v1);//最短距离\n\tif(abs(dist)cDeep && hitpos.y=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn curValue;\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat totalValue=0.0;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\tfloat lastValue=lastGradientNumber.y;\n\t\t\n\t\tif(key>=normalizedAge){\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\n\t\t}\n\t}\n\treturn totalValue;\n}\n#endif\n\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n\tvec4 overTimeColor;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientAlpha=gradientAlphas[i];\n\t\tfloat alphaKey=gradientAlpha.x;\n\t\tif(alphaKey>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec4 gradientColor=gradientColors[i];\n\t\tfloat colorKey=gradientColor.x;\n\t\tif(colorKey>=normalizedAge)\n\t\t{\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\n\t\t\tfloat lastColorKey=lastGradientColor.x;\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn overTimeColor;\n}\n#endif\n\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n\tfloat overTimeFrame;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientFrame=gradientFrames[i];\n\t\tfloat key=gradientFrame.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\n\t\t\tfloat lastKey=lastGradientFrame.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn floor(overTimeFrame);\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n #ifdef VELOCITYOVERLIFETIMECONSTANT\n\t outLifeVelocity=u_VOLVelocityConst; \n #endif\n #ifdef VELOCITYOVERLIFETIMECURVE\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\n\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n #endif\n\t\t\t\t\t\n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMECURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n\t#endif\n\t\n\tvec3 finalPosition;\n\tif(u_VOLSpaceType==0){\n\t if(u_ScalingMode!=2)\n\t finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\n\t else\n\t finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\n\t}\n\telse{\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\n\t}\n #else\n\t startPosition=startVelocity*age;\n\t vec3 finalPosition;\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=0.5*gravityVelocity*age;\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n\t#ifdef COLOROVERLIFETIME\n\t color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n\t#endif\n\t\n\t#ifdef RANDOMCOLOROVERLIFETIME\n\t color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n\t#endif\n\n return color;\n}\n\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n\n#ifdef RENDERMODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n#endif\n\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n\n\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n#endif\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n\t#ifdef TEXTURESHEETANIMATIONCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n\t float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\treturn uv;\n}\n\nvoid main()\n{\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\n\tvec3 lifeVelocity;\n\tif(normalizedAge<1.0){ \n\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n\t#endif \n\tvec3 gravityVelocity=u_Gravity*age;\n\t\n\tvec4 worldRotation;\n\tif(u_SimulationSpace==0)\n\t\tworldRotation=a_SimulationWorldRotation;\n\telse\n\t\tworldRotation=u_WorldRotation;\n\t\n\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\n \n \n #ifdef SPHERHBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n\t corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\tfloat c = cos(rot);\n\t\t\t\tfloat s = sin(rot);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat c = cos(a_StartRotation0.x);\n\t\t\t\tfloat s = sin(a_StartRotation0.x);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#endif\n #endif\n \n #ifdef STRETCHEDBILLBOARD\n\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n\tvec3 velocity;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t if(u_VOLSpaceType==0)\n\t\t velocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\n\t else\n\t\t velocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\n #else\n\t velocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n #endif\t\n\t\tvec3 cameraUpVector = normalize(velocity);\n\t\tvec3 direction = normalize(center-u_CameraPosition);\n vec3 sideVector = normalize(cross(direction,normalize(velocity)));\n\t\t\n\t\tsideVector=u_SizeScale.xzy*sideVector;\n\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\n\t\t\n\t vec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t\n\t const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n\t corner=rotaionZHalfPI*corner;\n\t corner.y=corner.y-abs(corner.y);\n\t\t\n\t float speed=length(velocity);//TODO:\n\t center +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector=vec3(0.0,0.0,1.0);\n\t const vec3 sideVector = vec3(-1.0,0.0,0.0);\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef RENDERMODE_MESH\n\t vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,-computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\t#ifdef ROTATIONOVERLIFETIME\n\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\n\t\t\t\t\t\t#endif\n\t\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t\t\t\t//TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\n\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,a_StartRotation0.z), age,normalizedAge);\n\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\n\t\t\t\t#endif\t\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\n\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\n\t\t\t\t\t#else\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t\tv_MeshColor=a_MeshColor;\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\t#ifdef DIFFUSEMAP\n\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n\t\t#endif\n\t\t#ifdef RENDERMODE_MESH\n\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\n\t\t#endif\n\t\t\n\t\t#ifdef TILINGOFFSET\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset.xy+vec2(u_TilingOffset.z,-u_TilingOffset.w);//需要特殊处理\n\t\t\tv_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t#endif\n v_Discard=0.0;\n\t \n\t#ifdef FOG\n\t\tv_PositionWorld=center;\n\t#endif\n }\n else\n\t{\n\t\tv_Discard=1.0;\n\t}\n}\n\n","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\nuniform vec4 u_Tintcolor;\n\n#ifdef RENDERMODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\n#ifdef FOG\n\tvarying vec3 v_PositionWorld;\n\tuniform vec3 u_CameraPosition;\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\t#ifdef ADDTIVEFOG\n\t#else\n\t\tuniform vec3 u_FogColor;\n\t#endif\n#endif\n\n\nvoid main()\n{\t\n\t#ifdef RENDERMODE_MESH\n\t\tgl_FragColor=v_MeshColor;\n\t#else\n\t\tgl_FragColor=vec4(1.0);\t\n\t#endif\n\t\t\n\t#ifdef DIFFUSEMAP\n\t\tif(v_Discard!=0.0)\n\t\t\tdiscard;\n\t\t#ifdef TINTCOLOR\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\n\t\t#else\n\t\t\tgl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n\t\t#endif\n\t#else\n\t\t#ifdef TINTCOLOR\n\t\t\tgl_FragColor*=u_Tintcolor*2.0*v_Color;\n\t\t#else\n\t\t\tgl_FragColor*=v_Color;\n\t\t#endif\n\t#endif\n\t\n\t#ifdef FOG\n\t\tvec3 toEye=u_CameraPosition-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t\t\n\t\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\t\t#ifdef ADDTIVEFOG\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n\t\t#else\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n\t\t#endif\n\t#endif\n}",e,t),Hi.SHADERDEFINE_DIFFUSEMAP=i.registerMaterialDefine("DIFFUSEMAP"),Hi.SHADERDEFINE_TINTCOLOR=i.registerMaterialDefine("TINTCOLOR"),Hi.SHADERDEFINE_ADDTIVEFOG=i.registerMaterialDefine("ADDTIVEFOG"),Hi.SHADERDEFINE_TILINGOFFSET=i.registerMaterialDefine("TILINGOFFSET"),mr.SHADERDEFINE_RENDERMODE_BILLBOARD=i.registerSpriteDefine("SPHERHBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=i.registerSpriteDefine("STRETCHEDBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=i.registerSpriteDefine("HORIZONTALBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=i.registerSpriteDefine("VERTICALBILLBOARD"),mr.SHADERDEFINE_COLOROVERLIFETIME=i.registerSpriteDefine("COLOROVERLIFETIME"),mr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=i.registerSpriteDefine("RANDOMCOLOROVERLIFETIME"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=i.registerSpriteDefine("VELOCITYOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=i.registerSpriteDefine("VELOCITYOVERLIFETIMECURVE"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=i.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=i.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=i.registerSpriteDefine("TEXTURESHEETANIMATIONCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=i.registerSpriteDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIME=i.registerSpriteDefine("ROTATIONOVERLIFETIME"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=i.registerSpriteDefine("ROTATIONOVERLIFETIMESEPERATE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=i.registerSpriteDefine("ROTATIONOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=i.registerSpriteDefine("ROTATIONOVERLIFETIMECURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=i.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=i.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE=i.registerSpriteDefine("SIZEOVERLIFETIMECURVE"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=i.registerSpriteDefine("SIZEOVERLIFETIMECURVESEPERATE"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=i.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=i.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),mr.SHADERDEFINE_RENDERMODE_MESH=i.registerSpriteDefine("RENDERMODE_MESH"),mr.SHADERDEFINE_SHAPE=i.registerSpriteDefine("SHAPE"),e={a_Position:0,a_Texcoord0:2,a_Time:33},t={u_Texture:[1,1],u_Albedo:[2,1],u_Color:[3,1],u_CurrentTime:[2,2],u_Duration:[3,2],u_MvpMatrix:[1,2]};n=Vi.nameKey.add("GLITTER");i=$n.add(n,"attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nattribute float a_Time;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_CurrentTime;\nuniform vec4 u_Color;\nuniform float u_Duration;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n \n float age = u_CurrentTime-a_Time;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n \n v_Texcoord=a_Texcoord0;\n \n v_Color=u_Color;\n v_Color.a*=1.0-normalizedAge;\n}\n","#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform vec4 u_Albedo;\nuniform sampler2D u_Texture;\n\nvarying vec2 v_Texcoord;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\t\n gl_FragColor=texture2D(u_Texture, v_Texcoord)*v_Color;\n gl_FragColor=gl_FragColor*u_Albedo;\n}\n\n",e,t),e={a_Position:0},t={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_CubeTexture:[3,1],u_MvpMatrix:[4,3]};i=Vi.nameKey.add("SkyBox");$n.add(i,"attribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord=a_Position.xyz;\n}\n","#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform samplerCube u_CubeTexture;\n\nvarying vec3 v_Texcoord;\n\n\nvoid main()\n{\t\n gl_FragColor=vec4(textureCube(u_CubeTexture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",e,t),e={a_Position:0,a_Texcoord0:2},t={u_Intensity:[1,1],u_AlphaBlending:[2,1],u_texture:[3,1],u_MvpMatrix:[4,3]};i=Vi.nameKey.add("SkyDome");$n.add(i,"attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\nuniform mat4 u_MvpMatrix;\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n v_Texcoord = a_Texcoord0;\n}\n","#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform float u_Intensity;\nuniform float u_AlphaBlending;\nuniform sampler2D u_texture;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\t\n gl_FragColor=vec4(texture2D(u_texture, v_Texcoord).rgb*u_Intensity,u_AlphaBlending);\n}\n\n",e,t),e={a_Position:0,a_Normal:3,a_Texcoord0:2,a_Texcoord1:15},t={u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_SplatAlphaTexture:[0,1],u_NormalTexture:[1,1],u_DiffuseTexture1:[2,1],u_DiffuseTexture2:[3,1],u_DiffuseTexture3:[4,1],u_DiffuseTexture4:[5,1],u_DiffuseScale1:[6,1],u_DiffuseScale2:[7,1],u_DiffuseScale3:[8,1],u_DiffuseScale4:[9,1],u_MaterialDiffuse:[11,1],u_MaterialAmbient:[10,1],u_MaterialSpecular:[12,1],u_CameraPos:[0,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};i=Vi.nameKey.add("Terrain"),i=$n.add(i,"attribute vec4 a_Position;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef LIGHTMAP\n\tuniform vec4 u_LightmapScaleOffset;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nattribute vec2 a_Texcoord0;\nattribute vec2 a_Texcoord1;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nuniform mat4 u_MvpMatrix;\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n\tv_Texcoord0=a_Texcoord0;\n\tv_Texcoord1=a_Texcoord1;\n\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tv_Normal=a_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n#endif\n\n#ifdef LIGHTMAP\n\t//这个地方使用a_Normal 并不是真的代表normal,其实凑巧法线图的uv正好是符合 light_Map的UV\n\tv_LightMapUV=vec2(a_Normal.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,(a_Normal.y-1.0)*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n#endif\n\n#ifdef RECEIVESHADOW\n\tv_posViewZ = gl_Position.w;\n\t#ifdef SHADOWMAP_PSSM1\n\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t#endif\n#endif\n\n}",'#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "LightHelper.glsl";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\tuniform vec3 u_MaterialDiffuse;\n\tuniform vec4 u_MaterialSpecular;\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_Normal;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tuniform vec3 u_MaterialAmbient;\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\n\nuniform sampler2D u_SplatAlphaTexture;\nuniform sampler2D u_NormalTexture;\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform vec2 u_DiffuseScale1;\nuniform vec2 u_DiffuseScale2;\nuniform vec2 u_DiffuseScale3;\nuniform vec2 u_DiffuseScale4;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\n#ifdef LIGHTMAP\n\tuniform sampler2D u_LightMap;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n#ifdef DETAIL_NUM1\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz;\n#endif\n#ifdef DETAIL_NUM2\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-splatAlpha.r) + color2.xyz * splatAlpha.r;\n#endif\n#ifdef DETAIL_NUM3\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord1/u_DiffuseScale3);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-(splatAlpha.r+splatAlpha.g)) + color2.xyz * splatAlpha.r + color3.xyz * splatAlpha.g;\n#endif\n#ifdef DETAIL_NUM4\n\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord1/u_DiffuseScale1);\n\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord1/u_DiffuseScale2);\n\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord1/u_DiffuseScale3);\n\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord1/u_DiffuseScale4);\n\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\tgl_FragColor.xyz = color1.xyz * (1.0-(splatAlpha.r+splatAlpha.g+splatAlpha.b))+ color2.xyz * splatAlpha.r + color3.xyz * splatAlpha.g + color4.xyz * splatAlpha.b;\n#endif\n\tgl_FragColor.w = splatAlpha.a;\n\t\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 normal = texture2D(u_NormalTexture,v_Normal.xy).xyz;\n\tnormal = normal*2.0 - vec3(1.0);\n\tvec3 diffuse = vec3(0.0);\n\tvec3 ambient = vec3(0.0);\n\tvec3 specular= vec3(0.0);\n\tvec3 dif, amb, spe;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tcomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,u_AmbientColor,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tcomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n#endif\n\n#ifdef LIGHTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t#else\n\t\t#if defined(RECEIVESHADOW)\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue);\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t\t#endif\n\t#endif\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse*shadowValue) + specular * shadowValue,gl_FragColor.a);\n\t#else\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular, gl_FragColor.a);\n\t#endif\n#endif\n\n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n',e,t);bi.SHADERDEFINE_DETAIL_NUM1=i.registerMaterialDefine("DETAIL_NUM1"),bi.SHADERDEFINE_DETAIL_NUM2=i.registerMaterialDefine("DETAIL_NUM2"),bi.SHADERDEFINE_DETAIL_NUM4=i.registerMaterialDefine("DETAIL_NUM4"),bi.SHADERDEFINE_DETAIL_NUM3=i.registerMaterialDefine("DETAIL_NUM3"),e={a_Position:0,a_Normal:3,a_Texcoord0:2},t={u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_LightmapScaleOffset:[2,2],u_LightMap:[3,2],u_SplatAlphaTexture:[0,1],u_DiffuseTexture1:[1,1],u_DiffuseTexture2:[2,1],u_DiffuseTexture3:[3,1],u_DiffuseTexture4:[4,1],u_DiffuseTexture5:[5,1],u_DiffuseScaleOffset1:[6,1],u_DiffuseScaleOffset2:[7,1],u_DiffuseScaleOffset3:[8,1],u_DiffuseScaleOffset4:[9,1],u_DiffuseScaleOffset5:[10,1],u_MaterialAlbedo:[14,1],u_MaterialDiffuse:[12,1],u_MaterialAmbient:[11,1],u_MaterialSpecular:[13,1],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Diffuse":[4,4],"u_PointLight.Position":[5,4],"u_PointLight.Range":[6,4],"u_PointLight.Attenuation":[7,4],"u_PointLight.Diffuse":[8,4],"u_SpotLight.Position":[9,4],"u_SpotLight.Direction":[10,4],"u_SpotLight.Range":[12,4],"u_SpotLight.Spot":[11,4],"u_SpotLight.Attenuation":[13,4],"u_SpotLight.Diffuse":[14,4],u_AmbientColor:[21,4],u_shadowMap1:[18,4],u_shadowMap2:[19,4],u_shadowMap3:[20,4],u_shadowPSSMDistance:[15,4],u_lightShadowVP:[16,4],u_shadowPCFoffset:[17,4]};i=Vi.nameKey.add("ExtendTerrain"),i=$n.add(i,"attribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nvarying vec2 v_Texcoord0;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n\tattribute vec3 a_Normal;\n\tvarying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\tuniform mat4 u_WorldMat;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef LIGHTMAP\n\tvarying vec2 v_LightMapUV;\n\tuniform vec4 u_LightmapScaleOffset;\n#endif\n\n#ifdef RECEIVESHADOW\n\tvarying float v_posViewZ;\n\t#ifdef SHADOWMAP_PSSM1 \n\t\tvarying vec4 v_lightMVPPos;\n\t\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n#endif\n\nvoid main()\n{\n\tgl_Position = u_MvpMatrix * a_Position;\n \n\tv_Texcoord0 = a_Texcoord0;\n \n\t#ifdef LIGHTMAP\n\t\tv_LightMapUV = vec2(a_Texcoord0.x*u_LightmapScaleOffset.x+u_LightmapScaleOffset.z,(a_Texcoord0.y-1.0)*u_LightmapScaleOffset.y+u_LightmapScaleOffset.w);\n\t#endif\n \n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tv_Normal = a_Normal;\n\t#endif\n\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n\t\tv_PositionWorld=(u_WorldMat*a_Position).xyz;\n\t#endif\n\n\t#ifdef RECEIVESHADOW\n\t\tv_posViewZ = gl_Position.w;\n\t\t#ifdef SHADOWMAP_PSSM1\n\t\t\tv_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n\t\t#endif\n\t#endif\n}",'#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\n#include "LightHelper.glsl";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tuniform vec3 u_MaterialDiffuse;\n\tuniform vec4 u_MaterialSpecular;\n\tuniform vec3 u_CameraPos;\n\tvarying vec3 v_Normal;\n\tvarying vec3 v_PositionWorld;\n#endif\n\n#ifdef FOG\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\tuniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n\tuniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n\tuniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n\tuniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n#include "ShadowHelper.glsl"\n#ifdef RECEIVESHADOW\n\t#if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n\tuniform mat4 u_lightShadowVP[4];\n\t#endif\n\t#ifdef SHADOWMAP_PSSM1 \n\tvarying vec4 v_lightMVPPos;\n\t#endif\n#endif\nvarying float v_posViewZ;\n\n\nuniform sampler2D u_SplatAlphaTexture;\n\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform sampler2D u_DiffuseTexture5;\n\nuniform vec4 u_DiffuseScaleOffset1;\nuniform vec4 u_DiffuseScaleOffset2;\nuniform vec4 u_DiffuseScaleOffset3;\nuniform vec4 u_DiffuseScaleOffset4;\nuniform vec4 u_DiffuseScaleOffset5;\n\nvarying vec2 v_Texcoord0;\n\nuniform vec3 u_MaterialAmbient;\nuniform vec4 u_MaterialAlbedo;\n\n#ifdef LIGHTMAP\n\tuniform sampler2D u_LightMap;\n\tvarying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n\t#ifdef ExtendTerrain_DETAIL_NUM1\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r;\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM2\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM3\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM4\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\n\t#endif\n\t#ifdef ExtendTerrain_DETAIL_NUM5\n\t\tvec4 splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n\t\tvec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n\t\tvec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n\t\tvec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n\t\tvec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n\t\tvec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\n\t\tgl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\n\t#endif\n\t\tgl_FragColor.w = splatAlpha.a;\n\t\t\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 normal = v_Normal;\n\tvec3 diffuse = vec3(0.0);\n\tvec3 ambient = vec3(0.0);\n\tvec3 specular= vec3(0.0);\n\tvec3 dif, amb, spe;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n\tvec3 toEye;\n\t#ifdef FOG\n\t\ttoEye=u_CameraPos-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t#else\n\t\ttoEye=normalize(u_CameraPos-v_PositionWorld);\n\t#endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n\tcomputeDirectionLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_DirectionLight,u_AmbientColor,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n\tcomputePointLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_PointLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n\tComputeSpotLight(u_MaterialDiffuse,u_MaterialAmbient,u_MaterialSpecular,u_SpotLight,u_AmbientColor,v_PositionWorld,normal,toEye, dif, amb, spe);\n\tdiffuse+=dif;\n\tambient+=amb;\n\tspecular+=spe;\n#endif\n\n#ifdef RECEIVESHADOW\n\tfloat shadowValue = 1.0;\n\t#ifdef SHADOWMAP_PSSM3\n\t\tshadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif\n\t#ifdef SHADOWMAP_PSSM2\n\t\tshadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n\t#endif \n\t#ifdef SHADOWMAP_PSSM1\n\t\tshadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n\t#endif\n#endif\n\n#ifdef LIGHTMAP\n\t#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t#else\n\t\t#if defined(RECEIVESHADOW)\t\t\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient+texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue);\n\t\t\t//vec3 tColor= u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb * shadowValue + mix(vec3(0.15,0.15,0.15),vec3(0.0),shadowValue);\n\t\t\t//gl_FragColor.rgb*=tColor;\n\t\t#else\n\t\t\tgl_FragColor.rgb=gl_FragColor.rgb*(u_MaterialAmbient + texture2D(u_LightMap, v_LightMapUV).rgb);\n\t\t#endif\n\t#endif\n#endif\n\ngl_FragColor=gl_FragColor*u_MaterialAlbedo;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n\t#ifdef RECEIVESHADOW\n\t\tgl_FragColor = vec4( gl_FragColor.rgb*(ambient + diffuse*shadowValue) + specular * shadowValue,gl_FragColor.a);\n\t#else\n\t\tgl_FragColor =vec4( gl_FragColor.rgb*(ambient + diffuse) + specular, gl_FragColor.a);\n\t#endif\n#endif\n\n#ifdef FOG\n\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n\n\n\n\n',e,t);i.addSpriteDefines(lr.shaderDefines),i.addMaterialDefines(Oi.shaderDefines),e={a_Position:0,a_OffsetVector:41,a_Texcoord0X:38,a_Texcoord0Y:40,a_BirthTime:33},t={u_MvpMatrix:[1,2],u_VMatrix:[1,3],u_PMatrix:[2,3],u_TilingOffset:[3,1],u_MainTexture:[1,1],u_MainColor:[2,1],u_CurTime:[3,2],u_LifeTime:[4,2],u_WidthCurve:[5,2],u_WidthCurveKeyLength:[6,2],u_GradientColorkey:[7,2],u_GradientAlphakey:[8,2]};i=Vi.nameKey.add("Trail"),t=$n.add(i,"attribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute vec4 a_Color;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0Y;\nattribute float a_BirthTime;\n\nuniform mat4 u_VMatrix;\nuniform mat4 u_PMatrix;\n\nuniform vec4 u_TilingOffset;\n\nuniform float u_CurTime;\nuniform float u_LifeTime;\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\n{\n\tfloat t2 = t * t;\n\tfloat t3 = t2 * t;\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\n\tfloat b = t3 - 2.0 * t2 + t;\n\tfloat c = t3 - t2;\n\tfloat d = -2.0 * t3 + 3.0 * t2;\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\n}\n\nfloat getCurWidth(in float normalizeTime)\n{\n\tif(normalizeTime == 0.0){\n\t\treturn u_WidthCurve[0].w;\n\t}\n\telse if(normalizeTime >= 1.0){\n\t\treturn u_WidthCurve[u_WidthCurveKeyLength - 1].w;\n\t}\n\telse{\n\t\tfor(int i = 0; i < 10; i ++ )\n\t\t{\n\t\t\tif(normalizeTime == u_WidthCurve[i].x)\n\t\t\t{\n\t\t\t\treturn u_WidthCurve[i].w;\n\t\t\t}\n\t\t\t\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\n\t\t\t{\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\n\t\t\t\tfloat outTangent = lastFrame.z;\n\t\t\t\tfloat inTangent = nextFrame.y;\n\t\t\t\tfloat value1 = lastFrame.w;\n\t\t\t\tfloat value2 = nextFrame.w;\n\t\t\t\treturn hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\n\t\t\t}\n\t\t}\t\n\t}\n}\t\n\nvec4 getColorFromGradientByBlend(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tfloat colorKey = gradientColor.w;\n\t\tif(colorKey >= normalizeTime)\n\t\t{\n\t\t\tvec4 lastGradientColor = gradientColors[i-1];\n\t\t\tfloat lastColorKey = lastGradientColor.w;\n\t\t\tfloat age = (normalizeTime - lastColorKey) / (colorKey - lastColorKey);\n\t\t\tcolor.rgb = mix(gradientColors[i-1].xyz, gradientColor.xyz, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tfloat alphaKey = gradientAlpha.y;\n\t\tif(alphaKey >= normalizeTime)\n\t\t{\n\t\t\tvec2 lastGradientAlpha = gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey = lastGradientAlpha.y;\n\t\t\tfloat age = (normalizeTime - lastAlphaKey) / (alphaKey - lastAlphaKey);\n\t\t\tcolor.a = mix(lastGradientAlpha.x, gradientAlpha.x, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvec4 getColorFromGradientByFixed(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tif(gradientColor.w >= normalizeTime)\n\t\t{\n\t\t\tcolor.rgb = gradientColor.xyz;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tif(gradientAlpha.y >= normalizeTime)\n\t\t{\n\t\t\tcolor.a = gradientAlpha.x;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvoid main()\n{\n\tfloat normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\n\t\n\tgl_Position = u_PMatrix * u_VMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\n\t\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0 = (vec2(a_Texcoord0X, a_Texcoord0Y) * u_TilingOffset.xy) + u_TilingOffset.zw;\n\t#else\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n\t#endif\n\t\n\t#ifdef GRADIENTMODE_BLEND\n\t\tv_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#else\n\t\tv_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n\t#endif\n}\n\n\n\n","#ifdef HIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform sampler2D u_MainTexture;\nuniform vec4 u_MainColor;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nvoid main()\n{\t\n\tvec4 color = 2.0 * u_MainColor * v_Color;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t\tcolor *= mainTextureColor;\n\t#endif\n\tgl_FragColor = color;\n}\n\n",e,t);zi.SHADERDEFINE_DIFFUSETEXTURE=t.registerMaterialDefine("DIFFUSETEXTURE"),zi.SHADERDEFINE_TILINGOFFSET=t.registerSpriteDefine("TILINGOFFSET"),Er.SHADERDEFINE_GRADIENTMODE_BLEND=t.registerSpriteDefine("GRADIENTMODE_BLEND")},En);function En(){}var vn=function(){function e(){this._data=null,this._data=[]}p(e,"laya.d3.shader.ValusArray");var t=e.prototype;return t.setValue=function(e,t){this._data[e]=t},_(0,t,"data",function(){return this._data}),e}(),gn=function(){function u(){this._currentPSSM=-1,this._numberOfPSSM=3,this._maxDistance=200,this._ratioOfDistance=1/this._numberOfPSSM,this._statesDirty=!0,this._lightCulling=null,this._renderTarget=null,this._lightVPMatrix=null,this._lightCameras=null,this._shadowQuenes=null,this._shadowMapTextureSize=1024,this._scene=null,this._PCFType=0,this._shaderValueLightVP=null,this._shaderValueVPs=null,this._spiltDistance=new Array(4),this._globalParallelLightDir=new hn(0,-1,0),this._boundingSphere=new Array(4),this._boundingBox=new Array(4),this._frustumPos=new Array(16),this._uniformDistance=new Array(4),this._logDistance=new Array(4),this._dimension=new Array(4),this._tempLookAt3=new hn,this._tempLookAt4=new _n,this._tempValue=new _n,this._tempPos=new hn,this._tempLightUp=new hn,this._tempMin=new _n,this._tempMax=new _n,this._tempMatrix44=new Jt,this._splitFrustumCulling=new Xt(Jt.DEFAULT),this._tempScaleMatrix44=new Jt,this._shadowPCFOffset=new ln(1/1024,1/1024),this._shaderValueDistance=new _n;for(var e=0,e=0;ethis._numberOfPSSM)throw new Error("ParallelSplitShadowMap: beginSample invalid index");this._currentPSSM=e,this._update(t)},e.endSampler=function(e){this._currentPSSM=-1},e._calcAllLightCameraInfo=function(e){if(1===this._numberOfPSSM)this._beginSampler(0,e),this.endSampler(e);else for(var t=0,n=this._numberOfPSSM+1;ta[0]?s:a)[0],a[1]=(s[1]>a[1]?s:a)[1],a[2]=(s[2]>a[2]?s:a)[2]}_n.add(this._tempMax,this._tempMin,this._tempValue),s[0]*=.5,s[1]*=.5,s[2]*=.5,s[3]=1,_n.transformByM4x4(this._tempValue,e.transform.worldMatrix,this._tempValue);t=Math.abs(-this._tempMax.z),n=t>this._maxDistance?t:this._maxDistance;hn.scale(this._globalParallelLightDir,n,this._tempPos);t=this._tempPos.elements;t[0]=s[0]-t[0],t[1]=s[1]-t[1],t[2]=s[2]-t[2],e.transform.position=this._tempPos,e.transform.lookAt(this._tempLookAt3,this._tempLightUp,!1),Jt.createOrthoOffCenterRH(o[0],a[0],o[1],a[1],1,n+.5*(a[2]-o[2]),e.projectionMatrix),e.projectionViewMatrix.cloneTo(this._lightVPMatrix[this._currentPSSM]),this._lightCulling[this._currentPSSM].matrix=this._lightVPMatrix[this._currentPSSM],u.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,this._lightVPMatrix[this._currentPSSM],this._shaderValueVPs[this._currentPSSM])},e.getLightFrustumCulling=function(e){return this._lightCulling[e]},e.getSplitFrustumCulling=function(){return this._splitFrustumCulling},e.getSplitDistance=function(e){return this._spiltDistance[e]},e.setShadowMapTextureSize=function(e){e!==this._shadowMapTextureSize&&(this._shadowMapTextureSize=e,this._shadowPCFOffset.x=1/this._shadowMapTextureSize,this._shadowPCFOffset.y=1/this._shadowMapTextureSize,this._statesDirty=!0)},e.getShadowMapTextureSize=function(){return this._shadowMapTextureSize},e.beginRenderTarget=function(e){this._renderTarget[e].start()},e.endRenderTarget=function(e){this._renderTarget[e].end()},e.getRenderTarget=function(e){return this._renderTarget[e]},e.disposeAllRenderTarget=function(){for(var e=0,t=this._numberOfPSSM+1;ef?T.__VECTOR3__.y:f,T.__ADAPT_MATRIX__&&hn.transformV3ToV3(T.__VECTOR3__,T.__ADAPT_MATRIX__,T.__VECTOR3__),a[d]=T.__VECTOR3__.x,a[++d]=T.__VECTOR3__.y,a[++d]=T.__VECTOR3__.z,d++,this.calcVertextNormlUV(this._beginGridX+v,this._beginGridZ+p,h,_,m),a[d]=m.x,a[++d]=m.y,a[++d]=m.z,a[++d]=(n+v)/T.CHUNK_GRID_NUM,a[++d]=(i+p)/T.CHUNK_GRID_NUM,a[++d]=this._beginGridX+v,a[++d]=this._beginGridZ+p,d++;this._sizeOfY=new ln(c-1,f+1),this.calcLODErrors(l,h,_),this.calcOriginalBoudingBoxAndSphere()},e.calcSkirtVertextBuffer=function(e,t,n,i,r,a,o,s,l,h,_){this._gridSize=r,this._beginGridX=e*T.CHUNK_GRID_NUM+n,this._beginGridZ=t*T.CHUNK_GRID_NUM+i;for(var u=o*s,d=0,c=0,f=T.LEAF_GRID_NUM+1,m=new hn,p=0,E=0,d=0;d<2;d++)for(c=0;cr&&(e=this._currentLODLevel)}for(var a=e;1<=a;a--)if(_r.LOD_DISTANCE_FACTOR*this._LODError[a]/r*tT._maxLODLevel&&(e=T._maxLODLevel);for(var t=T.LEAF_GRID_NUM+1,n=0,i=null,e=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e),i=new Uint16Array(e*e*6),r=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/e,a=0;aT._maxLODLevel&&(e=T._maxLODLevel);for(var t=T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM*(T.CHUNK_GRID_NUM/T.LEAF_GRID_NUM)*T.LEAF_PLANE_VERTEXT_COUNT,n=T.LEAF_GRID_NUM+1,i=0,r=null,e=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/Math.pow(2,e),r=new Uint16Array(4*e*6),a=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM/e,o=0;o<4;o++){for(var s=0;s-Number.MIN_VALUE&&n=Math.PI&&e[2]>=Math.PI&&(e[1]=0,e[2]=0,e[0]=Math.PI-e[0]),t[0]=e[1],t[1]=e[0],t[2]=e[2]},Fn.arcTanAngle=function(e,t){return 0==e?1==t?Math.PI/2:-Math.PI/2:0t._batchIndexStart},e._addCombineBatchRenderObjTest=function(e){var t=e.renderObj._vertexCount;return!(65535<(0t){this._realTimeCurrentFrameIndexes[s]=h-1;break}h++}h===u&&(this._realTimeCurrentFrameIndexes[s]=u-1);var d=0,c=0,f=(f=n[s])||(n[s]=new Float32Array(l.keyFrameWidth)),m=_[this._realTimeCurrentFrameIndexes[s]];if(m)if(m.next){var p=m.duration,E=NaN,E=0!==p?(t-m.startTime)/p:0;this._hermiteInterpolate(m,E,p,f)}else for(var v=m.data,d=0,c=f.length;d=r)return this._onAnimationStop(),this._setPlayParamsWhenStop(r,t),void this.event("stopped");if(n+=this._currentTime,0=this._bufferMaxParticles&&(this._firstActiveElement=0)}},t._freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){var e=this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*this._vertexStride+this._timeIndex];if(this.isPerformanceMode&&e<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this._bufferMaxParticles&&(this._firstRetiredElement=0)}},t._burst=function(e,t){for(var n=0,i=this._emission._bursts,r=i.length;this._burstsIndexthis.duration){if(!this.looping){for(r=Math.min(this.maxParticles-this.aliveParticleCount,r),n=0;n=this._bufferMaxParticles?0:i)===this._firstRetiredElement)return!1;if(ce.create(this,this._ownerRender,this._owner.transform),this._currentTime-n>=ce.startLifeTime)return!0;var r,a=NaN,o=NaN,s=NaN,l=NaN,h=NaN,_=NaN,u=NaN,d=this._velocityOverLifetime&&this._velocityOverLifetime.enbale;d&&(2===(r=this._velocityOverLifetime.velocity.type)||3===r)?this.autoRandomSeed?(a=Math.random(),o=Math.random(),s=Math.random()):(this._rand.seed=this._randomSeeds[9],a=this._rand.getFloat(),o=this._rand.getFloat(),s=this._rand.getFloat(),this._randomSeeds[9]=this._rand.seed):d=!1;var c=this._colorOverLifetime&&this._colorOverLifetime.enbale;c&&3===this._colorOverLifetime.color.type?this.autoRandomSeed?l=Math.random():(this._rand.seed=this._randomSeeds[10],l=this._rand.getFloat(),this._randomSeeds[10]=this._rand.seed):c=!1;var f=this._sizeOverLifetime&&this._sizeOverLifetime.enbale;f&&3===this._sizeOverLifetime.size.type?this.autoRandomSeed?h=Math.random():(this._rand.seed=this._randomSeeds[11],h=this._rand.getFloat(),this._randomSeeds[11]=this._rand.seed):f=!1;var m=this._rotationOverLifetime&&this._rotationOverLifetime.enbale;m&&(2===(g=this._rotationOverLifetime.angularVelocity.type)||3===g)?this.autoRandomSeed?_=Math.random():(this._rand.seed=this._randomSeeds[12],_=this._rand.getFloat(),this._randomSeeds[12]=this._rand.seed):m=!1;var p=this._textureSheetAnimation&&this._textureSheetAnimation.enable;p&&3===this._textureSheetAnimation.frame.type?this.autoRandomSeed?u=Math.random():(this._rand.seed=this._randomSeeds[15],u=this._rand.getFloat(),this._randomSeeds[15]=this._rand.seed):p=!1;var E,v,g=this._firstFreeElement*this._floatCountPerVertex*this._vertexStride,T=ce.startUVInfo[0],S=ce.startUVInfo[1],D=ce.startUVInfo[2],x=ce.startUVInfo[3],M=e.elements,R=t.elements,I=0,A=0,C=0,y=0,O=0,N=this._ownerRender;4===N.renderMode?(E=(t=N.mesh._vertexBuffers[0]).getData(),A=(v=t.vertexDeclaration).getVertexElementByUsage(0).offset/4,C=(t=v.getVertexElementByUsage(1))?t.offset/4:-1,y=(t=v.getVertexElementByUsage(2))?t.offset/4:-1,I=v.vertexStride/4,O=0):(this._vertices[2+g]=D,this._vertices[3+g]=x+S,v=g+this._floatCountPerVertex,this._vertices[v+2]=D+T,this._vertices[v+3]=x+S,v=v+this._floatCountPerVertex,this._vertices[v+2]=D+T,this._vertices[v+3]=x,v=v+this._floatCountPerVertex,this._vertices[v+2]=D,this._vertices[v+3]=x);for(var V=g,L=g+this._floatCountPerVertex*this._vertexStride;Vthis.duration?this.duration:this._emissionTime}),_(0,t,"aliveParticleCount",function(){return this._firstNewElement>=this._firstRetiredElement?this._firstNewElement-this._firstRetiredElement:this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement}),_(0,t,"isPlaying",function(){return this._isPlaying}),_(0,t,"isPaused",function(){return this._isPaused}),_(0,t,"startLifetimeType",function(){return this._startLifetimeType},function(e){var t=0,n=0;switch(this.startLifetimeType){case 0:this._maxStartLifetime=this.startLifetimeConstant;break;case 1:this._maxStartLifetime=-Number.MAX_VALUE;for(var i=i,t=0,n=i.gradientCount;t=this.DominoRenderElementMaxDominoCount&&(i=this.addDominoRenderElement(),this.event("dominofilterchange",[i,this._dominoRenderElements[i]])),(r=this._dominoRenderElements[this._dominoRenderElements.length-1]).addDomino(e,t,n)},e.updateDomino=function(e,t,n,i){void 0===t&&(t=hn.ZERO),void 0===n&&(n=rn.DEFAULT),void 0===i&&(i=hn.ZERO);var r=Math.floor(e/this.DominoRenderElementMaxDominoCount),e=e%this.DominoRenderElementMaxDominoCount;this._dominoRenderElements[r].updateDomino(e,t,n,i)},e.updateDominos=function(e,t,n){var i,r=e+t-1,a=Math.floor(e/this.DominoRenderElementMaxDominoCount),o=Math.floor(r/this.DominoRenderElementMaxDominoCount),s=e%this.DominoRenderElementMaxDominoCount,l=r%this.DominoRenderElementMaxDominoCount,h=o-a+1;if(h<=1)(i=this._dominoRenderElements[a]).updateDominos(s,t,n);else for(var _,u=0,d=0,c=0,f=0;f=this.maxSegments&&(this._firstActiveElement=0)}},n._freeRetiredGlitter=function(){for(var e=2*this._floatCountPerVertex;this._firstRetiredElement!=this._firstActiveElement;){if(this._drawCounter-this._vertices[this._firstRetiredElement*e+5]<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this.maxSegments&&(this._firstRetiredElement=0)}},n._calcVelocity=function(e,t,n){hn.subtract(e,t,n),hn.scale(n,.5,n)},n._addNewGlitterSegementToVertexBuffer=function(){var e=0;this._firstActiveElement=this.maxSegments&&(i=0,e.cloneTo(this._lastPatchAddPos0),t.cloneTo(this._lastPatchAddPos1),this._lastPatchAddTime=n,this._needPatch=!0),i===this._firstRetiredElement&&console.log("GlitterTemplet:current segement count have large than maxSegments,please adjust the value of maxSegments or add Glitter Vertex Frequency.");for(var r=e.elements,a=t.elements,o=0,s=this._firstFreeElement*this._floatCountPerVertex*2,o=0;o<3;o++)this._vertices[s+o]=r[o];this._vertices[3+s]=0,this._vertices[4+s]=0,this._vertices[5+s]=n;var l=s+this._floatCountPerVertex;for(o=0;o<3;o++)this._vertices[l+o]=a[o];this._vertices[l+3]=0,this._vertices[l+4]=1,this._vertices[l+5]=n,this._firstFreeElement=i},n._update=function(e){this._currentTime+=e/1e3,this._retireActiveGlitter(),this._freeRetiredGlitter(),this._firstActiveElement==this._firstFreeElement&&(this._currentTime=0),this._firstRetiredElement==this._firstActiveElement&&(this._drawCounter=0),this._updateTextureCoordinates()},n._beforeRender=function(e){return this._firstNewElement!=this._firstFreeElement&&this._addNewGlitterSegementToVertexBuffer(),this._drawCounter++,this._firstActiveElement!=this._firstFreeElement&&(this._vertexBuffer.bindWithIndexBuffer(null),!0)},n._render=function(e){var t=0,n=N.mainContext;this._firstActiveElemente.y?this._leafs[t]._sizeOfY:e).y;var n=new hn(this._chunkOffsetX*Tn.CHUNK_GRID_NUM*this._gridSize,e.x,this._chunkOffsetZ*Tn.CHUNK_GRID_NUM*this._gridSize),i=new hn((this._chunkOffsetX+1)*Tn.CHUNK_GRID_NUM*this._gridSize,e.y,(this._chunkOffsetZ+1)*Tn.CHUNK_GRID_NUM*this._gridSize);Tn.__ADAPT_MATRIX__&&(hn.transformV3ToV3(n,Tn.__ADAPT_MATRIX__,n),hn.transformV3ToV3(i,Tn.__ADAPT_MATRIX__,i)),this._boundingBox=new kt(n,i);var r=new hn;hn.subtract(i,n,r),hn.scale(r,.5,r);i=new hn;hn.add(n,r,i),this._boundingSphere=new Yt(i,hn.scalarLength(r)),this._boundingBoxCorners=v(8,null),this._boundingBox.getCorners(this._boundingBoxCorners)},t.calcLeafBoudingBox=function(e){for(var t=0;t=n.y&&n.x>=n.z?n.x:n.y>=n.z?n.y:n.z,hn.transformCoordinate(e.center,t.worldMatrix,this._boundingSphere.center),this._boundingSphere.radius=e.radius*i,r.calcLeafBoudingSphere(t.worldMatrix,i))},n._calculateBoundingBox=function(){var e=this._terrainSprite3DOwner.terrainFilter;if(null==e)this._boundingBox.toDefault();else{for(var t=this._terrainSprite3DOwner.transform.worldMatrix,n=e._boundingBoxCorners,i=0;i<8;i++)hn.transformCoordinate(n[i],t,Gn._tempBoundBoxCorners[i]);kt.createfromPoints(Gn._tempBoundBoxCorners,this._boundingBox),e.calcLeafBoudingBox(t)}},n._renderUpdate=function(e){this._setShaderValueMatrix4x4(0,this._owner.transform.worldMatrix);e=this._owner.getProjectionViewWorldMatrix(e);return this._setShaderValueMatrix4x4(1,e),!0},n._destroy=function(){e.prototype._destroy.call(this),this._terrainSprite3DOwner=null},t}(Gn),Ai=(function(e){function t(e){t.__super.call(this,e)}p(t,"laya.d3.water.WaterRender",e);var n=t.prototype;n._calculateBoundingSphere=function(){},n._calculateBoundingBox=function(){},n._destroy=function(){e.prototype._destroy.call(this)}}(Gn),function(t){function i(){this._time=0,this._enableLightCount=3,this._customRenderQueneIndex=11,this.enableLight=!0,i.__super.call(this),this._renderState=new ve,this._lights=[],this._quenes=[],this._cameraPool=[],this._renderableSprite3Ds=[],this.__loaded=!0,this._lightmaps=[],this._shaderValues=new vn,this.parallelSplitShadowMaps=[],this._dynamicBatchManager=new Ue,this._cullingRenders=[],this._cullingRendersLength=0,this.enableFog=!1,this.fogStart=300,this.fogRange=1e3,this.fogColor=new hn(.7,.7,.7),this.ambientColor=new hn(.212,.227,.259),N.shaderHighPrecision&&this.addShaderDefine($n.SHADERDEFINE_HIGHPRECISION),this.on("display",this,this._display),this.on("undisplay",this,this._unDisplay),this._componentsMap=[],this._typeComponentsIndices=[],this._components=[]}p(i,"laya.d3.core.scene.Scene",t);var e=i.prototype;return S.imps(e,{"laya.webgl.submit.ISubmit":!0,"laya.resource.ICreateResource":!0}),e._setUrl=function(e){this._url=e},e._getGroup=function(){return this._group},e._setGroup=function(e){this._group=e},e._display=function(){S.stage._scenes.push(this),S.stage._scenes.sort(i._sortScenes);for(var e=0,t=this._childs.length;e=this._enableLightCount);i++);},e._updateChilds=function(e){for(var t=0,n=this._childs.length;t>>16))<<1|(2863311530&e)>>>1))<<2|(3435973836&e)>>>2))<<4|(4042322160&e)>>>4))<<8|(4278255360&e)>>>8,2.3283064365386963e-10*t[0]},e.createHammersleyTex=function(e,t){for(var n=new Uint8Array(e*t*4),i=0,r=0,r=0;r 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.r) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.r * specTexColorG;\n\talbedoColor.g = albedoTextureColor.g > 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.g) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.g * specTexColorG;\n\talbedoColor.b = albedoTextureColor.b > 0.5 ? 1.0 - 2.0 * (1.0 - albedoTextureColor.b) * (1.0 - specTexColorG) : 2.0 * albedoTextureColor.b * specTexColorG;\n\t\n\talbedoColor = clamp(albedoColor, 0.0, 1.0);\n\t\n\tfloat nl = max(dot(normal, -lightDir), 0.0);\n\t\n\tfloat shadowValue = nl + specTexColorG - 0.5;\n\tfloat shadow = step(shadowValue, u_ShadowRange);\n\tif(u_ShadowRange > (shadowValue + 0.01))\n\t\tshadow = 1.0;\n\telse if(u_ShadowRange < (shadowValue - 0.01))\n\t\tshadow = 0.0;\n\telse\n\t\tshadow = (u_ShadowRange - (shadowValue - 0.01)) / 0.02;\n\t\t\n\tshadow = clamp(shadow, 0.0, 1.0);\n\t\n\t//specularTextureColor.r 影响高光范围\n\tfloat specular = step(u_SpecularRange, clamp(pow(nl, specularTextureColor.r), 0.0, 1.0));\n\t//specularTextureColor.b 影响高光强度\n\tspecular = step(0.1, specular * specularTextureColor.b);\n\t\n\tvec3 albedoAreaColor = (1.0 - shadow) * albedoColor;\n\tvec3 shadowAreaColor = shadow * albedoColor * u_ShadowColor.rgb * u_ShadowIntensity;\n\tvec3 speculAreaColor = (1.0 - shadow) * albedoColor * u_SpecularIntensity * specular;\n\t\n\tvec3 finalColor = albedoAreaColor + speculAreaColor + shadowAreaColor;\n\t\n\tgl_FragColor = vec4(finalColor, 1.0);\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],u_AlbedoTexture:[1,1],u_SpecularTexture:[2,1],u_ShadowColor:[5,1],u_ShadowRange:[6,1],u_ShadowIntensity:[7,1],u_SpecularRange:[8,1],u_SpecularIntensity:[9,1],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4]});laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_ALBEDOTEXTURE=e.registerMaterialDefine("ALBEDOTEXTURE"),laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_SPECULARTEXTURE=e.registerMaterialDefine("SPECULARTEXTURE"),laya.d3.extension.cartoonRender.CartoonMaterial.SHADERDEFINE_TILINGOFFSET=e.registerMaterialDefine("TILINGOFFSET")},e.ALBEDOTEXTURE=1,e.SPECULARTEXTURE=2,e.TILINGOFFSET=4,e.SHADOWCOLOR=5,e.SHADOWRANGE=6,e.SHADOWINTENSITY=7,e.SPECULARRANGE=8,e.SPECULARINTENSITY=9,e.SHADERDEFINE_ALBEDOTEXTURE=0,e.SHADERDEFINE_SPECULARTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("OutlineShader"),this._setNumber(2,.01581197),this._setNumber(3,1)}p(e,"laya.d3.extension.cartoonRender.OutlineMaterial",ri);var t=e.prototype;_(0,t,"outlineTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE):this._removeShaderDefine(laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE),this._setTexture(1,e)}),_(0,t,"outlineWidth",function(){return this._getNumber(2)},function(e){e=Math.max(0,Math.min(.05,e)),this._setNumber(2,e)}),_(0,t,"outlineLightness",function(){return this._getNumber(3)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(3,e)}),e.__init__=function(){e.SHADERDEFINE_OUTLINETEXTURE=e.shaderDefines.registerDefine("OUTLINETEXTURE")},e.initShader=function(){var e=Vi.nameKey.add("OutlineShader"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_OutlineWidth;\n\nvarying vec2 v_Texcoord0;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t\n\tvec4 position = vec4(a_Position.xyz + a_Normal * u_OutlineWidth, 1.0);\n\tgl_Position = u_MvpMatrix * position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\n\nvarying vec2 v_Texcoord0;\n\n#ifdef OUTLINETEXTURE\n\tuniform sampler2D u_OutlineTexture;\n#endif\nuniform float u_OutlineLightness;\n\nvoid main()\n{\n\tvec4 outlineTextureColor = vec4(1.0);\n\t#ifdef OUTLINETEXTURE\n\t\toutlineTextureColor = texture2D(u_OutlineTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec3 finalColor = outlineTextureColor.rgb * u_OutlineLightness;\n\t\n\tgl_FragColor = vec4(finalColor,0.0);\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_OutlineTexture:[1,1],u_OutlineWidth:[2,1],u_OutlineLightness:[3,1]});laya.d3.extension.cartoonRender.OutlineMaterial.SHADERDEFINE_OUTLINETEXTURE=e.registerMaterialDefine("OUTLINETEXTURE")},e.OUTLINETEXTURE=1,e.OUTLINEWIDTH=2,e.OUTLINELIGHTNESS=3,e.SHADERDEFINE_OUTLINETEXTURE=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),p(ki,"laya.d3.extension.domino.DominoMaterial",ri),ki.__init__=function(){},ki.initShader=function(){var e=Vi.nameKey.add("DominoShader");$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\nvarying vec3 v_PositionWorld;\nvarying vec3 v_Normal;\nvarying vec3 v_ViewDir;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\tv_Color = a_Color;\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n\t\n\tv_Normal = mat3(u_WorldMat) * a_Normal;\n\tv_PositionWorld = (u_WorldMat * a_Position).xyz;\n\tv_ViewDir = u_CameraPos - v_PositionWorld;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nstruct DirectionLight\n{\n\tvec3 Color;\n\tvec3 Direction;\n};\nuniform DirectionLight u_DirectionLight;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\nvarying vec3 v_ViewDir; \nvarying vec3 v_Normal;\n\nvoid LayaAirBlinnPhongDiectionLight (in vec3 normal, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor)\n{\n\tvec3 lightVec = normalize(light.Direction);\n\t\n\t//mediump vec3 h = normalize(viewDir-light.Direction);\n\t//float nh = max (0.0, dot (h,normal));\n\t\n lowp float ln = max (0.0, dot (-lightVec,normal));\n\tdiffuseColor = light.Color * ln;\n}\n\nvoid main()\n{\n\tvec3 diffuseColor;\n\tvec3 normal = normalize(v_Normal);\n\tvec3 viewDir = normalize(v_ViewDir);\n\tLayaAirBlinnPhongDiectionLight(normal, viewDir, u_DirectionLight, diffuseColor);\n\t\n\tgl_FragColor.xyz = diffuseColor * v_Color.xyz * 2.0;\n}\n\n",{a_Position:0,a_Normal:3,a_Color:1},{u_MvpMatrix:[1,2],u_WorldMat:[0,2],u_CameraPos:[0,3],"u_DirectionLight.Direction":[3,4],"u_DirectionLight.Color":[4,4]})},l(ki,["defaultMaterial",function(){return this.defaultMaterial=new ki},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),ki);function ki(){ki.__super.call(this),this.setShaderName("DominoShader")}var Xi=function(){function t(){t.__super.call(this),this.setShaderName("LineShader"),this._setColor(2,new _n(1,1,1,1)),this.cull=0}p(t,"laya.d3.extension.lineRender.LineMaterial",ri);var e=t.prototype;return _(0,e,"tintColor",function(){return this._getColor(2)},function(e){this._setColor(2,e)}),_(0,e,"diffuseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE):this._removeShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE),this._setTexture(1,e)}),_(0,e,"tilingOffset",function(){return this._getColor(3)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_TILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_TILINGOFFSET),this._setColor(3,e)}),t.__init__=function(){t.SHADERDEFINE_DIFFUSETEXTURE=t.shaderDefines.registerDefine("DIFFUSETEXTURE"),t.SHADERDEFINE_TILINGOFFSET=t.shaderDefines.registerDefine("TILINGOFFSET")},t.load=function(e){return S.loader.create(e,null,null,t)},t.initShader=function(){var e=Vi.nameKey.add("LineShader"),e=$n.add(e,"attribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0X1;\nattribute float a_Texcoord0Y;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_VMatrix;\nuniform mat4 u_PMatrix;\n\nuniform vec4 u_TilingOffset;\n\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec4 v_Color;\nvarying vec2 v_Texcoord0;\n\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\n{\n\tfloat t2 = t * t;\n\tfloat t3 = t2 * t;\n\tfloat a = 2.0 * t3 - 3.0 * t2 + 1.0;\n\tfloat b = t3 - 2.0 * t2 + t;\n\tfloat c = t3 - t2;\n\tfloat d = -2.0 * t3 + 3.0 * t2;\n\treturn a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\n}\n\nfloat getCurWidth(in float normalizeTime)\n{\n\tif(normalizeTime == 0.0){\n\t\treturn u_WidthCurve[0].w;\n\t}\n\telse if(normalizeTime >= 1.0){\n\t\treturn u_WidthCurve[u_WidthCurveKeyLength - 1].w;\n\t}\n\telse{\n\t\tfor(int i = 0; i < 10; i ++ )\n\t\t{\n\t\t\tif(normalizeTime == u_WidthCurve[i].x)\n\t\t\t{\n\t\t\t\treturn u_WidthCurve[i].w;\n\t\t\t}\n\t\t\t\n\t\t\tvec4 lastFrame = u_WidthCurve[i];\n\t\t\tvec4 nextFrame = u_WidthCurve[i + 1];\n\t\t\tif(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\n\t\t\t{\n\t\t\t\tfloat duration = nextFrame.x - lastFrame.x;\n\t\t\t\tfloat t = (normalizeTime - lastFrame.x) / duration;\n\t\t\t\tfloat outTangent = lastFrame.z;\n\t\t\t\tfloat inTangent = nextFrame.y;\n\t\t\t\tfloat value1 = lastFrame.w;\n\t\t\t\tfloat value2 = nextFrame.w;\n\t\t\t\treturn hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\n\t\t\t}\n\t\t}\t\n\t}\n}\t\n\nvec4 getColorFromGradientByBlend(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tfloat colorKey = gradientColor.w;\n\t\tif(colorKey >= normalizeTime)\n\t\t{\n\t\t\tvec4 lastGradientColor = gradientColors[i-1];\n\t\t\tfloat lastColorKey = lastGradientColor.w;\n\t\t\tfloat age = (normalizeTime - lastColorKey) / (colorKey - lastColorKey);\n\t\t\tcolor.rgb = mix(gradientColors[i-1].xyz, gradientColor.xyz, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tfloat alphaKey = gradientAlpha.y;\n\t\tif(alphaKey >= normalizeTime)\n\t\t{\n\t\t\tvec2 lastGradientAlpha = gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey = lastGradientAlpha.y;\n\t\t\tfloat age = (normalizeTime - lastAlphaKey) / (alphaKey - lastAlphaKey);\n\t\t\tcolor.a = mix(lastGradientAlpha.x, gradientAlpha.x, age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvec4 getColorFromGradientByFixed(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n\tvec4 color;\n\tfor(int i = 0; i < 10; i++)\n\t{\n\t\tvec4 gradientColor = gradientColors[i];\n\t\tif(gradientColor.w >= normalizeTime)\n\t\t{\n\t\t\tcolor.rgb = gradientColor.xyz;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor(int i = 0; i < 10; i++)\n\t{\n\t\tvec2 gradientAlpha = gradientAlphas[i];\n\t\tif(gradientAlpha.y >= normalizeTime)\n\t\t{\n\t\t\tcolor.a = gradientAlpha.x;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn color;\n}\n\nvoid main()\n{\n\t#ifdef TEXTUREMODE_STRETCH\n\t\tv_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n\t#else\n\t\tv_Texcoord0 = vec2(a_Texcoord0X1, a_Texcoord0Y);\n\t#endif\n\t\n\t#ifdef TILINGOFFSET\n\t\tv_Texcoord0 = v_Texcoord0 * u_TilingOffset.xy + u_TilingOffset.zw;\n\t#endif\n\t\n\t#ifdef GRADIENTMODE_BLEND\n\t\tv_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, a_Texcoord0X);\n\t#else\n\t\tv_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, a_Texcoord0X);\n\t#endif\n\t\n\t#ifdef WORLDSPACE\n\t\tgl_Position = u_PMatrix * u_VMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(a_Texcoord0X),1.0);\n\t#else\n\t\tgl_Position = u_MvpMatrix * vec4(a_Position + a_OffsetVector * getCurWidth(a_Texcoord0X),1.0);\n\t#endif\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nuniform sampler2D u_MainTexture;\nuniform vec4 u_MainColor;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nvoid main()\n{\n\tvec4 color = 2.0 * u_MainColor * v_Color;\n\t#ifdef DIFFUSETEXTURE\n\t\tvec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t\tcolor *= mainTextureColor;\n\t#endif\n\tgl_FragColor = color;\n}\n\n",{a_Position:0,a_OffsetVector:41,a_Texcoord0X:38,a_Texcoord0X1:39,a_Texcoord0Y:40},{u_MvpMatrix:[1,2],u_VMatrix:[1,3],u_PMatrix:[2,3],u_TilingOffset:[3,1],u_MainTexture:[1,1],u_MainColor:[2,1],u_WidthCurve:[3,2],u_WidthCurveKeyLength:[4,2],u_GradientColorkey:[5,2],u_GradientAlphakey:[6,2]});laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_DIFFUSETEXTURE=e.registerMaterialDefine("DIFFUSETEXTURE"),laya.d3.extension.lineRender.LineMaterial.SHADERDEFINE_TILINGOFFSET=e.registerMaterialDefine("TILINGOFFSET"),vr.SHADERDEFINE_GRADIENTMODE_BLEND=e.registerSpriteDefine("GRADIENTMODE_BLEND"),vr.SHADERDEFINE_TEXTUREMODE_STRETCH=e.registerSpriteDefine("TEXTUREMODE_STRETCH"),vr.SHADERDEFINE_WORLDSPACE=e.registerSpriteDefine("WORLDSPACE")},t.SHADERDEFINE_DIFFUSETEXTURE=0,t.SHADERDEFINE_TILINGOFFSET=0,t.DIFFUSETEXTURE=1,t.TINTCOLOR=2,t.TILINGOFFSET=3,l(t,["defaultMaterial",function(){return this.defaultMaterial=new t},"shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),t}(),Yi=(function(){function e(){e.__super.call(this),this.setShaderName("Dissolve"),this._setColor(9,new _n(1,1,1,1)),this._setNumber(7,0),this._setNumber(8,5)}p(e,"laya.d3.extension.lulingmen.DissolveMaterial",ri);var t=e.prototype;_(0,t,"albedoColor",function(){return this._getColor(9)},function(e){this._setColor(9,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"dissolveSpeed",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),_(0,t,"tilingOffset",function(){return this._getColor(4)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET),this._setColor(4,e)}),_(0,t,"dissolveTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE),this._setTexture(2,e)}),_(0,t,"maskTexture",function(){return this._getTexture(3)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE),this._setTexture(3,e)}),_(0,t,"dissolveTilingOffset",function(){return this._getColor(5)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET),this._setColor(5,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(6)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET):this._removeShaderDefine(laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET),this._setColor(6,e)}),_(0,t,"dissolve",function(){return this._getNumber(7)},function(e){this._setNumber(7,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_DISSOLVETEXTURE=e.shaderDefines.registerDefine("DISSOLVETEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_MAINTILINGOFFSET=e.shaderDefines.registerDefine("MAINTILINGOFFSET"),e.SHADERDEFINE_DISSOLVETILINGOFFSET=e.shaderDefines.registerDefine("DISSOLVETILINGOFFSET"),e.SHADERDEFINE_MASKTILINGOFFSET=e.shaderDefines.registerDefine("MASKTILINGOFFSET")},e.initShader=function(){var e=Vi.nameKey.add("Dissolve"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nuniform vec4 u_MainTilingOffset;\nuniform vec4 u_DissolveTilingOffset;\nuniform vec4 u_MaskTilingOffset;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec2 v_Texcoord2;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef MAINTILINGOFFSET\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_MainTilingOffset.xy) + u_MainTilingOffset.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef DISSOLVETILINGOFFSET\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_DissolveTilingOffset.xy) + u_DissolveTilingOffset.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Texcoord2 = a_Texcoord0;\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec2 v_Texcoord2;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef DISSOLVETEXTURE\n\tuniform sampler2D u_DissolveTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform float u_Dissolve;\nuniform float u_DissolveSpeed;\n\nvoid main()\n{\n\tvec4 mainColor = u_BaseColor;\n\tmainColor.a = 1.0;\n\t#ifdef MAINTEXTURE\n\t\tmainColor *= texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 dissolveColor = vec4(1.0);\n\t#ifdef DISSOLVETEXTURE\n\t\tdissolveColor = texture2D(u_DissolveTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 maskColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskColor = texture2D(u_MaskTexture, v_Texcoord2);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainColor, maskColor);\n\tif(dissolveColor.a <= u_Dissolve){\n\t\tfloat alpha = clamp(outColor.a - u_Dissolve * 2.0 + dissolveColor.a, 0.0, 1.0);\n\t\talpha = pow(alpha, u_DissolveSpeed);\n\t\toutColor.a = alpha;\n\t}\n\t\n\tgl_FragColor = outColor;\n}\n",{a_Position:0,a_Normal:3,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_MainTexture:[1,1],u_DissolveTexture:[2,1],u_MaskTexture:[3,1],u_BaseColor:[9,1],u_MainTilingOffset:[4,1],u_DissolveTilingOffset:[5,1],u_MaskTilingOffset:[6,1],u_Dissolve:[7,1],u_DissolveSpeed:[8,1]});laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETEXTURE=e.registerMaterialDefine("DISSOLVETEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MAINTILINGOFFSET=e.registerMaterialDefine("MAINTILINGOFFSET"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_DISSOLVETILINGOFFSET=e.registerMaterialDefine("DISSOLVETILINGOFFSET"),laya.d3.extension.lulingmen.DissolveMaterial.SHADERDEFINE_MASKTILINGOFFSET=e.registerMaterialDefine("MASKTILINGOFFSET")},e.MAINTEXTURE=1,e.DISSOLVETEXTURE=2,e.MASKTEXTURE=3,e.MAINTILINGOFFSET=4,e.DISSOLVETILINGOFFSET=5,e.MASKTILINGOFFSET=6,e.DISSOLVE=7,e.DISSOLVESPEED=8,e.BASECOLOR=9,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_DISSOLVETEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_MAINTILINGOFFSET=0,e.SHADERDEFINE_DISSOLVETILINGOFFSET=0,e.SHADERDEFINE_MASKTILINGOFFSET=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("MeshParticle"),this._setColor(3,new _n(1,1,1,1)),this._setColor(4,new _n(1,1,1,1)),this._setNumber(5,1),this._setNumber(6,1)}p(e,"laya.d3.extension.lulingmen.MeshParticleMaterial",ri);var t=e.prototype;return _(0,t,"alpha",function(){return this._getNumber(6)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(6,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"maskTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE),this._setTexture(2,e)}),_(0,t,"albedoColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"intensity",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"alphaColor",function(){return this._getColor(4)},function(e){this._setColor(4,e)}),_(0,t,"tilingOffset",function(){return this._getColor(7)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1),this._setColor(7,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(8)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2),this._setColor(8,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("MeshParticle"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\n\nuniform vec4 u_TilingOffset1;\nuniform vec4 u_TilingOffset2;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET1\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_TilingOffset1.xy) + u_TilingOffset1.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef TILINGOFFSET2\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_TilingOffset2.xy) + u_TilingOffset2.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Color = vec4(1.0);\n\t#ifdef COLOR\n\t\tv_Color = a_Color;\n\t#endif\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform vec4 u_AlphaColor;\nuniform float u_Instensity;\nuniform float u_Alpha;\n\nvoid main()\n{\n\tvec4 mainTextureColor = vec4(1.0);\n\t#ifdef MAINTEXTURE\n\t\tmainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 maskTextureColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskTextureColor = texture2D(u_MaskTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainTextureColor, maskTextureColor);\n\t\n\tgl_FragColor = 2.0 * outColor * u_BaseColor * u_AlphaColor * u_Instensity * v_Color;\n\tgl_FragColor.a *= u_Alpha;\n}\n",{a_Position:0,a_Normal:3,a_Color:1,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_MainTexture:[1,1],u_MaskTexture:[2,1],u_BaseColor:[3,1],u_AlphaColor:[4,1],u_Instensity:[5,1],u_Alpha:[6,1],u_TilingOffset1:[7,1],u_TilingOffset2:[8,1]});laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),laya.d3.extension.lulingmen.MeshParticleMaterial.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2")},e.MAINTEXTURE=1,e.MASKTEXTURE=2,e.BASECOLOR=3,e.ALPHACOLOR=4,e.INTENSITY=5,e.ALPHA=6,e.TILINGOFFSET1=7,e.TILINGOFFSET2=8,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}]),e}()),Zi=(function(){function e(){e.__super.call(this),this.setShaderName("Particle"),this._setColor(3,new _n(1,1,1,1)),this._setColor(4,new _n(1,1,1,1)),this._setNumber(5,1),this._setNumber(6,1)}p(e,"laya.d3.extension.lulingmen.ParticleMaterial",ri);var t=e.prototype;_(0,t,"alpha",function(){return this._getNumber(6)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(6,e)}),_(0,t,"tintColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"mainTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(Yi.SHADERDEFINE_MAINTEXTURE):this._removeShaderDefine(Yi.SHADERDEFINE_MAINTEXTURE),this._setTexture(1,e)}),_(0,t,"maskTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(Yi.SHADERDEFINE_MASKTEXTURE):this._removeShaderDefine(Yi.SHADERDEFINE_MASKTEXTURE),this._setTexture(2,e)}),_(0,t,"intensity",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"alphaColor",function(){return this._getColor(4)},function(e){this._setColor(4,e)}),_(0,t,"tilingOffset",function(){return this._getColor(7)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET1),this._setColor(7,e)}),_(0,t,"maskTilingOffset",function(){return this._getColor(8)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(Yi.SHADERDEFINE_TILINGOFFSET2),this._setColor(8,e)}),e.__init__=function(){e.SHADERDEFINE_MAINTEXTURE=e.shaderDefines.registerDefine("MAINTEXTURE"),e.SHADERDEFINE_MASKTEXTURE=e.shaderDefines.registerDefine("MASKTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("Particle"),e=$n.add(e,"#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\tattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERMODE_MESH\n\tattribute vec3 a_MeshPosition;\n\tattribute vec4 a_MeshColor;\n\tattribute vec2 a_MeshTextureCoordinate;\n\tvarying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n attribute vec4 a_Random0;\n#endif\n#if defined(TEXTURESHEETANIMATIONRANDOMCURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\n#ifdef MAINTEXTURE\n\tvarying vec2 v_TextureCoordinate;\n\t#ifdef TILINGOFFSET1\n\t\tuniform vec4 u_TilingOffset1;\n\t#endif\n#endif\n\n#ifdef MASKTEXTURE\n\t#ifdef TILINGOFFSET2\n\t\tuniform vec4 u_TilingOffset2;\n\t#endif\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform vec4 u_WorldRotation;\nuniform bool u_ThreeDStartRotation;\nuniform int u_ScalingMode;\nuniform vec3 u_PositionScale;\nuniform vec3 u_SizeScale;\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\n#ifdef STRETCHEDBILLBOARD\n\tuniform vec3 u_CameraPosition;\n#endif\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform float u_StretchedBillboardLengthScale;\nuniform float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n uniform int u_VOLSpaceType;\n#endif\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)\n uniform vec3 u_VOLVelocityConst;\n#endif\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\n#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n uniform vec3 u_VOLVelocityConstMax;\n#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\n#endif\n\n#ifdef COLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n#ifdef RANDOMCOLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n\n#if defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVES\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n#endif\n#if defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\n#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\n#endif\n\n\n#ifdef ROTATIONOVERLIFETIME\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n uniform float u_ROLAngularVelocityConst;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n uniform float u_ROLAngularVelocityConstMax;\n #endif\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n #endif\n#endif\n#ifdef ROTATIONOVERLIFETIMESEPERATE\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\n #endif\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_ROLAngularVelocityGradientX[4];\n uniform vec2 u_ROLAngularVelocityGradientY[4];\n uniform vec2 u_ROLAngularVelocityGradientZ[4];\n\tuniform vec2 u_ROLAngularVelocityGradientW[4];\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];\n\tuniform vec2 u_ROLAngularVelocityGradientMaxW[4];\n #endif\n#endif\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\n uniform float u_TSACycles;\n uniform vec2 u_TSASubUVLength;\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\n#endif\n#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\n#ifdef FOG\n\tvarying vec3 v_PositionWorld;\n#endif\n\nvec3 rotationByEuler(in vec3 vector,in vec3 rot)\n{\n\tfloat halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n\tfloat halfYaw = rot.y * 0.5;\n\n\tfloat sinRoll = sin(halfRoll);\n\tfloat cosRoll = cos(halfRoll);\n\tfloat sinPitch = sin(halfPitch);\n\tfloat cosPitch = cos(halfPitch);\n\tfloat sinYaw = sin(halfYaw);\n\tfloat cosYaw = cos(halfYaw);\n\n\tfloat quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n\tfloat quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n\tfloat quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\n\tfloat quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\n\t\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\t\n\tfloat x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n\tfloat xx = quaX * x;\n float xy = quaX * y;\n\tfloat xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n\t\n}\n\n//假定axis已经归一化\nvec3 rotationByAxis(in vec3 vector,in vec3 axis, in float angle)\n{\n\tfloat halfAngle = angle * 0.5;\n\tfloat sin = sin(halfAngle);\n\t\n\tfloat quaX = axis.x * sin;\n\tfloat quaY = axis.y * sin;\n\tfloat quaZ = axis.z * sin;\n\tfloat quaW = cos(halfAngle);\n\t\n\t//vec4 q=vec4(quaX,quaY,quaZ,quaW);\n\t//vec3 temp = cross(q.xyz, vector) + q.w * vector;\n\t//return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n\t\n\tfloat x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n\tfloat xx = quaX * x;\n float xy = quaX * y;\n\tfloat xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n\t\n}\n\nvec3 rotationByQuaternions(in vec3 v,in vec4 q) \n{\n\treturn v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\n \n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat curValue;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\tcurValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn curValue;\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n\tfloat totalValue=0.0;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientNumber=gradientNumbers[i];\n\t\tfloat key=gradientNumber.x;\n\t\tvec2 lastGradientNumber=gradientNumbers[i-1];\n\t\tfloat lastValue=lastGradientNumber.y;\n\t\t\n\t\tif(key>=normalizedAge){\n\t\t\tfloat lastKey=lastGradientNumber.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\ttotalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\n\t\t\tbreak;\n\t\t}\n\t\telse{\n\t\t\ttotalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\n\t\t}\n\t}\n\treturn totalValue;\n}\n#endif\n\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n\tvec4 overTimeColor;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientAlpha=gradientAlphas[i];\n\t\tfloat alphaKey=gradientAlpha.x;\n\t\tif(alphaKey>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientAlpha=gradientAlphas[i-1];\n\t\t\tfloat lastAlphaKey=lastGradientAlpha.x;\n\t\t\tfloat age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n\t\t\toverTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec4 gradientColor=gradientColors[i];\n\t\tfloat colorKey=gradientColor.x;\n\t\tif(colorKey>=normalizedAge)\n\t\t{\n\t\t\tvec4 lastGradientColor=gradientColors[i-1];\n\t\t\tfloat lastColorKey=lastGradientColor.x;\n\t\t\tfloat age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n\t\t\toverTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn overTimeColor;\n}\n#endif\n\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n\tfloat overTimeFrame;\n\tfor(int i=1;i<4;i++)\n\t{\n\t\tvec2 gradientFrame=gradientFrames[i];\n\t\tfloat key=gradientFrame.x;\n\t\tif(key>=normalizedAge)\n\t\t{\n\t\t\tvec2 lastGradientFrame=gradientFrames[i-1];\n\t\t\tfloat lastKey=lastGradientFrame.x;\n\t\t\tfloat age=(normalizedAge-lastKey)/(key-lastKey);\n\t\t\toverTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn floor(overTimeFrame);\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n #ifdef VELOCITYOVERLIFETIMECONSTANT\n\t outLifeVelocity=u_VOLVelocityConst; \n #endif\n #ifdef VELOCITYOVERLIFETIMECURVE\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\n\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\n\t\t\t\t\t mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n #endif\n\t\t\t\t\t\n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t#ifdef VELOCITYOVERLIFETIMECONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMECURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=lifeVelocity*age;\n\t#endif\n\t#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n\t\t startPosition=startVelocity*age;\n\t\t lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\n\t ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n\t#endif\n\t\n\tvec3 finalPosition;\n\tif(u_VOLSpaceType==0){\n\t if(u_ScalingMode!=2)\n\t finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\n\t else\n\t finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\n\t}\n\telse{\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\n\t}\n #else\n\t startPosition=startVelocity*age;\n\t vec3 finalPosition;\n\t if(u_ScalingMode!=2)\n\t finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\n\t else\n\t finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=0.5*gravityVelocity*age;\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n\t#ifdef COLOROVERLIFETIME\n\t color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n\t#endif\n\t\n\t#ifdef RANDOMCOLOROVERLIFETIME\n\t color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n\t#endif\n\n return color;\n}\n\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n\n#ifdef RENDERMODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\n{\n\t#ifdef SIZEOVERLIFETIMECURVE\n\t\tsize*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVES\n\t size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n\t#endif\n\t#ifdef SIZEOVERLIFETIMECURVESEPERATE\n\t\tsize*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\n\t#endif\n\t#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n\t size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n\t ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\n\t\t,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\n\t#endif\n\treturn size;\n}\n#endif\n\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n\n\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\n{ \n\t#ifdef ROTATIONOVERLIFETIME\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tfloat ageRot=u_ROLAngularVelocityConst*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n\t\t#endif\n\t#endif\n\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t#ifdef ROTATIONOVERLIFETIMECONSTANT\n\t\t\tvec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n\t rotation+=ageRot;\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMECURVE\n\t\t\trotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n\t\t#endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n\t\t\tvec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n\t rotation+=ageRot;\n\t #endif\n\t\t#ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n\t\t\trotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n\t ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n\t\t#endif\n\t#endif\n\treturn rotation;\n}\n#endif\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n\t#ifdef TEXTURESHEETANIMATIONCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\t#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n\t\tfloat cycleNormalizedAge=normalizedAge*u_TSACycles;\n\t\tfloat uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n\t float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n\t\tfloat totalULength=frame*u_TSASubUVLength.x;\n\t\tfloat floorTotalULength=floor(totalULength);\n\t uv.x+=totalULength-floorTotalULength;\n\t\tuv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n\treturn uv;\n}\n\nvoid main()\n{\n\tfloat age = u_CurrentTime - a_DirectionTime.w;\n\tfloat normalizedAge = age/a_ShapePositionStartLifeTime.w;\n\tvec3 lifeVelocity;\n\tif(normalizedAge<1.0){ \n\tvec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t\tlifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n\t#endif \n\tvec3 gravityVelocity=u_Gravity*age;\n\t\n\tvec4 worldRotation;\n\tif(u_SimulationSpace==0)\n\t\tworldRotation=a_SimulationWorldRotation;\n\telse\n\t\tworldRotation=u_WorldRotation;\n\t\n\tvec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\n \n \n #ifdef SPHERHBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n\t corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\tfloat c = cos(rot);\n\t\t\t\tfloat s = sin(rot);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tfloat c = cos(a_StartRotation0.x);\n\t\t\t\tfloat s = sin(a_StartRotation0.x);\n\t\t\t\tmat2 rotation= mat2(c, -s, s, c);\n\t\t\t\tcorner=rotation*corner;\n\t\t\t\tcenter += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n\t\t\t}\n\t\t#endif\n #endif\n \n #ifdef STRETCHEDBILLBOARD\n\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n\tvec3 velocity;\n\t#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n\t if(u_VOLSpaceType==0)\n\t\t velocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\n\t else\n\t\t velocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\n #else\n\t velocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n #endif\t\n\t\tvec3 cameraUpVector = normalize(velocity);\n\t\tvec3 direction = normalize(center-u_CameraPosition);\n vec3 sideVector = normalize(cross(direction,normalize(velocity)));\n\t\t\n\t\tsideVector=u_SizeScale.xzy*sideVector;\n\t\tcameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\n\t\t\n\t vec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n\t\t\n\t const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n\t corner=rotaionZHalfPI*corner;\n\t corner.y=corner.y-abs(corner.y);\n\t\t\n\t float speed=length(velocity);//TODO:\n\t center +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector=vec3(0.0,0.0,1.0);\n\t const vec3 sideVector = vec3(-1.0,0.0,0.0);\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n\t\tvec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n\t\t\n\t\tfloat rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n\t corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n\t\tcorner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef RENDERMODE_MESH\n\t vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n\t\t#if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tvec3 rotation=vec3(a_StartRotation0.xy,-computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\n\t\t\t}\n\t\t\telse{\n\t\t\t\t#ifdef ROTATIONOVERLIFETIME\n\t\t\t\t\tfloat angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n\t\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\t\tcenter+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n\t\t\t\t\t\t#else\n\t\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\t\tcenter+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\n\t\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\t\tcenter+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\n\t\t\t\t\t\t#endif\n\t\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t\t#ifdef ROTATIONOVERLIFETIMESEPERATE\n\t\t\t\t\t//TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\n\t\t\t\t\tvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,a_StartRotation0.z), age,normalizedAge);\n\t\t\t\t\tcenter+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\n\t\t\t\t#endif\t\n\t\t\t}\n\t\t#else\n\t\t\tif(u_ThreeDStartRotation){\n\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\n\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\tcenter+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t#ifdef SHAPE\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\t\n\t\t\t\t\t#else\n\t\t\t\t\t\tif(u_SimulationSpace==0)\n\t\t\t\t\t\t\tcenter+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\n\t\t\t\t\t\telse if(u_SimulationSpace==1)\n\t\t\t\t\t\t\tcenter+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\n\t\t\t\t\t#endif\n\t\t\t\t}\n\t\t\t}\n\t\t#endif\n\t\tv_MeshColor=a_MeshColor;\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\t#ifdef MAINTEXTURE\n\t\t#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n\t\t\tv_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n\t\t#endif\n\t\t#ifdef RENDERMODE_MESH\n\t\t\tv_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\n\t\t#endif\n\t\t\n\t\tv_Texcoord0 = v_TextureCoordinate;\n\t\t#ifdef TILINGOFFSET1 \n\t\t\tv_Texcoord0=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset1.xy+vec2(u_TilingOffset1.z,-u_TilingOffset1.w);//需要特殊处理\n\t\t\tv_Texcoord0=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t\t\n\t\tv_Texcoord1 = v_TextureCoordinate;\n\t\t#ifdef TILINGOFFSET2 \n\t\t\tv_Texcoord1=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset2.xy+vec2(u_TilingOffset2.z,-u_TilingOffset2.w);//需要特殊处理\n\t\t\tv_Texcoord1=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n\t\t#endif\n\t\t\n\t#endif\n v_Discard=0.0;\n\t \n\t#ifdef FOG\n\t\tv_PositionWorld=center;\n\t#endif\n }\n else\n\t{\n\t\tv_Discard=1.0;\n\t}\n}\n\n","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\nuniform vec4 u_BaseColor;\nuniform vec4 u_AlphaColor;\nuniform float u_Instensity;\nuniform float u_Alpha;\n\n#ifdef MAINTEXTURE\n\tuniform sampler2D u_MainTexture;\n#endif\n\n#ifdef MASKTEXTURE\n\tuniform sampler2D u_MaskTexture;\n#endif\n\n#ifdef RENDERMODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\n#ifdef FOG\n\tvarying vec3 v_PositionWorld;\n\tuniform vec3 u_CameraPosition;\n\tuniform float u_FogStart;\n\tuniform float u_FogRange;\n\t#ifdef ADDTIVEFOG\n\t#else\n\t\tuniform vec3 u_FogColor;\n\t#endif\n#endif\n\n\nvoid main()\n{\t\n\t#ifdef RENDERMODE_MESH\n\t\tgl_FragColor=v_MeshColor;\n\t#else\n\t\tgl_FragColor=vec4(1.0);\t\n\t#endif\n\t\t\n\tvec4 mainTextureColor = vec4(1.0);\n\t#ifdef MAINTEXTURE\n\t\tmainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 maskTextureColor = vec4(1.0);\n\t#ifdef MASKTEXTURE\n\t\tmaskTextureColor = texture2D(u_MaskTexture, v_Texcoord1);\n\t#endif\n\t\n\tvec4 outColor = mix(vec4(0.0), mainTextureColor, maskTextureColor);\n\t\n\tgl_FragColor *= 2.0 * outColor * u_BaseColor * u_AlphaColor * v_Color * u_Instensity;\n\tgl_FragColor.a *= u_Alpha;\n\t\n\t#ifdef FOG\n\t\tvec3 toEye=u_CameraPosition-v_PositionWorld;\n\t\tfloat toEyeLength=length(toEye);\n\t\ttoEye/=toEyeLength;\n\t\t\n\t\tfloat lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n\t\t#ifdef ADDTIVEFOG\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n\t\t#else\n\t\t\tgl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n\t\t#endif\n\t#endif\n}",{a_CornerTextureCoordinate:17,a_MeshPosition:0,a_MeshColor:1,a_MeshTextureCoordinate:2,a_ShapePositionStartLifeTime:30,a_DirectionTime:32,a_StartColor:19,a_EndColor:23,a_StartSize:20,a_StartRotation0:22,a_StartSpeed:31,a_Random0:34,a_Random1:35,a_SimulationWorldPostion:36,a_SimulationWorldRotation:37},{u_MainTexture:[1,1],u_MaskTexture:[2,1],u_BaseColor:[3,1],u_AlphaColor:[4,1],u_Instensity:[5,1],u_Alpha:[6,1],u_TilingOffset1:[7,1],u_TilingOffset2:[8,1],u_WorldPosition:[0,2],u_WorldRotation:[1,2],u_PositionScale:[4,2],u_SizeScale:[5,2],u_ScalingMode:[6,2],u_Gravity:[7,2],u_ThreeDStartRotation:[8,2],u_StretchedBillboardLengthScale:[9,2],u_StretchedBillboardSpeedScale:[10,2],u_SimulationSpace:[11,2],u_CurrentTime:[12,2],u_ColorOverLifeGradientAlphas:[22,2],u_ColorOverLifeGradientColors:[23,2],u_MaxColorOverLifeGradientAlphas:[24,2],u_MaxColorOverLifeGradientColors:[25,2],u_VOLVelocityConst:[13,2],u_VOLVelocityGradientX:[14,2],u_VOLVelocityGradientY:[15,2],u_VOLVelocityGradientZ:[16,2],u_VOLVelocityConstMax:[17,2],u_VOLVelocityGradientMaxX:[18,2],u_VOLVelocityGradientMaxY:[19,2],u_VOLVelocityGradientMaxZ:[20,2],u_VOLSpaceType:[21,2],u_SOLSizeGradient:[26,2],u_SOLSizeGradientX:[27,2],u_SOLSizeGradientY:[28,2],u_SOLSizeGradientZ:[29,2],u_SOLSizeGradientMax:[30,2],u_SOLSizeGradientMaxX:[31,2],u_SOLSizeGradientMaxY:[32,2],u_SOLSizeGradientMaxZ:[33,2],u_ROLAngularVelocityConst:[34,2],u_ROLAngularVelocityConstSeprarate:[35,2],u_ROLAngularVelocityGradient:[36,2],u_ROLAngularVelocityGradientX:[37,2],u_ROLAngularVelocityGradientY:[38,2],u_ROLAngularVelocityGradientZ:[39,2],u_ROLAngularVelocityGradientW:[40,2],u_ROLAngularVelocityConstMax:[41,2],u_ROLAngularVelocityConstMaxSeprarate:[42,2],u_ROLAngularVelocityGradientMax:[43,2],u_ROLAngularVelocityGradientMaxX:[44,2],u_ROLAngularVelocityGradientMaxY:[45,2],u_ROLAngularVelocityGradientMaxZ:[46,2],u_ROLAngularVelocityGradientMaxW:[47,2],u_TSACycles:[48,2],u_TSASubUVLength:[49,2],u_TSAGradientUVs:[50,2],u_TSAMaxGradientUVs:[51,2],u_CameraPosition:[0,3],u_CameraDirection:[5,3],u_CameraUp:[6,3],u_View:[1,3],u_Projection:[2,3],u_FogStart:[1,4],u_FogRange:[2,4],u_FogColor:[0,4]});Yi.SHADERDEFINE_MAINTEXTURE=e.registerMaterialDefine("MAINTEXTURE"),Yi.SHADERDEFINE_MASKTEXTURE=e.registerMaterialDefine("MASKTEXTURE"),Yi.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),Yi.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2"),mr.SHADERDEFINE_RENDERMODE_BILLBOARD=e.registerSpriteDefine("SPHERHBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=e.registerSpriteDefine("STRETCHEDBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=e.registerSpriteDefine("HORIZONTALBILLBOARD"),mr.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=e.registerSpriteDefine("VERTICALBILLBOARD"),mr.SHADERDEFINE_COLOROVERLIFETIME=e.registerSpriteDefine("COLOROVERLIFETIME"),mr.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=e.registerSpriteDefine("RANDOMCOLOROVERLIFETIME"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=e.registerSpriteDefine("VELOCITYOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=e.registerSpriteDefine("VELOCITYOVERLIFETIMECURVE"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=e.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT"),mr.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=e.registerSpriteDefine("VELOCITYOVERLIFETIMERANDOMCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=e.registerSpriteDefine("TEXTURESHEETANIMATIONCURVE"),mr.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=e.registerSpriteDefine("TEXTURESHEETANIMATIONRANDOMCURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIME=e.registerSpriteDefine("ROTATIONOVERLIFETIME"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=e.registerSpriteDefine("ROTATIONOVERLIFETIMESEPERATE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=e.registerSpriteDefine("ROTATIONOVERLIFETIMECONSTANT"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=e.registerSpriteDefine("ROTATIONOVERLIFETIMECURVE"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=e.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS"),mr.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=e.registerSpriteDefine("ROTATIONOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVE=e.registerSpriteDefine("SIZEOVERLIFETIMECURVE"),mr.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=e.registerSpriteDefine("SIZEOVERLIFETIMECURVESEPERATE"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=e.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVES"),mr.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=e.registerSpriteDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE"),mr.SHADERDEFINE_RENDERMODE_MESH=e.registerSpriteDefine("RENDERMODE_MESH"),mr.SHADERDEFINE_SHAPE=e.registerSpriteDefine("SHAPE")},e.MAINTEXTURE=1,e.MASKTEXTURE=2,e.BASECOLOR=3,e.ALPHACOLOR=4,e.INTENSITY=5,e.ALPHA=6,e.TILINGOFFSET1=7,e.TILINGOFFSET2=8,e.SHADERDEFINE_MAINTEXTURE=0,e.SHADERDEFINE_MASKTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){e.__super.call(this),this.setShaderName("UVSine"),this._setColor(3,new _n(1,1,1,1)),this._setNumber(4,0),this._setNumber(5,0),this._setNumber(6,0),this._setNumber(7,0),this._setNumber(8,1),this._setNumber(9,1)}p(e,"laya.d3.extension.lulingmen.UVSineMaterial",ri);var t=e.prototype;_(0,t,"alpha",function(){return this._getNumber(9)},function(e){e=Math.max(0,Math.min(1,e)),this._setNumber(9,e)}),_(0,t,"baseTexture",function(){return this._getTexture(1)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE),this._setTexture(1,e)}),_(0,t,"baseScrollSpeedX",function(){return this._getNumber(4)},function(e){this._setNumber(4,e)}),_(0,t,"secondTexture",function(){return this._getTexture(2)},function(e){e?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE),this._setTexture(2,e)}),_(0,t,"mMultiplier",function(){return this._getNumber(8)},function(e){this._setNumber(8,e)}),_(0,t,"baseScrollSpeedY",function(){return this._getNumber(5)},function(e){this._setNumber(5,e)}),_(0,t,"albedoColor",function(){return this._getColor(3)},function(e){this._setColor(3,e)}),_(0,t,"secondScrollSpeedX",function(){return this._getNumber(6)},function(e){this._setNumber(6,e)}),_(0,t,"secondScrollSpeedY",function(){return this._getNumber(7)},function(e){this._setNumber(7,e)}),_(0,t,"tilingOffset",function(){return this._getColor(10)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1),this._setColor(10,e)}),_(0,t,"detailTilingOffset",function(){return this._getColor(11)},function(e){var t;e&&(1!=(t=e.elements)[0]||1!=t[1]||0!=t[2]||0!=t[3])?this._addShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2):this._removeShaderDefine(laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2),this._setColor(11,e)}),e.__init__=function(){e.SHADERDEFINE_BASETEXTURE=e.shaderDefines.registerDefine("BASETEXTURE"),e.SHADERDEFINE_SECONDTEXTURE=e.shaderDefines.registerDefine("SECONDTEXTURE"),e.SHADERDEFINE_TILINGOFFSET1=e.shaderDefines.registerDefine("TILINGOFFSET1"),e.SHADERDEFINE_TILINGOFFSET2=e.shaderDefines.registerDefine("TILINGOFFSET2")},e.initShader=function(){var e=Vi.nameKey.add("UVSine"),e=$n.add(e,"attribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec2 a_Texcoord0;\nattribute vec4 a_Color;\n\nuniform mat4 u_MvpMatrix;\nuniform float u_Time;\nuniform float u_BaseScrollSpeedX;\nuniform float u_BaseScrollSpeedY;\nuniform float u_SecondScrollSpeedX;\nuniform float u_SecondScrollSpeedY;\n\nuniform vec4 u_TilingOffset1;\nuniform vec4 u_TilingOffset2;\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\nvoid main()\n{\n\tv_Texcoord0 = a_Texcoord0;\n\t#ifdef TILINGOFFSET1\n\t\tv_Texcoord0 = (vec2(v_Texcoord0.x, v_Texcoord0.y - 1.0) * u_TilingOffset1.xy) + u_TilingOffset1.zw;\n\t\tv_Texcoord0 = vec2(v_Texcoord0.x, 1.0 + v_Texcoord0.y);\n\t#endif\n\t\n\tv_Texcoord1 = a_Texcoord0;\n\t#ifdef TILINGOFFSET2\n\t\tv_Texcoord1 = (vec2(v_Texcoord1.x, v_Texcoord1.y - 1.0) * u_TilingOffset2.xy) + u_TilingOffset2.zw;\n\t\tv_Texcoord1 = vec2(v_Texcoord1.x, 1.0 + v_Texcoord1.y);\n\t#endif\n\t\n\tv_Texcoord0 = v_Texcoord0 + vec2(fract(u_BaseScrollSpeedX * u_Time / 20.0), fract(-u_BaseScrollSpeedY * u_Time));\n\tv_Texcoord1 = v_Texcoord1 + vec2(fract(u_SecondScrollSpeedX * u_Time / 20.0), fract(-u_SecondScrollSpeedY * u_Time));\n\t\n\tv_Color = vec4(1.0);\n\t#ifdef COLOR\n\t\tv_Color = a_Color;\n\t#endif\n\t\n\tgl_Position = u_MvpMatrix * a_Position;\n}","#ifdef FSHIGHPRECISION\n\tprecision highp float;\n#else\n\tprecision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\nvarying vec4 v_Color;\n\n#ifdef BASETEXTURE\n\tuniform sampler2D u_BaseTexture;\n#endif\n\n#ifdef SECONDTEXTURE\n\tuniform sampler2D u_SecondTexture;\n#endif\n\nuniform vec4 u_BaseColor;\nuniform float u_MMultiplier;\nuniform float u_Alpha;\n\nvoid main()\n{\n\tvec4 baseTextureColor = vec4(1.0);\n\t#ifdef BASETEXTURE\n\t\tbaseTextureColor = texture2D(u_BaseTexture, v_Texcoord0);\n\t#endif\n\t\n\tvec4 secondTextureColor = vec4(1.0);\n\t#ifdef SECONDTEXTURE\n\t\tsecondTextureColor = texture2D(u_SecondTexture, v_Texcoord1);\n\t#endif\n\t\n\tgl_FragColor = baseTextureColor * secondTextureColor * u_BaseColor * u_MMultiplier * v_Color;\n\tgl_FragColor.a *= u_Alpha;\n}\n",{a_Position:0,a_Normal:3,a_Color:1,a_Texcoord0:2},{u_MvpMatrix:[1,2],u_Time:[22,4],u_BaseTexture:[1,1],u_SecondTexture:[2,1],u_BaseColor:[3,1],u_BaseScrollSpeedX:[4,1],u_BaseScrollSpeedY:[5,1],u_SecondScrollSpeedX:[6,1],u_SecondScrollSpeedY:[7,1],u_MMultiplier:[8,1],u_Alpha:[9,1],u_TilingOffset1:[10,1],u_TilingOffset2:[11,1]});laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_BASETEXTURE=e.registerMaterialDefine("BASETEXTURE"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_SECONDTEXTURE=e.registerMaterialDefine("SECONDTEXTURE"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET1=e.registerMaterialDefine("TILINGOFFSET1"),laya.d3.extension.lulingmen.UVSineMaterial.SHADERDEFINE_TILINGOFFSET2=e.registerMaterialDefine("TILINGOFFSET2")},e.BASETEXTURE=1,e.SECONDTEXTURE=2,e.BASECOLOR=3,e.BASESCROLLSPEEDX=4,e.BASESCROLLSPEEDY=5,e.SECONDSCROLLSPEEDX=6,e.SECONDSCROLLSPEEDY=7,e.MMULTIPLIER=8,e.ALPHA=9,e.TILINGOFFSET1=10,e.TILINGOFFSET2=11,e.SHADERDEFINE_BASETEXTURE=0,e.SHADERDEFINE_SECONDTEXTURE=0,e.SHADERDEFINE_TILINGOFFSET1=0,e.SHADERDEFINE_TILINGOFFSET2=0,l(e,["shaderDefines",function(){return this.shaderDefines=new fn(ri.shaderDefines)}])}(),function(){function e(){this._startTm=0,e.__super.call(this),laya.d3.water.WaterDetailMaterial.init(),this.setShaderName("WaterDetail"),this.cull=0,this._startTm=S.timer.currTimer}p(e,"laya.d3.water.WaterDetailMaterial",ri);var t=e.prototype;return _(0,t,"currentTm",function(){return this._getNumber(1)},function(e){this._setNumber(1,e-this._startTm)}),_(0,t,"waveInfo",function(){return this._getBuffer(12)},function(e){this._setBuffer(12,e)}),_(0,t,"waveInfoD",function(){return this._getBuffer(13)},function(e){this._setBuffer(13,e)}),_(0,t,"texWaveUVScale",function(){return this._getNumber(15)},function(e){this._setNumber(15,e)}),e.init=function(){var e;laya.d3.water.WaterDetailMaterial._bInited||(laya.d3.water.WaterDetailMaterial._bInited=!0,e=Vi.nameKey.add("WaterDetail"),$n.add(e,"\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 uv;\n\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n\n\nvoid main() {\n\tvec3 pos = a_position;\n\tif(pos.z!=0.)pos.y=pos.z;\n\tpos.z=0.5;\n\tgl_Position = vec4(pos,1.);\n vUv = uv;\n\t//vWorldNorm = normalize((modelMat*vec4(a_normal,0.0)).xyz);\n\t//vWorldTangent = normalize((modelMat*vec4(tangent,0.0)).xyz);\n\t//vWorldBinormal = normalize((modelMat*vec4(binormal,0.0)).xyz);\n}\n",'precision highp float;\nprecision lowp int;\n\nconst float PI = 3.14159265358979323846264;\nconst float _2PI = 6.2831853071796;\nvarying vec2 vUv;\nvarying vec3 vWorldNorm;\nvarying vec3 vWorldTangent;\nvarying vec3 vWorldBinormal;\n\nuniform float u_curTm;\n\n#include "WaveFunction.glsl"\n\nvoid main() {\n\tvec3 wave_N,wave_B,wave_T;\n\tcalcWave(u_curTm, vUv,wave_B,wave_T,wave_N);\n\tgl_FragColor.rgb = normalize(wave_N)*0.5+vec3(0.5);// vec3(0.1,.4,0.1);\n gl_FragColor.a = 1.0;\n}\n',{a_position:0,a_normal:3,uv:2},{u_curTm:[1,1],u_WaveInfo:[12,1],u_WaveInfoD:[13,1],TEXWAVE_UV_SCALE:[15,1]}))},e.CURTM=1,e.WAVEINFO=12,e.WAVEINFOD=13,e.WAVEMAINDIR=14,e.TEXWAVE_UV_SCALE=15,e._bInited=!1,e}()),ji=(function(t){function e(){this._animationSprites=null,this._animationSpritesInitLocalMatrix=null,this._tempCurAnimationData=null,this._curOriginalData=null,this._lastFrameIndex=-1,this._curAnimationDatas=null,e.__super.call(this),this._animationSprites=[],this._animationSpritesInitLocalMatrix=[]}p(e,"laya.d3.component.animation.RigidAnimations",t);var n=e.prototype;n._init=function(){for(var e=this._templet.getNodes(this.currentAnimationClipIndex),t=this._owner,n=e.length,i=0,r=new Uint16Array(this._templet.getPublicExtData()),a=0;a=t.y&&t.x>=t.z?t.x:t.y>=t.z?t.y:t.z,hn.transformCoordinate(this._originalBoundSphere.center,e.worldMatrix,this._transformBoundSphere.center),this._transformBoundSphere.radius=this._originalBoundSphere.radius*n,this._needUpdate=!1)},t._onWorldMatrixChanged=function(){for(var e in this._needUpdate=!0,this._runtimeCollisonMap)this._runtimeCollisonTestMap[e]=!0,this._runtimeCollisonMap[e]._runtimeCollisonTestMap[this.id]=!0},t._initialize=function(e){laya.d3.component.Component3D.prototype._initialize.call(this,e),this._originalBoundSphere=new Yt(new hn(0,0,0),.5),this._transformBoundSphere=new Yt(new hn(0,0,0),.5),e.transform.on("worldmatrixneedchanged",this,this._onWorldMatrixChanged),this._needUpdate=!0},t._getType=function(){return 0},t._collisonTo=function(e){switch(e._getType()){case 0:return 0!==Zt.sphereContainsSphere(this.boundSphere,e.boundSphere);case 1:return 0!==e.boundBox.containsSphere(this.boundSphere);case 2:var t=e;if(0===Zt.sphereContainsBox(this.boundSphere,t._boundBox))return!1;for(var n=t.mesh._positions,i=0,r=n.length;ie.byteLength)throw"load mipmaps data size error ";var s=new Uint8Array(e,a,o);if(this._mipmaps.push(s),a+=o,1==i&&1==r)break;(i/=2)<1&&(i=1),(r/=2)<1&&(r=1)}return null}]);if(laya.d3.resource.DataTexture2D.lodasatlas){a.simLodInfo=new Float32Array(40);for(var o=0;ot[n].renderingOrder&&(e=t[i],t[i]=t[n],t[n]=e)},e._calculateProjectionMatrix=function(){},e._onScreenSizeChanged=function(){this._calculateProjectionMatrix()},e._prepareCameraToRender=function(){Z._currentCameraCullingMask=this.cullingMask;var e=this._shaderValues;e.setValue(0,this.transform.position.elements),e.setValue(5,this.forward.elements),e.setValue(6,this.up.elements)},e._prepareCameraViewProject=function(e,t){var n=this._shaderValues;n.setValue(1,e.elements),n.setValue(2,t.elements)},e._renderCamera=function(e,t,n){},e.addLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask|e.mask)},e.removeLayer=function(e){29!==e.number&&30!=e.number&&(this.cullingMask=this.cullingMask&~e.mask)},e.addAllLayers=function(){this.cullingMask=2147483647},e.removeAllLayers=function(){this.cullingMask=0|Z.getLayerByNumber(29).mask|Z.getLayerByNumber(30).mask},e.ResetProjectionMatrix=function(){this._useUserProjectionMatrix=!1,this._calculateProjectionMatrix()},e.moveForward=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[1]=0,this._tempVector3.elements[2]=e,this.transform.translate(this._tempVector3)},e.moveRight=function(e){this._tempVector3.elements[1]=this._tempVector3.elements[2]=0,this._tempVector3.elements[0]=e,this.transform.translate(this._tempVector3)},e.moveVertical=function(e){this._tempVector3.elements[0]=this._tempVector3.elements[2]=0,this._tempVector3.elements[1]=e,this.transform.translate(this._tempVector3,!1)},e._addSelfRenderObjects=function(){var e=this.scene._cameraPool,t=e.length;if(0this.width()||t<0||t>this.depth())return NaN;var n=this._terrainRes._gridSize,i=parseInt(""+e/n),r=parseInt(""+t/n),a=e-i*n,o=t-r*n,e=NaN,t=this._terrainRes._heightData;return nn.length)throw Error("Update domino count can't more than keyFrames Count!");this._geometryFilter.updateDominos(e,t,n)},n._changeRenderObjects=function(e,t,n){var i=this._geometryFilter.getDominoRenderElementsCount();this._render._renderElements.length=i;for(var r=0;r