1 |
- var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.BUMP=!1,i.REFLECTION=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.SPECULARTERM=!1,i.LOGARITHMICDEPTH=!1,i.FRESNELSEPARATE=!1,i.BUMPSUPERIMPOSE=!1,i.BUMPAFFECTSREFLECTION=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(n,r,o){void 0===o&&(o=new e.Vector2(512,512));var a=t.call(this,n,r)||this;return a.renderTargetSize=o,a.diffuseColor=new e.Color3(1,1,1),a.specularColor=new e.Color3(0,0,0),a.specularPower=64,a.disableLighting=!1,a.maxSimultaneousLights=4,a.windForce=6,a.windDirection=new e.Vector2(0,1),a.waveHeight=.4,a.bumpHeight=.4,a.bumpSuperimpose=!1,a.fresnelSeparate=!1,a.bumpAffectsReflection=!1,a.waterColor=new e.Color3(.1,.1,.6),a.colorBlendFactor=.2,a.waterColor2=new e.Color3(.1,.1,.6),a.colorBlendFactor2=.2,a.waveLength=.1,a.waveSpeed=1,a._mesh=null,a._reflectionTransform=e.Matrix.Zero(),a._lastTime=0,a._defines=new i,a._cachedDefines=new i,a._createRenderTargets(r,o),a}return __extends(n,t),Object.defineProperty(n.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!0,configurable:!0}),n.prototype.addToRenderList=function(e){this._refractionRTT.renderList.push(e),this._reflectionRTT.renderList.push(e)},n.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT.refreshRate=i,this._reflectionRTT.refreshRate=i},n.prototype.getRenderList=function(){return this._refractionRTT.renderList},Object.defineProperty(n.prototype,"renderTargetsEnabled",{get:function(){return!(0===this._refractionRTT.refreshRate)},enumerable:!0,configurable:!0}),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype._checkCache=function(e,i,t){return!i||this._defines.INSTANCES===t&&!(!i._materialDefines||!i._materialDefines.isEqual(this._defines))},n.prototype.isReady=function(t,n){if(this.checkReadyOnlyOnce&&this._wasPreviouslyReady)return!0;var r=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId()&&this._checkCache(r,t,n))return!0;var o=r.getEngine(),a=!1,s=!1;if(this._defines.reset(),r.texturesEnabled){if(this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;s=!0,this._defines.BUMP=!0}e.StandardMaterial.ReflectionTextureEnabled&&(this._defines.REFLECTION=!0)}if(r.clipPlane&&(this._defines.CLIPPLANE=!0),o.getAlphaTesting()&&(this._defines.ALPHATEST=!0),(this.pointsCloud||r.forcePointsCloud)&&(this._defines.POINTSIZE=!0),this.useLogarithmicDepth&&(this._defines.LOGARITHMICDEPTH=!0),this.fresnelSeparate&&(this._defines.FRESNELSEPARATE=!0),this.bumpSuperimpose&&(this._defines.BUMPSUPERIMPOSE=!0),this.bumpAffectsReflection&&(this._defines.BUMPAFFECTSREFLECTION=!0),r.fogEnabled&&t&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),r.lightsEnabled&&!this.disableLighting&&(a=e.MaterialHelper.PrepareDefinesForLights(r,t,this._defines,this.maxSimultaneousLights)),t&&(a&&t.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),s&&(t.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,t.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),t.useBones&&t.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=t.numBoneInfluencers,this._defines.BonesPerMesh=t.skeleton.bones.length+1),n&&(this._defines.INSTANCES=!0)),this._mesh=t,!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),r.resetCachedMaterial();var l=new e.EffectFallbacks;this._defines.FOG&&l.addFallback(1,"FOG"),this._defines.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,l,this.maxSimultaneousLights),this._defines.NUM_BONE_INFLUENCERS>0&&l.addCPUSkinningFallback(0,t);var c=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&c.push(e.VertexBuffer.NormalKind),this._defines.UV1&&c.push(e.VertexBuffer.UVKind),this._defines.UV2&&c.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,t,this._defines,l),e.MaterialHelper.PrepareAttributesForInstances(c,this._defines);var f=this._defines.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed"],p=["normalSampler","refractionSampler","reflectionSampler"];e.MaterialHelper.PrepareUniformsAndSamplersList(d,p,this._defines,this.maxSimultaneousLights),this._effect=r.getEngine().createEffect("water",c,d,p,f,l,this.onCompiled,this.onError,{maxSimultaneousLights:this.maxSimultaneousLights})}return!!this._effect.isReady()&&(this._renderId=r.getRenderId(),this._wasPreviouslyReady=!0,t&&(t._materialDefines||(t._materialDefines=new i),this._defines.cloneTo(t._materialDefines)),!0)},n.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},n.prototype.bind=function(i,n){var r=this.getScene();this.bindOnlyWorldMatrix(i),this._effect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(n,this._effect),r.getCachedMaterial()!==this&&(this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&(this._effect.setTexture("normalSampler",this.bumpTexture),this._effect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._effect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._effect,r),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._effect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._effect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*n.visibility),this._defines.SPECULARTERM&&this._effect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,n,this._effect,this._defines,this.maxSimultaneousLights),r.fogEnabled&&n.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._effect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,n,this._effect),e.MaterialHelper.BindLogDepth(this._defines,this._effect,r),e.StandardMaterial.ReflectionTextureEnabled&&(this._effect.setTexture("refractionSampler",this._refractionRTT),this._effect.setTexture("reflectionSampler",this._reflectionRTT));var o=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(r.getProjectionMatrix());this._lastTime+=r.getEngine().getDeltaTime(),this._effect.setMatrix("worldReflectionViewProjection",o),this._effect.setVector2("windDirection",this.windDirection),this._effect.setFloat("waveLength",this.waveLength),this._effect.setFloat("time",this._lastTime/1e5),this._effect.setFloat("windForce",this.windForce),this._effect.setFloat("waveHeight",this.waveHeight),this._effect.setFloat("bumpHeight",this.bumpHeight),this._effect.setColor4("waterColor",this.waterColor,1),this._effect.setFloat("colorBlendFactor",this.colorBlendFactor),this._effect.setColor4("waterColor2",this.waterColor2,1),this._effect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._effect.setFloat("waveSpeed",this.waveSpeed),t.prototype.bind.call(this,i,n)},n.prototype._createRenderTargets=function(i,t){var n=this;this._refractionRTT=new e.RenderTargetTexture(name+"_refraction",{width:t.x,height:t.y},i,!1,!0),this._refractionRTT.wrapU=e.Texture.MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=e.Texture.MIRROR_ADDRESSMODE,this._reflectionRTT=new e.RenderTargetTexture(name+"_reflection",{width:t.x,height:t.y},i,!1,!0),this._reflectionRTT.wrapU=e.Texture.MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=e.Texture.MIRROR_ADDRESSMODE,i.customRenderTargets.push(this._refractionRTT),i.customRenderTargets.push(this._reflectionRTT);var r,o,a=null,s=e.Matrix.Zero();this._refractionRTT.onBeforeRender=function(){n._mesh&&(r=n._mesh.isVisible,n._mesh.isVisible=!1),a=i.clipPlane;var t=n._mesh?n._mesh.position.y:0;i.clipPlane=e.Plane.FromPositionAndNormal(new e.Vector3(0,t+.05,0),new e.Vector3(0,1,0))},this._refractionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=r),i.clipPlane=a},this._reflectionRTT.onBeforeRender=function(){n._mesh&&(r=n._mesh.isVisible,n._mesh.isVisible=!1),a=i.clipPlane;var t=n._mesh?n._mesh.position.y:0;i.clipPlane=e.Plane.FromPositionAndNormal(new e.Vector3(0,t-.05,0),new e.Vector3(0,-1,0)),e.Matrix.ReflectionToRef(i.clipPlane,s),o=i.getViewMatrix(),s.multiplyToRef(o,n._reflectionTransform),i.setTransformMatrix(n._reflectionTransform,i.getProjectionMatrix()),i.getEngine().cullBackFaces=!1,i._mirroredCameraPosition=e.Vector3.TransformCoordinates(i.activeCamera.position,s)},this._reflectionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=r),i.clipPlane=a,i.setTransformMatrix(o,i.getProjectionMatrix()),i.getEngine().cullBackFaces=!0,i._mirroredCameraPosition=null}},n.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},n.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);i!=-1&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),i!=-1&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),t.prototype.dispose.call(this,e)},n.prototype.clone=function(i){var t=this;return e.SerializationHelper.Clone((function(){return new n(i,t.getScene())}),this)},n.prototype.serialize=function(){var i=e.SerializationHelper.Serialize(this);return i.customType="BABYLON.WaterMaterial",i.reflectionTexture.isRenderTarget=!0,i.refractionTexture.isRenderTarget=!0,i},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},n.CreateDefaultMesh=function(i,t){return e.Mesh.CreateGround(i,512,512,32,t,!1)},n})(e.Material);__decorate([e.serializeAsTexture()],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsColor3()],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3()],t.prototype,"specularColor",void 0),__decorate([e.serialize()],t.prototype,"specularPower",void 0),__decorate([e.serialize()],t.prototype,"disableLighting",void 0),__decorate([e.serialize()],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],t.prototype,"windForce",void 0),__decorate([e.serializeAsVector2()],t.prototype,"windDirection",void 0),__decorate([e.serialize()],t.prototype,"waveHeight",void 0),__decorate([e.serialize()],t.prototype,"bumpHeight",void 0),__decorate([e.serialize()],t.prototype,"bumpSuperimpose",void 0),__decorate([e.serialize()],t.prototype,"fresnelSeparate",void 0),__decorate([e.serialize()],t.prototype,"bumpAffectsReflection",void 0),__decorate([e.serializeAsColor3()],t.prototype,"waterColor",void 0),__decorate([e.serialize()],t.prototype,"colorBlendFactor",void 0),__decorate([e.serializeAsColor3()],t.prototype,"waterColor2",void 0),__decorate([e.serialize()],t.prototype,"colorBlendFactor2",void 0),__decorate([e.serialize()],t.prototype,"waveLength",void 0),__decorate([e.serialize()],t.prototype,"waveSpeed",void 0),__decorate([e.serialize()],t.prototype,"useLogarithmicDepth",null),e.WaterMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.waterVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;\nuniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<shadowsVertexDeclaration>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\n\nuniform mat4 worldReflectionViewProjection;\nuniform vec2 windDirection;\nuniform float waveLength;\nuniform float time;\nuniform float windForce;\nuniform float waveHeight;\nuniform float waveSpeed;\n\nvarying vec3 vPosition;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef BUMP\nif (vNormalInfos.x == 0.)\n{\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\n#endif\n}\nelse\n{\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\n#endif\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\nvec3 p=position;\nfloat newY=(sin(((p.x/0.05)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+(cos(((p.z/0.05)+time*waveSpeed))*waveHeight*windDirection.y*5.0);\np.y+=abs(newY);\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#ifdef REFLECTION\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\n\nvPosition=position;\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvRefractionMapTexCoord.z=worldPos.w;\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n}\n",BABYLON.Effect.ShadersStore.waterPixelShader="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<lightFragmentDeclaration>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef BUMP\nvarying vec2 vNormalUV;\nvarying vec2 vNormalUV2;\nuniform sampler2D normalSampler;\nuniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;\nuniform sampler2D reflectionSampler;\n\nconst float LOG2=1.442695;\nuniform vec3 cameraPosition;\nuniform vec4 waterColor;\nuniform float colorBlendFactor;\nuniform vec4 waterColor2;\nuniform float colorBlendFactor2;\nuniform float bumpHeight;\nuniform float time;\n\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvarying vec3 vPosition;\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef BUMP\n#ifdef BUMPSUPERIMPOSE\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\n#else\nbaseColor=texture2D(normalSampler,vNormalUV);\n#endif\nvec3 bumpColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vNormalInfos.y;\n#else\nvec3 bumpColor=vec3(1.0);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\n#ifdef BUMPAFFECTSREFLECTION\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\nif (normalW.y<0.0) {\nnormalW.y=-normalW.y;\n}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\n\nvec3 eyeVector=normalize(vEyePosition-vPosition);\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=clamp(abs(pow(dot(eyeVector,upVector),3.0)),0.05,0.65);\nfloat IfresnelTerm=1.0-fresnelTerm;\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\nbaseColor=combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#else \n#ifdef REFLECTION\n\nvec3 eyeVector=normalize(vEyePosition-vPosition);\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=max(dot(eyeVector,upVector),0.0);\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
|