babylon.lavaMaterial.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  13. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  14. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  15. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16. return c > 3 && r && Object.defineProperty(target, key, r), r;
  17. };
  18. var BABYLON;
  19. (function (BABYLON) {
  20. var LavaMaterialDefines = /** @class */ (function (_super) {
  21. __extends(LavaMaterialDefines, _super);
  22. function LavaMaterialDefines() {
  23. var _this = _super.call(this) || this;
  24. _this.DIFFUSE = false;
  25. _this.CLIPPLANE = false;
  26. _this.ALPHATEST = false;
  27. _this.DEPTHPREPASS = false;
  28. _this.POINTSIZE = false;
  29. _this.FOG = false;
  30. _this.LIGHT0 = false;
  31. _this.LIGHT1 = false;
  32. _this.LIGHT2 = false;
  33. _this.LIGHT3 = false;
  34. _this.SPOTLIGHT0 = false;
  35. _this.SPOTLIGHT1 = false;
  36. _this.SPOTLIGHT2 = false;
  37. _this.SPOTLIGHT3 = false;
  38. _this.HEMILIGHT0 = false;
  39. _this.HEMILIGHT1 = false;
  40. _this.HEMILIGHT2 = false;
  41. _this.HEMILIGHT3 = false;
  42. _this.DIRLIGHT0 = false;
  43. _this.DIRLIGHT1 = false;
  44. _this.DIRLIGHT2 = false;
  45. _this.DIRLIGHT3 = false;
  46. _this.POINTLIGHT0 = false;
  47. _this.POINTLIGHT1 = false;
  48. _this.POINTLIGHT2 = false;
  49. _this.POINTLIGHT3 = false;
  50. _this.SHADOW0 = false;
  51. _this.SHADOW1 = false;
  52. _this.SHADOW2 = false;
  53. _this.SHADOW3 = false;
  54. _this.SHADOWS = false;
  55. _this.SHADOWESM0 = false;
  56. _this.SHADOWESM1 = false;
  57. _this.SHADOWESM2 = false;
  58. _this.SHADOWESM3 = false;
  59. _this.SHADOWPOISSON0 = false;
  60. _this.SHADOWPOISSON1 = false;
  61. _this.SHADOWPOISSON2 = false;
  62. _this.SHADOWPOISSON3 = false;
  63. _this.SHADOWPCF0 = false;
  64. _this.SHADOWPCF1 = false;
  65. _this.SHADOWPCF2 = false;
  66. _this.SHADOWPCF3 = false;
  67. _this.SHADOWPCSS0 = false;
  68. _this.SHADOWPCSS1 = false;
  69. _this.SHADOWPCSS2 = false;
  70. _this.SHADOWPCSS3 = false;
  71. _this.NORMAL = false;
  72. _this.UV1 = false;
  73. _this.UV2 = false;
  74. _this.VERTEXCOLOR = false;
  75. _this.VERTEXALPHA = false;
  76. _this.NUM_BONE_INFLUENCERS = 0;
  77. _this.BonesPerMesh = 0;
  78. _this.INSTANCES = false;
  79. _this.rebuild();
  80. return _this;
  81. }
  82. return LavaMaterialDefines;
  83. }(BABYLON.MaterialDefines));
  84. var LavaMaterial = /** @class */ (function (_super) {
  85. __extends(LavaMaterial, _super);
  86. function LavaMaterial(name, scene) {
  87. var _this = _super.call(this, name, scene) || this;
  88. _this.speed = 1;
  89. _this.movingSpeed = 1;
  90. _this.lowFrequencySpeed = 1;
  91. _this.fogDensity = 0.15;
  92. _this._lastTime = 0;
  93. _this.diffuseColor = new BABYLON.Color3(1, 1, 1);
  94. _this._disableLighting = false;
  95. _this._maxSimultaneousLights = 4;
  96. _this._scaledDiffuse = new BABYLON.Color3();
  97. return _this;
  98. }
  99. LavaMaterial.prototype.needAlphaBlending = function () {
  100. return (this.alpha < 1.0);
  101. };
  102. LavaMaterial.prototype.needAlphaTesting = function () {
  103. return false;
  104. };
  105. LavaMaterial.prototype.getAlphaTestTexture = function () {
  106. return null;
  107. };
  108. // Methods
  109. LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  110. if (this.isFrozen) {
  111. if (this._wasPreviouslyReady && subMesh.effect) {
  112. return true;
  113. }
  114. }
  115. if (!subMesh._materialDefines) {
  116. subMesh._materialDefines = new LavaMaterialDefines();
  117. }
  118. var defines = subMesh._materialDefines;
  119. var scene = this.getScene();
  120. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  121. if (this._renderId === scene.getRenderId()) {
  122. return true;
  123. }
  124. }
  125. var engine = scene.getEngine();
  126. // Textures
  127. if (defines._areTexturesDirty) {
  128. defines._needUVs = false;
  129. if (scene.texturesEnabled) {
  130. if (this._diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  131. if (!this._diffuseTexture.isReady()) {
  132. return false;
  133. }
  134. else {
  135. defines._needUVs = true;
  136. defines.DIFFUSE = true;
  137. }
  138. }
  139. }
  140. }
  141. // Misc.
  142. BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  143. // Lights
  144. defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  145. // Values that need to be evaluated on every frame
  146. BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  147. // Attribs
  148. BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  149. // Get correct effect
  150. if (defines.isDirty) {
  151. defines.markAsProcessed();
  152. scene.resetCachedMaterial();
  153. // Fallbacks
  154. var fallbacks = new BABYLON.EffectFallbacks();
  155. if (defines.FOG) {
  156. fallbacks.addFallback(1, "FOG");
  157. }
  158. BABYLON.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
  159. if (defines.NUM_BONE_INFLUENCERS > 0) {
  160. fallbacks.addCPUSkinningFallback(0, mesh);
  161. }
  162. //Attributes
  163. var attribs = [BABYLON.VertexBuffer.PositionKind];
  164. if (defines.NORMAL) {
  165. attribs.push(BABYLON.VertexBuffer.NormalKind);
  166. }
  167. if (defines.UV1) {
  168. attribs.push(BABYLON.VertexBuffer.UVKind);
  169. }
  170. if (defines.UV2) {
  171. attribs.push(BABYLON.VertexBuffer.UV2Kind);
  172. }
  173. if (defines.VERTEXCOLOR) {
  174. attribs.push(BABYLON.VertexBuffer.ColorKind);
  175. }
  176. BABYLON.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  177. BABYLON.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  178. // Legacy browser patch
  179. var shaderName = "lava";
  180. var join = defines.toString();
  181. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  182. "vFogInfos", "vFogColor", "pointSize",
  183. "vDiffuseInfos",
  184. "mBones",
  185. "vClipPlane", "diffuseMatrix",
  186. "time", "speed", "movingSpeed",
  187. "fogColor", "fogDensity", "lowFrequencySpeed"
  188. ];
  189. var samplers = ["diffuseSampler",
  190. "noiseTexture"
  191. ];
  192. var uniformBuffers = new Array();
  193. BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
  194. uniformsNames: uniforms,
  195. uniformBuffersNames: uniformBuffers,
  196. samplers: samplers,
  197. defines: defines,
  198. maxSimultaneousLights: this.maxSimultaneousLights
  199. });
  200. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  201. attributes: attribs,
  202. uniformsNames: uniforms,
  203. uniformBuffersNames: uniformBuffers,
  204. samplers: samplers,
  205. defines: join,
  206. fallbacks: fallbacks,
  207. onCompiled: this.onCompiled,
  208. onError: this.onError,
  209. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  210. }, engine), defines);
  211. }
  212. if (!subMesh.effect || !subMesh.effect.isReady()) {
  213. return false;
  214. }
  215. this._renderId = scene.getRenderId();
  216. this._wasPreviouslyReady = true;
  217. return true;
  218. };
  219. LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  220. var scene = this.getScene();
  221. var defines = subMesh._materialDefines;
  222. if (!defines) {
  223. return;
  224. }
  225. var effect = subMesh.effect;
  226. if (!effect) {
  227. return;
  228. }
  229. this._activeEffect = effect;
  230. // Matrices
  231. this.bindOnlyWorldMatrix(world);
  232. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  233. // Bones
  234. BABYLON.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  235. if (this._mustRebind(scene, effect)) {
  236. // Textures
  237. if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  238. this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
  239. this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
  240. this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
  241. }
  242. if (this.noiseTexture) {
  243. this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
  244. }
  245. // Clip plane
  246. BABYLON.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  247. // Point size
  248. if (this.pointsCloud) {
  249. this._activeEffect.setFloat("pointSize", this.pointSize);
  250. }
  251. BABYLON.MaterialHelper.BindEyePosition(effect, scene);
  252. }
  253. this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  254. if (scene.lightsEnabled && !this.disableLighting) {
  255. BABYLON.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
  256. }
  257. // View
  258. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  259. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  260. }
  261. // Fog
  262. BABYLON.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  263. this._lastTime += scene.getEngine().getDeltaTime();
  264. this._activeEffect.setFloat("time", this._lastTime * this.speed / 1000);
  265. if (!this.fogColor) {
  266. this.fogColor = BABYLON.Color3.Black();
  267. }
  268. this._activeEffect.setColor3("fogColor", this.fogColor);
  269. this._activeEffect.setFloat("fogDensity", this.fogDensity);
  270. this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
  271. this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
  272. this._afterBind(mesh, this._activeEffect);
  273. };
  274. LavaMaterial.prototype.getAnimatables = function () {
  275. var results = [];
  276. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  277. results.push(this.diffuseTexture);
  278. }
  279. if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
  280. results.push(this.noiseTexture);
  281. }
  282. return results;
  283. };
  284. LavaMaterial.prototype.getActiveTextures = function () {
  285. var activeTextures = _super.prototype.getActiveTextures.call(this);
  286. if (this._diffuseTexture) {
  287. activeTextures.push(this._diffuseTexture);
  288. }
  289. return activeTextures;
  290. };
  291. LavaMaterial.prototype.hasTexture = function (texture) {
  292. if (_super.prototype.hasTexture.call(this, texture)) {
  293. return true;
  294. }
  295. if (this.diffuseTexture === texture) {
  296. return true;
  297. }
  298. return false;
  299. };
  300. LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
  301. if (this.diffuseTexture) {
  302. this.diffuseTexture.dispose();
  303. }
  304. if (this.noiseTexture) {
  305. this.noiseTexture.dispose();
  306. }
  307. _super.prototype.dispose.call(this, forceDisposeEffect);
  308. };
  309. LavaMaterial.prototype.clone = function (name) {
  310. var _this = this;
  311. return BABYLON.SerializationHelper.Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
  312. };
  313. LavaMaterial.prototype.serialize = function () {
  314. var serializationObject = BABYLON.SerializationHelper.Serialize(this);
  315. serializationObject.customType = "BABYLON.LavaMaterial";
  316. return serializationObject;
  317. };
  318. LavaMaterial.prototype.getClassName = function () {
  319. return "LavaMaterial";
  320. };
  321. // Statics
  322. LavaMaterial.Parse = function (source, scene, rootUrl) {
  323. return BABYLON.SerializationHelper.Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
  324. };
  325. __decorate([
  326. BABYLON.serializeAsTexture("diffuseTexture")
  327. ], LavaMaterial.prototype, "_diffuseTexture", void 0);
  328. __decorate([
  329. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  330. ], LavaMaterial.prototype, "diffuseTexture", void 0);
  331. __decorate([
  332. BABYLON.serializeAsTexture()
  333. ], LavaMaterial.prototype, "noiseTexture", void 0);
  334. __decorate([
  335. BABYLON.serializeAsColor3()
  336. ], LavaMaterial.prototype, "fogColor", void 0);
  337. __decorate([
  338. BABYLON.serialize()
  339. ], LavaMaterial.prototype, "speed", void 0);
  340. __decorate([
  341. BABYLON.serialize()
  342. ], LavaMaterial.prototype, "movingSpeed", void 0);
  343. __decorate([
  344. BABYLON.serialize()
  345. ], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
  346. __decorate([
  347. BABYLON.serialize()
  348. ], LavaMaterial.prototype, "fogDensity", void 0);
  349. __decorate([
  350. BABYLON.serializeAsColor3()
  351. ], LavaMaterial.prototype, "diffuseColor", void 0);
  352. __decorate([
  353. BABYLON.serialize("disableLighting")
  354. ], LavaMaterial.prototype, "_disableLighting", void 0);
  355. __decorate([
  356. BABYLON.expandToProperty("_markAllSubMeshesAsLightsDirty")
  357. ], LavaMaterial.prototype, "disableLighting", void 0);
  358. __decorate([
  359. BABYLON.serialize("maxSimultaneousLights")
  360. ], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
  361. __decorate([
  362. BABYLON.expandToProperty("_markAllSubMeshesAsLightsDirty")
  363. ], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
  364. return LavaMaterial;
  365. }(BABYLON.PushMaterial));
  366. BABYLON.LavaMaterial = LavaMaterial;
  367. })(BABYLON || (BABYLON = {}));
  368. //# sourceMappingURL=babylon.lavaMaterial.js.map
  369. BABYLON.Effect.ShadersStore['lavaVertexShader'] = "precision highp float;\n\nuniform float time;\nuniform float lowFrequencySpeed;\n\nvarying float noise;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n\n\nvec3 mod289(vec3 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 mod289(vec4 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 permute(vec4 x)\n{\nreturn mod289(((x*34.0)+1.0)*x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\nreturn 1.79284291400159-0.85373472095314*r;\n}\nvec3 fade(vec3 t) {\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat pnoise(vec3 P,vec3 rep)\n{\nvec3 Pi0=mod(floor(P),rep); \nvec3 Pi1=mod(Pi0+vec3(1.0),rep); \nPi0=mod289(Pi0);\nPi1=mod289(Pi1);\nvec3 Pf0=fract(P); \nvec3 Pf1=Pf0-vec3(1.0); \nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\nvec4 iz0=Pi0.zzzz;\nvec4 iz1=Pi1.zzzz;\nvec4 ixy=permute(permute(ix)+iy);\nvec4 ixy0=permute(ixy+iz0);\nvec4 ixy1=permute(ixy+iz1);\nvec4 gx0=ixy0*(1.0/7.0);\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\ngx0=fract(gx0);\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\nvec4 sz0=step(gz0,vec4(0.0));\ngx0-=sz0*(step(0.0,gx0)-0.5);\ngy0-=sz0*(step(0.0,gy0)-0.5);\nvec4 gx1=ixy1*(1.0/7.0);\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\ngx1=fract(gx1);\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\nvec4 sz1=step(gz1,vec4(0.0));\ngx1-=sz1*(step(0.0,gx1)-0.5);\ngy1-=sz1*(step(0.0,gy1)-0.5);\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\ng000*=norm0.x;\ng010*=norm0.y;\ng100*=norm0.z;\ng110*=norm0.w;\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\ng001*=norm1.x;\ng011*=norm1.y;\ng101*=norm1.z;\ng111*=norm1.w;\nfloat n000=dot(g000,Pf0);\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\nfloat n111=dot(g111,Pf1);\nvec3 fade_xyz=fade(Pf0);\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\nreturn 2.2*n_xyz;\n}\n\nfloat turbulence( vec3 p ) {\nfloat w=100.0;\nfloat t=-.5;\nfor (float f=1.0 ; f<=10.0 ; f++ ){\nfloat power=pow( 2.0,f );\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\n}\nreturn t;\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef NORMAL\n\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\n\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\n\nfloat displacement =-1.5*noise+b;\n\nvec3 newPosition=position+normal*displacement;\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}";
  370. BABYLON.Effect.ShadersStore['lavaPixelShader'] = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n\nuniform float time;\nuniform float speed;\nuniform float movingSpeed;\nuniform vec3 fogColor;\nuniform sampler2D noiseTexture;\nuniform float fogDensity;\n\nvarying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\n}\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\n\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\nT1.x+=noiseTex.x*2.0;\nT1.y+=noiseTex.y*2.0;\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\nbaseColor=temp;\nfloat depth=gl_FragCoord.z*4.0;\nconst float LOG2=1.442695;\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\ndiffuseColor=baseColor.rgb;\n\n\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";