babylonjs-materials
Version:
Babylon.js Materials Library =====================
1 lines • 202 kB
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={597:i=>{i.exports=e}},t={};function n(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return i[e](o,o.exports,n),o.exports}n.d=(e,i)=>{for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};n.d(r,{default:()=>xe});var o={};n.r(o),n.d(o,{CellMaterial:()=>p,CustomMaterial:()=>g,CustomShaderStructure:()=>m,FireMaterial:()=>P,FurMaterial:()=>I,GradientMaterial:()=>D,GridMaterial:()=>U,LavaMaterial:()=>z,MixMaterial:()=>X,NormalMaterial:()=>Y,PBRCustomMaterial:()=>_,ShaderAlbedoParts:()=>T,ShaderAlebdoParts:()=>S,ShaderSpecialParts:()=>v,ShadowOnlyMaterial:()=>J,SimpleMaterial:()=>te,SkyMaterial:()=>se,TerrainMaterial:()=>ue,TriPlanarMaterial:()=>pe,WaterMaterial:()=>Te});var s={};n.r(s),n.d(s,{CellMaterial:()=>p,CustomMaterial:()=>g,CustomShaderStructure:()=>m,FireMaterial:()=>P,FurMaterial:()=>I,GradientMaterial:()=>D,GridMaterial:()=>U,LavaMaterial:()=>z,MixMaterial:()=>X,NormalMaterial:()=>Y,PBRCustomMaterial:()=>_,ShaderAlbedoParts:()=>T,ShaderAlebdoParts:()=>S,ShaderSpecialParts:()=>v,ShadowOnlyMaterial:()=>J,SimpleMaterial:()=>te,SkyMaterial:()=>se,TerrainMaterial:()=>ue,TriPlanarMaterial:()=>pe,WaterMaterial:()=>Te});var a=function(e,i){return a=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])},a(e,i)};function f(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function t(){this.constructor=e}a(e,i),e.prototype=null===i?Object.create(i):(t.prototype=i.prototype,new t)}function l(e,i,t,n){var r,o=arguments.length,s=o<3?i:null===n?n=Object.getOwnPropertyDescriptor(i,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(i,t,s):r(i,t))||s);return o>3&&s&&Object.defineProperty(i,t,s),s}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u=n(597),d="cellPixelShader";u.ShaderStore.ShadersStore[d]||(u.ShaderStore.ShadersStore[d]="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#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\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.;float aggShadow=0.;float numLights=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<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}");var c="cellVertexShader";u.ShaderStore.ShadersStore[c]||(u.ShaderStore.ShadersStore[c]="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<logDepthDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#ifdef VERTEXCOLOR\nvec4 colorUpdated=color;\n#endif\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#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n");var h=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.LOGARITHMICDEPTH=!1,i.AREALIGHTSUPPORTED=!0,i.AREALIGHTNOROUGHTNESS=!0,i.rebuild(),i}return f(i,e),i}(u.MaterialDefines),p=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new u.Color3(1,1,1),n._computeHighLevel=!1,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return f(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){var n=i._drawWrapper;if(this.isFrozen&&n.effect&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new h);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&u.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(r.CELLBASIC=!this.computeHighLevel,(0,u.PrepareDefinesForMisc)(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),r),r._needNormals=(0,u.PrepareDefinesForLights)(o,e,r,!1,this._maxSimultaneousLights,this._disableLighting),(0,u.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,u.PrepareDefinesForAttributes)(e,r,!0,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var a=new u.EffectFallbacks;r.FOG&&a.addFallback(1,"FOG"),(0,u.HandleFallbacksForShadows)(r,a,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&a.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var f=[u.VertexBuffer.PositionKind];r.NORMAL&&f.push(u.VertexBuffer.NormalKind),r.UV1&&f.push(u.VertexBuffer.UVKind),r.UV2&&f.push(u.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(u.VertexBuffer.ColorKind),(0,u.PrepareAttributesForBones)(f,e,r,a),(0,u.PrepareAttributesForInstances)(f,r);var l=r.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant"],c=["diffuseSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"],p=[];(0,u.AddClipPlaneUniforms)(d),(0,u.PrepareUniformsAndSamplersList)({uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(o.getEngine().createEffect("cell",{attributes:f,uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:l,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},s),r,this._materialContext)}if(r.AREALIGHTUSED)for(var m=0;m<e.lightSources.length;m++)if(!e.lightSources[m]._isReady())return!1;return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,u.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&u.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,u.BindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,u.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&(0,u.BindLights)(n,i,this._activeEffect,r,this._maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==u.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),(0,u.BindFogParameters)(n,i,this._activeEffect),this._afterBind(i,this._activeEffect,t))}},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 u.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,n){return u.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},l([(0,u.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),l([(0,u.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),l([(0,u.serialize)("computeHighLevel")],i.prototype,"_computeHighLevel",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"computeHighLevel",void 0),l([(0,u.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),l([(0,u.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(u.PushMaterial);(0,u.RegisterClass)("BABYLON.CellMaterial",p);var m=function(){},v=function(){},g=function(e){function i(t,n){var r=e.call(this,t,n,!0)||this;return r.CustomParts=new v,r.customShaderNameResolve=r.Builder,r.FragmentShader=u.Effect.ShadersStore.defaultPixelShader,r.VertexShader=u.Effect.ShadersStore.defaultVertexShader,i.ShaderIndexer++,r._createdShaderName="custom_"+i.ShaderIndexer,r}return f(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?this._newUniformInstances[t]instanceof u.Color3?i.setColor3(n[1],this._newUniformInstances[t]):i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?(this._newUniformInstances[t]instanceof u.Color4?i.setDirectColor4(n[1],this._newUniformInstances[t]):i.setVector4(n[1],this._newUniformInstances[t]),i.setVector4(n[1],this._newUniformInstances[t])):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[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,i,t,n,r,o){o&&this._customAttributes&&this._customAttributes.length>0&&o.push.apply(o,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",n);var s=this._createdShaderName;return u.Effect.ShadersStore[s+"VertexShader"]&&u.Effect.ShadersStore[s+"PixelShader"]||(u.Effect.ShadersStore[s+"VertexShader"]=this._injectCustomCode(this.VertexShader,"vertex"),u.Effect.ShadersStore[s+"PixelShader"]=this._injectCustomCode(this.FragmentShader,"fragment")),s},i.prototype._injectCustomCode=function(e,i){var t=this._getCustomCode(i);for(var n in t){var r=t[n];if(r&&r.length>0){var o="#define "+n;e=e.replace(o,"\n"+r+"\n"+o)}}return e},i.prototype._getCustomCode=function(e){var i,t;return"vertex"===e?{CUSTOM_VERTEX_BEGIN:this.CustomParts.Vertex_Begin,CUSTOM_VERTEX_DEFINITIONS:((null===(i=this._customUniform)||void 0===i?void 0:i.join("\n"))||"")+(this.CustomParts.Vertex_Definitions||""),CUSTOM_VERTEX_MAIN_BEGIN:this.CustomParts.Vertex_MainBegin,CUSTOM_VERTEX_UPDATE_POSITION:this.CustomParts.Vertex_Before_PositionUpdated,CUSTOM_VERTEX_UPDATE_NORMAL:this.CustomParts.Vertex_Before_NormalUpdated,CUSTOM_VERTEX_MAIN_END:this.CustomParts.Vertex_MainEnd,CUSTOM_VERTEX_UPDATE_WORLDPOS:this.CustomParts.Vertex_After_WorldPosComputed}:{CUSTOM_FRAGMENT_BEGIN:this.CustomParts.Fragment_Begin,CUSTOM_FRAGMENT_DEFINITIONS:((null===(t=this._customUniform)||void 0===t?void 0:t.join("\n"))||"")+(this.CustomParts.Fragment_Definitions||""),CUSTOM_FRAGMENT_MAIN_BEGIN:this.CustomParts.Fragment_MainBegin,CUSTOM_FRAGMENT_UPDATE_DIFFUSE:this.CustomParts.Fragment_Custom_Diffuse,CUSTOM_FRAGMENT_UPDATE_ALPHA:this.CustomParts.Fragment_Custom_Alpha,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.CustomParts.Fragment_Before_Lights,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:this.CustomParts.Fragment_Before_FragColor,CUSTOM_FRAGMENT_MAIN_END:this.CustomParts.Fragment_MainEnd,CUSTOM_FRAGMENT_BEFORE_FOG:this.CustomParts.Fragment_Before_Fog}},i.prototype._afterBind=function(i,t,n){if(void 0===t&&(t=null),t){this.AttachAfterBind(i,t);try{e.prototype._afterBind.call(this,i,t,n)}catch(e){}}},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=[],this._newUniforms=[],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}(u.StandardMaterial);(0,u.RegisterClass)("BABYLON.CustomMaterial",g);var T=function(){},S=T,_=function(e){function i(t,n){var r=e.call(this,t,n,!0)||this;return r.CustomParts=new T,r.customShaderNameResolve=r.Builder,r.FragmentShader=u.Effect.ShadersStore.pbrPixelShader,r.VertexShader=u.Effect.ShadersStore.pbrVertexShader,r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,u.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,u.Effect.IncludesShadersStore.pbrBlockReflectivity),r.FragmentShader=r.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,u.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),i.ShaderIndexer++,r._createdShaderName="custompbr_"+i.ShaderIndexer,r}return f(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?this._newUniformInstances[t]instanceof u.Color3?i.setColor3(n[1],this._newUniformInstances[t]):i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?(this._newUniformInstances[t]instanceof u.Color4?i.setDirectColor4(n[1],this._newUniformInstances[t]):i.setVector4(n[1],this._newUniformInstances[t]),i.setVector4(n[1],this._newUniformInstances[t])):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[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,i,t,n,r,o,s){if(s){var a=s.processFinalCode;s.processFinalCode=function(e,i){if("vertex"===e)return a?a(e,i):i;var t=new u.ShaderCodeInliner(i);return t.inlineToken="#define pbr_inline",t.processCode(),a?a(e,t.code):t.code}}o&&this._customAttributes&&this._customAttributes.length>0&&o.push.apply(o,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",n);var f=this._createdShaderName;return u.Effect.ShadersStore[f+"VertexShader"]&&u.Effect.ShadersStore[f+"PixelShader"]||(u.Effect.ShadersStore[f+"VertexShader"]=this._injectCustomCode(this.VertexShader,"vertex"),u.Effect.ShadersStore[f+"PixelShader"]=this._injectCustomCode(this.FragmentShader,"fragment")),f},i.prototype._injectCustomCode=function(e,i){var t=this._getCustomCode(i);for(var n in t){var r=t[n];if(r&&r.length>0){var o="#define "+n;e=e.replace(o,"\n"+r+"\n"+o)}}return e},i.prototype._getCustomCode=function(e){var i,t;return"vertex"===e?{CUSTOM_VERTEX_BEGIN:this.CustomParts.Vertex_Begin,CUSTOM_VERTEX_DEFINITIONS:((null===(i=this._customUniform)||void 0===i?void 0:i.join("\n"))||"")+(this.CustomParts.Vertex_Definitions||""),CUSTOM_VERTEX_MAIN_BEGIN:this.CustomParts.Vertex_MainBegin,CUSTOM_VERTEX_UPDATE_POSITION:this.CustomParts.Vertex_Before_PositionUpdated,CUSTOM_VERTEX_UPDATE_NORMAL:this.CustomParts.Vertex_Before_NormalUpdated,CUSTOM_VERTEX_MAIN_END:this.CustomParts.Vertex_MainEnd,CUSTOM_VERTEX_UPDATE_WORLDPOS:this.CustomParts.Vertex_After_WorldPosComputed}:{CUSTOM_FRAGMENT_BEGIN:this.CustomParts.Fragment_Begin,CUSTOM_FRAGMENT_MAIN_BEGIN:this.CustomParts.Fragment_MainBegin,CUSTOM_FRAGMENT_DEFINITIONS:((null===(t=this._customUniform)||void 0===t?void 0:t.join("\n"))||"")+(this.CustomParts.Fragment_Definitions||""),CUSTOM_FRAGMENT_UPDATE_ALBEDO:this.CustomParts.Fragment_Custom_Albedo,CUSTOM_FRAGMENT_UPDATE_ALPHA:this.CustomParts.Fragment_Custom_Alpha,CUSTOM_FRAGMENT_BEFORE_LIGHTS:this.CustomParts.Fragment_Before_Lights,CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS:this.CustomParts.Fragment_Custom_MetallicRoughness,CUSTOM_FRAGMENT_UPDATE_MICROSURFACE:this.CustomParts.Fragment_Custom_MicroSurface,CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION:this.CustomParts.Fragment_Before_FinalColorComposition,CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR:this.CustomParts.Fragment_Before_FragColor,CUSTOM_FRAGMENT_MAIN_END:this.CustomParts.Fragment_MainEnd,CUSTOM_FRAGMENT_BEFORE_FOG:this.CustomParts.Fragment_Before_Fog}},i.prototype._afterBind=function(i,t,n){if(void 0===t&&(t=null),t){this.AttachAfterBind(i,t);try{e.prototype._afterBind.call(this,i,t,n)}catch(e){}}},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=[],this._newUniforms=[],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}(u.PBRMaterial);(0,u.RegisterClass)("BABYLON.PBRCustomMaterial",_);var x="firePixelShader";u.ShaderStore.ShadersStore[x]||(u.ShaderStore.ShadersStore[x]="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#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\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<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}");var E="fireVertexShader";u.ShaderStore.ShadersStore[E]||(u.ShaderStore.ShadersStore[E]="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<logDepthDeclaration>\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#ifdef VERTEXCOLOR\nvec4 colorUpdated=color;\n#endif\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<logDepthVertex>\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 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.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.LOGARITHMICDEPTH=!1,i.rebuild(),i}return f(i,e),i}(u.MaterialDefines),P=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new u.Color3(1,1,1),n.speed=1,n._scaledDiffuse=new u.Color3,n._lastTime=0,n}return f(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){var n=i._drawWrapper;if(this.isFrozen&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new C);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&(r._needUVs=!1,this._diffuseTexture&&u.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||o.forcePointsCloud,r.FOG=o.fogEnabled&&e.applyFog&&o.fogMode!==u.Scene.FOGMODE_NONE&&this.fogEnabled,r.LOGARITHMICDEPTH=this._useLogarithmicDepth),(0,u.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,u.PrepareDefinesForAttributes)(e,r,!1,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var a=new u.EffectFallbacks;r.FOG&&a.addFallback(1,"FOG"),r.NUM_BONE_INFLUENCERS>0&&a.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var f=[u.VertexBuffer.PositionKind];r.UV1&&f.push(u.VertexBuffer.UVKind),r.VERTEXCOLOR&&f.push(u.VertexBuffer.ColorKind),(0,u.PrepareAttributesForBones)(f,e,r,a),(0,u.PrepareAttributesForInstances)(f,r);var l=["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant","time","speed"];(0,u.AddClipPlaneUniforms)(l);var d=r.toString();i.setEffect(o.getEngine().createEffect("fire",{attributes:f,uniformsNames:l,uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:d,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},s),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,u.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&u.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,u.BindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,u.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),n.fogEnabled&&i.applyFog&&n.fogMode!==u.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),(0,u.BindFogParameters)(n,i,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(i,this._activeEffect,t))}},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 u.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,n){var r=new i(e.name,t);return r.diffuseColor=u.Color3.FromArray(e.diffuseColor),r.speed=e.speed,r.alpha=e.alpha,r.id=e.id,u.Tags.AddTagsTo(r,e.tags),r.backFaceCulling=e.backFaceCulling,r.wireframe=e.wireframe,e._diffuseTexture&&(r._diffuseTexture=u.Texture.Parse(e._diffuseTexture,t,n)),e._distortionTexture&&(r._distortionTexture=u.Texture.Parse(e._distortionTexture,t,n)),e._opacityTexture&&(r._opacityTexture=u.Texture.Parse(e._opacityTexture,t,n)),r},l([(0,u.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),l([(0,u.serializeAsTexture)("distortionTexture")],i.prototype,"_distortionTexture",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"distortionTexture",void 0),l([(0,u.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),l([(0,u.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),l([(0,u.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),l([(0,u.serialize)()],i.prototype,"speed",void 0),i}(u.PushMaterial);(0,u.RegisterClass)("BABYLON.FireMaterial",P);var y="furPixelShader";u.ShaderStore.ShadersStore[y]||(u.ShaderStore.ShadersStore[y]="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#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<logDepthDeclaration>\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.;float aggShadow=0.;float numLights=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<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}");var A="furVertexShader";u.ShaderStore.ShadersStore[A]||(u.ShaderStore.ShadersStore[A]="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<logDepthDeclaration>\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#ifdef VERTEXCOLOR\nvec4 colorUpdated=color;\n#endif\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<logDepthVertex>\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 L=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.LOGARITHMICDEPTH=!1,i.AREALIGHTSUPPORTED=!0,i.AREALIGHTNOROUGHTNESS=!0,i.rebuild(),i}return f(i,e),i}(u.MaterialDefines),I=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new u.Color3(1,1,1),n.furLength=1,n.furAngle=0,n.furColor=new u.Color3(.44,.21,.02),n.furOffset=0,n.furSpacing=12,n.furGravity=new u.Vector3(0,0,0),n.furSpeed=100,n.furDensity=20,n.furOcclusion=0,n._disableLighting=!1,n._maxSimultaneousLights=4,n.highLevelFur=!0,n._furTime=0,n}return f(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){var n=i._drawWrapper;if(this.isFrozen&&n.effect&&n._wasPreviouslyReady&&n._wasPreviouslyUsingInstances===t)return!0;i.materialDefines||(i.materialDefines=new L);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(r._areTexturesDirty&&o.texturesEnabled){if(this.diffuseTexture&&u.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;r._needUVs=!0,r.DIFFUSE=!0}if(this.heightTexture&&s.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;r._needUVs=!0,r.HEIGHTMAP=!0}}if(this.highLevelFur!==r.HIGHLEVEL&&(r.HIGHLEVEL=!0,r.markAsUnprocessed()),(0,u.PrepareDefinesForMisc)(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),r),r._needNormals=(0,u.PrepareDefinesForLights)(o,e,r,!1,this._maxSimultaneousLights,this._disableLighting),(0,u.PrepareDefinesForFrameBoundValues)(o,s,this,r,!!t),(0,u.PrepareDefinesForAttributes)(e,r,!0,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var a=new u.EffectFallbacks;r.FOG&&a.addFallback(1,"FOG"),(0,u.HandleFallbacksForShadows)(r,a,this.maxSimultaneousLights),r.NUM_BONE_INFLUENCERS>0&&a.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var f=[u.VertexBuffer.PositionKind];r.NORMAL&&f.push(u.VertexBuffer.NormalKind),r.UV1&&f.push(u.VertexBuffer.UVKind),r.UV2&&f.push(u.VertexBuffer.UV2Kind),r.VERTEXCOLOR&&f.push(u.VertexBuffer.ColorKind),(0,u.PrepareAttributesForBones)(f,e,r,a),(0,u.PrepareAttributesForInstances)(f,r);var l=r.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","diffuseMatrix","logarithmicDepthConstant","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity","furOcclusion"];(0,u.AddClipPlaneUniforms)(d);var c=["diffuseSampler","heightTexture","furTexture","areaLightsLTC1Sampler","areaLightsLTC2Sampler"],h=[];(0,u.PrepareUniformsAndSamplersList)({uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:r,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(o.getEngine().createEffect("fur",{attributes:f,uniformsNames:d,uniformBuffersNames:h,samplers:c,defines:l,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},s),r,this._materialContext)}if(r.AREALIGHTUSED)for(var p=0;p<e.lightSources.length;p++)if(!e.lightSources[p]._isReady())return!1;return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),n._wasPreviouslyReady=!0,n._wasPreviouslyUsingInstances=!!t,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),(0,u.BindBonesParameters)(i,this._activeEffect),this._mustRebind(n,o,t)&&(this._diffuseTexture&&u.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,u.BindClipPlane)(this._activeEffect,this,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._useLogarithmicDepth&&(0,u.BindLogDepth)(r,o,n),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.