babylon.terrainMaterial.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. var __extends = (this && this.__extends) || function (d, b) {
  3. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  4. function __() { this.constructor = d; }
  5. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6. };
  7. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  8. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  9. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  10. 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;
  11. return c > 3 && r && Object.defineProperty(target, key, r), r;
  12. };
  13. var BABYLON;
  14. (function (BABYLON) {
  15. var maxSimultaneousLights = 4;
  16. var TerrainMaterialDefines = (function (_super) {
  17. __extends(TerrainMaterialDefines, _super);
  18. function TerrainMaterialDefines() {
  19. var _this = _super.call(this) || this;
  20. _this.DIFFUSE = false;
  21. _this.BUMP = false;
  22. _this.CLIPPLANE = false;
  23. _this.ALPHATEST = false;
  24. _this.POINTSIZE = false;
  25. _this.FOG = false;
  26. _this.SPECULARTERM = false;
  27. _this.NORMAL = false;
  28. _this.UV1 = false;
  29. _this.UV2 = false;
  30. _this.VERTEXCOLOR = false;
  31. _this.VERTEXALPHA = false;
  32. _this.NUM_BONE_INFLUENCERS = 0;
  33. _this.BonesPerMesh = 0;
  34. _this.INSTANCES = false;
  35. _this.rebuild();
  36. return _this;
  37. }
  38. return TerrainMaterialDefines;
  39. }(BABYLON.MaterialDefines));
  40. var TerrainMaterial = (function (_super) {
  41. __extends(TerrainMaterial, _super);
  42. function TerrainMaterial(name, scene) {
  43. var _this = _super.call(this, name, scene) || this;
  44. _this.diffuseColor = new BABYLON.Color3(1, 1, 1);
  45. _this.specularColor = new BABYLON.Color3(0, 0, 0);
  46. _this.specularPower = 64;
  47. _this.disableLighting = false;
  48. _this.maxSimultaneousLights = 4;
  49. _this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
  50. _this._defines = new TerrainMaterialDefines();
  51. _this._cachedDefines = new TerrainMaterialDefines();
  52. _this._cachedDefines.BonesPerMesh = -1;
  53. return _this;
  54. }
  55. TerrainMaterial.prototype.needAlphaBlending = function () {
  56. return (this.alpha < 1.0);
  57. };
  58. TerrainMaterial.prototype.needAlphaTesting = function () {
  59. return false;
  60. };
  61. TerrainMaterial.prototype.getAlphaTestTexture = function () {
  62. return null;
  63. };
  64. // Methods
  65. TerrainMaterial.prototype._checkCache = function (scene, mesh, useInstances) {
  66. if (!mesh) {
  67. return true;
  68. }
  69. if (this._defines.INSTANCES !== useInstances) {
  70. return false;
  71. }
  72. if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
  73. return true;
  74. }
  75. return false;
  76. };
  77. TerrainMaterial.prototype.isReady = function (mesh, useInstances) {
  78. if (this.checkReadyOnlyOnce) {
  79. if (this._wasPreviouslyReady) {
  80. return true;
  81. }
  82. }
  83. var scene = this.getScene();
  84. if (!this.checkReadyOnEveryCall) {
  85. if (this._renderId === scene.getRenderId()) {
  86. if (this._checkCache(scene, mesh, useInstances)) {
  87. return true;
  88. }
  89. }
  90. }
  91. var engine = scene.getEngine();
  92. var needNormals = false;
  93. var needUVs = false;
  94. this._defines.reset();
  95. // Effect
  96. if (scene.clipPlane) {
  97. this._defines.CLIPPLANE = true;
  98. }
  99. if (engine.getAlphaTesting()) {
  100. this._defines.ALPHATEST = true;
  101. }
  102. // Point size
  103. if (this.pointsCloud || scene.forcePointsCloud) {
  104. this._defines.POINTSIZE = true;
  105. }
  106. // Fog
  107. if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
  108. this._defines.FOG = true;
  109. }
  110. // Lights
  111. if (scene.lightsEnabled && !this.disableLighting) {
  112. needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, this._defines, this.maxSimultaneousLights);
  113. }
  114. // Textures
  115. if (scene.texturesEnabled) {
  116. if (this.mixTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  117. if (!this.mixTexture.isReady()) {
  118. return false;
  119. }
  120. else {
  121. needUVs = true;
  122. this._defines.DIFFUSE = true;
  123. }
  124. }
  125. if ((this.bumpTexture1 || this.bumpTexture2 || this.bumpTexture3) && BABYLON.StandardMaterial.BumpTextureEnabled) {
  126. needUVs = true;
  127. needNormals = true;
  128. this._defines.BUMP = true;
  129. }
  130. }
  131. // Attribs
  132. if (mesh) {
  133. if (needNormals && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
  134. this._defines.NORMAL = true;
  135. }
  136. if (needUVs) {
  137. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
  138. this._defines.UV1 = true;
  139. }
  140. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UV2Kind)) {
  141. this._defines.UV2 = true;
  142. }
  143. }
  144. if (mesh.useVertexColors && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
  145. this._defines.VERTEXCOLOR = true;
  146. if (mesh.hasVertexAlpha) {
  147. this._defines.VERTEXALPHA = true;
  148. }
  149. }
  150. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  151. this._defines.NUM_BONE_INFLUENCERS = mesh.numBoneInfluencers;
  152. this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
  153. }
  154. // Instances
  155. if (useInstances) {
  156. this._defines.INSTANCES = true;
  157. }
  158. }
  159. // Get correct effect
  160. if (!this._defines.isEqual(this._cachedDefines)) {
  161. this._defines.cloneTo(this._cachedDefines);
  162. scene.resetCachedMaterial();
  163. // Fallbacks
  164. var fallbacks = new BABYLON.EffectFallbacks();
  165. if (this._defines.FOG) {
  166. fallbacks.addFallback(1, "FOG");
  167. }
  168. BABYLON.MaterialHelper.HandleFallbacksForShadows(this._defines, fallbacks, this.maxSimultaneousLights);
  169. if (this._defines.NUM_BONE_INFLUENCERS > 0) {
  170. fallbacks.addCPUSkinningFallback(0, mesh);
  171. }
  172. //Attributes
  173. var attribs = [BABYLON.VertexBuffer.PositionKind];
  174. if (this._defines.NORMAL) {
  175. attribs.push(BABYLON.VertexBuffer.NormalKind);
  176. }
  177. if (this._defines.UV1) {
  178. attribs.push(BABYLON.VertexBuffer.UVKind);
  179. }
  180. if (this._defines.UV2) {
  181. attribs.push(BABYLON.VertexBuffer.UV2Kind);
  182. }
  183. if (this._defines.VERTEXCOLOR) {
  184. attribs.push(BABYLON.VertexBuffer.ColorKind);
  185. }
  186. BABYLON.MaterialHelper.PrepareAttributesForBones(attribs, mesh, this._defines, fallbacks);
  187. BABYLON.MaterialHelper.PrepareAttributesForInstances(attribs, this._defines);
  188. // Legacy browser patch
  189. var shaderName = "terrain";
  190. var join = this._defines.toString();
  191. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  192. "vFogInfos", "vFogColor", "pointSize",
  193. "vTextureInfos",
  194. "mBones",
  195. "vClipPlane", "textureMatrix",
  196. "diffuse1Infos", "diffuse2Infos", "diffuse3Infos"
  197. ];
  198. var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler",
  199. "bump1Sampler", "bump2Sampler", "bump3Sampler"
  200. ];
  201. BABYLON.MaterialHelper.PrepareUniformsAndSamplersList(uniforms, samplers, this._defines, this.maxSimultaneousLights);
  202. this._effect = scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights });
  203. }
  204. if (!this._effect.isReady()) {
  205. return false;
  206. }
  207. this._renderId = scene.getRenderId();
  208. this._wasPreviouslyReady = true;
  209. if (mesh) {
  210. if (!mesh._materialDefines) {
  211. mesh._materialDefines = new TerrainMaterialDefines();
  212. }
  213. this._defines.cloneTo(mesh._materialDefines);
  214. }
  215. return true;
  216. };
  217. TerrainMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  218. this._effect.setMatrix("world", world);
  219. };
  220. TerrainMaterial.prototype.bind = function (world, mesh) {
  221. var scene = this.getScene();
  222. // Matrices
  223. this.bindOnlyWorldMatrix(world);
  224. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  225. // Bones
  226. BABYLON.MaterialHelper.BindBonesParameters(mesh, this._effect);
  227. if (scene.getCachedMaterial() !== this) {
  228. // Textures
  229. if (this.mixTexture) {
  230. this._effect.setTexture("textureSampler", this.mixTexture);
  231. this._effect.setFloat2("vTextureInfos", this.mixTexture.coordinatesIndex, this.mixTexture.level);
  232. this._effect.setMatrix("textureMatrix", this.mixTexture.getTextureMatrix());
  233. if (BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  234. if (this.diffuseTexture1) {
  235. this._effect.setTexture("diffuse1Sampler", this.diffuseTexture1);
  236. this._effect.setFloat2("diffuse1Infos", this.diffuseTexture1.uScale, this.diffuseTexture1.vScale);
  237. }
  238. if (this.diffuseTexture2) {
  239. this._effect.setTexture("diffuse2Sampler", this.diffuseTexture2);
  240. this._effect.setFloat2("diffuse2Infos", this.diffuseTexture2.uScale, this.diffuseTexture2.vScale);
  241. }
  242. if (this.diffuseTexture3) {
  243. this._effect.setTexture("diffuse3Sampler", this.diffuseTexture3);
  244. this._effect.setFloat2("diffuse3Infos", this.diffuseTexture3.uScale, this.diffuseTexture3.vScale);
  245. }
  246. }
  247. if (BABYLON.StandardMaterial.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {
  248. if (this.bumpTexture1) {
  249. this._effect.setTexture("bump1Sampler", this.bumpTexture1);
  250. }
  251. if (this.bumpTexture2) {
  252. this._effect.setTexture("bump2Sampler", this.bumpTexture2);
  253. }
  254. if (this.bumpTexture3) {
  255. this._effect.setTexture("bump3Sampler", this.bumpTexture3);
  256. }
  257. }
  258. }
  259. // Clip plane
  260. BABYLON.MaterialHelper.BindClipPlane(this._effect, scene);
  261. // Point size
  262. if (this.pointsCloud) {
  263. this._effect.setFloat("pointSize", this.pointSize);
  264. }
  265. this._effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
  266. }
  267. this._effect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  268. if (this._defines.SPECULARTERM) {
  269. this._effect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  270. }
  271. if (scene.lightsEnabled && !this.disableLighting) {
  272. BABYLON.MaterialHelper.BindLights(scene, mesh, this._effect, this._defines, this.maxSimultaneousLights);
  273. }
  274. // View
  275. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  276. this._effect.setMatrix("view", scene.getViewMatrix());
  277. }
  278. // Fog
  279. BABYLON.MaterialHelper.BindFogParameters(scene, mesh, this._effect);
  280. _super.prototype.bind.call(this, world, mesh);
  281. };
  282. TerrainMaterial.prototype.getAnimatables = function () {
  283. var results = [];
  284. if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
  285. results.push(this.mixTexture);
  286. }
  287. return results;
  288. };
  289. TerrainMaterial.prototype.dispose = function (forceDisposeEffect) {
  290. if (this.mixTexture) {
  291. this.mixTexture.dispose();
  292. }
  293. _super.prototype.dispose.call(this, forceDisposeEffect);
  294. };
  295. TerrainMaterial.prototype.clone = function (name) {
  296. var _this = this;
  297. return BABYLON.SerializationHelper.Clone(function () { return new TerrainMaterial(name, _this.getScene()); }, this);
  298. };
  299. TerrainMaterial.prototype.serialize = function () {
  300. var serializationObject = BABYLON.SerializationHelper.Serialize(this);
  301. serializationObject.customType = "BABYLON.TerrainMaterial";
  302. return serializationObject;
  303. };
  304. // Statics
  305. TerrainMaterial.Parse = function (source, scene, rootUrl) {
  306. return BABYLON.SerializationHelper.Parse(function () { return new TerrainMaterial(source.name, scene); }, source, scene, rootUrl);
  307. };
  308. return TerrainMaterial;
  309. }(BABYLON.Material));
  310. __decorate([
  311. BABYLON.serializeAsTexture()
  312. ], TerrainMaterial.prototype, "mixTexture", void 0);
  313. __decorate([
  314. BABYLON.serializeAsTexture()
  315. ], TerrainMaterial.prototype, "diffuseTexture1", void 0);
  316. __decorate([
  317. BABYLON.serializeAsTexture()
  318. ], TerrainMaterial.prototype, "diffuseTexture2", void 0);
  319. __decorate([
  320. BABYLON.serializeAsTexture()
  321. ], TerrainMaterial.prototype, "diffuseTexture3", void 0);
  322. __decorate([
  323. BABYLON.serializeAsTexture()
  324. ], TerrainMaterial.prototype, "bumpTexture1", void 0);
  325. __decorate([
  326. BABYLON.serializeAsTexture()
  327. ], TerrainMaterial.prototype, "bumpTexture2", void 0);
  328. __decorate([
  329. BABYLON.serializeAsTexture()
  330. ], TerrainMaterial.prototype, "bumpTexture3", void 0);
  331. __decorate([
  332. BABYLON.serializeAsColor3()
  333. ], TerrainMaterial.prototype, "diffuseColor", void 0);
  334. __decorate([
  335. BABYLON.serializeAsColor3()
  336. ], TerrainMaterial.prototype, "specularColor", void 0);
  337. __decorate([
  338. BABYLON.serialize()
  339. ], TerrainMaterial.prototype, "specularPower", void 0);
  340. __decorate([
  341. BABYLON.serialize()
  342. ], TerrainMaterial.prototype, "disableLighting", void 0);
  343. __decorate([
  344. BABYLON.serialize()
  345. ], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
  346. BABYLON.TerrainMaterial = TerrainMaterial;
  347. })(BABYLON || (BABYLON = {}));
  348. //# sourceMappingURL=babylon.terrainMaterial.js.map
  349. BABYLON.Effect.ShadersStore['terrainVertexShader'] = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<shadowsVertexDeclaration>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  350. BABYLON.Effect.ShadersStore['terrainPixelShader'] = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<lightFragmentDeclaration>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{ \nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\nvoid main(void) {\n\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";