babylonjs-procedural-textures 6.11.0 → 6.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/babylon.brickProceduralTexture.js +109 -102
  2. package/babylon.brickProceduralTexture.js.map +1 -1
  3. package/babylon.brickProceduralTexture.min.js +1 -1
  4. package/babylon.brickProceduralTexture.min.js.map +1 -1
  5. package/babylon.cloudProceduralTexture.js +109 -100
  6. package/babylon.cloudProceduralTexture.js.map +1 -1
  7. package/babylon.cloudProceduralTexture.min.js +1 -1
  8. package/babylon.cloudProceduralTexture.min.js.map +1 -1
  9. package/babylon.fireProceduralTexture.js +156 -120
  10. package/babylon.fireProceduralTexture.js.map +1 -1
  11. package/babylon.fireProceduralTexture.min.js +1 -1
  12. package/babylon.fireProceduralTexture.min.js.map +1 -1
  13. package/babylon.grassProceduralTexture.js +80 -77
  14. package/babylon.grassProceduralTexture.js.map +1 -1
  15. package/babylon.grassProceduralTexture.min.js +1 -1
  16. package/babylon.grassProceduralTexture.min.js.map +1 -1
  17. package/babylon.marbleProceduralTexture.js +109 -89
  18. package/babylon.marbleProceduralTexture.js.map +1 -1
  19. package/babylon.marbleProceduralTexture.min.js +1 -1
  20. package/babylon.marbleProceduralTexture.min.js.map +1 -1
  21. package/babylon.normalMapProceduralTexture.js +72 -68
  22. package/babylon.normalMapProceduralTexture.js.map +1 -1
  23. package/babylon.normalMapProceduralTexture.min.js +1 -1
  24. package/babylon.normalMapProceduralTexture.min.js.map +1 -1
  25. package/babylon.perlinNoiseProceduralTexture.js +70 -104
  26. package/babylon.perlinNoiseProceduralTexture.js.map +1 -1
  27. package/babylon.perlinNoiseProceduralTexture.min.js +1 -1
  28. package/babylon.perlinNoiseProceduralTexture.min.js.map +1 -1
  29. package/babylon.roadProceduralTexture.js +64 -66
  30. package/babylon.roadProceduralTexture.js.map +1 -1
  31. package/babylon.roadProceduralTexture.min.js +1 -1
  32. package/babylon.roadProceduralTexture.min.js.map +1 -1
  33. package/babylon.starfieldProceduralTexture.js +219 -186
  34. package/babylon.starfieldProceduralTexture.js.map +1 -1
  35. package/babylon.starfieldProceduralTexture.min.js +1 -1
  36. package/babylon.starfieldProceduralTexture.min.js.map +1 -1
  37. package/babylon.woodProceduralTexture.js +79 -76
  38. package/babylon.woodProceduralTexture.js.map +1 -1
  39. package/babylon.woodProceduralTexture.min.js +1 -1
  40. package/babylon.woodProceduralTexture.min.js.map +1 -1
  41. package/babylonjs.proceduralTextures.js +1001 -922
  42. package/babylonjs.proceduralTextures.js.map +1 -1
  43. package/babylonjs.proceduralTextures.min.js +1 -1
  44. package/babylonjs.proceduralTextures.min.js.map +1 -1
  45. package/package.json +3 -3
  46. package/tsconfig.build.json +7 -4
  47. package/webpack.config.js +2 -2
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],r):"object"==typeof exports?exports["babylonjs-procedural-textures"]=r(require("babylonjs")):e.PROCEDURALTEXTURES=r(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var r={520:r=>{r.exports=e}},t={};function o(e){var i=t[e];if(void 0!==i)return i.exports;var a=t[e]={exports:{}};return r[e](a,a.exports,o),a.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.d(i,{default:()=>C});var e={};o.r(e),o.d(e,{BrickProceduralTexture:()=>s,CloudProceduralTexture:()=>n,FireProceduralTexture:()=>l,GrassProceduralTexture:()=>u,MarbleProceduralTexture:()=>d,NormalMapProceduralTexture:()=>c,PerlinNoiseProceduralTexture:()=>h,RoadProceduralTexture:()=>f,StarfieldProceduralTexture:()=>p,WoodProceduralTexture:()=>m});var r={};function t(e,r,t,o){var i,a=arguments.length,s=a<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,r,t,o);else for(var n=e.length-1;n>=0;n--)(i=e[n])&&(s=(a<3?i(s):a>3?i(r,t,s):i(r,t))||s);return a>3&&s&&Object.defineProperty(r,t,s),s}o.r(r),o.d(r,{BrickProceduralTexture:()=>s,CloudProceduralTexture:()=>n,FireProceduralTexture:()=>l,GrassProceduralTexture:()=>u,MarbleProceduralTexture:()=>d,NormalMapProceduralTexture:()=>c,PerlinNoiseProceduralTexture:()=>h,RoadProceduralTexture:()=>f,StarfieldProceduralTexture:()=>p,WoodProceduralTexture:()=>m}),Object.create,Object.create;var a=o(520);a.ShaderStore.ShadersStore.brickProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfBricksHeight;uniform float numberOfBricksWidth;uniform vec3 brickColor;uniform vec3 jointColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nfloat roundF(float number){return sign(number)*floor(abs(number)+0.5);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}\nfloat nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}\nelse {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);}\ngl_FragColor=vec4(color,1.0);}";class s extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"brickProceduralTexture",t,o,i),this._numberOfBricksHeight=15,this._numberOfBricksWidth=5,this._jointColor=new a.Color3(.72,.72,.72),this._brickColor=new a.Color3(.77,.47,.4),this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("numberOfBricksHeight",this._numberOfBricksHeight),this.setFloat("numberOfBricksWidth",this._numberOfBricksWidth),this.setColor3("brickColor",this._brickColor),this.setColor3("jointColor",this._jointColor)}get numberOfBricksHeight(){return this._numberOfBricksHeight}set numberOfBricksHeight(e){this._numberOfBricksHeight=e,this.updateShaderUniforms()}get numberOfBricksWidth(){return this._numberOfBricksWidth}set numberOfBricksWidth(e){this._numberOfBricksWidth=e,this.updateShaderUniforms()}get jointColor(){return this._jointColor}set jointColor(e){this._jointColor=e,this.updateShaderUniforms()}get brickColor(){return this._brickColor}set brickColor(e){this._brickColor=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.BrickProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new s(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serialize)()],s.prototype,"numberOfBricksHeight",null),t([(0,a.serialize)()],s.prototype,"numberOfBricksWidth",null),t([(0,a.serializeAsColor3)()],s.prototype,"jointColor",null),t([(0,a.serializeAsColor3)()],s.prototype,"brickColor",null),(0,a.RegisterClass)("BABYLON.BrickProceduralTexture",s);a.ShaderStore.ShadersStore.cloudProceduralTexturePixelShader="precision highp float;varying vec2 vUV;uniform vec4 skyColor;uniform vec4 cloudColor;uniform float amplitude;uniform int numOctaves;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,ampl=amplitude;\n#ifdef WEBGL2\nfor (int i=0; i<numOctaves; i++) {\n#else\nfor (int i=0; i<4; i++) {\n#endif\ntotal+=noise(n)*ampl;n+=n;ampl*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}\n";class n extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"cloudProceduralTexture",t,o,i),this._skyColor=new a.Color4(.15,.68,1,1),this._cloudColor=new a.Color4(1,1,1,1),this._amplitude=1,this._numOctaves=4,this.updateShaderUniforms()}updateShaderUniforms(){this.setColor4("skyColor",this._skyColor),this.setColor4("cloudColor",this._cloudColor),this.setFloat("amplitude",this._amplitude),this.setInt("numOctaves",this._numOctaves)}get skyColor(){return this._skyColor}set skyColor(e){this._skyColor=e,this.updateShaderUniforms()}get cloudColor(){return this._cloudColor}set cloudColor(e){this._cloudColor=e,this.updateShaderUniforms()}get amplitude(){return this._amplitude}set amplitude(e){this._amplitude=e,this.updateShaderUniforms()}get numOctaves(){return this._numOctaves}set numOctaves(e){this._numOctaves=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.CloudProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new n(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serializeAsColor4)()],n.prototype,"skyColor",null),t([(0,a.serializeAsColor4)()],n.prototype,"cloudColor",null),t([(0,a.serialize)()],n.prototype,"amplitude",null),t([(0,a.serialize)()],n.prototype,"numOctaves",null),(0,a.RegisterClass)("BABYLON.CloudProceduralTexture",n);a.ShaderStore.ShadersStore.fireProceduralTexturePixelShader="precision highp float;uniform float time;uniform vec3 c1;uniform vec3 c2;uniform vec3 c3;uniform vec3 c4;uniform vec3 c5;uniform vec3 c6;uniform vec2 speed;uniform float shift;uniform float alphaThreshold;varying vec2 vUV;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}";class l extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"fireProceduralTexture",t,o,i),this._time=0,this._speed=new a.Vector2(.5,.3),this._autoGenerateTime=!0,this._alphaThreshold=.5,this._fireColors=l.RedFireColors,this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("time",this._time),this.setVector2("speed",this._speed),this.setColor3("c1",this._fireColors[0]),this.setColor3("c2",this._fireColors[1]),this.setColor3("c3",this._fireColors[2]),this.setColor3("c4",this._fireColors[3]),this.setColor3("c5",this._fireColors[4]),this.setColor3("c6",this._fireColors[5]),this.setFloat("alphaThreshold",this._alphaThreshold)}render(e){const r=this.getScene();this._autoGenerateTime&&r&&(this._time+=.03*r.getAnimationRatio(),this.updateShaderUniforms()),super.render(e)}static get PurpleFireColors(){return[new a.Color3(.5,0,1),new a.Color3(.9,0,1),new a.Color3(.2,0,1),new a.Color3(1,.9,1),new a.Color3(.1,.1,1),new a.Color3(.9,.9,1)]}static get GreenFireColors(){return[new a.Color3(.5,1,0),new a.Color3(.5,1,0),new a.Color3(.3,.4,0),new a.Color3(.5,1,0),new a.Color3(.2,0,0),new a.Color3(.5,1,0)]}static get RedFireColors(){return[new a.Color3(.5,0,.1),new a.Color3(.9,0,0),new a.Color3(.2,0,0),new a.Color3(1,.9,0),new a.Color3(.1,.1,.1),new a.Color3(.9,.9,.9)]}static get BlueFireColors(){return[new a.Color3(.1,0,.5),new a.Color3(0,0,.5),new a.Color3(.1,0,.2),new a.Color3(0,0,1),new a.Color3(.1,.2,.3),new a.Color3(0,.2,.9)]}get autoGenerateTime(){return this._autoGenerateTime}set autoGenerateTime(e){this._autoGenerateTime=e}get fireColors(){return this._fireColors}set fireColors(e){this._fireColors=e,this.updateShaderUniforms()}get time(){return this._time}set time(e){this._time=e,this.updateShaderUniforms()}get speed(){return this._speed}set speed(e){this._speed=e,this.updateShaderUniforms()}get alphaThreshold(){return this._alphaThreshold}set alphaThreshold(e){this._alphaThreshold=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());e.customType="BABYLON.FireProceduralTexture",e.fireColors=[];for(let r=0;r<this._fireColors.length;r++)e.fireColors.push(this._fireColors[r].asArray());return e}static Parse(e,r,t){const o=a.SerializationHelper.Parse((()=>new l(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t),i=[];for(let r=0;r<e.fireColors.length;r++)i.push(a.Color3.FromArray(e.fireColors[r]));return o.fireColors=i,o}}t([(0,a.serialize)()],l.prototype,"autoGenerateTime",null),t([(0,a.serialize)()],l.prototype,"time",null),t([(0,a.serializeAsVector2)()],l.prototype,"speed",null),t([(0,a.serialize)()],l.prototype,"alphaThreshold",null),(0,a.RegisterClass)("BABYLON.FireProceduralTexture",l);a.ShaderStore.ShadersStore.grassProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform vec3 herb1Color;uniform vec3 herb2Color;uniform vec3 herb3Color;uniform vec3 groundColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));color=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));color=mix(color,herb3Color,rand(gl_FragCoord.xy));color=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";class u extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"grassProceduralTexture",t,o,i),this._groundColor=new a.Color3(1,1,1),this._grassColors=[new a.Color3(.29,.38,.02),new a.Color3(.36,.49,.09),new a.Color3(.51,.6,.28)],this.updateShaderUniforms()}updateShaderUniforms(){this.setColor3("herb1Color",this._grassColors[0]),this.setColor3("herb2Color",this._grassColors[1]),this.setColor3("herb3Color",this._grassColors[2]),this.setColor3("groundColor",this._groundColor)}get grassColors(){return this._grassColors}set grassColors(e){this._grassColors=e,this.updateShaderUniforms()}get groundColor(){return this._groundColor}set groundColor(e){this._groundColor=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());e.customType="BABYLON.GrassProceduralTexture",e.grassColors=[];for(let r=0;r<this._grassColors.length;r++)e.grassColors.push(this._grassColors[r].asArray());return e}static Parse(e,r,t){const o=a.SerializationHelper.Parse((()=>new u(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t),i=[];for(let r=0;r<e.grassColors.length;r++)i.push(a.Color3.FromArray(e.grassColors[r]));return o.grassColors=i,o}}t([(0,a.serializeAsColor3)()],u.prototype,"groundColor",null),(0,a.RegisterClass)("BABYLON.GrassProceduralTexture",u);a.ShaderStore.ShadersStore.marbleProceduralTexturePixelShader="precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfTilesHeight;\nuniform float numberOfTilesWidth;\nuniform float amplitude;\nuniform vec3 marbleColor;\nuniform vec3 jointColor;\nconst vec3 tileSize=vec3(1.1,1.0,1.1);\nconst vec3 tilePct=vec3(0.98,1.0,0.98);\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat turbulence(vec2 P)\n{\nfloat val=0.0;\nfloat freq=1.0;\nfor (int i=0; i<4; i++)\n{\nval+=abs(noise(P*freq)/freq);\nfreq*=2.07;\n}\nreturn val;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvec3 marble_color(float x)\n{\nvec3 col;\nx=0.5*(x+1.);\nx=sqrt(x); \nx=sqrt(x);\nx=sqrt(x);\ncol=vec3(.2+.75*x); \ncol.b*=0.95; \nreturn col;\n}\nvoid main()\n{\nfloat brickW=1.0/numberOfTilesWidth;\nfloat brickH=1.0/numberOfTilesHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.01;\nvec3 color=marbleColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0)==0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));\nt+=amplitude*turbulence(brickvUV.xy);\nt=sin(t);\ncolor=marble_color(t);\n}\ngl_FragColor=vec4(color,0.0);\n}";class d extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"marbleProceduralTexture",t,o,i),this._numberOfTilesHeight=3,this._numberOfTilesWidth=3,this._amplitude=9,this._jointColor=new a.Color3(.72,.72,.72),this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("numberOfTilesHeight",this._numberOfTilesHeight),this.setFloat("numberOfTilesWidth",this._numberOfTilesWidth),this.setFloat("amplitude",this._amplitude),this.setColor3("jointColor",this._jointColor)}get numberOfTilesHeight(){return this._numberOfTilesHeight}set numberOfTilesHeight(e){this._numberOfTilesHeight=e,this.updateShaderUniforms()}get amplitude(){return this._amplitude}set amplitude(e){this._amplitude=e,this.updateShaderUniforms()}get numberOfTilesWidth(){return this._numberOfTilesWidth}set numberOfTilesWidth(e){this._numberOfTilesWidth=e,this.updateShaderUniforms()}get jointColor(){return this._jointColor}set jointColor(e){this._jointColor=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.MarbleProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new d(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serialize)()],d.prototype,"numberOfTilesHeight",null),t([(0,a.serialize)()],d.prototype,"amplitude",null),t([(0,a.serialize)()],d.prototype,"numberOfTilesWidth",null),t([(0,a.serialize)()],d.prototype,"jointColor",null),(0,a.RegisterClass)("BABYLON.MarbleProceduralTexture",d);a.ShaderStore.ShadersStore.normalMapProceduralTexturePixelShader="precision highp float;uniform sampler2D baseSampler;uniform float size;varying vec2 vUV;const vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);float lumaAtCoord(vec2 coord)\n{vec3 pixel=texture2D(baseSampler,coord).rgb;float luma=dot(pixel,LUMA_COEFFICIENT);return luma;}\nvoid main()\n{float lumaU0=lumaAtCoord(vUV+vec2(-1.0, 0.0)/size);float lumaU1=lumaAtCoord(vUV+vec2( 1.0, 0.0)/size);float lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);float lumaV1=lumaAtCoord(vUV+vec2( 0.0, 1.0)/size);vec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;gl_FragColor=vec4(slope,1.0,1.0);}\n";class c extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"normalMapProceduralTexture",t,o,i),this.updateShaderUniforms()}updateShaderUniforms(){this.setTexture("baseSampler",this._baseTexture),this.setFloat("size",this.getRenderSize())}render(e){super.render(e)}resize(e,r){super.resize(e,r),this.updateShaderUniforms()}isReady(){return!(!this._baseTexture||!this._baseTexture.isReady())&&super.isReady()}get baseTexture(){return this._baseTexture}set baseTexture(e){this._baseTexture=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.NormalMapProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new c(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serializeAsTexture)()],c.prototype,"baseTexture",null),(0,a.RegisterClass)("BABYLON.NormalMapProceduralTexture",c);a.ShaderStore.ShadersStore.perlinNoiseProceduralTexturePixelShader="precision highp float;uniform float size;uniform float time;uniform float translationSpeed;varying vec2 vUV;float r(float n)\n{return fract(cos(n*89.42)*343.42);}\nvec2 r(vec2 n)\n{return vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); }\nfloat worley(vec2 n,float s)\n{float dis=1.0;for(int x=-1; x<=1; x++)\n{for(int y=-1; y<=1; y++)\n{vec2 p=floor(n/s)+vec2(x,y);float d=length(r(p)+vec2(x,y)-fract(n/s));if (dis>d)\ndis=d;}}\nreturn 1.0-dis;}\nvec3 hash33(vec3 p3)\n{p3=fract(p3*vec3(0.1031,0.11369,0.13787));p3+=dot(p3,p3.yxz+19.19);return -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));}\nfloat perlinNoise(vec3 p)\n{vec3 pi=floor(p);vec3 pf=p-pi;vec3 w=pf*pf*(3.0-2.0*pf);return mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),w.x\n),mix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),w.x\n),w.z\n),mix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),w.x\n),mix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),w.x\n),w.z\n),w.y\n);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 uv=gl_FragCoord.xy+translationSpeed;float dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n* (1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);gl_FragColor=vec4(vec3(dis/4.0),1.0);}\n";class h extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"perlinNoiseProceduralTexture",t,o,i),this.time=0,this.timeScale=1,this.translationSpeed=1,this._currentTranslation=0,this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("size",this.getRenderSize());const e=this.getScene();if(!e)return;const r=e.getEngine().getDeltaTime();this.time+=r,this.setFloat("time",this.time*this.timeScale/1e3),this._currentTranslation+=r*this.translationSpeed/1e3,this.setFloat("translationSpeed",this._currentTranslation)}render(e){this.updateShaderUniforms(),super.render(e)}resize(e,r){super.resize(e,r)}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.PerlinNoiseProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new h(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serialize)()],h.prototype,"time",void 0),t([(0,a.serialize)()],h.prototype,"timeScale",void 0),t([(0,a.serialize)()],h.prototype,"translationSpeed",void 0),(0,a.RegisterClass)("BABYLON.PerlinNoiseProceduralTexture",h);a.ShaderStore.ShadersStore.roadProceduralTexturePixelShader="precision highp float;varying vec2 vUV; \nuniform vec3 roadColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";class f extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"roadProceduralTexture",t,o,i),this._roadColor=new a.Color3(.53,.53,.53),this.updateShaderUniforms()}updateShaderUniforms(){this.setColor3("roadColor",this._roadColor)}get roadColor(){return this._roadColor}set roadColor(e){this._roadColor=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.RoadProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new f(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serializeAsColor3)()],f.prototype,"roadColor",null),(0,a.RegisterClass)("BABYLON.RoadProceduralTexture",f);a.ShaderStore.ShadersStore.starfieldProceduralTexturePixelShader="precision highp float;\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()\n{vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \nv+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);}";class p extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"starfieldProceduralTexture",t,o,i),this._time=1,this._alpha=.5,this._beta=.8,this._zoom=.8,this._formuparam=.53,this._stepsize=.1,this._tile=.85,this._brightness=.0015,this._darkmatter=.4,this._distfading=.73,this._saturation=.85,this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("time",this._time),this.setFloat("alpha",this._alpha),this.setFloat("beta",this._beta),this.setFloat("zoom",this._zoom),this.setFloat("formuparam",this._formuparam),this.setFloat("stepsize",this._stepsize),this.setFloat("tile",this._tile),this.setFloat("brightness",this._brightness),this.setFloat("darkmatter",this._darkmatter),this.setFloat("distfading",this._distfading),this.setFloat("saturation",this._saturation)}get time(){return this._time}set time(e){this._time=e,this.updateShaderUniforms()}get alpha(){return this._alpha}set alpha(e){this._alpha=e,this.updateShaderUniforms()}get beta(){return this._beta}set beta(e){this._beta=e,this.updateShaderUniforms()}get formuparam(){return this._formuparam}set formuparam(e){this._formuparam=e,this.updateShaderUniforms()}get stepsize(){return this._stepsize}set stepsize(e){this._stepsize=e,this.updateShaderUniforms()}get zoom(){return this._zoom}set zoom(e){this._zoom=e,this.updateShaderUniforms()}get tile(){return this._tile}set tile(e){this._tile=e,this.updateShaderUniforms()}get brightness(){return this._brightness}set brightness(e){this._brightness=e,this.updateShaderUniforms()}get darkmatter(){return this._darkmatter}set darkmatter(e){this._darkmatter=e,this.updateShaderUniforms()}get distfading(){return this._distfading}set distfading(e){this._distfading=e,this.updateShaderUniforms()}get saturation(){return this._saturation}set saturation(e){this._saturation=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.StarfieldProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new p(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serialize)()],p.prototype,"time",null),t([(0,a.serialize)()],p.prototype,"alpha",null),t([(0,a.serialize)()],p.prototype,"beta",null),t([(0,a.serialize)()],p.prototype,"formuparam",null),t([(0,a.serialize)()],p.prototype,"stepsize",null),t([(0,a.serialize)()],p.prototype,"zoom",null),t([(0,a.serialize)()],p.prototype,"tile",null),t([(0,a.serialize)()],p.prototype,"brightness",null),t([(0,a.serialize)()],p.prototype,"darkmatter",null),t([(0,a.serialize)()],p.prototype,"distfading",null),t([(0,a.serialize)()],p.prototype,"saturation",null),(0,a.RegisterClass)("BABYLON.StarfieldProceduralTexture",p);a.ShaderStore.ShadersStore.woodProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";class m extends a.ProceduralTexture{constructor(e,r,t=null,o,i){super(e,r,"woodProceduralTexture",t,o,i),this._ampScale=100,this._woodColor=new a.Color3(.32,.17,.09),this.updateShaderUniforms()}updateShaderUniforms(){this.setFloat("ampScale",this._ampScale),this.setColor3("woodColor",this._woodColor)}get ampScale(){return this._ampScale}set ampScale(e){this._ampScale=e,this.updateShaderUniforms()}get woodColor(){return this._woodColor}set woodColor(e){this._woodColor=e,this.updateShaderUniforms()}serialize(){const e=a.SerializationHelper.Serialize(this,super.serialize());return e.customType="BABYLON.WoodProceduralTexture",e}static Parse(e,r,t){return a.SerializationHelper.Parse((()=>new m(e.name,e._size,r,void 0,e._generateMipMaps)),e,r,t)}}t([(0,a.serialize)()],m.prototype,"ampScale",null),t([(0,a.serializeAsColor3)()],m.prototype,"woodColor",null),(0,a.RegisterClass)("BABYLON.WoodProceduralTexture",m);var v=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==v)for(var x in v.BABYLON=v.BABYLON||{},e)v.BABYLON[x]=e[x];const C=r})(),i.default})()));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-procedural-textures",["babylonjs"],r):"object"==typeof exports?exports["babylonjs-procedural-textures"]=r(require("babylonjs")):e.PROCEDURALTEXTURES=r(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var r={520:r=>{r.exports=e}},t={};function o(e){var i=t[e];if(void 0!==i)return i.exports;var n=t[e]={exports:{}};return r[e](n,n.exports,o),n.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.d(i,{default:()=>x});var e={};o.r(e),o.d(e,{BrickProceduralTexture:()=>s,CloudProceduralTexture:()=>u,FireProceduralTexture:()=>c,GrassProceduralTexture:()=>f,MarbleProceduralTexture:()=>d,NormalMapProceduralTexture:()=>p,PerlinNoiseProceduralTexture:()=>h,RoadProceduralTexture:()=>m,StarfieldProceduralTexture:()=>v,WoodProceduralTexture:()=>b});var r={};o.r(r),o.d(r,{BrickProceduralTexture:()=>s,CloudProceduralTexture:()=>u,FireProceduralTexture:()=>c,GrassProceduralTexture:()=>f,MarbleProceduralTexture:()=>d,NormalMapProceduralTexture:()=>p,PerlinNoiseProceduralTexture:()=>h,RoadProceduralTexture:()=>m,StarfieldProceduralTexture:()=>v,WoodProceduralTexture:()=>b});var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])},t(e,r)};function n(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function o(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(o.prototype=r.prototype,new o)}function a(e,r,t,o){var i,n=arguments.length,a=n<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,r,t,o);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(n<3?i(a):n>3?i(r,t,a):i(r,t))||a);return n>3&&a&&Object.defineProperty(r,t,a),a}Object.create,Object.create;var l=o(520);l.ShaderStore.ShadersStore.brickProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float numberOfBricksHeight;uniform float numberOfBricksWidth;uniform vec3 brickColor;uniform vec3 jointColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nfloat roundF(float number){return sign(number)*floor(abs(number)+0.5);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{float brickW=1.0/numberOfBricksWidth;float brickH=1.0/numberOfBricksHeight;float jointWPercentage=0.01;float jointHPercentage=0.05;vec3 color=brickColor;float yi=vUV.y/brickH;float nyi=roundF(yi);float xi=vUV.x/brickW;if (mod(floor(yi),2.0)==0.0){xi=xi-0.5;}\nfloat nxi=roundF(xi);vec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/ brickW);if (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){color=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){color=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);}\nelse {float brickColorSwitch=mod(floor(yi)+floor(xi),3.0);if (brickColorSwitch==0.0)\ncolor=mix(color,vec3(0.33,0.33,0.33),0.3);else if (brickColorSwitch==2.0)\ncolor=mix(color,vec3(0.11,0.11,0.11),0.3);}\ngl_FragColor=vec4(color,1.0);}";var s=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"brickProceduralTexture",o,i,n)||this;return a._numberOfBricksHeight=15,a._numberOfBricksWidth=5,a._jointColor=new l.Color3(.72,.72,.72),a._brickColor=new l.Color3(.77,.47,.4),a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("numberOfBricksHeight",this._numberOfBricksHeight),this.setFloat("numberOfBricksWidth",this._numberOfBricksWidth),this.setColor3("brickColor",this._brickColor),this.setColor3("jointColor",this._jointColor)},Object.defineProperty(r.prototype,"numberOfBricksHeight",{get:function(){return this._numberOfBricksHeight},set:function(e){this._numberOfBricksHeight=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numberOfBricksWidth",{get:function(){return this._numberOfBricksWidth},set:function(e){this._numberOfBricksWidth=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"jointColor",{get:function(){return this._jointColor},set:function(e){this._jointColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"brickColor",{get:function(){return this._brickColor},set:function(e){this._brickColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.BrickProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serialize)()],r.prototype,"numberOfBricksHeight",null),a([(0,l.serialize)()],r.prototype,"numberOfBricksWidth",null),a([(0,l.serializeAsColor3)()],r.prototype,"jointColor",null),a([(0,l.serializeAsColor3)()],r.prototype,"brickColor",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.BrickProceduralTexture",s);l.ShaderStore.ShadersStore.cloudProceduralTexturePixelShader="precision highp float;varying vec2 vUV;uniform vec4 skyColor;uniform vec4 cloudColor;uniform float amplitude;uniform int numOctaves;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,ampl=amplitude;\n#ifdef WEBGL2\nfor (int i=0; i<numOctaves; i++) {\n#else\nfor (int i=0; i<4; i++) {\n#endif\ntotal+=noise(n)*ampl;n+=n;ampl*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*12.0;vec4 c=mix(skyColor,cloudColor,fbm(p));gl_FragColor=c;}\n";var u=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"cloudProceduralTexture",o,i,n)||this;return a._skyColor=new l.Color4(.15,.68,1,1),a._cloudColor=new l.Color4(1,1,1,1),a._amplitude=1,a._numOctaves=4,a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setColor4("skyColor",this._skyColor),this.setColor4("cloudColor",this._cloudColor),this.setFloat("amplitude",this._amplitude),this.setInt("numOctaves",this._numOctaves)},Object.defineProperty(r.prototype,"skyColor",{get:function(){return this._skyColor},set:function(e){this._skyColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"cloudColor",{get:function(){return this._cloudColor},set:function(e){this._cloudColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"amplitude",{get:function(){return this._amplitude},set:function(e){this._amplitude=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numOctaves",{get:function(){return this._numOctaves},set:function(e){this._numOctaves=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.CloudProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serializeAsColor4)()],r.prototype,"skyColor",null),a([(0,l.serializeAsColor4)()],r.prototype,"cloudColor",null),a([(0,l.serialize)()],r.prototype,"amplitude",null),a([(0,l.serialize)()],r.prototype,"numOctaves",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.CloudProceduralTexture",u);l.ShaderStore.ShadersStore.fireProceduralTexturePixelShader="precision highp float;uniform float time;uniform vec3 c1;uniform vec3 c2;uniform vec3 c3;uniform vec3 c4;uniform vec3 c5;uniform vec3 c6;uniform vec2 speed;uniform float shift;uniform float alphaThreshold;varying vec2 vUV;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\nvoid main() {vec2 p=vUV*8.0;float q=fbm(p-time*0.1);vec2 r=vec2(fbm(p+q+time*speed.x-p.x-p.y),fbm(p+q-time*speed.y));vec3 c=mix(c1,c2,fbm(p+r))+mix(c3,c4,r.x)-mix(c5,c6,r.y);vec3 color=c*cos(shift*vUV.y);float luminance=dot(color.rgb,vec3(0.3,0.59,0.11));gl_FragColor=vec4(color,luminance*alphaThreshold+(1.0-alphaThreshold));}";var c=function(e){function r(t,o,i,n,a){void 0===i&&(i=null);var s=e.call(this,t,o,"fireProceduralTexture",i,n,a)||this;return s._time=0,s._speed=new l.Vector2(.5,.3),s._autoGenerateTime=!0,s._alphaThreshold=.5,s._fireColors=r.RedFireColors,s.updateShaderUniforms(),s}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("time",this._time),this.setVector2("speed",this._speed),this.setColor3("c1",this._fireColors[0]),this.setColor3("c2",this._fireColors[1]),this.setColor3("c3",this._fireColors[2]),this.setColor3("c4",this._fireColors[3]),this.setColor3("c5",this._fireColors[4]),this.setColor3("c6",this._fireColors[5]),this.setFloat("alphaThreshold",this._alphaThreshold)},r.prototype.render=function(r){var t=this.getScene();this._autoGenerateTime&&t&&(this._time+=.03*t.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,r)},Object.defineProperty(r,"PurpleFireColors",{get:function(){return[new l.Color3(.5,0,1),new l.Color3(.9,0,1),new l.Color3(.2,0,1),new l.Color3(1,.9,1),new l.Color3(.1,.1,1),new l.Color3(.9,.9,1)]},enumerable:!1,configurable:!0}),Object.defineProperty(r,"GreenFireColors",{get:function(){return[new l.Color3(.5,1,0),new l.Color3(.5,1,0),new l.Color3(.3,.4,0),new l.Color3(.5,1,0),new l.Color3(.2,0,0),new l.Color3(.5,1,0)]},enumerable:!1,configurable:!0}),Object.defineProperty(r,"RedFireColors",{get:function(){return[new l.Color3(.5,0,.1),new l.Color3(.9,0,0),new l.Color3(.2,0,0),new l.Color3(1,.9,0),new l.Color3(.1,.1,.1),new l.Color3(.9,.9,.9)]},enumerable:!1,configurable:!0}),Object.defineProperty(r,"BlueFireColors",{get:function(){return[new l.Color3(.1,0,.5),new l.Color3(0,0,.5),new l.Color3(.1,0,.2),new l.Color3(0,0,1),new l.Color3(.1,.2,.3),new l.Color3(0,.2,.9)]},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"autoGenerateTime",{get:function(){return this._autoGenerateTime},set:function(e){this._autoGenerateTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"fireColors",{get:function(){return this._fireColors},set:function(e){this._fireColors=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"time",{get:function(){return this._time},set:function(e){this._time=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"speed",{get:function(){return this._speed},set:function(e){this._speed=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alphaThreshold",{get:function(){return this._alphaThreshold},set:function(e){this._alphaThreshold=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));r.customType="BABYLON.FireProceduralTexture",r.fireColors=[];for(var t=0;t<this._fireColors.length;t++)r.fireColors.push(this._fireColors[t].asArray());return r},r.Parse=function(e,t,o){for(var i=l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o),n=[],a=0;a<e.fireColors.length;a++)n.push(l.Color3.FromArray(e.fireColors[a]));return i.fireColors=n,i},a([(0,l.serialize)()],r.prototype,"autoGenerateTime",null),a([(0,l.serialize)()],r.prototype,"time",null),a([(0,l.serializeAsVector2)()],r.prototype,"speed",null),a([(0,l.serialize)()],r.prototype,"alphaThreshold",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.FireProceduralTexture",c);l.ShaderStore.ShadersStore.grassProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform vec3 herb1Color;uniform vec3 herb2Color;uniform vec3 herb3Color;uniform vec3 groundColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec3 color=mix(groundColor,herb1Color,rand(gl_FragCoord.xy*4.0));color=mix(color,herb2Color,rand(gl_FragCoord.xy*8.0));color=mix(color,herb3Color,rand(gl_FragCoord.xy));color=mix(color,herb1Color,fbm(gl_FragCoord.xy*16.0));gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";var f=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"grassProceduralTexture",o,i,n)||this;return a._groundColor=new l.Color3(1,1,1),a._grassColors=[new l.Color3(.29,.38,.02),new l.Color3(.36,.49,.09),new l.Color3(.51,.6,.28)],a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setColor3("herb1Color",this._grassColors[0]),this.setColor3("herb2Color",this._grassColors[1]),this.setColor3("herb3Color",this._grassColors[2]),this.setColor3("groundColor",this._groundColor)},Object.defineProperty(r.prototype,"grassColors",{get:function(){return this._grassColors},set:function(e){this._grassColors=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"groundColor",{get:function(){return this._groundColor},set:function(e){this._groundColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));r.customType="BABYLON.GrassProceduralTexture",r.grassColors=[];for(var t=0;t<this._grassColors.length;t++)r.grassColors.push(this._grassColors[t].asArray());return r},r.Parse=function(e,t,o){for(var i=l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o),n=[],a=0;a<e.grassColors.length;a++)n.push(l.Color3.FromArray(e.grassColors[a]));return i.grassColors=n,i},a([(0,l.serializeAsColor3)()],r.prototype,"groundColor",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.GrassProceduralTexture",f);l.ShaderStore.ShadersStore.marbleProceduralTexturePixelShader="precision highp float;\nvarying vec2 vPosition;\nvarying vec2 vUV;\nuniform float numberOfTilesHeight;\nuniform float numberOfTilesWidth;\nuniform float amplitude;\nuniform vec3 marbleColor;\nuniform vec3 jointColor;\nconst vec3 tileSize=vec3(1.1,1.0,1.1);\nconst vec3 tilePct=vec3(0.98,1.0,0.98);\nfloat rand(vec2 n) {\nreturn fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);\n}\nfloat noise(vec2 n) {\nconst vec2 d=vec2(0.0,1.0);\nvec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));\nreturn mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);\n}\nfloat turbulence(vec2 P)\n{\nfloat val=0.0;\nfloat freq=1.0;\nfor (int i=0; i<4; i++)\n{\nval+=abs(noise(P*freq)/freq);\nfreq*=2.07;\n}\nreturn val;\n}\nfloat roundF(float number){\nreturn sign(number)*floor(abs(number)+0.5);\n}\nvec3 marble_color(float x)\n{\nvec3 col;\nx=0.5*(x+1.);\nx=sqrt(x); \nx=sqrt(x);\nx=sqrt(x);\ncol=vec3(.2+.75*x); \ncol.b*=0.95; \nreturn col;\n}\nvoid main()\n{\nfloat brickW=1.0/numberOfTilesWidth;\nfloat brickH=1.0/numberOfTilesHeight;\nfloat jointWPercentage=0.01;\nfloat jointHPercentage=0.01;\nvec3 color=marbleColor;\nfloat yi=vUV.y/brickH;\nfloat nyi=roundF(yi);\nfloat xi=vUV.x/brickW;\nif (mod(floor(yi),2.0)==0.0){\nxi=xi-0.5;\n}\nfloat nxi=roundF(xi);\nvec2 brickvUV=vec2((xi-floor(xi))/brickH,(yi-floor(yi))/brickW);\nif (yi<nyi+jointHPercentage && yi>nyi-jointHPercentage){\ncolor=mix(jointColor,vec3(0.37,0.25,0.25),(yi-nyi)/jointHPercentage+0.2);\n}\nelse if (xi<nxi+jointWPercentage && xi>nxi-jointWPercentage){\ncolor=mix(jointColor,vec3(0.44,0.44,0.44),(xi-nxi)/jointWPercentage+0.2);\n}\nelse {\nfloat t=6.28*brickvUV.x/(tileSize.x+noise(vec2(vUV)*6.0));\nt+=amplitude*turbulence(brickvUV.xy);\nt=sin(t);\ncolor=marble_color(t);\n}\ngl_FragColor=vec4(color,0.0);\n}";var d=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"marbleProceduralTexture",o,i,n)||this;return a._numberOfTilesHeight=3,a._numberOfTilesWidth=3,a._amplitude=9,a._jointColor=new l.Color3(.72,.72,.72),a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("numberOfTilesHeight",this._numberOfTilesHeight),this.setFloat("numberOfTilesWidth",this._numberOfTilesWidth),this.setFloat("amplitude",this._amplitude),this.setColor3("jointColor",this._jointColor)},Object.defineProperty(r.prototype,"numberOfTilesHeight",{get:function(){return this._numberOfTilesHeight},set:function(e){this._numberOfTilesHeight=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"amplitude",{get:function(){return this._amplitude},set:function(e){this._amplitude=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"numberOfTilesWidth",{get:function(){return this._numberOfTilesWidth},set:function(e){this._numberOfTilesWidth=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"jointColor",{get:function(){return this._jointColor},set:function(e){this._jointColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.MarbleProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serialize)()],r.prototype,"numberOfTilesHeight",null),a([(0,l.serialize)()],r.prototype,"amplitude",null),a([(0,l.serialize)()],r.prototype,"numberOfTilesWidth",null),a([(0,l.serialize)()],r.prototype,"jointColor",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.MarbleProceduralTexture",d);l.ShaderStore.ShadersStore.normalMapProceduralTexturePixelShader="precision highp float;uniform sampler2D baseSampler;uniform float size;varying vec2 vUV;const vec3 LUMA_COEFFICIENT=vec3(0.2126,0.7152,0.0722);float lumaAtCoord(vec2 coord)\n{vec3 pixel=texture2D(baseSampler,coord).rgb;float luma=dot(pixel,LUMA_COEFFICIENT);return luma;}\nvoid main()\n{float lumaU0=lumaAtCoord(vUV+vec2(-1.0, 0.0)/size);float lumaU1=lumaAtCoord(vUV+vec2( 1.0, 0.0)/size);float lumaV0=lumaAtCoord(vUV+vec2( 0.0,-1.0)/size);float lumaV1=lumaAtCoord(vUV+vec2( 0.0, 1.0)/size);vec2 slope=(vec2(lumaU0-lumaU1,lumaV0-lumaV1)+1.0)*0.5;gl_FragColor=vec4(slope,1.0,1.0);}\n";var p=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"normalMapProceduralTexture",o,i,n)||this;return a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setTexture("baseSampler",this._baseTexture),this.setFloat("size",this.getRenderSize())},r.prototype.render=function(r){e.prototype.render.call(this,r)},r.prototype.resize=function(r,t){e.prototype.resize.call(this,r,t),this.updateShaderUniforms()},r.prototype.isReady=function(){return!(!this._baseTexture||!this._baseTexture.isReady())&&e.prototype.isReady.call(this)},Object.defineProperty(r.prototype,"baseTexture",{get:function(){return this._baseTexture},set:function(e){this._baseTexture=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.NormalMapProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serializeAsTexture)()],r.prototype,"baseTexture",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.NormalMapProceduralTexture",p);l.ShaderStore.ShadersStore.perlinNoiseProceduralTexturePixelShader="precision highp float;uniform float size;uniform float time;uniform float translationSpeed;varying vec2 vUV;float r(float n)\n{return fract(cos(n*89.42)*343.42);}\nvec2 r(vec2 n)\n{return vec2(r(n.x*23.62-300.0+n.y*34.35),r(n.x*45.13+256.0+n.y*38.89)); }\nfloat worley(vec2 n,float s)\n{float dis=1.0;for(int x=-1; x<=1; x++)\n{for(int y=-1; y<=1; y++)\n{vec2 p=floor(n/s)+vec2(x,y);float d=length(r(p)+vec2(x,y)-fract(n/s));if (dis>d)\ndis=d;}}\nreturn 1.0-dis;}\nvec3 hash33(vec3 p3)\n{p3=fract(p3*vec3(0.1031,0.11369,0.13787));p3+=dot(p3,p3.yxz+19.19);return -1.0+2.0*fract(vec3((p3.x+p3.y)*p3.z,(p3.x+p3.z)*p3.y,(p3.y+p3.z)*p3.x));}\nfloat perlinNoise(vec3 p)\n{vec3 pi=floor(p);vec3 pf=p-pi;vec3 w=pf*pf*(3.0-2.0*pf);return mix(\nmix(\nmix(\ndot(pf-vec3(0,0,0),hash33(pi+vec3(0,0,0))),\ndot(pf-vec3(1,0,0),hash33(pi+vec3(1,0,0))),w.x\n),mix(\ndot(pf-vec3(0,0,1),hash33(pi+vec3(0,0,1))),\ndot(pf-vec3(1,0,1),hash33(pi+vec3(1,0,1))),w.x\n),w.z\n),mix(\nmix(\ndot(pf-vec3(0,1,0),hash33(pi+vec3(0,1,0))),\ndot(pf-vec3(1,1,0),hash33(pi+vec3(1,1,0))),w.x\n),mix(\ndot(pf-vec3(0,1,1),hash33(pi+vec3(0,1,1))),\ndot(pf-vec3(1,1,1),hash33(pi+vec3(1,1,1))),w.x\n),w.z\n),w.y\n);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{vec2 uv=gl_FragCoord.xy+translationSpeed;float dis=(\n1.0+perlinNoise(vec3(uv/vec2(size,size),time*0.05)*8.0))\n* (1.0+(worley(uv,32.0)+ 0.5*worley(2.0*uv,32.0)+0.25*worley(4.0*uv,32.0))\n);gl_FragColor=vec4(vec3(dis/4.0),1.0);}\n";var h=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"perlinNoiseProceduralTexture",o,i,n)||this;return a.time=0,a.timeScale=1,a.translationSpeed=1,a._currentTranslation=0,a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("size",this.getRenderSize());var e=this.getScene();if(e){var r=e.getEngine().getDeltaTime();this.time+=r,this.setFloat("time",this.time*this.timeScale/1e3),this._currentTranslation+=r*this.translationSpeed/1e3,this.setFloat("translationSpeed",this._currentTranslation)}},r.prototype.render=function(r){this.updateShaderUniforms(),e.prototype.render.call(this,r)},r.prototype.resize=function(r,t){e.prototype.resize.call(this,r,t)},r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.PerlinNoiseProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serialize)()],r.prototype,"time",void 0),a([(0,l.serialize)()],r.prototype,"timeScale",void 0),a([(0,l.serialize)()],r.prototype,"translationSpeed",void 0),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.PerlinNoiseProceduralTexture",h);l.ShaderStore.ShadersStore.roadProceduralTexturePixelShader="precision highp float;varying vec2 vUV; \nuniform vec3 roadColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(gl_FragCoord.y*100.0 ,fbm(vUV*2.0));vec3 color=roadColor*ratioy;gl_FragColor=vec4(color,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";var m=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"roadProceduralTexture",o,i,n)||this;return a._roadColor=new l.Color3(.53,.53,.53),a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setColor3("roadColor",this._roadColor)},Object.defineProperty(r.prototype,"roadColor",{get:function(){return this._roadColor},set:function(e){this._roadColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.RoadProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serializeAsColor3)()],r.prototype,"roadColor",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.RoadProceduralTexture",m);l.ShaderStore.ShadersStore.starfieldProceduralTexturePixelShader="precision highp float;\n#define volsteps 20\n#define iterations 15\nvarying vec2 vPosition;varying vec2 vUV;uniform float time;uniform float alpha;uniform float beta;uniform float zoom;uniform float formuparam;uniform float stepsize;uniform float tile;uniform float brightness;uniform float darkmatter;uniform float distfading;uniform float saturation;void main()\n{vec3 dir=vec3(vUV*zoom,1.);float localTime=time*0.0001;mat2 rot1=mat2(cos(alpha),sin(alpha),-sin(alpha),cos(alpha));mat2 rot2=mat2(cos(beta),sin(beta),-sin(beta),cos(beta));dir.xz*=rot1;dir.xy*=rot2;vec3 from_=vec3(1.,.5,0.5);from_+=vec3(-2.,localTime*2.,localTime);from_.xz*=rot1;from_.xy*=rot2;float s=0.1,fade=1.;vec3 v=vec3(0.);for (int r=0; r<volsteps; r++) {vec3 p=from_+s*dir*.5;p=abs(vec3(tile)-mod(p,vec3(tile*2.))); \nfloat pa,a=pa=0.;for (int i=0; i<iterations; i++) {p=abs(p)/dot(p,p)-formuparam; \na+=abs(length(p)-pa); \npa=length(p);}\nfloat dm=max(0.,darkmatter-a*a*.001); \na*=a*a; \nif (r>6) fade*=1.-dm; \nv+=fade;v+=vec3(s,s*s,s*s*s*s)*a*brightness*fade; \nfade*=distfading; \ns+=stepsize;}\nv=mix(vec3(length(v)),v,saturation); \ngl_FragColor=vec4(v*.01,1.);}";var v=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"starfieldProceduralTexture",o,i,n)||this;return a._time=1,a._alpha=.5,a._beta=.8,a._zoom=.8,a._formuparam=.53,a._stepsize=.1,a._tile=.85,a._brightness=.0015,a._darkmatter=.4,a._distfading=.73,a._saturation=.85,a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("time",this._time),this.setFloat("alpha",this._alpha),this.setFloat("beta",this._beta),this.setFloat("zoom",this._zoom),this.setFloat("formuparam",this._formuparam),this.setFloat("stepsize",this._stepsize),this.setFloat("tile",this._tile),this.setFloat("brightness",this._brightness),this.setFloat("darkmatter",this._darkmatter),this.setFloat("distfading",this._distfading),this.setFloat("saturation",this._saturation)},Object.defineProperty(r.prototype,"time",{get:function(){return this._time},set:function(e){this._time=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"beta",{get:function(){return this._beta},set:function(e){this._beta=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"formuparam",{get:function(){return this._formuparam},set:function(e){this._formuparam=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"stepsize",{get:function(){return this._stepsize},set:function(e){this._stepsize=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"zoom",{get:function(){return this._zoom},set:function(e){this._zoom=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"tile",{get:function(){return this._tile},set:function(e){this._tile=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"brightness",{get:function(){return this._brightness},set:function(e){this._brightness=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"darkmatter",{get:function(){return this._darkmatter},set:function(e){this._darkmatter=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"distfading",{get:function(){return this._distfading},set:function(e){this._distfading=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"saturation",{get:function(){return this._saturation},set:function(e){this._saturation=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.StarfieldProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serialize)()],r.prototype,"time",null),a([(0,l.serialize)()],r.prototype,"alpha",null),a([(0,l.serialize)()],r.prototype,"beta",null),a([(0,l.serialize)()],r.prototype,"formuparam",null),a([(0,l.serialize)()],r.prototype,"stepsize",null),a([(0,l.serialize)()],r.prototype,"zoom",null),a([(0,l.serialize)()],r.prototype,"tile",null),a([(0,l.serialize)()],r.prototype,"brightness",null),a([(0,l.serialize)()],r.prototype,"darkmatter",null),a([(0,l.serialize)()],r.prototype,"distfading",null),a([(0,l.serialize)()],r.prototype,"saturation",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.StarfieldProceduralTexture",v);l.ShaderStore.ShadersStore.woodProceduralTexturePixelShader="precision highp float;varying vec2 vPosition;varying vec2 vUV;uniform float ampScale;uniform vec3 woodColor;float rand(vec2 n) {return fract(cos(dot(n,vec2(12.9898,4.1414)))*43758.5453);}\nfloat noise(vec2 n) {const vec2 d=vec2(0.0,1.0);vec2 b=floor(n),f=smoothstep(vec2(0.0),vec2(1.0),fract(n));return mix(mix(rand(b),rand(b+d.yx),f.x),mix(rand(b+d.xy),rand(b+d.yy),f.x),f.y);}\nfloat fbm(vec2 n) {float total=0.0,amplitude=1.0;for (int i=0; i<4; i++) {total+=noise(n)*amplitude;n+=n;amplitude*=0.5;}\nreturn total;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat ratioy=mod(vUV.x*ampScale,2.0+fbm(vUV*0.8));vec3 wood=woodColor*ratioy;gl_FragColor=vec4(wood,1.0);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";var b=function(e){function r(r,t,o,i,n){void 0===o&&(o=null);var a=e.call(this,r,t,"woodProceduralTexture",o,i,n)||this;return a._ampScale=100,a._woodColor=new l.Color3(.32,.17,.09),a.updateShaderUniforms(),a}return n(r,e),r.prototype.updateShaderUniforms=function(){this.setFloat("ampScale",this._ampScale),this.setColor3("woodColor",this._woodColor)},Object.defineProperty(r.prototype,"ampScale",{get:function(){return this._ampScale},set:function(e){this._ampScale=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"woodColor",{get:function(){return this._woodColor},set:function(e){this._woodColor=e,this.updateShaderUniforms()},enumerable:!1,configurable:!0}),r.prototype.serialize=function(){var r=l.SerializationHelper.Serialize(this,e.prototype.serialize.call(this));return r.customType="BABYLON.WoodProceduralTexture",r},r.Parse=function(e,t,o){return l.SerializationHelper.Parse((function(){return new r(e.name,e._size,t,void 0,e._generateMipMaps)}),e,t,o)},a([(0,l.serialize)()],r.prototype,"ampScale",null),a([(0,l.serializeAsColor3)()],r.prototype,"woodColor",null),r}(l.ProceduralTexture);(0,l.RegisterClass)("BABYLON.WoodProceduralTexture",b);var y=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==y)for(var g in y.BABYLON=y.BABYLON||{},e)y.BABYLON[g]=e[g];const x=r})(),i.default})()));
2
2
  //# sourceMappingURL=babylonjs.proceduralTextures.min.js.map