babylon.fireMaterial.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2. var BABYLON;
  3. (function (BABYLON) {
  4. var maxSimultaneousLights = 4;
  5. var FireMaterialDefines = (function (_super) {
  6. __extends(FireMaterialDefines, _super);
  7. function FireMaterialDefines() {
  8. _super.call(this);
  9. this.DIFFUSE = false;
  10. this.CLIPPLANE = false;
  11. this.ALPHATEST = false;
  12. this.POINTSIZE = false;
  13. this.FOG = false;
  14. this.UV1 = false;
  15. this.NORMAL = false;
  16. this.VERTEXCOLOR = false;
  17. this.VERTEXALPHA = false;
  18. this.NUM_BONE_INFLUENCERS = 0;
  19. this.BonesPerMesh = 0;
  20. this.INSTANCES = false;
  21. this._keys = Object.keys(this);
  22. }
  23. return FireMaterialDefines;
  24. })(BABYLON.MaterialDefines);
  25. var FireMaterial = (function (_super) {
  26. __extends(FireMaterial, _super);
  27. function FireMaterial(name, scene) {
  28. _super.call(this, name, scene);
  29. this.diffuseColor = new BABYLON.Color3(1, 1, 1);
  30. this.disableLighting = false;
  31. this.speed = 1.0;
  32. this._scaledDiffuse = new BABYLON.Color3();
  33. this._defines = new FireMaterialDefines();
  34. this._cachedDefines = new FireMaterialDefines();
  35. this._lastTime = 0;
  36. this._cachedDefines.BonesPerMesh = -1;
  37. }
  38. FireMaterial.prototype.needAlphaBlending = function () {
  39. return (this.alpha < 1.0);
  40. };
  41. FireMaterial.prototype.needAlphaTesting = function () {
  42. return false;
  43. };
  44. FireMaterial.prototype.getAlphaTestTexture = function () {
  45. return null;
  46. };
  47. // Methods
  48. FireMaterial.prototype._checkCache = function (scene, mesh, useInstances) {
  49. if (!mesh) {
  50. return true;
  51. }
  52. if (this._defines.INSTANCES !== useInstances) {
  53. return false;
  54. }
  55. if (mesh._materialDefines && mesh._materialDefines.isEqual(this._defines)) {
  56. return true;
  57. }
  58. return false;
  59. };
  60. FireMaterial.prototype.isReady = function (mesh, useInstances) {
  61. if (this.checkReadyOnlyOnce) {
  62. if (this._wasPreviouslyReady) {
  63. return true;
  64. }
  65. }
  66. var scene = this.getScene();
  67. if (!this.checkReadyOnEveryCall) {
  68. if (this._renderId === scene.getRenderId()) {
  69. if (this._checkCache(scene, mesh, useInstances)) {
  70. return true;
  71. }
  72. }
  73. }
  74. var engine = scene.getEngine();
  75. var needNormals = false;
  76. var needUVs = false;
  77. this._defines.reset();
  78. // Textures
  79. if (scene.texturesEnabled) {
  80. if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  81. if (!this.diffuseTexture.isReady()) {
  82. return false;
  83. }
  84. else {
  85. needUVs = true;
  86. this._defines.DIFFUSE = true;
  87. }
  88. }
  89. }
  90. // Effect
  91. if (scene.clipPlane) {
  92. this._defines.CLIPPLANE = true;
  93. }
  94. this._defines.ALPHATEST = true;
  95. // Point size
  96. if (this.pointsCloud || scene.forcePointsCloud) {
  97. this._defines.POINTSIZE = true;
  98. }
  99. // Fog
  100. if (scene.fogEnabled && mesh && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
  101. this._defines.FOG = true;
  102. }
  103. // Attribs
  104. if (mesh) {
  105. if (needNormals && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.NormalKind)) {
  106. this._defines.NORMAL = true;
  107. }
  108. if (needUVs) {
  109. if (mesh.isVerticesDataPresent(BABYLON.VertexBuffer.UVKind)) {
  110. this._defines.UV1 = true;
  111. }
  112. }
  113. if (mesh.useVertexColors && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.ColorKind)) {
  114. this._defines.VERTEXCOLOR = true;
  115. if (mesh.hasVertexAlpha) {
  116. this._defines.VERTEXALPHA = true;
  117. }
  118. }
  119. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120. this._defines.NUM_BONE_INFLUENCERS = mesh.numBoneInfluencers;
  121. this._defines.BonesPerMesh = (mesh.skeleton.bones.length + 1);
  122. }
  123. // Instances
  124. if (useInstances) {
  125. this._defines.INSTANCES = true;
  126. }
  127. }
  128. // Get correct effect
  129. if (!this._defines.isEqual(this._cachedDefines)) {
  130. this._defines.cloneTo(this._cachedDefines);
  131. scene.resetCachedMaterial();
  132. // Fallbacks
  133. var fallbacks = new BABYLON.EffectFallbacks();
  134. if (this._defines.FOG) {
  135. fallbacks.addFallback(1, "FOG");
  136. }
  137. if (this._defines.NUM_BONE_INFLUENCERS > 0) {
  138. fallbacks.addCPUSkinningFallback(0, mesh);
  139. }
  140. //Attributes
  141. var attribs = [BABYLON.VertexBuffer.PositionKind];
  142. if (this._defines.NORMAL) {
  143. attribs.push(BABYLON.VertexBuffer.NormalKind);
  144. }
  145. if (this._defines.UV1) {
  146. attribs.push(BABYLON.VertexBuffer.UVKind);
  147. }
  148. if (this._defines.VERTEXCOLOR) {
  149. attribs.push(BABYLON.VertexBuffer.ColorKind);
  150. }
  151. if (this._defines.NUM_BONE_INFLUENCERS > 0) {
  152. attribs.push(BABYLON.VertexBuffer.MatricesIndicesKind);
  153. attribs.push(BABYLON.VertexBuffer.MatricesWeightsKind);
  154. if (this._defines.NUM_BONE_INFLUENCERS > 4) {
  155. attribs.push(BABYLON.VertexBuffer.MatricesIndicesExtraKind);
  156. attribs.push(BABYLON.VertexBuffer.MatricesWeightsExtraKind);
  157. }
  158. }
  159. if (this._defines.INSTANCES) {
  160. attribs.push("world0");
  161. attribs.push("world1");
  162. attribs.push("world2");
  163. attribs.push("world3");
  164. }
  165. // Legacy browser patch
  166. var shaderName = "fire";
  167. var join = this._defines.toString();
  168. this._effect = scene.getEngine().createEffect(shaderName, attribs, ["world", "view", "viewProjection", "vEyePosition",
  169. "vFogInfos", "vFogColor", "pointSize",
  170. "vDiffuseInfos",
  171. "mBones",
  172. "vClipPlane", "diffuseMatrix",
  173. // Fire
  174. "time", "speed"
  175. ], ["diffuseSampler",
  176. // Fire
  177. "distortionSampler", "opacitySampler"
  178. ], join, fallbacks, this.onCompiled, this.onError);
  179. }
  180. if (!this._effect.isReady()) {
  181. return false;
  182. }
  183. this._renderId = scene.getRenderId();
  184. this._wasPreviouslyReady = true;
  185. if (mesh) {
  186. if (!mesh._materialDefines) {
  187. mesh._materialDefines = new FireMaterialDefines();
  188. }
  189. this._defines.cloneTo(mesh._materialDefines);
  190. }
  191. return true;
  192. };
  193. FireMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  194. this._effect.setMatrix("world", world);
  195. };
  196. FireMaterial.prototype.bind = function (world, mesh) {
  197. var scene = this.getScene();
  198. // Matrices
  199. this.bindOnlyWorldMatrix(world);
  200. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  201. // Bones
  202. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders) {
  203. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
  204. }
  205. if (scene.getCachedMaterial() !== this) {
  206. // Textures
  207. if (this.diffuseTexture && BABYLON.StandardMaterial.DiffuseTextureEnabled) {
  208. this._effect.setTexture("diffuseSampler", this.diffuseTexture);
  209. this._effect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
  210. this._effect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
  211. this._effect.setTexture("distortionSampler", this.distortionTexture);
  212. this._effect.setTexture("opacitySampler", this.opacityTexture);
  213. }
  214. // Clip plane
  215. if (scene.clipPlane) {
  216. var clipPlane = scene.clipPlane;
  217. this._effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  218. }
  219. // Point size
  220. if (this.pointsCloud) {
  221. this._effect.setFloat("pointSize", this.pointSize);
  222. }
  223. this._effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.position);
  224. }
  225. this._effect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  226. // View
  227. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  228. this._effect.setMatrix("view", scene.getViewMatrix());
  229. }
  230. // Fog
  231. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
  232. this._effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  233. this._effect.setColor3("vFogColor", scene.fogColor);
  234. }
  235. // Time
  236. this._lastTime += scene.getEngine().getDeltaTime();
  237. this._effect.setFloat("time", this._lastTime);
  238. // Speed
  239. this._effect.setFloat("speed", this.speed);
  240. _super.prototype.bind.call(this, world, mesh);
  241. };
  242. FireMaterial.prototype.getAnimatables = function () {
  243. var results = [];
  244. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  245. results.push(this.diffuseTexture);
  246. }
  247. if (this.distortionTexture && this.distortionTexture.animations && this.distortionTexture.animations.length > 0) {
  248. results.push(this.distortionTexture);
  249. }
  250. if (this.opacityTexture && this.opacityTexture.animations && this.opacityTexture.animations.length > 0) {
  251. results.push(this.opacityTexture);
  252. }
  253. return results;
  254. };
  255. FireMaterial.prototype.dispose = function (forceDisposeEffect) {
  256. if (this.diffuseTexture) {
  257. this.diffuseTexture.dispose();
  258. }
  259. if (this.distortionTexture) {
  260. this.distortionTexture.dispose();
  261. }
  262. _super.prototype.dispose.call(this, forceDisposeEffect);
  263. };
  264. FireMaterial.prototype.clone = function (name) {
  265. var newMaterial = new FireMaterial(name, this.getScene());
  266. // Base material
  267. this.copyTo(newMaterial);
  268. // Fire material
  269. if (this.diffuseTexture && this.diffuseTexture.clone) {
  270. newMaterial.diffuseTexture = this.diffuseTexture.clone();
  271. }
  272. if (this.distortionTexture && this.distortionTexture.clone) {
  273. newMaterial.distortionTexture = this.distortionTexture.clone();
  274. }
  275. if (this.opacityTexture && this.opacityTexture.clone) {
  276. newMaterial.opacityTexture = this.opacityTexture.clone();
  277. }
  278. newMaterial.diffuseColor = this.diffuseColor.clone();
  279. return newMaterial;
  280. };
  281. return FireMaterial;
  282. })(BABYLON.Material);
  283. BABYLON.FireMaterial = FireMaterial;
  284. })(BABYLON || (BABYLON = {}));
  285. BABYLON.Effect.ShadersStore['fireVertexShader'] = "precision highp float;\r\n\r\n// Attributes\r\nattribute vec3 position;\r\n#ifdef NORMAL\r\nattribute vec3 normal;\r\n#endif\r\n#ifdef UV1\r\nattribute vec2 uv;\r\n#endif\r\n#ifdef UV2\r\nattribute vec2 uv2;\r\n#endif\r\n#ifdef VERTEXCOLOR\r\nattribute vec4 color;\r\n#endif\r\n#ifdef BONES\r\nattribute vec4 matricesIndices;\r\nattribute vec4 matricesWeights;\r\n#endif\r\n\r\n// Uniforms\r\n\r\n#ifdef INSTANCES\r\nattribute vec4 world0;\r\nattribute vec4 world1;\r\nattribute vec4 world2;\r\nattribute vec4 world3;\r\n#else\r\nuniform mat4 world;\r\n#endif\r\n\r\nuniform mat4 view;\r\nuniform mat4 viewProjection;\r\n\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\n#endif\r\n\r\n#if NUM_BONE_INFLUENCERS > 0\r\n\tuniform mat4 mBones[BonesPerMesh];\r\n\r\n\tattribute vec4 matricesIndices;\r\n\tattribute vec4 matricesWeights;\r\n\t#if NUM_BONE_INFLUENCERS > 4\r\n\t\tattribute vec4 matricesIndicesExtra;\r\n\t\tattribute vec4 matricesWeightsExtra;\r\n\t#endif\r\n#endif\r\n\r\n#ifdef POINTSIZE\r\nuniform float pointSize;\r\n#endif\r\n\r\n// Output\r\nvarying vec3 vPositionW;\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n#ifdef CLIPPLANE\r\nuniform vec4 vClipPlane;\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n#ifdef FOG\r\nvarying float fFogDistance;\r\n#endif\r\n\r\n// Fire\r\nuniform float time;\r\nuniform float speed;\r\n\r\nvarying vec2 vDistortionCoords1;\r\nvarying vec2 vDistortionCoords2;\r\nvarying vec2 vDistortionCoords3;\r\n\r\nvoid main(void) {\r\n\tmat4 finalWorld;\r\n\r\n#ifdef INSTANCES\r\n\tfinalWorld = mat4(world0, world1, world2, world3);\r\n#else\r\n\tfinalWorld = world;\r\n#endif\r\n\r\n#if NUM_BONE_INFLUENCERS > 0\r\n\tmat4 influence;\r\n\tinfluence = mBones[int(matricesIndices[0])] * matricesWeights[0];\r\n\r\n\t#if NUM_BONE_INFLUENCERS > 1\r\n\t\tinfluence += mBones[int(matricesIndices[1])] * matricesWeights[1];\r\n\t#endif \r\n\t#if NUM_BONE_INFLUENCERS > 2\r\n\t\tinfluence += mBones[int(matricesIndices[2])] * matricesWeights[2];\r\n\t#endif\t\r\n\t#if NUM_BONE_INFLUENCERS > 3\r\n\t\tinfluence += mBones[int(matricesIndices[3])] * matricesWeights[3];\r\n\t#endif\t\r\n\r\n\t#if NUM_BONE_INFLUENCERS > 4\r\n\t\tinfluence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];\r\n\t#endif\r\n\t#if NUM_BONE_INFLUENCERS > 5\r\n\t\tinfluence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];\r\n\t#endif\t\r\n\t#if NUM_BONE_INFLUENCERS > 6\r\n\t\tinfluence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];\r\n\t#endif\t\r\n\t#if NUM_BONE_INFLUENCERS > 7\r\n\t\tinfluence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];\r\n\t#endif\t\r\n\r\n\tfinalWorld = finalWorld * influence;\r\n#endif\r\n\r\n\tgl_Position = viewProjection * finalWorld * vec4(position, 1.0);\r\n\r\n\tvec4 worldPos = finalWorld * vec4(position, 1.0);\r\n\tvPositionW = vec3(worldPos);\r\n\r\n#ifdef NORMAL\r\n\tvNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));\r\n#endif\r\n\r\n\t// Texture coordinates\r\n#ifdef DIFFUSE\r\n\tvDiffuseUV = uv;\r\n\tvDiffuseUV.y -= 0.2;\r\n#endif\r\n\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tfClipDistance = dot(worldPos, vClipPlane);\r\n#endif\r\n\r\n\t// Fog\r\n#ifdef FOG\r\n\tfFogDistance = (view * worldPos).z;\r\n#endif\r\n\r\n\t// Vertex color\r\n#ifdef VERTEXCOLOR\r\n\tvColor = color;\r\n#endif\r\n\r\n\t// Point size\r\n#ifdef POINTSIZE\r\n\tgl_PointSize = pointSize;\r\n#endif\r\n\r\n\t// Fire\r\n\tvec3 layerSpeed = vec3(-0.2, -0.52, -0.1) * speed;\r\n\t\r\n\tvDistortionCoords1.x = uv.x;\r\n\tvDistortionCoords1.y = uv.y + layerSpeed.x * time / 1000.0;\r\n\t\r\n\tvDistortionCoords2.x = uv.x;\r\n\tvDistortionCoords2.y = uv.y + layerSpeed.y * time / 1000.0;\r\n\t\r\n\tvDistortionCoords3.x = uv.x;\r\n\tvDistortionCoords3.y = uv.y + layerSpeed.z * time / 1000.0;\r\n}\r\n";
  286. BABYLON.Effect.ShadersStore['firePixelShader'] = "precision highp float;\r\n\r\n// Constants\r\nuniform vec3 vEyePosition;\r\n\r\n// Input\r\nvarying vec3 vPositionW;\r\n\r\n#ifdef NORMAL\r\nvarying vec3 vNormalW;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\nvarying vec4 vColor;\r\n#endif\r\n\r\n// Samplers\r\n#ifdef DIFFUSE\r\nvarying vec2 vDiffuseUV;\r\nuniform sampler2D diffuseSampler;\r\nuniform vec2 vDiffuseInfos;\r\n#endif\r\n\r\n// Fire\r\nuniform sampler2D distortionSampler;\r\nuniform sampler2D opacitySampler;\r\n\r\nvarying vec2 vDistortionCoords1;\r\nvarying vec2 vDistortionCoords2;\r\nvarying vec2 vDistortionCoords3;\r\n\r\n#ifdef CLIPPLANE\r\nvarying float fClipDistance;\r\n#endif\r\n\r\n// Fog\r\n#ifdef FOG\r\n\r\n#define FOGMODE_NONE 0.\r\n#define FOGMODE_EXP 1.\r\n#define FOGMODE_EXP2 2.\r\n#define FOGMODE_LINEAR 3.\r\n#define E 2.71828\r\n\r\nuniform vec4 vFogInfos;\r\nuniform vec3 vFogColor;\r\nvarying float fFogDistance;\r\n\r\nfloat CalcFogFactor()\r\n{\r\n\tfloat fogCoeff = 1.0;\r\n\tfloat fogStart = vFogInfos.y;\r\n\tfloat fogEnd = vFogInfos.z;\r\n\tfloat fogDensity = vFogInfos.w;\r\n\r\n\tif (FOGMODE_LINEAR == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);\r\n\t}\r\n\telse if (FOGMODE_EXP == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);\r\n\t}\r\n\telse if (FOGMODE_EXP2 == vFogInfos.x)\r\n\t{\r\n\t\tfogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);\r\n\t}\r\n\r\n\treturn clamp(fogCoeff, 0.0, 1.0);\r\n}\r\n#endif\r\n\r\nvec4 bx2(vec4 x)\r\n{\r\n return vec4(2.0) * x - vec4(1.0);\r\n}\r\n\r\nvoid main(void) {\r\n\t// Clip plane\r\n#ifdef CLIPPLANE\r\n\tif (fClipDistance > 0.0)\r\n\t\tdiscard;\r\n#endif\r\n\r\n\tvec3 viewDirectionW = normalize(vEyePosition - vPositionW);\r\n\r\n\t// Base color\r\n\tvec4 baseColor = vec4(1., 1., 1., 1.);\r\n\r\n\t// Alpha\r\n\tfloat alpha = 1.0;\r\n\r\n#ifdef DIFFUSE\r\n\t// Fire\r\n\tconst float distortionAmount0 = 0.092;\r\n\tconst float distortionAmount1 = 0.092;\r\n\tconst float distortionAmount2 = 0.092;\r\n\t\r\n\tvec2 heightAttenuation = vec2(0.3, 0.39);\r\n\t\r\n\tvec4 noise0 = texture2D(distortionSampler, vDistortionCoords1);\r\n\tvec4 noise1 = texture2D(distortionSampler, vDistortionCoords2);\r\n\tvec4 noise2 = texture2D(distortionSampler, vDistortionCoords3);\r\n\t\r\n\tvec4 noiseSum = bx2(noise0) * distortionAmount0 + bx2(noise1) * distortionAmount1 + bx2(noise2) * distortionAmount2;\r\n\t\r\n\tvec4 perturbedBaseCoords = vec4(vDiffuseUV, 0.0, 1.0) + noiseSum * (vDiffuseUV.y * heightAttenuation.x + heightAttenuation.y);\r\n\t\r\n\tvec4 opacityColor = texture2D(opacitySampler, perturbedBaseCoords.xy);\r\n\t\r\n#ifdef ALPHATEST\r\n\tif (opacityColor.r < 0.1)\r\n\t\tdiscard;\r\n#endif\r\n\t\r\n\tbaseColor = texture2D(diffuseSampler, perturbedBaseCoords.xy) * 2.0;\r\n\tbaseColor *= opacityColor;\r\n\r\n\tbaseColor.rgb *= vDiffuseInfos.y;\r\n#endif\r\n\r\n#ifdef VERTEXCOLOR\r\n\tbaseColor.rgb *= vColor.rgb;\r\n#endif\r\n\r\n\t// Bump\r\n#ifdef NORMAL\r\n\tvec3 normalW = normalize(vNormalW);\r\n#else\r\n\tvec3 normalW = vec3(1.0, 1.0, 1.0);\r\n#endif\r\n\r\n\t// Lighting\r\n\tvec3 diffuseBase = vec3(1.0, 1.0, 1.0);\r\n\r\n#ifdef VERTEXALPHA\r\n\talpha *= vColor.a;\r\n#endif\r\n\r\n\t// Composition\r\n\tvec4 color = vec4(baseColor.rgb, alpha);\r\n\r\n#ifdef FOG\r\n\tfloat fog = CalcFogFactor();\r\n\tcolor.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;\r\n#endif\r\n\r\n\tgl_FragColor = color;\r\n}";