]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
no more warping meshs of any kind
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 21 Aug 2002 00:10:30 +0000 (00:10 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 21 Aug 2002 00:10:30 +0000 (00:10 +0000)
sky is always of the masked variety if enabled at all
water does not move
R_Mesh_Draw is no longer used by gl_rsurf at all

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2268 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c
gl_rsurf.c
menu.c
model_brush.c
model_shared.h
r_sky.c
render.h

index 653d515c0c5ef499ce67fd5d5230fc89055401e4..a8c8d056ebae58df717882bba917afd7513f4163 100644 (file)
@@ -57,7 +57,6 @@ cvar_t r_speeds = {0, "r_speeds","0"};
 cvar_t r_fullbright = {0, "r_fullbright","0"};
 cvar_t r_wateralpha = {CVAR_SAVE, "r_wateralpha","1"};
 cvar_t r_dynamic = {CVAR_SAVE, "r_dynamic","1"};
-cvar_t r_waterripple = {CVAR_SAVE, "r_waterripple","0"};
 cvar_t r_fullbrights = {CVAR_SAVE, "r_fullbrights", "1"};
 
 cvar_t gl_fogenable = {0, "gl_fogenable", "0"};
@@ -240,7 +239,6 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable (&r_fullbrights);
        Cvar_RegisterVariable (&r_wateralpha);
        Cvar_RegisterVariable (&r_dynamic);
-       Cvar_RegisterVariable (&r_waterripple);
        Cvar_RegisterVariable (&r_fullbright);
        Cvar_RegisterVariable (&r_multitexture);
        if (gamemode == GAME_NEHAHRA)
index fdc78f73972db233face969d102a03d23e3ddb3b..fed6a6a72d4916aa3b6591846a56116fcec77613 100644 (file)
@@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 
 #define MAX_LIGHTMAP_SIZE 256
-#define USEMESHBUFFER 1
 
 static unsigned int intblocklights[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*3]; // LordHavoc: *3 for colored lighting
 static float floatblocklights[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*3]; // LordHavoc: *3 for colored lighting
@@ -618,235 +617,70 @@ void R_Stain (vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, i
 =============================================================
 */
 
-
-static float turbsin[256] =
-{
-       #include "gl_warp_sin.h"
-};
-#define TURBSCALE (256.0 / (2 * M_PI))
-
-// only need to hold as many verts as the mesh splitter will allow in model_brush.c
-#define MAX_SURFVERTS 3072
-typedef struct
-{
-       float v[4];
-       float st[2];
-       float uv[2];
-       float c[4];
-}
-surfvert_t;
-static surfvert_t svert[MAX_SURFVERTS]; // used by the following functions
-
 static void RSurfShader_Sky(msurface_t *firstsurf)
 {
        msurface_t *surf;
        int i;
-       float number, length, dir[3], speedscale;
        surfvertex_t *v;
-       surfvert_t *sv;
        surfmesh_t *mesh;
-       rmeshinfo_t m;
+       rmeshbufferinfo_t m;
+       float cr, cg, cb, ca;
+       float *outv, *outc;
 
        // LordHavoc: HalfLife maps have freaky skypolys...
        if (currentrenderentity->model->ishlbsp)
                return;
 
-       if (skyrendermasked)
+       if (skyrendernow)
        {
-               if (skyrendernow)
-               {
-                       skyrendernow = false;
+               skyrendernow = false;
+               if (skyrendermasked)
                        R_Sky();
-               }
-               for (surf = firstsurf;surf;surf = surf->chain)
+       }
+       for (surf = firstsurf;surf;surf = surf->chain)
+       {
+               // draw depth-only polys
+               memset(&m, 0, sizeof(m));
+               m.transparent = false;
+               if (skyrendermasked)
                {
-                       // draw depth-only polys
-                       memset(&m, 0, sizeof(m));
-                       m.transparent = false;
                        m.blendfunc1 = GL_ZERO;
                        m.blendfunc2 = GL_ONE;
                        m.depthwrite = true;
-                       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-                       {
-                               m.numtriangles = mesh->numtriangles;
-                               m.numverts = mesh->numverts;
-                               m.index = mesh->index;
-                               if (softwaretransform_complexity)
-                               {
-                                       m.vertex = &svert[0].v[0];
-                                       m.vertexstep = sizeof(surfvert_t);
-                                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                                               softwaretransform(v->v, sv->v);
-                               }
-                               else
-                               {
-                                       m.vertex = &mesh->vertex[0].v[0];
-                                       m.vertexstep = sizeof(surfvertex_t);
-                               }
-                               R_Mesh_Draw(&m);
-                       }
                }
-       }
-       else if (skyrenderglquake)
-       {
-               for (surf = firstsurf;surf;surf = surf->chain)
+               else
                {
-                       memset(&m, 0, sizeof(m));
-                       m.transparent = false;
                        m.blendfunc1 = GL_ONE;
                        m.blendfunc2 = GL_ZERO;
-                       m.vertex = &svert[0].v[0];
-                       m.vertexstep = sizeof(surfvert_t);
-                       m.cr = 1;
-                       m.cg = 1;
-                       m.cb = 1;
-                       m.ca = 1;
-                       m.tex[0] = R_GetTexture(solidskytexture);
-                       m.texcoords[0] = &svert[0].st[0];
-                       m.texcoordstep[0] = sizeof(surfvert_t);
-                       speedscale = cl.time * (8.0/128.0);
-                       speedscale -= (int)speedscale;
-                       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-                       {
-                               m.numtriangles = mesh->numtriangles;
-                               m.numverts = mesh->numverts;
-                               m.index = mesh->index;
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       softwaretransform(v->v, sv->v);
-                                       VectorSubtract (sv->v, r_origin, dir);
-                                       // flatten the sphere
-                                       dir[2] *= 3;
-
-                                       number = DotProduct(dir, dir);
-                                       #if SLOWMATH
-                                       length = 3.0f / sqrt(number);
-                                       #else
-                                       *((int *)&length) = 0x5f3759df - ((* (int *) &number) >> 1);
-                                       length = 3.0f * (length * (1.5f - (number * 0.5f * length * length)));
-                                       #endif
-
-                                       sv->st[0] = speedscale + dir[0] * length;
-                                       sv->st[1] = speedscale + dir[1] * length;
-                               }
-                               R_Mesh_Draw(&m);
-                       }
+                       m.depthwrite = false;
                }
-       }
-       else
-       {
-               for (surf = firstsurf;surf;surf = surf->chain)
+               for (mesh = surf->mesh;mesh;mesh = mesh->chain)
                {
-                       // flat color
-                       memset(&m, 0, sizeof(m));
-                       m.transparent = false;
-                       m.blendfunc1 = GL_ONE;
-                       m.blendfunc2 = GL_ZERO;
-                       m.cr = fogcolor[0];
-                       m.cg = fogcolor[1];
-                       m.cb = fogcolor[2];
-                       m.ca = 1;
-                       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-                       {
-                               m.numtriangles = mesh->numtriangles;
-                               m.numverts = mesh->numverts;
-                               m.index = mesh->index;
-                               if (softwaretransform_complexity)
-                               {
-                                       m.vertex = &svert[0].v[0];
-                                       m.vertexstep = sizeof(surfvert_t);
-                                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                                               softwaretransform(v->v, sv->v);
-                               }
-                               else
-                               {
-                                       m.vertex = &mesh->vertex[0].v[0];
-                                       m.vertexstep = sizeof(surfvertex_t);
-                               }
-                               R_Mesh_Draw(&m);
-                       }
-               }
-       }
-       if (skyrenderglquake)
-       {
-               for (surf = firstsurf;surf;surf = surf->chain)
-               {
-                       memset(&m, 0, sizeof(m));
-                       m.transparent = false;
-                       m.blendfunc1 = GL_SRC_ALPHA;
-                       m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-                       m.vertex = &svert[0].v[0];
-                       m.vertexstep = sizeof(surfvert_t);
-                       m.cr = 1;
-                       m.cg = 1;
-                       m.cb = 1;
-                       m.ca = 1;
-                       m.tex[0] = R_GetTexture(alphaskytexture);
-                       m.texcoords[0] = &svert[0].st[0];
-                       m.texcoordstep[0] = sizeof(surfvert_t);
-                       speedscale = cl.time * (16.0/128.0);
-                       speedscale -= (int)speedscale;
-                       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+                       m.numtriangles = mesh->numtriangles;
+                       m.numverts = mesh->numverts;
+                       if (R_Mesh_Draw_GetBuffer(&m))
                        {
-                               m.numtriangles = mesh->numtriangles;
-                               m.numverts = mesh->numverts;
-                               m.index = mesh->index;
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
+                               cr = fogcolor[0] * m.colorscale;
+                               cg = fogcolor[1] * m.colorscale;
+                               cb = fogcolor[2] * m.colorscale;
+                               ca = 1;
+                               memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
+                               for (i = 0, v = mesh->vertex, outv = m.vertex;i < m.numverts;i++, v++, outv += 4, outc += 4)
                                {
-                                       softwaretransform(v->v, sv->v);
-                                       VectorSubtract (sv->v, r_origin, dir);
-                                       // flatten the sphere
-                                       dir[2] *= 3;
-
-                                       number = DotProduct(dir, dir);
-                                       #if SLOWMATH
-                                       length = 3.0f / sqrt(number);
-                                       #else
-                                       *((int *)&length) = 0x5f3759df - ((* (int *) &number) >> 1);
-                                       length = 3.0f * (length * (1.5f - (number * 0.5f * length * length)));
-                                       #endif
-
-                                       sv->st[0] = speedscale + dir[0] * length;
-                                       sv->st[1] = speedscale + dir[1] * length;
+                                       softwaretransform(v->v, outv);
                                }
-                               R_Mesh_Draw(&m);
-                       }
-               }
-       }
-}
-
-static int RSurf_Light(int *dlightbits, int numverts)
-{
-       float f;
-       int i, l, lit = false;
-       rdlight_t *rd;
-       vec3_t lightorigin;
-       surfvert_t *sv;
-       for (l = 0;l < r_numdlights;l++)
-       {
-               if (dlightbits[l >> 5] & (1 << (l & 31)))
-               {
-                       rd = &r_dlight[l];
-                       // FIXME: support softwareuntransform here and make bmodels use hardware transform?
-                       VectorCopy(rd->origin, lightorigin);
-                       for (i = 0, sv = svert;i < numverts;i++, sv++)
-                       {
-                               f = VectorDistance2(sv->v, lightorigin);
-                               if (f < rd->cullradius2)
+                               for (i = 0, outc = m.color;i < m.numverts;i++, outc += 4)
                                {
-                                       f = (1.0f / f) - rd->subtract;
-                                       sv->c[0] += rd->light[0] * f;
-                                       sv->c[1] += rd->light[1] * f;
-                                       sv->c[2] += rd->light[2] * f;
-                                       lit = true;
+                                       outc[0] = cr;
+                                       outc[1] = cg;
+                                       outc[2] = cb;
+                                       outc[3] = ca;
                                }
                        }
                }
        }
-       return lit;
 }
 
-#if USEMESHBUFFER
 static int RSurf_LightSeparate(int *dlightbits, int numverts, float *vert, float *color)
 {
        float f, *v, *c;
@@ -896,18 +730,17 @@ static int RSurf_LightCheck(int *dlightbits, surfmesh_t *mesh)
        }
        return false;
 }
-#endif
 
 static void RSurfShader_Water_Pass_Base(msurface_t *surf)
 {
-#if 0
        int i, size3;
        surfvertex_t *v;
-       float *outv, *outc, *outst, *outuv, cl, ca, diff[3];
+       float *outv, *outc, *outst, cl, diff[3];
        float base[3], scale, f;
        qbyte *lm;
        surfmesh_t *mesh;
        rmeshbufferinfo_t m;
+       float alpha = currentrenderentity->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
        memset(&m, 0, sizeof(m));
        if (currentrenderentity->effects & EF_ADDITIVE)
        {
@@ -915,7 +748,7 @@ static void RSurfShader_Water_Pass_Base(msurface_t *surf)
                m.blendfunc1 = GL_SRC_ALPHA;
                m.blendfunc2 = GL_ONE;
        }
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
+       else if (surf->currenttexture->fogtexture != NULL || alpha < 1)
        {
                m.transparent = true;
                m.blendfunc1 = GL_SRC_ALPHA;
@@ -930,255 +763,141 @@ static void RSurfShader_Water_Pass_Base(msurface_t *surf)
        m.depthwrite = false;
        m.depthdisable = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-
-       size3 = ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3;
-
-       base[0] = base[1] = base[2] = currentrenderentity->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f) + surf->flags & SURF_LIGHTMAP ? 0 : ;
-
-       ca = currentrenderentity->alpha;
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+       if (surf->flags & SURF_DRAWFULLBRIGHT || currentrenderentity->effects & EF_FULLBRIGHT)
        {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-
-               if (R_Mesh_Draw_GetBuffer(&m))
+               for (mesh = surf->mesh;mesh;mesh = mesh->chain)
                {
-                       cl = m.colorscale;
-                       memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
-
-                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                       m.numtriangles = mesh->numtriangles;
+                       m.numverts = mesh->numverts;
+                       if (R_Mesh_Draw_GetBuffer(&m))
                        {
-                               softwaretransform(v->v, outv);
-                               outv[3] = 1;
-                               VectorCopy(base, outc);
-                               outc[3] = ca;
-                               outst[0] = v->st[0];
-                               outst[1] = v->st[1];
+                               base[0] = base[1] = base[2] = 1.0f * m.colorscale;
+                               memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
+                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
+                               {
+                                       softwaretransform(v->v, outv);
+                                       outv[3] = 1;
+                                       VectorCopy(base, outc);
+                                       outc[3] = alpha;
+                                       outst[0] = v->st[0];
+                                       outst[1] = v->st[1];
+                                       if (fogenabled)
+                                       {
+                                               VectorSubtract(outv, r_origin, diff);
+                                               f = 1 - exp(fogdensity/DotProduct(diff, diff));
+                                               VectorScale(outc, f, outc);
+                                       }
+                               }
                        }
-
-                       if (surf->dlightframe == r_framecount)
-                               RSurf_LightSeparate(surf->dlightbits, m.numverts, m.vertex, m.color);
-
-                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color;i < m.numverts;i++, v++, outv += 4, outc += 4)
+               }
+       }
+       else
+       {
+               size3 = ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3;
+               base[0] = base[1] = base[2] = (r_ambient.value * (1.0f / 64.0f) + ((surf->flags & SURF_LIGHTMAP) ? 0 : 0.5f));
+               for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+               {
+                       m.numtriangles = mesh->numtriangles;
+                       m.numverts = mesh->numverts;
+                       if (R_Mesh_Draw_GetBuffer(&m))
                        {
-                               if (surf->flags & SURF_LIGHTMAP)
-                               if (surf->styles[0] != 255)
+                               cl = m.colorscale;
+                               memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
+                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                {
-                                       lm = surf->samples + v->lightmapoffset;
-                                       scale = d_lightstylevalue[surf->styles[0]] * (1.0f / 32768.0f);
-                                       VectorMA(outc, scale, lm, outc);
-                                       if (surf->styles[1] != 255)
+                                       softwaretransform(v->v, outv);
+                                       outv[3] = 1;
+                                       VectorCopy(base, outc);
+                                       outc[3] = alpha;
+                                       outst[0] = v->st[0];
+                                       outst[1] = v->st[1];
+                               }
+                               if (surf->dlightframe == r_framecount)
+                                       RSurf_LightSeparate(surf->dlightbits, m.numverts, m.vertex, m.color);
+                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color;i < m.numverts;i++, v++, outv += 4, outc += 4)
+                               {
+                                       if (surf->flags & SURF_LIGHTMAP)
+                                       if (surf->styles[0] != 255)
                                        {
-                                               lm += size3;
-                                               scale = d_lightstylevalue[surf->styles[1]] * (1.0f / 32768.0f);
+                                               lm = surf->samples + v->lightmapoffset;
+                                               scale = d_lightstylevalue[surf->styles[0]] * (1.0f / 32768.0f);
                                                VectorMA(outc, scale, lm, outc);
-                                               if (surf->styles[2] != 255)
+                                               if (surf->styles[1] != 255)
                                                {
                                                        lm += size3;
-                                                       scale = d_lightstylevalue[surf->styles[2]] * (1.0f / 32768.0f);
+                                                       scale = d_lightstylevalue[surf->styles[1]] * (1.0f / 32768.0f);
                                                        VectorMA(outc, scale, lm, outc);
-                                                       if (surf->styles[3] != 255)
+                                                       if (surf->styles[2] != 255)
                                                        {
                                                                lm += size3;
-                                                               scale = d_lightstylevalue[surf->styles[3]] * (1.0f / 32768.0f);
+                                                               scale = d_lightstylevalue[surf->styles[2]] * (1.0f / 32768.0f);
                                                                VectorMA(outc, scale, lm, outc);
+                                                               if (surf->styles[3] != 255)
+                                                               {
+                                                                       lm += size3;
+                                                                       scale = d_lightstylevalue[surf->styles[3]] * (1.0f / 32768.0f);
+                                                                       VectorMA(outc, scale, lm, outc);
+                                                               }
                                                        }
                                                }
                                        }
+                                       if (fogenabled)
+                                       {
+                                               VectorSubtract(outv, r_origin, diff);
+                                               f = cl * (1 - exp(fogdensity/DotProduct(diff, diff)));
+                                               VectorScale(outc, f, outc);
+                                       }
+                                       else
+                                               VectorScale(outc, cl, outc);
                                }
-                               if (fogenabled)
-                               {
-                                       VectorSubtract(outv, r_origin, diff);
-                                       f = cl * (1 - exp(fogdensity/DotProduct(diff, diff)));
-                                       VectorScale(outc, f, outc);
-                               }
-                               else
-                                       VectorScale(outc, cl, outc);
                        }
                }
        }
+}
+
+static void RSurfShader_Water_Pass_Fog(msurface_t *surf)
+{
        int i;
        surfvertex_t *v;
-       float *outv, *outc, *outst, *outuv, cl, ca, diff[3];
+       float *outv, *outc, *outst, diff[3];
+       float base[3], f;
        surfmesh_t *mesh;
        rmeshbufferinfo_t m;
+       float alpha = currentrenderentity->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
        memset(&m, 0, sizeof(m));
-       if (currentrenderentity->effects & EF_ADDITIVE)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
-       }
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       }
-       else
-       {
-               m.transparent = false;
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
-       }
+       m.transparent = currentrenderentity->effects & EF_ADDITIVE || surf->currenttexture->fogtexture != NULL || alpha < 1;
+       m.blendfunc1 = GL_SRC_ALPHA;
+       m.blendfunc2 = GL_ONE;
        m.depthwrite = false;
        m.depthdisable = false;
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.tex[1] = R_GetTexture(surf->lightmaptexture);
-       ca = currentrenderentity->alpha;
+       m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                m.numtriangles = mesh->numtriangles;
                m.numverts = mesh->numverts;
-
                if (R_Mesh_Draw_GetBuffer(&m))
                {
-                       cl = (float) (1 << lightscalebit) * m.colorscale;
+                       VectorScale(fogcolor, m.colorscale, base);
                        memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
-                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color;i < m.numverts;i++, v++, outv += 4, outc += 4)
                        {
                                softwaretransform(v->v, outv);
-                               if (r_waterripple.value)
-                                       outv[2] += r_waterripple.value * (1.0f / 64.0f) * turbsin[(int)((v->v[0]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255] * turbsin[(int)((v->v[1]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255];
                                outv[3] = 1;
-                               if (fogenabled)
-                               {
-                                       VectorSubtract(outv, r_origin, diff);
-                                       outc[0] = outc[1] = outc[2] = cl * (1 - exp(fogdensity/DotProduct(diff, diff)));
-                               }
-                               else
-                                       outc[0] = outc[1] = outc[2] = cl;
-                               outc[3] = ca;
-                               outst[0] = v->st[0];
-                               outst[1] = v->st[1];
-                               outuv[0] = v->uv[0];
-                               outuv[1] = v->uv[1];
+                               VectorSubtract(outv, r_origin, diff);
+                               f = exp(fogdensity/DotProduct(diff, diff));
+                               VectorScale(base, f, outc);
+                               outc[3] = alpha;
                        }
-               }
-       }
-#else
-       int i;
-       float diff[3], alpha, ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-       alpha = currentrenderentity->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
-
-       memset(&m, 0, sizeof(m));
-       if (alpha != 1 || surf->currenttexture->fogtexture != NULL)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       }
-       else
-       {
-               m.transparent = false;
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
-       }
-       m.vertex = &svert[0].v[0];
-       m.vertexstep = sizeof(surfvert_t);
-       m.color = &svert[0].c[0];
-       m.colorstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.texcoords[0] = &svert[0].st[0];
-       m.texcoordstep[0] = sizeof(surfvert_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-               {
-                       softwaretransform(v->v, sv->v);
-                       if (r_waterripple.value)
-                               sv->v[2] += r_waterripple.value * (1.0f / 64.0f) * turbsin[(int)((v->v[0]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255] * turbsin[(int)((v->v[1]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255];
-                       if (surf->flags & SURF_DRAWFULLBRIGHT)
-                       {
-                               sv->c[0] = 1;
-                               sv->c[1] = 1;
-                               sv->c[2] = 1;
-                               sv->c[3] = alpha;
-                       }
-                       else
-                       {
-                               sv->c[0] = 0.5f;
-                               sv->c[1] = 0.5f;
-                               sv->c[2] = 0.5f;
-                               sv->c[3] = alpha;
-                       }
-                       sv->st[0] = (v->st[0] + turbsin[(int)((v->st[1]*0.125f+cl.time) * TURBSCALE) & 255]) * (1.0f / 64.0f);
-                       sv->st[1] = (v->st[1] + turbsin[(int)((v->st[0]*0.125f+cl.time) * TURBSCALE) & 255]) * (1.0f / 64.0f);
-               }
-               if (surf->dlightframe == r_framecount && !(surf->flags & SURF_DRAWFULLBRIGHT))
-                       RSurf_Light(surf->dlightbits, m.numverts);
-               if (fogenabled && (surf->flags & SURF_DRAWNOALPHA))
-               {
-                       for (i = 0, sv = svert;i < m.numverts;i++, sv++)
-                       {
-                               VectorSubtract(sv->v, r_origin, diff);
-                               ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                               sv->c[0] *= ifog;
-                               sv->c[1] *= ifog;
-                               sv->c[2] *= ifog;
-                       }
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
-}
-
-static void RSurfShader_Water_Pass_Fog(msurface_t *surf)
-{
-#if 0
-#else
-       int i;
-       float alpha;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-       vec3_t diff;
-       alpha = currentrenderentity->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
-
-       memset(&m, 0, sizeof(m));
-       m.transparent = alpha != 1 || surf->currenttexture->fogtexture != NULL;
-       m.blendfunc1 = GL_SRC_ALPHA;
-       m.blendfunc2 = GL_ONE;
-       m.vertex = &svert[0].v[0];
-       m.vertexstep = sizeof(surfvert_t);
-       m.color = &svert[0].c[0];
-       m.colorstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
-       m.texcoords[0] = &svert[0].st[0];
-       m.texcoordstep[0] = sizeof(surfvert_t);
-
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-               {
-                       softwaretransform(v->v, sv->v);
-                       if (r_waterripple.value)
-                               sv->v[2] += r_waterripple.value * (1.0f / 64.0f) * turbsin[(int)((v->v[0]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255] * turbsin[(int)((v->v[1]*(1.0f/32.0f)+cl.time) * TURBSCALE) & 255];
                        if (m.tex[0])
                        {
-                               sv->st[0] = (v->st[0] + turbsin[(int)((v->st[1]*0.125f+cl.time) * TURBSCALE) & 255]) * (1.0f / 64.0f);
-                               sv->st[1] = (v->st[1] + turbsin[(int)((v->st[0]*0.125f+cl.time) * TURBSCALE) & 255]) * (1.0f / 64.0f);
+                               for (i = 0, v = mesh->vertex, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outst += 2)
+                               {
+                                       outst[0] = v->st[0];
+                                       outst[1] = v->st[1];
+                               }
                        }
-                       VectorSubtract(sv->v, r_origin, diff);
-                       sv->c[0] = fogcolor[0];
-                       sv->c[1] = fogcolor[1];
-                       sv->c[2] = fogcolor[2];
-                       sv->c[3] = alpha * exp(fogdensity/DotProduct(diff, diff));
                }
-               R_Mesh_Draw(&m);
        }
-#endif
 }
 
 static void RSurfShader_Water(msurface_t *firstsurf)
@@ -1193,7 +912,6 @@ static void RSurfShader_Water(msurface_t *firstsurf)
 
 static void RSurfShader_Wall_Pass_BaseMTex(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outst, *outuv, cl, ca, diff[3];
@@ -1298,103 +1016,10 @@ static void RSurfShader_Wall_Pass_BaseMTex(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       float diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       if (currentrenderentity->effects & EF_ADDITIVE)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
-       }
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       }
-       else
-       {
-               m.transparent = false;
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
-       }
-       m.cr = m.cg = m.cb = (float) (1 << lightscalebit);
-       m.ca = currentrenderentity->alpha;
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.tex[1] = R_GetTexture(surf->lightmaptexture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       m.texcoordstep[1] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               m.texcoords[1] = &mesh->vertex->uv[0];
-               if (fogenabled)
-               {
-                       m.color = &svert[0].c[0];
-                       m.colorstep = sizeof(surfvert_t);
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       softwaretransform(v->v, sv->v);
-                                       VectorSubtract(sv->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       VectorSubtract(v->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-               }
-               else
-               {
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                                       softwaretransform(v->v, sv->v);
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                       }
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_BaseTexture(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outst, cl, ca;
@@ -1425,65 +1050,28 @@ static void RSurfShader_Wall_Pass_BaseTexture(msurface_t *surf)
                                        outv[3] = 1;
                                        outc[0] = outc[1] = outc[2] = cl;
                                        outc[3] = ca;
-                                       outst[0] = v->st[0];
-                                       outst[1] = v->st[1];
-                               }
-                       }
-                       else
-                       {
-                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
-                               {
-                                       VectorCopy(v->v, outv);
-                                       outv[3] = 1;
-                                       outc[0] = outc[1] = outc[2] = cl;
-                                       outc[3] = ca;
-                                       outst[0] = v->st[0];
-                                       outst[1] = v->st[1];
-                               }
-                       }
-               }
-       }
-#else
-       int i;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       m.transparent = false;
-       m.blendfunc1 = GL_ONE;
-       m.blendfunc2 = GL_ZERO;
-       m.cr = m.cg = m.cb = (float) (1 << v_overbrightbits.integer);
-       m.ca = 1;
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               if (softwaretransform_complexity)
-               {
-                       m.vertex = &svert[0].v[0];
-                       m.vertexstep = sizeof(surfvert_t);
-                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               softwaretransform(v->v, sv->v);
-               }
-               else
-               {
-                       m.vertex = &mesh->vertex->v[0];
-                       m.vertexstep = sizeof(surfvertex_t);
+                                       outst[0] = v->st[0];
+                                       outst[1] = v->st[1];
+                               }
+                       }
+                       else
+                       {
+                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
+                               {
+                                       VectorCopy(v->v, outv);
+                                       outv[3] = 1;
+                                       outc[0] = outc[1] = outc[2] = cl;
+                                       outc[3] = ca;
+                                       outst[0] = v->st[0];
+                                       outst[1] = v->st[1];
+                               }
+                       }
                }
-               R_Mesh_Draw(&m);
        }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_BaseLightmap(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outuv, cl, ca, diff[3];
@@ -1564,88 +1152,13 @@ static void RSurfShader_Wall_Pass_BaseLightmap(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       float diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       m.transparent = false;
-       m.blendfunc1 = GL_ZERO;
-       m.blendfunc2 = GL_SRC_COLOR;
-       m.cr = m.cg = m.cb = (float) (1 << v_overbrightbits.integer);
-       m.ca = 1;
-       m.tex[0] = R_GetTexture(surf->lightmaptexture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->uv[0];
-               if (fogenabled)
-               {
-                       m.color = &svert[0].c[0];
-                       m.colorstep = sizeof(surfvert_t);
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       softwaretransform(v->v, sv->v);
-                                       VectorSubtract(sv->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       VectorSubtract(v->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-               }
-               else
-               {
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                                       softwaretransform(v->v, sv->v);
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                       }
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i, size3;
        surfvertex_t *v;
-       float *outv, *outc, *outst, *outuv, cl, ca, diff[3];
+       float *outv, *outc, *outst, cl, ca, diff[3];
        float base[3], scale, f;
        qbyte *lm;
        surfmesh_t *mesh;
@@ -1692,7 +1205,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                        {
                                if (softwaretransform_complexity)
                                {
-                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                        {
                                                softwaretransform(v->v, outv);
                                                outv[3] = 1;
@@ -1705,7 +1218,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                                }
                                else
                                {
-                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                        {
                                                VectorCopy(v->v, outv);
                                                outv[3] = 1;
@@ -1721,7 +1234,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                        {
                                if (softwaretransform_complexity)
                                {
-                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                        {
                                                softwaretransform(v->v, outv);
                                                outv[3] = 1;
@@ -1733,7 +1246,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                                }
                                else
                                {
-                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                                       for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                        {
                                                VectorCopy(v->v, outv);
                                                outv[3] = 1;
@@ -1785,104 +1298,10 @@ static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *surf)
                        }
                }
        }
-#else
-       int i, size3;
-       float c[3], base[3], scale, diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-       qbyte *lm;
-
-       size3 = ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3;
-
-       base[0] = base[1] = base[2] = currentrenderentity->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 128.0f);
-
-       memset(&m, 0, sizeof(m));
-       if (currentrenderentity->effects & EF_ADDITIVE)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
-       }
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       }
-       else
-       {
-               m.transparent = false;
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
-       }
-       m.vertex = &svert[0].v[0];
-       m.vertexstep = sizeof(surfvert_t);
-       m.color = &svert[0].c[0];
-       m.colorstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-               {
-                       softwaretransform(v->v, sv->v);
-                       VectorCopy(base, c);
-                       if (surf->styles[0] != 255)
-                       {
-                               lm = surf->samples + v->lightmapoffset;
-                               scale = d_lightstylevalue[surf->styles[0]] * (1.0f / 32768.0f);
-                               VectorMA(c, scale, lm, c);
-                               if (surf->styles[1] != 255)
-                               {
-                                       lm += size3;
-                                       scale = d_lightstylevalue[surf->styles[1]] * (1.0f / 32768.0f);
-                                       VectorMA(c, scale, lm, c);
-                                       if (surf->styles[2] != 255)
-                                       {
-                                               lm += size3;
-                                               scale = d_lightstylevalue[surf->styles[2]] * (1.0f / 32768.0f);
-                                               VectorMA(c, scale, lm, c);
-                                               if (surf->styles[3] != 255)
-                                               {
-                                                       lm += size3;
-                                                       scale = d_lightstylevalue[surf->styles[3]] * (1.0f / 32768.0f);
-                                                       VectorMA(c, scale, lm, c);
-                                               }
-                                       }
-                               }
-                       }
-                       sv->c[0] = c[0];
-                       sv->c[1] = c[1];
-                       sv->c[2] = c[2];
-                       sv->c[3] = currentrenderentity->alpha;
-               }
-               if (surf->dlightframe == r_framecount)
-                       RSurf_Light(surf->dlightbits, m.numverts);
-               if (fogenabled)
-               {
-                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                       {
-                               VectorSubtract(sv->v, r_origin, diff);
-                               ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                               sv->c[0] *= ifog;
-                               sv->c[1] *= ifog;
-                               sv->c[2] *= ifog;
-                       }
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_BaseFullbright(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outst, cl, ca, diff[3];
@@ -1978,76 +1397,13 @@ static void RSurfShader_Wall_Pass_BaseFullbright(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       float diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       if (currentrenderentity->effects & EF_ADDITIVE)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE;
-       }
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
-       {
-               m.transparent = true;
-               m.blendfunc1 = GL_SRC_ALPHA;
-               m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       }
-       else
-       {
-               m.transparent = false;
-               m.blendfunc1 = GL_ONE;
-               m.blendfunc2 = GL_ZERO;
-       }
-       m.vertex = &svert[0].v[0];
-       m.vertexstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               if (fogenabled)
-               {
-                       m.color = &svert[0].c[0];
-                       m.colorstep = sizeof(surfvert_t);
-                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                       {
-                               softwaretransform(v->v, sv->v);
-                               VectorSubtract(sv->v, r_origin, diff);
-                               ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                               sv->c[0] = ifog;
-                               sv->c[1] = ifog;
-                               sv->c[2] = ifog;
-                               sv->c[3] = currentrenderentity->alpha;
-                       }
-               }
-               else
-               {
-                       m.cr = m.cg = m.cb = 1;
-                       m.ca = currentrenderentity->alpha;
-                       for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               softwaretransform(v->v, sv->v);
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_Light(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
-       float *outv, *outc, *outst, *outuv, cl, ca, diff[3], f;
+       float *outv, *outc, *outst, cl, ca, diff[3], f;
        surfmesh_t *mesh;
        rmeshbufferinfo_t m;
 
@@ -2090,7 +1446,7 @@ static void RSurfShader_Wall_Pass_Light(msurface_t *surf)
                        {
                                cl = m.colorscale;
                                memcpy(m.index, mesh->index, m.numtriangles * sizeof(int[3]));
-                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0], outuv = m.texcoords[1];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2, outuv += 2)
+                               for (i = 0, v = mesh->vertex, outv = m.vertex, outc = m.color, outst = m.texcoords[0];i < m.numverts;i++, v++, outv += 4, outc += 4, outst += 2)
                                {
                                        softwaretransform(v->v, outv);
                                        outv[3] = 1;
@@ -2115,65 +1471,10 @@ static void RSurfShader_Wall_Pass_Light(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       float diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       if (currentrenderentity->effects & EF_ADDITIVE)
-               m.transparent = true;
-       else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
-               m.transparent = true;
-       else
-               m.transparent = false;
-       m.blendfunc1 = GL_SRC_ALPHA;
-       m.blendfunc2 = GL_ONE;
-       m.vertex = &svert[0].v[0];
-       m.vertexstep = sizeof(surfvert_t);
-       m.color = &svert[0].c[0];
-       m.colorstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->texture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-               {
-                       softwaretransform(v->v, sv->v);
-                       sv->c[0] = 0;
-                       sv->c[1] = 0;
-                       sv->c[2] = 0;
-                       sv->c[3] = currentrenderentity->alpha;
-               }
-               if (RSurf_Light(surf->dlightbits, m.numverts))
-               {
-                       if (fogenabled)
-                       {
-                               for (i = 0, sv = svert;i < m.numverts;i++, sv++)
-                               {
-                                       VectorSubtract(sv->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] *= ifog;
-                                       sv->c[1] *= ifog;
-                                       sv->c[2] *= ifog;
-                               }
-                       }
-                       R_Mesh_Draw(&m);
-               }
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_Glow(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outst, cl, ca, diff[3];
@@ -2221,87 +1522,10 @@ static void RSurfShader_Wall_Pass_Glow(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       float diff[3], ifog;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       surfmesh_t *mesh;
-       rmeshinfo_t m;
-
-       memset(&m, 0, sizeof(m));
-       m.transparent = currentrenderentity->effects & EF_ADDITIVE || surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1;
-       m.blendfunc1 = GL_SRC_ALPHA;
-       m.blendfunc2 = GL_ONE;
-       m.cr = 1;
-       m.cg = 1;
-       m.cb = 1;
-       m.ca = currentrenderentity->alpha;
-       m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               if (fogenabled)
-               {
-                       m.color = &svert[0].c[0];
-                       m.colorstep = sizeof(surfvert_t);
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       softwaretransform(v->v, sv->v);
-                                       VectorSubtract(sv->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                               {
-                                       VectorSubtract(v->v, r_origin, diff);
-                                       ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
-                                       sv->c[0] = m.cr * ifog;
-                                       sv->c[1] = m.cg * ifog;
-                                       sv->c[2] = m.cb * ifog;
-                                       sv->c[3] = m.ca;
-                               }
-                       }
-               }
-               else
-               {
-                       if (softwaretransform_complexity)
-                       {
-                               m.vertex = &svert[0].v[0];
-                               m.vertexstep = sizeof(surfvert_t);
-                               for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
-                                       softwaretransform(v->v, sv->v);
-                       }
-                       else
-                       {
-                               m.vertex = &mesh->vertex->v[0];
-                               m.vertexstep = sizeof(surfvertex_t);
-                       }
-               }
-               R_Mesh_Draw(&m);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Pass_Fog(msurface_t *surf)
 {
-#if USEMESHBUFFER
        int i;
        surfvertex_t *v;
        float *outv, *outc, *outst, cl, ca, diff[3], f;
@@ -2352,58 +1576,6 @@ static void RSurfShader_Wall_Pass_Fog(msurface_t *surf)
                        }
                }
        }
-#else
-       int i;
-       surfvertex_t *v;
-       surfvert_t *sv;
-       rmeshinfo_t m;
-       surfmesh_t *mesh;
-       vec3_t diff;
-
-       memset(&m, 0, sizeof(m));
-       m.transparent = currentrenderentity->effects & EF_ADDITIVE || surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1;
-       m.blendfunc1 = GL_SRC_ALPHA;
-       m.blendfunc2 = GL_ONE;
-       m.color = &svert[0].c[0];
-       m.colorstep = sizeof(surfvert_t);
-       m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
-       m.texcoordstep[0] = sizeof(surfvertex_t);
-       for (mesh = surf->mesh;mesh;mesh = mesh->chain)
-       {
-               m.numtriangles = mesh->numtriangles;
-               m.numverts = mesh->numverts;
-               m.index = mesh->index;
-               m.texcoords[0] = &mesh->vertex->st[0];
-               if (softwaretransform_complexity)
-               {
-                       m.vertex = &svert[0].v[0];
-                       m.vertexstep = sizeof(surfvert_t);
-                       for (i = 0, sv = svert, v = 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 = &mesh->vertex->v[0];
-                       m.vertexstep = sizeof(surfvertex_t);
-                       for (i = 0, sv = svert, v = 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);
-       }
-#endif
 }
 
 static void RSurfShader_Wall_Fullbright(msurface_t *firstsurf)
diff --git a/menu.c b/menu.c
index 35ba6387ac2999f0ef1876f888606e48b8413da6..7ae34c490be588759985a87168f8c3d8bdc0c97e 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1300,7 +1300,7 @@ void M_Menu_Options_AdjustSliders (int dir)
                Cvar_SetValueQuick (&scr_viewsize, bound(30, scr_viewsize.value + dir * 10, 120));
                break;
        case 7:
-               Cvar_SetValueQuick (&r_skyquality, bound(0, r_skyquality.integer + dir, 2));
+               Cvar_SetValueQuick (&r_sky, !r_sky.integer);
                break;
        case 8:
                Cvar_SetValueQuick (&v_overbrightbits, bound(0, v_overbrightbits.integer + dir, 4));
@@ -1392,7 +1392,7 @@ void M_Options_Draw (void)
        M_Print(16, y, "       Effects Options");y += 8;
        M_Print(16, y, "         2D Resolution");M_DrawSlider(220, y, scr_2dresolution.value);y += 8;
        M_Print(16, y, "           Screen size");M_DrawSlider(220, y, (scr_viewsize.value - 30) /(120 - 30));y += 8;
-       M_Print(16, y, "           Sky Quality");M_DrawSlider(220, y, r_skyquality.value / 2);y += 8;
+       M_Print(16, y, "                   Sky");M_DrawCheckbox(220, y, r_sky.integer);y += 8;
        M_Print(16, y, "       Overbright Bits");M_DrawSlider(220, y, (v_overbrightbits.value) / 4);y += 8;
        M_Print(16, y, "       Texture Combine");M_DrawCheckbox(220, y, gl_combine.integer);y += 8;
        M_Print(16, y, "             Dithering");M_DrawCheckbox(220, y, gl_dither.integer);y += 8;
index 3c248fe258ee06fa2948ee422affcd0c920cec1e..5b7e7dd5979a918c5470921634123cdbf2fda7cf 100644 (file)
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 qbyte mod_novis[(MAX_MAP_LEAFS + 7)/ 8];
 
-cvar_t r_subdivide_size = {CVAR_SAVE, "r_subdivide_size", "128"};
+//cvar_t r_subdivide_size = {CVAR_SAVE, "r_subdivide_size", "128"};
 cvar_t halflifebsp = {0, "halflifebsp", "0"};
 cvar_t r_novis = {0, "r_novis", "0"};
 cvar_t r_miplightmaps = {CVAR_SAVE, "r_miplightmaps", "0"};
@@ -40,7 +40,7 @@ Mod_BrushInit
 */
 void Mod_BrushInit (void)
 {
-       Cvar_RegisterVariable(&r_subdivide_size);
+//     Cvar_RegisterVariable(&r_subdivide_size);
        Cvar_RegisterVariable(&halflifebsp);
        Cvar_RegisterVariable(&r_novis);
        Cvar_RegisterVariable(&r_miplightmaps);
@@ -892,6 +892,7 @@ void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
        }
 }
 
+#if 0
 #define MAX_SUBDIVPOLYTRIANGLES 4096
 #define MAX_SUBDIVPOLYVERTS (MAX_SUBDIVPOLYTRIANGLES * 3)
 
@@ -1027,6 +1028,7 @@ void Mod_GenerateWarpMesh (msurface_t *surf)
                v->st[1] = DotProduct (v->v, surf->texinfo->vecs[1]);
        }
 }
+#endif
 
 void Mod_GenerateVertexLitMesh (msurface_t *surf)
 {
@@ -1323,13 +1325,13 @@ static void Mod_LoadFaces (lump_t *l)
                {
                        out->shader = &Cshader_sky;
                        out->samples = NULL;
-                       Mod_GenerateWarpMesh (out);
+                       Mod_GenerateVertexMesh (out);
                }
                else if (out->texinfo->texture->flags & SURF_DRAWTURB)
                {
                        out->shader = &Cshader_water;
                        out->samples = NULL;
-                       Mod_GenerateWarpMesh (out);
+                       Mod_GenerateVertexMesh (out);
                }
                else
                {
@@ -1341,9 +1343,9 @@ static void Mod_LoadFaces (lump_t *l)
                                out->shader = &Cshader_water;
                                out->shader = &Cshader_water;
                                out->samples = NULL;
-                               Mod_GenerateWarpMesh (out);
+                               Mod_GenerateVertexMesh (out);
                        }
-                       else if ((out->extents[0]+1) > (256*16) || (out->extents[1]+1) > (256*16))
+                       else if ((out->extents[0] >> 4) + 1 > (256) || (out->extents[1] >> 4) + 1 > (256))
                        {
                                Con_Printf ("Bad surface extents, converting to fullbright polygon");
                                out->shader = &Cshader_wall_fullbright;
index 21deb6a250693c59f58377e5d8cdc4d3007f0da6..90657ed2e1b2cadb882b0ed46e9a5b5729e343d5 100644 (file)
@@ -215,7 +215,7 @@ extern rtexturepool_t *r_notexturepool;
 extern model_t *loadmodel;
 extern qbyte *mod_base;
 // sky/water subdivision
-extern cvar_t gl_subdivide_size;
+//extern cvar_t gl_subdivide_size;
 // texture fullbrights
 extern cvar_t r_fullbrights;
 
diff --git a/r_sky.c b/r_sky.c
index f25fc1127fe0c74e08f892206525f1a74100f8fd..3e9d9bf58945eed13182d45f2b1d768a4e3dca75 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -3,8 +3,7 @@
 
 void LoadSky_f(void);
 
-cvar_t r_skyquality = {CVAR_SAVE, "r_skyquality", "2"};
-cvar_t r_skyflush = {0, "r_skyflush", "0"};
+cvar_t r_sky = {CVAR_SAVE, "r_sky", "1"};
 
 static char skyworldname[1024];
 rtexture_t *solidskytexture;
@@ -15,7 +14,6 @@ static rtexturepool_t *skytexturepool;
 
 int skyrendernow;
 int skyrendermasked;
-int skyrenderglquake;
 
 static void r_sky_start(void)
 {
@@ -43,8 +41,7 @@ static void r_sky_newmap(void)
 void R_Sky_Init(void)
 {
        Cmd_AddCommand ("loadsky", &LoadSky_f);
-       Cvar_RegisterVariable (&r_skyquality);
-       Cvar_RegisterVariable (&r_skyflush);
+       Cvar_RegisterVariable (&r_sky);
        R_RegisterModule("R_Sky", r_sky_start, r_sky_shutdown, r_sky_newmap);
 }
 
@@ -56,31 +53,16 @@ void R_SkyStartFrame(void)
        skyrendernow = false;
        skyrendersphere = false;
        skyrenderbox = false;
-       skyrenderglquake = false;
        skyrendermasked = false;
-       if (r_skyquality.integer >= 1 && !fogenabled)
+       if (r_sky.integer && !fogenabled)
        {
                if (skyavailable_box)
                        skyrenderbox = true;
                else if (skyavailable_quake)
-               {
-                       switch(r_skyquality.integer)
-                       {
-                       case 1:
-                               skyrenderglquake = true;
-                               break;
-                       default:
-                       case 2:
-                               skyrendersphere = true;
-                               break;
-                       }
-               }
-               if (skyrenderbox || skyrendersphere)
-               {
-                       // for depth-masked sky, render the sky on the first sky surface encountered
-                       skyrendernow = true;
-                       skyrendermasked = true;
-               }
+                       skyrendersphere = true;
+               // for depth-masked sky, render the sky on the first sky surface encountered
+               skyrendernow = true;
+               skyrendermasked = true;
        }
 }
 
@@ -185,6 +167,7 @@ static void R_SkyBox(void)
        m.transparent = false;
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
+       m.depthdisable = true; // don't modify or read zbuffer
        m.numtriangles = 2;
        m.numverts = 4;
        m.tex[0] = R_GetTexture(skyboxside[3]); // front
@@ -354,6 +337,7 @@ static void R_SkySphere(void)
        m.transparent = false;
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
+       m.depthdisable = true; // don't modify or read zbuffer
        m.numtriangles = skygridx*skygridy*2;
        m.numverts = skygridx1*skygridy1;
        m.tex[0] = R_GetTexture(solidskytexture);
@@ -377,12 +361,24 @@ void R_Sky(void)
        if (skyrendermasked)
        {
                if (skyrendersphere)
+               {
+                       // this does not modify depth buffer
                        R_SkySphere();
+               }
                else if (skyrenderbox)
+               {
+                       // this does not modify depth buffer
                        R_SkyBox();
-
-               // clear the zbuffer that was used while rendering the sky
-               R_Mesh_ClearDepth();
+               }
+               /* this will be skyroom someday
+               else
+               {
+                       // this modifies the depth buffer so we have to clear it afterward
+                       //R_SkyRoom();
+                       // clear the depthbuffer that was used while rendering the skyroom
+                       //R_Mesh_ClearDepth();
+               }
+               */
        }
 }
 
index 2cac4ff000ea9bf49844443db8f8fc56d7d02318..cecb01c0d7c61d5f9d8d146c17bda30282e76046 100644 (file)
--- a/render.h
+++ b/render.h
@@ -33,11 +33,11 @@ extern float fog_density, fog_red, fog_green, fog_blue;
 
 // sky stuff
 extern int R_SetSkyBox(char* sky);
-extern cvar_t r_skyquality;
+extern cvar_t r_sky;
 // these are exposed because surface rendering uses them
 extern rtexture_t *solidskytexture;
 extern rtexture_t *alphaskytexture;
-extern int skyrendernow, skyrendermasked, skyrenderglquake;
+extern int skyrendernow, skyrendermasked;
 extern void R_SkyStartFrame(void);
 extern void R_Sky(void);
 
@@ -95,7 +95,6 @@ extern        cvar_t  r_speeds;
 extern cvar_t  r_fullbright;
 extern cvar_t  r_wateralpha;
 extern cvar_t  r_dynamic;
-extern cvar_t  r_waterripple;
 
 void R_Init (void);
 void R_RenderView (void); // must set r_refdef first