babylon.triPlanarMaterial.js 23 KB

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