+ particletexture_t *tex;
+ const float *org;
+ float up2[3], v[3], right[3], up[3], fog, ifog, cr, cg, cb, ca, size;
+
+ p = cl.particles + surfacelist[surfacelistindex];
+
+ blendmode = p->type->blendmode;
+
+ cr = p->color[0] * (1.0f / 255.0f);
+ cg = p->color[1] * (1.0f / 255.0f);
+ cb = p->color[2] * (1.0f / 255.0f);
+ ca = p->alpha * (1.0f / 255.0f);
+ if (blendmode == PBLEND_MOD)
+ {
+ cr *= ca;
+ cg *= ca;
+ cb *= ca;
+ cr = min(cr, 1);
+ cg = min(cg, 1);
+ cb = min(cb, 1);
+ ca = 1;
+ }
+ ca /= cl_particles_quality.value;
+ if (p->type->lighting)
+ {
+ float ambient[3], diffuse[3], diffusenormal[3];
+ R_CompleteLightPoint(ambient, diffuse, diffusenormal, p->org, true);
+ cr *= (ambient[0] + 0.5 * diffuse[0]);
+ cg *= (ambient[1] + 0.5 * diffuse[1]);
+ cb *= (ambient[2] + 0.5 * diffuse[2]);
+ }
+ if (fogenabled)
+ {
+ fog = VERTEXFOGTABLE(VectorDistance(p->org, r_vieworigin));
+ ifog = 1 - fog;
+ cr = cr * ifog;
+ cg = cg * ifog;
+ cb = cb * ifog;
+ if (blendmode == PBLEND_ALPHA)
+ {
+ cr += fogcolor[0] * fog;
+ cg += fogcolor[1] * fog;
+ cb += fogcolor[2] * fog;
+ }
+ }
+ c4f[0] = c4f[4] = c4f[8] = c4f[12] = cr;
+ c4f[1] = c4f[5] = c4f[9] = c4f[13] = cg;
+ c4f[2] = c4f[6] = c4f[10] = c4f[14] = cb;
+ c4f[3] = c4f[7] = c4f[11] = c4f[15] = ca;
+
+ size = p->size * cl_particles_size.value;
+ org = p->org;
+ tex = &particletexture[p->texnum];
+ if (p->type->orientation == PARTICLE_BILLBOARD)
+ {
+ VectorScale(r_viewleft, -size, right);
+ VectorScale(r_viewup, size, up);
+ v3f[ 0] = org[0] - right[0] - up[0];
+ v3f[ 1] = org[1] - right[1] - up[1];
+ v3f[ 2] = org[2] - right[2] - up[2];
+ v3f[ 3] = org[0] - right[0] + up[0];
+ v3f[ 4] = org[1] - right[1] + up[1];
+ v3f[ 5] = org[2] - right[2] + up[2];
+ v3f[ 6] = org[0] + right[0] + up[0];
+ v3f[ 7] = org[1] + right[1] + up[1];
+ v3f[ 8] = org[2] + right[2] + up[2];
+ v3f[ 9] = org[0] + right[0] - up[0];
+ v3f[10] = org[1] + right[1] - up[1];
+ v3f[11] = org[2] + right[2] - up[2];
+ t2f[0] = tex->s1;t2f[1] = tex->t2;
+ t2f[2] = tex->s1;t2f[3] = tex->t1;
+ t2f[4] = tex->s2;t2f[5] = tex->t1;
+ t2f[6] = tex->s2;t2f[7] = tex->t2;
+ }
+ else if (p->type->orientation == PARTICLE_ORIENTED_DOUBLESIDED)