babylon.triPlanarMaterial.js 23 KB

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