+static void RSurfShader_Wall_Pass_Fog(msurface_t *s)
+{
+ int i;
+ surfvertex_t *v;
+ surfvert_t *sv;
+ rmeshinfo_t m;
+ vec3_t diff;
+
+ memset(&m, 0, sizeof(m));
+ if (currentrenderentity->effects & EF_ADDITIVE)
+ m.transparent = true;
+ else if (currentrenderentity != &cl_entities[0].render && (s->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1))
+ m.transparent = true;
+ else
+ m.transparent = false;
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE;
+ m.numtriangles = s->mesh.numtriangles;
+ m.numverts = s->mesh.numverts;
+ m.index = s->mesh.index;
+ m.color = &svert[0].c[0];
+ m.colorstep = sizeof(surfvert_t);
+ m.tex[0] = R_GetTexture(s->currenttexture->fogtexture);
+ m.texcoords[0] = &s->mesh.vertex->st[0];
+ m.texcoordstep[0] = sizeof(surfvertex_t);
+ if (softwaretransform_complexity)
+ {
+ m.vertex = &svert[0].v[0];
+ m.vertexstep = sizeof(surfvert_t);
+ for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+ {
+ softwaretransform(v->v, sv->v);
+ VectorSubtract(sv->v, r_origin, diff);
+ sv->c[0] = fogcolor[0];
+ sv->c[1] = fogcolor[1];
+ sv->c[2] = fogcolor[2];
+ sv->c[3] = currentrenderentity->alpha * exp(fogdensity/DotProduct(diff,diff));
+ }
+ }
+ else
+ {
+ m.vertex = &s->mesh.vertex->v[0];
+ m.vertexstep = sizeof(surfvertex_t);
+ for (i = 0, sv = svert, v = s->mesh.vertex;i < m.numverts;i++, sv++, v++)
+ {
+ VectorSubtract(v->v, r_origin, diff);
+ sv->c[0] = fogcolor[0];
+ sv->c[1] = fogcolor[1];
+ sv->c[2] = fogcolor[2];
+ sv->c[3] = currentrenderentity->alpha * exp(fogdensity/DotProduct(diff,diff));
+ }
+ }
+ R_Mesh_Draw(&m);
+}