babylonjs.materials.min.js 278 KB

12345678910
  1. var babylonDependency;try{babylonDependency=BABYLON||"undefined"!=typeof require&&require("../babylon.max")}catch(e){babylonDependency=BABYLON||"undefined"!=typeof require&&require("babylonjs")}var BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,i,t,n){var r,o=arguments.length,a=o<3?i:null===n?n=Object.getOwnPropertyDescriptor(i,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,i,t,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(i,t,a):r(i,t))||a);return o>3&&a&&Object.defineProperty(i,t,a),a},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var t in i)i.hasOwnProperty(t)&&(e[t]=i[t])};return function(i,t){function n(){this.constructor=i}e(i,t),i.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}})(),BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(e,i){return t.call(this,e,i)||this}return __extends(n,t),n.prototype.needAlphaBlending=function(){return!0},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(n.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!0,configurable:!0}),n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(this._activeLight)for(var f=0,l=t._lightSources;f<l.length;f++){var u=l[f];if(u.shadowEnabled){if(this._activeLight===u)break;var c=t._lightSources.indexOf(this._activeLight);-1!==c&&(t._lightSources.splice(c,1),t._lightSources.splice(0,0,this._activeLight));break}}if(e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,1),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var d=new e.EffectFallbacks;o.FOG&&d.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,d,1),o.NUM_BONE_INFLUENCERS>0&&d.addCPUSkinningFallback(0,t);var m=[e.VertexBuffer.PositionKind];o.NORMAL&&m.push(e.VertexBuffer.NormalKind),e.MaterialHelper.PrepareAttributesForBones(m,t,o,d),e.MaterialHelper.PrepareAttributesForInstances(m,o);var v=o.toString(),h=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","mBones","vClipPlane"],p=new Array,g=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:g,samplers:p,defines:o,maxSimultaneousLights:1}),n.setEffect(a.getEngine().createEffect("shadowOnly",{attributes:m,uniformsNames:h,uniformBuffersNames:g,samplers:p,defines:v,fallbacks:d,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),r.lightsEnabled&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,1),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},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.ShadowOnlyMaterial",i},n.prototype.getClassName=function(){return"ShadowOnlyMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},n})(e.PushMaterial);e.ShadowOnlyMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.shadowOnlyVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.shadowOnlyPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform float alpha;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\n\nvec4 color=vec4(0.,0.,0.,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.LIGHT0=!1,i.LIGHT1=!1,i.LIGHT2=!1,i.LIGHT3=!1,i.SPOTLIGHT0=!1,i.SPOTLIGHT1=!1,i.SPOTLIGHT2=!1,i.SPOTLIGHT3=!1,i.HEMILIGHT0=!1,i.HEMILIGHT1=!1,i.HEMILIGHT2=!1,i.HEMILIGHT3=!1,i.DIRLIGHT0=!1,i.DIRLIGHT1=!1,i.DIRLIGHT2=!1,i.DIRLIGHT3=!1,i.POINTLIGHT0=!1,i.POINTLIGHT1=!1,i.POINTLIGHT2=!1,i.POINTLIGHT3=!1,i.SHADOW0=!1,i.SHADOW1=!1,i.SHADOW2=!1,i.SHADOW3=!1,i.SHADOWS=!1,i.SHADOWESM0=!1,i.SHADOWESM1=!1,i.SHADOWESM2=!1,i.SHADOWESM3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!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.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r._maxSimultaneousLights=4,r.topColor=new e.Color3(1,0,0),r.topColorAlpha=1,r.bottomColor=new e.Color3(0,0,1),r.bottomColorAlpha=1,r.offset=0,r.smoothness=1,r.disableLighting=!1,r._scaledDiffuse=new e.Color3,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},n.prototype.needAlphaTesting=function(){return!0},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix","topColor","bottomColor","offset","smoothness"],d=["diffuseSampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:4}),n.setEffect(a.getEngine().createEffect("gradient",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._effect),this._mustRebind(r,a)&&(e.MaterialHelper.BindClipPlane(this._effect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._activeEffect.setColor4("topColor",this.topColor,this.topColorAlpha),this._activeEffect.setColor4("bottomColor",this.bottomColor,this.bottomColorAlpha),this._activeEffect.setFloat("offset",this.offset),this._activeEffect.setFloat("smoothness",this.smoothness),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){return[]},n.prototype.dispose=function(e){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.GradientMaterial",i},n.prototype.getClassName=function(){return"GradientMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),__decorate([e.serializeAsColor3()],n.prototype,"topColor",void 0),__decorate([e.serialize()],n.prototype,"topColorAlpha",void 0),__decorate([e.serializeAsColor3()],n.prototype,"bottomColor",void 0),__decorate([e.serialize()],n.prototype,"bottomColorAlpha",void 0),__decorate([e.serialize()],n.prototype,"offset",void 0),__decorate([e.serialize()],n.prototype,"smoothness",void 0),__decorate([e.serialize()],n.prototype,"disableLighting",void 0),n})(e.PushMaterial);e.GradientMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.gradientVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex> \ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.gradientPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float smoothness;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\nfloat h=normalize(vPositionW).y+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\n\nvec3 diffuseColor=baseColor.rgb;\n\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.LIGHT0=!1,i.LIGHT1=!1,i.LIGHT2=!1,i.LIGHT3=!1,i.SPOTLIGHT0=!1,i.SPOTLIGHT1=!1,i.SPOTLIGHT2=!1,i.SPOTLIGHT3=!1,i.HEMILIGHT0=!1,i.HEMILIGHT1=!1,i.HEMILIGHT2=!1,i.HEMILIGHT3=!1,i.DIRLIGHT0=!1,i.DIRLIGHT1=!1,i.DIRLIGHT2=!1,i.DIRLIGHT3=!1,i.POINTLIGHT0=!1,i.POINTLIGHT1=!1,i.POINTLIGHT2=!1,i.POINTLIGHT3=!1,i.SHADOW0=!1,i.SHADOW1=!1,i.SHADOW2=!1,i.SHADOW3=!1,i.SHADOWS=!1,i.SHADOWESM0=!1,i.SHADOWESM1=!1,i.SHADOWESM2=!1,i.SHADOWESM3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!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.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled&&this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix"],d=["diffuseSampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:4}),n.setEffect(a.getEngine().createEffect("normal",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this.diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this.diffuseTexture===e},n.prototype.dispose=function(e){this.diffuseTexture&&this.diffuseTexture.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.NormalMaterial",i},n.prototype.getClassName=function(){return"NormalMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.NormalMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.normalVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.normalPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef NORMAL\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.LIGHT0=!1,i.LIGHT1=!1,i.LIGHT2=!1,i.LIGHT3=!1,i.SPOTLIGHT0=!1,i.SPOTLIGHT1=!1,i.SPOTLIGHT2=!1,i.SPOTLIGHT3=!1,i.HEMILIGHT0=!1,i.HEMILIGHT1=!1,i.HEMILIGHT2=!1,i.HEMILIGHT3=!1,i.DIRLIGHT0=!1,i.DIRLIGHT1=!1,i.DIRLIGHT2=!1,i.DIRLIGHT3=!1,i.POINTLIGHT0=!1,i.POINTLIGHT1=!1,i.POINTLIGHT2=!1,i.POINTLIGHT3=!1,i.SHADOW0=!1,i.SHADOW1=!1,i.SHADOW2=!1,i.SHADOW3=!1,i.SHADOWS=!1,i.SHADOWESM0=!1,i.SHADOWESM1=!1,i.SHADOWESM2=!1,i.SHADOWESM3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!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.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.speed=1,r.movingSpeed=1,r.lowFrequencySpeed=1,r.fogDensity=.15,r._lastTime=0,r.diffuseColor=new e.Color3(1,1,1),r._disableLighting=!1,r._maxSimultaneousLights=4,r._scaledDiffuse=new e.Color3,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled&&this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix","time","speed","movingSpeed","fogColor","fogDensity","lowFrequencySpeed"],d=["diffuseSampler","noiseTexture"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("lava",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this.diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.noiseTexture&&this._activeEffect.setTexture("noiseTexture",this.noiseTexture),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._lastTime+=r.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime*this.speed/1e3),this.fogColor||(this.fogColor=e.Color3.Black()),this._activeEffect.setColor3("fogColor",this.fogColor),this._activeEffect.setFloat("fogDensity",this.fogDensity),this._activeEffect.setFloat("lowFrequencySpeed",this.lowFrequencySpeed),this._activeEffect.setFloat("movingSpeed",this.movingSpeed),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.noiseTexture&&this.noiseTexture.animations&&this.noiseTexture.animations.length>0&&e.push(this.noiseTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this.diffuseTexture===e},n.prototype.dispose=function(e){this.diffuseTexture&&this.diffuseTexture.dispose(),this.noiseTexture&&this.noiseTexture.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.LavaMaterial",i},n.prototype.getClassName=function(){return"LavaMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"noiseTexture",void 0),__decorate([e.serializeAsColor3()],n.prototype,"fogColor",void 0),__decorate([e.serialize()],n.prototype,"speed",void 0),__decorate([e.serialize()],n.prototype,"movingSpeed",void 0),
  2. __decorate([e.serialize()],n.prototype,"lowFrequencySpeed",void 0),__decorate([e.serialize()],n.prototype,"fogDensity",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.LavaMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.lavaVertexShader="precision highp float;\n\nuniform float time;\nuniform float lowFrequencySpeed;\n\nvarying float noise;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n\n\nvec3 mod289(vec3 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 mod289(vec4 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 permute(vec4 x)\n{\nreturn mod289(((x*34.0)+1.0)*x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\nreturn 1.79284291400159-0.85373472095314*r;\n}\nvec3 fade(vec3 t) {\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat pnoise(vec3 P,vec3 rep)\n{\nvec3 Pi0=mod(floor(P),rep); \nvec3 Pi1=mod(Pi0+vec3(1.0),rep); \nPi0=mod289(Pi0);\nPi1=mod289(Pi1);\nvec3 Pf0=fract(P); \nvec3 Pf1=Pf0-vec3(1.0); \nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\nvec4 iz0=Pi0.zzzz;\nvec4 iz1=Pi1.zzzz;\nvec4 ixy=permute(permute(ix)+iy);\nvec4 ixy0=permute(ixy+iz0);\nvec4 ixy1=permute(ixy+iz1);\nvec4 gx0=ixy0*(1.0/7.0);\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\ngx0=fract(gx0);\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\nvec4 sz0=step(gz0,vec4(0.0));\ngx0-=sz0*(step(0.0,gx0)-0.5);\ngy0-=sz0*(step(0.0,gy0)-0.5);\nvec4 gx1=ixy1*(1.0/7.0);\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\ngx1=fract(gx1);\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\nvec4 sz1=step(gz1,vec4(0.0));\ngx1-=sz1*(step(0.0,gx1)-0.5);\ngy1-=sz1*(step(0.0,gy1)-0.5);\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\ng000*=norm0.x;\ng010*=norm0.y;\ng100*=norm0.z;\ng110*=norm0.w;\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\ng001*=norm1.x;\ng011*=norm1.y;\ng101*=norm1.z;\ng111*=norm1.w;\nfloat n000=dot(g000,Pf0);\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\nfloat n111=dot(g111,Pf1);\nvec3 fade_xyz=fade(Pf0);\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\nreturn 2.2*n_xyz;\n}\n\nfloat turbulence( vec3 p ) {\nfloat w=100.0;\nfloat t=-.5;\nfor (float f=1.0 ; f<=10.0 ; f++ ){\nfloat power=pow( 2.0,f );\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\n}\nreturn t;\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef NORMAL\n\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\n\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\n\nfloat displacement =-1.5*noise+b;\n\nvec3 newPosition=position+normal*displacement;\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}",BABYLON.Effect.ShadersStore.lavaPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n\nuniform float time;\nuniform float speed;\nuniform float movingSpeed;\nuniform vec3 fogColor;\nuniform sampler2D noiseTexture;\nuniform float fogDensity;\n\nvarying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\n}\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\n\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\nT1.x+=noiseTex.x*2.0;\nT1.y+=noiseTex.y*2.0;\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\nbaseColor=temp;\nfloat depth=gl_FragCoord.z*4.0;\nconst float LOG2=1.442695;\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\ndiffuseColor=baseColor.rgb;\n\n\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!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.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled&&this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix"],d=["diffuseSampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("simple",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights-1}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this.maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this.diffuseTexture===e},n.prototype.dispose=function(e){this._diffuseTexture&&this._diffuseTexture.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.SimpleMaterial",i},n.prototype.getClassName=function(){return"SimpleMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("diffuseColor")],n.prototype,"diffuseColor",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.SimpleMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.simpleVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.simplePixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";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.DEPTHPREPASS=!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(i,n,r){void 0===r&&(r=new e.Vector2(512,512));var o=t.call(this,i,n)||this;return o.renderTargetSize=r,o.diffuseColor=new e.Color3(1,1,1),o.specularColor=new e.Color3(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new e.Vector2(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new e.Color3(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new e.Color3(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o._renderTargets=new e.SmartArray(16),o._mesh=null,o._reflectionTransform=e.Matrix.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(n,r),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o}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,this._markAllSubMeshesAsMiscDirty()},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.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled)){if(this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;o._needUVs=!0,o.BUMP=!0}e.StandardMaterial.ReflectionTextureEnabled&&(o.REFLECTION=!0)}if(e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForMisc(t,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,o),o._areMiscDirty&&(this._fresnelSeparate&&(o.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(o.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(o.BUMPAFFECTSREFLECTION=!0)),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!0,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),this._mesh=t,o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),o.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["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"],d=["normalSampler","refractionSampler","reflectionSampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("water",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this.maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,r),e.StandardMaterial.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var s=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(r.getProjectionMatrix()),f=r.getEngine().getDeltaTime();f!==this._lastDeltaTime&&(this._lastDeltaTime=f,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",s),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._afterBind(t,this._activeEffect)}},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._refractionRTT.ignoreCameraViewport=!0,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,this._reflectionRTT.ignoreCameraViewport=!0;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.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._bumpTexture&&e.push(this._bumpTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this._bumpTexture===e},n.prototype.dispose=function(e){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);-1!=i&&this.getScene().customRenderTargets.splice(i,1),i=-1,i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT),-1!=i&&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.prototype.getClassName=function(){return"WaterMaterial"},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)},__decorate([e.serializeAsTexture("bumpTexture")],n.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3()],n.prototype,"specularColor",void 0),__decorate([e.serialize()],n.prototype,"specularPower",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],n.prototype,"windForce",void 0),__decorate([e.serializeAsVector2()],n.prototype,"windDirection",void 0),__decorate([e.serialize()],n.prototype,"waveHeight",void 0),__decorate([e.serialize()],n.prototype,"bumpHeight",void 0),__decorate([e.serialize("bumpSuperimpose")],n.prototype,"_bumpSuperimpose",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsMiscDirty")],n.prototype,"bumpSuperimpose",void 0),__decorate([e.serialize("fresnelSeparate")],n.prototype,"_fresnelSeparate",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsMiscDirty")],n.prototype,"fresnelSeparate",void 0),__decorate([e.serialize("bumpAffectsReflection")],n.prototype,"_bumpAffectsReflection",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsMiscDirty")],n.prototype,"bumpAffectsReflection",void 0),__decorate([e.serializeAsColor3()],n.prototype,"waterColor",void 0),__decorate([e.serialize()],n.prototype,"colorBlendFactor",void 0),__decorate([e.serializeAsColor3()],n.prototype,"waterColor2",void 0),__decorate([e.serialize()],n.prototype,"colorBlendFactor2",void 0),__decorate([e.serialize()],n.prototype,"waveLength",void 0),__decorate([e.serialize()],n.prototype,"waveSpeed",void 0),__decorate([e.serialize()],n.prototype,"useLogarithmicDepth",null),n})(e.PushMaterial);e.WaterMaterial=t})(BABYLON||(BABYLON={})),
  3. 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<__decl__lightFragment>[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<helperFunctions>\n\n#include<__decl__lightFragment>[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";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.UV1=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.BonesPerMesh=0,i.NUM_BONE_INFLUENCERS=0,i.INSTANCES=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r.speed=1,r._scaledDiffuse=new e.Color3,r._lastTime=0,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return!1},n.prototype.needAlphaTesting=function(){return!0},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(o._areMiscDirty&&(o.POINTSIZE=this.pointsCloud||a.forcePointsCloud,o.FOG=a.fogEnabled&&t.applyFog&&a.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.UV1&&l.push(e.VertexBuffer.UVKind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString();n.setEffect(a.getEngine().createEffect("fire",{attributes:l,uniformsNames:["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix","time","speed"],uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene();if(n._materialDefines){var o=n.effect;if(this._activeEffect=o,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,o)){if(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix()),this._activeEffect.setTexture("distortionSampler",this._distortionTexture),this._activeEffect.setTexture("opacitySampler",this._opacityTexture)),r.clipPlane){var a=r.clipPlane;this._activeEffect.setFloat4("vClipPlane",a.normal.x,a.normal.y,a.normal.z,a.d)}this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)}this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*t.visibility),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._lastTime+=r.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._distortionTexture&&this._distortionTexture.animations&&this._distortionTexture.animations.length>0&&e.push(this._distortionTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._distortionTexture&&e.push(this._distortionTexture),this._opacityTexture&&e.push(this._opacityTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._distortionTexture===e||this._opacityTexture===e))},n.prototype.getClassName=function(){return"FireMaterial"},n.prototype.dispose=function(e){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.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 e=t.prototype.serialize.call(this);return e.customType="BABYLON.FireMaterial",e.diffuseColor=this.diffuseColor.asArray(),e.speed=this.speed,this._diffuseTexture&&(e._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(e._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(e._opacityTexture=this._opacityTexture.serialize()),e},n.Parse=function(i,t,r){var o=new n(i.name,t);return o.diffuseColor=e.Color3.FromArray(i.diffuseColor),o.speed=i.speed,o.alpha=i.alpha,o.id=i.id,e.Tags.AddTagsTo(o,i.tags),o.backFaceCulling=i.backFaceCulling,o.wireframe=i.wireframe,i._diffuseTexture&&(o._diffuseTexture=e.Texture.Parse(i._diffuseTexture,t,r)),i._distortionTexture&&(o._distortionTexture=e.Texture.Parse(i._distortionTexture,t,r)),i._opacityTexture&&(o._opacityTexture=e.Texture.Parse(i._opacityTexture,t,r)),i.checkReadyOnlyOnce&&(o.checkReadyOnlyOnce=i.checkReadyOnlyOnce),o},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("distortionTexture")],n.prototype,"_distortionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"distortionTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],n.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"opacityTexture",void 0),__decorate([e.serialize("diffuseColor")],n.prototype,"diffuseColor",void 0),__decorate([e.serialize()],n.prototype,"speed",void 0),n})(e.PushMaterial);e.FireMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.fireVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n\nuniform float time;\nuniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#ifdef DIFFUSE\nvDiffuseUV=uv;\nvDiffuseUV.y-=0.2;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\n\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\nvDistortionCoords1.x=uv.x;\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\nvDistortionCoords2.x=uv.x;\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\nvDistortionCoords3.x=uv.x;\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n}\n",BABYLON.Effect.ShadersStore.firePixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\nuniform sampler2D distortionSampler;\nuniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{\nreturn vec4(2.0)*x-vec4(1.0);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\n\nfloat alpha=1.0;\n#ifdef DIFFUSE\n\nconst float distortionAmount0=0.092;\nconst float distortionAmount1=0.092;\nconst float distortionAmount2=0.092;\nvec2 heightAttenuation=vec2(0.3,0.39);\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\nbaseColor*=opacityColor;\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.HEIGHTMAP=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!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.HIGHLEVEL=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r.furLength=1,r.furAngle=0,r.furColor=new e.Color3(.44,.21,.02),r.furOffset=0,r.furSpacing=12,r.furGravity=new e.Vector3(0,0,0),r.furSpeed=100,r.furDensity=20,r._disableLighting=!1,r._maxSimultaneousLights=4,r.highLevelFur=!0,r._furTime=0,r}return __extends(n,t),Object.defineProperty(n.prototype,"furTime",{get:function(){return this._furTime},set:function(e){this._furTime=e},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.updateFur=function(){for(var e=1;e<this._meshes.length;e++){var i=this._meshes[e].material;i.furLength=this.furLength,i.furAngle=this.furAngle,i.furGravity=this.furGravity,i.furSpacing=this.furSpacing,i.furSpeed=this.furSpeed,i.furColor=this.furColor,i.diffuseTexture=this.diffuseTexture,i.furTexture=this.furTexture,i.highLevelFur=this.highLevelFur,i.furTime=this.furTime,i.furDensity=this.furDensity}},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&a.texturesEnabled){if(this.diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(this.heightTexture&&s.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;o._needUVs=!0,o.HEIGHTMAP=!0}}if(this.highLevelFur!==o.HIGHLEVEL&&(o.HIGHLEVEL=!0,o.markAsUnprocessed()),e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity"],d=["diffuseSampler","heightTexture","furTexture"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("fur",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),r.getCachedMaterial()!==this&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._heightTexture&&this._activeEffect.setTexture("heightTexture",this._heightTexture),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this.maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._activeEffect.setFloat("furLength",this.furLength),this._activeEffect.setFloat("furAngle",this.furAngle),this._activeEffect.setColor4("furColor",this.furColor,1),this.highLevelFur&&(this._activeEffect.setVector3("furGravity",this.furGravity),this._activeEffect.setFloat("furOffset",this.furOffset),this._activeEffect.setFloat("furSpacing",this.furSpacing),this._activeEffect.setFloat("furDensity",this.furDensity),this._furTime+=this.getScene().getEngine().getDeltaTime()/this.furSpeed,this._activeEffect.setFloat("furTime",this._furTime),this._activeEffect.setTexture("furTexture",this.furTexture)),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.heightTexture&&this.heightTexture.animations&&this.heightTexture.animations.length>0&&e.push(this.heightTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._heightTexture&&e.push(this._heightTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this._heightTexture===e)},n.prototype.dispose=function(e){if(this.diffuseTexture&&this.diffuseTexture.dispose(),this._meshes)for(var i=1;i<this._meshes.length;i++)this._meshes[i].material.dispose(e),this._meshes[i].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.FurMaterial",this._meshes&&(i.sourceMeshName=this._meshes[0].name,i.quality=this._meshes.length),i},n.prototype.getClassName=function(){return"FurMaterial"},n.Parse=function(i,t,r){var o=e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r);return i.sourceMeshName&&o.highLevelFur&&t.executeWhenReady((function(){var e=t.getMeshByName(i.sourceMeshName);if(e){var r=n.GenerateTexture("Fur Texture",t);o.furTexture=r,n.FurifyMesh(e,i.quality)}})),o},n.GenerateTexture=function(i,t){for(var n=new e.DynamicTexture("FurTexture "+i,256,t,!0),r=n.getContext(),o=0;o<2e4;++o)r.fillStyle="rgba(255, "+Math.floor(255*Math.random())+", "+Math.floor(255*Math.random())+", 1)",r.fillRect(Math.random()*n.getSize().width,Math.random()*n.getSize().height,2,2);return n.update(!1),n.wrapU=e.Texture.WRAP_ADDRESSMODE,n.wrapV=e.Texture.WRAP_ADDRESSMODE,n},n.FurifyMesh=function(i,t){var r,o=[i],a=i.material;if(!(a instanceof n))throw"The material of the source mesh must be a Fur Material";for(r=1;r<t;r++){var s=new e.FurMaterial(a.name+r,i.getScene());i.getScene().materials.pop(),e.Tags.EnableFor(s),e.Tags.AddTagsTo(s,"furShellMaterial"),s.furLength=a.furLength,s.furAngle=a.furAngle,s.furGravity=a.furGravity,s.furSpacing=a.furSpacing,s.furSpeed=a.furSpeed,s.furColor=a.furColor,s.diffuseTexture=a.diffuseTexture,s.furOffset=r/t,s.furTexture=a.furTexture,s.highLevelFur=a.highLevelFur,s.furTime=a.furTime,s.furDensity=a.furDensity;var f=i.clone(i.name+r);f.material=s,f.skeleton=i.skeleton,f.position=e.Vector3.Zero(),o.push(f)}for(r=1;r<o.length;r++)o[r].parent=i;return i.material._meshes=o,o},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("heightTexture")],n.prototype,"_heightTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"heightTexture",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serialize()],n.prototype,"furLength",void 0),__decorate([e.serialize()],n.prototype,"furAngle",void 0),__decorate([e.serializeAsColor3()],n.prototype,"furColor",void 0),__decorate([e.serialize()],n.prototype,"furOffset",void 0),__decorate([e.serialize()],n.prototype,"furSpacing",void 0),__decorate([e.serializeAsVector3()],n.prototype,"furGravity",void 0),__decorate([e.serialize()],n.prototype,"furSpeed",void 0),__decorate([e.serialize()],n.prototype,"furDensity",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],n.prototype,"highLevelFur",void 0),__decorate([e.serialize()],n.prototype,"furTime",null),n})(e.PushMaterial);e.FurMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.furVertexShader="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\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\nuniform float furLength;\nuniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform vec3 furGravity;\nuniform float furTime;\nuniform float furSpacing;\nuniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else \nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);\nvec3 tangent2=vec3(-normal.z,0,normal.x);\nr=Rand(tangent1*r);\nfloat J=(2.0+4.0*r);\nr=Rand(tangent2*r);\nfloat K=(2.0+2.0*r);\ntangent1=tangent1*J+tangent2*K;\ntangent1=normalize(tangent1);\nvec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\n\nvec3 forceDirection=vec3(0.0,0.0,0.0);\nforceDirection.x=sin(furTime+position.x*0.05)*0.2;\nforceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;\nforceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;\nvec3 displacement=vec3(0.0,0.0,0.0);\ndisplacement=furGravity+forceDirection;\nfloat displacementFactor=pow(furOffset,3.0);\nvec3 aNormal=normal;\naNormal.xyz+=displacement*displacementFactor;\nnewPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\n#ifdef HIGHLEVEL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0))*aNormal);\n#else\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#endif\n\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\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\n}\n",
  4. BABYLON.Effect.ShadersStore.furPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 furColor;\nuniform float furLength;\nvarying vec3 vPositionW;\nvarying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform sampler2D furTexture;\nvarying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=furColor;\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\n\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));\nif (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {\ndiscard;\n}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);\nbaseColor=vec4(baseColor.xyz*occlusion,1.1-furOffset);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;\nvec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.BUMP=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!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.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r.specularColor=new e.Color3(0,0,0),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(a.texturesEnabled){if(this.mixTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this.mixTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}(this.bumpTexture1||this.bumpTexture2||this.bumpTexture3)&&e.StandardMaterial.BumpTextureEnabled&&(o._needUVs=!0,o._needNormals=!0,o.BUMP=!0)}if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","vClipPlane","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos"],d=["textureSampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","bump1Sampler","bump2Sampler","bump3Sampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("terrain",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this.mixTexture&&(this._activeEffect.setTexture("textureSampler",this._mixTexture),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture.coordinatesIndex,this._mixTexture.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture.getTextureMatrix()),e.StandardMaterial.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture("diffuse1Sampler",this._diffuseTexture1),this._activeEffect.setFloat2("diffuse1Infos",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture("diffuse2Sampler",this._diffuseTexture2),this._activeEffect.setFloat2("diffuse2Infos",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture("diffuse3Sampler",this._diffuseTexture3),this._activeEffect.setFloat2("diffuse3Infos",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale))),e.StandardMaterial.BumpTextureEnabled&&r.getEngine().getCaps().standardDerivatives&&(this._bumpTexture1&&this._activeEffect.setTexture("bump1Sampler",this._bumpTexture1),this._bumpTexture2&&this._activeEffect.setTexture("bump2Sampler",this._bumpTexture2),this._bumpTexture3&&this._activeEffect.setTexture("bump3Sampler",this._bumpTexture3))),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this.maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._mixTexture&&e.push(this._mixTexture),this._diffuseTexture1&&e.push(this._diffuseTexture1),this._diffuseTexture2&&e.push(this._diffuseTexture2),this._diffuseTexture3&&e.push(this._diffuseTexture3),this._bumpTexture1&&e.push(this._bumpTexture1),this._bumpTexture2&&e.push(this._bumpTexture2),this._bumpTexture3&&e.push(this._bumpTexture3),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._mixTexture===e||(this._diffuseTexture1===e||(this._diffuseTexture2===e||(this._diffuseTexture3===e||(this._bumpTexture1===e||(this._bumpTexture2===e||this._bumpTexture3===e))))))},n.prototype.dispose=function(e){this.mixTexture&&this.mixTexture.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.TerrainMaterial",i},n.prototype.getClassName=function(){return"TerrainMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture("mixTexture")],n.prototype,"_mixTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"mixTexture",void 0),__decorate([e.serializeAsTexture("diffuseTexture1")],n.prototype,"_diffuseTexture1",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture1",void 0),__decorate([e.serializeAsTexture("diffuseTexture2")],n.prototype,"_diffuseTexture2",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture2",void 0),__decorate([e.serializeAsTexture("diffuseTexture3")],n.prototype,"_diffuseTexture3",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture3",void 0),__decorate([e.serializeAsTexture("bumpTexture1")],n.prototype,"_bumpTexture1",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture1",void 0),__decorate([e.serializeAsTexture("bumpTexture2")],n.prototype,"_bumpTexture2",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture2",void 0),__decorate([e.serializeAsTexture("bumpTexture3")],n.prototype,"_bumpTexture3",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture3",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3()],n.prototype,"specularColor",void 0),__decorate([e.serialize()],n.prototype,"specularPower",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.TerrainMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.terrainVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\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\n}\n",BABYLON.Effect.ShadersStore.terrainPixelShader="precision 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<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{ \nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\nvoid main(void) {\n\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSEX=!1,i.DIFFUSEY=!1,i.DIFFUSEZ=!1,i.BUMPX=!1,i.BUMPY=!1,i.BUMPZ=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.NORMAL=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.tileSize=1,r.diffuseColor=new e.Color3(1,1,1),r.specularColor=new e.Color3(.2,.2,.2),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&a.texturesEnabled){if(e.StandardMaterial.DiffuseTextureEnabled)for(var f=[this.diffuseTextureX,this.diffuseTextureY,this.diffuseTextureZ],l=["DIFFUSEX","DIFFUSEY","DIFFUSEZ"],u=0;u<f.length;u++)if(f[u]){if(!f[u].isReady())return!1;o[l[u]]=!0}if(e.StandardMaterial.BumpTextureEnabled)for(var f=[this.normalTextureX,this.normalTextureY,this.normalTextureZ],l=["BUMPX","BUMPY","BUMPZ"],u=0;u<f.length;u++)if(f[u]){if(!f[u].isReady())return!1;o[l[u]]=!0}}if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var c=new e.EffectFallbacks;o.FOG&&c.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,c,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,t);var d=[e.VertexBuffer.PositionKind];o.NORMAL&&d.push(e.VertexBuffer.NormalKind),o.VERTEXCOLOR&&d.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(d,t,o,c),e.MaterialHelper.PrepareAttributesForInstances(d,o);var m=o.toString(),v=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","tileSize"],h=["diffuseSamplerX","diffuseSamplerY","diffuseSamplerZ","normalSamplerX","normalSamplerY","normalSamplerZ"],p=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:v,uniformBuffersNames:p,samplers:h,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("triplanar",{attributes:d,uniformsNames:v,uniformBuffersNames:p,samplers:h,defines:m,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._activeEffect.setFloat("tileSize",this.tileSize),r.getCachedMaterial()!==this&&(this.diffuseTextureX&&this._activeEffect.setTexture("diffuseSamplerX",this.diffuseTextureX),this.diffuseTextureY&&this._activeEffect.setTexture("diffuseSamplerY",this.diffuseTextureY),this.diffuseTextureZ&&this._activeEffect.setTexture("diffuseSamplerZ",this.diffuseTextureZ),this.normalTextureX&&this._activeEffect.setTexture("normalSamplerX",this.normalTextureX),this.normalTextureY&&this._activeEffect.setTexture("normalSamplerY",this.normalTextureY),this.normalTextureZ&&this._activeEffect.setTexture("normalSamplerZ",this.normalTextureZ),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this.maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTextureX&&e.push(this._diffuseTextureX),this._diffuseTextureY&&e.push(this._diffuseTextureY),this._diffuseTextureZ&&e.push(this._diffuseTextureZ),this._normalTextureX&&e.push(this._normalTextureX),this._normalTextureY&&e.push(this._normalTextureY),this._normalTextureZ&&e.push(this._normalTextureZ),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._diffuseTextureX===e||(this._diffuseTextureY===e||(this._diffuseTextureZ===e||(this._normalTextureX===e||(this._normalTextureY===e||this._normalTextureZ===e)))))},n.prototype.dispose=function(e){this.mixTexture&&this.mixTexture.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.TriPlanarMaterial",i},n.prototype.getClassName=function(){return"TriPlanarMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture()],n.prototype,"mixTexture",void 0),__decorate([e.serializeAsTexture("diffuseTextureX")],n.prototype,"_diffuseTextureX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTextureX",void 0),__decorate([e.serializeAsTexture("diffuseTexturY")],n.prototype,"_diffuseTextureY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTextureY",void 0),__decorate([e.serializeAsTexture("diffuseTextureZ")],n.prototype,"_diffuseTextureZ",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTextureZ",void 0),__decorate([e.serializeAsTexture("normalTextureX")],n.prototype,"_normalTextureX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"normalTextureX",void 0),__decorate([e.serializeAsTexture("normalTextureY")],n.prototype,"_normalTextureY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"normalTextureY",void 0),__decorate([e.serializeAsTexture("normalTextureZ")],n.prototype,"_normalTextureZ",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"normalTextureZ",void 0),__decorate([e.serialize()],n.prototype,"tileSize",void 0),__decorate([e.serializeAsColor3()],n.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3()],n.prototype,"specularColor",void 0),__decorate([e.serialize()],n.prototype,"specularPower",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.TriPlanarMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.triplanarVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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 DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\nvec3 worldNormal=normalize(cross(worldTangent,worldBinormal));\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\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\n}\n",BABYLON.Effect.ShadersStore.triplanarPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\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]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.POINTSIZE=!1,i.FOG=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.luminance=1,r.turbidity=10,r.rayleigh=2,r.mieCoefficient=.005,r.mieDirectionalG=.8,r.distance=500,r.inclination=.49,r.azimuth=.25,r.sunPosition=new e.Vector3(0,100,0),r.useSunPosition=!1,r._cameraPosition=e.Vector3.Zero(),r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;if(e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!1),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var s=new e.EffectFallbacks;o.FOG&&s.addFallback(1,"FOG");var f=[e.VertexBuffer.PositionKind];o.VERTEXCOLOR&&f.push(e.VertexBuffer.ColorKind);var l=o.toString();n.setEffect(a.getEngine().createEffect("sky",f,["world","viewProjection","view","vFogInfos","vFogColor","pointSize","vClipPlane","luminance","turbidity","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","cameraPosition"],[],l,s,this.onCompiled,this.onError),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene();if(n._materialDefines){var o=n.effect;if(this._activeEffect=o,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),this._mustRebind(r,o)){if(r.clipPlane){var a=r.clipPlane;this._activeEffect.setFloat4("vClipPlane",a.normal.x,a.normal.y,a.normal.z,a.d)}this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize)}r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect);var s=r.activeCamera;if(s){var f=s.getWorldMatrix();this._cameraPosition.x=f.m[12],this._cameraPosition.y=f.m[13],
  5. this._cameraPosition.z=f.m[14],this._activeEffect.setVector3("cameraPosition",this._cameraPosition)}if(this.luminance>0&&this._activeEffect.setFloat("luminance",this.luminance),this._activeEffect.setFloat("turbidity",this.turbidity),this._activeEffect.setFloat("rayleigh",this.rayleigh),this._activeEffect.setFloat("mieCoefficient",this.mieCoefficient),this._activeEffect.setFloat("mieDirectionalG",this.mieDirectionalG),!this.useSunPosition){var l=Math.PI*(this.inclination-.5),u=2*Math.PI*(this.azimuth-.5);this.sunPosition.x=this.distance*Math.cos(u),this.sunPosition.y=this.distance*Math.sin(u)*Math.sin(l),this.sunPosition.z=this.distance*Math.sin(u)*Math.cos(l)}this._activeEffect.setVector3("sunPosition",this.sunPosition),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){return[]},n.prototype.dispose=function(e){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.SkyMaterial",i},n.prototype.getClassName=function(){return"SkyMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serialize()],n.prototype,"luminance",void 0),__decorate([e.serialize()],n.prototype,"turbidity",void 0),__decorate([e.serialize()],n.prototype,"rayleigh",void 0),__decorate([e.serialize()],n.prototype,"mieCoefficient",void 0),__decorate([e.serialize()],n.prototype,"mieDirectionalG",void 0),__decorate([e.serialize()],n.prototype,"distance",void 0),__decorate([e.serialize()],n.prototype,"inclination",void 0),__decorate([e.serialize()],n.prototype,"azimuth",void 0),__decorate([e.serializeAsVector3()],n.prototype,"sunPosition",void 0),__decorate([e.serialize()],n.prototype,"useSunPosition",void 0),n})(e.PushMaterial);e.SkyMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.skyVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nvoid main(void) {\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.skyPixelShader="precision highp float;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\nuniform vec3 cameraPosition;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n\n#include<fogFragmentDeclaration>\n\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst vec3 up=vec3(0.0,1.0,0.0);\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{ \nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp(-((cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\n\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0); \ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance; \nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled); \nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\n\n\n\nvec3 retColor=curr*whiteScale;\n\n\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.TRANSPARENT=!1,i.FOG=!1,i.PREMULTIPLYALPHA=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.mainColor=e.Color3.Black(),r.lineColor=e.Color3.Teal(),r.gridRatio=1,r.gridOffset=e.Vector3.Zero(),r.majorUnitFrequency=10,r.minorUnitVisibility=.33,r.opacity=1,r.preMultiplyAlpha=!1,r._gridControl=new e.Vector4(r.gridRatio,r.majorUnitFrequency,r.minorUnitVisibility,r.opacity),r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.opacity<1},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;if(o.TRANSPARENT!==this.opacity<1&&(o.TRANSPARENT=!o.TRANSPARENT,o.markAsUnprocessed()),o.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(o.PREMULTIPLYALPHA=!o.PREMULTIPLYALPHA,o.markAsUnprocessed()),e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,!1,this.fogEnabled,o),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var s=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],f=o.toString();n.setEffect(a.getEngine().createEffect("grid",s,["projection","worldView","mainColor","lineColor","gridControl","gridOffset","vFogInfos","vFogColor","world","view"],[],f,null,this.onCompiled,this.onError),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene();if(n._materialDefines){var o=n.effect;this._activeEffect=o,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("worldView",i.multiply(r.getViewMatrix())),this._activeEffect.setMatrix("view",r.getViewMatrix()),this._activeEffect.setMatrix("projection",r.getProjectionMatrix()),this._mustRebind(r,o)&&(this._activeEffect.setColor3("mainColor",this.mainColor),this._activeEffect.setColor3("lineColor",this.lineColor),this._activeEffect.setVector3("gridOffset",this.gridOffset),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4("gridControl",this._gridControl)),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.dispose=function(e){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.GridMaterial",i},n.prototype.getClassName=function(){return"GridMaterial"},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsColor3()],n.prototype,"mainColor",void 0),__decorate([e.serializeAsColor3()],n.prototype,"lineColor",void 0),__decorate([e.serialize()],n.prototype,"gridRatio",void 0),__decorate([e.serializeAsColor3()],n.prototype,"gridOffset",void 0),__decorate([e.serialize()],n.prototype,"majorUnitFrequency",void 0),__decorate([e.serialize()],n.prototype,"minorUnitVisibility",void 0),__decorate([e.serialize()],n.prototype,"opacity",void 0),__decorate([e.serialize()],n.prototype,"preMultiplyAlpha",void 0),n})(e.PushMaterial);e.GridMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.gridVertexShader="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 projection;\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 worldView;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\nvoid main(void) {\n#ifdef FOG\nvec4 worldPos=world*vec4(position,1.0);\n#endif\n#include<fogVertex>\nvec4 cameraSpacePosition=worldView*vec4(position,1.0);\ngl_Position=projection*cameraSpacePosition;\n#ifdef TRANSPARENT\nvCameraSpacePosition=cameraSpacePosition;\n#endif\nvPosition=position;\nvNormal=normal;\n}",BABYLON.Effect.ShadersStore.gridPixelShader="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\nfloat getVisibility(float position) {\n\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n} \nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result; \n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2; \n\nfloat result=isPointOnLine(position,differentialLength);\n\nfloat visibility=getVisibility(position);\nresult*=visibility;\n\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\nvoid main(void) {\n\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset)/gridRatio;\n\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\n\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n\nfloat grid=clamp(x+y+z,0.,1.);\n\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\n#ifdef TRANSPARENT\nfloat distanceToFragment=length(vCameraSpacePosition.xyz);\nfloat cameraPassThrough=clamp(distanceToFragment-0.25,0.0,1.0);\nfloat opacity=clamp(grid,0.08,cameraPassThrough*gridControl.w*grid);\ngl_FragColor=vec4(color.rgb,opacity);\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n\ngl_FragColor=vec4(color.rgb,1.0);\n#endif\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.AMBIENT=!1,i.OPACITY=!1,i.OPACITYRGB=!1,i.REFLECTION=!1,i.EMISSIVE=!1,i.SPECULAR=!1,i.BUMP=!1,i.PARALLAX=!1,i.PARALLAXOCCLUSION=!1,i.SPECULAROVERALPHA=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.ALPHAFROMDIFFUSE=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.DIFFUSEFRESNEL=!1,i.OPACITYFRESNEL=!1,i.REFLECTIONFRESNEL=!1,i.REFRACTIONFRESNEL=!1,i.EMISSIVEFRESNEL=!1,i.FRESNEL=!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.GLOSSINESS=!1,i.ROUGHNESS=!1,i.EMISSIVEASILLUMINATION=!1,i.LINKEMISSIVEWITHDIFFUSE=!1,i.REFLECTIONFRESNELFROMSPECULAR=!1,i.LIGHTMAP=!1,i.USELIGHTMAPASSHADOWMAP=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.LOGARITHMICDEPTH=!1,i.REFRACTION=!1,i.REFRACTIONMAP_3D=!1,i.REFLECTIONOVERALPHA=!1,i.TWOSIDEDLIGHTING=!1,i.SHADOWFLOAT=!1,i.MORPHTARGETS=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS_TANGENT=!1,i.NUM_MORPH_INFLUENCERS=0,i.IMAGEPROCESSING=!1,i.VIGNETTE=!1,i.VIGNETTEBLENDMODEMULTIPLY=!1,i.VIGNETTEBLENDMODEOPAQUE=!1,i.TONEMAPPING=!1,i.CONTRAST=!1,i.COLORCURVES=!1,i.COLORGRADING=!1,i.SAMPLER3DGREENDEPTH=!1,i.SAMPLER3DBGRMAP=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.EXPOSURE=!1,i.rebuild(),i}return __extends(i,e),i.prototype.setReflectionMode=function(e){for(var i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],t=0,n=i;t<n.length;t++){var r=n[t];this[r]=r===e}},i})(e.MaterialDefines);e.StandardMaterialDefines_OldVer=i;var t=(function(t){function n(i,r){var o=t.call(this,i,r)||this;return o.ambientColor=new e.Color3(0,0,0),o.diffuseColor=new e.Color3(1,1,1),o.specularColor=new e.Color3(1,1,1),o.emissiveColor=new e.Color3(0,0,0),o.specularPower=64,o._useAlphaFromDiffuseTexture=!1,o._useEmissiveAsIllumination=!1,o._linkEmissiveWithDiffuse=!1,o._useSpecularOverAlpha=!1,o._useReflectionOverAlpha=!1,o._disableLighting=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o._roughness=0,o.indexOfRefraction=.98,o.invertRefractionY=!0,o._useLightmapAsShadowmap=!1,o._useReflectionFresnelFromSpecular=!1,o._useGlossinessFromSpecularMapAlpha=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._renderTargets=new e.SmartArray(16),o._worldViewProjectionMatrix=e.Matrix.Zero(),o._globalAmbientColor=new e.Color3(0,0,0),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),n.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),n.RefractionTextureEnabled&&o._refractionTexture&&o._refractionTexture.isRenderTarget&&o._renderTargets.push(o._refractionTexture),o._renderTargets},o}return __extends(n,t),Object.defineProperty(n.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),n.prototype._attachImageProcessingConfiguration=function(e){var i=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){i._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(n.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),n.prototype.getClassName=function(){return"StandardMaterial_OldVer"},Object.defineProperty(n.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),n.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},n.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},n.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},n.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},n.prototype.isReadyForSubMesh=function(t,r,o){if(this.isFrozen&&this._wasPreviouslyReady&&r.effect)return!0;r._materialDefines||(r._materialDefines=new i);var a=this.getScene(),s=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&s._renderId===a.getRenderId())return!0;var f=a.getEngine();if(s._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,s,!0,this._maxSimultaneousLights,this._disableLighting),s._areTexturesDirty){if(s._needUVs=!1,a.texturesEnabled){if(this._diffuseTexture&&n.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.DIFFUSE=!0}else s.DIFFUSE=!1;if(this._ambientTexture&&n.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.AMBIENT=!0}else s.AMBIENT=!1;if(this._opacityTexture&&n.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.OPACITY=!0,s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;if(this._reflectionTexture&&n.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(s._needNormals=!0,s.REFLECTION=!0,s.ROUGHNESS=this._roughness>0,s.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,s.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,s.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:s.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:s.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:s.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:s.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:s.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:s.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else s.REFLECTION=!1;if(this._emissiveTexture&&n.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.EMISSIVE=!0}else s.EMISSIVE=!1;if(this._lightmapTexture&&n.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.LIGHTMAP=!0,s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._specularTexture&&n.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.SPECULAR=!0,s.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else s.SPECULAR=!1;if(a.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&n.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;s._needUVs=!0,s.BUMP=!0,s.PARALLAX=this._useParallax,s.PARALLAXOCCLUSION=this._useParallaxOcclusion}else s.BUMP=!1;if(this._refractionTexture&&n.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.REFRACTION=!0,s.REFRACTIONMAP_3D=this._refractionTexture.isCube}else s.REFRACTION=!1;s.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else s.DIFFUSE=!1,s.AMBIENT=!1,s.OPACITY=!1,s.REFLECTION=!1,s.EMISSIVE=!1,s.LIGHTMAP=!1,s.BUMP=!1,s.REFRACTION=!1;s.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),s.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,s.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,s.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s._areFresnelDirty&&(n.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(s.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,s.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,s.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,s.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,s.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,s.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,s._needNormals=!0,s.FRESNEL=!0):s.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(t,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForAttributes(t,s,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,f,s,o),s.isDirty){s.markAsProcessed(),a.resetCachedMaterial();var l=new e.EffectFallbacks;s.REFLECTION&&l.addFallback(0,"REFLECTION"),s.SPECULAR&&l.addFallback(0,"SPECULAR"),s.BUMP&&l.addFallback(0,"BUMP"),s.PARALLAX&&l.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&l.addFallback(1,"FOG"),s.POINTSIZE&&l.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,l,this._maxSimultaneousLights),s.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),s.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),s.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),s.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),s.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),s.FRESNEL&&l.addFallback(4,"FRESNEL");var u=[e.VertexBuffer.PositionKind];s.NORMAL&&u.push(e.VertexBuffer.NormalKind),s.UV1&&u.push(e.VertexBuffer.UVKind),s.UV2&&u.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,t,s,l),e.MaterialHelper.PrepareAttributesForInstances(u,s),e.MaterialHelper.PrepareAttributesForMorphTargets(u,t,s);var c="default",d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vTangentSpaceParams"],m=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],v=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(d,s),e.ImageProcessingConfiguration.PrepareSamplers(m,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:v,samplers:m,defines:s,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(c=this.customShaderNameResolve(c,d,v,m,s));var h=s.toString();r.setEffect(a.getEngine().createEffect(c,{attributes:u,uniformsNames:d,uniformBuffersNames:v,samplers:m,defines:h,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},f),s),this.buildUniformLayout()}return!!r.effect.isReady()&&(s._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},n.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),t.prototype.unbind.call(this)},n.prototype.bindForSubMesh=function(i,t,r){var o=this.getScene(),a=r._materialDefines;if(a){var s=r.effect;if(this._activeEffect=s,this.bindOnlyWorldMatrix(i),e.MaterialHelper.BindBonesParameters(t,s),this._mustRebind(o,s,t.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.FresnelEnabled&&a.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),
  6. o.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._uniformBuffer.updateMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._ambientTexture&&n.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),this._uniformBuffer.updateMatrix("ambientMatrix",this._ambientTexture.getTextureMatrix())),this._opacityTexture&&n.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._uniformBuffer.updateMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix())),this._reflectionTexture&&n.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&n.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),this._uniformBuffer.updateMatrix("emissiveMatrix",this._emissiveTexture.getTextureMatrix())),this._lightmapTexture&&n.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),this._uniformBuffer.updateMatrix("lightmapMatrix",this._lightmapTexture.getTextureMatrix())),this._specularTexture&&n.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),this._uniformBuffer.updateMatrix("specularMatrix",this._specularTexture.getTextureMatrix())),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),this._uniformBuffer.updateMatrix("bumpMatrix",this._bumpTexture.getTextureMatrix()),o._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&n.RefractionTextureEnabled)){var f=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(f=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,f,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),a.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&n.DiffuseTextureEnabled&&s.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&n.AmbientTextureEnabled&&s.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&n.OpacityTextureEnabled&&s.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&n.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture("reflectionCubeSampler",this._reflectionTexture):s.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&n.EmissiveTextureEnabled&&s.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&n.LightmapTextureEnabled&&s.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&n.SpecularTextureEnabled&&s.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&n.BumpTextureEnabled&&s.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&n.RefractionTextureEnabled)){var f=1;this._refractionTexture.isCube?s.setTexture("refractionCubeSampler",this._refractionTexture):s.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(s,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),s.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.position),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,s)&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,t,s,a,this._maxSimultaneousLights),(o.fogEnabled&&t.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(s),e.MaterialHelper.BindFogParameters(o,t,s),a.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(t,s),e.MaterialHelper.BindLogDepth(a,s,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},n.prototype.dispose=function(e,i){i&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),t.prototype.dispose.call(this,e,i)},n.prototype.clone=function(i){var t=this,r=e.SerializationHelper.Clone((function(){return new n(i,t.getScene())}),this);return r.name=i,r.id=i,r},n.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},Object.defineProperty(n,"DiffuseTextureEnabled",{get:function(){return n._DiffuseTextureEnabled},set:function(i){n._DiffuseTextureEnabled!==i&&(n._DiffuseTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"AmbientTextureEnabled",{get:function(){return n._AmbientTextureEnabled},set:function(i){n._AmbientTextureEnabled!==i&&(n._AmbientTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"OpacityTextureEnabled",{get:function(){return n._OpacityTextureEnabled},set:function(i){n._OpacityTextureEnabled!==i&&(n._OpacityTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ReflectionTextureEnabled",{get:function(){return n._ReflectionTextureEnabled},set:function(i){n._ReflectionTextureEnabled!==i&&(n._ReflectionTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"EmissiveTextureEnabled",{get:function(){return n._EmissiveTextureEnabled},set:function(i){n._EmissiveTextureEnabled!==i&&(n._EmissiveTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SpecularTextureEnabled",{get:function(){return n._SpecularTextureEnabled},set:function(i){n._SpecularTextureEnabled!==i&&(n._SpecularTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"BumpTextureEnabled",{get:function(){return n._BumpTextureEnabled},set:function(i){n._BumpTextureEnabled!==i&&(n._BumpTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LightmapTextureEnabled",{get:function(){return n._LightmapTextureEnabled},set:function(i){n._LightmapTextureEnabled!==i&&(n._LightmapTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"RefractionTextureEnabled",{get:function(){return n._RefractionTextureEnabled},set:function(i){n._RefractionTextureEnabled!==i&&(n._RefractionTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ColorGradingTextureEnabled",{get:function(){return n._ColorGradingTextureEnabled},set:function(i){n._ColorGradingTextureEnabled!==i&&(n._ColorGradingTextureEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n,"FresnelEnabled",{get:function(){return n._FresnelEnabled},set:function(i){n._FresnelEnabled!==i&&(n._FresnelEnabled=i,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),n._DiffuseTextureEnabled=!0,n._AmbientTextureEnabled=!0,n._OpacityTextureEnabled=!0,n._ReflectionTextureEnabled=!0,n._EmissiveTextureEnabled=!0,n._SpecularTextureEnabled=!0,n._BumpTextureEnabled=!0,n._LightmapTextureEnabled=!0,n._RefractionTextureEnabled=!0,n._ColorGradingTextureEnabled=!0,n._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],n.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],n.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],n.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],n.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],n.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],n.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],n.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],n.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],n.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],n.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],n.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],n.prototype,"emissiveColor",void 0),__decorate([e.serialize()],n.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],n.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],n.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],n.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],n.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],n.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],n.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],n.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],n.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],n.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"roughness",void 0),__decorate([e.serialize()],n.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],n.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],n.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],n.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],n.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],n.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],n.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],n.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],n.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],n.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],n.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],n.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],n.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],n.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],n.prototype,"useLogarithmicDepth",null),n})(e.PushMaterial);e.StandardMaterial_OldVer=t;var n=(function(){function e(){}return e})();e.CustomShaderStructure=n;var r=(function(){function e(){}return e})();e.ShaderSpecialParts=r;var o=(function(e){function i(){var i=e.call(this)||this;return i.VertexStore="",i.FragmentStore="#include<__decl__defaultFragment>\n#[Fragment_Begin]\n#extension GL_OES_standard_derivatives : enable\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW_helper;\nvarying vec3 localNormal;\nvarying vec3 localPosition;\nvec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#[Fragment_Definitions]\n\nvoid main(void) {\n\nvNormalW = vNormalW_helper;\n#[Fragment_MainBegin]\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#[Fragment_Custom_Diffuse]\n\nfloat alpha=vDiffuseColor.a;\n#[Fragment_Custom_Alpha]\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\n\n// Apply image processing if relevant. As this applies in linear space, \n// We first move from gamma to linear.\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\tcolor.rgb = toLinearSpace(color.rgb);\n#else\n\t#ifdef IMAGEPROCESSING\n\t\tcolor.rgb = toLinearSpace(color.rgb);\n\t\tcolor = applyImageProcessing(color);\n\t#endif\n#endif\n\n#[Fragment_Before_FragColor]\ngl_FragColor=color;\n}",i.VertexStore="#include<__decl__defaultVertex>\n\n#[Vertex_Begin]\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\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>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\n#endif\n#ifdef BUMP\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 localPosition;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW_helper;\nvarying vec3 localNormal;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n\n#[Vertex_Definitions]\n\nvoid main(void) {\n \n #[Vertex_MainBegin]\n \nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\n\nlocalPosition = positionUpdated;\n#[Vertex_Before_PositionUpdated]\n\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\n\n#[Vertex_Before_NormalUpdated]\n\nlocalNormal = normalUpdated;\nvNormalW_helper=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}",i}return __extends(i,e),i})(n);e.ShaderForVer3_0=o;var a=(function(){function e(){}return e.Ver3_0="3.0.0",e})();e.StandardShaderVersions=a;var s=(function(i){function t(e,t){var n=i.call(this,e,t)||this;return n.CustomParts=new r,n.customShaderNameResolve=n.Builder,n.SelectVersion("3.0.0"),n}return __extends(t,i),t.prototype.AttachAfterBind=function(e,i){for(var t in this._newUniformInstances){var n=t.toString().split("-");"vec2"==n[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?i.setVector4(n[1],this._newUniformInstances[t]):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t])}for(var t in this._newSamplerInstances){var n=t.toString().split("-")
  7. ;"sampler2D"==n[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[1],this._newSamplerInstances[t])}},t.prototype.ReviewUniform=function(e,i){if("uniform"==e)for(var t in this._newUniforms)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);if("sampler"==e)for(var t in this._newUniforms)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);return i},t.prototype.Builder=function(i,n,r,o,a){var s=this;if(this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,t.ShaderIndexer++;var f=f+"custom_"+t.ShaderIndexer;this.ReviewUniform("uniform",n),this.ReviewUniform("sampler",o);var l=this._afterBind;return this._afterBind=function(e,i){s.AttachAfterBind(e,i);try{l(e,i)}catch(i){}},e.Effect.ShadersStore[f+"VertexShader"]=this.ShaderVersion.VertexStore.replace("#[Vertex_Begin]",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#[Vertex_Definitions]",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#[Vertex_MainBegin]",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#[Vertex_Before_PositionUpdated]",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#[Vertex_Before_NormalUpdated]",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:""),e.Effect.ShadersStore[f+"PixelShader"]=this.ShaderVersion.FragmentStore.replace("#[Fragment_Begin]",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#[Fragment_MainBegin]",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#[Fragment_Definitions]",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#[Fragment_Custom_Diffuse]",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:"").replace("#[Fragment_Custom_Alpha]",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#[Fragment_Before_FragColor]",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this._isCreatedShader=!0,this._createdShaderName=f,f},t.prototype.SelectVersion=function(e){switch(e){case"3.0.0":this.ShaderVersion=new o}},t.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances=new Array,this._newUniformInstances=new Array),t&&(i.indexOf("sampler"),this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},t.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},t.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},t.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},t.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace("result","diffuseColor"),this},t.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},t.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},t.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},t.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},t.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},t.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},t.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},t.ShaderIndexer=1,t})(t);e.CustomMaterial=s})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!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.NDOTL=!0,i.CUSTOMUSERLIGHTING=!0,i.CELLBASIC=!0,i.DEPTHPREPASS=!1,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(i,n){var r=t.call(this,i,n)||this;return r.diffuseColor=new e.Color3(1,1,1),r._computeHighLevel=!1,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return __extends(n,t),n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.isReadyForSubMesh=function(t,n,r){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new i);var o=n._materialDefines,a=this.getScene();if(!this.checkReadyOnEveryCall&&n.effect&&this._renderId===a.getRenderId())return!0;var s=a.getEngine();if(o._areTexturesDirty&&(o._needUVs=!1,a.texturesEnabled&&this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;o._needUVs=!0,o.DIFFUSE=!0}if(o.CELLBASIC=!this.computeHighLevel,e.MaterialHelper.PrepareDefinesForMisc(t,a,!1,this.pointsCloud,this.fogEnabled,o),o._needNormals=e.MaterialHelper.PrepareDefinesForLights(a,t,o,!1,this._maxSimultaneousLights,this._disableLighting),e.MaterialHelper.PrepareDefinesForFrameBoundValues(a,s,o,r),e.MaterialHelper.PrepareDefinesForAttributes(t,o,!0,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var f=new e.EffectFallbacks;o.FOG&&f.addFallback(1,"FOG"),e.MaterialHelper.HandleFallbacksForShadows(o,f,this.maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,t);var l=[e.VertexBuffer.PositionKind];o.NORMAL&&l.push(e.VertexBuffer.NormalKind),o.UV1&&l.push(e.VertexBuffer.UVKind),o.UV2&&l.push(e.VertexBuffer.UV2Kind),o.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,t,o,f),e.MaterialHelper.PrepareAttributesForInstances(l,o);var u=o.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","diffuseMatrix"],d=["diffuseSampler"],m=new Array;e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:o,maxSimultaneousLights:this.maxSimultaneousLights}),n.setEffect(a.getEngine().createEffect("cell",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},s),o)}return!!n.effect.isReady()&&(this._renderId=a.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.bindForSubMesh=function(i,t,n){var r=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(i),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),e.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(r,a)&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),e.MaterialHelper.BindClipPlane(this._activeEffect,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setVector3("vEyePosition",r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.position)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(r,t,this._activeEffect,o,this._maxSimultaneousLights),r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),e.MaterialHelper.BindFogParameters(r,t,this._activeEffect),this._afterBind(t,this._activeEffect)}},n.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},n.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),e},n.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this._diffuseTexture===e},n.prototype.dispose=function(e){this._diffuseTexture&&this._diffuseTexture.dispose(),t.prototype.dispose.call(this,e)},n.prototype.getClassName=function(){return"CellMaterial"},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.CellMaterial",i},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},__decorate([e.serializeAsTexture("diffuseTexture")],n.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("diffuseColor")],n.prototype,"diffuseColor",void 0),__decorate([e.serialize("computeHighLevel")],n.prototype,"_computeHighLevel",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"computeHighLevel",void 0),__decorate([e.serialize("disableLighting")],n.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),__decorate([e.serialize("maxSimultaneousLights")],n.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),n})(e.PushMaterial);e.CellMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.cellVertexShader="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",BABYLON.Effect.ShadersStore.cellPixelShader="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";var BABYLON;!(function(e){var i=(function(e){function i(){var i=e.call(this)||this;return i.ALBEDO=!1,i.AMBIENT=!1,i.AMBIENTINGRAYSCALE=!1,i.OPACITY=!1,i.OPACITYRGB=!1,i.REFLECTION=!1,i.EMISSIVE=!1,i.REFLECTIVITY=!1,i.BUMP=!1,i.PARALLAX=!1,i.PARALLAXOCCLUSION=!1,i.SPECULAROVERALPHA=!1,i.CLIPPLANE=!1,i.ALPHATEST=!1,i.ALPHAFROMALBEDO=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.OPACITYFRESNEL=!1,i.EMISSIVEFRESNEL=!1,i.FRESNEL=!1,i.NORMAL=!1,i.TANGENT=!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.MICROSURFACEFROMREFLECTIVITYMAP=!1,i.MICROSURFACEAUTOMATIC=!1,i.EMISSIVEASILLUMINATION=!1,i.LINKEMISSIVEWITHALBEDO=!1,i.LIGHTMAP=!1,i.USELIGHTMAPASSHADOWMAP=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.LOGARITHMICDEPTH=!1,i.CAMERATONEMAP=!1,i.CAMERACONTRAST=!1,i.CAMERACOLORGRADING=!1,i.CAMERACOLORCURVES=!1,i.OVERLOADEDVALUES=!1,i.OVERLOADEDSHADOWVALUES=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.REFRACTION=!1,i.REFRACTIONMAP_3D=!1,i.LINKREFRACTIONTOTRANSPARENCY=!1,i.REFRACTIONMAPINLINEARSPACE=!1,i.LODBASEDMICROSFURACE=!1,i.USEPHYSICALLIGHTFALLOFF=!1,i.RADIANCEOVERALPHA=!1,i.USEPMREMREFLECTION=!1,i.USEPMREMREFRACTION=!1,i.TWOSIDEDLIGHTING=!1,i.SHADOWFLOAT=!1,i.METALLICWORKFLOW=!1,i.METALLICMAP=!1,i.ROUGHNESSSTOREINMETALMAPALPHA=!1,i.ROUGHNESSSTOREINMETALMAPGREEN=!1,i.METALLNESSSTOREINMETALMAPBLUE=!1,i.AOSTOREINMETALMAPRED=!1,i.MICROSURFACEMAP=!1,i.MORPHTARGETS=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS_TANGENT=!1,i.NUM_MORPH_INFLUENCERS=0,i.rebuild(),i}return __extends(i,e),i})(e.MaterialDefines),t=(function(t){function n(n,r){var o=t.call(this,n,r)||this;return o.directIntensity=1,o.emissiveIntensity=1,o.environmentIntensity=1,o.specularIntensity=1,o._lightingInfos=new e.Vector4(o.directIntensity,o.emissiveIntensity,o.environmentIntensity,o.specularIntensity),o.disableBumpMap=!1,o.overloadedShadowIntensity=1,o.overloadedShadeIntensity=1,o._overloadedShadowInfos=new e.Vector4(o.overloadedShadowIntensity,o.overloadedShadeIntensity,0,0),o.cameraExposure=1,o.cameraContrast=1,o.cameraColorGradingTexture=null,o.cameraColorCurves=null,o._cameraInfos=new e.Vector4(1,1,0,0),o._microsurfaceTextureLods=new e.Vector2(0,0),o.overloadedAmbient=e.Color3.White(),o.overloadedAmbientIntensity=0,o.overloadedAlbedo=e.Color3.White(),o.overloadedAlbedoIntensity=0,o.overloadedReflectivity=new e.Color3(0,0,0),o.overloadedReflectivityIntensity=0,o.overloadedEmissive=e.Color3.White(),o.overloadedEmissiveIntensity=0,o._overloadedIntensity=new e.Vector4(o.overloadedAmbientIntensity,o.overloadedAlbedoIntensity,o.overloadedReflectivityIntensity,o.overloadedEmissiveIntensity),o.overloadedReflection=e.Color3.White(),o.overloadedReflectionIntensity=0,o.overloadedMicroSurface=0,o.overloadedMicroSurfaceIntensity=0,o._overloadedMicroSurface=new e.Vector3(o.overloadedMicroSurface,o.overloadedMicroSurfaceIntensity,o.overloadedReflectionIntensity),o.ambientTextureStrength=1,o.ambientColor=new e.Color3(0,0,0),o.albedoColor=new e.Color3(1,1,1),o.reflectivityColor=new e.Color3(1,1,1),o.reflectionColor=new e.Color3(0,0,0),o.emissiveColor=new e.Color3(0,0,0),o.microSurface=.9,o.indexOfRefraction=.66,o.invertRefractionY=!1,o.linkRefractionWithTransparency=!1,o.linkEmissiveWithAlbedo=!1,o.useLightmapAsShadowmap=!1,o.useEmissiveAsIllumination=!1,o.useAlphaFromAlbedoTexture=!1,o.useSpecularOverAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!1,o.useRoughnessFromMetallicTextureAlpha=!0,o.useRoughnessFromMetallicTextureGreen=!1,o.useMetallnessFromMetallicTextureBlue=!1,o.useAmbientOcclusionFromMetallicTextureRed=!1,o.useAmbientInGrayScale=!1,o.useAutoMicroSurfaceFromReflectivityMap=!1,o.useScalarInLinearSpace=!1,o.usePhysicalLightFalloff=!0,o.useRadianceOverAlpha=!0,o.useParallax=!1,o.useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o.disableLighting=!1,o.maxSimultaneousLights=4,o.invertNormalMapX=!1,o.invertNormalMapY=!1,o.twoSidedLighting=!1,o._renderTargets=new e.SmartArray(16),o._globalAmbientColor=new e.Color3(0,0,0),o._tempColor=new e.Color3,o._defines=new i,o._cachedDefines=new i,o._myScene=null,o._cachedDefines.BonesPerMesh=-1,o.getRenderTargetTextures=function(){return o._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&o.reflectionTexture&&o.reflectionTexture.isRenderTarget&&o._renderTargets.push(o.reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&o.refractionTexture&&o.refractionTexture.isRenderTarget&&o._renderTargets.push(o.refractionTexture),o._renderTargets},o}return __extends(n,t),n.prototype.getClassName=function(){return"LegacyPBRMaterial"},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}),n.prototype.needAlphaBlending=function(){return!this.linkRefractionWithTransparency&&(this.alpha<1||null!=this.opacityTexture||this._shouldUseAlphaFromAlbedoTexture()||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled)},n.prototype.needAlphaTesting=function(){return!this.linkRefractionWithTransparency&&(null!=this.albedoTexture&&this.albedoTexture.hasAlpha)},n.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this.albedoTexture&&this.albedoTexture.hasAlpha&&this.useAlphaFromAlbedoTexture},n.prototype.getAlphaTestTexture=function(){return this.albedoTexture},n.prototype._checkCache=function(e,i,t){return!i||(this._defines.INSTANCES,!1)},n.prototype.convertColorToLinearSpaceToRef=function(e,i){n.convertColorToLinearSpaceToRef(e,i,this.useScalarInLinearSpace)},n.convertColorToLinearSpaceToRef=function(e,i,t){t?(i.r=e.r,i.g=e.g,i.b=e.b):e.toLinearSpaceToRef(i)},n.BindLights=function(i,t,r,o,a,s,f){for(var l=0,u=0,c=t._lightSources;u<c.length;u++){var d=c[u],m=d._uniformBuffer.useUbo;if(d._uniformBuffer.bindToEffect(r,"Light"+l),e.MaterialHelper.BindLightProperties(d,r,l),this.convertColorToLinearSpaceToRef(d.diffuse,n._scaledAlbedo,a),n._scaledAlbedo.scaleToRef(d.intensity,n._scaledAlbedo),d._uniformBuffer.updateColor4(m?"vLightDiffuse":"vLightDiffuse"+l,n._scaledAlbedo,f?d.radius:d.range),o.SPECULARTERM&&(this.convertColorToLinearSpaceToRef(d.specular,n._scaledReflectivity,a),n._scaledReflectivity.scaleToRef(d.intensity,n._scaledReflectivity),d._uniformBuffer.updateColor3(m?"vLightSpecular":"vLightSpecular"+l,n._scaledReflectivity)),i.shadowsEnabled&&e.MaterialHelper.BindLightShadow(d,i,t,l+"",r),d._uniformBuffer.update(),++l===s)break}},n.prototype.isReady=function(i,t){var n=this;if(this.isFrozen&&this._wasPreviouslyReady)return!0;var r=this.getScene(),o=r.getEngine(),a=!1;if(this._defines.reset(),r.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.PrepareDefinesForLights(r,i,this._defines,!0,this.maxSimultaneousLights),!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId()&&this._checkCache(r,i,t))return!0;if(r.texturesEnabled){if(r.getEngine().getCaps().textureLOD&&(this._defines.LODBASEDMICROSFURACE=!0),this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this.albedoTexture.isReady())return!1;a=!0,this._defines.ALBEDO=!0}if(this.ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this.ambientTexture.isReady())return!1;a=!0,this._defines.AMBIENT=!0,this._defines.AMBIENTINGRAYSCALE=this.useAmbientInGrayScale}if(this.opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this.opacityTexture.isReady())return!1;a=!0,this._defines.OPACITY=!0,this.opacityTexture.getAlphaFromRGB&&(this._defines.OPACITYRGB=!0)}if(this.reflectionTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this.reflectionTexture.isReady())return!1;switch(this._defines.REFLECTION=!0,this.reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE&&(this._defines.INVERTCUBICMAP=!0),this._defines.REFLECTIONMAP_3D=this.reflectionTexture.isCube,this.reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:this._defines.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:this._defines.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:this._defines.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:this._defines.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:this._defines.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:this._defines.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:this._defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}this.reflectionTexture instanceof e.HDRCubeTexture&&this.reflectionTexture&&(this._defines.USESPHERICALFROMREFLECTIONMAP=!0,this.reflectionTexture.isPMREM&&(this._defines.USEPMREMREFLECTION=!0))}if(this.lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this.emissiveTexture.isReady())return!1;a=!0,this._defines.EMISSIVE=!0}if(e.StandardMaterial.SpecularTextureEnabled){if(this.metallicTexture){if(!this.metallicTexture.isReady())return!1;a=!0,this._defines.METALLICWORKFLOW=!0,this._defines.METALLICMAP=!0,this._defines.ROUGHNESSSTOREINMETALMAPALPHA=this.useRoughnessFromMetallicTextureAlpha,this._defines.ROUGHNESSSTOREINMETALMAPGREEN=!this.useRoughnessFromMetallicTextureAlpha&&this.useRoughnessFromMetallicTextureGreen,this._defines.METALLNESSSTOREINMETALMAPBLUE=this.useMetallnessFromMetallicTextureBlue,this._defines.AOSTOREINMETALMAPRED=this.useAmbientOcclusionFromMetallicTextureRed}else if(this.reflectivityTexture){if(!this.reflectivityTexture.isReady())return!1;a=!0,this._defines.REFLECTIVITY=!0,this._defines.MICROSURFACEFROMREFLECTIVITYMAP=this.useMicroSurfaceFromReflectivityMapAlpha,this._defines.MICROSURFACEAUTOMATIC=this.useAutoMicroSurfaceFromReflectivityMap}if(this.microSurfaceTexture){if(!this.microSurfaceTexture.isReady())return!1;a=!0,this._defines.MICROSURFACEMAP=!0}}if(r.getEngine().getCaps().standardDerivatives&&this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this.disableBumpMap){if(!this.bumpTexture.isReady())return!1;a=!0,this._defines.BUMP=!0,this.useParallax&&this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._defines.PARALLAX=!0,this.useParallaxOcclusion&&(this._defines.PARALLAXOCCLUSION=!0))}if(this.refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube,this.linkRefractionWithTransparency&&(this._defines.LINKREFRACTIONTOTRANSPARENCY=!0),this.refractionTexture instanceof e.HDRCubeTexture&&(this._defines.REFRACTIONMAPINLINEARSPACE=!0,this.refractionTexture.isPMREM&&(this._defines.USEPMREMREFRACTION=!0))}if(this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}!this.backFaceCulling&&this.twoSidedLighting&&(this._defines.TWOSIDEDLIGHTING=!0)}if(r.clipPlane&&(this._defines.CLIPPLANE=!0),o.getAlphaTesting()&&(this._defines.ALPHATEST=!0),this._shouldUseAlphaFromAlbedoTexture()&&(this._defines.ALPHAFROMALBEDO=!0),this.useEmissiveAsIllumination&&(this._defines.EMISSIVEASILLUMINATION=!0),this.linkEmissiveWithAlbedo&&(this._defines.LINKEMISSIVEWITHALBEDO=!0),this.useLogarithmicDepth&&(this._defines.LOGARITHMICDEPTH=!0),1!=this.cameraContrast&&(this._defines.CAMERACONTRAST=!0),1!=this.cameraExposure&&(this._defines.CAMERATONEMAP=!0),this.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!0),1==this.overloadedShadeIntensity&&1==this.overloadedShadowIntensity||(this._defines.OVERLOADEDSHADOWVALUES=!0),(this.overloadedMicroSurfaceIntensity>0||this.overloadedEmissiveIntensity>0||this.overloadedReflectivityIntensity>0||this.overloadedAlbedoIntensity>0||this.overloadedAmbientIntensity>0||this.overloadedReflectionIntensity>0)&&(this._defines.OVERLOADEDVALUES=!0),(this.pointsCloud||r.forcePointsCloud)&&(this._defines.POINTSIZE=!0),r.fogEnabled&&i&&i.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),e.StandardMaterial.FresnelEnabled&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled||this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled)&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&(this._defines.OPACITYFRESNEL=!0),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._defines.EMISSIVEFRESNEL=!0),this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),this.usePhysicalLightFalloff&&(this._defines.USEPHYSICALLIGHTFALLOFF=!0),this.useRadianceOverAlpha&&(this._defines.RADIANCEOVERALPHA=!0),(void 0!==this.metallic&&null!==this.metallic||void 0!==this.roughness&&null!==this.roughness)&&(this._defines.METALLICWORKFLOW=!0),i&&(r.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0,i.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(this._defines.TANGENT=!0)),a&&(i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),i.useVertexColors&&i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,i.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),i.useBones&&i.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=i.numBoneInfluencers,this._defines.BonesPerMesh=i.skeleton.bones.length+1),t&&(this._defines.INSTANCES=!0),i.morphTargetManager)){var s=i.morphTargetManager;this._defines.MORPHTARGETS_TANGENT=s.supportsTangents&&this._defines.TANGENT,this._defines.MORPHTARGETS_NORMAL=s.supportsNormals&&this._defines.NORMAL,this._defines.MORPHTARGETS=s.numInfluencers>0,this._defines.NUM_MORPH_INFLUENCERS=s.numInfluencers}if(!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),r.resetCachedMaterial();var f=new e.EffectFallbacks;this._defines.REFLECTION&&f.addFallback(0,"REFLECTION"),this._defines.REFRACTION&&f.addFallback(0,"REFRACTION"),this._defines.REFLECTIVITY&&f.addFallback(0,"REFLECTIVITY"),this._defines.BUMP&&f.addFallback(0,"BUMP"),this._defines.PARALLAX&&f.addFallback(1,"PARALLAX"),this._defines.PARALLAXOCCLUSION&&f.addFallback(0,"PARALLAXOCCLUSION"),this._defines.SPECULAROVERALPHA&&f.addFallback(0,"SPECULAROVERALPHA"),this._defines.FOG&&f.addFallback(1,"FOG"),this._defines.POINTSIZE&&f.addFallback(0,"POINTSIZE"),this._defines.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,f,this.maxSimultaneousLights),this._defines.SPECULARTERM&&f.addFallback(0,"SPECULARTERM"),this._defines.OPACITYFRESNEL&&f.addFallback(1,"OPACITYFRESNEL"),this._defines.EMISSIVEFRESNEL&&f.addFallback(2,"EMISSIVEFRESNEL"),this._defines.FRESNEL&&f.addFallback(3,"FRESNEL"),this._defines.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,i);var l=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&l.push(e.VertexBuffer.NormalKind),this._defines.TANGENT&&l.push(e.VertexBuffer.TangentKind),this._defines.UV1&&l.push(e.VertexBuffer.UVKind),this._defines.UV2&&l.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,i,this._defines,f),e.MaterialHelper.PrepareAttributesForInstances(l,this._defines),e.MaterialHelper.PrepareAttributesForMorphTargets(l,i,this._defines);var u=this._defines.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","opacityParts","emissiveLeftColor","emissiveRightColor","vLightingIntensity","vOverloadedShadowIntensity","vOverloadedIntensity","vOverloadedAlbedo","vOverloadedReflection","vOverloadedReflectivity","vOverloadedEmissive","vOverloadedMicroSurface","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vMicrosurfaceTextureLods","vCameraInfos","vTangentSpaceParams"],d=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","microSurfaceSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],m=["Material","Scene"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(c),
  8. this._defines.CAMERACOLORGRADING&&(c.push("vCameraColorGradingInfos","vCameraColorGradingScaleOffset"),d.push("cameraColorGrading2DSampler")),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:this._defines,maxSimultaneousLights:this.maxSimultaneousLights});var v=function(e){n.onCompiled&&n.onCompiled(e),n.bindSceneUniformBuffer(e,r.getSceneUniformBuffer())};this._effect=r.getEngine().createEffect("legacyPbr",{attributes:l,uniformsNames:c,uniformBuffersNames:m,samplers:d,defines:u,fallbacks:f,onCompiled:v,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights,maxSimultaneousMorphTargets:this._defines.NUM_MORPH_INFLUENCERS}},o),this.buildUniformLayout()}return!!this._effect.isReady()&&(this._renderId=r.getRenderId(),this._wasPreviouslyReady=!0,!0)},n.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vMicrosurfaceTextureLods",2),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vOverloadedIntensity",4),this._uniformBuffer.addUniform("vOverloadedAmbient",3),this._uniformBuffer.addUniform("vOverloadedAlbedo",3),this._uniformBuffer.addUniform("vOverloadedReflectivity",3),this._uniformBuffer.addUniform("vOverloadedEmissive",3),this._uniformBuffer.addUniform("vOverloadedReflection",3),this._uniformBuffer.addUniform("vOverloadedMicroSurface",3),this._uniformBuffer.addUniform("vOverloadedShadowIntensity",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},n.prototype.unbind=function(){this.reflectionTexture&&this.reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflection2DSampler",null),this.refractionTexture&&this.refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refraction2DSampler",null),t.prototype.unbind.call(this)},n.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},n.prototype.bind=function(i,t){this._myScene=this.getScene();var r=this._effect;if(this.bindOnlyWorldMatrix(i),e.MaterialHelper.BindBonesParameters(t,this._effect),this._myScene.getCachedMaterial()!==this){if(this._uniformBuffer.bindToEffect(r,"Material"),this.bindViewProjection(r),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(e.StandardMaterial.FresnelEnabled&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),this._myScene.texturesEnabled){if(this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this.albedoTexture.coordinatesIndex,this.albedoTexture.level),this._uniformBuffer.updateMatrix("albedoMatrix",this.albedoTexture.getTextureMatrix())),this.ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level,this.ambientTextureStrength),this._uniformBuffer.updateMatrix("ambientMatrix",this.ambientTexture.getTextureMatrix())),this.opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level),this._uniformBuffer.updateMatrix("opacityMatrix",this.opacityTexture.getTextureMatrix())),this.reflectionTexture&&e.StandardMaterial.ReflectionTextureEnabled&&(this._microsurfaceTextureLods.x=Math.round(Math.log(this.reflectionTexture.getSize().width)*Math.LOG2E),this._uniformBuffer.updateMatrix("reflectionMatrix",this.reflectionTexture.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",this.reflectionTexture.level,0),this._defines.USESPHERICALFROMREFLECTIONMAP)){var o=this.reflectionTexture.sphericalPolynomial;this._effect.setFloat3("vSphericalX",o.x.x,o.x.y,o.x.z),this._effect.setFloat3("vSphericalY",o.y.x,o.y.y,o.y.z),this._effect.setFloat3("vSphericalZ",o.z.x,o.z.y,o.z.z),this._effect.setFloat3("vSphericalXX_ZZ",o.xx.x-o.zz.x,o.xx.y-o.zz.y,o.xx.z-o.zz.z),this._effect.setFloat3("vSphericalYY_ZZ",o.yy.x-o.zz.x,o.yy.y-o.zz.y,o.yy.z-o.zz.z),this._effect.setFloat3("vSphericalZZ",o.zz.x,o.zz.y,o.zz.z),this._effect.setFloat3("vSphericalXY",o.xy.x,o.xy.y,o.xy.z),this._effect.setFloat3("vSphericalYZ",o.yz.x,o.yz.y,o.yz.z),this._effect.setFloat3("vSphericalZX",o.zx.x,o.zx.y,o.zx.z)}if(this.emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level),this._uniformBuffer.updateMatrix("emissiveMatrix",this.emissiveTexture.getTextureMatrix())),this.lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this.lightmapTexture.coordinatesIndex,this.lightmapTexture.level),this._uniformBuffer.updateMatrix("lightmapMatrix",this.lightmapTexture.getTextureMatrix())),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this.metallicTexture.coordinatesIndex,this.metallicTexture.level,this.ambientTextureStrength),this._uniformBuffer.updateMatrix("reflectivityMatrix",this.metallicTexture.getTextureMatrix())):this.reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this.reflectivityTexture.coordinatesIndex,this.reflectivityTexture.level,1),this._uniformBuffer.updateMatrix("reflectivityMatrix",this.reflectivityTexture.getTextureMatrix())),this.microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this.microSurfaceTexture.coordinatesIndex,this.microSurfaceTexture.level),this._uniformBuffer.updateMatrix("microSurfaceSamplerMatrix",this.microSurfaceTexture.getTextureMatrix()))),this.bumpTexture&&this._myScene.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this.disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this.bumpTexture.coordinatesIndex,1/this.bumpTexture.level,this.parallaxScaleBias),this._uniformBuffer.updateMatrix("bumpMatrix",this.bumpTexture.getTextureMatrix()),this._myScene._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this.invertNormalMapX?1:-1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this.invertNormalMapX?-1:1,this.invertNormalMapY?-1:1)),this.refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){this._microsurfaceTextureLods.y=Math.round(Math.log(this.refractionTexture.getSize().width)*Math.LOG2E);var a=1;this.refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this.refractionTexture.getReflectionTextureMatrix()),this.refractionTexture.depth&&(a=this.refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this.refractionTexture.level,this.indexOfRefraction,a,this.invertRefractionY?-1:1)}(this.reflectionTexture||this.refractionTexture)&&this._uniformBuffer.updateFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),this._defines.METALLICWORKFLOW?(n._scaledReflectivity.r=void 0===this.metallic||null===this.metallic?1:this.metallic,n._scaledReflectivity.g=void 0===this.roughness||null===this.roughness?1:this.roughness,this._uniformBuffer.updateColor4("vReflectivityColor",n._scaledReflectivity,0)):(this.convertColorToLinearSpaceToRef(this.reflectivityColor,n._scaledReflectivity),this._uniformBuffer.updateColor4("vReflectivityColor",n._scaledReflectivity,this.microSurface)),this.convertColorToLinearSpaceToRef(this.emissiveColor,n._scaledEmissive),this._uniformBuffer.updateColor3("vEmissiveColor",n._scaledEmissive),this.convertColorToLinearSpaceToRef(this.reflectionColor,n._scaledReflection),this._uniformBuffer.updateColor3("vReflectionColor",n._scaledReflection),this.convertColorToLinearSpaceToRef(this.albedoColor,n._scaledAlbedo),this._uniformBuffer.updateColor4("vAlbedoColor",n._scaledAlbedo,this.alpha*t.visibility),this._lightingInfos.x=this.directIntensity,this._lightingInfos.y=this.emissiveIntensity,this._lightingInfos.z=this.environmentIntensity,this._lightingInfos.w=this.specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos),this._overloadedShadowInfos.x=this.overloadedShadowIntensity,this._overloadedShadowInfos.y=this.overloadedShadeIntensity,this._uniformBuffer.updateVector4("vOverloadedShadowIntensity",this._overloadedShadowInfos),this._overloadedIntensity.x=this.overloadedAmbientIntensity,this._overloadedIntensity.y=this.overloadedAlbedoIntensity,this._overloadedIntensity.z=this.overloadedReflectivityIntensity,this._overloadedIntensity.w=this.overloadedEmissiveIntensity,this._uniformBuffer.updateVector4("vOverloadedIntensity",this._overloadedIntensity),this._uniformBuffer.updateColor3("vOverloadedAmbient",this.overloadedAmbient),this.convertColorToLinearSpaceToRef(this.overloadedAlbedo,this._tempColor),this._uniformBuffer.updateColor3("vOverloadedAlbedo",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedReflectivity,this._tempColor),this._uniformBuffer.updateColor3("vOverloadedReflectivity",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedEmissive,this._tempColor),this._uniformBuffer.updateColor3("vOverloadedEmissive",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedReflection,this._tempColor),this._uniformBuffer.updateColor3("vOverloadedReflection",this._tempColor),this._overloadedMicroSurface.x=this.overloadedMicroSurface,this._overloadedMicroSurface.y=this.overloadedMicroSurfaceIntensity,this._overloadedMicroSurface.z=this.overloadedReflectionIntensity,this._uniformBuffer.updateVector3("vOverloadedMicroSurface",this._overloadedMicroSurface)}if(this._myScene.texturesEnabled&&(this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this.albedoTexture),this.ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this.ambientTexture),this.opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this.opacityTexture),this.reflectionTexture&&e.StandardMaterial.ReflectionTextureEnabled&&(this.reflectionTexture.isCube?this._uniformBuffer.setTexture("reflectionCubeSampler",this.reflectionTexture):this._uniformBuffer.setTexture("reflection2DSampler",this.reflectionTexture)),this.emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this.emissiveTexture),this.lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this.lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this.metallicTexture):this.reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this.reflectivityTexture),this.microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this.microSurfaceTexture)),this.bumpTexture&&this._myScene.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this.disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this.bumpTexture),this.refractionTexture&&e.StandardMaterial.RefractionTextureEnabled&&(this.refractionTexture.isCube?this._uniformBuffer.setTexture("refractionCubeSampler",this.refractionTexture):this._uniformBuffer.setTexture("refraction2DSampler",this.refractionTexture)),this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled)){this._effect.setTexture("cameraColorGrading2DSampler",this.cameraColorGradingTexture);var s=this.cameraColorGradingTexture.level,f=this.cameraColorGradingTexture.getSize().height,l=f-1,u=1/f;this._effect.setFloat4("vCameraColorGradingInfos",s,f,l,u);var c=u/f,d=u,m=l*c,v=l/f,h=.5*c,p=.5*d;this._effect.setFloat4("vCameraColorGradingScaleOffset",m,v,h,p)}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),r.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),r.setColor3("vAmbientColor",this._globalAmbientColor)}this._myScene.getCachedMaterial()===this&&this.isFrozen||(this._myScene.lightsEnabled&&!this.disableLighting&&n.BindLights(this._myScene,t,this._effect,this._defines,this.useScalarInLinearSpace,this.maxSimultaneousLights,this.usePhysicalLightFalloff),(this._myScene.fogEnabled&&t.applyFog&&this._myScene.fogMode!==e.Scene.FOGMODE_NONE||this.reflectionTexture)&&this.bindView(r),e.MaterialHelper.BindFogParameters(this._myScene,t,this._effect),this._defines.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(t,this._effect),this._cameraInfos.x=this.cameraExposure,this._cameraInfos.y=this.cameraContrast,r.setVector4("vCameraInfos",this._cameraInfos),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect),e.MaterialHelper.BindLogDepth(this._defines,this._effect,this._myScene)),this._uniformBuffer.update(),this._afterBind(t),this._myScene=null},n.prototype.getAnimatables=function(){var e=[];return this.albedoTexture&&this.albedoTexture.animations&&this.albedoTexture.animations.length>0&&e.push(this.albedoTexture),this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0&&e.push(this.ambientTexture),this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0&&e.push(this.opacityTexture),this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0&&e.push(this.reflectionTexture),this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0&&e.push(this.emissiveTexture),this.metallicTexture&&this.metallicTexture.animations&&this.metallicTexture.animations.length>0?e.push(this.metallicTexture):this.reflectivityTexture&&this.reflectivityTexture.animations&&this.reflectivityTexture.animations.length>0&&e.push(this.reflectivityTexture),this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this.lightmapTexture&&this.lightmapTexture.animations&&this.lightmapTexture.animations.length>0&&e.push(this.lightmapTexture),this.refractionTexture&&this.refractionTexture.animations&&this.refractionTexture.animations.length>0&&e.push(this.refractionTexture),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),e},n.prototype.dispose=function(e,i){i&&(this.albedoTexture&&this.albedoTexture.dispose(),this.ambientTexture&&this.ambientTexture.dispose(),this.opacityTexture&&this.opacityTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose(),this.emissiveTexture&&this.emissiveTexture.dispose(),this.metallicTexture&&this.metallicTexture.dispose(),this.reflectivityTexture&&this.reflectivityTexture.dispose(),this.bumpTexture&&this.bumpTexture.dispose(),this.lightmapTexture&&this.lightmapTexture.dispose(),this.refractionTexture&&this.refractionTexture.dispose(),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.dispose()),this._renderTargets.dispose(),t.prototype.dispose.call(this,e,i)},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.LegacyPBRMaterial",i},n.Parse=function(i,t,r){return e.SerializationHelper.Parse((function(){return new n(i.name,t)}),i,t,r)},n._scaledAlbedo=new e.Color3,n._scaledReflectivity=new e.Color3,n._scaledEmissive=new e.Color3,n._scaledReflection=new e.Color3,__decorate([e.serialize()],n.prototype,"directIntensity",void 0),__decorate([e.serialize()],n.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],n.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],n.prototype,"specularIntensity",void 0),__decorate([e.serialize()],n.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],n.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],n.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],n.prototype,"cameraExposure",void 0),__decorate([e.serialize()],n.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],n.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],n.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],n.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],n.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],n.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],n.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],n.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],n.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],n.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],n.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],n.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],n.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],n.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],n.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],n.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"ambientTexture",void 0),__decorate([e.serialize()],n.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture()],n.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"metallicTexture",void 0),__decorate([e.serialize()],n.prototype,"metallic",void 0),__decorate([e.serialize()],n.prototype,"roughness",void 0),__decorate([e.serializeAsTexture()],n.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],n.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],n.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],n.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],n.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],n.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],n.prototype,"emissiveColor",void 0),__decorate([e.serialize()],n.prototype,"microSurface",void 0),__decorate([e.serialize()],n.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],n.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],n.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],n.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],n.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],n.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],n.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],n.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],n.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],n.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],n.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],n.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize()],n.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize()],n.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize()],n.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize()],n.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize()],n.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],n.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],n.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],n.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],n.prototype,"useParallax",void 0),__decorate([e.serialize()],n.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],n.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],n.prototype,"disableLighting",void 0),__decorate([e.serialize()],n.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],n.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],n.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],n.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],n.prototype,"useLogarithmicDepth",null),n})(e.Material);e.LegacyPBRMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore.legacyPbrVertexShader="precision highp float;\n#include<__decl__legacyPbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\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>\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\n#endif\n#ifdef MICROSURFACEMAP\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#ifdef BUMP\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,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 ALBEDO\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef MICROSURFACEMAP\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\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\n\n#include<logDepthVertex>\n}",
  9. BABYLON.Effect.ShadersStore.legacyPbrPixelShader="#if defined(BUMP)|| !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__legacyPbrFragment>\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform sampler2D lightmapSampler;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\nvarying vec2 vMicroSurfaceSamplerUV;\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef CAMERACOLORGRADING\n#include<legacyColorGradingDefinition>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<legacyColorCurvesDefinition>\n#endif\n\n#include<shadowsFragmentFunctions>\n#include<legacyPbrFunctions>\n#ifdef CAMERACOLORGRADING\n#include<legacyColorGrading>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<legacyColorCurves>\n#endif\n#include<legacyPbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\nsurfaceAlbedo=vec4(toLinearSpace(surfaceAlbedo.rgb),surfaceAlbedo.a);\n#ifndef LINKREFRACTIONTOTRANSPARENCY\n#ifdef ALPHATEST\nif (surfaceAlbedo.a<0.4)\ndiscard;\n#endif\n#endif\n#ifdef ALPHAFROMALBEDO\nalpha*=surfaceAlbedo.a;\n#endif\nsurfaceAlbedo.rgb*=vAlbedoInfos.y;\n#else\n\nsurfaceAlbedo.rgb=surfaceAlbedoContribution;\nsurfaceAlbedoContribution=vec3(1.,1.,1.);\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo.rgb*=vColor.rgb;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,vOverloadedAlbedo,vOverloadedIntensity.y);\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE \nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#ifdef OVERLOADEDVALUES\nambientOcclusionColor.rgb=mix(ambientOcclusionColor.rgb,vOverloadedAmbient,vOverloadedIntensity.x);\n#endif\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor=surfaceReflectivityColorMap.rgb;\nsurfaceReflectivityColor=toLinearSpace(surfaceReflectivityColor);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface=surfaceReflectivityColorMap.a*vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#endif\n#else\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#endif\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED \nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo.rgb=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#else\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface=microSurfaceTexel.r;\n#endif\n#endif\n#ifdef OVERLOADEDVALUES\nmicroSurface=mix(microSurface,vOverloadedMicroSurface.x,vOverloadedMicroSurface.y);\n#endif\n\nfloat NdotV=max(0.00000000001,dot(normalW,viewDirectionW));\n\nmicroSurface=clamp(microSurface,0.,1.)*0.98;\n\nfloat roughness=clamp(1.-microSurface,0.000001,1.0);\n\nvec3 lightDiffuseContribution=vec3(0.,0.,0.);\n#ifdef OVERLOADEDSHADOWVALUES\nvec3 shadowedOnlyLightDiffuseContribution=vec3(1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nvec3 lightSpecularContribution=vec3(0.,0.,0.);\n#endif\nfloat notShadowLevel=1.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nfloat NdotL=-1.;\nlightingInfo info;\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\n\n\nfloat reflectance90=clamp(reflectance*25.0,0.0,1.0);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n#include<legacyPbrLightFunctionsCall>[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 surfaceRefractionColor=vec3(0.,0.,0.);\n\n#ifdef LODBASEDMICROSFURACE\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#endif\n#ifdef REFRACTION\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\nfloat lodRefraction=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.y,alphaG);\n#else\nfloat lodRefraction=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.y,alphaG);\n#endif\n#else\nfloat biasRefraction=(vMicrosurfaceTextureLods.y+2.)*(1.0-microSurface);\n#endif\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\n\nif ((vMicrosurfaceTextureLods.y-lodRefraction)>4.0)\n{\n\nfloat scaleRefraction=1.-exp2(lodRefraction)/exp2(vMicrosurfaceTextureLods.y); \nfloat maxRefraction=max(max(abs(refractionVector.x),abs(refractionVector.y)),abs(refractionVector.z));\nif (abs(refractionVector.x) != maxRefraction) refractionVector.x*=scaleRefraction;\nif (abs(refractionVector.y) != maxRefraction) refractionVector.y*=scaleRefraction;\nif (abs(refractionVector.z) != maxRefraction) refractionVector.z*=scaleRefraction;\n}\n#endif\nsurfaceRefractionColor=textureCubeLodEXT(refractionCubeSampler,refractionVector,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=textureCube(refractionCubeSampler,refractionVector,biasRefraction).rgb*vRefractionInfos.x;\n#endif\n}\n#ifndef REFRACTIONMAPINLINEARSPACE\nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#ifdef LODBASEDMICROSFURACE\nsurfaceRefractionColor=texture2DLodEXT(refraction2DSampler,refractionCoords,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=texture2D(refraction2DSampler,refractionCoords,biasRefraction).rgb*vRefractionInfos.x;\n#endif \nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#endif\n\nvec3 environmentRadiance=vReflectionColor.rgb;\nvec3 environmentIrradiance=vReflectionColor.rgb;\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\nfloat lodReflection=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.x,alphaG);\n#else\nfloat lodReflection=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.x,alphaG);\n#endif\n#else\nfloat biasReflection=(vMicrosurfaceTextureLods.x+2.)*(1.0-microSurface);\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\n\nif ((vMicrosurfaceTextureLods.y-lodReflection)>4.0)\n{\n\nfloat scaleReflection=1.-exp2(lodReflection)/exp2(vMicrosurfaceTextureLods.x); \nfloat maxReflection=max(max(abs(vReflectionUVW.x),abs(vReflectionUVW.y)),abs(vReflectionUVW.z));\nif (abs(vReflectionUVW.x) != maxReflection) vReflectionUVW.x*=scaleReflection;\nif (abs(vReflectionUVW.y) != maxReflection) vReflectionUVW.y*=scaleReflection;\nif (abs(vReflectionUVW.z) != maxReflection) vReflectionUVW.z*=scaleReflection;\n}\n#endif\nenvironmentRadiance=textureCubeLodEXT(reflectionCubeSampler,vReflectionUVW,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=textureCube(reflectionCubeSampler,vReflectionUVW,biasReflection).rgb*vReflectionInfos.x;\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifndef REFLECTIONMAP_SKYBOX\nvec3 normalEnvironmentSpace=(reflectionMatrix*vec4(normalW,1)).xyz;\nenvironmentIrradiance=EnvironmentIrradiance(normalEnvironmentSpace);\n#endif\n#else\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=textureCube(reflectionCubeSampler,normalW,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\nenvironmentIrradiance*=0.2; \n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\n#ifdef LODBASEDMICROSFURACE\nenvironmentRadiance=texture2DLodEXT(reflection2DSampler,coords,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=texture2D(reflection2DSampler,coords,biasReflection).rgb*vReflectionInfos.x;\n#endif\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=texture2D(reflection2DSampler,coords,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\n#ifdef OVERLOADEDVALUES\nenvironmentIrradiance=mix(environmentIrradiance,vOverloadedReflection,vOverloadedMicroSurface.z);\nenvironmentRadiance=mix(environmentRadiance,vOverloadedReflection,vOverloadedMicroSurface.z);\n#endif\nenvironmentRadiance*=vLightingIntensity.z;\nenvironmentIrradiance*=vLightingIntensity.z;\n\nvec3 specularEnvironmentReflectance=FresnelSchlickEnvironmentGGX(clamp(NdotV,0.,1.),specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n\nvec3 refractance=vec3(0.0,0.0,0.0);\n#ifdef REFRACTION\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedoContribution.rgb*surfaceAlbedo.rgb;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedoContribution*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nsurfaceRefractionColor*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=surfaceRefractionColor*transmission;\n#endif\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\nrefractance*=vLightingIntensity.z;\nenvironmentRadiance*=specularEnvironmentReflectance;\n\nvec3 surfaceEmissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nsurfaceEmissiveColor=toLinearSpace(emissiveColorTex.rgb)*surfaceEmissiveColor*vEmissiveInfos.y;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceEmissiveColor=mix(surfaceEmissiveColor,vOverloadedEmissive,vOverloadedIntensity.w);\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nsurfaceEmissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=lightDiffuseContribution*surfaceAlbedoContribution;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution;\n#endif\n#else\n#ifdef LINKEMISSIVEWITHALBEDO\nvec3 finalDiffuse=(lightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=(shadowedOnlyLightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution;\n#endif\n#else\nvec3 finalDiffuse=lightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor;\n#endif\n#endif\n#endif\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution+=vAmbientColor;\nshadowedOnlyLightDiffuseContribution*=surfaceAlbedo.rgb;\nshadowedOnlyLightDiffuseContribution=max(shadowedOnlyLightDiffuseContribution,0.0);\nfinalDiffuse=mix(finalDiffuse,shadowedOnlyLightDiffuseContribution,(1.0-vOverloadedShadowIntensity.y));\n#endif\nfinalDiffuse=(finalDiffuse*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance)*ambientOcclusionColor;\n#ifdef SPECULARTERM\nvec3 finalSpecular=lightSpecularContribution*surfaceReflectivityColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+getLuminance(finalSpecular),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef RADIANCEOVERALPHA\nalpha=clamp(alpha+getLuminance(environmentRadiance),0.,1.);\n#endif\n\n\nvec4 finalColor=vec4(finalDiffuse+finalSpecular*vLightingIntensity.x+environmentRadiance+refractance,alpha);\n#ifdef EMISSIVEASILLUMINATION\nfinalColor.rgb+=(surfaceEmissiveColor*vLightingIntensity.y);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\nfinalColor=max(finalColor,0.0);\n#ifdef CAMERATONEMAP\nfinalColor.rgb=toneMaps(finalColor.rgb);\n#endif\nfinalColor.rgb=toGammaSpace(finalColor.rgb);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef CAMERACONTRAST\nfinalColor=contrasts(finalColor);\n#endif\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\n#ifdef CAMERACOLORGRADING\nfinalColor=colorGrades(finalColor);\n#endif\n#ifdef CAMERACOLORCURVES\nfinalColor.rgb=applyColorCurves(finalColor.rgb);\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ngl_FragColor=finalColor;\n}",BABYLON.Effect.IncludesShadersStore.legacyPbrFragmentDeclaration="uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\n#ifdef OVERLOADEDVALUES\nuniform vec4 vOverloadedIntensity;\nuniform vec3 vOverloadedAmbient;\nuniform vec3 vOverloadedAlbedo;\nuniform vec3 vOverloadedReflectivity;\nuniform vec3 vOverloadedEmissive;\nuniform vec3 vOverloadedReflection;\nuniform vec3 vOverloadedMicroSurface;\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nuniform vec4 vOverloadedShadowIntensity;\n#endif\n#if defined(REFLECTION) || defined(REFRACTION)\nuniform vec2 vMicrosurfaceTextureLods;\n#endif\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifdef REFRACTIONMAP_3D\n#else\nuniform mat4 refractionMatrix;\n#endif\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#endif",BABYLON.Effect.IncludesShadersStore.legacyPbrFunctions="\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kPi=3.1415926535897932384626433832795;\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat Square(float value)\n{\nreturn value*value;\n}\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=Square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat getMipMapIndexFromAverageSlope(float maxMipLevel,float alpha)\n{\n\n\n\n\n\n\n\nfloat mip=kRougnhessToAlphaOffset+maxMipLevel+(maxMipLevel*kRougnhessToAlphaScale*log2(alpha));\nreturn clamp(mip,0.,maxMipLevel);\n}\nfloat getMipMapIndexFromAverageSlopeWithPMREM(float maxMipLevel,float alphaG)\n{\nfloat specularPower=clamp(2./alphaG-2.,0.000001,2048.);\n\nreturn clamp(- 0.5*log2(specularPower)+5.5,0.,maxMipLevel);\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=Square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(kPi*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 FresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 specularColor,vec3 reflectance90)\n{\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nvec3 fresnel=fresnelSchlickGGX(VdotH,specularColor,reflectance90);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nreturn fresnel*specTerm*kPi; \n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat diffuseFresnelTerm =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn diffuseFresnelTerm*NdotL;\n\n\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nfloat kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#ifdef CAMERATONEMAP\nvec3 toneMaps(vec3 color)\n{\ncolor=max(color,0.0);\n\ncolor.rgb=color.rgb*vCameraInfos.x;\nfloat tuning=1.5; \n\n\nvec3 tonemapped=1.0-exp2(-color.rgb*tuning); \ncolor.rgb=mix(color.rgb,tonemapped,1.0);\nreturn color;\n}\n#endif\n#ifdef CAMERACONTRAST\nvec4 contrasts(vec4 color)\n{\ncolor=clamp(color,0.0,1.0);\nvec3 resultHighContrast=color.rgb*color.rgb*(3.0-2.0*color.rgb);\nfloat contrast=vCameraInfos.y;\nif (contrast<1.0)\n{\n\ncolor.rgb=mix(vec3(0.5,0.5,0.5),color.rgb,contrast);\n}\nelse\n{\n\ncolor.rgb=mix(color.rgb,resultHighContrast,contrast-1.0);\n}\nreturn color;\n}\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX;\nuniform vec3 vSphericalYY;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 EnvironmentIrradiance(vec3 normal)\n{\n\n\n\nvec3 result =\nvSphericalX*normal.x +\nvSphericalY*normal.y +\nvSphericalZ*normal.z +\nvSphericalXX*normal.x*normal.x +\nvSphericalYY*normal.y*normal.y +\nvSphericalZZ*normal.z*normal.z +\nvSphericalYZ*normal.y*normal.z +\nvSphericalZX*normal.z*normal.x +\nvSphericalXY*normal.x*normal.y;\nreturn result.rgb;\n}\n#endif",BABYLON.Effect.IncludesShadersStore.legacyPbrLightFunctions="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat lightDistanceFalloff=1.0/((lightDistanceSquared+0.0001));\n#else\nfloat lightDistanceFalloff=max(0.,1.0-length(lightOffset)/range);\n#endif\nreturn lightDistanceFalloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngle,float exponent)\n{\nfloat falloff=0.0;\n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat cosHalfAngle=cos(lightAngle*0.5);\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfalloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\n#else\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=lightAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\n#endif\nreturn falloff;\n}\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightDirection;\nfloat attenuation=1.0;\nfloat lightDistance;\n\nif (lightData.w == 0.)\n{\nvec3 lightOffset=lightData.xyz-vPositionW;\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nattenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\nlightDistance=sqrt(lightDistanceSquared);\nlightDirection=normalize(lightOffset);\n}\n\nelse\n{\nlightDistance=length(-lightData.xyz);\nlightDirection=normalize(-lightData.xyz);\n}\n\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=max(0.00000000001,dot(vNormal,lightDirection));\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightOffset=lightData.xyz-vPositionW;\nvec3 directionToLightCenterW=normalize(lightOffset);\n\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nfloat attenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\n\nfloat directionalAttenuation=computeDirectionalLightFalloff(lightDirection.xyz,directionToLightCenterW,lightDirection.w,lightData.w);\nattenuation*=directionalAttenuation;\n\nfloat lightDistance=sqrt(lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+directionToLightCenterW);\nNdotL=max(0.00000000001,dot(vNormal,directionToLightCenterW));\nfloat VdotH=clamp(dot(viewDirectionW,H),0.00000000001,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nNdotL=max(0.00000000001,NdotL);\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm;\n#endif\nreturn result;\n}",BABYLON.Effect.IncludesShadersStore.legacyPbrLightFunctionsCall="#ifdef LIGHT{X}\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nnotShadowLevel=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nnotShadowLevel=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,0.0);\n#endif\n#else\n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nnotShadowLevel=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nnotShadowLevel=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,0.0);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nnotShadowLevel=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nnotShadowLevel=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,0.0);\n#endif\n#endif\n#endif\n#else\nnotShadowLevel=1.;\n#endif\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\nlightDiffuseContribution+=info.diffuse*notShadowLevel;\n#ifdef OVERLOADEDSHADOWVALUES\nif (NdotL<0.000000000011)\n{\nnotShadowLevel=1.;\n}\nshadowedOnlyLightDiffuseContribution*=notShadowLevel;\n#endif\n#ifdef SPECULARTERM\nlightSpecularContribution+=info.specular*notShadowLevel;\n#endif\n#endif\n#endif",
  10. BABYLON.Effect.IncludesShadersStore.legacyPbrUboDeclaration="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec3 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec2 vMicrosurfaceTextureLods;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform vec4 opacityParts;\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\nuniform vec4 vOverloadedIntensity;\nuniform vec3 vOverloadedAmbient;\nuniform vec3 vOverloadedAlbedo;\nuniform vec3 vOverloadedReflectivity;\nuniform vec3 vOverloadedEmissive;\nuniform vec3 vOverloadedReflection;\nuniform vec3 vOverloadedMicroSurface;\nuniform vec4 vOverloadedShadowIntensity;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",BABYLON.Effect.IncludesShadersStore.legacyPbrVertexDeclaration="uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",BABYLON.Effect.IncludesShadersStore.legacyColorCurves="const vec3 HDTVRec709_RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvec3 applyColorCurves(vec3 original) {\nvec3 result=original;\n\n\n\nfloat luma=dot(result.rgb,HDTVRec709_RGBLuminanceCoefficients);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0,0.0),vec2(1.0,1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma,luma,luma),result.rgb,colorCurve.a);\nreturn result;\n}",BABYLON.Effect.IncludesShadersStore.legacyColorCurvesDefinition="uniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\nuniform vec4 vCameraColorCurveNegative;",BABYLON.Effect.IncludesShadersStore.legacyColorGrading="vec4 colorGrades(vec4 color) \n{ \n\nfloat sliceContinuous=color.z*vCameraColorGradingInfos.z;\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger; \n\nvec2 sliceUV=color.xy*vCameraColorGradingScaleOffset.xy+vCameraColorGradingScaleOffset.zw;\n\n\nsliceUV.x+=sliceInteger*vCameraColorGradingInfos.w;\nvec4 slice0Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nsliceUV.x+=vCameraColorGradingInfos.w;\nvec4 slice1Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\ncolor.rgb=mix(color.rgb,result,vCameraColorGradingInfos.x);\nreturn color;\n}",BABYLON.Effect.IncludesShadersStore.legacyColorGradingDefinition="uniform sampler2D cameraColorGrading2DSampler;\nuniform vec4 vCameraColorGradingInfos;\nuniform vec4 vCameraColorGradingScaleOffset;",(function(e,i){e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports.BJSMaterials=i():e.BABYLON=i())})(this,(function(){return BABYLON}));