2 lines
192 KiB
JavaScript
2 lines
192 KiB
JavaScript
!function(e,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],i):"object"==typeof exports?exports["babylonjs-materials"]=i(require("babylonjs")):e.MATERIALS=i(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var i={520:i=>{i.exports=e}},t={};function r(e){var n=t[e];if(void 0!==n)return n.exports;var o=t[e]={exports:{}};return i[e](o,o.exports,r),o.exports}r.d=(e,i)=>{for(var t in i)r.o(i,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.d(n,{default:()=>W});var e={};r.r(e),r.d(e,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>v,FurMaterial:()=>T,GradientMaterial:()=>x,GridMaterial:()=>E,LavaMaterial:()=>P,MixMaterial:()=>M,NormalMaterial:()=>F,PBRCustomMaterial:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>I,SimpleMaterial:()=>L,SkyMaterial:()=>R,TerrainMaterial:()=>U,TriPlanarMaterial:()=>w,WaterMaterial:()=>z});var i={};r.r(i),r.d(i,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>v,FurMaterial:()=>T,GradientMaterial:()=>x,GridMaterial:()=>E,LavaMaterial:()=>P,MixMaterial:()=>M,NormalMaterial:()=>F,PBRCustomMaterial:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>I,SimpleMaterial:()=>L,SkyMaterial:()=>R,TerrainMaterial:()=>U,TriPlanarMaterial:()=>w,WaterMaterial:()=>z});var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t])},t(e,i)};function o(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}function s(e,i,t,r){var n,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(i,t,s):n(i,t))||s);return o>3&&s&&Object.defineProperty(i,t,s),s}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var a=r(520);a.ShaderStore.ShadersStore.cellPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{diffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;if (info.ndl<0.5)\nlevel=0.5;diffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];ToonThresholds[0]=0.95;ToonThresholds[1]=0.5;ToonThresholds[2]=0.2;ToonThresholds[3]=0.03;float ToonBrightnessLevels[5];ToonBrightnessLevels[0]=1.0;ToonBrightnessLevels[1]=0.8;ToonBrightnessLevels[2]=0.6;ToonBrightnessLevels[3]=0.35;ToonBrightnessLevels[4]=0.2;if (info.ndl>ToonThresholds[0])\n{diffuseBase.rgb*=ToonBrightnessLevels[0];}\nelse if (info.ndl>ToonThresholds[1])\n{diffuseBase.rgb*=ToonBrightnessLevels[1];}\nelse if (info.ndl>ToonThresholds[2])\n{diffuseBase.rgb*=ToonBrightnessLevels[2];}\nelse if (info.ndl>ToonThresholds[3])\n{diffuseBase.rgb*=ToonBrightnessLevels[3];}\nelse\n{diffuseBase.rgb*=ToonBrightnessLevels[4];}\n#endif\nreturn max(diffuseBase,vec3(0.2));}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float 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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nlightingInfo info;vec3 diffuseBase=vec3(0.,0.,0.);float shadow=1.;float glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.cellVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\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#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var f=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.NDOTL=!0,i.CUSTOMUSERLIGHTING=!0,i.CELLBASIC=!0,i.DEPTHPREPASS=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),l=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r._computeHighLevel=!1,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new f);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(r.CELLBASIC=!this.computeHighLevel,a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var l=[a.VertexBuffer.PositionKind];r.NORMAL&&l.push(a.VertexBuffer.NormalKind),r.UV1&&l.push(a.VertexBuffer.UVKind),r.UV2&&l.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(l,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(l,r);var u=r.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix"],c=["diffuseSampler"],p=new Array;(0,a.addClipPlaneUniforms)(d),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("cell",{attributes:l,uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:u,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),(0,a.bindClipPlane)(this._activeEffect,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this._maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.getClassName=function(){return"CellMaterial"},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.CellMaterial",i},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("computeHighLevel")],i.prototype,"_computeHighLevel",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"computeHighLevel",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.CellMaterial",l);var u=function(){},d=function(){},c=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.CustomParts=new d,r.customShaderNameResolve=r.Builder,r.FragmentShader=a.Effect.ShadersStore.defaultPixelShader,r.VertexShader=a.Effect.ShadersStore.defaultVertexShader,r}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(r=t.toString().split("-"))[0]?i.setVector2(r[1],this._newUniformInstances[t]):"vec3"==r[0]?i.setVector3(r[1],this._newUniformInstances[t]):"vec4"==r[0]?i.setVector4(r[1],this._newUniformInstances[t]):"mat4"==r[0]?i.setMatrix(r[1],this._newUniformInstances[t]):"float"==r[0]&&i.setFloat(r[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var r;"sampler2D"==(r=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(r[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));return i},i.prototype.Builder=function(e,t,r,n,o,s){var f=this;if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",t),this.ReviewUniform("sampler",n),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,i.ShaderIndexer++;var l="custom_"+i.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,i){if(i){f.AttachAfterBind(e,i);try{u(e,i)}catch(i){}}},a.Effect.ShadersStore[l+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(a.Effect.ShadersStore[l+"VertexShader"]=a.Effect.ShadersStore[l+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),a.Effect.ShadersStore[l+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:"").replace("#define CUSTOM_FRAGMENT_MAIN_END",this.CustomParts.Fragment_MainEnd?this.CustomParts.Fragment_MainEnd:""),this.CustomParts.Fragment_Before_Fog&&(a.Effect.ShadersStore[l+"PixelShader"]=a.Effect.ShadersStore[l+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace("result","diffuseColor"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.StandardMaterial);(0,a.RegisterClass)("BABYLON.CustomMaterial",c);var p=function(){},h=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.CustomParts=new p,r.customShaderNameResolve=r.Builder,r.FragmentShader=a.Effect.ShadersStore.pbrPixelShader,r.VertexShader=a.Effect.ShadersStore.pbrVertexShader,r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,a.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,a.Effect.IncludesShadersStore.pbrBlockReflectivity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,a.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),r}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(r=t.toString().split("-"))[0]?i.setVector2(r[1],this._newUniformInstances[t]):"vec3"==r[0]?i.setVector3(r[1],this._newUniformInstances[t]):"vec4"==r[0]?i.setVector4(r[1],this._newUniformInstances[t]):"mat4"==r[0]?i.setMatrix(r[1],this._newUniformInstances[t]):"float"==r[0]&&i.setFloat(r[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var r;"sampler2D"==(r=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(r[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t].replace(/\[\d*\]/g,""));return i},i.prototype.Builder=function(e,t,r,n,o,s,f){var l=this;if(f){var u=f.processFinalCode;f.processFinalCode=function(e,i){if("vertex"===e)return u?u(e,i):i;var t=new a.ShaderCodeInliner(i);return t.inlineToken="#define pbr_inline",t.processCode(),u?u(e,t.code):t.code}}if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",t),this.ReviewUniform("sampler",n),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,i.ShaderIndexer++;var d="custom_"+i.ShaderIndexer,c=this._afterBind.bind(this);return this._afterBind=function(e,i){if(i){l.AttachAfterBind(e,i);try{c(e,i)}catch(i){}}},a.Effect.ShadersStore[d+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(a.Effect.ShadersStore[d+"VertexShader"]=a.Effect.ShadersStore[d+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),a.Effect.ShadersStore[d+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_ALBEDO",this.CustomParts.Fragment_Custom_Albedo?this.CustomParts.Fragment_Custom_Albedo:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS",this.CustomParts.Fragment_Custom_MetallicRoughness?this.CustomParts.Fragment_Custom_MetallicRoughness:"").replace("#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE",this.CustomParts.Fragment_Custom_MicroSurface?this.CustomParts.Fragment_Custom_MicroSurface:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION",this.CustomParts.Fragment_Before_FinalColorComposition?this.CustomParts.Fragment_Before_FinalColorComposition:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:"").replace("#define CUSTOM_FRAGMENT_MAIN_END",this.CustomParts.Fragment_MainEnd?this.CustomParts.Fragment_MainEnd:""),this.CustomParts.Fragment_Before_Fog&&(a.Effect.ShadersStore[d+"PixelShader"]=a.Effect.ShadersStore[d+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=d,d},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_Custom_Albedo=function(e){return this.CustomParts.Fragment_Custom_Albedo=e.replace("result","surfaceAlbedo"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Custom_MetallicRoughness=function(e){return this.CustomParts.Fragment_Custom_MetallicRoughness=e,this},i.prototype.Fragment_Custom_MicroSurface=function(e){return this.CustomParts.Fragment_Custom_MicroSurface=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FinalColorComposition=function(e){return this.CustomParts.Fragment_Before_FinalColorComposition=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.PBRMaterial);(0,a.RegisterClass)("BABYLON.PBRCustomMaterial",h);a.ShaderStore.ShadersStore.firePixelShader="precision highp float;uniform vec4 vEyePosition;varying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\nuniform sampler2D distortionSampler;uniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{return vec4(2.0)*x-vec4(1.0);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);float alpha=1.0;\n#ifdef DIFFUSE\nconst float distortionAmount0 =0.092;const float distortionAmount1 =0.092;const float distortionAmount2 =0.092;vec2 heightAttenuation=vec2(0.3,0.39);vec4 noise0=texture2D(distortionSampler,vDistortionCoords1);vec4 noise1=texture2D(distortionSampler,vDistortionCoords2);vec4 noise2=texture2D(distortionSampler,vDistortionCoords3);vec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;vec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);vec4 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;baseColor*=opacityColor;baseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.fireVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nuniform float time;uniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef DIFFUSE\nvDiffuseUV=uv;vDiffuseUV.y-=0.2;\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;vDistortionCoords1.x=uv.x;vDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;vDistortionCoords2.x=uv.x;vDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;vDistortionCoords3.x=uv.x;vDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var m=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),v=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r.speed=1,r._scaledDiffuse=new a.Color3,r._lastTime=0,r}return o(i,e),i.prototype.needAlphaBlending=function(){return!1},i.prototype.needAlphaTesting=function(){return!0},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new m);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(r.ALPHATEST=!!this._opacityTexture,r._areMiscDirty&&(r.POINTSIZE=this.pointsCloud||n.forcePointsCloud,r.FOG=n.fogEnabled&&e.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this.fogEnabled),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!1,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.UV1&&f.push(a.VertexBuffer.UVKind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","time","speed"];(0,a.addClipPlaneUniforms)(l);var u=r.toString();i.setEffect(n.getEngine().createEffect("fire",{attributes:f,uniformsNames:l,uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:u,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene();if(t.materialDefines){var n=t.effect;n&&(this._activeEffect=n,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,n)&&(this._diffuseTexture&&a.MaterialFlags.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)),(0,a.bindClipPlane)(this._activeEffect,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(n)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._lastTime+=r.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(i,this._activeEffect))}},i.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},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),this._distortionTexture&&i.push(this._distortionTexture),this._opacityTexture&&i.push(this._opacityTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i||this._distortionTexture===i||this._opacityTexture===i},i.prototype.getClassName=function(){return"FireMaterial"},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.FireMaterial",i.diffuseColor=this.diffuseColor.asArray(),i.speed=this.speed,this._diffuseTexture&&(i._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(i._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(i._opacityTexture=this._opacityTexture.serialize()),i},i.Parse=function(e,t,r){var n=new i(e.name,t);return n.diffuseColor=a.Color3.FromArray(e.diffuseColor),n.speed=e.speed,n.alpha=e.alpha,n.id=e.id,a.Tags.AddTagsTo(n,e.tags),n.backFaceCulling=e.backFaceCulling,n.wireframe=e.wireframe,e._diffuseTexture&&(n._diffuseTexture=a.Texture.Parse(e._diffuseTexture,t,r)),e._distortionTexture&&(n._distortionTexture=a.Texture.Parse(e._distortionTexture,t,r)),e._opacityTexture&&(n._opacityTexture=a.Texture.Parse(e._opacityTexture,t,r)),n},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)("distortionTexture")],i.prototype,"_distortionTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"distortionTexture",void 0),s([(0,a.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)()],i.prototype,"speed",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.FireMaterial",v);a.ShaderStore.ShadersStore.furPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 furColor;uniform float furLength;varying vec3 vPositionW;varying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform float furOcclusion;uniform sampler2D furTexture;varying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=furColor;vec3 diffuseColor=vDiffuseColor.rgb;float 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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));if (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {discard;}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);baseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;vec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.furVertexShader="precision highp float;attribute vec3 position;attribute 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#include<bakedVertexAnimationDeclaration>\nuniform float furLength;uniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform vec3 furGravity;uniform float furTime;uniform float furSpacing;uniform 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;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\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) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\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);vec3 tangent2=vec3(-normal.z,0,normal.x);r=Rand(tangent1*r);float J=(2.0+4.0*r);r=Rand(tangent2*r);float K=(2.0+2.0*r);tangent1=tangent1*J+tangent2*K;tangent1=normalize(tangent1);vec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\nvec3 forceDirection=vec3(0.0,0.0,0.0);forceDirection.x=sin(furTime+position.x*0.05)*0.2;forceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;forceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;vec3 displacement=vec3(0.0,0.0,0.0);displacement=furGravity+forceDirection;float displacementFactor=pow(furOffset,3.0);vec3 aNormal=normal;aNormal.xyz+=displacement*displacementFactor;newPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos);\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var g=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.HEIGHTMAP=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.HIGHLEVEL=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),T=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r.furLength=1,r.furAngle=0,r.furColor=new a.Color3(.44,.21,.02),r.furOffset=0,r.furSpacing=12,r.furGravity=new a.Vector3(0,0,0),r.furSpeed=100,r.furDensity=20,r.furOcclusion=0,r._disableLighting=!1,r._maxSimultaneousLights=4,r.highLevelFur=!0,r._furTime=0,r}return o(i,e),Object.defineProperty(i.prototype,"furTime",{get:function(){return this._furTime},set:function(e){this._furTime=e},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.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}},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new g);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&n.texturesEnabled){if(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(this.heightTexture&&o.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;r._needUVs=!0,r.HEIGHTMAP=!0}}if(this.highLevelFur!==r.HIGHLEVEL&&(r.HIGHLEVEL=!0,r.markAsUnprocessed()),a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity","furOcclusion"];(0,a.addClipPlaneUniforms)(u);var d=["diffuseSampler","heightTexture","furTexture"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("fur",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),r.getCachedMaterial()!==this&&(this._diffuseTexture&&a.MaterialFlags.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),(0,a.bindClipPlane)(this._activeEffect,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,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._activeEffect.setFloat("furOcclusion",this.furOcclusion),this._furTime+=this.getScene().getEngine().getDeltaTime()/this.furSpeed,this._activeEffect.setFloat("furTime",this._furTime),this._activeEffect.setTexture("furTexture",this.furTexture)),this._afterBind(i,this._activeEffect))}},i.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},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),this._heightTexture&&i.push(this._heightTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i||this._heightTexture===i},i.prototype.dispose=function(i){if(this.diffuseTexture&&this.diffuseTexture.dispose(),this._meshes)for(var t=1;t<this._meshes.length;t++){var r=this._meshes[t].material;r&&r.dispose(i),this._meshes[t].dispose()}e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.FurMaterial",this._meshes&&(i.sourceMeshName=this._meshes[0].name,i.quality=this._meshes.length),i},i.prototype.getClassName=function(){return"FurMaterial"},i.Parse=function(e,t,r){var n=a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r);return e.sourceMeshName&&n.highLevelFur&&t.executeWhenReady((function(){var r=t.getMeshByName(e.sourceMeshName);if(r){var o=i.GenerateTexture("Fur Texture",t);n.furTexture=o,i.FurifyMesh(r,e.quality)}})),n},i.GenerateTexture=function(e,i){for(var t=new a.DynamicTexture("FurTexture "+e,256,i,!0),r=t.getContext(),n=0;n<2e4;++n)r.fillStyle="rgba(255, "+Math.floor(255*Math.random())+", "+Math.floor(255*Math.random())+", 1)",r.fillRect(Math.random()*t.getSize().width,Math.random()*t.getSize().height,2,2);return t.update(!1),t.wrapU=a.Texture.WRAP_ADDRESSMODE,t.wrapV=a.Texture.WRAP_ADDRESSMODE,t},i.FurifyMesh=function(e,t){var r,n=[e],o=e.material;if(!(o instanceof i))throw"The material of the source mesh must be a Fur Material";for(r=1;r<t;r++){var s=new i(o.name+r,e.getScene());e.getScene().materials.pop(),a.Tags.EnableFor(s),a.Tags.AddTagsTo(s,"furShellMaterial"),s.furLength=o.furLength,s.furAngle=o.furAngle,s.furGravity=o.furGravity,s.furSpacing=o.furSpacing,s.furSpeed=o.furSpeed,s.furColor=o.furColor,s.diffuseTexture=o.diffuseTexture,s.furOffset=r/t,s.furTexture=o.furTexture,s.highLevelFur=o.highLevelFur,s.furTime=o.furTime,s.furDensity=o.furDensity;var f=e.clone(e.name+r);f.material=s,f.skeleton=e.skeleton,f.position=a.Vector3.Zero(),n.push(f)}for(r=1;r<n.length;r++)n[r].parent=e;return e.material._meshes=n,n},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)("heightTexture")],i.prototype,"_heightTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"heightTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)()],i.prototype,"furLength",void 0),s([(0,a.serialize)()],i.prototype,"furAngle",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"furColor",void 0),s([(0,a.serialize)()],i.prototype,"furOffset",void 0),s([(0,a.serialize)()],i.prototype,"furSpacing",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"furGravity",void 0),s([(0,a.serialize)()],i.prototype,"furSpeed",void 0),s([(0,a.serialize)()],i.prototype,"furDensity",void 0),s([(0,a.serialize)()],i.prototype,"furOcclusion",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serialize)()],i.prototype,"highLevelFur",void 0),s([(0,a.serialize)()],i.prototype,"furTime",null),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.FurMaterial",T);a.ShaderStore.ShadersStore.gradientPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 topColor;uniform vec4 bottomColor;uniform float offset;uniform float scale;uniform float smoothness;varying vec3 vPositionW;varying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\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#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);float h=vPosition.y*scale+offset;float mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));vec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));vec3 diffuseColor=baseColor.rgb;float 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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef EMISSIVE\nvec3 diffuseBase=baseColor.rgb;\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);\n#endif\nlightingInfo info;float shadow=1.;float glossiness=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.gradientVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;varying vec3 vPosition;\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#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);vPosition=position;\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var _=function(e){function i(){var i=e.call(this)||this;return i.EMISSIVE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),x=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r._maxSimultaneousLights=4,r.topColor=new a.Color3(1,0,0),r.topColorAlpha=1,r.bottomColor=new a.Color3(0,0,1),r.bottomColorAlpha=1,r.offset=0,r.scale=1,r.smoothness=1,r._disableLighting=!1,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},i.prototype.needAlphaTesting=function(){return!0},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new _);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),r.EMISSIVE=this._disableLighting,a.MaterialHelper.PrepareDefinesForAttributes(e,r,!1,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","topColor","bottomColor","offset","smoothness","scale"];(0,a.addClipPlaneUniforms)(u);var d=[],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:4}),i.setEffect(n.getEngine().createEffect("gradient",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,o),this._mustRebind(r,o)&&((0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,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("scale",this.scale),this._activeEffect.setFloat("smoothness",this.smoothness),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){return[]},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.GradientMaterial",i},i.prototype.getClassName=function(){return"GradientMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"topColor",void 0),s([(0,a.serialize)()],i.prototype,"topColorAlpha",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"bottomColor",void 0),s([(0,a.serialize)()],i.prototype,"bottomColorAlpha",void 0),s([(0,a.serialize)()],i.prototype,"offset",void 0),s([(0,a.serialize)()],i.prototype,"scale",void 0),s([(0,a.serialize)()],i.prototype,"smoothness",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.GradientMaterial",x);a.ShaderStore.ShadersStore.gridPixelShader="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;uniform float visibility;uniform vec3 mainColor;uniform vec3 lineColor;uniform vec4 gridControl;uniform vec3 gridOffset;varying vec3 vPosition;varying vec3 vNormal;\n#include<fogFragmentDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;uniform sampler2D opacitySampler;uniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {float majorGridFrequency=gridControl.y;if (floor(position+0.5)==floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{return 1.0;}\nreturn gridControl.z;}\nfloat getAnisotropicAttenuation(float differentialLength) {const float maxNumberOfLines=10.0;return clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);}\nfloat isPointOnLine(float position,float differentialLength) {float fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \n#ifdef ANTIALIAS\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);float result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result;\n#else\nreturn abs(fractionPartOfPosition)<SQRT2/4. ? 1. : 0.;\n#endif\n}\nfloat contributionOnAxis(float position) {float differentialLength=length(vec2(dFdx(position),dFdy(position)));differentialLength*=SQRT2; \nfloat result=isPointOnLine(position,differentialLength);float dynamicVisibility=getDynamicVisibility(position);result*=dynamicVisibility;float anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);result*=anisotropicAttenuation;return result;}\nfloat normalImpactOnAxis(float x) {float normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);return normalImpact;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat gridRatio=gridControl.x;vec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;float x=contributionOnAxis(gridPos.x);float y=contributionOnAxis(gridPos.y);float z=contributionOnAxis(gridPos.z);vec3 normal=normalize(vNormal);x*=normalImpactOnAxis(normal.x);y*=normalImpactOnAxis(normal.y);z*=normalImpactOnAxis(normal.z);\n#ifdef MAX_LINE\nfloat grid=clamp(max(max(x,y),z),0.,1.);\n#else\nfloat grid=clamp(x+y+z,0.,1.);\n#endif\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif\n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif\ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n#endif\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.gridVertexShader="precision highp float;attribute vec3 position;attribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#include<instancesDeclaration>\nuniform mat4 projection;uniform mat4 view;varying vec3 vPosition;varying vec3 vNormal;\n#include<fogVertexDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<fogVertex>\nvec4 cameraSpacePosition=view*worldPos;gl_Position=projection*cameraSpacePosition;\n#ifdef OPACITY\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\nif (vOpacityInfos.x==0.)\n{vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));}\nelse\n{vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));}\n#endif \nvPosition=position;vNormal=normal;\n#define CUSTOM_VERTEX_MAIN_END\n}";var S=function(e){function i(){var i=e.call(this)||this;return i.OPACITY=!1,i.ANTIALIAS=!1,i.TRANSPARENT=!1,i.FOG=!1,i.PREMULTIPLYALPHA=!1,i.MAX_LINE=!1,i.UV1=!1,i.UV2=!1,i.INSTANCES=!1,i.THIN_INSTANCES=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),E=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.mainColor=a.Color3.Black(),r.lineColor=a.Color3.Teal(),r.gridRatio=1,r.gridOffset=a.Vector3.Zero(),r.majorUnitFrequency=10,r.minorUnitVisibility=.33,r.opacity=1,r.antialias=!0,r.preMultiplyAlpha=!1,r.useMaxLine=!1,r._gridControl=new a.Vector4(r.gridRatio,r.majorUnitFrequency,r.minorUnitVisibility,r.opacity),r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.opacity<1||this._opacityTexture&&this._opacityTexture.isReady()},i.prototype.needAlphaBlendingForMesh=function(e){return e.visibility<1||this.needAlphaBlending()},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new S);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;if(r.TRANSPARENT!==this.opacity<1&&(r.TRANSPARENT=!r.TRANSPARENT,r.markAsUnprocessed()),r.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(r.PREMULTIPLYALPHA=!r.PREMULTIPLYALPHA,r.markAsUnprocessed()),r.MAX_LINE!==this.useMaxLine&&(r.MAX_LINE=!r.MAX_LINE,r.markAsUnprocessed()),r.ANTIALIAS!==this.antialias&&(r.ANTIALIAS=!r.ANTIALIAS,r.markAsUnprocessed()),r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled&&this._opacityTexture&&a.MaterialFlags.OpacityTextureEnabled)){if(!this._opacityTexture.isReady())return!1;r._needUVs=!0,r.OPACITY=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,!1,this.fogEnabled,!1,r),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,n.getEngine(),this,r,!!t),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial(),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!1,!1);var o=[a.VertexBuffer.PositionKind,a.VertexBuffer.NormalKind];r.UV1&&o.push(a.VertexBuffer.UVKind),r.UV2&&o.push(a.VertexBuffer.UV2Kind),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess,a.MaterialHelper.PrepareAttributesForInstances(o,r);var s=r.toString();i.setEffect(n.getEngine().createEffect("grid",o,["projection","mainColor","lineColor","gridControl","gridOffset","vFogInfos","vFogColor","world","view","opacityMatrix","vOpacityInfos","visibility"],["opacitySampler"],s,void 0,this.onCompiled,this.onError),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this._activeEffect.setFloat("visibility",i.visibility),n.INSTANCES&&!n.THIN_INSTANCE||this.bindOnlyWorldMatrix(e),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),this._opacityTexture&&a.MaterialFlags.OpacityTextureEnabled&&(this._activeEffect.setTexture("opacitySampler",this._opacityTexture),this._activeEffect.setFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._activeEffect.setMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix()))),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.GridMaterial",i},i.prototype.getClassName=function(){return"GridMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsColor3)()],i.prototype,"mainColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"lineColor",void 0),s([(0,a.serialize)()],i.prototype,"gridRatio",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"gridOffset",void 0),s([(0,a.serialize)()],i.prototype,"majorUnitFrequency",void 0),s([(0,a.serialize)()],i.prototype,"minorUnitVisibility",void 0),s([(0,a.serialize)()],i.prototype,"opacity",void 0),s([(0,a.serialize)()],i.prototype,"antialias",void 0),s([(0,a.serialize)()],i.prototype,"preMultiplyAlpha",void 0),s([(0,a.serialize)()],i.prototype,"useMaxLine",void 0),s([(0,a.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.GridMaterial",E);a.ShaderStore.ShadersStore.lavaPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;uniform float time;uniform float speed;uniform float movingSpeed;uniform vec3 fogColor;uniform sampler2D noiseTexture;uniform float fogDensity;varying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\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#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){return fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );vec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time *0.02;vec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;T1.x+=noiseTex.x*2.0;T1.y+=noiseTex.y*2.0;T2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;T2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;float p=texture2D( noiseTexture,T1*3.0 ).a;vec4 lavaColor=texture2D( diffuseSampler,T2*4.0);vec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );baseColor=temp;float depth=gl_FragCoord.z*4.0;const float LOG2=1.442695;float fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );fogFactor=1.0-clamp( fogFactor,0.0,1.0 );baseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );diffuseColor=baseColor.rgb;\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#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.lavaVertexShader="precision highp float;uniform float time;uniform float lowFrequencySpeed;varying float noise;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\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/* NOISE FUNCTIONS */\nvec3 mod289(vec3 x)\n{return x-floor(x*(1.0/289.0))*289.0;}\nvec4 mod289(vec4 x)\n{return x-floor(x*(1.0/289.0))*289.0;}\nvec4 permute(vec4 x)\n{return mod289(((x*34.0)+1.0)*x);}\nvec4 taylorInvSqrt(vec4 r)\n{return 1.79284291400159-0.85373472095314*r;}\nvec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}\nfloat pnoise(vec3 P,vec3 rep)\n{vec3 Pi0=mod(floor(P),rep); \nvec3 Pi1=mod(Pi0+vec3(1.0),rep); \nPi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P); \nvec3 Pf1=Pf0-vec3(1.0); \nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}\n/* END FUNCTION */\nfloat turbulence( vec3 p ) {float w=100.0;float t=-.5;for (float f=1.0 ; f<=10.0 ; f++ ){float power=pow( 2.0,f );t+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );}\nreturn t;}\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef NORMAL\nnoise=10.0* -.10*turbulence( .5*normal+time*1.15 );float b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );float displacement=- 1.5*noise+b;vec3 newPosition=position+normal*displacement;gl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos);vNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";var C=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.SHADOWPOISSON0=!1,i.SHADOWPOISSON1=!1,i.SHADOWPOISSON2=!1,i.SHADOWPOISSON3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!1,i.SHADOWPCSS0=!1,i.SHADOWPCSS1=!1,i.SHADOWPCSS2=!1,i.SHADOWPCSS3=!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.INSTANCESCOLOR=!1,i.UNLIT=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),P=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.speed=1,r.movingSpeed=1,r.lowFrequencySpeed=1,r.fogDensity=.15,r._lastTime=0,r.diffuseColor=new a.Color3(1,1,1),r._disableLighting=!1,r._unlit=!1,r._maxSimultaneousLights=4,r._scaledDiffuse=new a.Color3,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new C);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=!0,a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","time","speed","movingSpeed","fogColor","fogDensity","lowFrequencySpeed"];(0,a.addClipPlaneUniforms)(u);var d=["diffuseSampler","noiseTexture"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("lava",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,n.UNLIT=this._unlit,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this.diffuseTexture&&a.MaterialFlags.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),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._lastTime+=r.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime*this.speed/1e3),this.fogColor||(this.fogColor=a.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(i,this._activeEffect))}},i.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},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this.diffuseTexture&&this.diffuseTexture.dispose(),this.noiseTexture&&this.noiseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.LavaMaterial",i},i.prototype.getClassName=function(){return"LavaMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)()],i.prototype,"noiseTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"fogColor",void 0),s([(0,a.serialize)()],i.prototype,"speed",void 0),s([(0,a.serialize)()],i.prototype,"movingSpeed",void 0),s([(0,a.serialize)()],i.prototype,"lowFrequencySpeed",void 0),s([(0,a.serialize)()],i.prototype,"fogDensity",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("unlit")],i.prototype,"_unlit",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"unlit",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.LavaMaterial",P);a.ShaderStore.ShadersStore.mixPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform sampler2D mixMap1Sampler;uniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;uniform sampler2D diffuse2Sampler;uniform sampler2D diffuse3Sampler;uniform sampler2D diffuse4Sampler;uniform vec2 diffuse1Infos;uniform vec2 diffuse2Infos;uniform vec2 diffuse3Infos;uniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;uniform sampler2D diffuse6Sampler;uniform sampler2D diffuse7Sampler;uniform sampler2D diffuse8Sampler;uniform vec2 diffuse5Infos;uniform vec2 diffuse6Infos;uniform vec2 diffuse7Infos;uniform vec2 diffuse8Infos;\n#endif\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 finalMixColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;vec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);vec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);vec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);vec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);diffuse1Color.rgb*=mixColor.r;diffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);diffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);finalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);mixColor.rgb*=vTextureInfos.y;vec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);vec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);vec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);vec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);diffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);diffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);diffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);finalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\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*finalMixColor.rgb,0.0,1.0);vec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.mixVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\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#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}\nelse\n{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var y=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.MIXMAP2=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),M=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r.specularColor=new a.Color3(0,0,0),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new y);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(n.texturesEnabled){if(!this._mixTexture1||!this._mixTexture1.isReady())return!1;if(r._needUVs=!0,a.MaterialFlags.DiffuseTextureEnabled){if(!this._diffuseTexture1||!this._diffuseTexture1.isReady())return!1;if(r.DIFFUSE=!0,!this._diffuseTexture2||!this._diffuseTexture2.isReady())return!1;if(!this._diffuseTexture3||!this._diffuseTexture3.isReady())return!1;if(!this._diffuseTexture4||!this._diffuseTexture4.isReady())return!1;if(this._mixTexture2){if(!this._mixTexture2.isReady())return!1;if(r.MIXMAP2=!0,!this._diffuseTexture5||!this._diffuseTexture5.isReady())return!1;if(!this._diffuseTexture6||!this._diffuseTexture6.isReady())return!1;if(!this._diffuseTexture7||!this._diffuseTexture7.isReady())return!1;if(!this._diffuseTexture8||!this._diffuseTexture8.isReady())return!1}}}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos","diffuse4Infos","diffuse5Infos","diffuse6Infos","diffuse7Infos","diffuse8Infos"],d=["mixMap1Sampler","mixMap2Sampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","diffuse4Sampler","diffuse5Sampler","diffuse6Sampler","diffuse7Sampler","diffuse8Sampler"],c=new Array;(0,a.addClipPlaneUniforms)(u),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("mix",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this._mixTexture1&&(this._activeEffect.setTexture("mixMap1Sampler",this._mixTexture1),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture1.coordinatesIndex,this._mixTexture1.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture1.getTextureMatrix()),a.MaterialFlags.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)),this._diffuseTexture4&&(this._activeEffect.setTexture("diffuse4Sampler",this._diffuseTexture4),this._activeEffect.setFloat2("diffuse4Infos",this._diffuseTexture4.uScale,this._diffuseTexture4.vScale)))),this._mixTexture2&&(this._activeEffect.setTexture("mixMap2Sampler",this._mixTexture2),a.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture5&&(this._activeEffect.setTexture("diffuse5Sampler",this._diffuseTexture5),this._activeEffect.setFloat2("diffuse5Infos",this._diffuseTexture5.uScale,this._diffuseTexture5.vScale)),this._diffuseTexture6&&(this._activeEffect.setTexture("diffuse6Sampler",this._diffuseTexture6),this._activeEffect.setFloat2("diffuse6Infos",this._diffuseTexture6.uScale,this._diffuseTexture6.vScale)),this._diffuseTexture7&&(this._activeEffect.setTexture("diffuse7Sampler",this._diffuseTexture7),this._activeEffect.setFloat2("diffuse7Infos",this._diffuseTexture7.uScale,this._diffuseTexture7.vScale)),this._diffuseTexture8&&(this._activeEffect.setTexture("diffuse8Sampler",this._diffuseTexture8),this._activeEffect.setFloat2("diffuse8Infos",this._diffuseTexture8.uScale,this._diffuseTexture8.vScale)))),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._mixTexture1&&this._mixTexture1.animations&&this._mixTexture1.animations.length>0&&e.push(this._mixTexture1),this._mixTexture2&&this._mixTexture2.animations&&this._mixTexture2.animations.length>0&&e.push(this._mixTexture2),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._mixTexture1&&i.push(this._mixTexture1),this._diffuseTexture1&&i.push(this._diffuseTexture1),this._diffuseTexture2&&i.push(this._diffuseTexture2),this._diffuseTexture3&&i.push(this._diffuseTexture3),this._diffuseTexture4&&i.push(this._diffuseTexture4),this._mixTexture2&&i.push(this._mixTexture2),this._diffuseTexture5&&i.push(this._diffuseTexture5),this._diffuseTexture6&&i.push(this._diffuseTexture6),this._diffuseTexture7&&i.push(this._diffuseTexture7),this._diffuseTexture8&&i.push(this._diffuseTexture8),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._mixTexture1===i||this._diffuseTexture1===i||this._diffuseTexture2===i||this._diffuseTexture3===i||this._diffuseTexture4===i||this._mixTexture2===i||this._diffuseTexture5===i||this._diffuseTexture6===i||this._diffuseTexture7===i||this._diffuseTexture8===i},i.prototype.dispose=function(i){this._mixTexture1&&this._mixTexture1.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.MixMaterial",i},i.prototype.getClassName=function(){return"MixMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("mixTexture1")],i.prototype,"_mixTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture1",void 0),s([(0,a.serializeAsTexture)("mixTexture2")],i.prototype,"_mixTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture1",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture3",void 0),s([(0,a.serializeAsTexture)("diffuseTexture4")],i.prototype,"_diffuseTexture4",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture4",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture5",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture5",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture6",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture6",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture7",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture7",void 0),s([(0,a.serializeAsTexture)("diffuseTexture4")],i.prototype,"_diffuseTexture8",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture8",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.MixMaterial",M);a.ShaderStore.ShadersStore.normalPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef LIGHTING\n#include<helperFunctions>\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#endif\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float 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 NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef LIGHTING\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse= baseColor.rgb;\n#endif\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.normalVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var A=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.SHADOWPOISSON0=!1,i.SHADOWPOISSON1=!1,i.SHADOWPOISSON2=!1,i.SHADOWPOISSON3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!1,i.SHADOWPCSS0=!1,i.SHADOWPCSS1=!1,i.SHADOWPCSS2=!1,i.SHADOWPCSS3=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.LIGHTING=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),F=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new A);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=!0,a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),r.LIGHTING=!this._disableLighting,a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix"],d=["diffuseSampler"],c=new Array;(0,a.addClipPlaneUniforms)(u),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:4}),i.setEffect(n.getEngine().createEffect("normal",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this.diffuseTexture&&this.diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.NormalMaterial",i},i.prototype.getClassName=function(){return"NormalMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.NormalMaterial",F);a.ShaderStore.ShadersStore.shadowOnlyPixelShader="precision highp float;uniform vec4 vEyePosition;uniform float alpha;uniform vec3 shadowColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#include<lightFragment>[0..1]\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.shadowOnlyVertexShader="precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\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#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var N=function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),I=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r._needAlphaBlending=!0,r.shadowColor=a.Color3.Black(),r}return o(i,e),i.prototype.needAlphaBlending=function(){return this._needAlphaBlending},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(i.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),i.prototype._getFirstShadowLightForMesh=function(e){for(var i=0,t=e.lightSources;i<t.length;i++){var r=t[i];if(r.shadowEnabled)return r}return null},i.prototype.isReadyForSubMesh=function(e,i,t){var r;if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new N);var n=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(this._activeLight)for(var f=0,l=e.lightSources;f<l.length;f++){var u=l[f];if(u.shadowEnabled){if(this._activeLight===u)break;var d=e.lightSources.indexOf(this._activeLight);-1!==d&&(e.lightSources.splice(d,1),e.lightSources.splice(0,0,this._activeLight));break}}a.MaterialHelper.PrepareDefinesForFrameBoundValues(o,s,this,n,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,1);var c=null===(r=this._getFirstShadowLightForMesh(e))||void 0===r?void 0:r.getShadowGenerator();if(this._needAlphaBlending=!0,c&&c.getClassName&&"CascadedShadowGenerator"===c.getClassName()){var p=c;this._needAlphaBlending=!p.autoCalcDepthBounds}if(a.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var h=new a.EffectFallbacks;n.FOG&&h.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,h,1),n.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var m=[a.VertexBuffer.PositionKind];n.NORMAL&&m.push(a.VertexBuffer.NormalKind),a.MaterialHelper.PrepareAttributesForBones(m,e,n,h),a.MaterialHelper.PrepareAttributesForInstances(m,n);var v=n.toString(),g=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones"],T=new Array,_=new Array;(0,a.addClipPlaneUniforms)(g),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:g,uniformBuffersNames:_,samplers:T,defines:n,maxSimultaneousLights:1}),i.setEffect(o.getEngine().createEffect("shadowOnly",{attributes:m,uniformsNames:g,uniformBuffersNames:_,samplers:T,defines:v,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},s),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=o.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;if(o){if(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&((0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),r.bindEyePosition(o)),r.lightsEnabled){a.MaterialHelper.BindLights(r,i,this._activeEffect,n,1);var s=this._getFirstShadowLightForMesh(i);s&&(s._renderId=-1)}(r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE||n.SHADOWCSM0)&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect)}}},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.ShadowOnlyMaterial",i},i.prototype.getClassName=function(){return"ShadowOnlyMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.ShadowOnlyMaterial",I);a.ShaderStore.ShadersStore.simplePixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float 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#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.simpleVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var b=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),L=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new b);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix"],d=["diffuseSampler"],c=new Array;(0,a.addClipPlaneUniforms)(u),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("simple",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights-1}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.SimpleMaterial",i},i.prototype.getClassName=function(){return"SimpleMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.SimpleMaterial",L);a.ShaderStore.ShadersStore.skyPixelShader="precision highp float;varying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\nuniform vec3 cameraPosition;uniform vec3 cameraOffset;uniform vec3 up;uniform float luminance;uniform float turbidity;uniform float rayleigh;uniform float mieCoefficient;uniform float mieDirectionalG;uniform vec3 sunPosition;\n#include<fogFragmentDeclaration>\nconst float e=2.71828182845904523536028747135266249775724709369995957;const float pi=3.141592653589793238462643383279502884197169;const float n=1.0003;const float N=2.545E25;const float pn=0.035;const vec3 lambda=vec3(680E-9,550E-9,450E-9);const vec3 K=vec3(0.686,0.678,0.666);const float v=4.0;const float rayleighZenithLength=8.4E3;const float mieZenithLength=1.25E3;const float EE=1000.0;const float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;const float cutoffAngle=pi/1.95;const float steepness=1.5;vec3 totalRayleigh(vec3 lambda)\n{return (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));}\nvec3 simplifiedRayleigh()\n{return 0.0005/vec3(94,40,18);}\nfloat rayleighPhase(float cosTheta)\n{ \nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{float c=(0.2*T )*10E-18;return 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;}\nfloat hgPhase(float cosTheta,float g)\n{return (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));}\nfloat sunIntensity(float zenithAngleCos)\n{return EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));}\nfloat A=0.15;float B=0.50;float C=0.10;float D=0.20;float EEE=0.02;float F=0.30;float W=1000.0;vec3 Uncharted2Tonemap(vec3 x)\n{return ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;}\n#if DITHER\n#include<helperFunctions>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);float rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));vec3 sunDirection=normalize(sunPosition);float sunE=sunIntensity(dot(sunDirection,up));vec3 betaR=simplifiedRayleigh()*rayleighCoefficient;vec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;float zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));float sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));float sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));vec3 Fex=exp(-(betaR*sR+betaM*sM));float cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);float rPhase=rayleighPhase(cosTheta*0.5+0.5);vec3 betaRTheta=betaR*rPhase;float mPhase=hgPhase(cosTheta,mieDirectionalG);vec3 betaMTheta=betaM*mPhase;vec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));Lin*=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));vec3 direction=normalize(vPositionW-cameraPosition);float theta=acos(direction.y);float phi=atan(direction.z,direction.x);vec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);vec3 L0=vec3(0.1)*Fex;float sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);L0+=(sunE*19000.0*Fex)*sundisk;vec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));vec3 texColor=(Lin+L0);texColor*=0.04 ;texColor+=vec3(0.0,0.001,0.0025)*0.3;float g_fMaxLuminance=1.0;float fLumScaled=0.1/luminance; \nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled); \nfloat ExposureBias=fLumCompressed;vec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);vec3 retColor=curr*whiteScale;/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#if DITHER\nretColor.rgb+=dither(gl_FragCoord.xy,0.5);\n#endif\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.skyVertexShader="precision highp float;attribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\nuniform mat4 world;uniform mat4 view;uniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=viewProjection*world*vec4(position,1.0);vec4 worldPos=world*vec4(position,1.0);vPositionW=vec3(worldPos);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var O=function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.POINTSIZE=!1,i.FOG=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.DITHER=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),R=function(e){function i(i,t){var r=e.call(this,i,t)||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 a.Vector3(0,100,0),r.useSunPosition=!1,r.cameraOffset=a.Vector3.Zero(),r.up=a.Vector3.Up(),r.dithering=!1,r._cameraPosition=a.Vector3.Zero(),r._skyOrientation=new a.Quaternion,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new O);var t=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,!1,t),a.MaterialHelper.PrepareDefinesForAttributes(e,t,!0,!1),t.IMAGEPROCESSINGPOSTPROCESS!==r.imageProcessingConfiguration.applyByPostProcess&&t.markAsMiscDirty(),t.DITHER!==this.dithering&&t.markAsMiscDirty(),t.isDirty){t.markAsProcessed(),r.resetCachedMaterial();var n=new a.EffectFallbacks;t.FOG&&n.addFallback(1,"FOG"),t.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess,t.DITHER=this.dithering;var o=[a.VertexBuffer.PositionKind];t.VERTEXCOLOR&&o.push(a.VertexBuffer.ColorKind);var s=["world","viewProjection","view","vFogInfos","vFogColor","pointSize","luminance","turbidity","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","cameraPosition","cameraOffset","up"];(0,a.addClipPlaneUniforms)(s);var f=t.toString();i.setEffect(r.getEngine().createEffect("sky",o,s,[],f,n,this.onCompiled,this.onError),t,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(t._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene();if(t.materialDefines){var n=t.effect;if(n){this._activeEffect=n,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),this._mustRebind(r,n)&&((0,a.bindClipPlane)(n,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize)),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect);var o=r.activeCamera;if(o){var s=o.getWorldMatrix();this._cameraPosition.x=s.m[12],this._cameraPosition.y=s.m[13],this._cameraPosition.z=s.m[14],this._activeEffect.setVector3("cameraPosition",this._cameraPosition)}if(this._activeEffect.setVector3("cameraOffset",this.cameraOffset),this._activeEffect.setVector3("up",this.up),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 f=Math.PI*(this.inclination-.5),l=2*Math.PI*(this.azimuth-.5);this.sunPosition.x=this.distance*Math.cos(l)*Math.cos(f),this.sunPosition.y=this.distance*Math.sin(-f),this.sunPosition.z=this.distance*Math.sin(l)*Math.cos(f),a.Quaternion.FromUnitVectorsToRef(a.Vector3.UpReadOnly,this.up,this._skyOrientation),this.sunPosition.rotateByQuaternionToRef(this._skyOrientation,this.sunPosition)}this._activeEffect.setVector3("sunPosition",this.sunPosition),this._afterBind(i,this._activeEffect)}}},i.prototype.getAnimatables=function(){return[]},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.SkyMaterial",i},i.prototype.getClassName=function(){return"SkyMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serialize)()],i.prototype,"luminance",void 0),s([(0,a.serialize)()],i.prototype,"turbidity",void 0),s([(0,a.serialize)()],i.prototype,"rayleigh",void 0),s([(0,a.serialize)()],i.prototype,"mieCoefficient",void 0),s([(0,a.serialize)()],i.prototype,"mieDirectionalG",void 0),s([(0,a.serialize)()],i.prototype,"distance",void 0),s([(0,a.serialize)()],i.prototype,"inclination",void 0),s([(0,a.serialize)()],i.prototype,"azimuth",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"sunPosition",void 0),s([(0,a.serialize)()],i.prototype,"useSunPosition",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"cameraOffset",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"up",void 0),s([(0,a.serialize)()],i.prototype,"dithering",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.SkyMaterial",R);a.ShaderStore.ShadersStore.terrainPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform sampler2D textureSampler;uniform vec2 vTextureInfos;uniform sampler2D diffuse1Sampler;uniform sampler2D diffuse2Sampler;uniform sampler2D diffuse3Sampler;uniform vec2 diffuse1Infos;uniform vec2 diffuse2Infos;uniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;uniform sampler2D bump2Sampler;uniform sampler2D bump3Sampler;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));return mat3(tangent*invmax,binormal*invmax,normal);}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{vec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;vec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;vec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;bump1Color.rgb*=mixColor.r;bump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);vec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);map=map*255./127.-128./127.;mat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);return normalize(TBN*map);}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\nfloat alpha=vDiffuseColor.a;\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;vec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);vec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);vec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);diffuse1Color.rgb*=baseColor.r;diffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);baseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\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);vec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.terrainVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}\nelse\n{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var D=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.BUMP=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),U=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.diffuseColor=new a.Color3(1,1,1),r.specularColor=new a.Color3(0,0,0),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new D);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(n.texturesEnabled){if(!this.mixTexture||!this.mixTexture.isReady())return!1;if(r._needUVs=!0,a.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture1||!this.diffuseTexture1.isReady())return!1;if(!this.diffuseTexture2||!this.diffuseTexture2.isReady())return!1;if(!this.diffuseTexture3||!this.diffuseTexture3.isReady())return!1;r.DIFFUSE=!0}if(this.bumpTexture1&&this.bumpTexture2&&this.bumpTexture3&&a.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture1.isReady())return!1;if(!this.bumpTexture2.isReady())return!1;if(!this.bumpTexture3.isReady())return!1;r._needNormals=!0,r.BUMP=!0}}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var s=new a.EffectFallbacks;r.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,s,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];r.NORMAL&&f.push(a.VertexBuffer.NormalKind),r.UV1&&f.push(a.VertexBuffer.UVKind),r.UV2&&f.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,r,s),a.MaterialHelper.PrepareAttributesForInstances(f,r);var l=r.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos"],d=["textureSampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","bump1Sampler","bump2Sampler","bump3Sampler"],c=new Array;(0,a.addClipPlaneUniforms)(u),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("terrain",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(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()),a.MaterialFlags.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))),a.MaterialFlags.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))),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._mixTexture&&i.push(this._mixTexture),this._diffuseTexture1&&i.push(this._diffuseTexture1),this._diffuseTexture2&&i.push(this._diffuseTexture2),this._diffuseTexture3&&i.push(this._diffuseTexture3),this._bumpTexture1&&i.push(this._bumpTexture1),this._bumpTexture2&&i.push(this._bumpTexture2),this._bumpTexture3&&i.push(this._bumpTexture3),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._mixTexture===i||this._diffuseTexture1===i||this._diffuseTexture2===i||this._diffuseTexture3===i||this._bumpTexture1===i||this._bumpTexture2===i||this._bumpTexture3===i},i.prototype.dispose=function(i){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.TerrainMaterial",i},i.prototype.getClassName=function(){return"TerrainMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)("mixTexture")],i.prototype,"_mixTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture1",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture3",void 0),s([(0,a.serializeAsTexture)("bumpTexture1")],i.prototype,"_bumpTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture1",void 0),s([(0,a.serializeAsTexture)("bumpTexture2")],i.prototype,"_bumpTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture2",void 0),s([(0,a.serializeAsTexture)("bumpTexture3")],i.prototype,"_bumpTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture3",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.TerrainMaterial",U);a.ShaderStore.ShadersStore.triplanarPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;uniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;uniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;uniform 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>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(0.,0.,0.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\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);normalW*=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#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\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;vec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.triplanarVertexShader="precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform 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\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=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\nvec3 xtan=vec3(0,0,1);vec3 xbin=vec3(0,1,0);vec3 ytan=vec3(1,0,0);vec3 ybin=vec3(0,0,1);vec3 ztan=vec3(1,0,0);vec3 zbin=vec3(0,1,0);vec3 normalizedNormal=normalize(normal);normalizedNormal*=normalizedNormal;vec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);vec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);mat3 normalWorld=mat3(world);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nworldTangent=normalize((normalWorld*worldTangent).xyz);worldBinormal=normalize((normalWorld*worldBinormal).xyz);vec3 worldNormal=normalize((normalWorld*normalize(normal)).xyz);tangentSpace[0]=worldTangent;tangentSpace[1]=worldBinormal;tangentSpace[2]=worldNormal;\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var V=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.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.NONUNIFORMSCALING=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),w=function(e){function i(i,t){var r=e.call(this,i,t)||this;return r.tileSize=1,r.diffuseColor=new a.Color3(1,1,1),r.specularColor=new a.Color3(.2,.2,.2),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new V);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&n.texturesEnabled){if(a.MaterialFlags.DiffuseTextureEnabled)for(var s=[this.diffuseTextureX,this.diffuseTextureY,this.diffuseTextureZ],f=["DIFFUSEX","DIFFUSEY","DIFFUSEZ"],l=0;l<s.length;l++)if(s[l]){if(!s[l].isReady())return!1;r[f[l]]=!0}if(a.MaterialFlags.BumpTextureEnabled)for(s=[this.normalTextureX,this.normalTextureY,this.normalTextureZ],f=["BUMPX","BUMPY","BUMPZ"],l=0;l<s.length;l++)if(s[l]){if(!s[l].isReady())return!1;r[f[l]]=!0}}if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var u=new a.EffectFallbacks;r.FOG&&u.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,u,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var d=[a.VertexBuffer.PositionKind];r.NORMAL&&d.push(a.VertexBuffer.NormalKind),r.VERTEXCOLOR&&d.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(d,e,r,u),a.MaterialHelper.PrepareAttributesForInstances(d,r);var c=r.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","mBones","tileSize"],h=["diffuseSamplerX","diffuseSamplerY","diffuseSamplerZ","normalSamplerX","normalSamplerY","normalSamplerZ"],m=new Array;(0,a.addClipPlaneUniforms)(p),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:m,samplers:h,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("triplanar",{attributes:d,uniformsNames:p,uniformBuffersNames:m,samplers:h,defines:c,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,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),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTextureX&&i.push(this._diffuseTextureX),this._diffuseTextureY&&i.push(this._diffuseTextureY),this._diffuseTextureZ&&i.push(this._diffuseTextureZ),this._normalTextureX&&i.push(this._normalTextureX),this._normalTextureY&&i.push(this._normalTextureY),this._normalTextureZ&&i.push(this._normalTextureZ),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTextureX===i||this._diffuseTextureY===i||this._diffuseTextureZ===i||this._normalTextureX===i||this._normalTextureY===i||this._normalTextureZ===i},i.prototype.dispose=function(i){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.TriPlanarMaterial",i},i.prototype.getClassName=function(){return"TriPlanarMaterial"},i.Parse=function(e,t,r){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r)},s([(0,a.serializeAsTexture)()],i.prototype,"mixTexture",void 0),s([(0,a.serializeAsTexture)("diffuseTextureX")],i.prototype,"_diffuseTextureX",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureX",void 0),s([(0,a.serializeAsTexture)("diffuseTexturY")],i.prototype,"_diffuseTextureY",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureY",void 0),s([(0,a.serializeAsTexture)("diffuseTextureZ")],i.prototype,"_diffuseTextureZ",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureZ",void 0),s([(0,a.serializeAsTexture)("normalTextureX")],i.prototype,"_normalTextureX",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureX",void 0),s([(0,a.serializeAsTexture)("normalTextureY")],i.prototype,"_normalTextureY",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureY",void 0),s([(0,a.serializeAsTexture)("normalTextureZ")],i.prototype,"_normalTextureZ",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureZ",void 0),s([(0,a.serialize)()],i.prototype,"tileSize",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.TriPlanarMaterial",w);a.ShaderStore.ShadersStore.waterPixelShader="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform sampler2D normalSampler;uniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;uniform sampler2D reflectionSampler;const float LOG2=1.442695;uniform vec3 cameraPosition;uniform vec4 waterColor;uniform float colorBlendFactor;uniform vec4 waterColor2;uniform float colorBlendFactor2;uniform float bumpHeight;uniform float time;varying vec3 vRefractionMapTexCoord;varying vec3 vReflectionMapTexCoord;\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float 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#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nbaseColor.rgb*=vColor.rgb;\n#endif\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));if (normalW.y<0.0) {normalW.y=-normalW.y;}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);vec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);vec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);vec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);float fresnelTerm=clamp(abs(pow(dot(viewDirectionW,upVector),3.0)),0.05,0.65);float IfresnelTerm=1.0-fresnelTerm;refractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;reflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;vec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;baseColor=combinedColor;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 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#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\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\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);vec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);vec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);float fresnelTerm=max(dot(viewDirectionW,upVector),0.0);vec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);baseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;vec3 specularBase=vec3(0.,0.,0.);vec3 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#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#elif defined(IMAGEPROCESSING)\ncolor.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.waterVertexShader="precision highp float;attribute 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#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;uniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\nuniform mat4 reflectionViewProjection;uniform vec2 windDirection;uniform float waveLength;uniform float time;uniform float windForce;uniform float waveHeight;uniform float waveSpeed;uniform float waveCount;varying vec3 vRefractionMapTexCoord;varying vec3 vReflectionMapTexCoord;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\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{vNormalUV=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{vNormalUV=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#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\nfloat finalWaveCount=1.0/(waveCount*0.5);\n#ifdef USE_WORLD_COORDINATES\nvec3 p=worldPos.xyz;\n#else\nvec3 p=position;\n#endif\nfloat newY=(sin(((p.x/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+ (cos(((p.z/finalWaveCount)+ time*waveSpeed))*waveHeight*windDirection.y*5.0);p.y+=abs(newY);\n#ifdef USE_WORLD_COORDINATES\ngl_Position=viewProjection*vec4(p,1.0);\n#else\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#endif\n#ifdef REFLECTION\nvRefractionMapTexCoord.x=0.5*(gl_Position.w+gl_Position.x);vRefractionMapTexCoord.y=0.5*(gl_Position.w+gl_Position.y);vRefractionMapTexCoord.z=gl_Position.w;worldPos=reflectionViewProjection*finalWorld*vec4(position,1.0);vReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);vReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);vReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var B=function(e){function i(){var i=e.call(this)||this;return i.BUMP=!1,i.REFLECTION=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!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.INSTANCESCOLOR=!1,i.SPECULARTERM=!1,i.LOGARITHMICDEPTH=!1,i.USE_REVERSE_DEPTHBUFFER=!1,i.FRESNELSEPARATE=!1,i.BUMPSUPERIMPOSE=!1,i.BUMPAFFECTSREFLECTION=!1,i.USE_WORLD_COORDINATES=!1,i.IMAGEPROCESSING=!1,i.VIGNETTE=!1,i.VIGNETTEBLENDMODEMULTIPLY=!1,i.VIGNETTEBLENDMODEOPAQUE=!1,i.TONEMAPPING=!1,i.TONEMAPPING_ACES=!1,i.CONTRAST=!1,i.EXPOSURE=!1,i.COLORCURVES=!1,i.COLORGRADING=!1,i.COLORGRADING3D=!1,i.SAMPLER3DGREENDEPTH=!1,i.SAMPLER3DBGRMAP=!1,i.DITHER=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),z=function(e){function i(i,t,r){void 0===r&&(r=new a.Vector2(512,512));var n=e.call(this,i,t)||this;return n.renderTargetSize=r,n.diffuseColor=new a.Color3(1,1,1),n.specularColor=new a.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n.windForce=6,n.windDirection=new a.Vector2(0,1),n.waveHeight=.4,n.bumpHeight=.4,n._bumpSuperimpose=!1,n._fresnelSeparate=!1,n._bumpAffectsReflection=!1,n.waterColor=new a.Color3(.1,.1,.6),n.colorBlendFactor=.2,n.waterColor2=new a.Color3(.1,.1,.6),n.colorBlendFactor2=.2,n.waveLength=.1,n.waveSpeed=1,n.waveCount=20,n.disableClipPlane=!1,n._useWorldCoordinatesForWaveDeformation=!1,n._renderTargets=new a.SmartArray(16),n._mesh=null,n._reflectionTransform=a.Matrix.Zero(),n._lastTime=0,n._lastDeltaTime=0,n._createRenderTargets(n.getScene(),r),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),n._renderTargets.push(n._reflectionRTT),n._renderTargets.push(n._refractionRTT),n._renderTargets},n._imageProcessingConfiguration=n.getScene().imageProcessingConfiguration,n._imageProcessingConfiguration&&(n._imageProcessingObserver=n._imageProcessingConfiguration.onUpdateParameters.add((function(){n._markAllSubMeshesAsImageProcessingDirty()}))),n}return o(i,e),Object.defineProperty(i.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),i.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},i.prototype.removeFromRenderList=function(e){var i;this._refractionRTT&&this._refractionRTT.renderList&&-1!==(i=this._refractionRTT.renderList.indexOf(e))&&this._refractionRTT.renderList.splice(i,1),this._reflectionRTT&&this._reflectionRTT.renderList&&-1!==(i=this._reflectionRTT.renderList.indexOf(e))&&this._reflectionRTT.renderList.splice(i,1)},i.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},i.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(i.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&0===this._refractionRTT.refreshRate)},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady&&i.effect._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new B);var r=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=n.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,n.texturesEnabled)){if(this.bumpTexture&&a.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;r._needUVs=!0,r.BUMP=!0}a.MaterialFlags.ReflectionTextureEnabled&&(r.REFLECTION=!0)}if(a.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,this,r,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._areMiscDirty&&(r.FRESNELSEPARATE=this._fresnelSeparate,r.BUMPSUPERIMPOSE=this._bumpSuperimpose,r.BUMPAFFECTSREFLECTION=this._bumpAffectsReflection,r.USE_WORLD_COORDINATES=this._useWorldCoordinatesForWaveDeformation),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(n,e,r,!0,this._maxSimultaneousLights,this._disableLighting),r._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(r),r.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,r.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(a.MaterialHelper.PrepareDefinesForAttributes(e,r,!0,!0),this._mesh=e,this._waitingRenderList){for(var s=0;s<this._waitingRenderList.length;s++)this.addToRenderList(n.getNodeById(this._waitingRenderList[s]));this._waitingRenderList=null}if(r.isDirty){r.markAsProcessed(),n.resetCachedMaterial();var f=new a.EffectFallbacks;r.FOG&&f.addFallback(1,"FOG"),r.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),a.MaterialHelper.HandleFallbacksForShadows(r,f,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e);var l=[a.VertexBuffer.PositionKind];r.NORMAL&&l.push(a.VertexBuffer.NormalKind),r.UV1&&l.push(a.VertexBuffer.UVKind),r.UV2&&l.push(a.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(l,e,r,f),a.MaterialHelper.PrepareAttributesForInstances(l,r);var u=r.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","normalMatrix","logarithmicDepthConstant","reflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],c=["normalSampler","refractionSampler","reflectionSampler"],p=new Array;a.ImageProcessingConfiguration&&(a.ImageProcessingConfiguration.PrepareUniforms(d,r),a.ImageProcessingConfiguration.PrepareSamplers(c,r)),(0,a.addClipPlaneUniforms)(d),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(n.getEngine().createEffect("water",{attributes:l,uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},o),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,i.effect._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var r=this.getScene(),n=t.materialDefines;if(n){var o=t.effect;if(o&&this._mesh){this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(r,o)&&(this.bumpTexture&&a.MaterialFlags.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),(0,a.bindClipPlane)(o,this,r),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),r.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(r,i,this._activeEffect,n,this.maxSimultaneousLights),r.fogEnabled&&i.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",r.getViewMatrix()),a.MaterialHelper.BindFogParameters(r,i,this._activeEffect),a.MaterialHelper.BindLogDepth(n,this._activeEffect,r),a.MaterialFlags.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var s=this._reflectionTransform.multiply(r.getProjectionMatrix()),f=r.getEngine().getDeltaTime();f!==this._lastDeltaTime&&(this._lastDeltaTime=f,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("reflectionViewProjection",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._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},i.prototype._createRenderTargets=function(e,i){var t,r=this;this._refractionRTT=new a.RenderTargetTexture(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new a.RenderTargetTexture(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var n,o=null,s=a.Matrix.Zero();this._refractionRTT.onBeforeRender=function(){if(r._mesh&&(t=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){o=e.clipPlane;var i=r._mesh?r._mesh.absolutePosition.y:0;e.clipPlane=a.Plane.FromPositionAndNormal(new a.Vector3(0,i+.05,0),new a.Vector3(0,1,0))}},this._refractionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=t),r.disableClipPlane||(e.clipPlane=o)},this._reflectionRTT.onBeforeRender=function(){if(r._mesh&&(t=r._mesh.isVisible,r._mesh.isVisible=!1),!r.disableClipPlane){o=e.clipPlane;var i=r._mesh?r._mesh.absolutePosition.y:0;e.clipPlane=a.Plane.FromPositionAndNormal(new a.Vector3(0,i-.05,0),new a.Vector3(0,-1,0)),a.Matrix.ReflectionToRef(e.clipPlane,s)}n=e.getViewMatrix(),s.multiplyToRef(n,r._reflectionTransform),e.setTransformMatrix(r._reflectionTransform,e.getProjectionMatrix()),e._mirroredCameraPosition=a.Vector3.TransformCoordinates(e.activeCamera.position,s)},this._reflectionRTT.onAfterRender=function(){r._mesh&&(r._mesh.isVisible=t),e.clipPlane=o,e.setTransformMatrix(n,e.getProjectionMatrix()),e._mirroredCameraPosition=null}},i.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},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._bumpTexture&&i.push(this._bumpTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._bumpTexture===i},i.prototype.dispose=function(i){this.bumpTexture&&this.bumpTexture.dispose();var t=this.getScene().customRenderTargets.indexOf(this._refractionRTT);-1!=t&&this.getScene().customRenderTargets.splice(t,1),t=-1,-1!=(t=this.getScene().customRenderTargets.indexOf(this._reflectionRTT))&&this.getScene().customRenderTargets.splice(t,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);if(i.customType="BABYLON.WaterMaterial",i.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var t=0;t<this._refractionRTT.renderList.length;t++)i.renderList.push(this._refractionRTT.renderList[t].id);return i},i.prototype.getClassName=function(){return"WaterMaterial"},i.Parse=function(e,t,r){var n=a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,r);return n._waitingRenderList=e.renderList,n},i.CreateDefaultMesh=function(e,i){return(0,a.CreateGround)(e,{width:512,height:512,subdivisions:32,updatable:!1},i)},s([(0,a.serializeAsTexture)("bumpTexture")],i.prototype,"_bumpTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serialize)()],i.prototype,"windForce",void 0),s([(0,a.serializeAsVector2)()],i.prototype,"windDirection",void 0),s([(0,a.serialize)()],i.prototype,"waveHeight",void 0),s([(0,a.serialize)()],i.prototype,"bumpHeight",void 0),s([(0,a.serialize)("bumpSuperimpose")],i.prototype,"_bumpSuperimpose",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"bumpSuperimpose",void 0),s([(0,a.serialize)("fresnelSeparate")],i.prototype,"_fresnelSeparate",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"fresnelSeparate",void 0),s([(0,a.serialize)("bumpAffectsReflection")],i.prototype,"_bumpAffectsReflection",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"bumpAffectsReflection",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"waterColor",void 0),s([(0,a.serialize)()],i.prototype,"colorBlendFactor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"waterColor2",void 0),s([(0,a.serialize)()],i.prototype,"colorBlendFactor2",void 0),s([(0,a.serialize)()],i.prototype,"waveLength",void 0),s([(0,a.serialize)()],i.prototype,"waveSpeed",void 0),s([(0,a.serialize)()],i.prototype,"waveCount",void 0),s([(0,a.serialize)()],i.prototype,"disableClipPlane",void 0),s([(0,a.serialize)("useWorldCoordinatesForWaveDeformation")],i.prototype,"_useWorldCoordinatesForWaveDeformation",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"useWorldCoordinatesForWaveDeformation",void 0),s([(0,a.serialize)()],i.prototype,"useLogarithmicDepth",null),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.WaterMaterial",z);var H=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==H)for(var G in H.BABYLON=H.BABYLON||{},e)H.BABYLON[G]=e[G];const W=i})(),n.default})()));
|
|
//# sourceMappingURL=babylonjs.materials.min.js.map
|