babylon.triPlanarMaterial.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 TriPlanarMaterialDefines = (function (_super) {
  21. __extends(TriPlanarMaterialDefines, _super);
  22. function TriPlanarMaterialDefines() {
  23. var _this = _super.call(this) || this;
  24. _this.DIFFUSEX = false;
  25. _this.DIFFUSEY = false;
  26. _this.DIFFUSEZ = false;
  27. _this.BUMPX = false;
  28. _this.BUMPY = false;
  29. _this.BUMPZ = false;
  30. _this.CLIPPLANE = false;
  31. _this.ALPHATEST = false;
  32. _this.DEPTHPREPASS = false;
  33. _this.POINTSIZE = false;
  34. _this.FOG = false;
  35. _this.SPECULARTERM = false;
  36. _this.NORMAL = false;
  37. _this.VERTEXCOLOR = false;
  38. _this.VERTEXALPHA = false;
  39. _this.NUM_BONE_INFLUENCERS = 0;
  40. _this.BonesPerMesh = 0;
  41. _this.INSTANCES = false;
  42. _this.rebuild();
  43. return _this;
  44. }
  45. return TriPlanarMaterialDefines;
  46. }(BABYLON.MaterialDefines));
  47. var TriPlanarMaterial = (function (_super) {
  48. __extends(TriPlanarMaterial, _super);
  49. function TriPlanarMaterial(name, scene) {
  50. var _this = _super.call(this, name, scene) || this;
  51. _this.tileSize = 1;
  52. _this.diffuseColor = new BABYLON.Color3(1, 1, 1);
  53. _this.specularColor = new BABYLON.Color3(0.2, 0.2, 0.2);
  54. _this.specularPower = 64;
  55. _this._disableLighting = false;
  56. _this._maxSimultaneousLights = 4;
  57. return _this;
  58. }
  59. TriPlanarMaterial.prototype.needAlphaBlending = function () {
  60. return (this.alpha < 1.0);
  61. };
  62. TriPlanarMaterial.prototype.needAlphaTesting = function () {
  63. return false;
  64. };
  65. TriPlanarMaterial.prototype.getAlphaTestTexture = function () {
  66. return null;
  67. };
  68. // Methods
  69. TriPlanarMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  70. if (this.isFrozen) {
  71. if (this._wasPreviouslyReady && subMesh.effect) {
  72. return true;
  73. }
  74. }
  75. if (!subMesh._materialDefines) {
  76. subMesh._materialDefines = new TriPlanarMaterialDefines();
  77. }
  78. var defines = subMesh._materialDefines;
  79. var scene = this.getScene();
  80. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  81. if (this._renderId === scene.getRenderId()) {
  82. return true;
  83. }
  84. }
  85. var engine = scene.getEngine();
  86. // Textures
  87. if (defines._areTexturesDirty) {
  88. if (scene.texturesEnabled) {
  89. if (BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  90. var textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];
  91. var textureDefines = ["DIFFUSEX", "DIFFUSEY", "DIFFUSEZ"];
  92. for (var i = 0; i < textures.length; i++) {
  93. if (textures[i]) {
  94. if (!textures[i].isReady()) {
  95. return false;
  96. }
  97. else {
  98. defines[textureDefines[i]] = true;
  99. }
  100. }
  101. }
  102. }
  103. if (BABYLON.StandardMaterial.BumpTextureEnabled) {
  104. var textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];
  105. var textureDefines = ["BUMPX", "BUMPY", "BUMPZ"];
  106. for (var i = 0; i < textures.length; i++) {
  107. if (textures[i]) {
  108. if (!textures[i].isReady()) {
  109. return false;
  110. }
  111. else {
  112. defines[textureDefines[i]] = true;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. // Misc.
  120. BABYLON.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, defines);
  121. // Lights
  122. defines._needNormals = BABYLON.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  123. // Values that need to be evaluated on every frame
  124. BABYLON.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  125. // Attribs
  126. BABYLON.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  127. // Get correct effect
  128. if (defines.isDirty) {
  129. defines.markAsProcessed();
  130. scene.resetCachedMaterial();
  131. // Fallbacks
  132. var fallbacks = new BABYLON.EffectFallbacks();
  133. if (defines.FOG) {
  134. fallbacks.addFallback(1, "FOG");
  135. }
  136. BABYLON.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  137. if (defines.NUM_BONE_INFLUENCERS > 0) {
  138. fallbacks.addCPUSkinningFallback(0, mesh);
  139. }
  140. //Attributes
  141. var attribs = [BABYLON.VertexBuffer.PositionKind];
  142. if (defines.NORMAL) {
  143. attribs.push(BABYLON.VertexBuffer.NormalKind);
  144. }
  145. if (defines.VERTEXCOLOR) {
  146. attribs.push(BABYLON.VertexBuffer.ColorKind);
  147. }
  148. BABYLON.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  149. BABYLON.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  150. // Legacy browser patch
  151. var shaderName = "triplanar";
  152. var join = defines.toString();
  153. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  154. "vFogInfos", "vFogColor", "pointSize",
  155. "mBones",
  156. "vClipPlane",
  157. "tileSize"
  158. ];
  159. var samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ",
  160. "normalSamplerX", "normalSamplerY", "normalSamplerZ"
  161. ];
  162. var uniformBuffers = new Array();
  163. BABYLON.MaterialHelper.PrepareUniformsAndSamplersList({
  164. uniformsNames: uniforms,
  165. uniformBuffersNames: uniformBuffers,
  166. samplers: samplers,
  167. defines: defines,
  168. maxSimultaneousLights: this.maxSimultaneousLights
  169. });
  170. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  171. attributes: attribs,
  172. uniformsNames: uniforms,
  173. uniformBuffersNames: uniformBuffers,
  174. samplers: samplers,
  175. defines: join,
  176. fallbacks: fallbacks,
  177. onCompiled: this.onCompiled,
  178. onError: this.onError,
  179. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  180. }, engine), defines);
  181. }
  182. if (!subMesh.effect.isReady()) {
  183. return false;
  184. }
  185. this._renderId = scene.getRenderId();
  186. this._wasPreviouslyReady = true;
  187. return true;
  188. };
  189. TriPlanarMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  190. var scene = this.getScene();
  191. var defines = subMesh._materialDefines;
  192. if (!defines) {
  193. return;
  194. }
  195. var effect = subMesh.effect;
  196. this._activeEffect = effect;
  197. // Matrices
  198. this.bindOnlyWorldMatrix(world);
  199. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  200. // Bones
  201. BABYLON.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  202. this._activeEffect.setFloat("tileSize", this.tileSize);
  203. if (scene.getCachedMaterial() !== this) {
  204. // Textures
  205. if (this.diffuseTextureX) {
  206. this._activeEffect.setTexture("diffuseSamplerX", this.diffuseTextureX);
  207. }
  208. if (this.diffuseTextureY) {
  209. this._activeEffect.setTexture("diffuseSamplerY", this.diffuseTextureY);
  210. }
  211. if (this.diffuseTextureZ) {
  212. this._activeEffect.setTexture("diffuseSamplerZ", this.diffuseTextureZ);
  213. }
  214. if (this.normalTextureX) {
  215. this._activeEffect.setTexture("normalSamplerX", this.normalTextureX);
  216. }
  217. if (this.normalTextureY) {
  218. this._activeEffect.setTexture("normalSamplerY", this.normalTextureY);
  219. }
  220. if (this.normalTextureZ) {
  221. this._activeEffect.setTexture("normalSamplerZ", this.normalTextureZ);
  222. }
  223. // Clip plane
  224. BABYLON.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  225. // Point size
  226. if (this.pointsCloud) {
  227. this._activeEffect.setFloat("pointSize", this.pointSize);
  228. }
  229. this._activeEffect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
  230. }
  231. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  232. if (defines.SPECULARTERM) {
  233. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  234. }
  235. if (scene.lightsEnabled && !this.disableLighting) {
  236. BABYLON.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  237. }
  238. // View
  239. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  240. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  241. }
  242. // Fog
  243. BABYLON.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  244. this._afterBind(mesh, this._activeEffect);
  245. };
  246. TriPlanarMaterial.prototype.getAnimatables = function () {
  247. var results = [];
  248. if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
  249. results.push(this.mixTexture);
  250. }
  251. return results;
  252. };
  253. TriPlanarMaterial.prototype.getActiveTextures = function () {
  254. var activeTextures = _super.prototype.getActiveTextures.call(this);
  255. if (this._diffuseTextureX) {
  256. activeTextures.push(this._diffuseTextureX);
  257. }
  258. if (this._diffuseTextureY) {
  259. activeTextures.push(this._diffuseTextureY);
  260. }
  261. if (this._diffuseTextureZ) {
  262. activeTextures.push(this._diffuseTextureZ);
  263. }
  264. if (this._normalTextureX) {
  265. activeTextures.push(this._normalTextureX);
  266. }
  267. if (this._normalTextureY) {
  268. activeTextures.push(this._normalTextureY);
  269. }
  270. if (this._normalTextureZ) {
  271. activeTextures.push(this._normalTextureZ);
  272. }
  273. return activeTextures;
  274. };
  275. TriPlanarMaterial.prototype.hasTexture = function (texture) {
  276. if (_super.prototype.hasTexture.call(this, texture)) {
  277. return true;
  278. }
  279. if (this._diffuseTextureX === texture) {
  280. return true;
  281. }
  282. if (this._diffuseTextureY === texture) {
  283. return true;
  284. }
  285. if (this._diffuseTextureZ === texture) {
  286. return true;
  287. }
  288. if (this._normalTextureX === texture) {
  289. return true;
  290. }
  291. if (this._normalTextureY === texture) {
  292. return true;
  293. }
  294. if (this._normalTextureZ === texture) {
  295. return true;
  296. }
  297. return false;
  298. };
  299. TriPlanarMaterial.prototype.dispose = function (forceDisposeEffect) {
  300. if (this.mixTexture) {
  301. this.mixTexture.dispose();
  302. }
  303. _super.prototype.dispose.call(this, forceDisposeEffect);
  304. };
  305. TriPlanarMaterial.prototype.clone = function (name) {
  306. var _this = this;
  307. return BABYLON.SerializationHelper.Clone(function () { return new TriPlanarMaterial(name, _this.getScene()); }, this);
  308. };
  309. TriPlanarMaterial.prototype.serialize = function () {
  310. var serializationObject = BABYLON.SerializationHelper.Serialize(this);
  311. serializationObject.customType = "BABYLON.TriPlanarMaterial";
  312. return serializationObject;
  313. };
  314. TriPlanarMaterial.prototype.getClassName = function () {
  315. return "TriPlanarMaterial";
  316. };
  317. // Statics
  318. TriPlanarMaterial.Parse = function (source, scene, rootUrl) {
  319. return BABYLON.SerializationHelper.Parse(function () { return new TriPlanarMaterial(source.name, scene); }, source, scene, rootUrl);
  320. };
  321. __decorate([
  322. BABYLON.serializeAsTexture()
  323. ], TriPlanarMaterial.prototype, "mixTexture", void 0);
  324. __decorate([
  325. BABYLON.serializeAsTexture("diffuseTextureX")
  326. ], TriPlanarMaterial.prototype, "_diffuseTextureX", void 0);
  327. __decorate([
  328. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  329. ], TriPlanarMaterial.prototype, "diffuseTextureX", void 0);
  330. __decorate([
  331. BABYLON.serializeAsTexture("diffuseTexturY")
  332. ], TriPlanarMaterial.prototype, "_diffuseTextureY", void 0);
  333. __decorate([
  334. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  335. ], TriPlanarMaterial.prototype, "diffuseTextureY", void 0);
  336. __decorate([
  337. BABYLON.serializeAsTexture("diffuseTextureZ")
  338. ], TriPlanarMaterial.prototype, "_diffuseTextureZ", void 0);
  339. __decorate([
  340. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  341. ], TriPlanarMaterial.prototype, "diffuseTextureZ", void 0);
  342. __decorate([
  343. BABYLON.serializeAsTexture("normalTextureX")
  344. ], TriPlanarMaterial.prototype, "_normalTextureX", void 0);
  345. __decorate([
  346. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  347. ], TriPlanarMaterial.prototype, "normalTextureX", void 0);
  348. __decorate([
  349. BABYLON.serializeAsTexture("normalTextureY")
  350. ], TriPlanarMaterial.prototype, "_normalTextureY", void 0);
  351. __decorate([
  352. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  353. ], TriPlanarMaterial.prototype, "normalTextureY", void 0);
  354. __decorate([
  355. BABYLON.serializeAsTexture("normalTextureZ")
  356. ], TriPlanarMaterial.prototype, "_normalTextureZ", void 0);
  357. __decorate([
  358. BABYLON.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  359. ], TriPlanarMaterial.prototype, "normalTextureZ", void 0);
  360. __decorate([
  361. BABYLON.serialize()
  362. ], TriPlanarMaterial.prototype, "tileSize", void 0);
  363. __decorate([
  364. BABYLON.serializeAsColor3()
  365. ], TriPlanarMaterial.prototype, "diffuseColor", void 0);
  366. __decorate([
  367. BABYLON.serializeAsColor3()
  368. ], TriPlanarMaterial.prototype, "specularColor", void 0);
  369. __decorate([
  370. BABYLON.serialize()
  371. ], TriPlanarMaterial.prototype, "specularPower", void 0);
  372. __decorate([
  373. BABYLON.serialize("disableLighting")
  374. ], TriPlanarMaterial.prototype, "_disableLighting", void 0);
  375. __decorate([
  376. BABYLON.expandToProperty("_markAllSubMeshesAsLightsDirty")
  377. ], TriPlanarMaterial.prototype, "disableLighting", void 0);
  378. __decorate([
  379. BABYLON.serialize("maxSimultaneousLights")
  380. ], TriPlanarMaterial.prototype, "_maxSimultaneousLights", void 0);
  381. __decorate([
  382. BABYLON.expandToProperty("_markAllSubMeshesAsLightsDirty")
  383. ], TriPlanarMaterial.prototype, "maxSimultaneousLights", void 0);
  384. return TriPlanarMaterial;
  385. }(BABYLON.PushMaterial));
  386. BABYLON.TriPlanarMaterial = TriPlanarMaterial;
  387. })(BABYLON || (BABYLON = {}));
  388. //# sourceMappingURL=babylon.triPlanarMaterial.js.map
  389. BABYLON.Effect.ShadersStore['triplanarVertexShader'] = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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 DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void)\n{\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 DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\nvec3 worldNormal=normalize(cross(worldTangent,worldBinormal));\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\n#endif\n\n#include<clipPlaneVertex>\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";
  390. BABYLON.Effect.ShadersStore['triplanarPixelShader'] = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=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,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";