babylon.triPlanarMaterial.js 23 KB

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